diff --git a/AGENTS.md b/AGENTS.md index 2cafdb88a..bdc3f2155 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,10 +11,8 @@ An empty provider disables chat; exactly `anthropic` or `openai` requires that provider's key. Ignore AI credentials and endpoints when chat is disabled; validate only the selected provider's endpoint. -- For the first Pitot alpha, `internal/config/loader.go` resolves legacy - `FANOUT_*` only when the equivalent primary name is unset. Preserve explicit - empty primaries and emit one names-only warning. See `CHANGELOG.md` for the - removal window and storage compatibility names. +- Only the current `PITOT_*` custom environment names are read; the + pre-rename environment variable prefix is no longer supported. - Every `secret:"true"` field accepts `_FILE`. Both forms nonempty fail; secret files lose exactly one trailing LF or CRLF and must remain nonempty. Unselected AI providers' value and file forms are ignored. diff --git a/CHANGELOG.md b/CHANGELOG.md index fd755a47b..138cbebf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased — Pitot rename (2026-11-11) -The product is now **Pitot** (pronounced **PEE-toh**), formerly Fanout, at +The product is now **Pitot** (pronounced **PEE-toh**) at [pitot.dev](https://pitot.dev). The owner approved this rename on 2026-11-11 to avoid a conflict with a third party's registered US trademark in cloud services. @@ -11,25 +11,39 @@ conflict with a third party's registered US trademark in cloud services. - Container images are `ghcr.io/labstack/pitot` and `docker.io/labstack/pitot`. Update deployment manifests, service names, install URLs and MCP client entries. The MCP Registry identity is `io.github.labstack/pitot`. -- Use `PITOT_*` settings. For the first Pitot alpha only, an unset primary - variable falls back to its `FANOUT_*` equivalent, including secret `_FILE` - forms and installer version/prefix overrides. A primary variable explicitly - set to empty blocks its legacy equivalent and uses the ordinary default. - Startup emits one deprecation warning listing used old names, never values. - Mixed value/file forms still fail when both are nonempty. Replace old names - before upgrading to the following alpha, when this bridge is due for removal. -- Keep the complete existing data directory. Native default `./data`, the - `control/fanout.sqlite` filename, all other storage filenames, telemetry format, - marker files, Parquet `fanout.spill.*` footer keys, stored - `_fanout_diagnostic_context` metadata and published migrations are unchanged; there is no data migration. - The new image defaults to `/var/lib/pitot/data`: mount the **existing** volume - there, or explicitly set `PITOT_DATA_DIR` to its existing mount location. - Do not accidentally create a fresh named volume when changing deployment names. -- Existing sessions keep their cookie names and keyboard preferences keep their - storage key. Saved chat activities resolve their old MCP App resource URI to - the new URI in memory, without rewriting history. Existing ingest and OAuth secrets - remain valid; token prefixes (`foi_`, `foa_`, `for_`, `foc_`) are unchanged for - both existing and new tokens because there is no central token-prefix registry. +- The server and installer refuse to start if any variable with the exact, + case-sensitive pre-rename prefix is set, including empty assignments, + installer overrides and secret-file settings. The error lists names only. + Rename those variables to `PITOT_*` before upgrading; they no longer silently + use defaults. +- The query language is now **PitotQL**. Existing structured dashboard queries, + MCP `query_telemetry` arguments (`text`, `panel.query`, `panel.sql`), query + keywords, Explore URL parameters and browser storage keys are unchanged. + Previous query HTTP paths and the MCP reference URI remain read aliases; + responses and new clients use canonical PitotQL names. See + [rename compatibility](site/src/content/docs/docs/reference/rename-compatibility.mdx) for the exact aliases. +- Before upgrading, stop the service and take a cold backup of the complete + data directory. On startup, Pitot automatically renames the previous control + database and its SQLite WAL, shared-memory and rollback-journal sidecars in + `control/` to `pitot.sqlite` and matching sidecar names, then syncs the directory. + No manual filename change is needed, including for unattended agent upgrades. + If both database names or an incomplete sidecar move exist, startup refuses + before opening SQLite; stop the instance and recover a consistent file set + from the cold backup before retrying. Never delete a database just to bypass + this refusal or create a fresh volume by accident. For rollback to the previous + binary, restore its complete cold backup before starting it; older binaries + do not move the database name back. +- Telemetry spill footer keys retain their persisted format-5 spelling so + existing Parquet files remain valid and byte compatibility stays unchanged. +- Sessions use the `pitot_session` cookie (with the `__Host-` prefix over HTTPS), + so users must sign in again. Keyboard shortcut preferences reset. Saved chat + activities using the previous MCP App URI no longer render; begin a new chat. + Reserved diagnostic context metadata now uses `_pitot_diagnostic_context`; + discard pre-rename chat history before resuming chat. +- Published SQL migrations remain unchanged. Existing ingest and OAuth secrets + and their token prefixes remain valid. The image defaults to + `/var/lib/pitot/data`: mount the existing volume there, or set `PITOT_DATA_DIR` + to its existing mount location. - HTTP request headers and metrics use the Pitot name. Update custom clients using the product request header to `Pitot-Request` (and dashboard deletion confirmation to `Pitot-Confirm-Delete`), and update Prometheus diff --git a/README.md b/README.md index 7bba473df..0338945ff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Pitot -Pitot (pronounced **PEE-toh**), formerly Fanout. +Pitot (pronounced **PEE-toh**). **Observability your agents can operate.** Send OpenTelemetry to one binary, then investigate with Pitot's built-in agent or connect your own over MCP. @@ -12,11 +12,11 @@ Pitot's built-in agent or connect your own over MCP. - A Pitot dashboard the built-in agent built from one request: store request rate, error rate, p95 latency and error logs, with request and error rates by service. + Pitot Store overview - last hour: request rate, error rate, p95 latency and error logs, with request rate, error rate and p95 latency by service. -*Preview capture from the pre-rename alpha.* +*Current Pitot interface with deterministic offline sample telemetry.* Pitot keeps OpenTelemetry traces, logs, and metrics in one binary and one data directory, with no external storage services to operate. Pitot is pre-release and changes without migration paths; the browser @@ -25,7 +25,7 @@ client, built-in agent, MCP tools, dashboards, and alerts are preview capabiliti [documentation](https://pitot.dev) or run it below. - OTLP ingest over gRPC and HTTP, with local Parquet storage and DuckDB analytics. -- Explore and FanQL for querying telemetry without an AI provider. +- Explore and PitotQL for querying telemetry without an AI provider. - An investigation agent that answers questions about your telemetry in plain language. - An MCP server for external agents using the same typed query tools. - Dashboards across traces, logs, and metrics, and alerts on service error rate, latency, diff --git a/cmd/pitot-docgen/main.go b/cmd/pitot-docgen/main.go index 297da4a22..bab2f0840 100644 --- a/cmd/pitot-docgen/main.go +++ b/cmd/pitot-docgen/main.go @@ -40,7 +40,7 @@ import ( "github.com/labstack/pitot/internal/alert" "github.com/labstack/pitot/internal/config" - "github.com/labstack/pitot/internal/fanql" + "github.com/labstack/pitot/internal/pitotql" ) func main() { @@ -117,7 +117,7 @@ func run(source, alertSource, routeDirs, outDir, envExample string, check bool) return err } pages["mcp.mdx"] = toolsPage - pages["fanql.md"] = []byte("---\ntitle: \"FanQL\"\ndescription: \"The preview text syntax for structured telemetry queries.\"\nsummary: \"FanQL syntax, fields, functions, variables, null semantics and examples, generated from query registries.\"\nread_when:\n - \"You are writing a FanQL query and need syntax or field names.\"\nstatus: preview\ngenerated: true\n---\n\n" + fanql.Reference()) + pages["pitotql.md"] = []byte("---\ntitle: \"PitotQL\"\ndescription: \"The preview text syntax for structured telemetry queries.\"\nsummary: \"PitotQL syntax, fields, functions, variables, null semantics and examples, generated from query registries.\"\nread_when:\n - \"You are writing a PitotQL query and need syntax or field names.\"\nstatus: preview\ngenerated: true\n---\n\n" + pitotql.Reference()) outputs := map[string][]byte{envExample: renderEnvironment(fields)} for name, body := range pages { @@ -555,7 +555,7 @@ func renderPage(name string, page groupPage, fields []field) []byte { b.WriteString("Every setting below is read once at startup and requires a restart to change.\n") b.WriteString("Built-in defaults are overridden by nonempty environment values.\n") - b.WriteString("For the first Pitot alpha, unset `PITOT_` variables accept `FANOUT_` equivalents with a names-only deprecation warning. Explicitly empty primary variables block fallback.\n") + b.WriteString("The pre-rename environment variable prefix is no longer read. Use `PITOT_` settings.\n") b.WriteString("Unknown `PITOT_` names fail startup; platform-injected service names are tolerated.\n") b.WriteString("Vendor credentials and endpoints keep the vendor's documented names.\n\n") if name == "ai" { diff --git a/cmd/pitot-docgen/main_test.go b/cmd/pitot-docgen/main_test.go index 15dd97e44..37036b024 100644 --- a/cmd/pitot-docgen/main_test.go +++ b/cmd/pitot-docgen/main_test.go @@ -7,18 +7,18 @@ import ( "testing" "github.com/labstack/pitot/internal/config" - "github.com/labstack/pitot/internal/fanql" + "github.com/labstack/pitot/internal/pitotql" ) const configSource = "../../internal/config/config.go" -func TestDocgenWritesFanQLReference(t *testing.T) { +func TestDocgenWritesPitotQLReference(t *testing.T) { dir := t.TempDir() out := filepath.Join(dir, "reference") if err := run(configSource, "../../internal/alert/types.go", strings.Join(routeDirs, ","), out, filepath.Join(dir, ".env.example"), false); err != nil { t.Fatal(err) } - raw, err := os.ReadFile(filepath.Join(out, "fanql.md")) + raw, err := os.ReadFile(filepath.Join(out, "pitotql.md")) if err != nil { t.Fatal(err) } @@ -27,7 +27,7 @@ func TestDocgenWritesFanQLReference(t *testing.T) { t.Fatal("missing site front matter") } _, content, ok := strings.Cut(page, "\n---\n\n") - if !ok || content != fanql.Reference() { + if !ok || content != pitotql.Reference() { t.Fatalf("page content differs from the API/MCP reference: %q", page) } } diff --git a/cmd/pitot/main.go b/cmd/pitot/main.go index 441b9b065..20f025b3f 100644 --- a/cmd/pitot/main.go +++ b/cmd/pitot/main.go @@ -64,6 +64,11 @@ type loginLinkCommand struct { } func main() { + if err := store.RejectPreviousEnvironment(os.Environ()); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } + showVersion, loginLink, healthURL, derivedProbe, repair, err := parseCommandLine(os.Args[1:], os.Stderr) if errors.Is(err, flag.ErrHelp) { return @@ -78,7 +83,7 @@ func main() { var healthEnvironment map[string]string if healthURL != "" || derivedProbe { healthEnvironment = make(map[string]string) - for _, assignment := range config.ResolveEnvironment(os.Environ()) { + for _, assignment := range os.Environ() { name, value, _ := strings.Cut(assignment, "=") healthEnvironment[name] = value } @@ -316,7 +321,7 @@ func main() { panels.SetRollupReader(queries) panels.SetCacheTTL(cfg.QueryCacheTTL) api.RegisterQueryRoutes(e, panels) - api.RegisterFanQLRoutes(e, q, panels) + api.RegisterPitotQLRoutes(e, q, panels) api.RegisterAnnotationRoutes(e, annotations.New(q)) api.RegisterTraceRoutes(e, panels.CachedTraces(queries), cfg.RetentionDays) api.RegisterIntelligenceRoutes(e, detector) @@ -711,6 +716,9 @@ func createLoginLink(cfg config.Config, rawEmail string, breakGlass bool, output if err != nil { return err } + if err := store.MigrateControlDatabase(cfg.ControlSQLitePath()); err != nil { + return err + } if _, err := os.Stat(cfg.ControlSQLitePath()); err != nil { if errors.Is(err, os.ErrNotExist) { return fmt.Errorf("control database does not exist at %s", cfg.ControlSQLitePath()) diff --git a/cmd/pitot/main_test.go b/cmd/pitot/main_test.go index 274d61c0a..9b24c0aa1 100644 --- a/cmd/pitot/main_test.go +++ b/cmd/pitot/main_test.go @@ -1,6 +1,7 @@ package main import ( + "bufio" "bytes" "context" "crypto/ecdsa" @@ -824,3 +825,70 @@ func TestApplyConfiguredIngestTokenLogsWithoutToken(t *testing.T) { t.Fatalf("logs must report both outcomes by setting name: %s", output) } } + +func TestStartupRefusesRetiredEnvironmentBeforeStores(t *testing.T) { + if os.Getenv("TEST_STARTUP_CHILD") == "1" { + os.Args = []string{"pitot"} + main() + return + } + for _, retired := range []bool{true, false} { + t.Run(map[bool]string{true: "retired", false: "current"}[retired], func(t *testing.T) { + root := filepath.Join(t.TempDir(), "data") + ctx, cancel := context.WithTimeout(t.Context(), 30*time.Second) + defer cancel() + command := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestStartupRefusesRetiredEnvironmentBeforeStores$") + command.Env = []string{"TEST_STARTUP_CHILD=1", "PATH=" + os.Getenv("PATH"), "PITOT_DATA_DIR=" + root, "PITOT_ADDR=127.0.0.1:0", "PITOT_MCP_ENABLED=false", "PITOT_AUTH_CODE_SECRET=" + strings.Repeat("x", 32)} + // Test fixture for the exact retired prefix; production spelling is isolated. + const previous = "FANOUT_" + if retired { + command.Env = append(command.Env, previous+"DATA_DIR=private-value", previous+"TOKEN=") + output, err := command.CombinedOutput() + if err == nil || !strings.Contains(string(output), previous+"DATA_DIR") || !strings.Contains(string(output), previous+"TOKEN") || !strings.Contains(string(output), "rename them to PITOT_") || strings.Contains(string(output), "private-value") { + t.Fatalf("refusal: %s, %v", output, err) + } + if _, err := os.Stat(root); !os.IsNotExist(err) { + t.Fatalf("data directory touched before refusal: %v", err) + } + return + } + pipe, err := command.StderrPipe() + if err != nil { + t.Fatal(err) + } + if err := command.Start(); err != nil { + t.Fatal(err) + } + ready := make(chan bool, 1) + go func() { + scanner := bufio.NewScanner(pipe) + for scanner.Scan() { + if strings.Contains(scanner.Text(), "HTTP and OTLP listening") { + ready <- true + return + } + } + ready <- false + }() + select { + case started := <-ready: + if !started { + _ = command.Wait() + t.Fatal("current environment did not start") + } + if err := command.Process.Signal(os.Interrupt); err != nil { + t.Fatal(err) + } + if err := command.Wait(); err != nil { + t.Fatal(err) + } + if _, err := os.Stat(filepath.Join(root, "control", "pitot.sqlite")); err != nil { + t.Fatal(err) + } + case <-ctx.Done(): + _ = command.Wait() + t.Fatal("startup timed out") + } + }) + } +} diff --git a/docs/adr/0006-one-structured-query-path.md b/docs/adr/0006-one-structured-query-path.md index 02682f8bb..dba72675e 100644 --- a/docs/adr/0006-one-structured-query-path.md +++ b/docs/adr/0006-one-structured-query-path.md @@ -5,7 +5,7 @@ Date: 2026-10-30 ## Context -Telemetry is queried from dashboards, FanQL text, MCP tools and the agent, and +Telemetry is queried from dashboards, PitotQL text, MCP tools and the agent, and a visual builder is planned. Separate query paths would each need their own validation, limits and SQL generation, and could diverge. @@ -13,7 +13,7 @@ limits and SQL generation, and could diverge. Every surface produces the same validated structured query (`from`, `where`, `measures`, `by`, `bucket`, `histogram`, `sort`, `limit`), which one engine path -validates, budgets and turns into SQL. FanQL is the text form of that query and +validates, budgets and turns into SQL. PitotQL is the text form of that query and compiles to it; its filters become predicates inside the query, checked by the same validation, and it never runs SQL of its own. Arbitrary read-only SQL remains a separate, locked-down gate for what the structured query cannot express. @@ -21,6 +21,6 @@ separate, locked-down gate for what the structured query cannot express. ## Consequences - One place enforces relations, functions and budgets. -- A FanQL query executes through the same engine path as the equivalent +- A PitotQL query executes through the same engine path as the equivalent dashboard panel. - New query features are added once and become available everywhere. diff --git a/docs/adr/0007-hand-written-fanql-parser.md b/docs/adr/0007-hand-written-pitotql-parser.md similarity index 72% rename from docs/adr/0007-hand-written-fanql-parser.md rename to docs/adr/0007-hand-written-pitotql-parser.md index 54d76f10a..3a9e6df3b 100644 --- a/docs/adr/0007-hand-written-fanql-parser.md +++ b/docs/adr/0007-hand-written-pitotql-parser.md @@ -1,17 +1,17 @@ -# 0007. A hand-written FanQL parser +# 0007. A hand-written PitotQL parser Status: Accepted Date: 2026-10-30 ## Context -FanQL needs precise, recovering diagnostics with source spans and suggested +PitotQL needs precise, recovering diagnostics with source spans and suggested fixes, position-aware completion, and canonical printing, all fast enough to run on every keystroke. ## Decision -FanQL uses a hand-written lexer and recursive-descent parser in Go, with no +PitotQL uses a hand-written lexer and recursive-descent parser in Go, with no parser-generator or grammar library. It recovers after errors so it can report every independent problem in one pass. diff --git a/docs/adr/0008-batch-format-5.md b/docs/adr/0008-batch-format-5.md index 1a448c5da..c0297a04e 100644 --- a/docs/adr/0008-batch-format-5.md +++ b/docs/adr/0008-batch-format-5.md @@ -32,7 +32,7 @@ Format 5 replaces format 4 and supersedes the format half of ADR 0003. service and time. Metrics sort by namespace, service, name, hour, series and time. - Reads rewrite `attributes['k']` and `resource['k']` for a standard key to - its column on the parsed SQL, so FanQL, structured panels and SQL share one + its column on the parsed SQL, so PitotQL, structured panels and SQL share one rule and read the converted value. Users never name the columns, and result stars leave them out. - SQL rejects `GROUP BY ALL`, because the pinned engine groups its keys diff --git a/docs/adr/README.md b/docs/adr/README.md index 0d9b92238..36bf0b47a 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -31,6 +31,6 @@ Date: YYYY-MM-DD | 0004 | [No legacy paths](0004-no-legacy-paths.md) | Accepted | | 0005 | [CalVer releases](0005-calver-releases.md) | Accepted | | 0006 | [One structured query path](0006-one-structured-query-path.md) | Accepted | -| 0007 | [A hand-written FanQL parser](0007-hand-written-fanql-parser.md) | Accepted | +| 0007 | [A hand-written PitotQL parser](0007-hand-written-pitotql-parser.md) | Accepted | | 0008 | [Batch format 5](0008-batch-format-5.md) | Accepted | | 0009 | [Ingest admission at saturation](0009-ingest-admission-at-saturation.md) | Accepted | diff --git a/docs/diagrams/architecture.json b/docs/diagrams/architecture.json index 6857b924e..a4a315cf5 100644 --- a/docs/diagrams/architecture.json +++ b/docs/diagrams/architecture.json @@ -7,10 +7,10 @@ "quality_profile": "showcase", "locale": "en", "repository": { - "url": "https://github.com/labstack/fanout.git", + "url": "https://github.com/labstack/pitot.git", "provider": "github", "link_mode": "web", - "revision": "681d46ba8cf0a92ea85764bfa4736a8e2739a8c9" + "revision": "f897cc132aa38926716de4c61e9bf2d0dff79aa9" } }, "components": [ @@ -55,9 +55,7 @@ "end_line": 30 }, { - "path": "cmd/fanout/main.go", - "line": 390, - "end_line": 393 + "path": "cmd/pitot/main.go" } ] }, @@ -97,9 +95,7 @@ ], "sources": [ { - "path": "cmd/fanout/main.go", - "line": 357, - "end_line": 369 + "path": "cmd/pitot/main.go" } ] }, @@ -128,9 +124,7 @@ "end_line": 89 }, { - "path": "cmd/fanout/main.go", - "line": 207, - "end_line": 209 + "path": "cmd/pitot/main.go" } ] }, @@ -149,14 +143,10 @@ ], "sources": [ { - "path": "cmd/fanout/main.go", - "line": 186, - "end_line": 190 + "path": "cmd/pitot/main.go" }, { - "path": "cmd/fanout/main.go", - "line": 299, - "end_line": 299 + "path": "cmd/pitot/main.go" }, { "path": "internal/api/oidc.go", @@ -180,9 +170,7 @@ ], "sources": [ { - "path": "cmd/fanout/main.go", - "line": 372, - "end_line": 385 + "path": "cmd/pitot/main.go" }, { "path": "internal/agent/runtime.go", @@ -206,9 +194,7 @@ ], "sources": [ { - "path": "cmd/fanout/main.go", - "line": 356, - "end_line": 371 + "path": "cmd/pitot/main.go" }, { "path": "internal/mcp/server.go", @@ -258,9 +244,7 @@ ], "sources": [ { - "path": "cmd/fanout/main.go", - "line": 277, - "end_line": 284 + "path": "cmd/pitot/main.go" } ] }, @@ -279,19 +263,13 @@ ], "sources": [ { - "path": "internal/query/duck.go", - "line": 240, - "end_line": 244 + "path": "internal/query/exec.go" }, { - "path": "internal/query/duck.go", - "line": 505, - "end_line": 522 + "path": "internal/query/exec.go" }, { - "path": "internal/query/duck.go", - "line": 627, - "end_line": 653 + "path": "internal/query/exec.go" } ] }, @@ -320,9 +298,7 @@ "end_line": 291 }, { - "path": "cmd/fanout/main.go", - "line": 161, - "end_line": 162 + "path": "cmd/pitot/main.go" } ] }, @@ -341,9 +317,7 @@ ], "sources": [ { - "path": "cmd/fanout/main.go", - "line": 173, - "end_line": 183 + "path": "cmd/pitot/main.go" }, { "path": "internal/alert/engine.go", @@ -445,9 +419,7 @@ "end_line": 30 }, { - "path": "cmd/fanout/main.go", - "line": 165, - "end_line": 170 + "path": "cmd/pitot/main.go" } ] } diff --git a/docs/diagrams/persistence.json b/docs/diagrams/persistence.json index b812b1cb2..153367bd4 100644 --- a/docs/diagrams/persistence.json +++ b/docs/diagrams/persistence.json @@ -7,7 +7,7 @@ "quality_profile": "showcase", "locale": "en", "repository": { - "url": "https://github.com/labstack/fanout.git", + "url": "https://github.com/labstack/pitot.git", "provider": "github", "link_mode": "web", "revision": "681d46ba8cf0a92ea85764bfa4736a8e2739a8c9" diff --git a/docs/proposals/0004-fanql.md b/docs/proposals/0004-pitotql.md similarity index 88% rename from docs/proposals/0004-fanql.md rename to docs/proposals/0004-pitotql.md index b7b164382..1d0e7d095 100644 --- a/docs/proposals/0004-fanql.md +++ b/docs/proposals/0004-pitotql.md @@ -2,7 +2,7 @@ Status: Accepted Date: 2026-10-29 -Pull request: #410 (section 0, FanQL); sections 1 to 5 are not yet built +Pull request: #410 (section 0, PitotQL); sections 1 to 5 are not yet built ## Intent @@ -11,7 +11,7 @@ Pitot must be fully usable when no AI provider is configured (`PITOT_AI_PROVIDER ## Goals - Every capability chat offers for dashboards, queries, logs, traces and alerts has a direct UI path that works without AI. -- One query model: the existing structured panel query (`from`, `where`, `measures`, `by`, `bucket`, `histogram`, `sort`, `limit`), viewed and edited as FanQL text (section 0) or in a visual builder, plus the existing read-only DuckDB SQL gate for anything the structured query cannot express. +- One query model: the existing structured panel query (`from`, `where`, `measures`, `by`, `bucket`, `histogram`, `sort`, `limit`), viewed and edited as PitotQL text (section 0) or in a visual builder, plus the existing read-only DuckDB SQL gate for anything the structured query cannot express. - One renderer: every result renders through the existing `PanelCard` and panel engine. No second chart, table, log or trace path. - AI affordances (Ask, Explain, Fix, the chat rail) are hidden when chat is disabled, so nothing is a dead button. @@ -37,9 +37,9 @@ Pitot must be fully usable when no AI provider is configured (`PITOT_AI_PROVIDER ## Design -### 0. FanQL, the text query syntax (owner-approved 2026-10-29; preview) +### 0. PitotQL, the text query syntax (owner-approved 2026-10-29; preview) -FanQL is the one-line text form of the structured panel query. Text parses into the same `panel.Query` that panels store and execute, and every valid query formats back to text; panels keep storing the query and the text is derived. One hand-written lexer and recursive-descent parser in Go (`internal/fanql`, with Pratt parsing for the boolean and arithmetic layers) serves the API, MCP and the UI; the UI calls an endpoint and ships no second parser. The syntax is preview: it may change before GA. +PitotQL is the one-line text form of the structured panel query. Text parses into the same `panel.Query` that panels store and execute, and every valid query formats back to text; panels keep storing the query and the text is derived. One hand-written lexer and recursive-descent parser in Go (`internal/pitotql`, with Pratt parsing for the boolean and arithmetic layers) serves the API, MCP and the UI; the UI calls an endpoint and ships no second parser. The syntax is preview: it may change before GA. **Two contracts.** The *interactive language* is the text, bounded for editing (0.13). The *exact interchange form* is the structured `Query` itself: every envelope may carry it, and clients that cannot parse text use it. `Format` is total over valid queries and never truncates; text beyond the interactive bounds is returned complete and marked `editable: false` (0.11). @@ -149,25 +149,25 @@ Tokens: `Word`, `Ident`, `Path` (measure context only), `String`, `Raw`, `Bracke | Modifiers | `as asc desc` | after a measure; after a sort key | | Buckets | `auto` and the twelve buckets | after `every` | | Stage names | `histogram`, `count_if`, the measure functions | after `\|` and `,` | -| Reserved | `let join correlate compare since until top eval extend having fields rename over window` | clause position only; `"join" is reserved for a future FanQL feature`, hint `quote it to search for the word` | +| Reserved | `let join correlate compare since until top eval extend having fields rename over window` | clause position only; `"join" is reserved for a future PitotQL feature`, hint `quote it to search for the word` | | Foreign | see below | unmistakable syntax only | Rules, each with fixtures in the corpus: -1. **Source.** `spans`, `logs`, `metrics` are recognised only as the first token; elsewhere they are words. Missing or unknown: `unknown source "X"`, hint `use spans, logs or metrics`; `traces` gets `use spans; traces is a viz of spans`; `from spans` gets `"from" is not FanQL; start with the source: spans where ...`. A bare source (`logs`) is valid: all rows under the viz's defaults. +1. **Source.** `spans`, `logs`, `metrics` are recognised only as the first token; elsewhere they are words. Missing or unknown: `unknown source "X"`, hint `use spans, logs or metrics`; `traces` gets `use spans; traces is a viz of spans`; `from spans` gets `"from" is not PitotQL; start with the source: spans where ...`. A bare source (`logs`) is valid: all rows under the viz's defaults. 2. **Clause words** are clause words only at depth 0, outside quotes and brackets, at a term boundary. After `:`, a comparison, `in (`, or inside a list they are values (`service:where`, `service in (sort, limit)`). As free text they must be quoted (`logs where "limit"`); canonical quotes them. `logs where limit 10` is `where needs a filter`, hint `quote "limit" to search for the word, or drop where`. `where` twice is `where appears twice; combine the filters into one where`. 3. **Expression words.** `not` at term start; `and`/`or` between terms (0.4); `in between is like ilike` after a field; `null` after `is [not]`; `and` inside `between`, which consumes its own `and` before conjunction parsing. Elsewhere they are ordinary words (`logs where in` searches "in"). A missing upper bound is `between needs two values`. 4. **Field vs free text.** A word is a field only when the next token is `:`, a comparison operator, `~`/`!~`, or one of `in`, `not in`, `between`, `not between`, `is`, `like`, `ilike`, `not like`, `not ilike`. Otherwise it is free text, whether or not it names a column (`logs where service` searches `body` for "service", with the notice `"service" is a field; did you mean service:?`). Meaning never depends on schema discovery. 5. **`:` ends a word.** `http.target:/a:b` tokenises as `http.target` `:` `/a` `:` `b`; the parser reports `unexpected : after /a`, hint `quote the value: http.target:"/a:b"`, over the whole whitespace-delimited run. The same for `http://x:8080/y` typed as free text. -6. **Comparison punctuation** `: = != <> > >= < <= ~ !~` are their own tokens, longest match first; whitespace around them is irrelevant. A bare `!` is `! negation is not FanQL`; `~~` is `~~ is SQL LIKE; use like, ilike or ~`. +6. **Comparison punctuation** `: = != <> > >= < <= ~ !~` are their own tokens, longest match first; whitespace around them is irrelevant. A bare `!` is `! negation is not PitotQL`; `~~` is `~~ is SQL LIKE; use like, ilike or ~`. 7. **Signs.** After a value-expecting operator (`:`, a comparison, `in (`, `,` in a list, `between` bounds) a `-` followed by a digit or `.digit` is a numeric sign (`value>-3`; `duration>-1ms` is then `durations are not negative`). Anywhere else a leading `-` is negation (`-duration>1s` negates the term). `+` at token start is legal only after `sort` and in exponents; elsewhere `unexpected +`. Inside a word both are ordinary (`us-east-1`, `web+api`). Repeated negation parses (`--a`, `not not a`, `-not a`, depth-bounded); canonical prints one `-` for odd, none for even. 8. **Value classification.** In value position the classifier tries duration, then number, then boolean, then word. In field position a number-shaped token is `a filter needs a field before >`. 9. **Calls.** An identifier immediately followed by `(` is a call. In `where` the name must be a filter function (`lower upper starts_with contains regexp_matches length`); `spans where P95(Duration)` is `function p95 is not allowed in a filter`. Arguments are typed by signature: `starts_with(field, string)`, `contains(field, string)`, `regexp_matches(field, string)`, `lower(field)`, `upper(field)`, `length(field)`. A bare word in a `string` slot is `starts_with needs a quoted string`. `length`, `lower`, `upper` must be compared (`length(...) needs a comparison`); `starts_with`, `contains`, `regexp_matches` are predicates alone. A space before `(` is `write starts_with(...) without a space`. 10. **Optional `where`.** `where` may be omitted after the source; canonical prints it whenever a filter is present. Search bars never contain it and reject it. -11. **Foreign syntax** gets a hint, never an alias, and only on unmistakable syntax: a known foreign stage command directly after `|` (`stats summarize select project extend eval fields rename take head top order sort by`), `head N`/`take N` and `order by`/`group by`/`facet` at a clause position (`group by` after measures has the fix-it `by`), a foreign call shape at stage position (`bin( span( percentile( perc95( pct( count_over_time( quantile_over_time( avg( mean( median( dc( distinct_count( cardinality(`), `from`, `index=`, `source=`, `search` as the first token, `ago(`, `now(`, `earliest=`, `_time:`, `since`/`until` at clause position, the operators `== =~ |= |~ ::`, `{` at term start, `@word:`, `!word:`. A bare foreign word in filter position is free text. Messages name the FanQL form: `"summarize" is not FanQL; write the measures after |, e.g. | count() by service`; `== is not FanQL; use key:value or =`; `=~ is not FanQL; ~ is contains; use regexp_matches(field, 're') for a regular expression`; `{ selectors are not FanQL; write labels as key:value, e.g. service:api`; `"@http.target" is not a field name; write the attribute without @: http.target`; `! negation is not FanQL; write -service:api`; `the time range is not part of FanQL; use the time picker (since is reserved)`. +11. **Foreign syntax** gets a hint, never an alias, and only on unmistakable syntax: a known foreign stage command directly after `|` (`stats summarize select project extend eval fields rename take head top order sort by`), `head N`/`take N` and `order by`/`group by`/`facet` at a clause position (`group by` after measures has the fix-it `by`), a foreign call shape at stage position (`bin( span( percentile( perc95( pct( count_over_time( quantile_over_time( avg( mean( median( dc( distinct_count( cardinality(`), `from`, `index=`, `source=`, `search` as the first token, `ago(`, `now(`, `earliest=`, `_time:`, `since`/`until` at clause position, the operators `== =~ |= |~ ::`, `{` at term start, `@word:`, `!word:`. A bare foreign word in filter position is free text. Messages name the PitotQL form: `"summarize" is not PitotQL; write the measures after |, e.g. | count() by service`; `== is not PitotQL; use key:value or =`; `=~ is not PitotQL; ~ is contains; use regexp_matches(field, 're') for a regular expression`; `{ selectors are not PitotQL; write labels as key:value, e.g. service:api`; `"@http.target" is not a field name; write the attribute without @: http.target`; `! negation is not PitotQL; write -service:api`; `the time range is not part of PitotQL; use the time picker (since is reserved)`. 12. **Quotes, backticks, brackets.** `"` or `'` with doubling as the only escape (no backslash escapes). Unclosed quote: `unclosed quote; close the value with "`, running to the end of the text. Backticks open a raw entry (0.8); `unclosed raw filter; close it with `` ` ``. Parentheses are preserved in the token stream: `unmatched ); remove it or add the opening (` and `unclosed (; add ) before |, sort, limit or the end` with the opening span. Recovery after a bad term consumes to the next whitespace at the term's depth. -13. **`*` and `$`.** `*` is legal as `k:*`, `-k:*`, `count(*)`; elsewhere in an unquoted value it is `* wildcards are not in FanQL`, hint `use ~ for contains, or quote "api*"`. `$ident` is a variable; `$` followed by anything else is `unexpected $`; `$__` names are rejected. -14. **Second `|`.** `| sort x` and `| limit n` after the stage are accepted and canonicalised without the pipe. Any other second stage: `FanQL runs one aggregation stage`, hint `remove the second |; more stages come in a later version`. +13. **`*` and `$`.** `*` is legal as `k:*`, `-k:*`, `count(*)`; elsewhere in an unquoted value it is `* wildcards are not in PitotQL`, hint `use ~ for contains, or quote "api*"`. `$ident` is a variable; `$` followed by anything else is `unexpected $`; `$__` names are rejected. +14. **Second `|`.** `| sort x` and `| limit n` after the stage are accepted and canonicalised without the pipe. Any other second stage: `PitotQL runs one aggregation stage`, hint `remove the second |; more stages come in a later version`. 15. **Sort.** `sort key`, `sort +key`, `sort -key`, `sort key asc`, `sort key desc`. Two directions is `sort takes one direction`. Canonical: `sort key` (descending) or `sort +key`. `limit` before `sort` is `limit comes before sort here; write ... sort duration limit 10`. The key is checked against the stage's aliases (`sort "p95" must name a measure alias; aliases here: count`) or the viz's row keys (0.12). 16. **Case.** Keywords, function names, column names, units and vocabulary aliases fold case. Values, free text and attribute/resource keys keep case (`HTTP.Target` is the key `HTTP.Target`). 17. **Limits** (0.13) are each reported at a span; `limit 0` is `limit needs a whole number from 1 to 1000; e.g. limit 50`; `every 2m` is `unknown bucket "2m"; use auto or one of 10s, 30s, 1m, 5m, 10m, 15m, 30m, 1h, 3h, 6h, 12h, 1d`; `| every 1m` alone is `every needs measures first; write | count() every 1m`; a fourth `by` field is `at most 3 grouping fields`. @@ -195,7 +195,7 @@ Field position means a `where` term read as a field (0.3 rule 4), a measure argu #### 0.6 Entries and variables -The structured query stores `Where []string`; the compiler ANDs the entries and treats each entry as a unit: an entry referencing a variable set to All is removed whole; an entry whose variable has zero values compiles to `FALSE`; metric aggregates need `name = literal` as a standalone entry; deploy split, rollup scope, annotation scope, empty-panel diagnosis and `inferBetter` all read standalone equalities. FanQL therefore makes entry boundaries part of the meaning: +The structured query stores `Where []string`; the compiler ANDs the entries and treats each entry as a unit: an entry referencing a variable set to All is removed whole; an entry whose variable has zero values compiles to `FALSE`; metric aggregates need `name = literal` as a standalone entry; deploy split, rollup scope, annotation scope, empty-panel diagnosis and `inferBetter` all read standalone equalities. PitotQL therefore makes entry boundaries part of the meaning: - The tree's `Where` is an ordered list of entries. At the top level of `filters`, each whitespace- or `and`-separated term is one entry; a parenthesised group is one entry; a raw entry is one entry; an `or` chain is one entry and must be the entire filter list (otherwise it is the grouping problem of 0.4). - `where a b (c or d) (e f)` lowers to four entries: `L(a)`, `L(b)`, `(L(c) OR L(d))`, `(L(e) AND L(f))`. `where a or b` is one entry `(L(a) OR L(b))`. @@ -204,7 +204,7 @@ The structured query stores `Where []string`; the compiler ANDs the entries and Variables set to All, per construct (no backend change): -| FanQL | Entries | Under `$service` = All | +| PitotQL | Entries | Under `$service` = All | |---|---|---| | `service:$service status:error` | 2 | status filter kept | | `(service:$service status:error)` | 1 | both dropped | @@ -218,11 +218,11 @@ The reference states beside `$name`: "a filter that mentions a variable set to A #### 0.7 Null semantics and negation -`attributes['k']` is NULL when the key is absent; SQL `k != 'v'` on NULL is NULL and excludes the row. FanQL predicates are two-valued ("matched" or "not matched") and negation is negation of "matched". Negation is pushed to the leaves (negation normal form: `-(a b)` is `(-a) or (-b)`, `-(a or b)` is `(-a) (-b)`, `--a` is `a`); positive leaves are never wrapped, so the standalone-equality shape the panel depends on survives. +`attributes['k']` is NULL when the key is absent; SQL `k != 'v'` on NULL is NULL and excludes the row. PitotQL predicates are two-valued ("matched" or "not matched") and negation is negation of "matched". Negation is pushed to the leaves (negation normal form: `-(a b)` is `(-a) or (-b)`, `-(a or b)` is `(-a) (-b)`, `--a` is `a`); positive leaves are never wrapped, so the standalone-equality shape the panel depends on survives. -**Rule: prefix negation (`-`, `not`, and FanQL's own `!~`) includes rows missing the field; SQL-spelled infix negation (`!=`, `<>`, `not in`, `not like`, `not between`) keeps SQL three-valued semantics**, so stored SQL negatives lift exactly. +**Rule: prefix negation (`-`, `not`, and PitotQL's own `!~`) includes rows missing the field; SQL-spelled infix negation (`!=`, `<>`, `not in`, `not like`, `not between`) keeps SQL three-valued semantics**, so stored SQL negatives lift exactly. -| Row has `k = v` | `k = w` | `k` missing | FanQL | Lowered | +| Row has `k = v` | `k = w` | `k` missing | PitotQL | Lowered | |---|---|---|---|---| | T | F | F | `k:v`, `k=v` | `k = 'v'` | | F | T | **T** | `-k:v`, `not k:v` | `(k IS NULL OR k != 'v')` | @@ -292,11 +292,11 @@ Aliases apply only under `:`, `=`, `!=`, `<>`, `-`/`not`, `in`, `not in`. Under Any other word under `severity:` is uppercased, as ingestion does for unknown levels, with the notice `not a standard level; stored levels in this window: …` when schema values are available. `status:fail` is `unknown status "fail"; use status:error, status:ok or status:unset`; `kind:http` likewise. -The severity alias table is **the same table ingestion uses**: `normalizeSeverity`, `severityFromText` and the rank order move to `internal/telemetry/severity.go` and are imported by `ingest` and `fanql`; no behaviour change in ingestion. +The severity alias table is **the same table ingestion uses**: `normalizeSeverity`, `severityFromText` and the rank order move to `internal/telemetry/severity.go` and are imported by `ingest` and `pitotql`; no behaviour change in ingestion. **Bands and ranges.** Every stored log row's `severity` is `normalizeSeverity(text, number)`: a positive `severity_number` determines the band (≥21 FATAL, ≥17 ERROR, ≥13 WARN, ≥9 INFO, ≥5 DEBUG, ≥1 TRACE); only an absent or nonpositive number falls back to the text mapping, which yields a band, `UNSPECIFIED`, or the emitter's own uppercased word. The stored column is therefore the effective band, computed once with number authority, and ranges compare it: -| FanQL | Lowered | +| PitotQL | Lowered | |---|---| | `severity>=warn` | `severity IN ('WARN', 'ERROR', 'FATAL')` | | `severity>warn` | `severity IN ('ERROR', 'FATAL')` | @@ -327,7 +327,7 @@ Measures, as the reference documents them: **Conditional aggregates and arithmetic** are in v1 for spans and logs on aggregate vizzes (stat, gauge, timeseries, bar, table, scatter, state_timeline); not for metrics (`measure arithmetic is not available for metrics`), distributions or `log_patterns`. The structured query carries them, so this is a backend change in `internal/panel`: -- `count_if()` takes one FanQL filter list (same grammar and grouping rule as `where`, one entry); variables inside are rejected in v1; raw entries are allowed. Structured form: the expression with the inner filter in SQL, e.g. `count_if(status = 'STATUS_CODE_ERROR') / count() * 100 as err_pct`; compiled as `count(*) FILTER (WHERE )::DOUBLE`. +- `count_if()` takes one PitotQL filter list (same grammar and grouping rule as `where`, one entry); variables inside are rejected in v1; raw entries are allowed. Structured form: the expression with the inner filter in SQL, e.g. `count_if(status = 'STATUS_CODE_ERROR') / count() * 100 as err_pct`; compiled as `count(*) FILTER (WHERE )::DOUBLE`. - `+ - * /` between measure calls, numeric constants and parenthesised expressions; unary minus. `/` lowers to `a / nullif(b, 0)`; a zero denominator yields NULL. - An expression that is not a single call needs `as alias` (`name this expression with as, e.g. count() / 2 as half`). A single call keeps the auto-alias rules. - **Every output expression has at least one aggregate leaf** (a call or `count_if`); numeric constants are operands only. `1 as one`, `1 / 2 as half`, `-(5) as neg` are `a measure needs an aggregate; constants can only scale one, e.g. count() * 100`; `count() * 0 as zero` is valid. The backend enforces the rule on structured `Query.Measures` too. @@ -336,7 +336,7 @@ Measures, as the reference documents them: - `inferBetter` extends to expressions recursively: a single call is today's rule; an affine `a·x + b` takes `x`'s inference, flipped when `a < 0`; a `ratio`/`percent` whose numerator is a `count_if` over an error filter is `lower`; a `count_if(error filter)` alone is `lower`; otherwise neutral. - Apdex is written with disjoint predicates: `(count_if(duration<=500ms) + count_if(duration>500ms duration<=2s) / 2) / count() as apdex`; a span at exactly 500 ms counts once, as satisfied; the population is the rows surviving `where`; a NULL duration counts in `count()` and in neither numerator. -**Budgets** are enforced in `internal/panel` on every `Query.Measures[i]` string at parse time, whether it arrived from the builder, MCP, a stored dashboard or FanQL. They count tokens and nodes, never raw bytes, so every string accepted today (including whitespace-padded single calls) parses unchanged: +**Budgets** are enforced in `internal/panel` on every `Query.Measures[i]` string at parse time, whether it arrived from the builder, MCP, a stored dashboard or PitotQL. They count tokens and nodes, never raw bytes, so every string accepted today (including whitespace-padded single calls) parses unchanged: | Budget | Per measure | Per query | |---|---|---| @@ -347,7 +347,7 @@ Measures, as the reference documents them: | `count_if` filter text | 500 bytes (a `where` entry) | — | | Measures | — | 6 | -Problems are reported at `panels[i].query.measures[j]` with the figure and the limit (`measures[2] has 70 nodes; a measure is at most 64`); FanQL maps them to the measure's text span. Raising a budget is additive; tightening one can reject previously accepted text and must be reviewed against the corpus. +Problems are reported at `panels[i].query.measures[j]` with the figure and the limit (`measures[2] has 70 nodes; a measure is at most 64`); PitotQL maps them to the measure's text span. Raising a budget is additive; tightening one can reject previously accepted text and must be reviewed against the corpus. **Ranking of grouped series.** Grouped timeseries and two-dimension bars select `top` series by ranking the first measure over the whole window; today's rules (`error_rate` by Wilson lower bound behind a 20-sample floor regardless of `better`; numeric measures by value behind the same floor counting actual samples; count-family by value) stay, and every order ends with the compiler's deterministic tie-breakers `n DESC, d` (dimension string ascending). Expressions attach ranking metadata instead of dispatching on the root: @@ -363,26 +363,26 @@ Ineligible series (`n < 20`) follow eligible ones by `n DESC, d`; they are ranke #### 0.11 Round trip: format, lift, exactness, `editable` -`Format(q)` lifts a valid `panel.Query` to a FanQL tree and prints it. Definitions, comparing the re-lowered tree with `q` entry by entry using the internal lowering: +`Format(q)` lifts a valid `panel.Query` to a PitotQL tree and prints it. Definitions, comparing the re-lowered tree with `q` entry by entry using the internal lowering: - **Byte-exact**: every `Where[i]` and `Measures[i]` equal as Go strings; `By`, `Bucket`, `Sort`, `Limit`, `Histogram`, `From` equal. - **AST-exact (normalized)**: some `Where[i]` or `Measures[i]` strings differ while the engine's canonical rendering is equal: `RenderSQL(ParseSQL(lowered)) == RenderSQL(ParseSQL(stored))` for filters, and equality of the parsed measure (function, field, quantile, alias) for measures (so `p95( duration_ms )` formats as `p95(duration)`, normalized). -- **Raw**: a `Where[i]` whose tree contains a node FanQL has no construct for, or whose shorthand candidates all fail the exactness check, prints as a backtick entry; byte-exact by construction. -- **Equivalent** (same results on all data) is not a tier FanQL claims anywhere. +- **Raw**: a `Where[i]` whose tree contains a node PitotQL has no construct for, or whose shorthand candidates all fail the exactness check, prints as a backtick entry; byte-exact by construction. +- **Equivalent** (same results on all data) is not a tier PitotQL claims anywhere. -`Format` returns `exactness: "exact" | "normalized"` (raw entries are exact) and `notices` naming each normalized entry (`where[2] is shown as service:api; stored text is "service='api'"`). Saving from the editor writes the FanQL spelling; the UI shows the notice first. A query that fails shape validation under every viz is not formatted; `Format` returns its problems. +`Format` returns `exactness: "exact" | "normalized"` (raw entries are exact) and `notices` naming each normalized entry (`where[2] is shown as service:api; stored text is "service='api'"`). Saving from the editor writes the PitotQL spelling; the UI shows the notice first. A query that fails shape validation under every viz is not formatted; `Format` returns its problems. **Lifting through the engine's parse tree.** Stored strings are arbitrary author text and the engine's parse is the only authority on what they mean, so `Format` runs on the API side with an injected `panel.Parser`. Each `Where[i]` is parsed as `SELECT 1 FROM WHERE ()` (as `checkFilter` does) and the `where_clause` is mapped: `AND`/`OR` conjunctions to entries and groups; `NOT` to a candidate negation; comparisons with a field side and a constant or parameter side; `IN`/`NOT IN`; `BETWEEN`; `IS NULL`/`IS NOT NULL`; `~~ ~~* !~~ !~~*` to `like` forms; `contains(lower(F), lower(C))` to `~`; the engine's parse of `IN $p` to `in $p`; `attributes`/`resource` extracts and the `CAST … AS VARCHAR` inside `contains` to attribute fields; `TRY_CAST(http_status_code AS INTEGER)` under a comparison to `http_status_code`; timestamp casts to timestamps; `severity IN (contiguous bands)` to a range; `NOT coalesce((X), FALSE)` where `X` maps to a leaf to that leaf under prefix negation; the `(k IS NULL OR k = C)` family to `-k!=v`, `-k not in`, `-k not like`, `-k not between`. Anything else (`coalesce`, other casts, field-to-field, `lower(k) = 'v'`, `starts_with`, `regexp_matches`, `length`, `CASE`) is `Raw` for that entry. Measures lift through the backend expression parser; `duration_ms` prints as `duration`, attribute fields in their canonical spelling, `as alias` when stored; `Sort: "errors"` prints `sort errors`. -**Exactness gate and fallback.** The printer emits candidate text per entry and re-lowers it with the internal entry parser, whose interactive bounds are disabled (the bounded public `Parse` is never part of the gate). Shorthand candidates (`k:v`, `-k:v`, `k!=v`, `duration>500ms`, `k ~ v`, bare word, dotted key, vocabulary alias, severity range) are tried first and kept only if re-lowering is byte-exact or AST-exact. Whenever no candidate passes, **the whole original entry prints raw**, including recognised-but-incompatible trees: stored `NOT (attributes['k'] = 'v')` is raw (FanQL's only negation of `k:v` is null-inclusive); stored `NOT (k ~~ 'x%')` is raw while `k !~~ 'x%'` is `k not like "x%"`; stored `k NOT IN ('a', 'b')` is `k not in (a, b)`; stored `(attributes['k'] IS NULL OR attributes['k'] != 'v')` is `-k:v`; stored `NOT coalesce((attributes['k'] = 'v'), FALSE)` is raw (the permitted rewrite is canonical); stored `NOT coalesce((TRY_CAST(http_status_code AS INTEGER) BETWEEN 400 AND 599), FALSE)` is `-http_status_code between 400 and 599`; stored `(service IS NULL OR service IN ('a', 'b'))` is `-service not in (a, b)`. Format of a query FanQL itself produced never calls the engine: lowering is a pure function and the byte-exact check is a string comparison. +**Exactness gate and fallback.** The printer emits candidate text per entry and re-lowers it with the internal entry parser, whose interactive bounds are disabled (the bounded public `Parse` is never part of the gate). Shorthand candidates (`k:v`, `-k:v`, `k!=v`, `duration>500ms`, `k ~ v`, bare word, dotted key, vocabulary alias, severity range) are tried first and kept only if re-lowering is byte-exact or AST-exact. Whenever no candidate passes, **the whole original entry prints raw**, including recognised-but-incompatible trees: stored `NOT (attributes['k'] = 'v')` is raw (PitotQL's only negation of `k:v` is null-inclusive); stored `NOT (k ~~ 'x%')` is raw while `k !~~ 'x%'` is `k not like "x%"`; stored `k NOT IN ('a', 'b')` is `k not in (a, b)`; stored `(attributes['k'] IS NULL OR attributes['k'] != 'v')` is `-k:v`; stored `NOT coalesce((attributes['k'] = 'v'), FALSE)` is raw (the permitted rewrite is canonical); stored `NOT coalesce((TRY_CAST(http_status_code AS INTEGER) BETWEEN 400 AND 599), FALSE)` is `-http_status_code between 400 and 599`; stored `(service IS NULL OR service IN ('a', 'b'))` is `-service not in (a, b)`. Format of a query PitotQL itself produced never calls the engine: lowering is a pure function and the byte-exact check is a string comparison. **`editable`.** `Format` carries `editable: true` when the text is within every interactive bound (0.13), else `editable: false` with `reason` (`formatted text is 15,466 bytes; the editor accepts 8,192`) and the complete text. The UI then shows the text read-only and keeps the builder on the original `Query`; Save writes that `Query` unchanged; the share action falls back to a saved view carrying `query` because a URL cannot carry the text. `Parse` enforces the interactive bounds before tokenising and reports the first one exceeded at a span. The **text-reparse property** `Lower(Parse(Format(q))) == q` under the reported tier is promised and tested only for `editable: true`; `editable: false` text is never submitted to `parse`, and its contract is preservation through the structured envelope (0.13). Oversized valid queries exist (sixteen 480-byte `body` literals; raw entries whose backticks double on escaping; measures padded with whitespace); nothing merges or drops entries to make them fit. -Guarantees, as tests: (1) every clean corpus text is a fixed point of `Format(Lower(Parse(t)))` with `exact` and `editable`; (2) every valid query in the default dashboards, the dashboard eval fixtures and the MCP tests formats with a tier and `editable`; when editable, `Lower(Parse(Format(q)))` equals `q` under the tier, `Check` results are identical and no entry count changes; when not, the text is complete, the envelope carries `q`, `q` survives JSON round trip, and the parser is never called; (3) property tests from FanQL's own lowering (always `exact`, `editable`, fixed point) and from the structured contract (tier in {exact, normalized, raw}, equal `Check` results and entry counts, `editable == false` exactly when a bound is exceeded); (4) a stored two-entry query and a stored one-entry `AND` query with the same predicates format to different texts and lower back to their own shapes; (5) each interactive bound is tested independently; (6) preservation for `editable: false` through the envelope, the builder and Save. +Guarantees, as tests: (1) every clean corpus text is a fixed point of `Format(Lower(Parse(t)))` with `exact` and `editable`; (2) every valid query in the default dashboards, the dashboard eval fixtures and the MCP tests formats with a tier and `editable`; when editable, `Lower(Parse(Format(q)))` equals `q` under the tier, `Check` results are identical and no entry count changes; when not, the text is complete, the envelope carries `q`, `q` survives JSON round trip, and the parser is never called; (3) property tests from PitotQL's own lowering (always `exact`, `editable`, fixed point) and from the structured contract (tier in {exact, normalized, raw}, equal `Check` results and entry counts, `editable == false` exactly when a bound is exceeded); (4) a stored two-entry query and a stored one-entry `AND` query with the same predicates format to different texts and lower back to their own shapes; (5) each interactive bound is tested independently; (6) preservation for `editable: false` through the envelope, the builder and Save. #### 0.12 Validation, problems and notices -**Shape checks.** `parse` and `complete` accept `viz` and `variables` (the dashboard's declarations), both optional; `format` accepts `variables` and an optional `panel`. The resolver lowers to `panel.Query` and calls a new exported `panel.QueryShape(q, viz, vars)`, extracted from the in-memory checks that depend only on the query, the viz and the declarations: from `validateQuery` (entry count and bytes, measure count and the grouped-one-measure rule, `by` bounds, bucket rules, histogram shape, limit, sort alias, unit families, reduce-one-measure), from `validateRows` (row-viz source, sort keys, `log_patterns` shape, no measures/by/bucket, no histogram), from `validateItems` (scatter two measures, `state_timeline` one measure and no sort), and variable references when declarations are supplied. `Requires` lists what full panel validity needs beyond the query: `min_max` for gauge, `thresholds` for `state_timeline`. Stacking additivity, highlight, option maxima and `Check`-only rules (filter binding, metric-name requirement, rollup representability, annotation projection) stay where they are; the FanQL handler maps `panels[0].query.where[i]` paths back to spans when `Check` runs on the transient panel. +**Shape checks.** `parse` and `complete` accept `viz` and `variables` (the dashboard's declarations), both optional; `format` accepts `variables` and an optional `panel`. The resolver lowers to `panel.Query` and calls a new exported `panel.QueryShape(q, viz, vars)`, extracted from the in-memory checks that depend only on the query, the viz and the declarations: from `validateQuery` (entry count and bytes, measure count and the grouped-one-measure rule, `by` bounds, bucket rules, histogram shape, limit, sort alias, unit families, reduce-one-measure), from `validateRows` (row-viz source, sort keys, `log_patterns` shape, no measures/by/bucket, no histogram), from `validateItems` (scatter two measures, `state_timeline` one measure and no sort), and variable references when declarations are supplied. `Requires` lists what full panel validity needs beyond the query: `min_max` for gauge, `thresholds` for `state_timeline`. Stacking additivity, highlight, option maxima and `Check`-only rules (filter binding, metric-name requirement, rollup representability, annotation projection) stay where they are; the PitotQL handler maps `panels[0].query.where[i]` paths back to spans when `Check` runs on the transient panel. The parse response reports shape problems with spans mapped from the lowered field back to the text (`measures[0]`, `where[2]`, `sort`, `bucket`, `by[1]`), and `viz.compatible: [{viz, requires: []}]` for every viz whose shape check passes **on the query as written**. `QueryShape` never normalizes; a timeseries without a bucket is reported as compatible-with-edit: `viz.edits: [{viz: "timeseries", text: "… every auto"}]`, applied only when the user accepts. Nothing returns a mutated query. @@ -401,9 +401,9 @@ The parse response reports shape problems with spans mapped from the lowered fie **Traces.** The `traces` viz does not list matching spans: candidates are `(namespace, trace_id)` pairs with at least one span matching the filters in the window, ranked by the matching spans' `max(duration_ms)` (or `min(start_time)` for `sort +start`), limited to `limit` (at most 1,001); each candidate returns one row, the trace's root span (or its earliest span in the window when the root is outside it), with `status` set to error if any span in the trace errored. A whole entry that is one prefix-negated term (`-service:x`, lowered per 0.7) instead excludes every trace with a span in the window that the positive term matches, so excluding a listed root's service removes that row; SQL negatives and negation inside `or` stay per span. The reference says exactly this; the Explore trace list labels columns "root service" and "root duration". Trace sort keys: `duration` (canonical for `duration_ms`), `errors`, `+start`; `sort +duration` and `sort start` are `traces sort descending by duration, by errors, or ascending by start only`. Logs: `time`, `+time`. `log_patterns`: `count`. -**`sort errors` stays.** It is valid stored state (appends `status = 'STATUS_CODE_ERROR'` and orders by duration). FanQL accepts and prints it with the notice `sort errors also filters to error spans; new queries: write status:error … sort duration`; completion after `sort` under traces offers `duration`, `+start` and `errors` (detail "filters to errors, orders by duration"); the reference teaches `status:error … sort duration` and lists `errors` as the legacy combined key. +**`sort errors` stays.** It is valid stored state (appends `status = 'STATUS_CODE_ERROR'` and orders by duration). PitotQL accepts and prints it with the notice `sort errors also filters to error spans; new queries: write status:error … sort duration`; completion after `sort` under traces offers `duration`, `+start` and `errors` (detail "filters to errors, orders by duration"); the reference teaches `status:error … sort duration` and lists `errors` as the legacy combined key. -**Bucketed sort and limit.** For bucketed aggregates the compiler orders by time and selects series by `options.top`, ignoring `Sort`/`Limit`; the panel accepts them, so FanQL must too. With `viz` in a bucketed family, a `sort` or `limit` yields the notice `sort does not apply to bucketed series; series are chosen by top (options)`; a `limit` on `stat`/`gauge` instead reports `limit does not apply to stat panels; the whole window produces one value` (using the selected visualization name), at path `limit`. Without a viz, no notice. +**Bucketed sort and limit.** For bucketed aggregates the compiler orders by time and selects series by `options.top`, ignoring `Sort`/`Limit`; the panel accepts them, so PitotQL must too. With `viz` in a bucketed family, a `sort` or `limit` yields the notice `sort does not apply to bucketed series; series are chosen by top (options)`; a `limit` on `stat`/`gauge` instead reports `limit does not apply to stat panels; the whole window produces one value` (using the selected visualization name), at path `limit`. Without a viz, no notice. **Error model.** (1) A text with any problem has no executable form: the parse response carries no `query`, Run and Save stay disabled, the user's text is never replaced. (2) All problems in one pass, in source order, capped at 20 (`more problems follow; fix these first` as the 21st); recovery exists to find more problems and to drive completion, never to produce a runnable remainder. (3) A repaired preview is returned only when requested (`preview: true`) and is labelled `not executable`. (4) Notices are a separate list and never block. (5) Fix-its are suggestions attached to a problem; applying one is a user action. @@ -428,36 +428,36 @@ type FixIt struct { #### 0.13 API, envelope, compatibility, bounds ``` -POST /api/fanql/parse +POST /api/pitotql/parse {text, source?, viz?, variables?, preview?: bool} 200 {query, canonical, viz: {requested?, compatible: [{viz, requires: []}], edits: [{viz, text}]}, notices: [{path, message, span?}]} - 400 {code: "invalid_fanql", message: "The query has problems.", problems: [...], preview?: {text, note: "not executable"}} + 400 {code: "invalid_pitotql", message: "The query has problems.", problems: [...], preview?: {text, note: "not executable"}} -POST /api/fanql/format +POST /api/pitotql/format {query, viz?, variables?, panel?} 200 {text, exactness: "exact" | "normalized", editable: bool, reason?: string, requires: [{name, satisfied}], notices: [...]} 400 {code: "invalid_spec", ... problems} (the query fails QueryShape under every viz) 503 {code: "unavailable", message} (engine parse failed operationally) -POST /api/fanql/complete +POST /api/pitotql/complete {text, cursor, source?, viz?, window?, from?, to?, namespace?, variables?} 200 {replace: {start, end}, items: [{label, insert, kind, detail}], schema: {window, sampled: true, warm: bool, recent: bool}} -GET /api/fanql/reference text/markdown +GET /api/pitotql/reference text/markdown ``` `format` needs in-memory shape validity under some viz, the supplied `variables` to judge `$x` references (without them, references are notices), and the engine only for `ParseSQL`/`RenderSQL` of stored entries; it never runs `Check`'s bind step or `Normalize`; `panel` is accepted so a builder round trip reports `requires: [{name, satisfied}]`; gauge needs `min_max`, and a state timeline needs `thresholds`. Other panel configuration is ignored. -**Handler.** `PanelHandler` holds a `PanelEngine` (`Exemplars`, `Run`, `ResolveVariables`, `Schema`) and no parser, so FanQL gets its own handler with an injected `panel.Parser` (`*query.Duck` implements it): +**Handler.** `PanelHandler` holds a `PanelEngine` (`Exemplars`, `Run`, `ResolveVariables`, `Schema`) and no parser, so PitotQL gets its own handler with an injected `panel.Parser` (`*query.Duck` implements it): ```go -type FanQLHandler struct { +type PitotQLHandler struct { parser panel.Parser engine PanelEngine // Schema, for completion } -func RegisterFanQLRoutes(e *echo.Echo, parser panel.Parser, engine PanelEngine) +func RegisterPitotQLRoutes(e *echo.Echo, parser panel.Parser, engine PanelEngine) ``` Routes use the 20-second panel deadline; operational errors (`panel.isOperational`) become `503 unavailable` and are logged through `PresentError`, never turned into problems; bodies are decoded with `decodeStrict` and the existing 512 KiB limit; all routes need the `telemetry:read` capability and are classified in `classifyRoute`. @@ -481,7 +481,7 @@ Routes use the 20-second panel deadline; operational errors (`panel.isOperationa When `editable` is false the envelope must carry `query`; consumers open the builder on it, show `text` read-only and never submit that text to `parse`. Explore URL: `?q=&viz=&range=1h|from=..&to=..&compare=&vars=&ns=`; an oversized text falls back to a saved view carrying `query`. `time` is `panel.Time`; `compare` is `previous_period` (the only value); `namespace` scopes schema and completion and is not a query filter (`namespace:prod` is). MCP `query_telemetry` gains optional `text` beside `panel`; `panel.query` stays the documented first choice for agents, with SQL for complex work; the text form is accepted and documented for agents but never required. Chat transcripts and documentation carry text without an envelope; they are not machine inputs. -**Compatibility.** FanQL has no language-version field or negotiation. Canonical output is pinned by a corpus, and registry tests detect changes to accepted text meanings. The structured query evolves under `panel.SpecVersion` (1); the measure grammar is additive to the spec. +**Compatibility.** PitotQL has no language-version field or negotiation. Canonical output is pinned by a corpus, and registry tests detect changes to accepted text meanings. The structured query evolves under `panel.SpecVersion` (1); the measure grammar is additive to the spec. **Bounds.** Interactive (the text): 4,000 code points **and** 8,192 bytes, whichever fails first (`a query is at most 4000 characters (8192 bytes)`); 1,024 tokens; 512 AST nodes; nesting depth 16 (groups, negation, calls, arithmetic together); `in` lists of 100 values; 20 problems; 50 completion items. Structured (the `Query`), enforced at lowering and reported at the text span: 16 entries (at the 17th entry's span); 500 **bytes** per lowered entry (`this filter lowers to N bytes; filters are at most 500`); 6 measures; 3 `by` fields and the viz's maximum; the expression budgets of 0.10. UI spans are code points; the UI converts once with `Array.from(text)`, and a test covers astral characters in values and keys. @@ -514,7 +514,7 @@ Algorithm: lex the whole text (never fails); the current token is the one contai Latency acceptance: p95 under 30 ms end-to-end with a warm cache and under 5 ms for parse and rank alone; cold bursts measured separately (50 concurrent completions on an empty cache issue exactly one schema query per cache key and at most 4 at once). -#### 0.15 FanQL at a glance +#### 0.15 PitotQL at a glance One line per query. Prefix `-` excludes and includes rows missing the field; `!=` is SQL. Mix `and` and `or` only with parentheses. `$name` is a dashboard variable; a term mentioning a variable set to All is removed, so keep fixed conditions in their own terms. @@ -548,7 +548,7 @@ One line per query. Prefix `-` excludes and includes rows missing the field; `!= | 11 | metrics counter rate | timeseries | counter increase per second, not points per second | | 12 | metrics gauge, resource attribute | table | `last(value)` is kind-aware; `resource.k` is `resource['k']` | -Comparison claims are descriptive only: over the four reference queries whose output contract is equivalent across FanQL, Pitot SQL, SPL, KQL and Grafana, the FanQL strings total 255 characters against 285 (SPL), 324 (Grafana, with two UI settings), 460 (KQL) and 670 (SQL). These are string sums for typing on a stated dataset, not claims about task completion, learning time or error rates. +Comparison claims are descriptive only: over the four reference queries whose output contract is equivalent across PitotQL, Pitot SQL, SPL, KQL and Grafana, the PitotQL strings total 255 characters against 285 (SPL), 324 (Grafana, with two UI settings), 460 (KQL) and 670 (SQL). These are string sums for typing on a stated dataset, not claims about task completion, learning time or error rates. #### 0.16 Scope: preview and later @@ -567,7 +567,7 @@ The preview covers, as corpus fixtures that parse, lower, pass `Check` against t | Metrics arithmetic | series alignment across kinds | after the spans/logs expressions land | | Alias references between measures | not in the structured query | later | -Extensibility by construction: the parser builds a tree and a separate lowering maps it to the structured query; `|` is a list of stages and any second aggregation stage is `FanQL runs one aggregation stage`, not a syntax error; the reserved words of 0.3 are errors now; functions, field spellings, vocabularies, buckets and foreign-word hints live in registries and the reference is generated from them with a test that every entry appears. Later plans store `Panel.SQL` for execution plus `Panel.Plan` for the round trip; the text round-trips from the plan, never from generated SQL, and editing a plan panel in the SQL tab detaches it. One engine, one gate, one renderer. +Extensibility by construction: the parser builds a tree and a separate lowering maps it to the structured query; `|` is a list of stages and any second aggregation stage is `PitotQL runs one aggregation stage`, not a syntax error; the reserved words of 0.3 are errors now; functions, field spellings, vocabularies, buckets and foreign-word hints live in registries and the reference is generated from them with a test that every entry appears. Later plans store `Panel.SQL` for execution plus `Panel.Plan` for the round trip; the text round-trips from the plan, never from generated SQL, and editing a plan panel in the SQL tab detaches it. One engine, one gate, one renderer. Acceptance replaces size and time estimates: the corpus (every fixture, the twelve examples, the covered workloads, at least sixty more texts); the round-trip guarantees of 0.11; DuckDB-backed truth tables for every negation row and leaf class, variables under All, and severity through ingestion; engine binding of every lowered shape; non-execution of texts with problems; fuzzing over lex, parse, resolve, lower and print in both lexer contexts plus random valid queries through `Format`; completion fixtures and the cold-cache test; ranking fixtures with the `Ranking` disclosure; measured latency (parse, resolve and lower p99 under 1 ms without the engine; `format` p99 under 20 ms for stored queries with up to 16 entries; `complete` p95 under 30 ms warm); every registry entry in the reference and `just docs-generate-check` guarding the site copy; the canonical freeze; registry growth detection; and the structural budgets on structured and text inputs alike. @@ -576,18 +576,18 @@ Acceptance replaces size and time estimates: the corpus (every fixture, the twel A single page for ad-hoc questions: - Signal picker (spans, logs, metrics), time range (the dashboard time control), and two editors on tabs: - - **Query:** a one-line FanQL box (section 0) with completion from `POST /api/fanql/complete`; the default. Problems render at their spans with fix-its; notices render separately; the canonical text is shown after a run. - - **Builder:** dropdowns for `measures`, `by`, `where` and `bucket`, fed by `GET /api/telemetry/schema` (columns, attribute keys per service, metric names, measure functions). Produces the structured `query`; edits stay in sync with the text box through `POST /api/fanql/format`. When `format` returns `editable: false`, the text is read-only and the builder edits the structured query. + - **Query:** a one-line PitotQL box (section 0) with completion from `POST /api/pitotql/complete`; the default. Problems render at their spans with fix-its; notices render separately; the canonical text is shown after a run. + - **Builder:** dropdowns for `measures`, `by`, `where` and `bucket`, fed by `GET /api/telemetry/schema` (columns, attribute keys per service, metric names, measure functions). Produces the structured `query`; edits stay in sync with the text box through `POST /api/pitotql/format`. When `format` returns `editable: false`, the text is read-only and the builder edits the structured query. - **SQL:** the existing SQL editor and diagnostics, for advanced use. - A viz picker limited to `viz.compatible` from the parse response; a compatible-with-edit viz (a timeseries that needs `every auto`, listed under `viz.edits`) is offered as an edit the user accepts. - Run sends a transient one-panel dashboard spec to `POST /api/panels/query`, as the SQL editor preview already does, and renders the result with `PanelCard`. - "Open as SQL" converts a builder query to editable SQL when the backend can render it; the reverse direction is not offered. - "Save to dashboard" picks an existing dashboard or creates a new one, then applies `add_panel`. -- The URL carries the FanQL envelope (section 0.13: `?v=1&q=…&viz=&range=…&vars=…&ns=`) so an Explore view can be shared and bookmarked; an oversized `editable: false` text falls back to a saved view carrying `query`. +- The URL carries the PitotQL envelope (section 0.13: `?v=1&q=…&viz=&range=…&vars=…&ns=`) so an Explore view can be shared and bookmarked; an oversized `editable: false` text falls back to a saved view carrying `query`. ### 2. Logs and Traces as Explore presets -Rather than separate renderers, the rail gets **Logs** and **Traces** entries that open Explore preset to `viz: logs` (sorted by time) and `viz: traces` (sorted by duration or errors). The search bar accepts FanQL `filters` only (section 0.1); the page supplies the source and viz. Filters (service, severity, status, duration, free-text body search on the redacted body) are also builder fields. Clicking a row uses the existing drill drawers. +Rather than separate renderers, the rail gets **Logs** and **Traces** entries that open Explore preset to `viz: logs` (sorted by time) and `viz: traces` (sorted by duration or errors). The search bar accepts PitotQL `filters` only (section 0.1); the page supplies the source and viz. Filters (service, severity, status, duration, free-text body search on the redacted body) are also builder fields. Clicking a row uses the existing drill drawers. ### 3. Dashboards without chat @@ -613,7 +613,7 @@ Rather than separate renderers, the rail gets **Logs** and **Traces** entries th 2. **No template gallery yet.** Only `DefaultSpec()` exists and every owner already has it. Add a "Duplicate dashboard" action instead (new name required); templates become a later content task. 3. **AI keys stay env-only in Pitot.** Self-hosted: Settings explains `PITOT_AI_PROVIDER` and the key variables, and how to connect an MCP client. Hosted pitot.dev: the customer enters a key on the pitot.dev account page, and the control plane renders it into the tenant's environment and redeploys (Onebox Cloud design). Pitot gains no secret storage. 4. **UI saves follow the MCP rule that panels must return data,** enforced in the UI: Add panel and Create dashboard are enabled only after a run returned rows without error. Editing an existing panel needs only a run without error, since a healthy panel such as errors by service can be empty right now; this keeps the old SQL editor's behaviour now that the panel editor replaces it. The HTTP API keeps its current behaviour. -5. **Variables.** The Add-panel drawer opened from a dashboard can reference that dashboard's variables (for example `$service`), and the FanQL editor and the builder's where-editor understand `$name` with the All rule of section 0.6. When saving from Explore into a dashboard that has a variable on the same field, the save dialog offers to replace the literal filter with the variable. +5. **Variables.** The Add-panel drawer opened from a dashboard can reference that dashboard's variables (for example `$service`), and the PitotQL editor and the builder's where-editor understand `$name` with the All rule of section 0.6. When saving from Explore into a dashboard that has a variable on the same field, the save dialog offers to replace the literal filter with the variable. ## Constraints diff --git a/docs/proposals/0005-dedicated-attribute-columns.md b/docs/proposals/0005-dedicated-attribute-columns.md index ae094a3b3..4bba0b74f 100644 --- a/docs/proposals/0005-dedicated-attribute-columns.md +++ b/docs/proposals/0005-dedicated-attribute-columns.md @@ -249,7 +249,7 @@ Candidate at v1.44.0. Filters on `rpc.method` read the VARIANT map until a later format adds the key. `peer_service` and `rpc_service` contain Pitot logic and stay as derived columns, which is open question 1. -**Resolution.** FanQL already reads `http.route` as `attributes['http.route']` +**Resolution.** PitotQL already reads `http.route` as `attributes['http.route']` (0004, section 0.5). The compiler maps a key in the list to its hidden column. The SQL guard does the same on the parsed AST for every `attributes['']` and `resource['']` subscript. The @@ -264,7 +264,7 @@ mark. The read path implements this as follows (`internal/engine/sql_keys.go`): -- Snapshot binding rewrites every query, so FanQL, structured panels, panel +- Snapshot binding rewrites every query, so PitotQL, structured panels, panel SQL and product SQL share one rule. A subscript becomes the column when its map binds to a signal relation directly, or through subqueries and CTEs that pass it on with `*`. Rewritten select items keep their original @@ -287,7 +287,7 @@ shredding `messaging.*`. **Views, rollups, compaction and verification.** - The spans view exposes the hidden columns. -- Rollups, default dashboards and FanQL reference examples move from the old +- Rollups, default dashboards and PitotQL reference examples move from the old columns to keys. - The read-cache schema version changes, so caches rebuild. - Compaction merges format-5 inputs column for column and sums the spill diff --git a/docs/proposals/README.md b/docs/proposals/README.md index fd0adfbbd..9597260a0 100644 --- a/docs/proposals/README.md +++ b/docs/proposals/README.md @@ -35,7 +35,7 @@ Earlier proposals predate the template and keep their original structure. | 0001 | [Logged-in UI: shell, chat pane, native widgets, sign-in code step](0001-logged-in-ui-shell.md) | Implemented | | 0002 | [Agent-built dashboards](0002-agent-dashboards.md) | Implemented | | 0003 | [Milestone 5: correct metrics and the system page](0003-agent-dashboards-m5.md) | Implemented | -| 0004 | [Full UI without an LLM key, and FanQL](0004-fanql.md) | Accepted | +| 0004 | [Full UI without an LLM key, and PitotQL](0004-pitotql.md) | Accepted | | 0005 | [Dedicated attribute columns and batch format 5](0005-dedicated-attribute-columns.md) | Accepted | Settled decisions that a proposal leads to are recorded in [../adr](../adr/README.md). diff --git a/docs/release.md b/docs/release.md index 9a79052b2..b1afce1ab 100644 --- a/docs/release.md +++ b/docs/release.md @@ -116,14 +116,15 @@ shipped dependencies. After merging the rename pull request: -1. Rename the GitHub repository from `labstack/fanout` to `labstack/pitot` in - repository settings. Update remotes and the repository website to +1. Verify the GitHub repository is `labstack/pitot`. Update remotes and the + repository website to `https://pitot.dev`; configure that domain for the site deployment. Configure the `pitot` Cloudflare Pages project used by `site.yml` and migrate the media hostname to `assets.pitot.dev` before enabling the renamed site workflow. - Refresh the six historical landing captures and hosted clips with the new - wordmark on a host that can launch Chrome; the committed captures still - document the pre-rename alpha. + All six landing stills and `site/public/logo.svg` are generated by + `just landing-captures` (see below). Verify hosted clips separately. + The social card and favicons are unchanged. + 2. Verify the renamed repository's Actions permissions, branch protection, environments, OIDC trust and package access. Ensure `ghcr.io/labstack/pitot` is public and Actions can write it. Create or configure the public Docker Hub @@ -135,12 +136,42 @@ After merging the rename pull request: 4. Wait for the tag-triggered `release.yml` workflow, including anonymous image pulls, `pitot_` archives containing `./pitot`, checksums, attestations and installer verification. It publishes version and `latest` images to both new - image destinations. Add the rename and one-alpha compatibility notice from + image destinations. Add the rename and upgrade notice from `CHANGELOG.md` to the release notes. 5. The final workflow job authenticates with GitHub OIDC and publishes the tagged `server.json` as `io.github.labstack/pitot` in the MCP Registry. Verify that entry and its version after the job passes; retire the old registry listing separately according to registry policy. Do not publish from this branch. -6. In the following alpha, remove the legacy environment bridge and its installer - overrides after repeating the deprecation notice. Keep storage filenames and - token compatibility independently of that environment window. +6. Verify the upgrade steps in `CHANGELOG.md`, including the control database + filename, session cookies and saved chat metadata. Telemetry footer keys + retain their persisted format-5 spelling. + The pre-rename environment variable prefix is no longer read. + +## Refresh landing stills + +Run `just landing-captures` with the locked browser dependencies and Google +Chrome installed. It builds the current app and seed command, starts an isolated +loopback-only instance, and stops it after capture. No private instance, API key, +or LLM provider is used; inherited external capture settings are cleared. + +The checked-in landing seed generates a dense hour across fourteen fictional +store services: about 39 requests/s, 0.01% errors, 50 ms p95 and 21 error logs. +The seed is deterministic for its seed and minute-aligned end time. Its reported +window freezes the UI clock for both themes. `landing-dashboard.json` is saved +through the real dashboard API and all stats/series use real telemetry queries. +The fixed `landing-chat.json` transcript loads through the real chat UI and MCP +App renderer; only the saved-thread reads and the UI capability flag are fixtures. +External browser requests and model runs are blocked and fail the capture. + +All screenshots retain the full header, expanded sidebar and content at a +1280×800 CSS viewport. `overview-{light,dark}.png` use 1.5× scale (1920×1200, +the original README hero dimensions); `dashboard-{light,dark}.png` and +`chat-{light,dark}.png` use CSS scale (1280×800). The overview and dashboard +images show **Store overview - last hour**, including the four stats and +request rate, error rate and p95 latency by service. The logo is exported from +the rendered app `BrandLockup`/mark, with the site's display font stack. + +Before committing, view every image in both themes and OCR the header when +Tesseract is available. Confirm **PITOT**, an expanded sidebar, populated charts, +a healthy error-rate stat and no loaders or old wordmark. Favicons and the +social card are separate artifacts and are not regenerated by this recipe. diff --git a/docs/testing.md b/docs/testing.md index 84d318615..4344d2fdd 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -306,7 +306,7 @@ and 1024×768 using the toolbar. `Pages` uses the shipping route tree, shell, auth gate, query client, and screens with memory history. Explore, Logs, Traces, and Alerts have full-page stories -in the same light/dark matrix. Explore includes FanQL fix-its and per-panel +in the same light/dark matrix. Explore includes PitotQL fix-its and per-panel validation diagnostics in both editors. Dashboard and receipt states show invalid panels alongside successful siblings and a corrected save. Settings includes chat-disabled and token-creation states with a fictional `foi_` token. @@ -347,10 +347,10 @@ Nested main landmarks, panel loading labels, Settings links and unnamed alert actions headers no longer need exceptions. Chromium validation must run on a host that permits the browser's Mach port registration. -## FanQL performance checks +## PitotQL performance checks -The FanQL tests always enforce allocation ceilings and bounded parser/renderer -work. Wall-clock acceptance is opt-in: run `just fanql-perf`, or set -`PITOT_TEST_LATENCY=1` when running the FanQL tests through +The PitotQL tests always enforce allocation ceilings and bounded parser/renderer +work. Wall-clock acceptance is opt-in: run `just pitotql-perf`, or set +`PITOT_TEST_LATENCY=1` when running the PitotQL tests through `scripts/with-duckdb.sh`. Use an uninstrumented build for timing; race builds still check deterministic work bounds but skip wall-clock assertions. diff --git a/internal/agent/store.go b/internal/agent/store.go index e287856d2..3781ee341 100644 --- a/internal/agent/store.go +++ b/internal/agent/store.go @@ -363,7 +363,7 @@ func mergeThreadMessages(stored, incoming []agtypes.Message, runContext []agtype } // Keep this reserved key server-owned even when a client posts metadata. -const diagnosticContextMetadata = "_fanout_diagnostic_context" +const diagnosticContextMetadata = "_pitot_diagnostic_context" func withoutDiagnosticContext(message agtypes.Message) agtypes.Message { metadata := agtypes.Metadata{} diff --git a/internal/api/auth_middleware.go b/internal/api/auth_middleware.go index c93f2069c..742fee973 100644 --- a/internal/api/auth_middleware.go +++ b/internal/api/auth_middleware.go @@ -346,9 +346,9 @@ func classifyNonSCIMRoute(method, path string) (routePolicy, bool) { return routePolicy{kind: routePolicyCapability, capability: ManageAlerts}, unsafe case path == "/api/queries/run" || path == "/api/queries/exemplars" || path == "/api/queries/variables/resolve" || path == "/api/annotations/query": return routePolicy{kind: routePolicyCapability, capability: ReadTelemetry}, method == http.MethodPost - case path == "/api/fanql/parse" || path == "/api/fanql/format" || path == "/api/fanql/complete": + case path == "/api/pitotql/parse" || path == "/api/pitotql/format" || path == "/api/pitotql/complete" || path == previousQueryPath("parse") || path == previousQueryPath("format") || path == previousQueryPath("complete"): return routePolicy{kind: routePolicyCapability, capability: ReadTelemetry}, method == http.MethodPost - case path == "/api/fanql/reference" || path == "/api/telemetry/schema": + case path == "/api/pitotql/reference" || path == previousQueryPath("reference") || path == "/api/telemetry/schema": return routePolicy{kind: routePolicyCapability, capability: ReadTelemetry}, read case path == "/api/dashboards" || strings.HasPrefix(path, "/api/dashboards/"): return routePolicy{kind: routePolicyCapability, capability: ManageOwnDashboards}, read || unsafe diff --git a/internal/api/auth_test.go b/internal/api/auth_test.go index a82735bbd..9339b050f 100644 --- a/internal/api/auth_test.go +++ b/internal/api/auth_test.go @@ -87,7 +87,7 @@ func (s *testAuthServer) login(t *testing.T, user auth.User) *http.Cookie { if rec.Code != http.StatusOK { t.Fatalf("verify = %d %s", rec.Code, rec.Body.String()) } - return firstCookie(t, rec, "fanout_session") + return firstCookie(t, rec, "pitot_session") } func sessionRequest(method, target string, body *strings.Reader, cookie *http.Cookie) *http.Request { @@ -189,10 +189,10 @@ func TestRoutePolicyClassification(t *testing.T) { {http.MethodPost, "/api/dashboards/dashboard-1/versions/1/restore", routePolicyCapability, ManageOwnDashboards}, {http.MethodPost, "/api/agent/runs", routePolicyCapability, RunAgent}, {http.MethodPost, "/api/queries/variables/resolve", routePolicyCapability, ReadTelemetry}, - {http.MethodPost, "/api/fanql/parse", routePolicyCapability, ReadTelemetry}, - {http.MethodPost, "/api/fanql/format", routePolicyCapability, ReadTelemetry}, - {http.MethodPost, "/api/fanql/complete", routePolicyCapability, ReadTelemetry}, - {http.MethodGet, "/api/fanql/reference", routePolicyCapability, ReadTelemetry}, + {http.MethodPost, "/api/pitotql/parse", routePolicyCapability, ReadTelemetry}, + {http.MethodPost, "/api/pitotql/format", routePolicyCapability, ReadTelemetry}, + {http.MethodPost, "/api/pitotql/complete", routePolicyCapability, ReadTelemetry}, + {http.MethodGet, "/api/pitotql/reference", routePolicyCapability, ReadTelemetry}, {http.MethodGet, "/api/settings/ingest", routePolicyCapability, ReadIngestMetadata}, {http.MethodGet, "/api/settings/ingest/tokens", routePolicyCapability, ManageIngest}, {http.MethodPost, "/api/settings/ingest/tokens", routePolicyCapability, ManageIngest}, @@ -527,7 +527,7 @@ func TestLoginLinkAuthenticatesExactlyOnce(t *testing.T) { req := httptest.NewRequest(http.MethodPost, "/api/auth/link/verify", strings.NewReader(body)) req.Header.Set("Content-Type", "application/json") s.e.ServeHTTP(first, req) - if first.Code != http.StatusOK || firstCookie(t, first, "fanout_session") == nil { + if first.Code != http.StatusOK || firstCookie(t, first, "pitot_session") == nil { t.Fatalf("first redemption = %d %s", first.Code, first.Body.String()) } @@ -589,7 +589,7 @@ func TestLocalSelfSignupCreatesVerifiedViewer(t *testing.T) { if user.Role != auth.RoleViewer || user.Status != auth.UserStatusActive { t.Fatalf("self-signup user = %#v, want active viewer", user) } - firstCookie(t, rec, "fanout_session") + firstCookie(t, rec, "pitot_session") var provisioned int if err := s.db.DB.QueryRow(`SELECT COUNT(*) FROM auth_audit_events WHERE event_type = 'user.provisioned' AND target_id = ?`, user.ID).Scan(&provisioned); err != nil { t.Fatalf("query audit: %v", err) @@ -735,7 +735,7 @@ func TestSetupExpiryAndExistingAdminRetry(t *testing.T) { t.Fatalf("retry = %d %s, want 403: one setup credential must not establish a second session", rec.Code, rec.Body.String()) } for _, cookie := range rec.Result().Cookies() { - if cookie.Name == "fanout_session" && cookie.Value != "" { + if cookie.Name == "pitot_session" && cookie.Value != "" { t.Fatal("denied setup retry established a browser session") } } @@ -811,7 +811,7 @@ func (s *testAuthServer) countFailedReason(t *testing.T, reason string) int { func hasSessionCookie(rec *httptest.ResponseRecorder) bool { for _, cookie := range rec.Result().Cookies() { - if cookie.Name == "fanout_session" && cookie.Value != "" { + if cookie.Name == "pitot_session" && cookie.Value != "" { return true } } diff --git a/internal/api/oauth_test.go b/internal/api/oauth_test.go index 39e911e71..257f5dc01 100644 --- a/internal/api/oauth_test.go +++ b/internal/api/oauth_test.go @@ -407,7 +407,7 @@ func oauthCookieForUser(t *testing.T, e *echo.Echo, user auth.User) *http.Cookie if rec.Code != http.StatusNoContent { t.Fatalf("test login = %d %s", rec.Code, rec.Body.String()) } - return firstCookie(t, rec, "fanout_session") + return firstCookie(t, rec, "pitot_session") } func oauthSessionCookie(t *testing.T, e *echo.Echo, users *auth.UserStore, email string) *http.Cookie { diff --git a/internal/api/fanql.go b/internal/api/pitotql.go similarity index 63% rename from internal/api/fanql.go rename to internal/api/pitotql.go index bf5a4d7b0..70e5ff304 100644 --- a/internal/api/fanql.go +++ b/internal/api/pitotql.go @@ -7,47 +7,55 @@ import ( "time" "github.com/labstack/echo/v5" - "github.com/labstack/pitot/internal/fanql" + "github.com/labstack/pitot/internal/pitotql" "github.com/labstack/pitot/internal/query" ) -type FanQLHandler struct { +type PitotQLHandler struct { parser query.Parser engine QueryEngine - completer *fanql.Completer + completer *pitotql.Completer } -func RegisterFanQLRoutes(e *echo.Echo, parser query.Parser, engine QueryEngine) { - h := &FanQLHandler{parser: parser, engine: engine, completer: fanql.NewCompleter(engine)} +func RegisterPitotQLRoutes(e *echo.Echo, parser query.Parser, engine QueryEngine) { + h := &PitotQLHandler{parser: parser, engine: engine, completer: pitotql.NewCompleter(engine)} read := RequireCapability(ReadTelemetry) - e.POST("/api/fanql/parse", h.parse, read) - e.POST("/api/fanql/format", h.format, read) - e.POST("/api/fanql/complete", h.complete, read) - e.GET("/api/fanql/reference", h.reference, read) + e.POST("/api/pitotql/parse", h.parse, read) + e.POST("/api/pitotql/format", h.format, read) + e.POST("/api/pitotql/complete", h.complete, read) + e.GET("/api/pitotql/reference", h.reference, read) + // Published route aliases accept old clients; all response content is canonical. + e.POST(previousQueryPath("parse"), h.parse, read) + e.POST(previousQueryPath("format"), h.format, read) + e.POST(previousQueryPath("complete"), h.complete, read) + e.GET(previousQueryPath("reference"), h.reference, read) } -type fanqlPreview struct { +// Intentional published API compatibility exception. +func previousQueryPath(action string) string { return "/api/fanql/" + action } + +type pitotqlPreview struct { Text string `json:"text"` Note string `json:"note"` } -// FanQL adds editor-only metadata at its own error boundary. -type fanqlFailure struct { +// PitotQL adds editor-only metadata at its own error boundary. +type pitotqlFailure struct { *apiError - Preview *fanqlPreview `json:"preview,omitempty"` + Preview *pitotqlPreview `json:"preview,omitempty"` } -func (e *fanqlFailure) ResponseBody() any { return e } -func fanqlNotices(notices []fanql.Notice) []fanql.Notice { +func (e *pitotqlFailure) ResponseBody() any { return e } +func pitotqlNotices(notices []pitotql.Notice) []pitotql.Notice { if notices == nil { - return []fanql.Notice{} + return []pitotql.Notice{} } return notices } -func (h *FanQLHandler) parse(c *echo.Context) error { +func (h *PitotQLHandler) parse(c *echo.Context) error { var req struct { - fanql.Options + pitotql.Options Text string `json:"text"` Preview bool `json:"preview,omitempty"` Window string `json:"window,omitempty"` @@ -57,12 +65,12 @@ func (h *FanQLHandler) parse(c *echo.Context) error { return err } req.Schema, req.SchemaPartial = h.cachedSchema(c.Request().Context(), req.Window, req.Namespace) - compiled, problems := fanql.Compile(req.Text, req.Options) + compiled, problems := pitotql.Compile(req.Text, req.Options) if len(problems) != 0 { - failure := &fanqlFailure{apiError: newAPIError(http.StatusBadRequest, "invalid_fanql", "The query has problems.")} + failure := &pitotqlFailure{apiError: newAPIError(http.StatusBadRequest, "invalid_pitotql", "The query has problems.")} failure.Problems = query.Diagnoses(problems) if req.Preview { - failure.Preview = &fanqlPreview{Text: req.Text, Note: "not executable"} + failure.Preview = &pitotqlPreview{Text: req.Text, Note: "not executable"} } return failure } @@ -72,17 +80,17 @@ func (h *FanQLHandler) parse(c *echo.Context) error { Viz struct { Requested string `json:"requested,omitempty"` Compatible []query.VizCompat `json:"compatible"` - Edits []fanql.VizEdit `json:"edits"` + Edits []pitotql.VizEdit `json:"edits"` } `json:"viz"` - Notices []fanql.Notice `json:"notices"` + Notices []pitotql.Notice `json:"notices"` }{ Query: compiled.Query, Canonical: compiled.Canonical, Viz: struct { Requested string `json:"requested,omitempty"` Compatible []query.VizCompat `json:"compatible"` - Edits []fanql.VizEdit `json:"edits"` + Edits []pitotql.VizEdit `json:"edits"` }{Requested: req.Viz, Compatible: compiled.Compatible, Edits: compiled.Edits}, - Notices: fanqlNotices(compiled.Notices), + Notices: pitotqlNotices(compiled.Notices), }) } @@ -90,7 +98,7 @@ func (h *FanQLHandler) parse(c *echo.Context) error { // those seen without waiting for a discovery. One for the query's window, or // the widest, and its namespace covers the query; otherwise the recent // schema is partial. -func (h *FanQLHandler) cachedSchema(ctx context.Context, window, namespace string) (*query.Schema, bool) { +func (h *PitotQLHandler) cachedSchema(ctx context.Context, window, namespace string) (*query.Schema, bool) { if h.engine == nil { return nil, false } @@ -117,9 +125,9 @@ func (h *FanQLHandler) cachedSchema(ctx context.Context, window, namespace strin return nil, false } -func (h *FanQLHandler) format(c *echo.Context) error { +func (h *PitotQLHandler) format(c *echo.Context) error { var req struct { - fanql.Options + pitotql.Options Query query.Spec `json:"query"` } if err := decodeStrict(c, &req, 512<<10); err != nil { @@ -127,26 +135,26 @@ func (h *FanQLHandler) format(c *echo.Context) error { } ctx, cancel := context.WithTimeout(c.Request().Context(), panelDeadline) defer cancel() - formatted, problems, err := fanql.Format(ctx, h.parser, req.Query, req.Options) + formatted, problems, err := pitotql.Format(ctx, h.parser, req.Query, req.Options) if err != nil { - return fanqlError(err) + return pitotqlError(err) } if len(problems) != 0 { failure := newAPIError(http.StatusBadRequest, "invalid_spec", "The query spec is invalid.") failure.Problems = query.PresentProblems(problems) return failure } - formatted.Notices = fanqlNotices(formatted.Notices) + formatted.Notices = pitotqlNotices(formatted.Notices) return c.JSON(http.StatusOK, formatted) } -func fanqlError(err error) error { +func pitotqlError(err error) error { return newAPIError(http.StatusServiceUnavailable, "unavailable", query.PresentError(err, query.ReadError)) } -func (h *FanQLHandler) complete(c *echo.Context) error { +func (h *PitotQLHandler) complete(c *echo.Context) error { var req struct { - fanql.Options + pitotql.Options Text string `json:"text"` Cursor int `json:"cursor"` Window *string `json:"window,omitempty"` @@ -166,11 +174,11 @@ func (h *FanQLHandler) complete(c *echo.Context) error { if req.Window != nil { window = *req.Window } - creq := fanql.CompleteRequest{ + creq := pitotql.CompleteRequest{ Text: req.Text, Cursor: req.Cursor, Options: req.Options, Window: window, From: req.From, To: req.To, Namespace: req.Namespace, } - if err := fanql.CheckCompleteRequest(creq); err != nil { + if err := pitotql.CheckCompleteRequest(creq); err != nil { return newAPIError(http.StatusBadRequest, "invalid_input", err.Error()) } ctx, cancel := context.WithTimeout(c.Request().Context(), panelDeadline) @@ -179,6 +187,6 @@ func (h *FanQLHandler) complete(c *echo.Context) error { return c.JSON(http.StatusOK, out) } -func (h *FanQLHandler) reference(c *echo.Context) error { - return c.Blob(http.StatusOK, "text/markdown; charset=utf-8", []byte(fanql.Reference())) +func (h *PitotQLHandler) reference(c *echo.Context) error { + return c.Blob(http.StatusOK, "text/markdown; charset=utf-8", []byte(pitotql.Reference())) } diff --git a/internal/api/fanql_corpus_test.go b/internal/api/pitotql_corpus_test.go similarity index 79% rename from internal/api/fanql_corpus_test.go rename to internal/api/pitotql_corpus_test.go index 2a1bf39fd..0389e144a 100644 --- a/internal/api/fanql_corpus_test.go +++ b/internal/api/pitotql_corpus_test.go @@ -12,22 +12,22 @@ import ( "testing" "github.com/labstack/pitot/internal/auth" - "github.com/labstack/pitot/internal/fanql" + "github.com/labstack/pitot/internal/pitotql" "github.com/labstack/pitot/internal/query" ) -type nonExecutingFanQLPanels struct { +type nonExecutingPitotQLPanels struct { fakePanels calls int } -func (p *nonExecutingFanQLPanels) Run(context.Context, query.RunRequest) ([]query.Result, error) { +func (p *nonExecutingPitotQLPanels) Run(context.Context, query.RunRequest) ([]query.Result, error) { p.calls++ - return nil, fmt.Errorf("FanQL parsing must not execute telemetry") + return nil, fmt.Errorf("PitotQL parsing must not execute telemetry") } func TestNonExecution(t *testing.T) { - file, err := os.Open("../fanql/testdata/corpus.txt") + file, err := os.Open("../pitotql/testdata/corpus.txt") if err != nil { t.Fatal(err) } @@ -42,8 +42,8 @@ func TestNonExecution(t *testing.T) { t.Fatal(err) } cookie := s.login(t, viewer) - engine := &nonExecutingFanQLPanels{} - RegisterFanQLRoutes(s.e, nil, engine) + engine := &nonExecutingPitotQLPanels{} + RegisterPitotQLRoutes(s.e, nil, engine) decoder := json.NewDecoder(file) negative := 0 @@ -60,14 +60,14 @@ func TestNonExecution(t *testing.T) { } else if err != nil { t.Fatalf("corpus fixture %d: %v", fixture, err) } - // Raw SQL rejected only by the existing execution gate is clean FanQL. + // Raw SQL rejected only by the existing execution gate is clean PitotQL. // The parse route must retain the same Compile-only contract. if tc.Query != nil || len(tc.Problems) == 0 || tc.GateProblems { continue } negative++ t.Run(fmt.Sprintf("%d/%s", fixture, tc.Text), func(t *testing.T) { - compiled, problems := fanql.Compile(tc.Text, fanql.Options{Viz: tc.Viz}) + compiled, problems := pitotql.Compile(tc.Text, pitotql.Options{Viz: tc.Viz}) if compiled != nil || len(problems) == 0 { t.Fatalf("negative corpus text became executable: %+v %+v", compiled, problems) } @@ -76,13 +76,13 @@ func TestNonExecution(t *testing.T) { if err != nil { t.Fatal(err) } - req := sessionRequest(http.MethodPost, "/api/fanql/parse", strings.NewReader(string(input)), cookie) + req := sessionRequest(http.MethodPost, "/api/pitotql/parse", strings.NewReader(string(input)), cookie) req.Header.Set("Content-Type", "application/json") rec := httptest.NewRecorder() s.e.ServeHTTP(rec, req) var body map[string]json.RawMessage - fanqlResponse(t, rec, http.StatusBadRequest, &body) - if string(body["code"]) != `"invalid_fanql"` || body["problems"] == nil { + pitotqlResponse(t, rec, http.StatusBadRequest, &body) + if string(body["code"]) != `"invalid_pitotql"` || body["problems"] == nil { t.Fatalf("preview=%t: wrong error contract: %s", preview, rec.Body) } if _, exists := body["query"]; exists { diff --git a/internal/api/fanql_test.go b/internal/api/pitotql_test.go similarity index 60% rename from internal/api/fanql_test.go rename to internal/api/pitotql_test.go index 7dabb73f3..66117f1b1 100644 --- a/internal/api/fanql_test.go +++ b/internal/api/pitotql_test.go @@ -11,16 +11,16 @@ import ( "testing" "github.com/labstack/pitot/internal/auth" - "github.com/labstack/pitot/internal/fanql" + "github.com/labstack/pitot/internal/pitotql" "github.com/labstack/pitot/internal/query" ) -type fakeFanQLParser struct { +type fakePitotQLParser struct { query.Parser err error } -func (p *fakeFanQLParser) ParseSQL(ctx context.Context, text string) (map[string]any, error) { +func (p *fakePitotQLParser) ParseSQL(ctx context.Context, text string) (map[string]any, error) { if _, ok := ctx.Deadline(); !ok { panic("format parser requires a deadline") } @@ -37,13 +37,13 @@ func (p *fakeFanQLParser) ParseSQL(ctx context.Context, text string) (map[string return map[string]any{}, nil } -func (*fakeFanQLParser) RenderSQL(context.Context, map[string]any) (string, error) { +func (*fakePitotQLParser) RenderSQL(context.Context, map[string]any) (string, error) { return "SELECT 1 FROM spans WHERE service = 'api'", nil } -type fakeFanQLPanels struct{ fakePanels } +type fakePitotQLPanels struct{ fakePanels } -func (*fakeFanQLPanels) Schema(_ context.Context, req query.SchemaRequest) (*query.Schema, error) { +func (*fakePitotQLPanels) Schema(_ context.Context, req query.SchemaRequest) (*query.Schema, error) { if req.Cached { return nil, query.ErrSchemaNotCached } @@ -52,7 +52,7 @@ func (*fakeFanQLPanels) Schema(_ context.Context, req query.SchemaRequest) (*que }}, nil } -func serveFanQL(t *testing.T, parser query.Parser, engine QueryEngine, method, path, body string) *httptest.ResponseRecorder { +func servePitotQL(t *testing.T, parser query.Parser, engine QueryEngine, method, path, body string) *httptest.ResponseRecorder { t.Helper() s := newTestAuthServer(t) if _, err := s.users.CreateWithAudit("admin@example.com", "", "admin", auth.AuditEvent{EventType: "user.created", Outcome: "success"}); err != nil { @@ -62,7 +62,7 @@ func serveFanQL(t *testing.T, parser query.Parser, engine QueryEngine, method, p if err != nil { t.Fatal(err) } - RegisterFanQLRoutes(s.e, parser, engine) + RegisterPitotQLRoutes(s.e, parser, engine) req := sessionRequest(method, path, strings.NewReader(body), s.login(t, viewer)) req.Header.Set("Content-Type", "application/json") rec := httptest.NewRecorder() @@ -70,7 +70,7 @@ func serveFanQL(t *testing.T, parser query.Parser, engine QueryEngine, method, p return rec } -func fanqlResponse(t *testing.T, rec *httptest.ResponseRecorder, status int, target any) { +func pitotqlResponse(t *testing.T, rec *httptest.ResponseRecorder, status int, target any) { t.Helper() if rec.Code != status { t.Fatalf("status %d, want %d: %s", rec.Code, status, rec.Body) @@ -80,19 +80,19 @@ func fanqlResponse(t *testing.T, rec *httptest.ResponseRecorder, status int, tar } } -func TestFanQLParseReturnsQueryCanonicalAndVizzes(t *testing.T) { +func TestPitotQLParseReturnsQueryCanonicalAndVizzes(t *testing.T) { text := "spans where status:error | count() by service" - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/parse", `{"text":"`+text+`"}`) + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/parse", `{"text":"`+text+`"}`) var body struct { Query query.Spec `json:"query"` Canonical string `json:"canonical"` Viz struct { Compatible []query.VizCompat `json:"compatible"` - Edits []fanql.VizEdit `json:"edits"` + Edits []pitotql.VizEdit `json:"edits"` } `json:"viz"` - Notices []fanql.Notice `json:"notices"` + Notices []pitotql.Notice `json:"notices"` } - fanqlResponse(t, rec, http.StatusOK, &body) + pitotqlResponse(t, rec, http.StatusOK, &body) want := query.Spec{From: "spans", Where: []string{"status = 'STATUS_CODE_ERROR'"}, Measures: []string{"count()"}, By: []string{"service"}} if !reflect.DeepEqual(body.Query, want) || body.Canonical != text || body.Notices == nil || len(body.Notices) != 0 { t.Fatalf("response: %s", rec.Body) @@ -119,9 +119,9 @@ func TestFanQLParseReturnsQueryCanonicalAndVizzes(t *testing.T) { } } -func TestFanQLParseProblemsHaveNoQuery(t *testing.T) { +func TestPitotQLParseProblemsHaveNoQuery(t *testing.T) { for _, preview := range []bool{false, true} { - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/parse", fmt.Sprintf(`{"text":"spans where a:1 b:2 or c:3 | p99(duration) by http.route every 1m","preview":%t}`, preview)) + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/parse", fmt.Sprintf(`{"text":"spans where a:1 b:2 or c:3 | p99(duration) by http.route every 1m","preview":%t}`, preview)) var body struct { Code string `json:"code"` Message string `json:"message"` @@ -131,8 +131,8 @@ func TestFanQLParseProblemsHaveNoQuery(t *testing.T) { Note string `json:"note"` } `json:"preview"` } - fanqlResponse(t, rec, http.StatusBadRequest, &body) - if body.Code != "invalid_fanql" || body.Message != "The query has problems." || len(body.Problems) == 0 || body.Problems[0].Message != "mixed and/or needs parentheses" || body.Problems[0].Span == nil || len(body.Problems[0].FixIts) != 2 { + pitotqlResponse(t, rec, http.StatusBadRequest, &body) + if body.Code != "invalid_pitotql" || body.Message != "The query has problems." || len(body.Problems) == 0 || body.Problems[0].Message != "mixed and/or needs parentheses" || body.Problems[0].Span == nil || len(body.Problems[0].FixIts) != 2 { t.Fatalf("problem response: %s", rec.Body) } var keys map[string]json.RawMessage @@ -152,52 +152,52 @@ func TestFanQLParseProblemsHaveNoQuery(t *testing.T) { } } -func TestFanQLParseSearchBarAndViz(t *testing.T) { - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/parse", `{"text":"service:api timeout","source":"logs"}`) +func TestPitotQLParseSearchBarAndViz(t *testing.T) { + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/parse", `{"text":"service:api timeout","source":"logs"}`) var body struct { Query query.Spec `json:"query"` Viz struct { Compatible []query.VizCompat `json:"compatible"` Requested string `json:"requested"` } `json:"viz"` - Notices []fanql.Notice `json:"notices"` + Notices []pitotql.Notice `json:"notices"` } - fanqlResponse(t, rec, http.StatusOK, &body) + pitotqlResponse(t, rec, http.StatusOK, &body) if len(body.Query.Where) != 2 || len(body.Viz.Compatible) != 1 || body.Viz.Compatible[0].Viz != "logs" || body.Viz.Compatible[0].Requires == nil { t.Fatalf("search bar: %s", rec.Body) } - rec = serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/parse", `{"text":"where service:api","source":"logs"}`) + rec = servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/parse", `{"text":"where service:api","source":"logs"}`) if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "the page supplies where") { t.Fatalf("where: %d %s", rec.Code, rec.Body) } - rec = serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/parse", `{"text":"spans | count() every 1m sort count","viz":"timeseries"}`) - fanqlResponse(t, rec, http.StatusOK, &body) + rec = servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/parse", `{"text":"spans | count() every 1m sort count","viz":"timeseries"}`) + pitotqlResponse(t, rec, http.StatusOK, &body) if body.Viz.Requested != "timeseries" || len(body.Notices) != 1 || !strings.Contains(body.Notices[0].Message, "sort does not apply to bucketed series") { t.Fatalf("bucketed sort: %s", rec.Body) } } -func TestFanQLFormat(t *testing.T) { - rec := serveFanQL(t, &fakeFanQLParser{}, &fakePanels{}, http.MethodPost, "/api/fanql/format", `{"query":{"from":"spans","where":["service='api'"],"measures":["p95( duration_ms )"]},"panel":{"id":"a","title":"A","viz":"stat"}}`) +func TestPitotQLFormat(t *testing.T) { + rec := servePitotQL(t, &fakePitotQLParser{}, &fakePanels{}, http.MethodPost, "/api/pitotql/format", `{"query":{"from":"spans","where":["service='api'"],"measures":["p95( duration_ms )"]},"panel":{"id":"a","title":"A","viz":"stat"}}`) var body struct { - fanql.Formatted + pitotql.Formatted } - fanqlResponse(t, rec, http.StatusOK, &body) + pitotqlResponse(t, rec, http.StatusOK, &body) if body.Text != "spans where service:api | p95(duration)" || body.Exactness != "normalized" || !body.Editable { t.Fatalf("format: %s", rec.Body) } if len(body.Notices) == 0 || body.Notices[0].Message != `where[0] is shown as service:api; stored text is "service='api'"` { t.Fatalf("notices: %s", rec.Body) } - rec = serveFanQL(t, &fakeFanQLParser{}, &fakePanels{}, http.MethodPost, "/api/fanql/format", `{"query":{"from":"spans","measures":["count()"],"by":["a","b","c","d"]}}`) + rec = servePitotQL(t, &fakePitotQLParser{}, &fakePanels{}, http.MethodPost, "/api/pitotql/format", `{"query":{"from":"spans","measures":["count()"],"by":["a","b","c","d"]}}`) var failure map[string]json.RawMessage - fanqlResponse(t, rec, http.StatusBadRequest, &failure) + pitotqlResponse(t, rec, http.StatusBadRequest, &failure) if string(failure["code"]) != `"invalid_spec"` || failure["problems"] == nil { t.Fatalf("shape: %s", rec.Body) } - rec = serveFanQL(t, &fakeFanQLParser{err: context.DeadlineExceeded}, &fakePanels{}, http.MethodPost, "/api/fanql/format", `{"query":{"from":"logs","where":["coalesce(body, '') = ''"]}}`) + rec = servePitotQL(t, &fakePitotQLParser{err: context.DeadlineExceeded}, &fakePanels{}, http.MethodPost, "/api/pitotql/format", `{"query":{"from":"logs","where":["coalesce(body, '') = ''"]}}`) failure = nil - fanqlResponse(t, rec, http.StatusServiceUnavailable, &failure) + pitotqlResponse(t, rec, http.StatusServiceUnavailable, &failure) if string(failure["code"]) != `"unavailable"` || failure["problems"] != nil { t.Fatalf("operational: %s", rec.Body) } @@ -209,8 +209,8 @@ func TestFanQLFormat(t *testing.T) { if err != nil { t.Fatal(err) } - rec = serveFanQL(t, &fakeFanQLParser{}, &fakePanels{}, http.MethodPost, "/api/fanql/format", string(input)) - fanqlResponse(t, rec, http.StatusOK, &body) + rec = servePitotQL(t, &fakePitotQLParser{}, &fakePanels{}, http.MethodPost, "/api/pitotql/format", string(input)) + pitotqlResponse(t, rec, http.StatusOK, &body) if body.Editable || !strings.HasPrefix(body.Reason, "formatted text is") { t.Fatalf("oversized character format: %s", rec.Body) } @@ -227,8 +227,8 @@ func TestFanQLFormat(t *testing.T) { if err != nil { t.Fatal(err) } - rec = serveFanQL(t, &fakeFanQLParser{}, &fakePanels{}, http.MethodPost, "/api/fanql/format", string(input)) - fanqlResponse(t, rec, http.StatusOK, &body) + rec = servePitotQL(t, &fakePitotQLParser{}, &fakePanels{}, http.MethodPost, "/api/pitotql/format", string(input)) + pitotqlResponse(t, rec, http.StatusOK, &body) if body.Editable || !strings.HasPrefix(body.Reason, "formatted text is") || len(body.Text) <= 8192 { t.Fatalf("oversized format: %s", rec.Body) } @@ -239,8 +239,8 @@ func TestFanQLFormat(t *testing.T) { } } -func TestFanQLComplete(t *testing.T) { - rec := serveFanQL(t, nil, &fakeFanQLPanels{}, http.MethodPost, "/api/fanql/complete", `{"text":"logs where sev","cursor":14}`) +func TestPitotQLComplete(t *testing.T) { + rec := servePitotQL(t, nil, &fakePitotQLPanels{}, http.MethodPost, "/api/pitotql/complete", `{"text":"logs where sev","cursor":14}`) var body struct { Replace query.TextSpan `json:"replace"` Items []struct { @@ -251,87 +251,87 @@ func TestFanQLComplete(t *testing.T) { Warm bool `json:"warm"` Recent bool `json:"recent"` } `json:"schema"` - Notices []fanql.Notice `json:"notices"` + Notices []pitotql.Notice `json:"notices"` } - fanqlResponse(t, rec, http.StatusOK, &body) + pitotqlResponse(t, rec, http.StatusOK, &body) if body.Replace != (query.TextSpan{Start: 11, End: 14}) || len(body.Items) == 0 || body.Items[0].Label != "severity" || body.Schema.Window != "24h" || body.Schema.Warm || !body.Schema.Recent { t.Fatalf("complete: %s", rec.Body) } - rec = serveFanQL(t, nil, &fakeFanQLPanels{}, http.MethodPost, "/api/fanql/complete", `{"text":"logs where sev","cursor":14,"window":"","namespace":"prod"}`) - fanqlResponse(t, rec, http.StatusOK, &body) + rec = servePitotQL(t, nil, &fakePitotQLPanels{}, http.MethodPost, "/api/pitotql/complete", `{"text":"logs where sev","cursor":14,"window":"","namespace":"prod"}`) + pitotqlResponse(t, rec, http.StatusOK, &body) if body.Schema.Window != "24h" || !body.Schema.Recent || len(body.Notices) != 0 { t.Fatalf("absolute completion: %s", rec.Body) } } -func TestFanQLReference(t *testing.T) { - for _, path := range []string{"/api/fanql/reference"} { - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodGet, path, "") - if rec.Code != http.StatusOK || !strings.HasPrefix(rec.Header().Get("Content-Type"), "text/markdown") || !strings.Contains(rec.Body.String(), "# FanQL") || !strings.Contains(rec.Body.String(), "Preview") { +func TestPitotQLReference(t *testing.T) { + for _, path := range []string{"/api/pitotql/reference"} { + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodGet, path, "") + if rec.Code != http.StatusOK || !strings.HasPrefix(rec.Header().Get("Content-Type"), "text/markdown") || !strings.Contains(rec.Body.String(), "# PitotQL") || !strings.Contains(rec.Body.String(), "Preview") { t.Fatalf("reference: %d %s", rec.Code, rec.Body) } } } -func TestFanQLRoutesAreClassified(t *testing.T) { +func TestPitotQLRoutesAreClassified(t *testing.T) { for _, path := range []string{"parse", "format", "complete", "reference"} { method, other := http.MethodPost, http.MethodGet if path == "reference" { method, other = other, method } - policy, ok := classifyRoute(method, "/api/fanql/"+path) + policy, ok := classifyRoute(method, "/api/pitotql/"+path) if !ok || policy.kind != routePolicyCapability || policy.capability != ReadTelemetry { t.Errorf("%s not telemetry:read", path) } - if _, ok := classifyRoute(other, "/api/fanql/"+path); ok { + if _, ok := classifyRoute(other, "/api/pitotql/"+path); ok { t.Errorf("%s %s classified", other, path) } } s := newTestAuthServer(t) - RegisterFanQLRoutes(s.e, nil, &fakePanels{}) + RegisterPitotQLRoutes(s.e, nil, &fakePanels{}) rec := httptest.NewRecorder() - s.e.ServeHTTP(rec, sessionRequest(http.MethodPost, "/api/fanql/parse", strings.NewReader(`{"text":"spans"}`), nil)) + s.e.ServeHTTP(rec, sessionRequest(http.MethodPost, "/api/pitotql/parse", strings.NewReader(`{"text":"spans"}`), nil)) if rec.Code != http.StatusUnauthorized { t.Fatalf("anonymous: %d %s", rec.Code, rec.Body) } - rec = serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/parse", `{"text":"spans"}`) + rec = servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/parse", `{"text":"spans"}`) if rec.Code != http.StatusOK { t.Fatalf("viewer: %d %s", rec.Code, rec.Body) } } -func TestFanQLBodyLimitsAndUnknownFields(t *testing.T) { +func TestPitotQLBodyLimitsAndUnknownFields(t *testing.T) { for _, path := range []string{"parse", "format", "complete"} { valid := `{"text":"spans"}` if path == "format" { valid = `{"query":{"from":"spans"}}` } - for _, input := range []string{`{"unknown":1}`, `{"fanql_version":1}`, valid + strings.Repeat(" ", (512<<10)+1), `{} {}`} { - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/"+path, input) + for _, input := range []string{`{"unknown":1}`, `{"pitotql_version":1}`, valid + strings.Repeat(" ", (512<<10)+1), `{} {}`} { + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/"+path, input) if rec.Code != http.StatusBadRequest { t.Errorf("%s bad body: %d %s", path, rec.Code, rec.Body) } } } - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/parse", `{"text":"`+strings.Repeat("a", 4001)+`"}`) - if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), `"code":"invalid_fanql"`) || !strings.Contains(rec.Body.String(), "a query is at most 4000 characters (8192 bytes)") { + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/parse", `{"text":"`+strings.Repeat("a", 4001)+`"}`) + if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), `"code":"invalid_pitotql"`) || !strings.Contains(rec.Body.String(), "a query is at most 4000 characters (8192 bytes)") { t.Fatalf("interactive bound: %d %s", rec.Code, rec.Body) } } -func TestFanQLResponsesHaveNoLanguageVersion(t *testing.T) { +func TestPitotQLResponsesHaveNoLanguageVersion(t *testing.T) { for _, tc := range []struct{ path, input string }{ {"parse", `{"text":"spans"}`}, {"format", `{"query":{"from":"spans"}}`}, {"complete", `{"text":"spans","cursor":5}`}, } { - rec := serveFanQL(t, &fakeFanQLParser{}, &fakeFanQLPanels{}, http.MethodPost, "/api/fanql/"+tc.path, tc.input) + rec := servePitotQL(t, &fakePitotQLParser{}, &fakePitotQLPanels{}, http.MethodPost, "/api/pitotql/"+tc.path, tc.input) var body map[string]json.RawMessage - fanqlResponse(t, rec, http.StatusOK, &body) - if body["fanql_version"] != nil || body["version"] != nil { + pitotqlResponse(t, rec, http.StatusOK, &body) + if body["pitotql_version"] != nil || body["version"] != nil { t.Fatalf("%s version contract: %s", tc.path, rec.Body) } - var notices []fanql.Notice + var notices []pitotql.Notice if raw := body["notices"]; raw != nil { if err := json.Unmarshal(raw, ¬ices); err != nil { t.Fatal(err) @@ -341,19 +341,19 @@ func TestFanQLResponsesHaveNoLanguageVersion(t *testing.T) { t.Fatalf("%s unexpected notices: %+v", tc.path, notices) } } - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodGet, "/api/fanql/reference", "") - if rec.Code != http.StatusOK || rec.Body.String() != fanql.Reference() || rec.Header().Get("FanQL-Notice") != "" || rec.Header().Get("FanQL-Version") != "" { + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodGet, "/api/pitotql/reference", "") + if rec.Code != http.StatusOK || rec.Body.String() != pitotql.Reference() || rec.Header().Get("PitotQL-Notice") != "" || rec.Header().Get("PitotQL-Version") != "" { t.Fatalf("reference metadata: %d %v %s", rec.Code, rec.Header(), rec.Body) } } -func TestFanQLCompletionAbsoluteAndLongWindowsDiscloseRecentSchema(t *testing.T) { +func TestPitotQLCompletionAbsoluteAndLongWindowsDiscloseRecentSchema(t *testing.T) { for _, tt := range []struct{ window, want string }{ // A past absolute range keeps its length; schema windows end now. {`"from":"2026-10-20T10:00:00Z","to":"2026-10-20T11:00:00Z"`, "1h"}, {`"window":"7d"`, "24h"}, } { - rec := serveFanQL(t, nil, &fakeFanQLPanels{}, http.MethodPost, "/api/fanql/complete", `{"text":"logs where sev","cursor":14,`+tt.window+`}`) + rec := servePitotQL(t, nil, &fakePitotQLPanels{}, http.MethodPost, "/api/pitotql/complete", `{"text":"logs where sev","cursor":14,`+tt.window+`}`) var body struct { Schema struct { Window string `json:"window"` @@ -361,27 +361,27 @@ func TestFanQLCompletionAbsoluteAndLongWindowsDiscloseRecentSchema(t *testing.T) Notice string `json:"notice"` } `json:"schema"` } - fanqlResponse(t, rec, http.StatusOK, &body) + pitotqlResponse(t, rec, http.StatusOK, &body) if body.Schema.Window != tt.want || !body.Schema.Recent || body.Schema.Notice != "keys seen in the last "+tt.want+" (recent), not in the selected interval" { t.Fatalf("disclosure: %s", rec.Body) } } } -func TestFanQLCompletionRejectsBadCursorAndWindow(t *testing.T) { +func TestPitotQLCompletionRejectsBadCursorAndWindow(t *testing.T) { for _, body := range []string{ `{"text":"spans","cursor":999}`, `{"text":"spans","cursor":-1}`, `{"text":"spans","cursor":5,"window":"bogus"}`, } { - rec := serveFanQL(t, nil, &fakeFanQLPanels{}, http.MethodPost, "/api/fanql/complete", body) + rec := servePitotQL(t, nil, &fakePitotQLPanels{}, http.MethodPost, "/api/pitotql/complete", body) if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "invalid_input") { t.Fatalf("%s: %d %s", body, rec.Code, rec.Body) } } } -func TestFanQLFormatReportsPanelRequirements(t *testing.T) { +func TestPitotQLFormatReportsPanelRequirements(t *testing.T) { for _, tt := range []struct { panel, query, name string satisfied bool @@ -392,34 +392,34 @@ func TestFanQLFormatReportsPanelRequirements(t *testing.T) { {`{"viz":"state_timeline","thresholds":[{"value":10,"status":"warn"}]}`, `{"from":"spans","measures":["count()"],"by":["service"],"bucket":"1m"}`, "thresholds", true}, } { input := `{"query":` + tt.query + `,"panel":` + tt.panel + `}` - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/format", input) + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/format", input) var body struct { Requires []struct { Name string `json:"name"` Satisfied bool `json:"satisfied"` } `json:"requires"` } - fanqlResponse(t, rec, http.StatusOK, &body) + pitotqlResponse(t, rec, http.StatusOK, &body) if len(body.Requires) != 1 || body.Requires[0].Name != tt.name || body.Requires[0].Satisfied != tt.satisfied { t.Fatalf("requirements: %s", rec.Body) } } } -// FanQL problems quote the user's own text, which is often a URL path; the +// PitotQL problems quote the user's own text, which is often a URL path; the // engine-error scrubber must not mistake them for filesystem paths. -func TestFanQLParseProblemsKeepURLPaths(t *testing.T) { +func TestPitotQLParseProblemsKeepURLPaths(t *testing.T) { for _, tc := range []struct{ text, message, hint string }{ {"spans where http.target:/a:b", "unexpected : after /a", `quote the value: http.target:"/a:b"`}, {"logs where http://x:8080/y", "unexpected : after http", `quote the value: "http://x:8080/y"`}, {"spans where url.path:/a/b:c", "unexpected : after /a/b", `quote the value: url.path:"/a/b:c"`}, } { body, _ := json.Marshal(map[string]string{"text": tc.text}) - rec := serveFanQL(t, nil, &fakePanels{}, http.MethodPost, "/api/fanql/parse", string(body)) + rec := servePitotQL(t, nil, &fakePanels{}, http.MethodPost, "/api/pitotql/parse", string(body)) var got struct { Problems query.Problems `json:"problems"` } - fanqlResponse(t, rec, http.StatusBadRequest, &got) + pitotqlResponse(t, rec, http.StatusBadRequest, &got) if len(got.Problems) == 0 || got.Problems[0].Message != tc.message || got.Problems[0].Hint != tc.hint { t.Errorf("%s: %s", tc.text, rec.Body) } @@ -443,18 +443,44 @@ func (*fakeCachedSchemaPanels) Schema(_ context.Context, req query.SchemaRequest // Parse compares keys with a schema already cached, never waiting for one. // It offers the seen key as a fix only when that schema covers the query's // window and namespace; otherwise it only names the key. -func TestFanQLParseOffersSeenDottedKey(t *testing.T) { +func TestPitotQLParseOffersSeenDottedKey(t *testing.T) { for _, tt := range []struct { scope string fix bool }{{`,"window":"1h"`, true}, {`,"window":"15m"`, false}, {``, false}, {`,"window":"7d"`, false}, {`,"window":"1h","namespace":"shop"`, false}} { - rec := serveFanQL(t, nil, &fakeCachedSchemaPanels{}, http.MethodPost, "/api/fanql/parse", `{"text":"spans where http.rout:/api/cart | count()"`+tt.scope+`}`) + rec := servePitotQL(t, nil, &fakeCachedSchemaPanels{}, http.MethodPost, "/api/pitotql/parse", `{"text":"spans where http.rout:/api/cart | count()"`+tt.scope+`}`) var body struct { - Notices []fanql.Notice `json:"notices"` + Notices []pitotql.Notice `json:"notices"` } - fanqlResponse(t, rec, http.StatusOK, &body) + pitotqlResponse(t, rec, http.StatusOK, &body) if len(body.Notices) != 1 || (len(body.Notices[0].FixIts) == 1) != tt.fix || !strings.Contains(body.Notices[0].Message, "did you mean http.route?") { t.Errorf("%s: %s", tt.scope, rec.Body) } } } + +func TestPreviousQueryRoutesAcceptClientsAndReturnCanonicalNames(t *testing.T) { + for _, tc := range []struct { + action, method, body string + status int + }{ + {"parse", http.MethodPost, `{"text":"spans | count() by service"}`, http.StatusOK}, + {"format", http.MethodPost, `{"query":{"from":"spans","where":["service = 'api'"]}}`, http.StatusOK}, + {"complete", http.MethodPost, `{"text":"spa","cursor":3}`, http.StatusOK}, + {"reference", http.MethodGet, "", http.StatusOK}, + {"parse", http.MethodPost, `{"text":"spans where a:1 b:2 or c:3"}`, http.StatusBadRequest}, + } { + t.Run(tc.action+tc.body, func(t *testing.T) { + oldPath := previousQueryPath(tc.action) + policy, ok := classifyRoute(tc.method, oldPath) + if !ok || policy.capability != ReadTelemetry { + t.Fatalf("unprotected alias: %+v", policy) + } + old := servePitotQL(t, &fakePitotQLParser{}, &fakePitotQLPanels{}, tc.method, oldPath, tc.body) + current := servePitotQL(t, &fakePitotQLParser{}, &fakePitotQLPanels{}, tc.method, "/api/pitotql/"+tc.action, tc.body) + if old.Code != tc.status || old.Body.String() != current.Body.String() { + t.Fatalf("alias: %d %s; canonical: %d %s", old.Code, old.Body, current.Code, current.Body) + } + }) + } +} diff --git a/internal/api/users_test.go b/internal/api/users_test.go index 2e8c2f2ae..315f88d9c 100644 --- a/internal/api/users_test.go +++ b/internal/api/users_test.go @@ -397,7 +397,7 @@ func TestStatusRouteSuspensionBlocksSessionsAndSignIn(t *testing.T) { t.Fatalf("suspended sign-in %s = %d: %s", tc.path, rec.Code, rec.Body.String()) } for _, cookie := range rec.Result().Cookies() { - if cookie.Name == "fanout_session" && cookie.Value != "" { + if cookie.Name == "pitot_session" && cookie.Value != "" { t.Fatal("suspended sign-in issued a session") } } diff --git a/internal/auth/session.go b/internal/auth/session.go index 41787479d..f6da6365a 100644 --- a/internal/auth/session.go +++ b/internal/auth/session.go @@ -265,9 +265,9 @@ func NewBrowserSessions(db *sql.DB, idleTTL, absoluteTTL time.Duration, secure b manager.IdleTimeout = 0 manager.HashTokenInStore = true // Keep existing browser sessions valid through the product rename. - manager.Cookie.Name = "fanout_session" + manager.Cookie.Name = "pitot_session" if secure { - manager.Cookie.Name = "__Host-fanout_session" + manager.Cookie.Name = "__Host-pitot_session" } manager.Cookie.Path = "/" manager.Cookie.Domain = "" diff --git a/internal/auth/session_test.go b/internal/auth/session_test.go index 814680f96..8b5b8e693 100644 --- a/internal/auth/session_test.go +++ b/internal/auth/session_test.go @@ -62,8 +62,8 @@ func TestSessionCookieSecurityModes(t *testing.T) { name, cookieName string secure bool }{ - {name: "secure", cookieName: "__Host-fanout_session", secure: true}, - {name: "development", cookieName: "fanout_session", secure: false}, + {name: "secure", cookieName: "__Host-pitot_session", secure: true}, + {name: "development", cookieName: "pitot_session", secure: false}, } { t.Run(tc.name, func(t *testing.T) { sessions := NewBrowserSessions(db.DB, 12*time.Hour, 7*24*time.Hour, tc.secure) diff --git a/internal/cmd/dbmigrate/main.go b/internal/cmd/dbmigrate/main.go index c85de2441..98363746e 100644 --- a/internal/cmd/dbmigrate/main.go +++ b/internal/cmd/dbmigrate/main.go @@ -12,7 +12,7 @@ import ( ) func main() { - path := flag.String("db", "data/control/fanout.sqlite", "SQLite control database path") + path := flag.String("db", "data/control/pitot.sqlite", "SQLite control database path") flag.Parse() if err := os.MkdirAll(filepath.Dir(*path), 0755); err != nil { slog.Error("create control database directory", "err", err) diff --git a/internal/cmd/e2eseed/landing.go b/internal/cmd/e2eseed/landing.go new file mode 100644 index 000000000..aeb54ef27 --- /dev/null +++ b/internal/cmd/e2eseed/landing.go @@ -0,0 +1,78 @@ +package main + +import ( + "math" + "math/rand" + "time" + + collectorlogs "go.opentelemetry.io/proto/otlp/collector/logs/v1" + collectortrace "go.opentelemetry.io/proto/otlp/collector/trace/v1" + common "go.opentelemetry.io/proto/otlp/common/v1" + logs "go.opentelemetry.io/proto/otlp/logs/v1" + resource "go.opentelemetry.io/proto/otlp/resource/v1" + trace "go.opentelemetry.io/proto/otlp/trace/v1" + "google.golang.org/protobuf/proto" +) + +// landingPayloads is a fictional store workload, not a captured customer export. +// One minute per request keeps the dense hour below the normal OTLP body limit. +func landingPayloads(seed int64, base time.Time) ([]map[string][]byte, error) { + services := []string{"cart", "currency", "flagd", "frontend", "frontend-proxy", "product-catalog", "checkout", "recommendation", "email", "payment", "shipping", "ad", "quote", "accounting"} + weights := []int{16, 3, 4, 22, 18, 9, 6, 8, 1, 4, 3, 2, 2, 2} + rng := rand.New(rand.NewSource(seed)) + var batches []map[string][]byte + ordinal := 0 + for minute := range 60 { + at := base.Add(-time.Hour + time.Duration(minute)*time.Minute) + count := 2340 + int(260*math.Sin(float64(minute)*2*math.Pi/10)) + int(150*math.Cos(float64(minute)*2*math.Pi/15)) + spans := make([][]*trace.Span, len(services)) + for index := range count { + service, ticket := 0, rng.Intn(100) + for service < len(weights)-1 && ticket >= weights[service] { + ticket -= weights[service] + service++ + } + start := at.Add(time.Duration(index) * time.Minute / time.Duration(count)) + duration := time.Duration(20+rng.Intn(33)) * time.Millisecond + status := trace.Status_STATUS_CODE_OK + if ordinal%10000 == 9999 { + status = trace.Status_STATUS_CODE_ERROR + } + span := &trace.Span{TraceId: identifier(uint64(ordinal/14+1), 16), SpanId: identifier(uint64(ordinal+1), 8), + Name: "GET /" + services[service], Kind: trace.Span_SPAN_KIND_SERVER, + StartTimeUnixNano: uint64(start.UnixNano()), EndTimeUnixNano: uint64(start.Add(duration).UnixNano()), + Status: &trace.Status{Code: status}, Attributes: []*common.KeyValue{attribute("http.request.method", "GET"), attribute("http.route", "/"+services[service])}} + if ordinal%14 != 0 { + span.ParentSpanId = identifier(uint64(ordinal), 8) + } + spans[service] = append(spans[service], span) + ordinal++ + } + traces := &collectortrace.ExportTraceServiceRequest{} + logRequest := &collectorlogs.ExportLogsServiceRequest{} + for index, service := range services { + res := &resource.Resource{Attributes: []*common.KeyValue{attribute("service.name", service), attribute("service.namespace", "shop"), attribute("service.version", "1.0.0")}} + traces.ResourceSpans = append(traces.ResourceSpans, &trace.ResourceSpans{Resource: res, ScopeSpans: []*trace.ScopeSpans{{Spans: spans[index]}}}) + var records []*logs.LogRecord + for sample := range 2 { + severity, label, body := logs.SeverityNumber_SEVERITY_NUMBER_INFO, "INFO", "request completed" + if (minute*28+index*2+sample)%80 == 0 { + severity, label, body = logs.SeverityNumber_SEVERITY_NUMBER_ERROR, "ERROR", "request failed; retry scheduled" + } + stamp := uint64(at.Add(time.Duration(sample*30+index) * time.Second).UnixNano()) + records = append(records, &logs.LogRecord{TimeUnixNano: stamp, ObservedTimeUnixNano: stamp, SeverityNumber: severity, SeverityText: label, Body: &common.AnyValue{Value: &common.AnyValue_StringValue{StringValue: body}}}) + } + logRequest.ResourceLogs = append(logRequest.ResourceLogs, &logs.ResourceLogs{Resource: res, ScopeLogs: []*logs.ScopeLogs{{LogRecords: records}}}) + } + traceBytes, err := (proto.MarshalOptions{Deterministic: true}).Marshal(traces) + if err != nil { + return nil, err + } + logBytes, err := (proto.MarshalOptions{Deterministic: true}).Marshal(logRequest) + if err != nil { + return nil, err + } + batches = append(batches, map[string][]byte{"traces": traceBytes, "logs": logBytes}) + } + return batches, nil +} diff --git a/internal/cmd/e2eseed/landing_test.go b/internal/cmd/e2eseed/landing_test.go new file mode 100644 index 000000000..d6678c6fa --- /dev/null +++ b/internal/cmd/e2eseed/landing_test.go @@ -0,0 +1,99 @@ +package main + +import ( + "bytes" + "testing" + "time" + + collectorlogs "go.opentelemetry.io/proto/otlp/collector/logs/v1" + collectortrace "go.opentelemetry.io/proto/otlp/collector/trace/v1" + logs "go.opentelemetry.io/proto/otlp/logs/v1" + trace "go.opentelemetry.io/proto/otlp/trace/v1" + "google.golang.org/protobuf/proto" +) + +func TestLandingSeedMatchesCaptureWorkload(t *testing.T) { + base := time.Date(2026, 11, 12, 12, 0, 0, 0, time.UTC) + batches, err := landingPayloads(13, base) + if err != nil { + t.Fatal(err) + } + repeated, err := landingPayloads(13, base) + if err != nil { + t.Fatal(err) + } + if len(batches) != 60 { + t.Fatalf("minute batches = %d", len(batches)) + } + services := make(map[string]int) + count, failures, errorLogs := 0, 0, 0 + var durations [100]int + for index, batch := range batches { + for _, signal := range []string{"traces", "logs"} { + if !bytes.Equal(batch[signal], repeated[index][signal]) { + t.Fatalf("%s is not deterministic", signal) + } + if len(batch[signal]) > 1<<20 { + t.Fatalf("%s batch exceeds 1 MiB", signal) + } + } + var traces collectortrace.ExportTraceServiceRequest + if err := proto.Unmarshal(batch["traces"], &traces); err != nil { + t.Fatal(err) + } + for _, resource := range traces.ResourceSpans { + service := resource.Resource.Attributes[0].Value.GetStringValue() + for _, scope := range resource.ScopeSpans { + for _, span := range scope.Spans { + services[service]++ + count++ + if span.Kind != trace.Span_SPAN_KIND_SERVER { + t.Fatal("landing requests must be server spans") + } + if span.StartTimeUnixNano < uint64(base.Add(-time.Hour).UnixNano()) || span.StartTimeUnixNano >= uint64(base.UnixNano()) { + t.Fatal("span falls outside the hour") + } + if span.Status.Code == trace.Status_STATUS_CODE_ERROR { + failures++ + } + durations[(span.EndTimeUnixNano-span.StartTimeUnixNano)/uint64(time.Millisecond)]++ + } + } + } + var logRequest collectorlogs.ExportLogsServiceRequest + if err := proto.Unmarshal(batch["logs"], &logRequest); err != nil { + t.Fatal(err) + } + for _, resource := range logRequest.ResourceLogs { + for _, scope := range resource.ScopeLogs { + for _, record := range scope.LogRecords { + if record.SeverityNumber == logs.SeverityNumber_SEVERITY_NUMBER_ERROR { + errorLogs++ + } + } + } + } + } + if count < 38*3600 || count > 40*3600 || failures != 14 || errorLogs != 21 { + t.Fatalf("spans=%d errors=%d error_logs=%d", count, failures, errorLogs) + } + for _, service := range []string{"cart", "currency", "flagd", "frontend", "frontend-proxy", "product-catalog", "checkout", "recommendation", "email", "payment", "shipping", "ad", "quote", "accounting"} { + if services[service] < 1000 { + t.Fatalf("service %s is not densely seeded: %d spans", service, services[service]) + } + } + if len(services) != 14 { + t.Fatalf("services = %d", len(services)) + } + seen, p95 := 0, 0 + for milliseconds, n := range durations { + seen += n + if seen*100 >= count*95 { + p95 = milliseconds + break + } + } + if p95 < 49 || p95 > 54 { + t.Fatalf("p95 = %d ms", p95) + } +} diff --git a/internal/cmd/e2eseed/main.go b/internal/cmd/e2eseed/main.go index ecdaad835..87524ed93 100644 --- a/internal/cmd/e2eseed/main.go +++ b/internal/cmd/e2eseed/main.go @@ -30,14 +30,15 @@ import ( func main() { endpoint := flag.String("endpoint", "", "Disposable Pitot base URL") tokenFile := flag.String("token-file", "", "Temporary ingest credential file") + landing := flag.Bool("landing", false, "Seed the dense one-hour landing capture workload") flag.Parse() - if err := run(*endpoint, *tokenFile); err != nil { + if err := run(*endpoint, *tokenFile, *landing); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } -func run(endpoint, tokenFile string) error { +func run(endpoint, tokenFile string, landing bool) error { u, err := url.Parse(endpoint) if err != nil || u.Host == "" || (u.Scheme != "http" && u.Scheme != "https") || tokenFile == "" { return errors.New("endpoint and token-file are required") @@ -50,34 +51,49 @@ func run(endpoint, tokenFile string) error { return errors.New("empty token file") } base := time.Now().UTC() - data, err := payloads(13, base) + window := 24 * time.Hour + var batches []map[string][]byte + if landing { + base = base.Truncate(time.Minute) + window = time.Hour + batches, err = landingPayloads(13, base) + } else { + var data map[string][]byte + data, err = payloads(13, base) + batches = []map[string][]byte{data} + } if err != nil { return err } ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() client := &http.Client{Timeout: 30 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }} - for _, signal := range []string{"traces", "logs", "metrics"} { - req, err := http.NewRequestWithContext(ctx, http.MethodPost, strings.TrimRight(endpoint, "/")+"/v1/"+signal, bytes.NewReader(data[signal])) - if err != nil { - return err - } - req.Header.Set("Content-Type", "application/x-protobuf") - req.Header.Set("Authorization", "Bearer "+strings.TrimSpace(string(token))) - resp, err := client.Do(req) - if err != nil { - return fmt.Errorf("post %s failed", signal) - } - _, readErr := io.Copy(io.Discard, resp.Body) - closeErr := resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("post %s: HTTP %d", signal, resp.StatusCode) - } - if readErr != nil || closeErr != nil { - return fmt.Errorf("read %s response failed", signal) + for _, data := range batches { + for _, signal := range []string{"traces", "logs", "metrics"} { + if len(data[signal]) == 0 { + continue + } + req, err := http.NewRequestWithContext(ctx, http.MethodPost, strings.TrimRight(endpoint, "/")+"/v1/"+signal, bytes.NewReader(data[signal])) + if err != nil { + return err + } + req.Header.Set("Content-Type", "application/x-protobuf") + req.Header.Set("Authorization", "Bearer "+strings.TrimSpace(string(token))) + resp, err := client.Do(req) + if err != nil { + return fmt.Errorf("post %s failed", signal) + } + _, readErr := io.Copy(io.Discard, resp.Body) + closeErr := resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("post %s: HTTP %d", signal, resp.StatusCode) + } + if readErr != nil || closeErr != nil { + return fmt.Errorf("read %s response failed", signal) + } } } - fmt.Printf("seed_window=%s,%s\n", base.Add(-24*time.Hour).Format(time.RFC3339Nano), base.Format(time.RFC3339Nano)) + fmt.Printf("seed_window=%s,%s\n", base.Add(-window).Format(time.RFC3339Nano), base.Format(time.RFC3339Nano)) return nil } diff --git a/internal/cmd/e2eseed/main_test.go b/internal/cmd/e2eseed/main_test.go index d42737c37..7986d84bc 100644 --- a/internal/cmd/e2eseed/main_test.go +++ b/internal/cmd/e2eseed/main_test.go @@ -251,7 +251,7 @@ func TestSeedPostsAuthenticatedProtobuf(t *testing.T) { if err := os.WriteFile(file, []byte("smoke-test-token"), 0o600); err != nil { t.Fatal(err) } - if err := run(server.URL, file); err != nil { + if err := run(server.URL, file, false); err != nil { t.Fatal(err) } if len(seen) != 3 { diff --git a/internal/config/config.go b/internal/config/config.go index f5e96b53e..8d9352a2e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -287,8 +287,8 @@ func (c Config) ControlDir() string { } func (c Config) ControlSQLitePath() string { - // Stable on-disk name: opening a new file would hide existing control state. - return filepath.Join(c.ControlDir(), "fanout.sqlite") + // Startup migrates the previous filename before opening this control database. + return filepath.Join(c.ControlDir(), "pitot.sqlite") } // TLSEnabled reports whether a cert/key pair is configured. When true, HTTP diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 985d82d02..50e04b121 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -784,95 +784,19 @@ func TestLoadSCIMToken(t *testing.T) { } } -func TestLegacyEnvironmentCompatibility(t *testing.T) { - for _, test := range []struct { - name string - env []string - want string - warnings int - }{ - {"fallback", []string{"FANOUT_ADDR=:9001", "FANOUT_RETENTION_DAYS=9"}, ":9001", 1}, - {"primary wins", []string{"FANOUT_ADDR=:9001", "PITOT_ADDR=:9002"}, ":9002", 0}, - {"empty primary blocks fallback", []string{"FANOUT_ADDR=:9001", "PITOT_ADDR="}, DefaultAddr, 0}, - {"empty legacy uses default", []string{"FANOUT_ADDR="}, DefaultAddr, 0}, - } { - t.Run(test.name, func(t *testing.T) { - var logs bytes.Buffer - previous := slog.Default() - slog.SetDefault(slog.New(slog.NewTextHandler(&logs, nil))) - t.Cleanup(func() { slog.SetDefault(previous) }) - cfg, err := Load(LoadOptions{Environ: append(validEnvironment(), test.env...)}) - if err != nil { - t.Fatal(err) - } - if cfg.Addr != test.want { - t.Fatalf("address = %q, want %q", cfg.Addr, test.want) - } - if strings.Count(logs.String(), "deprecated environment variables") != test.warnings { - t.Fatalf("unexpected warning count: %s", logs.String()) - } - if test.warnings > 0 && !strings.Contains(logs.String(), "FANOUT_ADDR, FANOUT_RETENTION_DAYS") { - t.Fatal("warning must list every used name") - } - if strings.Contains(logs.String(), ":9001") { - t.Fatal("warning leaked a value") - } - }) - } -} - -func TestLegacySecretFileCompatibility(t *testing.T) { - path := filepath.Join(t.TempDir(), "auth-secret") - value := strings.Repeat("z", 32) - if err := os.WriteFile(path, []byte(value+"\n"), 0600); err != nil { - t.Fatal(err) - } - var logs bytes.Buffer - previous := slog.Default() - slog.SetDefault(slog.New(slog.NewTextHandler(&logs, nil))) - t.Cleanup(func() { slog.SetDefault(previous) }) - cfg, err := Load(LoadOptions{Environ: []string{"FANOUT_AUTH_CODE_SECRET_FILE=" + path}}) +func TestUnrelatedEnvironmentPrefixesAreIgnored(t *testing.T) { + cfg, err := Load(LoadOptions{Environ: append(validEnvironment(), "PREVIOUS_ADDR=:9001", "PREVIOUS_AUTH_CODE_SECRET_FILE=/nonexistent")}) if err != nil { t.Fatal(err) } - if cfg.AuthCodeSecret != value { - t.Fatal("legacy secret file was not loaded") - } - if !strings.Contains(logs.String(), "FANOUT_AUTH_CODE_SECRET_FILE") || strings.Contains(logs.String(), path) || strings.Contains(logs.String(), value) { - t.Fatal("warning must contain only the variable name") - } - _, err = Load(LoadOptions{Environ: []string{"FANOUT_AUTH_CODE_SECRET_FILE=" + path, "PITOT_AUTH_CODE_SECRET=" + value}}) - if err == nil { - t.Fatal("mixed value and file forms must still conflict") - } -} - -func TestLegacySchemaAliasesCoverEveryOwnedSetting(t *testing.T) { - specs, err := configFieldSpecs() - if err != nil { - t.Fatal(err) - } - for _, spec := range specs { - if !strings.HasPrefix(spec.env, "PITOT_") { - continue - } - names := []string{spec.env} - if spec.secret { - names = append(names, spec.env+"_FILE") - } - for _, name := range names { - legacy := strings.Replace(name, "PITOT_", "FANOUT_", 1) - got := ResolveEnvironment([]string{legacy + "="}) - if !reflect.DeepEqual(got, []string{name + "="}) { - t.Fatalf("alias missing for %s", name) - } - } + if cfg.Addr != DefaultAddr { + t.Fatalf("unrelated prefix changed address to %q", cfg.Addr) } } -func TestControlDatabaseKeepsLegacyFilename(t *testing.T) { +func TestControlDatabaseUsesProductFilename(t *testing.T) { cfg := Config{DataDir: t.TempDir()} - if filepath.Base(cfg.ControlSQLitePath()) != "fanout.sqlite" { - t.Fatal("rename must preserve the existing control database") + if filepath.Base(cfg.ControlSQLitePath()) != "pitot.sqlite" { + t.Fatal("control database must use the product filename") } } diff --git a/internal/config/loader.go b/internal/config/loader.go index b7e35795c..8ff053d4c 100644 --- a/internal/config/loader.go +++ b/internal/config/loader.go @@ -2,7 +2,6 @@ package config import ( "fmt" - "log/slog" "os" "reflect" "sort" @@ -49,7 +48,7 @@ func Load(options LoadOptions) (Config, error) { if environ == nil { environ = os.Environ() } - values, err := environmentValues(ResolveEnvironment(environ), known) + values, err := environmentValues(environ, known) if err != nil { return Config{}, err } @@ -98,42 +97,6 @@ func Load(options LoadOptions) (Config, error) { return cfg, nil } -// ResolveEnvironment provides the one-alpha-release legacy environment bridge. -// Presence, including an empty value, takes precedence over the old spelling. -// It reports only names, never values or secret file paths. -func ResolveEnvironment(environ []string) []string { - present := make(map[string]bool, len(environ)) - for _, assignment := range environ { - name, _, _ := strings.Cut(assignment, "=") - present[name] = true - } - resolved := make([]string, 0, len(environ)) - var used []string - for _, assignment := range environ { - name, value, found := strings.Cut(assignment, "=") - if strings.HasPrefix(name, "FANOUT_") { - primary := "PITOT_" + strings.TrimPrefix(name, "FANOUT_") - if present[primary] { - continue - } - if value != "" && !isPlatformInjectedEnvironment(primary) { - used = append(used, name) - } - name = primary - } - if found { - resolved = append(resolved, name+"="+value) - } else { - resolved = append(resolved, name) - } - } - if len(used) > 0 { - sort.Strings(used) - slog.Warn("deprecated environment variables; use PITOT_ equivalents before the next alpha release", "names", strings.Join(used, ", ")) - } - return resolved -} - func configFieldSpecs() ([]fieldSpec, error) { return fieldSpecs(reflect.TypeOf(Config{})) } diff --git a/internal/fanql/failure.go b/internal/fanql/failure.go deleted file mode 100644 index d2da546c9..000000000 --- a/internal/fanql/failure.go +++ /dev/null @@ -1,7 +0,0 @@ -package fanql - -// Failure is the transport-neutral FanQL failure. -type Failure struct { - Code string `json:"code"` - Message string `json:"message"` -} diff --git a/internal/mcp/fanql_resource.go b/internal/mcp/fanql_resource.go deleted file mode 100644 index 89f0c92ef..000000000 --- a/internal/mcp/fanql_resource.go +++ /dev/null @@ -1,19 +0,0 @@ -package mcp - -import ( - "context" - - "github.com/labstack/pitot/internal/fanql" - "github.com/modelcontextprotocol/go-sdk/mcp" -) - -const fanqlReferenceURI = "pitot://fanql/reference" - -func (s *Server) registerFanQLResource() { - s.mcp.AddResource(&mcp.Resource{ - URI: fanqlReferenceURI, Name: "FanQL reference", MIMEType: "text/markdown", - Description: "The FanQL preview language reference, generated from the server registries.", - }, func(_ context.Context, _ *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error) { - return &mcp.ReadResourceResult{Contents: []*mcp.ResourceContents{{URI: fanqlReferenceURI, MIMEType: "text/markdown", Text: fanql.Reference()}}}, nil - }) -} diff --git a/internal/mcp/fragments.go b/internal/mcp/fragments.go index 62f2b6f31..1641a64da 100644 --- a/internal/mcp/fragments.go +++ b/internal/mcp/fragments.go @@ -14,31 +14,31 @@ import ( "unicode/utf8" "github.com/google/jsonschema-go/jsonschema" - "github.com/labstack/pitot/internal/fanql" "github.com/labstack/pitot/internal/observability" + "github.com/labstack/pitot/internal/pitotql" "github.com/labstack/pitot/internal/query" "github.com/modelcontextprotocol/go-sdk/mcp" ) type QueryTelemetryInput struct { Panel query.Panel `json:"panel" jsonschema:"One v1 panel to display in the answer"` - Text string `json:"text,omitempty" jsonschema:"FanQL text that becomes panel.query; prefer panel.query (structured) or panel.sql; see pitot://fanql/reference"` + Text string `json:"text,omitempty" jsonschema:"PitotQL text that becomes panel.query; prefer panel.query (structured) or panel.sql; see pitot://pitotql/reference"` Variables []query.Variable `json:"variables,omitempty" jsonschema:"Optional v1 variable definitions used by this panel"` Time *query.Time `json:"time,omitempty" jsonschema:"Optional dashboard time override: exact from/to or a relative range"` Vars map[string]query.Value `json:"vars,omitempty" jsonschema:"Resolved variable values: strings or lists; preserves $__all and empty lists"` } -type fanqlToolFailureOutput struct { - Error fanql.Failure `json:"error"` - Problems query.Problems `json:"problems,omitempty"` +type pitotqlToolFailureOutput struct { + Error pitotql.Failure `json:"error"` + Problems query.Problems `json:"problems,omitempty"` } -// QueryTelemetryOutput includes FanQL failures without changing preset fragments. +// QueryTelemetryOutput includes PitotQL failures without changing preset fragments. type QueryTelemetryOutput struct { *PanelFragment - Notices []fanql.Notice `json:"notices,omitempty"` - Error *fanql.Failure `json:"error,omitempty"` - Problems query.Problems `json:"problems,omitempty"` + Notices []pitotql.Notice `json:"notices,omitempty"` + Error *pitotql.Failure `json:"error,omitempty"` + Problems query.Problems `json:"problems,omitempty"` } type FragmentView struct { Kind string `json:"kind" jsonschema:"View kind: preset or query"` @@ -85,7 +85,7 @@ func fragmentTool[In, Out any](server *Server, tool *mcp.Tool, handler mcp.ToolH panic(err) } success.Properties["notices"] = output.Properties["notices"] - failure, err := jsonschema.For[fanqlToolFailureOutput](options) + failure, err := jsonschema.For[pitotqlToolFailureOutput](options) if err != nil { panic(err) } @@ -190,11 +190,11 @@ func (s *Server) queryTelemetry(ctx context.Context, _ *mcp.CallToolRequest, inp if input.Text != "" && (input.Panel.Query != nil || input.Panel.SQL != "") { return nil, QueryTelemetryOutput{}, guidanceError("invalid_input", "text cannot be combined with panel.query or panel.sql") } - var notices []fanql.Notice + var notices []pitotql.Notice if input.Text != "" { - compiled, problems := fanql.Compile(input.Text, fanql.Options{Viz: input.Panel.Viz, Variables: input.Variables}) + compiled, problems := pitotql.Compile(input.Text, pitotql.Options{Viz: input.Panel.Viz, Variables: input.Variables}) if len(problems) != 0 { - return fanqlToolFailure(fanql.Failure{Code: "invalid_fanql", Message: "The query has problems."}, query.Diagnoses(problems)) + return pitotqlToolFailure(pitotql.Failure{Code: "invalid_pitotql", Message: "The query has problems."}, query.Diagnoses(problems)) } input.Panel.Query = &compiled.Query notices = append(notices, compiled.Notices...) @@ -792,7 +792,7 @@ func boundFragment(ctx context.Context, fragment PanelFragment) (PanelFragment, return out, nil } -func fanqlToolFailure(problem fanql.Failure, problems query.Problems) (*mcp.CallToolResult, QueryTelemetryOutput, error) { +func pitotqlToolFailure(problem pitotql.Failure, problems query.Problems) (*mcp.CallToolResult, QueryTelemetryOutput, error) { result := summary(problem.Message) result.IsError = true return result, QueryTelemetryOutput{Error: &problem, Problems: problems}, nil diff --git a/internal/mcp/panels.go b/internal/mcp/panels.go index 296e4f1fa..025fc4765 100644 --- a/internal/mcp/panels.go +++ b/internal/mcp/panels.go @@ -48,7 +48,7 @@ const baseSpecGuide = `A dashboard is {name, description, time:{range}, variable func (s *Server) registerPanelTools() { readOnly := &mcp.ToolAnnotations{ReadOnlyHint: true, OpenWorldHint: boolPtr(false)} - fragmentTool(s, &mcp.Tool{Name: "query_telemetry", Title: "Telemetry panel", Description: "Display one v1 panel in chat as an executable dashboard fragment. Use get_telemetry_schema to discover fields; see create_dashboard for the spec guide. The authored spec plus vars must fit 128 KiB (131072 serialized JSON bytes); larger inputs are rejected with their actual size. Agents: write panel.query (structured JSON) first, or panel.sql for complex work; text accepts FanQL: source [where] filters | measures by fields every bucket sort key limit n. Examples: spans where status:error | count() by service; logs where severity>=warn | count() by service every 1m. See pitot://fanql/reference for fields, operators and variables.", Annotations: readOnly, Meta: appToolMeta(panelsAppURI)}, s.queryTelemetry) + fragmentTool(s, &mcp.Tool{Name: "query_telemetry", Title: "Telemetry panel", Description: "Display one v1 panel in chat as an executable dashboard fragment. Use get_telemetry_schema to discover fields; see create_dashboard for the spec guide. The authored spec plus vars must fit 128 KiB (131072 serialized JSON bytes); larger inputs are rejected with their actual size. Agents: write panel.query (structured JSON) first, or panel.sql for complex work; text accepts PitotQL: source [where] filters | measures by fields every bucket sort key limit n. Examples: spans where status:error | count() by service; logs where severity>=warn | count() by service every 1m. See pitot://pitotql/reference for fields, operators and variables.", Annotations: readOnly, Meta: appToolMeta(panelsAppURI)}, s.queryTelemetry) fragmentTool(s, &mcp.Tool{Name: "query_panel_fragment", Title: "Refresh telemetry panels", Description: "Run every panel in a dashboard fragment; panel subsets are forbidden.", Annotations: readOnly, Meta: appHelperMeta()}, func(ctx context.Context, req *mcp.CallToolRequest, input fragmentInput) (*mcp.CallToolResult, PanelFragment, error) { return s.queryPanelFragment(ctx, req, query.RunRequest{Dashboard: input.Dashboard, Time: input.Time, Vars: input.Vars, Widths: input.Widths, Compare: input.Compare}) }) diff --git a/internal/mcp/pitotql_resource.go b/internal/mcp/pitotql_resource.go new file mode 100644 index 000000000..c1f42abad --- /dev/null +++ b/internal/mcp/pitotql_resource.go @@ -0,0 +1,36 @@ +package mcp + +import ( + "context" + + "github.com/labstack/pitot/internal/pitotql" + "github.com/modelcontextprotocol/go-sdk/mcp" +) + +const previousQueryReferenceURI = "pitot://fanql/reference" // Published read alias. + +const pitotqlReferenceURI = "pitot://pitotql/reference" + +func (s *Server) registerPitotQLResource() { + + s.mcp.AddResource(&mcp.Resource{ + URI: pitotqlReferenceURI, Name: "PitotQL reference", MIMEType: "text/markdown", + Description: "The PitotQL preview language reference, generated from the server registries.", + }, func(_ context.Context, _ *mcp.ReadResourceRequest) (*mcp.ReadResourceResult, error) { + return &mcp.ReadResourceResult{Contents: []*mcp.ResourceContents{{URI: pitotqlReferenceURI, MIMEType: "text/markdown", Text: pitotql.Reference()}}}, nil + }) +} + +// canonicalQueryResource accepts the published URI without advertising it. +func canonicalQueryResource(next mcp.MethodHandler) mcp.MethodHandler { + return func(ctx context.Context, method string, req mcp.Request) (mcp.Result, error) { + if read, ok := req.(*mcp.ReadResourceRequest); ok && method == "resources/read" && read.Params != nil && read.Params.URI == previousQueryReferenceURI { + copied := *read + params := *read.Params + params.URI = pitotqlReferenceURI + copied.Params = ¶ms + req = &copied + } + return next(ctx, method, req) + } +} diff --git a/internal/mcp/fanql_test.go b/internal/mcp/pitotql_test.go similarity index 75% rename from internal/mcp/fanql_test.go rename to internal/mcp/pitotql_test.go index f959d8b77..9990affee 100644 --- a/internal/mcp/fanql_test.go +++ b/internal/mcp/pitotql_test.go @@ -8,13 +8,13 @@ import ( "strings" "testing" - "github.com/labstack/pitot/internal/fanql" + "github.com/labstack/pitot/internal/pitotql" "github.com/labstack/pitot/internal/query" "github.com/labstack/pitot/internal/toolerror" "github.com/modelcontextprotocol/go-sdk/mcp" ) -func TestQueryTelemetryAcceptsFanQLText(t *testing.T) { +func TestQueryTelemetryAcceptsPitotQLText(t *testing.T) { s := panelServerFixture(t, true) p := query.Panel{ID: "t", Title: "t", Viz: "table"} input := QueryTelemetryInput{Panel: p, Text: "spans where status:error | count() by service"} @@ -39,20 +39,20 @@ func TestQueryTelemetryAcceptsFanQLText(t *testing.T) { } } -type fanqlRunCounter struct { +type pitotqlRunCounter struct { panelExecutor calls int } -func (e *fanqlRunCounter) Run(ctx context.Context, req query.RunRequest) ([]query.Result, error) { +func (e *pitotqlRunCounter) Run(ctx context.Context, req query.RunRequest) ([]query.Result, error) { e.calls++ return e.panelExecutor.Run(ctx, req) } -func checkFanQLToolFailure(t *testing.T, input QueryTelemetryInput, code, message string) { +func checkPitotQLToolFailure(t *testing.T, input QueryTelemetryInput, code, message string) { t.Helper() s := newPanelServer(t) - counter := &fanqlRunCounter{panelExecutor: s.panels} + counter := &pitotqlRunCounter{panelExecutor: s.panels} s.panels = counter result, out, err := s.queryTelemetry(t.Context(), nil, input) var raw []byte @@ -74,15 +74,15 @@ func checkFanQLToolFailure(t *testing.T, input QueryTelemetryInput, code, messag func TestQueryTelemetryRejectsTextWithQueryOrSQL(t *testing.T) { for _, p := range []query.Panel{{Query: &query.Spec{From: "spans"}}, {SQL: "SELECT 1"}} { - checkFanQLToolFailure(t, QueryTelemetryInput{Panel: p, Text: "spans"}, "invalid_input", "text cannot be combined with panel.query or panel.sql") + checkPitotQLToolFailure(t, QueryTelemetryInput{Panel: p, Text: "spans"}, "invalid_input", "text cannot be combined with panel.query or panel.sql") } } -func TestQueryTelemetryReportsFanQLProblems(t *testing.T) { - checkFanQLToolFailure(t, QueryTelemetryInput{Text: "spans where a:1 b:2 or c:3"}, "invalid_fanql", "The query has problems.") +func TestQueryTelemetryReportsPitotQLProblems(t *testing.T) { + checkPitotQLToolFailure(t, QueryTelemetryInput{Text: "spans where a:1 b:2 or c:3"}, "invalid_pitotql", "The query has problems.") } -func TestFanQLReferenceResource(t *testing.T) { +func TestPitotQLReferenceResource(t *testing.T) { s := newPanelServer(t) client := connectTestClient(t, s, nil) listed, err := client.ListResources(t.Context(), nil) @@ -91,21 +91,21 @@ func TestFanQLReferenceResource(t *testing.T) { } found := false for _, r := range listed.Resources { - if r.URI == "pitot://fanql/reference" { + if r.URI == "pitot://pitotql/reference" { found = true - if r.Name != "FanQL reference" || r.MIMEType != "text/markdown" { + if r.Name != "PitotQL reference" || r.MIMEType != "text/markdown" { t.Fatal(r) } } } if !found { - t.Fatal("FanQL reference missing from resources/list") + t.Fatal("PitotQL reference missing from resources/list") } - r, err := client.ReadResource(t.Context(), &mcp.ReadResourceParams{URI: "pitot://fanql/reference"}) + r, err := client.ReadResource(t.Context(), &mcp.ReadResourceParams{URI: "pitot://pitotql/reference"}) if err != nil { t.Fatal(err) } - if len(r.Contents) != 1 || r.Contents[0].MIMEType != "text/markdown" || r.Contents[0].Text != fanql.Reference() || !strings.Contains(r.Contents[0].Text, "# FanQL") || !strings.Contains(r.Contents[0].Text, "Preview") { + if len(r.Contents) != 1 || r.Contents[0].MIMEType != "text/markdown" || r.Contents[0].Text != pitotql.Reference() || !strings.Contains(r.Contents[0].Text, "# PitotQL") || !strings.Contains(r.Contents[0].Text, "Preview") { t.Fatal(r) } } @@ -121,7 +121,7 @@ func TestQueryTelemetryDescriptionPrefersStructuredInput(t *testing.T) { continue } d := tool.Description - if !strings.Contains(d, "panel.query") || strings.Index(d, "text") < strings.Index(d, "panel.query") || !strings.Contains(d, "pitot://fanql/reference") { + if !strings.Contains(d, "panel.query") || strings.Index(d, "text") < strings.Index(d, "panel.query") || !strings.Contains(d, "pitot://pitotql/reference") { t.Fatal(d) } if tool.Annotations == nil || !tool.Annotations.ReadOnlyHint { @@ -135,7 +135,7 @@ func TestQueryTelemetryDescriptionPrefersStructuredInput(t *testing.T) { if err := json.Unmarshal(raw, &input); err != nil { t.Fatal(err) } - if input.Properties["text"] == nil || input.Properties["fanql_version"] != nil { + if input.Properties["text"] == nil || input.Properties["pitotql_version"] != nil { t.Fatalf("text contract: %s", raw) } for _, field := range input.Required { @@ -144,7 +144,7 @@ func TestQueryTelemetryDescriptionPrefersStructuredInput(t *testing.T) { } } raw, _ = json.Marshal(tool.OutputSchema) - if strings.Contains(string(raw), "fanql_version") { + if strings.Contains(string(raw), "pitotql_version") { t.Fatalf("output version: %s", raw) } return @@ -152,7 +152,7 @@ func TestQueryTelemetryDescriptionPrefersStructuredInput(t *testing.T) { t.Fatal("query_telemetry missing") } -func TestQueryTelemetryFanQLMetadataAndStructuredProblems(t *testing.T) { +func TestQueryTelemetryPitotQLMetadataAndStructuredProblems(t *testing.T) { s := panelServerFixture(t, true) _, out, err := s.queryTelemetry(t.Context(), nil, QueryTelemetryInput{Panel: query.Panel{ID: "t", Title: "t", Viz: "table"}, Text: "spans where status:error | count() by service"}) if err != nil { @@ -167,7 +167,7 @@ func TestQueryTelemetryFanQLMetadataAndStructuredProblems(t *testing.T) { Error toolerror.Error `json:"error"` Problems query.Problems `json:"problems"` } - if err != nil || result == nil || !result.IsError || json.Unmarshal(raw, &failure) != nil || failure.Error.Code != "invalid_fanql" || len(failure.Problems) != 1 || failure.Problems[0].Span == nil || len(failure.Problems[0].FixIts) != 2 { + if err != nil || result == nil || !result.IsError || json.Unmarshal(raw, &failure) != nil || failure.Error.Code != "invalid_pitotql" || len(failure.Problems) != 1 || failure.Problems[0].Span == nil || len(failure.Problems[0].FixIts) != 2 { t.Fatalf("structured failure: %v", err) } client := connectTestClient(t, s, nil) @@ -186,7 +186,7 @@ func TestQueryTelemetryFanQLMetadataAndStructuredProblems(t *testing.T) { } } -func TestQueryTelemetryFanQLProblemsStayStructuredThroughMiddleware(t *testing.T) { +func TestQueryTelemetryPitotQLProblemsStayStructuredThroughMiddleware(t *testing.T) { client := connectTestClient(t, newPanelServer(t), nil) result, err := client.CallTool(t.Context(), &mcp.CallToolParams{Name: "query_telemetry", Arguments: map[string]any{ "panel": map[string]any{"id": "errors", "title": "Errors", "viz": "table"}, @@ -201,21 +201,21 @@ func TestQueryTelemetryFanQLProblemsStayStructuredThroughMiddleware(t *testing.T Error toolerror.Error `json:"error"` Problems query.Problems `json:"problems"` } - if json.Unmarshal(raw, &body) != nil || body.Error.Code != "invalid_fanql" || len(body.Problems) != 1 || body.Problems[0].Span == nil || len(body.Problems[0].FixIts) != 2 { + if json.Unmarshal(raw, &body) != nil || body.Error.Code != "invalid_pitotql" || len(body.Problems) != 1 || body.Problems[0].Span == nil || len(body.Problems[0].FixIts) != 2 { t.Fatalf("structured failure: %s", raw) } } } func TestQueryTelemetryUsesNeutralFailure(t *testing.T) { - out := QueryTelemetryOutput{Error: &fanql.Failure{Code: "invalid_fanql", Message: "The query has problems."}} + out := QueryTelemetryOutput{Error: &pitotql.Failure{Code: "invalid_pitotql", Message: "The query has problems."}} raw, err := json.Marshal(out) - if err != nil || string(raw) != `{"error":{"code":"invalid_fanql","message":"The query has problems."}}` { + if err != nil || string(raw) != `{"error":{"code":"invalid_pitotql","message":"The query has problems."}}` { t.Fatalf("failure: %s %v", raw, err) } } -func TestPresetSchemasExcludeFanQLMetadata(t *testing.T) { +func TestPresetSchemasExcludePitotQLMetadata(t *testing.T) { client := connectTestClient(t, newPanelServer(t), nil) listed, err := client.ListTools(t.Context(), nil) if err != nil { @@ -285,3 +285,23 @@ func TestQueryTelemetryKeepsInvalidPanelProblems(t *testing.T) { } } + +func TestPreviousQueryReferenceReadsCanonicalResource(t *testing.T) { + client := connectTestClient(t, newPanelServer(t), nil) + listed, err := client.ListResources(t.Context(), nil) + if err != nil { + t.Fatal(err) + } + for _, resource := range listed.Resources { + if resource.URI == previousQueryReferenceURI { + t.Fatal("read alias advertised") + } + } + result, err := client.ReadResource(t.Context(), &mcp.ReadResourceParams{URI: previousQueryReferenceURI}) + if err != nil { + t.Fatal(err) + } + if len(result.Contents) != 1 || result.Contents[0].URI != pitotqlReferenceURI || result.Contents[0].Text != pitotql.Reference() { + t.Fatalf("resource = %+v", result) + } +} diff --git a/internal/mcp/server.go b/internal/mcp/server.go index 119d8df61..379d77419 100644 --- a/internal/mcp/server.go +++ b/internal/mcp/server.go @@ -142,8 +142,8 @@ func newServer(queries Observability, dashboards *dashboard.Service, panels *que s.registerPanelTools() s.registerDashboardTools() s.registerAppResources() - s.registerFanQLResource() - s.mcp.AddReceivingMiddleware(limitLegacySessions(s.mcp), normalizeToolErrors, recoverToolPanic, addStaticCacheHints, filterMCPAppToolMetadata, s.validateToolArguments) + s.registerPitotQLResource() + s.mcp.AddReceivingMiddleware(limitLegacySessions(s.mcp), canonicalQueryResource, normalizeToolErrors, recoverToolPanic, addStaticCacheHints, filterMCPAppToolMetadata, s.validateToolArguments) return s } diff --git a/internal/fanql/ast.go b/internal/pitotql/ast.go similarity index 99% rename from internal/fanql/ast.go rename to internal/pitotql/ast.go index bf7d98160..1043b58d5 100644 --- a/internal/fanql/ast.go +++ b/internal/pitotql/ast.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import "github.com/labstack/pitot/internal/query" diff --git a/internal/fanql/bounds_test.go b/internal/pitotql/bounds_test.go similarity index 99% rename from internal/fanql/bounds_test.go rename to internal/pitotql/bounds_test.go index 336cf4018..415266494 100644 --- a/internal/fanql/bounds_test.go +++ b/internal/pitotql/bounds_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "reflect" diff --git a/internal/fanql/complete.go b/internal/pitotql/complete.go similarity index 99% rename from internal/fanql/complete.go rename to internal/pitotql/complete.go index dcebf03e3..4a36c63b4 100644 --- a/internal/fanql/complete.go +++ b/internal/pitotql/complete.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" @@ -612,7 +612,7 @@ func (s *completionCandidates) values(e expect) { if column.Name == key { for _, v := range column.Values { if key == "severity" { - // Stored levels are uppercase; FanQL spells them in + // Stored levels are uppercase; PitotQL spells them in // lowercase, as it does the standard bands. addValue(strings.ToLower(v.Value), v.Value, printValue(literalValue{Kind: stringValue, Text: strings.ToLower(v.Value)}, *f, false), v.Count) continue diff --git a/internal/fanql/complete_test.go b/internal/pitotql/complete_test.go similarity index 99% rename from internal/fanql/complete_test.go rename to internal/pitotql/complete_test.go index de64a674f..b75d499da 100644 --- a/internal/fanql/complete_test.go +++ b/internal/pitotql/complete_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" diff --git a/internal/fanql/corpus_test.go b/internal/pitotql/corpus_test.go similarity index 97% rename from internal/fanql/corpus_test.go rename to internal/pitotql/corpus_test.go index c69c00dff..61bd5aa63 100644 --- a/internal/fanql/corpus_test.go +++ b/internal/pitotql/corpus_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "encoding/json" @@ -103,7 +103,7 @@ func TestCanonicalFreeze(t *testing.T) { t.Fatal(f.Text, ps) } if want, ok := golden[f.Text]; !ok || c.Canonical != want { - t.Fatalf("FanQL canonical changed for %q: %q; pinned %q", f.Text, c.Canonical, want) + t.Fatalf("PitotQL canonical changed for %q: %q; pinned %q", f.Text, c.Canonical, want) } } if len(golden) != len(clean) { diff --git a/internal/fanql/diagnostic_copy_test.go b/internal/pitotql/diagnostic_copy_test.go similarity index 97% rename from internal/fanql/diagnostic_copy_test.go rename to internal/pitotql/diagnostic_copy_test.go index b2727992f..9a1b5fe2a 100644 --- a/internal/fanql/diagnostic_copy_test.go +++ b/internal/pitotql/diagnostic_copy_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "github.com/labstack/pitot/internal/query" @@ -53,7 +53,7 @@ func TestCorpusDiagnosticCopy(t *testing.T) { _, problems := Compile(fixture.Text, Options{Viz: fixture.Viz}) for _, p := range problems { copy := p.Message + " " + p.Hint - for _, internal := range []string{"FanQL 1", "log_patterns", "state_timeline", "service_map"} { + for _, internal := range []string{"PitotQL 1", "log_patterns", "state_timeline", "service_map"} { if strings.Contains(copy, internal) { t.Errorf("%q exposes %q: %s", fixture.Text, internal, copy) } diff --git a/internal/fanql/diagnostics_test.go b/internal/pitotql/diagnostics_test.go similarity index 95% rename from internal/fanql/diagnostics_test.go rename to internal/pitotql/diagnostics_test.go index 7a13f79ef..a1ccdc39e 100644 --- a/internal/fanql/diagnostics_test.go +++ b/internal/pitotql/diagnostics_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "strings" @@ -240,7 +240,7 @@ func TestCompileMetricAggregateNamesMisspelledName(t *testing.T) { } // A misspelled measure function offers the nearest function as a fix-it on -// its name; a percentile FanQL lacks offers swapped digits and quantile. +// its name; a percentile PitotQL lacks offers swapped digits and quantile. func TestCompileUnknownMeasureOffersFix(t *testing.T) { for _, tt := range []struct{ text, message string }{ {"spans | cuont()", "unknown function cuont; did you mean count?"}, @@ -275,14 +275,14 @@ func TestCompileUnknownMeasureOffersFix(t *testing.T) { // PromQL and Kusto get one message for the whole query, not a cascade. func TestCompileForeignQueryLanguages(t *testing.T) { - const promql = "PromQL is not FanQL; start with the source, e.g. metrics where name:http.server.request.duration | rate() by service" + const promql = "PromQL is not PitotQL; start with the source, e.g. metrics where name:http.server.request.duration | rate() by service" for _, tt := range []struct{ text, message string }{ {"sum(rate(http_server_requests_total[5m])) by (service)", promql}, {"http_server_duration_seconds_bucket", promql}, {`rate(traces_span_metrics_calls_total{service="cart"}[1m])`, promql}, {`up{job="api"}`, promql}, - {"spans | where service == 'cart' | summarize count() by service", "Kusto is not FanQL; filters follow the source and measures follow one |, e.g. spans where service:api | count() by service"}, - {"logs | where service:cart | project body", "Kusto is not FanQL; filters follow the source and measures follow one |, e.g. logs where service:api | count() by service"}, + {"spans | where service == 'cart' | summarize count() by service", "Kusto is not PitotQL; filters follow the source and measures follow one |, e.g. spans where service:api | count() by service"}, + {"logs | where service:cart | project body", "Kusto is not PitotQL; filters follow the source and measures follow one |, e.g. logs where service:api | count() by service"}, } { _, ps := Compile(tt.text, Options{}) if len(ps) != 1 || ps[0].Message != tt.message { @@ -291,7 +291,7 @@ func TestCompileForeignQueryLanguages(t *testing.T) { } // Only the pipe is wrong: the fix-it removes it and the rest still parses. _, ps := Compile("spans | where service:cart | count() by service", Options{}) - if len(ps) != 1 || ps[0].Message != "| where is not FanQL; filters follow the source, e.g. spans where service:api | count()" || + if len(ps) != 1 || ps[0].Message != "| where is not PitotQL; filters follow the source, e.g. spans where service:api | count()" || len(ps[0].FixIts) != 1 || ps[0].FixIts[0].Text != "where" || *ps[0].Span != (query.TextSpan{Start: 6, End: 13}) { t.Errorf("pipe where: %+v", ps) } diff --git a/internal/pitotql/failure.go b/internal/pitotql/failure.go new file mode 100644 index 000000000..e927aa115 --- /dev/null +++ b/internal/pitotql/failure.go @@ -0,0 +1,23 @@ +package pitotql + +import "encoding/json" + +// Failure is the transport-neutral PitotQL failure. +type Failure struct { + Code string `json:"code"` + Message string `json:"message"` +} + +// UnmarshalJSON accepts recorded responses from before the language rename. +func (f *Failure) UnmarshalJSON(data []byte) error { + type plain Failure + var value plain + if err := json.Unmarshal(data, &value); err != nil { + return err + } + if value.Code == "invalid_fanql" { + value.Code = "invalid_pitotql" + } + *f = Failure(value) + return nil +} diff --git a/internal/pitotql/failure_test.go b/internal/pitotql/failure_test.go new file mode 100644 index 000000000..873aa1af2 --- /dev/null +++ b/internal/pitotql/failure_test.go @@ -0,0 +1,17 @@ +package pitotql + +import ( + "encoding/json" + "testing" +) + +func TestRecordedFailureReadsPreviousCodeAndWritesCurrentCode(t *testing.T) { + var failure Failure + if err := json.Unmarshal([]byte(`{"code":"invalid_fanql","message":"The query has problems."}`), &failure); err != nil { + t.Fatal(err) + } + raw, err := json.Marshal(failure) + if err != nil || string(raw) != `{"code":"invalid_pitotql","message":"The query has problems."}` { + t.Fatalf("failure = %s, %v", raw, err) + } +} diff --git a/internal/fanql/filter_exactness_test.go b/internal/pitotql/filter_exactness_test.go similarity index 99% rename from internal/fanql/filter_exactness_test.go rename to internal/pitotql/filter_exactness_test.go index 5af7b9329..1171435df 100644 --- a/internal/fanql/filter_exactness_test.go +++ b/internal/pitotql/filter_exactness_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "reflect" diff --git a/internal/fanql/format.go b/internal/pitotql/format.go similarity index 97% rename from internal/fanql/format.go rename to internal/pitotql/format.go index b3ccb5b38..7408a8bd1 100644 --- a/internal/fanql/format.go +++ b/internal/pitotql/format.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" @@ -28,7 +28,7 @@ type Formatted struct { Editable bool `json:"editable"` Reason string `json:"reason,omitempty"` Notices []Notice `json:"notices"` - // Each stored filter and measure as FanQL, in stored order, so an editor + // Each stored filter and measure as PitotQL, in stored order, so an editor // can label entries it cannot edit without showing their SQL. Where []string `json:"where"` Measures []string `json:"measures"` @@ -107,7 +107,7 @@ func Format(ctx context.Context, p query.Parser, stored query.Spec, opts Options if stored.Histogram != nil { field, ok := liftFieldText(stored.From, stored.Histogram.Field) if !ok { - return nil, query.Problems{{Path: "histogram.field", Message: "histogram field cannot be expressed in FanQL"}}, nil + return nil, query.Problems{{Path: "histogram.field", Message: "histogram field cannot be expressed in PitotQL"}}, nil } q.Stage.Histogram = &field } else { @@ -130,7 +130,7 @@ func Format(ctx context.Context, p query.Parser, stored query.Spec, opts Options for _, text := range stored.By { field, ok := liftFieldText(stored.From, text) if !ok { - return nil, query.Problems{{Path: "by", Message: "grouping field cannot be expressed in FanQL"}}, nil + return nil, query.Problems{{Path: "by", Message: "grouping field cannot be expressed in PitotQL"}}, nil } q.Stage.By = append(q.Stage.By, field) } diff --git a/internal/fanql/format_copy_test.go b/internal/pitotql/format_copy_test.go similarity index 96% rename from internal/fanql/format_copy_test.go rename to internal/pitotql/format_copy_test.go index e379e0855..64af60c61 100644 --- a/internal/fanql/format_copy_test.go +++ b/internal/pitotql/format_copy_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "testing" diff --git a/internal/fanql/fuzz_test.go b/internal/pitotql/fuzz_test.go similarity index 99% rename from internal/fanql/fuzz_test.go rename to internal/pitotql/fuzz_test.go index 4a3033658..72fc0f3a2 100644 --- a/internal/fanql/fuzz_test.go +++ b/internal/pitotql/fuzz_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "encoding/json" @@ -166,7 +166,7 @@ func TestStructuredGeneratorCoversConditionalMeasuresAndArithmetic(t *testing.T) } // generatedStructuredQuery is generator B: a bounded grammar of SQL accepted -// by the existing gate, independent of FanQL's own lowerer and printer. +// by the existing gate, independent of PitotQL's own lowerer and printer. func generatedStructuredQuery(data []byte) query.Spec { byteAt := func(i int) byte { if len(data) == 0 { diff --git a/internal/fanql/hints_test.go b/internal/pitotql/hints_test.go similarity index 89% rename from internal/fanql/hints_test.go rename to internal/pitotql/hints_test.go index 49fea9e22..dfdcd2aa3 100644 --- a/internal/fanql/hints_test.go +++ b/internal/pitotql/hints_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" @@ -10,17 +10,17 @@ import ( ) // Foreign forms get one problem with a fix-it that makes the query valid. -func TestCompileForeignFormsFixToFanQL(t *testing.T) { +func TestCompileForeignFormsFixToPitotQL(t *testing.T) { for _, tt := range []struct{ text, message, fixed string }{ - {"spans | percentile(duration, 0.95)", "percentile(...) is not FanQL; write quantile(duration, 0.95)", "spans | quantile(duration, 0.95)"}, - {"spans | percentile(duration, 99.9)", "percentile(...) is not FanQL; write quantile(duration, 0.999)", "spans | quantile(duration, 0.999)"}, - {"spans | percentile(duration, 95) by service", "percentile(...) is not FanQL; write p95(duration)", "spans | p95(duration) by service"}, - {"spans | percentile(duration, 95) every 1m", "percentile(...) is not FanQL; write p95(duration)", "spans | p95(duration) every 1m"}, - {"spans | count() group by service", `"group by" is not FanQL; use by after measures, e.g. | count() by service`, "spans | count() by service"}, - {"spans | count() GROUP BY service", `"group by" is not FanQL; use by after measures, e.g. | count() by service`, "spans | count() by service"}, - {"spans | count() | group by service", `"group by" is not FanQL; use by after measures, e.g. | count() by service`, "spans | count() by service"}, - {"spans take 10", `"take" is not FanQL; use limit, e.g. limit 10`, "spans limit 10"}, - {"spans where service:x head 5", `"head" is not FanQL; use limit, e.g. limit 5`, "spans where service:x limit 5"}, + {"spans | percentile(duration, 0.95)", "percentile(...) is not PitotQL; write quantile(duration, 0.95)", "spans | quantile(duration, 0.95)"}, + {"spans | percentile(duration, 99.9)", "percentile(...) is not PitotQL; write quantile(duration, 0.999)", "spans | quantile(duration, 0.999)"}, + {"spans | percentile(duration, 95) by service", "percentile(...) is not PitotQL; write p95(duration)", "spans | p95(duration) by service"}, + {"spans | percentile(duration, 95) every 1m", "percentile(...) is not PitotQL; write p95(duration)", "spans | p95(duration) every 1m"}, + {"spans | count() group by service", `"group by" is not PitotQL; use by after measures, e.g. | count() by service`, "spans | count() by service"}, + {"spans | count() GROUP BY service", `"group by" is not PitotQL; use by after measures, e.g. | count() by service`, "spans | count() by service"}, + {"spans | count() | group by service", `"group by" is not PitotQL; use by after measures, e.g. | count() by service`, "spans | count() by service"}, + {"spans take 10", `"take" is not PitotQL; use limit, e.g. limit 10`, "spans limit 10"}, + {"spans where service:x head 5", `"head" is not PitotQL; use limit, e.g. limit 5`, "spans where service:x limit 5"}, } { c, ps := Compile(tt.text, Options{}) if c != nil || len(ps) != 1 || ps[0].Message != tt.message || len(ps[0].FixIts) == 0 { diff --git a/internal/fanql/instrumentation_plain_test.go b/internal/pitotql/instrumentation_plain_test.go similarity index 76% rename from internal/fanql/instrumentation_plain_test.go rename to internal/pitotql/instrumentation_plain_test.go index 66693862d..2b640396c 100644 --- a/internal/fanql/instrumentation_plain_test.go +++ b/internal/pitotql/instrumentation_plain_test.go @@ -1,5 +1,5 @@ //go:build !race -package fanql +package pitotql const raceInstrumentation = false diff --git a/internal/fanql/instrumentation_race_test.go b/internal/pitotql/instrumentation_race_test.go similarity index 76% rename from internal/fanql/instrumentation_race_test.go rename to internal/pitotql/instrumentation_race_test.go index 2463fcf98..93cd4fcaa 100644 --- a/internal/fanql/instrumentation_race_test.go +++ b/internal/pitotql/instrumentation_race_test.go @@ -1,5 +1,5 @@ //go:build race -package fanql +package pitotql const raceInstrumentation = true diff --git a/internal/fanql/latency_test.go b/internal/pitotql/latency_test.go similarity index 98% rename from internal/fanql/latency_test.go rename to internal/pitotql/latency_test.go index 0c977e19c..490b9f0a6 100644 --- a/internal/fanql/latency_test.go +++ b/internal/pitotql/latency_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" @@ -35,7 +35,7 @@ func latencyPercentile(samples []time.Duration, percentile float64) time.Duratio return ordered[max(0, int(math.Ceil(float64(len(ordered))*percentile))-1)] } -// Latency requirements: ../../docs/proposals/0004-fanql.md, +// Latency requirements: ../../docs/proposals/0004-pitotql.md, // section 0 (especially 0.14 and 0.16). Tests bound work deterministically; // benchmarks report the strict spec percentiles on an uninstrumented build. func TestLatencyBudgets(t *testing.T) { @@ -108,7 +108,7 @@ func TestLatencyBudgets(t *testing.T) { } t.Run("smoke", func(t *testing.T) { if !latencyAcceptanceEnabled() { - t.Skip("set PITOT_TEST_LATENCY=1 or run just fanql-perf to assert wall-clock budgets") + t.Skip("set PITOT_TEST_LATENCY=1 or run just pitotql-perf to assert wall-clock budgets") } if raceInstrumentation { t.Skip("wall-clock smoke budgets exclude race instrumentation; deterministic work bounds still run") diff --git a/internal/fanql/lexer.go b/internal/pitotql/lexer.go similarity index 98% rename from internal/fanql/lexer.go rename to internal/pitotql/lexer.go index 9bf90723f..f862c3062 100644 --- a/internal/fanql/lexer.go +++ b/internal/pitotql/lexer.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "fmt" @@ -156,7 +156,7 @@ func lex(text string) lexTokens { } if c == '!' && i == start+1 { tok.Kind = tokenBad - tok.Message = "! negation is not FanQL" + tok.Message = "! negation is not PitotQL" } case strings.ContainsRune("#{}@", c): tok.Kind = tokenBad diff --git a/internal/fanql/lexer_test.go b/internal/pitotql/lexer_test.go similarity index 98% rename from internal/fanql/lexer_test.go rename to internal/pitotql/lexer_test.go index 7cbb11b27..b6debbbc7 100644 --- a/internal/fanql/lexer_test.go +++ b/internal/pitotql/lexer_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "reflect" @@ -48,7 +48,7 @@ func TestLexLongestMatchOperators(t *testing.T) { func TestLexBadTokens(t *testing.T) { for _, tc := range []struct{ text, bad, message, hint string }{ - {"!service:api", "!", "! negation is not FanQL", ""}, + {"!service:api", "!", "! negation is not PitotQL", ""}, {"body ~~ x", "~~", "~~ is SQL LIKE; use like, ilike or ~", "use like or ilike for SQL patterns; use ~ for a literal substring"}, {"#tag", "#", "", ""}, {"$ x", "$", "unexpected $", ""}, } { diff --git a/internal/fanql/lift.go b/internal/pitotql/lift.go similarity index 99% rename from internal/fanql/lift.go rename to internal/pitotql/lift.go index b4d73021a..1448a73c5 100644 --- a/internal/fanql/lift.go +++ b/internal/pitotql/lift.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" diff --git a/internal/fanql/lift_test.go b/internal/pitotql/lift_test.go similarity index 99% rename from internal/fanql/lift_test.go rename to internal/pitotql/lift_test.go index 6a48cf2ce..068359112 100644 --- a/internal/fanql/lift_test.go +++ b/internal/pitotql/lift_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" @@ -438,7 +438,7 @@ func TestCompileAndFormatReturnNonNilEmptyNotices(t *testing.T) { } } -func TestFormatLabelsEachEntryAsFanQL(t *testing.T) { +func TestFormatLabelsEachEntryAsPitotQL(t *testing.T) { stored := query.Spec{From: "spans", Where: []string{`contains(lower(operation), lower('se'))`, `status = 'STATUS_CODE_ERROR'`, `duration_ms > 100`}, Measures: []string{`count_if(status = 'STATUS_CODE_ERROR')`, `count()`}} f, problems, err := Format(t.Context(), &countingParser{fail: true}, stored, Options{}) if err != nil || len(problems) != 0 { diff --git a/internal/fanql/literal_roundtrip_test.go b/internal/pitotql/literal_roundtrip_test.go similarity index 99% rename from internal/fanql/literal_roundtrip_test.go rename to internal/pitotql/literal_roundtrip_test.go index 24689547b..255ba5d5f 100644 --- a/internal/fanql/literal_roundtrip_test.go +++ b/internal/pitotql/literal_roundtrip_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "fmt" diff --git a/internal/fanql/lower.go b/internal/pitotql/lower.go similarity index 99% rename from internal/fanql/lower.go rename to internal/pitotql/lower.go index bc5f1d15d..5739ad164 100644 --- a/internal/fanql/lower.go +++ b/internal/pitotql/lower.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "fmt" diff --git a/internal/fanql/lower_test.go b/internal/pitotql/lower_test.go similarity index 99% rename from internal/fanql/lower_test.go rename to internal/pitotql/lower_test.go index 658f25964..413c9b54c 100644 --- a/internal/fanql/lower_test.go +++ b/internal/pitotql/lower_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "fmt" diff --git a/internal/fanql/measure_validation_test.go b/internal/pitotql/measure_validation_test.go similarity index 98% rename from internal/fanql/measure_validation_test.go rename to internal/pitotql/measure_validation_test.go index 24cb11d5c..ca2a971b6 100644 --- a/internal/fanql/measure_validation_test.go +++ b/internal/pitotql/measure_validation_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "strings" diff --git a/internal/fanql/parser.go b/internal/pitotql/parser.go similarity index 99% rename from internal/fanql/parser.go rename to internal/pitotql/parser.go index 7d35166fb..6b88f8599 100644 --- a/internal/fanql/parser.go +++ b/internal/pitotql/parser.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "maps" @@ -1177,7 +1177,7 @@ func (p *parser) foreignTerm() bool { } // foreignStage reports a foreign command at the current token, naming the -// FanQL clause it maps to, and consumes the command with its simple argument. +// PitotQL clause it maps to, and consumes the command with its simple argument. // start is where a fix-it replacement begins, including a preceding |. func (p *parser) foreignStage(start int) { t := p.take() @@ -1234,7 +1234,7 @@ func (p *parser) groupBy() bool { var foreignPercentile = regexp.MustCompile(`(?i)^(percentile|pct|perc([0-9]{1,2})|median|mean|dc|distinct_count|cardinality)\(\s*([^\s,()]+)\s*(?:,\s*([0-9.]+)\s*)?\)$`) -// foreignCall reports a foreign aggregate call, suggesting the FanQL measure +// foreignCall reports a foreign aggregate call, suggesting the PitotQL measure // when the call has a direct equivalent: percentile(duration, 95) is p95(duration). func (p *parser) foreignCall() { name := p.peek() diff --git a/internal/fanql/parser_test.go b/internal/pitotql/parser_test.go similarity index 96% rename from internal/fanql/parser_test.go rename to internal/pitotql/parser_test.go index 9259bd280..c3f21d7f1 100644 --- a/internal/fanql/parser_test.go +++ b/internal/pitotql/parser_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "fmt" @@ -318,7 +318,7 @@ func TestParseSortLimitAndSecondPipe(t *testing.T) { func TestParseSourceErrors(t *testing.T) { wantProblem(t, "traces where a:1", "", `unknown source "traces"`, "use spans; traces is a viz of spans") - wantProblem(t, "from spans", "", `"from" is not FanQL; start with the source: spans where ...`, "") + wantProblem(t, "from spans", "", `"from" is not PitotQL; start with the source: spans where ...`, "") wantProblem(t, "", "", `unknown source ""`, "use spans, logs or metrics") q := mustParse(t, "logs") if q.Source != "logs" || len(q.Where) != 0 { @@ -339,15 +339,15 @@ func TestParseSearchBarFilters(t *testing.T) { func TestParseReservedAndForeignWords(t *testing.T) { for _, w := range strings.Fields("let join correlate compare top eval extend having fields rename over window") { - wantProblem(t, "spans where "+w, "", fmt.Sprintf("%q is reserved for a future FanQL feature", w), "quote it to search for the word") + wantProblem(t, "spans where "+w, "", fmt.Sprintf("%q is reserved for a future PitotQL feature", w), "quote it to search for the word") } for _, tc := range []struct{ text, message, hint string }{ - {"spans | summarize count() by service", `"summarize" is not FanQL; write the measures after |, e.g. | count() by service`, ""}, - {`spans where service == "api"`, "== is not FanQL; use key:value or =", ""}, - {`spans where body =~ "re"`, "=~ is not FanQL; ~ is contains; use regexp_matches(field, 're') for a regular expression", ""}, - {`spans where {service="api"}`, "{ selectors are not FanQL; write labels as key:value, e.g. service:api", ""}, + {"spans | summarize count() by service", `"summarize" is not PitotQL; write the measures after |, e.g. | count() by service`, ""}, + {`spans where service == "api"`, "== is not PitotQL; use key:value or =", ""}, + {`spans where body =~ "re"`, "=~ is not PitotQL; ~ is contains; use regexp_matches(field, 're') for a regular expression", ""}, + {`spans where {service="api"}`, "{ selectors are not PitotQL; write labels as key:value, e.g. service:api", ""}, {"spans where @http.target:x", `"@http.target" is not a field name; write the attribute without @: http.target`, ""}, - {"spans where !service:api", "! negation is not FanQL; write -service:api", ""}, + {"spans where !service:api", "! negation is not PitotQL; write -service:api", ""}, {"spans since 1h", "set the time range with the time picker, not in the query", ""}, {"spans until 1h", "set the time range with the time picker, not in the query", ""}, {"spans where service:api*", "* wildcards are not supported; use ~ for contains or quote the value", `use ~ for contains, or quote "api*"`}, diff --git a/internal/fanql/fanql.go b/internal/pitotql/pitotql.go similarity index 96% rename from internal/fanql/fanql.go rename to internal/pitotql/pitotql.go index 1c254009b..2cb44b809 100644 --- a/internal/fanql/fanql.go +++ b/internal/pitotql/pitotql.go @@ -1,5 +1,5 @@ -// Package fanql parses the text form of Pitot's structured telemetry queries. -package fanql +// Package pitotql parses the text form of Pitot's structured telemetry queries. +package pitotql import ( "sort" diff --git a/internal/fanql/print.go b/internal/pitotql/print.go similarity index 99% rename from internal/fanql/print.go rename to internal/pitotql/print.go index 97491ced0..488893b1c 100644 --- a/internal/fanql/print.go +++ b/internal/pitotql/print.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "strconv" diff --git a/internal/fanql/print_test.go b/internal/pitotql/print_test.go similarity index 99% rename from internal/fanql/print_test.go rename to internal/pitotql/print_test.go index cb88e733c..6af3a86f5 100644 --- a/internal/fanql/print_test.go +++ b/internal/pitotql/print_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "reflect" diff --git a/internal/fanql/reference.go b/internal/pitotql/reference.go similarity index 88% rename from internal/fanql/reference.go rename to internal/pitotql/reference.go index ca5fc290c..ffffa5fd6 100644 --- a/internal/fanql/reference.go +++ b/internal/pitotql/reference.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "fmt" @@ -13,8 +13,8 @@ import ( // Registry-owned names, field metadata and vocabularies are read on every call. func Reference() string { var b strings.Builder - b.WriteString("# FanQL\n\nPreview: the syntax may change before GA\n\n") - b.WriteString("FanQL is the text form of a structured telemetry query. It produces the same `query.Spec` that dashboards store and the engine executes. Panels store the query; text is derived. Problems prevent execution; notices never block it. Each diagnostic says what happened and what to write instead, using a valid example from that field. Diagnostics use display names without internal visualization identifiers and report all independent problems in one pass, in source order. Only follow-on cascades are suppressed.\n\n") + b.WriteString("# PitotQL\n\nPreview: the syntax may change before GA\n\n") + b.WriteString("PitotQL is the text form of a structured telemetry query. It produces the same `query.Spec` that dashboards store and the engine executes. Panels store the query; text is derived. Problems prevent execution; notices never block it. Each diagnostic says what happened and what to write instead, using a valid example from that field. Diagnostics use display names without internal visualization identifiers and report all independent problems in one pass, in source order. Only follow-on cascades are suppressed.\n\n") b.WriteString("## Shape and entry points\n\n`source [where] filters | measures by fields every bucket sort key limit n`\n\nExplore accepts a whole query. Logs and Traces search bars accept filters only; the page supplies source, `where` and visualization. The visualization picker accepts the query as written. Adding `| count() every auto` to make a timeseries is a visible edit. One aggregation stage is allowed; another pipe may introduce only `sort` or `limit`, and canonical text drops that pipe.\n\n") b.WriteString("## Sources and words\n\n") fmt.Fprintf(&b, "Sources: %s, recognized only as the first token. A bare source selects all rows in the chosen time range. `where` is optional; canonical text supplies it when filters exist.\n\n", referenceWords(referenceKeys(sources))) @@ -87,7 +87,7 @@ func Reference() string { fmt.Fprintf(&b, "| `%s` | `%s` | %s | %s | %s |\n", m.Name, form, strings.Join(signals, ", "), unit, referenceMeasureMeaning(m.Name)) } b.WriteString("\nMetric aggregates require a standalone `name:` equality entry. Counters use per-series increases and reset handling; gauge/updown use point values; histograms use observation counts, sums and buckets; summaries use available stored aggregates. Unsupported kind/function combinations report a diagnosis instead of treating counters as gauges.\n\n`histogram(duration)` on spans uses count with log2 duration buckets; `histogram(value)` on metrics uses explicit histogram buckets. Distributions stand alone, with at most one `by` field for a histogram; `every` selects a heatmap.\n\n") - b.WriteString("## Expressions and ranking\n\n`count_if(filters)` takes a FanQL filter list as one entry and compiles to checked `count(*) FILTER (WHERE ...)::DOUBLE`. Raw entries are allowed; variables are forbidden. Spans and logs support `+ - * /`, constants, unary minus and parentheses on aggregate vizzes. Metrics, distributions and log_patterns do not support arithmetic. Every expression needs at least one aggregate. Other than a single call, an expression requires `as alias`; aliases are 1–40 lowercase letters/digits/underscores and start with a letter. `share()` stands alone. Division emits `a / nullif(b, 0)`, so zero denominators yield NULL.\n\nCount-family ratios use ratio units, `* 100` makes percent, addition/subtraction retains equal units, scaling retains the measure unit, other combinations use none. Expressions are not additive. Affine transformations inherit the underlying ranking and flip direction for a negative scale. Binomial count_if/count ratios use Wilson ranking with a 20-sample floor; other expressions use value ranking with leaf/denominator support. Ineligible series follow eligible ones by support, then dimension; result metadata discloses them.\n\nApdex uses disjoint predicates: `(count_if(duration<=500ms) + count_if(duration>500ms duration<=2s) / 2) / count() as apdex`. Exactly 500 ms counts once; NULL duration counts in the population and neither numerator.\n\nEach measure allows 256 tokens, 64 nodes, depth 8 and 8 aggregates. A query allows 256 expression nodes and 24 aggregates across at most 6 measures. A count_if filter is at most 500 bytes. Whitespace is not a token. Budgets apply to structured inputs too.\n\n") + b.WriteString("## Expressions and ranking\n\n`count_if(filters)` takes a PitotQL filter list as one entry and compiles to checked `count(*) FILTER (WHERE ...)::DOUBLE`. Raw entries are allowed; variables are forbidden. Spans and logs support `+ - * /`, constants, unary minus and parentheses on aggregate vizzes. Metrics, distributions and log_patterns do not support arithmetic. Every expression needs at least one aggregate. Other than a single call, an expression requires `as alias`; aliases are 1–40 lowercase letters/digits/underscores and start with a letter. `share()` stands alone. Division emits `a / nullif(b, 0)`, so zero denominators yield NULL.\n\nCount-family ratios use ratio units, `* 100` makes percent, addition/subtraction retains equal units, scaling retains the measure unit, other combinations use none. Expressions are not additive. Affine transformations inherit the underlying ranking and flip direction for a negative scale. Binomial count_if/count ratios use Wilson ranking with a 20-sample floor; other expressions use value ranking with leaf/denominator support. Ineligible series follow eligible ones by support, then dimension; result metadata discloses them.\n\nApdex uses disjoint predicates: `(count_if(duration<=500ms) + count_if(duration>500ms duration<=2s) / 2) / count() as apdex`. Exactly 500 ms counts once; NULL duration counts in the population and neither numerator.\n\nEach measure allows 256 tokens, 64 nodes, depth 8 and 8 aggregates. A query allows 256 expression nodes and 24 aggregates across at most 6 measures. A count_if filter is at most 500 bytes. Whitespace is not a token. Budgets apply to structured inputs too.\n\n") b.WriteString("## Filter functions and raw entries\n\n| Function | Signature |\n|---|---|\n") for _, name := range query.FilterFunctionNames() { args := "field" @@ -100,15 +100,15 @@ func Reference() string { b.WriteString("## Variables and entry boundaries\n\n`$name` is a dashboard variable; `$__` names are reserved. It stays a parameter, never a string literal. `k in $multi` accepts multiple values; scalar operators reject multi variables. Without declarations, references produce notices so editing can continue; execution checks them.\n\nAll rule: a filter that mentions a variable set to All is removed; keep fixed conditions in their own terms. An empty variable list makes its entry FALSE. Top-level terms are separate entries; a parenthesized group, raw entry or OR chain is one entry. Stored order and boundaries survive formatting.\n\n| Filters | Entries | `$service` = All |\n|---|---|---|\n| `service:$service status:error` | 2 | Keep status. |\n| `(service:$service status:error)` | 1 | Drop both. |\n| `service:$service or service:worker` | 1 | Drop whole entry. |\n| `service:$service (status:error or status:unset)` | 2 | Keep status group. |\n| `-service:$service` | 1 | Drop entry; nothing excluded. |\n| Raw SQL mentioning `$service` | 1 | Drop whole entry. |\n| `count_if(service:$service)` | n/a | Rejected. |\n\n") b.WriteString("## Visualization and trace semantics\n\nLogs/traces use logs/spans respectively and forbid measures, grouping, buckets and histogram. Log_patterns uses `count() by body_template`, optionally a bucket. Timeseries needs a bucket and at most one grouping field, with one measure when grouped. Tables allow three grouping fields; bars two, with one measure when grouped by two. Stat/gauge need one measure and no grouping/bucket; gauge needs min/max. Scatter needs two measures and one or two grouping fields. State_timeline needs one measure, one grouping field, a bucket and thresholds.\n\nTraces are `(namespace, trace_id)` candidates with at least one matching span in the window, ranked by matching spans' max(duration_ms), or min(start_time) for `sort +start`. Limit applies to candidates; the engine reads at most 1,001 for truncation detection. Each returns one root span, or its earliest span in the window if the root is outside it, with error status if any span in the trace errored. Displayed service and duration are root service and root duration. A child can match while the returned root has different values. A prefix-negated filter (`-service:checkout`, `not operation~health`) excludes whole traces instead: a trace with any span in the window that the term matches is not listed, so `-service:load-generator` also drops traces that pass through load-generator. SQL's own negatives (`service!=checkout`, `not in`) and negation inside `or` stay per span, and `-k:*` keeps its meaning (`k is null`).\n\nTrace sorts: descending `duration` (stored duration_ms), `errors`, or ascending `+start`. `sort errors` is the legacy combined key: it also filters to error spans, then orders by duration. Prefer `status:error` with `sort duration`. Logs sort by `time` or `+time`; log_patterns by `count`. Aggregate sorts name a measure alias. Default/desc is descending; +/asc is ascending; choose one direction. Bucketed families use time order and options.top for series selection; sort/limit are accepted with a notice when ignored.\n\n") b.WriteString("## Reserved words and foreign syntax\n\n") - fmt.Fprintf(&b, "%s are reserved at clause positions. Quote them to search for the word. Foreign syntax gets a diagnostic and FanQL hint, never an alias; an ordinary foreign word in filter position stays free text.\n\n", referenceWords(referenceKeys(reserved))) + fmt.Fprintf(&b, "%s are reserved at clause positions. Quote them to search for the word. Foreign syntax gets a diagnostic and PitotQL hint, never an alias; an ordinary foreign word in filter position stays free text.\n\n", referenceWords(referenceKeys(reserved))) fmt.Fprintf(&b, "Recognized foreign stages: %s. Foreign call shapes: %s. `from`, `index=`, `source=`, first-token `search`, `ago(`, `now(`, `earliest=`, `_time:`, `order by`, `group by`, `facet`, `==`, `=~`, `|=`, `|~`, `::`, selectors and `@field:` get targeted hints. Time ranges belong to the time picker.\n\n", referenceWords(referenceKeys(foreignStages)), referenceWords(referenceKeys(foreignCalls))) b.WriteString("## Bounds and diagnostics\n\nInteractive text allows 4,000 code points and 8,192 bytes, 1,024 tokens, 512 AST nodes, nesting depth 16 and lists of 100 values. Queries lower to 16 entries of 500 bytes each, 6 measures and 3 grouping fields, further constrained by the viz. Completion returns at most 50 items. Problems have code-point spans and optional fix-its, follow source order and are capped at 20 plus a final more-problems diagnostic. Any problem prevents execution; requested repair previews are labeled not executable.\n\nFormat returns complete text and exactness `exact` or `normalized`, with notices for normalization. Raw preserves whole SQL entries. Editable canonical text reparses under its tier without merging entries. Beyond any interactive bound, `editable: false` carries a reason and complete text; the envelope must preserve the original query and consumers must not parse the oversized text.\n\n") - b.WriteString("## Examples\n\n```fanql\n") + b.WriteString("## Examples\n\n```pitotql\n") for _, example := range referenceExamples { b.WriteString(example) b.WriteByte('\n') } - b.WriteString("```\n\n## Transport\n\nMachine text inputs carry visualization, time, comparison, declarations, resolved values, namespace and options as needed. The structured query is required when editable is false. Panels keep storing queries, never text.\n\nCompletion accepts a relative `window` duration or absolute `from` and `to` timestamps. Absolute windows and durations over 24h use recent 24h schema, disclosed by `schema.recent` and `schema.notice`. With no selected window, the same recent fallback applies.\n\nHTTP exposes `/api/fanql/parse`, `/api/fanql/format`, `/api/fanql/complete` and `/api/fanql/reference`, requiring telemetry:read. MCP query_telemetry accepts optional text beside panel; agents should prefer panel.query, or panel.sql for complex work. This reference is also `pitot://fanql/reference`.\n") + b.WriteString("```\n\n## Transport\n\nMachine text inputs carry visualization, time, comparison, declarations, resolved values, namespace and options as needed. The structured query is required when editable is false. Panels keep storing queries, never text.\n\nCompletion accepts a relative `window` duration or absolute `from` and `to` timestamps. Absolute windows and durations over 24h use recent 24h schema, disclosed by `schema.recent` and `schema.notice`. With no selected window, the same recent fallback applies.\n\nHTTP exposes `/api/pitotql/parse`, `/api/pitotql/format`, `/api/pitotql/complete` and `/api/pitotql/reference`, requiring telemetry:read. MCP query_telemetry accepts optional text beside panel; agents should prefer panel.query, or panel.sql for complex work. This reference is also `pitot://pitotql/reference`.\n") return b.String() } diff --git a/internal/fanql/reference_test.go b/internal/pitotql/reference_test.go similarity index 96% rename from internal/fanql/reference_test.go rename to internal/pitotql/reference_test.go index 025dddf59..09eff6633 100644 --- a/internal/fanql/reference_test.go +++ b/internal/pitotql/reference_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "strings" @@ -59,7 +59,7 @@ func TestReferenceIsDeterministicAndMarksPreview(t *testing.T) { t.Fatal("reference order is unstable") } } - if !strings.HasPrefix(ref, "# FanQL\n") || !strings.Contains(ref, "Preview: the syntax may change before GA") { + if !strings.HasPrefix(ref, "# PitotQL\n") || !strings.Contains(ref, "Preview: the syntax may change before GA") { t.Fatal("missing title/preview") } } diff --git a/internal/fanql/registry_growth_test.go b/internal/pitotql/registry_growth_test.go similarity index 99% rename from internal/fanql/registry_growth_test.go rename to internal/pitotql/registry_growth_test.go index 1166e0327..82d33e514 100644 --- a/internal/fanql/registry_growth_test.go +++ b/internal/pitotql/registry_growth_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "encoding/json" diff --git a/internal/fanql/resolve.go b/internal/pitotql/resolve.go similarity index 99% rename from internal/fanql/resolve.go rename to internal/pitotql/resolve.go index d4af23dc6..79ff17402 100644 --- a/internal/fanql/resolve.go +++ b/internal/pitotql/resolve.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "fmt" diff --git a/internal/fanql/resolve_test.go b/internal/pitotql/resolve_test.go similarity index 99% rename from internal/fanql/resolve_test.go rename to internal/pitotql/resolve_test.go index 802abce59..6d2e810f2 100644 --- a/internal/fanql/resolve_test.go +++ b/internal/pitotql/resolve_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "reflect" diff --git a/internal/fanql/roundtrip_test.go b/internal/pitotql/roundtrip_test.go similarity index 99% rename from internal/fanql/roundtrip_test.go rename to internal/pitotql/roundtrip_test.go index 9e75db90c..e27ea9412 100644 --- a/internal/fanql/roundtrip_test.go +++ b/internal/pitotql/roundtrip_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" diff --git a/internal/fanql/semantics_test.go b/internal/pitotql/semantics_test.go similarity index 99% rename from internal/fanql/semantics_test.go rename to internal/pitotql/semantics_test.go index e9cbfa1f1..3d420578f 100644 --- a/internal/fanql/semantics_test.go +++ b/internal/pitotql/semantics_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "context" diff --git a/internal/fanql/spellings.go b/internal/pitotql/spellings.go similarity index 98% rename from internal/fanql/spellings.go rename to internal/pitotql/spellings.go index e6a6a34c1..040dd61aa 100644 --- a/internal/fanql/spellings.go +++ b/internal/pitotql/spellings.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "math" diff --git a/internal/fanql/testdata/canonical.golden b/internal/pitotql/testdata/canonical.golden similarity index 100% rename from internal/fanql/testdata/canonical.golden rename to internal/pitotql/testdata/canonical.golden diff --git a/internal/fanql/testdata/corpus.txt b/internal/pitotql/testdata/corpus.txt similarity index 96% rename from internal/fanql/testdata/corpus.txt rename to internal/pitotql/testdata/corpus.txt index 11febafa5..b7f1aa33e 100644 --- a/internal/fanql/testdata/corpus.txt +++ b/internal/pitotql/testdata/corpus.txt @@ -18,7 +18,7 @@ "problems": [ { "path": "text", - "message": "\"from\" is not FanQL; start with the source: spans where ...", + "message": "\"from\" is not PitotQL; start with the source: spans where ...", "span": { "start": 0, "end": 10 @@ -389,7 +389,7 @@ "problems": [ { "path": "text", - "message": "ago(...) is not FanQL; use the time picker", + "message": "ago(...) is not PitotQL; use the time picker", "span": { "start": 11, "end": 14 @@ -453,7 +453,7 @@ "problems": [ { "path": "text", - "message": "== is not FanQL; use key:value or =", + "message": "== is not PitotQL; use key:value or =", "span": { "start": 16, "end": 18 @@ -467,7 +467,7 @@ "problems": [ { "path": "text", - "message": "=~ is not FanQL; ~ is contains; use regexp_matches(field, 're') for a regular expression", + "message": "=~ is not PitotQL; ~ is contains; use regexp_matches(field, 're') for a regular expression", "span": { "start": 16, "end": 18 @@ -501,7 +501,7 @@ "problems": [ { "path": "text", - "message": "|= is not FanQL; use body ~ \"text\" for contains", + "message": "|= is not PitotQL; use body ~ \"text\" for contains", "span": { "start": 16, "end": 18 @@ -515,7 +515,7 @@ "problems": [ { "path": "text", - "message": "|~ is not FanQL; use body ~ \"text\" for contains", + "message": "|~ is not PitotQL; use body ~ \"text\" for contains", "span": { "start": 16, "end": 18 @@ -581,7 +581,7 @@ "problems": [ { "path": "text", - "message": ":: is not FanQL; use field comparisons or a backtick raw filter", + "message": ":: is not PitotQL; use field comparisons or a backtick raw filter", "span": { "start": 15, "end": 17 @@ -703,7 +703,7 @@ "problems": [ { "path": "text", - "message": "now(...) is not FanQL; use the time picker", + "message": "now(...) is not PitotQL; use the time picker", "span": { "start": 11, "end": 14 @@ -1978,7 +1978,7 @@ "problems": [ { "path": "text", - "message": "\"facet\" is not FanQL; use by after measures, e.g. | count() by service", + "message": "\"facet\" is not PitotQL; use by after measures, e.g. | count() by service", "span": { "start": 6, "end": 11 @@ -1992,7 +1992,7 @@ "problems": [ { "path": "text", - "message": "\"group by\" is not FanQL; use by after measures, e.g. | count() by service", + "message": "\"group by\" is not PitotQL; use by after measures, e.g. | count() by service", "span": { "start": 6, "end": 14 @@ -2210,7 +2210,7 @@ "problems": [ { "path": "text", - "message": "! negation is not FanQL; write -service:api", + "message": "! negation is not PitotQL; write -service:api", "span": { "start": 12, "end": 24 @@ -2964,7 +2964,7 @@ "problems": [ { "path": "text", - "message": "ago(...) is not FanQL; use the time picker", + "message": "ago(...) is not PitotQL; use the time picker", "span": { "start": 12, "end": 15 @@ -4138,7 +4138,7 @@ "problems": [ { "path": "text", - "message": "=~ is not FanQL; ~ is contains; use regexp_matches(field, 're') for a regular expression", + "message": "=~ is not PitotQL; ~ is contains; use regexp_matches(field, 're') for a regular expression", "span": { "start": 17, "end": 19 @@ -4152,7 +4152,7 @@ "problems": [ { "path": "text", - "message": ":: is not FanQL; use field comparisons or a backtick raw filter", + "message": ":: is not PitotQL; use field comparisons or a backtick raw filter", "span": { "start": 16, "end": 18 @@ -4166,7 +4166,7 @@ "problems": [ { "path": "text", - "message": "\"compare\" is reserved for a future FanQL feature", + "message": "\"compare\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -4181,7 +4181,7 @@ "problems": [ { "path": "text", - "message": "\"correlate\" is reserved for a future FanQL feature", + "message": "\"correlate\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -4415,7 +4415,7 @@ "problems": [ { "path": "text", - "message": "\"eval\" is reserved for a future FanQL feature", + "message": "\"eval\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -4430,7 +4430,7 @@ "problems": [ { "path": "text", - "message": "\"extend\" is reserved for a future FanQL feature", + "message": "\"extend\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -4445,7 +4445,7 @@ "problems": [ { "path": "text", - "message": "\"fields\" is reserved for a future FanQL feature", + "message": "\"fields\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -4480,7 +4480,7 @@ "problems": [ { "path": "text", - "message": "\"having\" is reserved for a future FanQL feature", + "message": "\"having\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -4639,7 +4639,7 @@ "problems": [ { "path": "text", - "message": "\"join\" is reserved for a future FanQL feature", + "message": "\"join\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -4984,7 +4984,7 @@ "problems": [ { "path": "text", - "message": "\"let\" is reserved for a future FanQL feature", + "message": "\"let\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -5034,7 +5034,7 @@ "problems": [ { "path": "text", - "message": "now(...) is not FanQL; use the time picker", + "message": "now(...) is not PitotQL; use the time picker", "span": { "start": 12, "end": 15 @@ -5048,7 +5048,7 @@ "problems": [ { "path": "text", - "message": "\"over\" is reserved for a future FanQL feature", + "message": "\"over\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -5063,7 +5063,7 @@ "problems": [ { "path": "text", - "message": "\"rename\" is reserved for a future FanQL feature", + "message": "\"rename\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -5190,7 +5190,7 @@ "problems": [ { "path": "text", - "message": "== is not FanQL; use key:value or =", + "message": "== is not PitotQL; use key:value or =", "span": { "start": 20, "end": 22 @@ -5356,7 +5356,7 @@ "problems": [ { "path": "text", - "message": "\"order by\" is not FanQL; use sort, e.g. sort duration", + "message": "\"order by\" is not PitotQL; use sort, e.g. sort duration", "span": { "start": 24, "end": 32 @@ -5720,7 +5720,7 @@ "problems": [ { "path": "text", - "message": "\"top\" is reserved for a future FanQL feature", + "message": "\"top\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -5775,7 +5775,7 @@ "problems": [ { "path": "text", - "message": "\"window\" is reserved for a future FanQL feature", + "message": "\"window\" is reserved for a future PitotQL feature", "hint": "quote it to search for the word", "span": { "start": 12, @@ -5814,7 +5814,7 @@ "problems": [ { "path": "text", - "message": "{ selectors are not FanQL; write labels as key:value, e.g. service:api", + "message": "{ selectors are not PitotQL; write labels as key:value, e.g. service:api", "span": { "start": 12, "end": 13 @@ -5828,7 +5828,7 @@ "problems": [ { "path": "text", - "message": "{ selectors are not FanQL; write labels as key:value, e.g. service:api", + "message": "{ selectors are not PitotQL; write labels as key:value, e.g. service:api", "span": { "start": 12, "end": 13 @@ -5938,7 +5938,7 @@ "problems": [ { "path": "text", - "message": "bin(...) is not FanQL; use the FanQL measure functions", + "message": "bin(...) is not PitotQL; use the PitotQL measure functions", "span": { "start": 8, "end": 11 @@ -5952,7 +5952,7 @@ "problems": [ { "path": "text", - "message": "cardinality(...) is not FanQL; write count_distinct(duration)", + "message": "cardinality(...) is not PitotQL; write count_distinct(duration)", "span": { "start": 8, "end": 29 @@ -6705,7 +6705,7 @@ "problems": [ { "path": "text", - "message": "count_over_time(...) is not FanQL; use the FanQL measure functions", + "message": "count_over_time(...) is not PitotQL; use the PitotQL measure functions", "span": { "start": 8, "end": 23 @@ -6719,7 +6719,7 @@ "problems": [ { "path": "text", - "message": "dc(...) is not FanQL; write count_distinct(duration)", + "message": "dc(...) is not PitotQL; write count_distinct(duration)", "span": { "start": 8, "end": 20 @@ -6743,7 +6743,7 @@ "problems": [ { "path": "text", - "message": "distinct_count(...) is not FanQL; write count_distinct(duration)", + "message": "distinct_count(...) is not PitotQL; write count_distinct(duration)", "span": { "start": 8, "end": 32 @@ -6767,7 +6767,7 @@ "problems": [ { "path": "text", - "message": "\"eval\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"eval\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 12 @@ -6795,7 +6795,7 @@ "problems": [ { "path": "text", - "message": "\"extend\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"extend\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 14 @@ -6809,7 +6809,7 @@ "problems": [ { "path": "text", - "message": "\"fields\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"fields\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 14 @@ -6823,7 +6823,7 @@ "problems": [ { "path": "text", - "message": "\"head\" is not FanQL; use limit, e.g. limit 10", + "message": "\"head\" is not PitotQL; use limit, e.g. limit 10", "span": { "start": 8, "end": 12 @@ -6956,7 +6956,7 @@ "problems": [ { "path": "text", - "message": "mean(...) is not FanQL; write avg(duration)", + "message": "mean(...) is not PitotQL; write avg(duration)", "span": { "start": 8, "end": 22 @@ -6980,7 +6980,7 @@ "problems": [ { "path": "text", - "message": "median(...) is not FanQL; write p50(duration)", + "message": "median(...) is not PitotQL; write p50(duration)", "span": { "start": 8, "end": 24 @@ -7004,7 +7004,7 @@ "problems": [ { "path": "text", - "message": "\"order\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"order\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 13 @@ -7119,7 +7119,7 @@ "problems": [ { "path": "text", - "message": "pct(...) is not FanQL; use the FanQL measure functions", + "message": "pct(...) is not PitotQL; use the PitotQL measure functions", "span": { "start": 8, "end": 11 @@ -7133,7 +7133,7 @@ "problems": [ { "path": "text", - "message": "perc95(...) is not FanQL; write p95(duration)", + "message": "perc95(...) is not PitotQL; write p95(duration)", "span": { "start": 8, "end": 24 @@ -7157,7 +7157,7 @@ "problems": [ { "path": "text", - "message": "percentile(...) is not FanQL; use the FanQL measure functions", + "message": "percentile(...) is not PitotQL; use the PitotQL measure functions", "span": { "start": 8, "end": 18 @@ -7171,7 +7171,7 @@ "problems": [ { "path": "text", - "message": "\"project\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"project\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 15 @@ -7223,7 +7223,7 @@ "problems": [ { "path": "text", - "message": "quantile_over_time(...) is not FanQL; use the FanQL measure functions", + "message": "quantile_over_time(...) is not PitotQL; use the PitotQL measure functions", "span": { "start": 8, "end": 26 @@ -7251,7 +7251,7 @@ "problems": [ { "path": "text", - "message": "\"rename\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"rename\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 14 @@ -7265,7 +7265,7 @@ "problems": [ { "path": "text", - "message": "\"select\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"select\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 14 @@ -7304,7 +7304,7 @@ "problems": [ { "path": "text", - "message": "\"sort by\" is not FanQL; use sort, e.g. sort service", + "message": "\"sort by\" is not PitotQL; use sort, e.g. sort service", "span": { "start": 8, "end": 15 @@ -7350,7 +7350,7 @@ "problems": [ { "path": "text", - "message": "span(...) is not FanQL; use the FanQL measure functions", + "message": "span(...) is not PitotQL; use the PitotQL measure functions", "span": { "start": 8, "end": 12 @@ -7364,7 +7364,7 @@ "problems": [ { "path": "text", - "message": "\"stats\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"stats\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 13 @@ -7392,7 +7392,7 @@ "problems": [ { "path": "text", - "message": "\"summarize\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"summarize\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 17 @@ -7406,7 +7406,7 @@ "problems": [ { "path": "text", - "message": "\"take\" is not FanQL; use limit, e.g. limit 10", + "message": "\"take\" is not PitotQL; use limit, e.g. limit 10", "span": { "start": 8, "end": 12 @@ -7420,7 +7420,7 @@ "problems": [ { "path": "text", - "message": "\"top\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"top\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 8, "end": 11 @@ -7434,7 +7434,7 @@ "problems": [ { "path": "text", - "message": "|= is not FanQL; use body ~ \"text\" for contains", + "message": "|= is not PitotQL; use body ~ \"text\" for contains", "span": { "start": 6, "end": 8 @@ -7448,7 +7448,7 @@ "problems": [ { "path": "text", - "message": "|~ is not FanQL; use body ~ \"text\" for contains", + "message": "|~ is not PitotQL; use body ~ \"text\" for contains", "span": { "start": 6, "end": 8 @@ -7486,7 +7486,7 @@ }, { "path": "text", - "message": "\"stats\" is not FanQL; write the measures after |, e.g. | count() by service", + "message": "\"stats\" is not PitotQL; write the measures after |, e.g. | count() by service", "span": { "start": 9, "end": 14 @@ -7500,7 +7500,7 @@ "problems": [ { "path": "text", - "message": "\"from\" is not FanQL; start with the source: logs where ...", + "message": "\"from\" is not PitotQL; start with the source: logs where ...", "span": { "start": 0, "end": 9 @@ -7524,7 +7524,7 @@ "problems": [ { "path": "text", - "message": "\"head\" is not FanQL; use limit, e.g. limit 5", + "message": "\"head\" is not PitotQL; use limit, e.g. limit 5", "span": { "start": 29, "end": 33 @@ -7548,7 +7548,7 @@ "problems": [ { "path": "text", - "message": "\"order by\" is not FanQL; use sort, e.g. sort count", + "message": "\"order by\" is not PitotQL; use sort, e.g. sort count", "span": { "start": 27, "end": 35 @@ -7572,7 +7572,7 @@ "problems": [ { "path": "text", - "message": "percentile(...) is not FanQL; write p95(duration)", + "message": "percentile(...) is not PitotQL; write p95(duration)", "span": { "start": 8, "end": 32 @@ -7596,7 +7596,7 @@ "problems": [ { "path": "text", - "message": "SQL is not FanQL; start with the source, e.g. spans | count() by service", + "message": "SQL is not PitotQL; start with the source, e.g. spans | count() by service", "span": { "start": 0, "end": 6 @@ -7610,7 +7610,7 @@ "problems": [ { "path": "text", - "message": "{ selectors are not FanQL; write labels as key:value, e.g. service:api", + "message": "{ selectors are not PitotQL; write labels as key:value, e.g. service:api", "span": { "start": 0, "end": 1 diff --git a/internal/fanql/testdata/fuzz/FuzzFormatRoundTrip/literal_backtick b/internal/pitotql/testdata/fuzz/FuzzFormatRoundTrip/literal_backtick similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzFormatRoundTrip/literal_backtick rename to internal/pitotql/testdata/fuzz/FuzzFormatRoundTrip/literal_backtick diff --git a/internal/fanql/testdata/fuzz/FuzzFormatRoundTrip/literal_group_key b/internal/pitotql/testdata/fuzz/FuzzFormatRoundTrip/literal_group_key similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzFormatRoundTrip/literal_group_key rename to internal/pitotql/testdata/fuzz/FuzzFormatRoundTrip/literal_group_key diff --git a/internal/fanql/testdata/fuzz/FuzzFormatRoundTrip/raw_negation b/internal/pitotql/testdata/fuzz/FuzzFormatRoundTrip/raw_negation similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzFormatRoundTrip/raw_negation rename to internal/pitotql/testdata/fuzz/FuzzFormatRoundTrip/raw_negation diff --git a/internal/fanql/testdata/fuzz/FuzzLexParsePrint/72518d1cde34436d b/internal/pitotql/testdata/fuzz/FuzzLexParsePrint/72518d1cde34436d similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzLexParsePrint/72518d1cde34436d rename to internal/pitotql/testdata/fuzz/FuzzLexParsePrint/72518d1cde34436d diff --git a/internal/fanql/testdata/fuzz/FuzzLexParsePrint/ac80e7dae538a502 b/internal/pitotql/testdata/fuzz/FuzzLexParsePrint/ac80e7dae538a502 similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzLexParsePrint/ac80e7dae538a502 rename to internal/pitotql/testdata/fuzz/FuzzLexParsePrint/ac80e7dae538a502 diff --git a/internal/fanql/testdata/fuzz/FuzzLexParsePrint/aca3db284bc204d2 b/internal/pitotql/testdata/fuzz/FuzzLexParsePrint/aca3db284bc204d2 similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzLexParsePrint/aca3db284bc204d2 rename to internal/pitotql/testdata/fuzz/FuzzLexParsePrint/aca3db284bc204d2 diff --git a/internal/fanql/testdata/fuzz/FuzzLexParsePrint/astral_diagnostic b/internal/pitotql/testdata/fuzz/FuzzLexParsePrint/astral_diagnostic similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzLexParsePrint/astral_diagnostic rename to internal/pitotql/testdata/fuzz/FuzzLexParsePrint/astral_diagnostic diff --git a/internal/fanql/testdata/fuzz/FuzzLexParsePrint/b4c83d8eaed5ec0b b/internal/pitotql/testdata/fuzz/FuzzLexParsePrint/b4c83d8eaed5ec0b similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzLexParsePrint/b4c83d8eaed5ec0b rename to internal/pitotql/testdata/fuzz/FuzzLexParsePrint/b4c83d8eaed5ec0b diff --git a/internal/fanql/testdata/fuzz/FuzzLexParsePrint/embedded_variable_character b/internal/pitotql/testdata/fuzz/FuzzLexParsePrint/embedded_variable_character similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzLexParsePrint/embedded_variable_character rename to internal/pitotql/testdata/fuzz/FuzzLexParsePrint/embedded_variable_character diff --git a/internal/fanql/testdata/fuzz/FuzzLexParsePrint/quoted_wildcard b/internal/pitotql/testdata/fuzz/FuzzLexParsePrint/quoted_wildcard similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzLexParsePrint/quoted_wildcard rename to internal/pitotql/testdata/fuzz/FuzzLexParsePrint/quoted_wildcard diff --git a/internal/fanql/testdata/fuzz/FuzzLexParsePrint/raw_boolean_fragment b/internal/pitotql/testdata/fuzz/FuzzLexParsePrint/raw_boolean_fragment similarity index 100% rename from internal/fanql/testdata/fuzz/FuzzLexParsePrint/raw_boolean_fragment rename to internal/pitotql/testdata/fuzz/FuzzLexParsePrint/raw_boolean_fragment diff --git a/internal/fanql/testhelpers_test.go b/internal/pitotql/testhelpers_test.go similarity index 98% rename from internal/fanql/testhelpers_test.go rename to internal/pitotql/testhelpers_test.go index c0a66b918..5f8c3124d 100644 --- a/internal/fanql/testhelpers_test.go +++ b/internal/pitotql/testhelpers_test.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "testing" diff --git a/internal/fanql/words.go b/internal/pitotql/words.go similarity index 85% rename from internal/fanql/words.go rename to internal/pitotql/words.go index 9c2b585fa..0095e5275 100644 --- a/internal/fanql/words.go +++ b/internal/pitotql/words.go @@ -1,4 +1,4 @@ -package fanql +package pitotql import ( "fmt" @@ -132,21 +132,21 @@ func message(code diagnosticCode) string { case diagSource: return "unknown source %q" case diagFrom: - return "%q is not FanQL; start with the source: %s where ..." + return "%q is not PitotQL; start with the source: %s where ..." case diagSQL: - return "SQL is not FanQL; start with the source, e.g. spans | count() by service" + return "SQL is not PitotQL; start with the source, e.g. spans | count() by service" case diagPromQL: - return "PromQL is not FanQL; start with the source, e.g. metrics where name:http.server.request.duration | rate() by service" + return "PromQL is not PitotQL; start with the source, e.g. metrics where name:http.server.request.duration | rate() by service" case diagKusto: - return "Kusto is not FanQL; filters follow the source and measures follow one |, e.g. %s where service:api | count() by service" + return "Kusto is not PitotQL; filters follow the source and measures follow one |, e.g. %s where service:api | count() by service" case diagPipeWhere: - return "| where is not FanQL; filters follow the source, e.g. %s where service:api | count()" + return "| where is not PitotQL; filters follow the source, e.g. %s where service:api | count()" case diagForeignSort: - return "%q is not FanQL; use sort, e.g. sort %s" + return "%q is not PitotQL; use sort, e.g. sort %s" case diagForeignLimit: - return "%q is not FanQL; use limit, e.g. limit %s" + return "%q is not PitotQL; use limit, e.g. limit %s" case diagForeignMeasure: - return "%s(...) is not FanQL; write %s" + return "%s(...) is not PitotQL; write %s" case diagCompoundDuration: return "compound durations are not supported; write %s" case diagRangeOrder: @@ -208,31 +208,31 @@ func message(code diagnosticCode) string { case diagVariable: return "$__ names are reserved; use a dashboard variable name" case diagReserved: - return "%q is reserved for a future FanQL feature" + return "%q is reserved for a future PitotQL feature" case diagForeignStage: - return "%q is not FanQL; write the measures after |, e.g. | count() by service" + return "%q is not PitotQL; write the measures after |, e.g. | count() by service" case diagForeignCall: - return "%s(...) is not FanQL; use the FanQL measure functions" + return "%s(...) is not PitotQL; use the PitotQL measure functions" case diagForeignClause: - return "%q is not FanQL; use by after measures, e.g. | count() by service" + return "%q is not PitotQL; use by after measures, e.g. | count() by service" case diagTime: return "set the time range with the time picker, not in the query" case diagTimeCall: - return "%s(...) is not FanQL; use the time picker" + return "%s(...) is not PitotQL; use the time picker" case diagEqeq: - return "== is not FanQL; use key:value or =" + return "== is not PitotQL; use key:value or =" case diagRegex: - return "=~ is not FanQL; ~ is contains; use regexp_matches(field, 're') for a regular expression" + return "=~ is not PitotQL; ~ is contains; use regexp_matches(field, 're') for a regular expression" case diagPipeOp: - return "%s is not FanQL; use body ~ \"text\" for contains" + return "%s is not PitotQL; use body ~ \"text\" for contains" case diagCast: - return ":: is not FanQL; use field comparisons or a backtick raw filter" + return ":: is not PitotQL; use field comparisons or a backtick raw filter" case diagSelector: - return "{ selectors are not FanQL; write labels as key:value, e.g. service:api" + return "{ selectors are not PitotQL; write labels as key:value, e.g. service:api" case diagAt: return "%q is not a field name; write the attribute without @: %s" case diagBang: - return "! negation is not FanQL; write -%s" + return "! negation is not PitotQL; write -%s" case diagMeasure: return "a measure needs a call, number or parenthesised expression" case diagMeasureSides: diff --git a/internal/query/backlog_pressure_test.go b/internal/query/backlog_pressure_test.go index cf012751d..e439c2cae 100644 --- a/internal/query/backlog_pressure_test.go +++ b/internal/query/backlog_pressure_test.go @@ -317,7 +317,7 @@ func runPanelPressure(t *testing.T, assertUsable bool) { return results } // Four concurrent dashboard requests retain the executor's production - // fanout. When internal reads occupy the fifth slot, diagnostics defer + // concurrency. When internal reads occupy the fifth slot, diagnostics defer // their SQL samples until the workers have joined. worker := func(c context.Context, phase string, id int) { for c.Err() == nil { diff --git a/internal/query/diagnose.go b/internal/query/diagnose.go index c49ea3c38..504dcc5be 100644 --- a/internal/query/diagnose.go +++ b/internal/query/diagnose.go @@ -175,7 +175,7 @@ func grouped(n int64) string { return b.String() } -// spoken writes a stored enum value as FanQL spells it: STATUS_CODE_ERROR is +// spoken writes a stored enum value as PitotQL spells it: STATUS_CODE_ERROR is // error. Other values are unchanged. func spoken(sig *signal, field, value string) string { if v := fieldVocabularies[field]; v.Signal == sig.name { diff --git a/internal/query/diagnose_regression_test.go b/internal/query/diagnose_regression_test.go index 69d219e0c..4527c06e5 100644 --- a/internal/query/diagnose_regression_test.go +++ b/internal/query/diagnose_regression_test.go @@ -193,7 +193,7 @@ func TestDiagnosisNamesTextAndNegatedFilters(t *testing.T) { if err != nil { t.Fatal(err) } - // FanQL free text lowers to contains() and negation to an OR; the diagnosis + // PitotQL free text lowers to contains() and negation to an OR; the diagnosis // names their field instead of "one filter". if r := results[0]; r.Status != StatusEmpty || !strings.Contains(r.Diagnosis, `Without operation containing "zzqxnomatch", 120 match the remaining filters.`) { t.Fatalf("text result = %+v", r) diff --git a/internal/query/diagnose_wording_test.go b/internal/query/diagnose_wording_test.go index fc42865c5..b2bfc0528 100644 --- a/internal/query/diagnose_wording_test.go +++ b/internal/query/diagnose_wording_test.go @@ -9,7 +9,7 @@ import ( ) // The Traces page lists traces of spans; a diagnosis that counts names spans -// throughout, groups digits, and spells stored enum values the way FanQL +// throughout, groups digits, and spells stored enum values the way PitotQL // writes them. func TestTracesDiagnosisWording(t *testing.T) { e := newFixtureExecutor(t) @@ -49,8 +49,8 @@ func TestDiagnosisWithoutTimeStaysNeutral(t *testing.T) { } } -// A diagnosis names fields as FanQL spells them: duration, not duration ms. -func TestDiagnosisNamesDurationAsFanQL(t *testing.T) { +// A diagnosis names fields as PitotQL spells them: duration, not duration ms. +func TestDiagnosisNamesDurationAsPitotQL(t *testing.T) { e := newFixtureExecutor(t) d := Dashboard{Name: "Duration", Time: Time{Range: "1h"}, Panels: []Panel{{ID: "p", Title: "Slow", Viz: "table", Query: &Spec{From: "spans", Measures: []string{"count()"}, By: []string{"service"}, Where: []string{"service = 'frontend'", "duration_ms > 9999000"}}}}} @@ -64,7 +64,7 @@ func TestDiagnosisNamesDurationAsFanQL(t *testing.T) { } // IDs are unique, so the most common ones say nothing: an ID filter lists no -// values seen. Other fields do, and an empty value is written as FanQL +// values seen. Other fields do, and an empty value is written as PitotQL // writes it. func TestDiagnosisValuesSeen(t *testing.T) { engine, repo := newTestEngine(t) diff --git a/internal/query/exec.go b/internal/query/exec.go index dc1f186a4..a7794b4ad 100644 --- a/internal/query/exec.go +++ b/internal/query/exec.go @@ -398,7 +398,7 @@ func (e *Executor) run(ctx context.Context, req RunRequest, emit func(int, Resul return caller.Err() } // Decide once before scheduling this batch's panels. A sibling waiting for - // the same limited panel slots is normal dashboard fanout, not evidence + // the same limited panel slots is normal dashboard concurrency, not evidence // of pre-existing pressure. Keep this policy even if the queue drains // before an admitted panel finishes; diagnosis uses its existing slot. deferDiagnosis := e.admission.waiting() > 0 @@ -894,8 +894,8 @@ func (e *Executor) runScope(ctx context.Context, p *Panel, checked *Checked, sco executionSQL := compiled.SQL scanColumns := compiled.Columns if compiled.ranking != nil { - executionSQL = executionSQL[:compiled.rankOffset] + `, (SELECT count(*) FROM candidates WHERE n < 20)::DOUBLE AS "_fanql_below_floor"` + executionSQL[compiled.rankOffset:] - scanColumns = append(append([]Column(nil), scanColumns...), Column{Name: "_fanql_below_floor", Type: "number"}) + executionSQL = executionSQL[:compiled.rankOffset] + `, (SELECT count(*) FROM candidates WHERE n < 20)::DOUBLE AS "_pitotql_below_floor"` + executionSQL[compiled.rankOffset:] + scanColumns = append(append([]Column(nil), scanColumns...), Column{Name: "_pitotql_below_floor", Type: "number"}) } rows, err := e.engine.QueryContext(ctx, executionSQL, compiled.Args...) if err != nil { diff --git a/internal/query/filter.go b/internal/query/filter.go index 9056b8611..16fa9dfc6 100644 --- a/internal/query/filter.go +++ b/internal/query/filter.go @@ -35,7 +35,7 @@ type Filter struct { DisplayLiteral string `json:"-"` DisplayParam string `json:"-"` NameInAnd bool `json:"-"` - // Negated is a whole entry that is one negated term as FanQL lowers it + // Negated is a whole entry that is one negated term as PitotQL lowers it // (proposal 0004, section 0.7); on the traces viz it excludes traces. Negated bool `json:"-"` } @@ -328,10 +328,10 @@ func checkAttributeExpr(v *SQLExpr) error { } // negatedTerm reports whether an expression is one prefix-negated term in a -// shape FanQL lowers it to and lifts back as one: k IS NULL (-k:*), NOT +// shape PitotQL lowers it to and lifts back as one: k IS NULL (-k:*), NOT // coalesce((p), FALSE) over one leaf, or (k IS NULL OR q) where q is one // comparison, IN, BETWEEN, LIKE or negated contains that reads only k. SQL's -// own k != v is not one, nor is a hand-written q that FanQL keeps raw. +// own k != v is not one, nor is a hand-written q that PitotQL keeps raw. func negatedTerm(v *SQLExpr) bool { if v == nil { return false @@ -358,7 +358,7 @@ func negatedTerm(v *SQLExpr) bool { return field != "" && negatedLeaf(v.Children[1]) && readsOnly(v.Children[1], field) } -// negatedLeaf reports whether q is one of the leaves FanQL writes after +// negatedLeaf reports whether q is one of the leaves PitotQL writes after // k IS NULL OR in a negated term: a predicate on the field itself, or a // negated contains. func negatedLeaf(q *SQLExpr) bool { @@ -715,7 +715,7 @@ func filterDisplay(node *SQLExpr) (field, literal, parameter string) { return "", "", "" } if node.Class == "FUNCTION" && node.Function == "contains" && len(node.Arguments) == 2 { - // FanQL free text and `~` lower to contains(lower(field), lower('text')). + // PitotQL free text and `~` lower to contains(lower(field), lower('text')). if field := displayField(fieldText(unwrapLower(node.Arguments[0]))); field != "" { if text := constantText(unwrapLower(node.Arguments[1])); text != "" { return field, `containing "` + text + `"`, "" diff --git a/internal/query/measure_syntax.go b/internal/query/measure_syntax.go index abe895926..5c06efd5a 100644 --- a/internal/query/measure_syntax.go +++ b/internal/query/measure_syntax.go @@ -27,7 +27,7 @@ type MeasureGrammar struct { } // ReadMeasureExpression is the single precedence and grouping grammar used by -// structured measures and FanQL. The result is panel's aggregate AST directly. +// structured measures and PitotQL. The result is panel's aggregate AST directly. func ReadMeasureExpression(g MeasureGrammar, minPrecedence, depth int) (MeasureExpr, int) { if !g.Depth(depth) || !g.OK() { return nil, 0 diff --git a/internal/query/problems.go b/internal/query/problems.go index 3f7cc6089..1f0c552ae 100644 --- a/internal/query/problems.go +++ b/internal/query/problems.go @@ -36,7 +36,7 @@ func DiagnosisProblem(path, message, hint string) Problem { return Problem{Path: path, Message: PresentDiagnosis(message), Hint: PresentDiagnosis(hint), productDiagnosis: true} } -// Diagnoses presents FanQL problems, which quote the user's own text (often URL +// Diagnoses presents PitotQL problems, which quote the user's own text (often URL // paths), as product-authored guidance rather than engine errors. func Diagnoses(problems Problems) Problems { for i := range problems { diff --git a/internal/query/shape.go b/internal/query/shape.go index 16995d76c..60377506c 100644 --- a/internal/query/shape.go +++ b/internal/query/shape.go @@ -65,7 +65,7 @@ func Shape(q *Spec, viz string, vars map[string]Variable, prepared ...[]Measure) func CompatibleVizzes(q *Spec, vars map[string]Variable, prepared ...[]Measure) []VizCompat { out := []VizCompat{} for _, viz := range vizOrder { - // Text and fixed rollup scopes are not FanQL query visualization targets. + // Text and fixed rollup scopes are not PitotQL query visualization targets. if viz == "text" || viz == "health" || viz == "service_map" { continue } diff --git a/internal/store/control_database_name.go b/internal/store/control_database_name.go new file mode 100644 index 000000000..78d414e5c --- /dev/null +++ b/internal/store/control_database_name.go @@ -0,0 +1,131 @@ +package store + +import ( + "fmt" + "log/slog" + "os" + "path/filepath" + "sort" + "strings" + + "golang.org/x/sys/unix" +) + +func previousControlDatabasePath(current string) string { + // Intentional compatibility exception: unattended upgrades must find the + // previous on-disk database instead of initializing an unclaimed instance. + return filepath.Join(filepath.Dir(current), "fanout.sqlite") +} + +// previousEnvironmentPrefix is isolated for the startup-refusal compatibility exception. +func previousEnvironmentPrefix() string { return "FANOUT_" } + +// RejectPreviousEnvironment refuses retired settings before startup can open state +// or listeners. Empty assignments count as set; values never enter diagnostics. +func RejectPreviousEnvironment(environ []string) error { + names := make(map[string]bool) + for _, assignment := range environ { + name, _, _ := strings.Cut(assignment, "=") + if strings.HasPrefix(name, previousEnvironmentPrefix()) { + names[name] = true + } + } + if len(names) == 0 { + return nil + } + ordered := make([]string, 0, len(names)) + for name := range names { + ordered = append(ordered, name) + } + sort.Strings(ordered) + return fmt.Errorf("retired environment variables: %s; rename them to PITOT_ before starting", strings.Join(ordered, ", ")) +} + +// MigrateControlDatabase preserves control state before any SQLite open can +// create a new, empty database. The service must be stopped during upgrades. +func MigrateControlDatabase(current string) error { + if filepath.Base(current) != "pitot.sqlite" || filepath.Base(filepath.Dir(current)) != "control" { + return nil + } + dir, err := os.Open(filepath.Dir(current)) + if os.IsNotExist(err) { + return nil + } + if err != nil { + return fmt.Errorf("inspect control directory: %w", err) + } + defer dir.Close() + // Serialize startup and CLI migrations without creating another on-disk name. + if err := unix.Flock(int(dir.Fd()), unix.LOCK_EX); err != nil { + return fmt.Errorf("lock control directory for database rename: %w", err) + } + defer unix.Flock(int(dir.Fd()), unix.LOCK_UN) //nolint:errcheck // Closing the descriptor also releases the lock. + + exists := func(path string) (bool, error) { + info, err := os.Lstat(path) + if os.IsNotExist(err) { + return false, nil + } + if err != nil { + return false, err + } + if !info.Mode().IsRegular() { + return false, fmt.Errorf("control database and sidecars must be regular files: %s", path) + } + return true, nil + } + previous := previousControlDatabasePath(current) + oldExists, err := exists(previous) + if err != nil { + return fmt.Errorf("inspect previous control database: %w", err) + } + newExists, err := exists(current) + if err != nil { + return fmt.Errorf("inspect current control database: %w", err) + } + if oldExists && newExists { + return fmt.Errorf("both control database names exist; stop the instance and reconcile control/ from a trusted backup before restarting") + } + var sidecars []string + for _, suffix := range []string{"-wal", "-shm", "-journal"} { + oldSidecar, err := exists(previous + suffix) + if err != nil { + return fmt.Errorf("inspect previous control sidecar: %w", err) + } + newSidecar, err := exists(current + suffix) + if err != nil { + return fmt.Errorf("inspect current control sidecar: %w", err) + } + // An interrupted move must fail closed, never open a database without its + // journal or discard a sidecar that might contain committed transactions. + if (oldSidecar && !oldExists) || (newSidecar && !newExists) { + return fmt.Errorf("orphaned or conflicting control database sidecars; stop the instance and recover the complete database file set before restarting") + } + if oldSidecar { + sidecars = append(sidecars, suffix) + } + } + if !oldExists { + return nil + } + // Rename sidecars first, then sync their directory entries before committing + // the main filename. A crash partway through leaves a refused partial state. + for _, suffix := range sidecars { + if err := os.Rename(previous+suffix, current+suffix); err != nil { + return fmt.Errorf("rename control database sidecar: %w", err) + } + } + if len(sidecars) > 0 { + if err := dir.Sync(); err != nil { + return fmt.Errorf("sync control sidecar renames: %w", err) + } + } + if err := os.Rename(previous, current); err != nil { + return fmt.Errorf("rename control database: %w", err) + } + if err := dir.Sync(); err != nil { + return fmt.Errorf("sync control database rename: %w", err) + } + slog.Info("migrated control database to the current name") + return nil +} diff --git a/internal/store/control_database_name_test.go b/internal/store/control_database_name_test.go new file mode 100644 index 000000000..ac5753304 --- /dev/null +++ b/internal/store/control_database_name_test.go @@ -0,0 +1,243 @@ +package store + +import ( + "bytes" + "log/slog" + "os" + "path/filepath" + "strings" + "testing" +) + +func controlDatabasePaths(t *testing.T) (string, string) { + t.Helper() + dir := filepath.Join(t.TempDir(), "control") + if err := os.Mkdir(dir, 0o700); err != nil { + t.Fatal(err) + } + current := filepath.Join(dir, "pitot.sqlite") + return current, previousControlDatabasePath(current) +} + +func TestControlDatabaseUpgradePreservesExistingUsers(t *testing.T) { + current, previous := controlDatabasePaths(t) + db, err := NewSQLite(previous) + if err != nil { + t.Fatal(err) + } + if _, err := db.DB.Exec(`INSERT INTO users (id, email, role) VALUES ('existing-admin', 'admin@example.test', 'admin')`); err != nil { + t.Fatal(err) + } + if err := db.Close(); err != nil { + t.Fatal(err) + } + db, err = NewSQLite(current) + if err != nil { + t.Fatal(err) + } + defer db.Close() + var role string + if err := db.DB.QueryRow(`SELECT role FROM users WHERE id = 'existing-admin'`).Scan(&role); err != nil { + t.Fatalf("existing administrator disappeared: %v", err) + } + if role != "admin" { + t.Fatalf("role = %q", role) + } + if _, err := os.Lstat(previous); !os.IsNotExist(err) { + t.Fatalf("previous database remains: %v", err) + } +} + +func TestControlDatabaseUpgradeRefusesBothNames(t *testing.T) { + current, previous := controlDatabasePaths(t) + for _, path := range []string{current, previous} { + if err := os.WriteFile(path, []byte("preserve"), 0o600); err != nil { + t.Fatal(err) + } + } + db, err := NewSQLite(current) + if err == nil { + db.Close() + t.Fatal("opened ambiguous control database") + } + if !strings.Contains(err.Error(), "both control database names exist") { + t.Fatalf("ambiguous database error = %v", err) + } + for _, path := range []string{current, previous} { + data, err := os.ReadFile(path) + if err != nil || string(data) != "preserve" { + t.Fatalf("database modified: data=%q err=%v", data, err) + } + } +} + +func TestControlDatabaseUpgradeMovesSidecarsWithoutCopying(t *testing.T) { + current, previous := controlDatabasePaths(t) + suffixes := []string{"", "-wal", "-shm", "-journal"} + before := make(map[string]os.FileInfo) + for _, suffix := range suffixes { + path := previous + suffix + if err := os.WriteFile(path, []byte("preserve"+suffix), 0o600); err != nil { + t.Fatal(err) + } + info, err := os.Stat(path) + if err != nil { + t.Fatal(err) + } + before[suffix] = info + } + var logs bytes.Buffer + original := slog.Default() + slog.SetDefault(slog.New(slog.NewTextHandler(&logs, nil))) + t.Cleanup(func() { slog.SetDefault(original) }) + if err := MigrateControlDatabase(current); err != nil { + t.Fatal(err) + } + for _, suffix := range suffixes { + data, err := os.ReadFile(current + suffix) + if err != nil || string(data) != "preserve"+suffix { + t.Fatalf("sidecar %q: data=%q err=%v", suffix, data, err) + } + info, err := os.Stat(current + suffix) + if err != nil { + t.Fatal(err) + } + if !os.SameFile(before[suffix], info) || info.Mode().Perm() != 0o600 { + t.Fatalf("file %q was copied or permissions changed", suffix) + } + if _, err := os.Lstat(previous + suffix); !os.IsNotExist(err) { + t.Fatalf("previous file %q remains: %v", suffix, err) + } + } + if err := MigrateControlDatabase(current); err != nil { + t.Fatal(err) + } + if strings.Count(logs.String(), "migrated control database to the current name") != 1 { + t.Fatalf("migration log = %q", logs.String()) + } +} + +func TestControlDatabaseUpgradeLeavesCurrentFilesUntouched(t *testing.T) { + current, _ := controlDatabasePaths(t) + for _, suffix := range []string{"", "-wal", "-shm", "-journal"} { + if err := os.WriteFile(current+suffix, []byte("current"+suffix), 0o600); err != nil { + t.Fatal(err) + } + } + if err := MigrateControlDatabase(current); err != nil { + t.Fatal(err) + } + for _, suffix := range []string{"", "-wal", "-shm", "-journal"} { + data, err := os.ReadFile(current + suffix) + if err != nil || string(data) != "current"+suffix { + t.Fatalf("current file %q changed: data=%q err=%v", suffix, data, err) + } + } +} + +func TestControlDatabaseUpgradeRecoversCommittedWAL(t *testing.T) { + current, previous := controlDatabasePaths(t) + db, err := NewSQLite(previous) + if err != nil { + t.Fatal(err) + } + if _, err := db.DB.Exec(`PRAGMA wal_checkpoint(TRUNCATE); PRAGMA wal_autocheckpoint=0`); err != nil { + t.Fatal(err) + } + if _, err := db.DB.Exec(`INSERT INTO users (id, email, role) VALUES ('wal-admin', 'admin@example.test', 'admin')`); err != nil { + t.Fatal(err) + } + // Snapshot a quiescent writer's file set before close checkpoints the WAL. + // Restoring those bytes models an unclean shutdown without an open writer. + files := make(map[string][]byte) + for _, suffix := range []string{"", "-wal", "-shm"} { + data, err := os.ReadFile(previous + suffix) + if err != nil { + t.Fatal(err) + } + files[suffix] = data + } + if len(files["-wal"]) <= 32 { + t.Fatal("fixture has no committed WAL frames") + } + if err := db.Close(); err != nil { + t.Fatal(err) + } + for suffix, data := range files { + if err := os.WriteFile(previous+suffix, data, 0o600); err != nil { + t.Fatal(err) + } + } + db, err = NewSQLite(current) + if err != nil { + t.Fatal(err) + } + defer db.Close() + var role string + if err := db.DB.QueryRow(`SELECT role FROM users WHERE id='wal-admin'`).Scan(&role); err != nil || role != "admin" { + t.Fatalf("committed WAL user lost: role=%q err=%v", role, err) + } +} + +func TestControlDatabaseUpgradeRefusesPartialFileSets(t *testing.T) { + for _, suffix := range []string{"-wal", "-shm", "-journal"} { + for _, state := range []string{"target_sidecar", "orphan_source"} { + t.Run(suffix+"/"+state, func(t *testing.T) { + current, previous := controlDatabasePaths(t) + path := previous + suffix + if state == "target_sidecar" { + if err := os.WriteFile(previous, []byte("old"), 0o600); err != nil { + t.Fatal(err) + } + path = current + suffix + } + if err := os.WriteFile(path, []byte("pending"), 0o600); err != nil { + t.Fatal(err) + } + if db, err := NewSQLite(current); err == nil { + db.Close() + t.Fatal("opened partial migration") + } else if !strings.Contains(err.Error(), "control database sidecars") { + t.Fatal(err) + } + if _, err := os.Lstat(current); !os.IsNotExist(err) { + t.Fatalf("created current database: %v", err) + } + data, err := os.ReadFile(path) + if err != nil || string(data) != "pending" { + t.Fatalf("sidecar overwritten: data=%q err=%v", data, err) + } + }) + } + } +} + +func TestControlDatabaseUpgradeAllowsFreshInstall(t *testing.T) { + current, _ := controlDatabasePaths(t) + db, err := NewSQLite(current) + if err != nil { + t.Fatal(err) + } + defer db.Close() + var users int + if err := db.DB.QueryRow(`SELECT COUNT(*) FROM users`).Scan(&users); err != nil || users != 0 { + t.Fatalf("fresh users = %d, err=%v", users, err) + } +} + +func TestPreviousEnvironmentRefusesNamesWithoutValues(t *testing.T) { + prefix := previousEnvironmentPrefix() + err := RejectPreviousEnvironment([]string{prefix + "TOKEN=private-marker", prefix + "ADDR=", prefix + "TOKEN=another-private-marker"}) + want := "retired environment variables: " + prefix + "ADDR, " + prefix + "TOKEN; rename them to PITOT_ before starting" + if err == nil || err.Error() != want { + t.Fatalf("refusal = %v, want %q", err, want) + } +} + +func TestPreviousEnvironmentAllowsCurrentAndCaseSensitiveNames(t *testing.T) { + for _, env := range [][]string{nil, {}, {"PITOT_ADDR=:0", strings.ToLower(previousEnvironmentPrefix()) + "TOKEN=ignored", "OTHER_" + previousEnvironmentPrefix() + "TOKEN=ignored"}} { + if err := RejectPreviousEnvironment(env); err != nil { + t.Fatal(err) + } + } +} diff --git a/internal/store/store.go b/internal/store/store.go index 3d84415fa..58d6a6653 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -28,6 +28,9 @@ type SQLite struct { // NewSQLite opens (or creates) an SQLite database at dbPath and runs // embedded schema migrations via Goose. Use ":memory:" for an in-memory database. func NewSQLite(dbPath string) (*SQLite, error) { + if err := MigrateControlDatabase(dbPath); err != nil { + return nil, err + } var dsn string if dbPath == ":memory:" { dsn = fmt.Sprintf("file::memory:?_pragma=busy_timeout(%d)&_pragma=foreign_keys(1)", ControlDBBusyTimeout.Milliseconds()) diff --git a/internal/ui/dist/assets/alerts-CYKuszTJ.js b/internal/ui/dist/assets/alerts-BlSGnTGi.js similarity index 98% rename from internal/ui/dist/assets/alerts-CYKuszTJ.js rename to internal/ui/dist/assets/alerts-BlSGnTGi.js index 111017848..6ae9b5d02 100644 --- a/internal/ui/dist/assets/alerts-CYKuszTJ.js +++ b/internal/ui/dist/assets/alerts-BlSGnTGi.js @@ -1 +1 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,Dt as i,Ft as a,G as o,N as s,Pt as c,S as l,T as u,Tt as d,a as f,en as p,f as m,g as h,in as g,j as _,k as v,q as y,s as b,u as x,w as S}from"./brand-D6fP-cLS.js";import{n as C}from"./useNavigate-B1zgPEUp.js";import{A as w,E as T,k as E}from"./search-D_K9J6yO.js";import{t as D}from"./NumberInput-CixyOph4.js";import{t as O}from"./Table-D4ZwUno3.js";import{n as k}from"./format-BZjbsxwM.js";import{c as A,i as j,l as M,n as N,o as P,r as F,s as ee,t as te}from"./live-data-meta-CUyw2snU.js";import{r as ne}from"./auth-DWqIkMZS.js";import{t as I}from"./Textarea-r3wuKNbO.js";import{T as re,t as L}from"./useQuery-BLTYSIvG.js";import{t as R}from"./useMutation-B1CTivyp.js";import{i as ie}from"./search-CDra9nG2.js";import{_ as ae,k as oe}from"./index-C1Pd14SU.js";import{t as se}from"./loading-skeleton-D1hXpfUI.js";import{t as ce}from"./discard-NZfxCIcK.js";var z=n(e(),1),B=t(),V=i(e=>{let t=a([`Input`,`InputWrapper`,`Autocomplete`],{size:`sm`},e),{classNames:n,styles:r,unstyled:i,vars:o,dropdownOpened:l,defaultDropdownOpened:u,onDropdownClose:d,onDropdownOpen:f,onFocus:m,onBlur:h,onClick:_,onChange:v,data:y,value:b,defaultValue:x,selectFirstOptionOnChange:S,selectFirstOptionOnDropdownOpen:C,onOptionSubmit:w,comboboxProps:T,readOnly:E,disabled:D,filter:O,limit:k,withScrollArea:N,maxDropdownHeight:te,floatingHeight:ne,size:I,id:re,renderOption:L,autoComplete:R,scrollAreaProps:ie,onClear:ae,clearButtonProps:oe,error:se,clearable:ce,clearSectionMode:V,rightSection:H,autoSelectOnBlur:U,openOnFocus:W=!0,attributes:G,...K}=t,le=g(re),q=F({id:le,label:K.label,labelProps:K.labelProps,inputWrapperOrder:K.inputWrapperOrder}),ue=M(y),de=A(ue),[J,fe]=p({value:b,defaultValue:x,finalValue:``,onChange:v}),Y=ee({opened:l,defaultOpened:u,onDropdownOpen:()=>{f?.(),C&&Y.selectFirstOption()},onDropdownClose:()=>{d?.(),setTimeout(Y.resetSelectedOption,0)}}),X=e=>{fe(e),Y.resetSelectedOption()},{resolvedClassNames:Z,resolvedStyles:pe}=c({props:t,styles:r,classNames:n});(0,z.useEffect)(()=>{S&&Y.selectFirstOption()},[S,J]);let me=(0,B.jsx)(P.ClearButton,{...oe,onClear:()=>{X(``),ae?.()}});return(0,B.jsxs)(P,{store:Y,__staticSelector:`Autocomplete`,classNames:Z,styles:pe,unstyled:i,readOnly:E,size:I,attributes:G,floatingHeight:ne,keepMounted:U,onOptionSubmit:e=>{w?.(e),X(de[e].label),Y.closeDropdown()},...T,children:[(0,B.jsx)(P.Target,{autoComplete:R,withExpandedAttribute:!0,children:(0,B.jsx)(s,{...K,size:I,__staticSelector:`Autocomplete`,__clearSection:me,__clearable:ce&&!!J&&!D&&!E,__clearSectionMode:V,rightSection:H,disabled:D,readOnly:E,value:J,error:se,onChange:e=>{X(e.currentTarget.value),Y.openDropdown(),S&&Y.selectFirstOption()},onFocus:e=>{W&&Y.openDropdown(),m?.(e)},onBlur:e=>{U&&Y.clickSelectedOption(),Y.closeDropdown(),h?.(e)},onClick:e=>{Y.openDropdown(),_?.(e)},classNames:Z,styles:pe,unstyled:i,attributes:G,id:le})}),(0,B.jsx)(j,{data:ue,hidden:E||D,filter:O,search:J,limit:k,hiddenWhenEmpty:!0,withScrollArea:N,maxDropdownHeight:te,unstyled:i,labelId:q,"aria-label":q?void 0:K[`aria-label`],renderOption:L,scrollAreaProps:ie})]})});V.classes={...s.classes,...P.classes},V.displayName=`@mantine/core/Autocomplete`;var H=[`alerting`,`rules`],U=[`alerting`,`alerts`],W=[`alerting`,`email`],G=e=>`/api/alerting/rules/${encodeURIComponent(e)}`,K=e=>T(`/api/alerting/rules`,{signal:e}).then(e=>e.rules),le=e=>T(`/api/alerting/alerts`,{signal:e}).then(e=>e.alerts),q=e=>T(`/api/alerting/email`,{signal:e}),ue=e=>T(`/api/alerting/rules`,{method:`POST`,json:e}),de=(e,t)=>T(G(e),{method:`PUT`,json:t}),J=e=>T(G(e),{method:`DELETE`}),fe=e=>T(`/api/telemetry/schema?window=1h`,{signal:e}).then(e=>(e.services??[]).map(e=>e.value)),Y=e=>T(`${G(e)}/test`,{method:`POST`}),X=/\b(error_rate|p50|p95|throughput|log_count|z_score|health_score)(_delta)?\b/g;function Z(e){let t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,`""`);return[...new Set(Array.from(t.matchAll(X),e=>e[0]))]}var pe=new Intl.NumberFormat(`en-US`,{style:`percent`,maximumFractionDigits:2}),me=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:0}),Q=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:2});function he(e,t){return e===`error_rate`?pe.format(t):e===`p50`||e===`p95`?`${Q.format(t)} ms`:e===`throughput`||e===`log_count`?me.format(t):e?.endsWith(`_delta`)?`${t>0?`+`:``}${Q.format(t)}%`:Q.format(t)}function ge(e){let t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,`""`),n=/\berror_rate\s*[<>=!]=?\s*(\d+(?:\.\d+)?)/.exec(t)??/(\d+(?:\.\d+)?)\s*[<>=!]=?\s*error_rate\b/.exec(t),r=n?Number(n[1]):0;return r>1?`error_rate runs from 0 to 1, so ${n[1]} can never be reached. For ${n[1]}%, write ${Q.format(r/100)}.`:void 0}var _e=[{label:`Error rate`,expression:`error_rate > 0.05 && throughput > 10`},{label:`p95 latency`,expression:`p95 > 500 && throughput > 10`},{label:`Traffic drop`,expression:`throughput_delta < -50`},{label:`Log volume`,expression:`log_count > 1000`}],ve={name:``,description:``,enabled:!0,service:``,expression:``,for_seconds:60,cooldown_s:300,repeat_interval_s:3600,webhook_url:``,webhook_headers:``,webhook_template:``,notify_on_resolve:!1};function ye(e){if(!e)return ve;let{id:t,created_at:n,updated_at:r,email_status:i,email_status_detail:a,email_status_at:o,...s}=e;return{...ve,...s}}var be=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,xe=e=>[...e].some(e=>{let t=e.charCodeAt(0);return t<32&&t!==9||t===127});function Se(e){if(!e?.trim())return;let t;try{t=JSON.parse(e)}catch{return`Enter a JSON object`}if(typeof t!=`object`||!t||Array.isArray(t))return`Enter a JSON object`;for(let[e,n]of Object.entries(t).sort(([e],[t])=>et))){if(!be.test(e))return`"${e}" is not a valid header name`;if(typeof n!=`string`)return`Header ${e} must be a string`;if(xe(n))return`Header ${e} has a line break or control character`}}var Ce=e=>e.split(/[,\s]+/).filter(Boolean),we=/^[^\s@,<>]+@[^\s@,<>]+$/;function Te(e,t){let n=e.find(e=>!we.test(e));return n?`"${n}" is not an email address`:new Set(e.map(e=>e.toLowerCase())).size>t?`Enter at most ${t} addresses`:void 0}function Ee({rule:e,onClose:t,onSave:n}){let[i,a]=(0,z.useState)(()=>ye(e)),[s,c]=(0,z.useState)(!1),l=ce(JSON.stringify(i)!==JSON.stringify(ye(e)),t,e?`this rule`:`the new rule`),[f,p]=(0,z.useState)(),m=e=>{a(t=>({...t,...e})),p(void 0)},h=i.webhook_headers===e?.webhook_headers?void 0:Se(i.webhook_headers),g=L({queryKey:W,queryFn:({signal:e})=>q(e),staleTime:6e4,retry:!1}),[y,x]=(0,z.useState)(()=>(e?.email_recipients??[]).join(`, `)),C=(e?.email_recipients?.length??0)>0,T=JSON.stringify(i.email_recipients??[])===JSON.stringify(e?.email_recipients??[])?void 0:Te(i.email_recipients??[],g.data?.max_recipients??10),E=i.name.trim()!==``&&i.expression.trim()!==``&&!h&&!T,O=L({queryKey:[`alerting`,`services`],queryFn:({signal:e})=>fe(e),staleTime:6e4,retry:!1}),k=i.service?.trim()??``,A=k!==``&&O.data!==void 0&&!O.data.includes(k),j=ge(i.expression),M=(e,t,n)=>(0,B.jsx)(D,{label:e,description:n,min:0,step:30,value:i[t],onChange:e=>m({[t]:typeof e==`number`?e:0})}),P=async()=>{c(!0);try{await n({...i,name:i.name.trim(),expression:i.expression.trim()})}catch(e){p(e instanceof Error?e.message:`The rule could not be saved`)}finally{c(!1)}};return(0,B.jsxs)(r,{opened:!0,onClose:()=>{s||l.request()},closeOnEscape:!1,onKeyDown:s?void 0:l.onKeyDown,title:e?`Edit rule · ${e.name}`:`New alert rule`,size:`lg`,children:[l.prompt,(0,B.jsxs)(u,{gap:`sm`,children:[(0,B.jsx)(S,{label:`Name`,required:!0,value:i.name,onChange:e=>m({name:e.currentTarget.value}),"data-autofocus":!0}),(0,B.jsx)(S,{label:`Description`,value:i.description??``,onChange:e=>m({description:e.currentTarget.value})}),(0,B.jsx)(V,{label:`Service`,description:`Leave empty to evaluate every service.`,data:O.data??[],value:i.service??``,onChange:e=>m({service:e})}),A&&(0,B.jsxs)(_,{size:`xs`,c:`warn`,mt:-8,role:`status`,children:[`No telemetry from `,k,` in the last hour. Check the name; the rule still saves.`]}),(0,B.jsxs)(u,{gap:4,children:[(0,B.jsxs)(o,{justify:`space-between`,align:`flex-end`,children:[(0,B.jsx)(_,{size:`sm`,fw:500,children:`Expression`}),(0,B.jsxs)(w,{position:`bottom-end`,children:[(0,B.jsx)(w.Target,{children:(0,B.jsx)(v,{size:`compact-xs`,variant:`subtle`,children:`Start from a template`})}),(0,B.jsx)(w.Dropdown,{children:_e.map(e=>(0,B.jsxs)(w.Item,{onClick:()=>m({expression:e.expression}),children:[e.label,(0,B.jsx)(_,{size:`xs`,c:`dimmed`,ff:`monospace`,children:e.expression})]},e.label))})]})]}),(0,B.jsx)(I,{"aria-label":`Expression`,required:!0,autosize:!0,minRows:2,ff:`monospace`,value:i.expression,onChange:e=>m({expression:e.currentTarget.value}),description:`A CEL condition over one service's rollup, for example error_rate > 0.05 && throughput > 10. error_rate is 0 to 1; p95 is in milliseconds.`}),j&&(0,B.jsx)(_,{size:`xs`,c:`warn`,role:`status`,children:j})]}),(0,B.jsxs)(o,{grow:!0,align:`flex-start`,children:[M(`Hold for (s)`,`for_seconds`,`Condition must hold this long, from the first check that sees it`),M(`Cooldown (s)`,`cooldown_s`,`Quiet period after resolving`),M(`Repeat every (s)`,`repeat_interval_s`,`0 delivers once`)]}),(0,B.jsxs)(u,{gap:4,children:[(0,B.jsx)(S,{label:`Email recipients`,placeholder:`oncall@example.com, team@example.com`,disabled:!g.data?.available&&!C,value:y,error:T,description:g.data?.available?`Separate addresses with commas, up to ${g.data.max_recipients}.${g.data.default_destination?` Leave this and the webhook empty to use the default destination.`:``}`:void 0,onChange:e=>{let t=e.currentTarget.value,n=Ce(t);x(t),m({email_recipients:n.length>0?n:void 0})}}),g.data&&!g.data.available&&(0,B.jsx)(_,{size:`xs`,c:`warn`,role:`status`,children:g.data.message}),g.isError&&(0,B.jsx)(_,{size:`xs`,c:`warn`,role:`status`,children:`Email availability could not be checked.`})]}),(0,B.jsx)(S,{label:`Webhook URL`,value:i.webhook_url??``,onChange:e=>m({webhook_url:e.currentTarget.value})}),(0,B.jsx)(I,{label:`Webhook headers`,description:`A JSON object, for example {"Authorization": "Bearer …"}`,autosize:!0,minRows:1,ff:`monospace`,value:i.webhook_headers??``,error:h,onChange:e=>m({webhook_headers:e.currentTarget.value})}),(0,B.jsx)(I,{label:`Webhook body template`,description:`Go text/template; leave empty for the default payload.`,autosize:!0,minRows:1,ff:`monospace`,value:i.webhook_template??``,onChange:e=>m({webhook_template:e.currentTarget.value})}),(0,B.jsxs)(o,{children:[(0,B.jsx)(N,{label:`Notify when resolved`,checked:i.notify_on_resolve,onChange:e=>m({notify_on_resolve:e.currentTarget.checked})}),(0,B.jsx)(N,{label:`Enabled`,checked:i.enabled,onChange:e=>m({enabled:e.currentTarget.checked})})]}),f&&(0,B.jsx)(d,{children:(0,B.jsx)(b,{tone:`danger`,title:`Not saved`,children:f})}),(0,B.jsxs)(o,{justify:`flex-end`,gap:`xs`,children:[(0,B.jsx)(v,{variant:`default`,disabled:s,onClick:l.request,children:`Cancel`}),(0,B.jsx)(v,{loading:s,disabled:!E,onClick:()=>void P(),children:e?`Save rule`:`Create rule`})]})]})]})}var De={firing:`danger`,pending:`warning`,resolved:`neutral`},$=e=>e?k(e):`—`,Oe={error_rate:`spans | error_rate()`,p95:`spans | p95(duration)`,throughput:`spans | count()`,log_count:`logs | count()`};function ke(e){let[t,n]=Oe[Z(e.expression).map(e=>e.replace(/_delta$/,``)).find(e=>e in Oe)??`throughput`].split(` | `);return e.service?`${t} where service:"${e.service.replaceAll(`"`,`""`)}" | ${n} every auto`:`${t} | ${n} by service every auto`}var Ae=`Open in Explore charts raw telemetry, so values can differ slightly from a rule's rollups. Explore shows error rate as a percent: a rule's 0.05 is 5 there.`,je={failed:{tone:`danger`,label:`Email failed`},unavailable:{tone:`danger`,label:`Email unavailable`},suppressed:{tone:`warning`,label:`Email suppressed`},retrying:{tone:`warning`,label:`Email retrying`}};function Me({onExplore:e}){let t=re(),n=ne().role!==`viewer`,i=L({queryKey:H,queryFn:({signal:e})=>K(e),refetchInterval:3e4}),a=L({queryKey:U,queryFn:({signal:e})=>le(e),refetchInterval:3e4}),[s,c]=(0,z.useState)(),[d,p]=(0,z.useState)(),[g,S]=(0,z.useState)(),C=ae(),T=(0,z.useRef)(null),D=(0,z.useRef)(new Map),k=e=>C.remember(D.current.get(e.id)??null),A=()=>{c(void 0),C.restore(T.current)},j=()=>{p(void 0),C.restore(T.current)},M=()=>{t.invalidateQueries({queryKey:H}),t.invalidateQueries({queryKey:U})},P=R({mutationFn:e=>de(e.id,{...Ne(e),enabled:!e.enabled}),onSuccess:M}),F=R({mutationFn:e=>J(e.id),onSuccess:()=>{I.current++,j(),M()}}),ee=async e=>{s?.rule?await de(s.rule.id,e):await ue(e),A(),M()},I=(0,z.useRef)(0),ie=()=>{I.current++,S(void 0),C.restore(T.current)},ce=e=>{let t=++I.current;S({rule:e});let n=n=>{I.current===t&&S({rule:e,...n})};Y(e.id).then(e=>n({result:e}),e=>n({error:e instanceof Error?e.message:`The test failed`}))},V=new Map((i.data??[]).map(e=>[e.id,e])),W=e=>(a.data??[]).filter(t=>t.rule_id===e.id&&t.fired_at).map(e=>e.fired_at).sort().at(-1),G=e=>(a.data??[]).filter(t=>t.rule_id===e.id&&(t.state===`firing`||t.state===`pending`)),q=[...a.data??[]].sort((e,t)=>(t.fired_at??t.created_at).localeCompare(e.fired_at??e.created_at));return(0,B.jsxs)(u,{gap:`lg`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,maw:1600,mx:`auto`,"data-alerts":!0,children:[(0,B.jsx)(h,{title:`Alerts`,description:`Evaluate service rules and deliver notifications when they fire.`,meta:(0,B.jsx)(te,{updatedAt:a.dataUpdatedAt}),actions:n&&(0,B.jsx)(v,{ref:T,leftSection:(0,B.jsx)(oe,{size:14}),onClick:e=>{C.remember(e.currentTarget),c({})},children:`New rule`})}),(0,B.jsxs)(u,{gap:`xs`,children:[(0,B.jsx)(l,{order:2,fz:18,children:`Rules`}),i.data&&i.data.length>0&&(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:Ae}),i.isLoading?(0,B.jsx)(f,{state:`loading`,loadingLabel:`Loading alert rules`,skeleton:(0,B.jsx)(se,{shape:`table`,columns:7,rows:4})}):i.error?(0,B.jsx)(f,{state:`error`,error:{message:`Rules could not be loaded: ${i.error.message}`,onRetry:()=>void i.refetch()}}):i.data?.length===0?(0,B.jsx)(f,{state:`empty`,empty:{title:`No rules yet`,description:n?`Create a rule to get notified when a service misbehaves.`:`An operator or admin can create rules.`,action:n&&(0,B.jsx)(v,{onClick:e=>{C.remember(e.currentTarget),c({})},children:`New rule`})}}):(0,B.jsx)(O.ScrollContainer,{minWidth:760,children:(0,B.jsxs)(O,{verticalSpacing:`sm`,children:[(0,B.jsx)(O.Thead,{children:(0,B.jsxs)(O.Tr,{children:[(0,B.jsx)(O.Th,{children:`Rule`}),(0,B.jsx)(O.Th,{children:`Service`}),(0,B.jsx)(O.Th,{children:`Expression`}),(0,B.jsx)(O.Th,{children:`State`}),(0,B.jsx)(O.Th,{children:`Last fired`}),(0,B.jsx)(O.Th,{children:`Enabled`}),(0,B.jsx)(O.Th,{w:48,children:(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:`Actions`})})]})}),(0,B.jsx)(O.Tbody,{children:i.data?.map(t=>{let r=G(t);return(0,B.jsxs)(O.Tr,{children:[(0,B.jsxs)(O.Td,{children:[(0,B.jsx)(_,{size:`sm`,fw:500,children:t.name}),t.description&&(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:t.description}),t.email_status&&je[t.email_status]&&(0,B.jsxs)(o,{gap:6,mt:4,role:`status`,children:[(0,B.jsx)(m,{tone:je[t.email_status].tone,children:je[t.email_status].label}),t.email_status_detail&&(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:t.email_status_detail})]})]}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,children:t.service||`All services`})}),(0,B.jsxs)(O.Td,{children:[(0,B.jsx)(_,{size:`xs`,ff:`monospace`,children:t.expression}),(0,B.jsx)(v,{size:`compact-xs`,variant:`subtle`,px:0,onClick:()=>e(ke(t)),children:`Open in Explore`})]}),(0,B.jsx)(O.Td,{children:t.enabled?a.isSuccess?r.length>0?(0,B.jsx)(o,{gap:4,children:r.map(e=>(0,B.jsxs)(m,{tone:De[e.state]??`neutral`,children:[e.state.charAt(0).toUpperCase()+e.state.slice(1),` · `,e.service]},e.id))}):(0,B.jsx)(m,{tone:`success`,children:`Ok`}):(0,B.jsx)(m,{tone:`neutral`,children:`Unknown`}):(0,B.jsx)(m,{tone:`neutral`,children:`Disabled`})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,ff:`monospace`,children:a.isSuccess?$(W(t)):`—`})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(N,{"aria-label":`Enable ${t.name}`,checked:t.enabled,disabled:!n||P.isPending,onChange:()=>P.mutate(t)})}),(0,B.jsx)(O.Td,{children:n&&(0,B.jsxs)(w,{position:`bottom-end`,children:[(0,B.jsx)(w.Target,{children:(0,B.jsx)(y,{ref:e=>{e?D.current.set(t.id,e):D.current.delete(t.id)},variant:`subtle`,color:`gray`,"aria-label":`${t.name} actions`,children:(0,B.jsx)(E,{size:18})})}),(0,B.jsxs)(w.Dropdown,{children:[(0,B.jsx)(w.Item,{onClick:()=>{k(t),c({rule:t})},children:`Edit`}),(0,B.jsx)(w.Item,{onClick:()=>{k(t),ce(t)},children:`Test against current data`}),(0,B.jsx)(w.Item,{color:`bad`,onClick:()=>{k(t),p(t)},children:`Delete`})]})]})})]},t.id)})})]})}),P.error&&(0,B.jsx)(b,{tone:`danger`,children:P.error.message})]}),(0,B.jsxs)(u,{gap:`xs`,children:[(0,B.jsx)(l,{order:2,fz:18,children:`History`}),a.isLoading?(0,B.jsx)(f,{state:`loading`,loadingLabel:`Loading alert history`,skeleton:(0,B.jsx)(se,{shape:`table`,columns:7,rows:4})}):a.error?(0,B.jsxs)(b,{tone:`danger`,children:[`Alert history could not be loaded: `,a.error.message]}):q.length===0?(0,B.jsx)(f,{state:`empty`,empty:{title:`Nothing has fired yet`,description:`Alerts appear here when a rule fires.`}}):(0,B.jsx)(O.ScrollContainer,{minWidth:760,scrollAreaProps:{viewportProps:{tabIndex:0,role:`region`,"aria-label":`Alert history`}},children:(0,B.jsxs)(O,{verticalSpacing:`xs`,children:[(0,B.jsx)(O.Thead,{children:(0,B.jsxs)(O.Tr,{children:[(0,B.jsx)(O.Th,{children:`State`}),(0,B.jsx)(O.Th,{children:`Rule`}),(0,B.jsx)(O.Th,{children:`Service`}),(0,B.jsx)(O.Th,{ta:`right`,children:`Value`}),(0,B.jsx)(O.Th,{children:`Fired`}),(0,B.jsx)(O.Th,{children:`Resolved`}),(0,B.jsx)(O.Th,{children:`Delivery`})]})}),(0,B.jsx)(O.Tbody,{children:q.map(e=>(0,B.jsxs)(O.Tr,{children:[(0,B.jsx)(O.Td,{children:(0,B.jsx)(m,{tone:De[e.state]??`neutral`,children:e.state.charAt(0).toUpperCase()+e.state.slice(1)})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,children:V.get(e.rule_id)?.name??e.rule_id})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,children:e.service})}),(0,B.jsx)(O.Td,{ta:`right`,children:(0,B.jsx)(_,{size:`sm`,ff:`monospace`,children:e.value===void 0?`—`:he(Z(V.get(e.rule_id)?.expression??``)[0],e.value)})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,ff:`monospace`,children:$(e.fired_at)})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,ff:`monospace`,children:$(e.resolved_at)})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:e.last_delivery_status?`${e.last_delivery_status} · ${$(e.last_delivery_at)}`:`—`})})]},e.id))})]})})]}),s&&(0,B.jsx)(Ee,{rule:s.rule,onClose:A,onSave:ee}),d&&(0,B.jsxs)(x,{opened:!0,onClose:j,title:`Delete ${d.name}?`,confirmLabel:`Delete rule`,tone:`danger`,pending:F.isPending?`confirm`:null,error:F.error?.message,onConfirm:()=>F.mutate(d),children:[`The rule `,(0,B.jsx)(_,{span:!0,ff:`monospace`,children:d.name}),` and its alert history are removed. This cannot be undone.`]}),g&&(0,B.jsx)(r,{opened:!0,onClose:ie,closeButtonProps:{"aria-label":`Close test`},title:`Test · ${g.rule.name}`,children:g.error?(0,B.jsx)(b,{tone:`danger`,children:g.error}):g.result?g.result.results?.length?(0,B.jsx)(u,{gap:`xs`,children:g.result.results.map(e=>(0,B.jsxs)(u,{gap:2,children:[(0,B.jsxs)(o,{justify:`space-between`,children:[(0,B.jsx)(_,{size:`sm`,children:e.service}),e.error?(0,B.jsx)(_,{size:`xs`,c:`bad`,children:e.error}):e.no_data?(0,B.jsx)(m,{tone:`warning`,children:`No recent data`}):(0,B.jsx)(m,{tone:e.triggered?`danger`:`success`,children:e.triggered?`Would fire`:`Quiet`})]}),e.no_data?(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:`This service has sent no telemetry recently. Check its name.`}):(0,B.jsx)(_,{size:`xs`,c:`dimmed`,ff:`monospace`,children:Z(g.rule.expression).filter(t=>typeof e.env?.[t]==`number`).map(t=>`${t} ${he(t,e.env[t])}`).join(` · `)})]},e.service))}):(0,B.jsx)(f,{state:`empty`,empty:{title:`No services have data in the current window.`}}):(0,B.jsx)(f,{state:`loading`,loadingLabel:`Testing the rule`,rows:3})})]})}function Ne(e){let{id:t,created_at:n,updated_at:r,email_status:i,email_status_detail:a,email_status_at:o,...s}=e;return s}function Pe(){let e=C();return(0,B.jsx)(Me,{onExplore:t=>void e({to:`/explore`,search:ie({q:t,range:`1h`,tab:`query`})})})}export{Pe as component}; \ No newline at end of file +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,Dt as i,Ft as a,G as o,N as s,Pt as c,S as l,T as u,Tt as d,a as f,en as p,f as m,g as h,in as g,j as _,k as v,q as y,s as b,u as x,w as S}from"./brand-D6fP-cLS.js";import{n as C}from"./useNavigate-B1zgPEUp.js";import{A as w,E as T,k as E}from"./search-P7VEnlsD.js";import{t as D}from"./NumberInput-CixyOph4.js";import{t as O}from"./Table-D4ZwUno3.js";import{n as k}from"./format-BZjbsxwM.js";import{c as A,i as j,l as M,n as N,o as P,r as F,s as ee,t as te}from"./live-data-meta-CkxM9djV.js";import{r as ne}from"./auth-DcVParCH.js";import{t as I}from"./Textarea-r3wuKNbO.js";import{T as re,t as L}from"./useQuery-BLTYSIvG.js";import{t as R}from"./useMutation-Diiy6DUC.js";import{i as ie}from"./search-pvW8SUhM.js";import{_ as ae,k as oe}from"./index-D7FG-NN3.js";import{t as se}from"./loading-skeleton-D1hXpfUI.js";import{t as ce}from"./discard-NZfxCIcK.js";var z=n(e(),1),B=t(),V=i(e=>{let t=a([`Input`,`InputWrapper`,`Autocomplete`],{size:`sm`},e),{classNames:n,styles:r,unstyled:i,vars:o,dropdownOpened:l,defaultDropdownOpened:u,onDropdownClose:d,onDropdownOpen:f,onFocus:m,onBlur:h,onClick:_,onChange:v,data:y,value:b,defaultValue:x,selectFirstOptionOnChange:S,selectFirstOptionOnDropdownOpen:C,onOptionSubmit:w,comboboxProps:T,readOnly:E,disabled:D,filter:O,limit:k,withScrollArea:N,maxDropdownHeight:te,floatingHeight:ne,size:I,id:re,renderOption:L,autoComplete:R,scrollAreaProps:ie,onClear:ae,clearButtonProps:oe,error:se,clearable:ce,clearSectionMode:V,rightSection:H,autoSelectOnBlur:U,openOnFocus:W=!0,attributes:G,...K}=t,le=g(re),q=F({id:le,label:K.label,labelProps:K.labelProps,inputWrapperOrder:K.inputWrapperOrder}),ue=M(y),de=A(ue),[J,fe]=p({value:b,defaultValue:x,finalValue:``,onChange:v}),Y=ee({opened:l,defaultOpened:u,onDropdownOpen:()=>{f?.(),C&&Y.selectFirstOption()},onDropdownClose:()=>{d?.(),setTimeout(Y.resetSelectedOption,0)}}),X=e=>{fe(e),Y.resetSelectedOption()},{resolvedClassNames:Z,resolvedStyles:pe}=c({props:t,styles:r,classNames:n});(0,z.useEffect)(()=>{S&&Y.selectFirstOption()},[S,J]);let me=(0,B.jsx)(P.ClearButton,{...oe,onClear:()=>{X(``),ae?.()}});return(0,B.jsxs)(P,{store:Y,__staticSelector:`Autocomplete`,classNames:Z,styles:pe,unstyled:i,readOnly:E,size:I,attributes:G,floatingHeight:ne,keepMounted:U,onOptionSubmit:e=>{w?.(e),X(de[e].label),Y.closeDropdown()},...T,children:[(0,B.jsx)(P.Target,{autoComplete:R,withExpandedAttribute:!0,children:(0,B.jsx)(s,{...K,size:I,__staticSelector:`Autocomplete`,__clearSection:me,__clearable:ce&&!!J&&!D&&!E,__clearSectionMode:V,rightSection:H,disabled:D,readOnly:E,value:J,error:se,onChange:e=>{X(e.currentTarget.value),Y.openDropdown(),S&&Y.selectFirstOption()},onFocus:e=>{W&&Y.openDropdown(),m?.(e)},onBlur:e=>{U&&Y.clickSelectedOption(),Y.closeDropdown(),h?.(e)},onClick:e=>{Y.openDropdown(),_?.(e)},classNames:Z,styles:pe,unstyled:i,attributes:G,id:le})}),(0,B.jsx)(j,{data:ue,hidden:E||D,filter:O,search:J,limit:k,hiddenWhenEmpty:!0,withScrollArea:N,maxDropdownHeight:te,unstyled:i,labelId:q,"aria-label":q?void 0:K[`aria-label`],renderOption:L,scrollAreaProps:ie})]})});V.classes={...s.classes,...P.classes},V.displayName=`@mantine/core/Autocomplete`;var H=[`alerting`,`rules`],U=[`alerting`,`alerts`],W=[`alerting`,`email`],G=e=>`/api/alerting/rules/${encodeURIComponent(e)}`,K=e=>T(`/api/alerting/rules`,{signal:e}).then(e=>e.rules),le=e=>T(`/api/alerting/alerts`,{signal:e}).then(e=>e.alerts),q=e=>T(`/api/alerting/email`,{signal:e}),ue=e=>T(`/api/alerting/rules`,{method:`POST`,json:e}),de=(e,t)=>T(G(e),{method:`PUT`,json:t}),J=e=>T(G(e),{method:`DELETE`}),fe=e=>T(`/api/telemetry/schema?window=1h`,{signal:e}).then(e=>(e.services??[]).map(e=>e.value)),Y=e=>T(`${G(e)}/test`,{method:`POST`}),X=/\b(error_rate|p50|p95|throughput|log_count|z_score|health_score)(_delta)?\b/g;function Z(e){let t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,`""`);return[...new Set(Array.from(t.matchAll(X),e=>e[0]))]}var pe=new Intl.NumberFormat(`en-US`,{style:`percent`,maximumFractionDigits:2}),me=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:0}),Q=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:2});function he(e,t){return e===`error_rate`?pe.format(t):e===`p50`||e===`p95`?`${Q.format(t)} ms`:e===`throughput`||e===`log_count`?me.format(t):e?.endsWith(`_delta`)?`${t>0?`+`:``}${Q.format(t)}%`:Q.format(t)}function ge(e){let t=e.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,`""`),n=/\berror_rate\s*[<>=!]=?\s*(\d+(?:\.\d+)?)/.exec(t)??/(\d+(?:\.\d+)?)\s*[<>=!]=?\s*error_rate\b/.exec(t),r=n?Number(n[1]):0;return r>1?`error_rate runs from 0 to 1, so ${n[1]} can never be reached. For ${n[1]}%, write ${Q.format(r/100)}.`:void 0}var _e=[{label:`Error rate`,expression:`error_rate > 0.05 && throughput > 10`},{label:`p95 latency`,expression:`p95 > 500 && throughput > 10`},{label:`Traffic drop`,expression:`throughput_delta < -50`},{label:`Log volume`,expression:`log_count > 1000`}],ve={name:``,description:``,enabled:!0,service:``,expression:``,for_seconds:60,cooldown_s:300,repeat_interval_s:3600,webhook_url:``,webhook_headers:``,webhook_template:``,notify_on_resolve:!1};function ye(e){if(!e)return ve;let{id:t,created_at:n,updated_at:r,email_status:i,email_status_detail:a,email_status_at:o,...s}=e;return{...ve,...s}}var be=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,xe=e=>[...e].some(e=>{let t=e.charCodeAt(0);return t<32&&t!==9||t===127});function Se(e){if(!e?.trim())return;let t;try{t=JSON.parse(e)}catch{return`Enter a JSON object`}if(typeof t!=`object`||!t||Array.isArray(t))return`Enter a JSON object`;for(let[e,n]of Object.entries(t).sort(([e],[t])=>et))){if(!be.test(e))return`"${e}" is not a valid header name`;if(typeof n!=`string`)return`Header ${e} must be a string`;if(xe(n))return`Header ${e} has a line break or control character`}}var Ce=e=>e.split(/[,\s]+/).filter(Boolean),we=/^[^\s@,<>]+@[^\s@,<>]+$/;function Te(e,t){let n=e.find(e=>!we.test(e));return n?`"${n}" is not an email address`:new Set(e.map(e=>e.toLowerCase())).size>t?`Enter at most ${t} addresses`:void 0}function Ee({rule:e,onClose:t,onSave:n}){let[i,a]=(0,z.useState)(()=>ye(e)),[s,c]=(0,z.useState)(!1),l=ce(JSON.stringify(i)!==JSON.stringify(ye(e)),t,e?`this rule`:`the new rule`),[f,p]=(0,z.useState)(),m=e=>{a(t=>({...t,...e})),p(void 0)},h=i.webhook_headers===e?.webhook_headers?void 0:Se(i.webhook_headers),g=L({queryKey:W,queryFn:({signal:e})=>q(e),staleTime:6e4,retry:!1}),[y,x]=(0,z.useState)(()=>(e?.email_recipients??[]).join(`, `)),C=(e?.email_recipients?.length??0)>0,T=JSON.stringify(i.email_recipients??[])===JSON.stringify(e?.email_recipients??[])?void 0:Te(i.email_recipients??[],g.data?.max_recipients??10),E=i.name.trim()!==``&&i.expression.trim()!==``&&!h&&!T,O=L({queryKey:[`alerting`,`services`],queryFn:({signal:e})=>fe(e),staleTime:6e4,retry:!1}),k=i.service?.trim()??``,A=k!==``&&O.data!==void 0&&!O.data.includes(k),j=ge(i.expression),M=(e,t,n)=>(0,B.jsx)(D,{label:e,description:n,min:0,step:30,value:i[t],onChange:e=>m({[t]:typeof e==`number`?e:0})}),P=async()=>{c(!0);try{await n({...i,name:i.name.trim(),expression:i.expression.trim()})}catch(e){p(e instanceof Error?e.message:`The rule could not be saved`)}finally{c(!1)}};return(0,B.jsxs)(r,{opened:!0,onClose:()=>{s||l.request()},closeOnEscape:!1,onKeyDown:s?void 0:l.onKeyDown,title:e?`Edit rule · ${e.name}`:`New alert rule`,size:`lg`,children:[l.prompt,(0,B.jsxs)(u,{gap:`sm`,children:[(0,B.jsx)(S,{label:`Name`,required:!0,value:i.name,onChange:e=>m({name:e.currentTarget.value}),"data-autofocus":!0}),(0,B.jsx)(S,{label:`Description`,value:i.description??``,onChange:e=>m({description:e.currentTarget.value})}),(0,B.jsx)(V,{label:`Service`,description:`Leave empty to evaluate every service.`,data:O.data??[],value:i.service??``,onChange:e=>m({service:e})}),A&&(0,B.jsxs)(_,{size:`xs`,c:`warn`,mt:-8,role:`status`,children:[`No telemetry from `,k,` in the last hour. Check the name; the rule still saves.`]}),(0,B.jsxs)(u,{gap:4,children:[(0,B.jsxs)(o,{justify:`space-between`,align:`flex-end`,children:[(0,B.jsx)(_,{size:`sm`,fw:500,children:`Expression`}),(0,B.jsxs)(w,{position:`bottom-end`,children:[(0,B.jsx)(w.Target,{children:(0,B.jsx)(v,{size:`compact-xs`,variant:`subtle`,children:`Start from a template`})}),(0,B.jsx)(w.Dropdown,{children:_e.map(e=>(0,B.jsxs)(w.Item,{onClick:()=>m({expression:e.expression}),children:[e.label,(0,B.jsx)(_,{size:`xs`,c:`dimmed`,ff:`monospace`,children:e.expression})]},e.label))})]})]}),(0,B.jsx)(I,{"aria-label":`Expression`,required:!0,autosize:!0,minRows:2,ff:`monospace`,value:i.expression,onChange:e=>m({expression:e.currentTarget.value}),description:`A CEL condition over one service's rollup, for example error_rate > 0.05 && throughput > 10. error_rate is 0 to 1; p95 is in milliseconds.`}),j&&(0,B.jsx)(_,{size:`xs`,c:`warn`,role:`status`,children:j})]}),(0,B.jsxs)(o,{grow:!0,align:`flex-start`,children:[M(`Hold for (s)`,`for_seconds`,`Condition must hold this long, from the first check that sees it`),M(`Cooldown (s)`,`cooldown_s`,`Quiet period after resolving`),M(`Repeat every (s)`,`repeat_interval_s`,`0 delivers once`)]}),(0,B.jsxs)(u,{gap:4,children:[(0,B.jsx)(S,{label:`Email recipients`,placeholder:`oncall@example.com, team@example.com`,disabled:!g.data?.available&&!C,value:y,error:T,description:g.data?.available?`Separate addresses with commas, up to ${g.data.max_recipients}.${g.data.default_destination?` Leave this and the webhook empty to use the default destination.`:``}`:void 0,onChange:e=>{let t=e.currentTarget.value,n=Ce(t);x(t),m({email_recipients:n.length>0?n:void 0})}}),g.data&&!g.data.available&&(0,B.jsx)(_,{size:`xs`,c:`warn`,role:`status`,children:g.data.message}),g.isError&&(0,B.jsx)(_,{size:`xs`,c:`warn`,role:`status`,children:`Email availability could not be checked.`})]}),(0,B.jsx)(S,{label:`Webhook URL`,value:i.webhook_url??``,onChange:e=>m({webhook_url:e.currentTarget.value})}),(0,B.jsx)(I,{label:`Webhook headers`,description:`A JSON object, for example {"Authorization": "Bearer …"}`,autosize:!0,minRows:1,ff:`monospace`,value:i.webhook_headers??``,error:h,onChange:e=>m({webhook_headers:e.currentTarget.value})}),(0,B.jsx)(I,{label:`Webhook body template`,description:`Go text/template; leave empty for the default payload.`,autosize:!0,minRows:1,ff:`monospace`,value:i.webhook_template??``,onChange:e=>m({webhook_template:e.currentTarget.value})}),(0,B.jsxs)(o,{children:[(0,B.jsx)(N,{label:`Notify when resolved`,checked:i.notify_on_resolve,onChange:e=>m({notify_on_resolve:e.currentTarget.checked})}),(0,B.jsx)(N,{label:`Enabled`,checked:i.enabled,onChange:e=>m({enabled:e.currentTarget.checked})})]}),f&&(0,B.jsx)(d,{children:(0,B.jsx)(b,{tone:`danger`,title:`Not saved`,children:f})}),(0,B.jsxs)(o,{justify:`flex-end`,gap:`xs`,children:[(0,B.jsx)(v,{variant:`default`,disabled:s,onClick:l.request,children:`Cancel`}),(0,B.jsx)(v,{loading:s,disabled:!E,onClick:()=>void P(),children:e?`Save rule`:`Create rule`})]})]})]})}var De={firing:`danger`,pending:`warning`,resolved:`neutral`},$=e=>e?k(e):`—`,Oe={error_rate:`spans | error_rate()`,p95:`spans | p95(duration)`,throughput:`spans | count()`,log_count:`logs | count()`};function ke(e){let[t,n]=Oe[Z(e.expression).map(e=>e.replace(/_delta$/,``)).find(e=>e in Oe)??`throughput`].split(` | `);return e.service?`${t} where service:"${e.service.replaceAll(`"`,`""`)}" | ${n} every auto`:`${t} | ${n} by service every auto`}var Ae=`Open in Explore charts raw telemetry, so values can differ slightly from a rule's rollups. Explore shows error rate as a percent: a rule's 0.05 is 5 there.`,je={failed:{tone:`danger`,label:`Email failed`},unavailable:{tone:`danger`,label:`Email unavailable`},suppressed:{tone:`warning`,label:`Email suppressed`},retrying:{tone:`warning`,label:`Email retrying`}};function Me({onExplore:e}){let t=re(),n=ne().role!==`viewer`,i=L({queryKey:H,queryFn:({signal:e})=>K(e),refetchInterval:3e4}),a=L({queryKey:U,queryFn:({signal:e})=>le(e),refetchInterval:3e4}),[s,c]=(0,z.useState)(),[d,p]=(0,z.useState)(),[g,S]=(0,z.useState)(),C=ae(),T=(0,z.useRef)(null),D=(0,z.useRef)(new Map),k=e=>C.remember(D.current.get(e.id)??null),A=()=>{c(void 0),C.restore(T.current)},j=()=>{p(void 0),C.restore(T.current)},M=()=>{t.invalidateQueries({queryKey:H}),t.invalidateQueries({queryKey:U})},P=R({mutationFn:e=>de(e.id,{...Ne(e),enabled:!e.enabled}),onSuccess:M}),F=R({mutationFn:e=>J(e.id),onSuccess:()=>{I.current++,j(),M()}}),ee=async e=>{s?.rule?await de(s.rule.id,e):await ue(e),A(),M()},I=(0,z.useRef)(0),ie=()=>{I.current++,S(void 0),C.restore(T.current)},ce=e=>{let t=++I.current;S({rule:e});let n=n=>{I.current===t&&S({rule:e,...n})};Y(e.id).then(e=>n({result:e}),e=>n({error:e instanceof Error?e.message:`The test failed`}))},V=new Map((i.data??[]).map(e=>[e.id,e])),W=e=>(a.data??[]).filter(t=>t.rule_id===e.id&&t.fired_at).map(e=>e.fired_at).sort().at(-1),G=e=>(a.data??[]).filter(t=>t.rule_id===e.id&&(t.state===`firing`||t.state===`pending`)),q=[...a.data??[]].sort((e,t)=>(t.fired_at??t.created_at).localeCompare(e.fired_at??e.created_at));return(0,B.jsxs)(u,{gap:`lg`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,maw:1600,mx:`auto`,"data-alerts":!0,children:[(0,B.jsx)(h,{title:`Alerts`,description:`Evaluate service rules and deliver notifications when they fire.`,meta:(0,B.jsx)(te,{updatedAt:a.dataUpdatedAt}),actions:n&&(0,B.jsx)(v,{ref:T,leftSection:(0,B.jsx)(oe,{size:14}),onClick:e=>{C.remember(e.currentTarget),c({})},children:`New rule`})}),(0,B.jsxs)(u,{gap:`xs`,children:[(0,B.jsx)(l,{order:2,fz:18,children:`Rules`}),i.data&&i.data.length>0&&(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:Ae}),i.isLoading?(0,B.jsx)(f,{state:`loading`,loadingLabel:`Loading alert rules`,skeleton:(0,B.jsx)(se,{shape:`table`,columns:7,rows:4})}):i.error?(0,B.jsx)(f,{state:`error`,error:{message:`Rules could not be loaded: ${i.error.message}`,onRetry:()=>void i.refetch()}}):i.data?.length===0?(0,B.jsx)(f,{state:`empty`,empty:{title:`No rules yet`,description:n?`Create a rule to get notified when a service misbehaves.`:`An operator or admin can create rules.`,action:n&&(0,B.jsx)(v,{onClick:e=>{C.remember(e.currentTarget),c({})},children:`New rule`})}}):(0,B.jsx)(O.ScrollContainer,{minWidth:760,children:(0,B.jsxs)(O,{verticalSpacing:`sm`,children:[(0,B.jsx)(O.Thead,{children:(0,B.jsxs)(O.Tr,{children:[(0,B.jsx)(O.Th,{children:`Rule`}),(0,B.jsx)(O.Th,{children:`Service`}),(0,B.jsx)(O.Th,{children:`Expression`}),(0,B.jsx)(O.Th,{children:`State`}),(0,B.jsx)(O.Th,{children:`Last fired`}),(0,B.jsx)(O.Th,{children:`Enabled`}),(0,B.jsx)(O.Th,{w:48,children:(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:`Actions`})})]})}),(0,B.jsx)(O.Tbody,{children:i.data?.map(t=>{let r=G(t);return(0,B.jsxs)(O.Tr,{children:[(0,B.jsxs)(O.Td,{children:[(0,B.jsx)(_,{size:`sm`,fw:500,children:t.name}),t.description&&(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:t.description}),t.email_status&&je[t.email_status]&&(0,B.jsxs)(o,{gap:6,mt:4,role:`status`,children:[(0,B.jsx)(m,{tone:je[t.email_status].tone,children:je[t.email_status].label}),t.email_status_detail&&(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:t.email_status_detail})]})]}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,children:t.service||`All services`})}),(0,B.jsxs)(O.Td,{children:[(0,B.jsx)(_,{size:`xs`,ff:`monospace`,children:t.expression}),(0,B.jsx)(v,{size:`compact-xs`,variant:`subtle`,px:0,onClick:()=>e(ke(t)),children:`Open in Explore`})]}),(0,B.jsx)(O.Td,{children:t.enabled?a.isSuccess?r.length>0?(0,B.jsx)(o,{gap:4,children:r.map(e=>(0,B.jsxs)(m,{tone:De[e.state]??`neutral`,children:[e.state.charAt(0).toUpperCase()+e.state.slice(1),` · `,e.service]},e.id))}):(0,B.jsx)(m,{tone:`success`,children:`Ok`}):(0,B.jsx)(m,{tone:`neutral`,children:`Unknown`}):(0,B.jsx)(m,{tone:`neutral`,children:`Disabled`})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,ff:`monospace`,children:a.isSuccess?$(W(t)):`—`})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(N,{"aria-label":`Enable ${t.name}`,checked:t.enabled,disabled:!n||P.isPending,onChange:()=>P.mutate(t)})}),(0,B.jsx)(O.Td,{children:n&&(0,B.jsxs)(w,{position:`bottom-end`,children:[(0,B.jsx)(w.Target,{children:(0,B.jsx)(y,{ref:e=>{e?D.current.set(t.id,e):D.current.delete(t.id)},variant:`subtle`,color:`gray`,"aria-label":`${t.name} actions`,children:(0,B.jsx)(E,{size:18})})}),(0,B.jsxs)(w.Dropdown,{children:[(0,B.jsx)(w.Item,{onClick:()=>{k(t),c({rule:t})},children:`Edit`}),(0,B.jsx)(w.Item,{onClick:()=>{k(t),ce(t)},children:`Test against current data`}),(0,B.jsx)(w.Item,{color:`bad`,onClick:()=>{k(t),p(t)},children:`Delete`})]})]})})]},t.id)})})]})}),P.error&&(0,B.jsx)(b,{tone:`danger`,children:P.error.message})]}),(0,B.jsxs)(u,{gap:`xs`,children:[(0,B.jsx)(l,{order:2,fz:18,children:`History`}),a.isLoading?(0,B.jsx)(f,{state:`loading`,loadingLabel:`Loading alert history`,skeleton:(0,B.jsx)(se,{shape:`table`,columns:7,rows:4})}):a.error?(0,B.jsxs)(b,{tone:`danger`,children:[`Alert history could not be loaded: `,a.error.message]}):q.length===0?(0,B.jsx)(f,{state:`empty`,empty:{title:`Nothing has fired yet`,description:`Alerts appear here when a rule fires.`}}):(0,B.jsx)(O.ScrollContainer,{minWidth:760,scrollAreaProps:{viewportProps:{tabIndex:0,role:`region`,"aria-label":`Alert history`}},children:(0,B.jsxs)(O,{verticalSpacing:`xs`,children:[(0,B.jsx)(O.Thead,{children:(0,B.jsxs)(O.Tr,{children:[(0,B.jsx)(O.Th,{children:`State`}),(0,B.jsx)(O.Th,{children:`Rule`}),(0,B.jsx)(O.Th,{children:`Service`}),(0,B.jsx)(O.Th,{ta:`right`,children:`Value`}),(0,B.jsx)(O.Th,{children:`Fired`}),(0,B.jsx)(O.Th,{children:`Resolved`}),(0,B.jsx)(O.Th,{children:`Delivery`})]})}),(0,B.jsx)(O.Tbody,{children:q.map(e=>(0,B.jsxs)(O.Tr,{children:[(0,B.jsx)(O.Td,{children:(0,B.jsx)(m,{tone:De[e.state]??`neutral`,children:e.state.charAt(0).toUpperCase()+e.state.slice(1)})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,children:V.get(e.rule_id)?.name??e.rule_id})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,children:e.service})}),(0,B.jsx)(O.Td,{ta:`right`,children:(0,B.jsx)(_,{size:`sm`,ff:`monospace`,children:e.value===void 0?`—`:he(Z(V.get(e.rule_id)?.expression??``)[0],e.value)})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,ff:`monospace`,children:$(e.fired_at)})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`sm`,ff:`monospace`,children:$(e.resolved_at)})}),(0,B.jsx)(O.Td,{children:(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:e.last_delivery_status?`${e.last_delivery_status} · ${$(e.last_delivery_at)}`:`—`})})]},e.id))})]})})]}),s&&(0,B.jsx)(Ee,{rule:s.rule,onClose:A,onSave:ee}),d&&(0,B.jsxs)(x,{opened:!0,onClose:j,title:`Delete ${d.name}?`,confirmLabel:`Delete rule`,tone:`danger`,pending:F.isPending?`confirm`:null,error:F.error?.message,onConfirm:()=>F.mutate(d),children:[`The rule `,(0,B.jsx)(_,{span:!0,ff:`monospace`,children:d.name}),` and its alert history are removed. This cannot be undone.`]}),g&&(0,B.jsx)(r,{opened:!0,onClose:ie,closeButtonProps:{"aria-label":`Close test`},title:`Test · ${g.rule.name}`,children:g.error?(0,B.jsx)(b,{tone:`danger`,children:g.error}):g.result?g.result.results?.length?(0,B.jsx)(u,{gap:`xs`,children:g.result.results.map(e=>(0,B.jsxs)(u,{gap:2,children:[(0,B.jsxs)(o,{justify:`space-between`,children:[(0,B.jsx)(_,{size:`sm`,children:e.service}),e.error?(0,B.jsx)(_,{size:`xs`,c:`bad`,children:e.error}):e.no_data?(0,B.jsx)(m,{tone:`warning`,children:`No recent data`}):(0,B.jsx)(m,{tone:e.triggered?`danger`:`success`,children:e.triggered?`Would fire`:`Quiet`})]}),e.no_data?(0,B.jsx)(_,{size:`xs`,c:`dimmed`,children:`This service has sent no telemetry recently. Check its name.`}):(0,B.jsx)(_,{size:`xs`,c:`dimmed`,ff:`monospace`,children:Z(g.rule.expression).filter(t=>typeof e.env?.[t]==`number`).map(t=>`${t} ${he(t,e.env[t])}`).join(` · `)})]},e.service))}):(0,B.jsx)(f,{state:`empty`,empty:{title:`No services have data in the current window.`}}):(0,B.jsx)(f,{state:`loading`,loadingLabel:`Testing the rule`,rows:3})})]})}function Ne(e){let{id:t,created_at:n,updated_at:r,email_status:i,email_status_detail:a,email_status_at:o,...s}=e;return s}function Pe(){let e=C();return(0,B.jsx)(Me,{onExplore:t=>void e({to:`/explore`,search:ie({q:t,range:`1h`,tab:`query`})})})}export{Pe as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/auth-DWqIkMZS.js b/internal/ui/dist/assets/auth-DWqIkMZS.js deleted file mode 100644 index 800f93c15..000000000 --- a/internal/ui/dist/assets/auth-DWqIkMZS.js +++ /dev/null @@ -1 +0,0 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{Dt as r,Et as i,Ft as a,G as o,Nt as s,T as c,Tt as l,Xt as u,Zt as d,a as f,g as p,i as ee,j as m,k as h,m as g,n as _,o as te,qt as v,r as ne,s as y,w as b,x}from"./brand-D6fP-cLS.js";import{n as re}from"./useNavigate-B1zgPEUp.js";var S={root:`m_849cf0da`},C=t(),w={underline:`hover`},T=i(e=>{let{underline:t,className:n,unstyled:r,mod:i,...o}=a(`Anchor`,w,e);return(0,C.jsx)(m,{component:`a`,className:u({[S.root]:!r},n),...o,mod:[{underline:t},i],__staticSelector:`Anchor`,unstyled:r})});T.classes=S,T.displayName=`@mantine/core/Anchor`;var E={root:`m_b183c0a2`},D=d((e,{color:t})=>({root:{"--code-bg":t?v(t,e):void 0}})),O=r(e=>{let t=a(`Code`,null,e),{classNames:n,className:r,style:i,styles:o,unstyled:c,vars:u,color:d,block:f,mod:p,attributes:ee,...m}=t,h=s({name:`Code`,props:t,classes:E,className:r,style:i,classNames:n,styles:o,unstyled:c,attributes:ee,vars:u,varsResolver:D});return(0,C.jsx)(l,{component:f?`pre`:`code`,mod:[{block:f},p],...h(`root`),...m,dir:`ltr`})});O.classes=E,O.varsResolver=D,O.displayName=`@mantine/core/Code`;var k=n(e(),1),A=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,128l-72,72V56Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M221.66,122.34l-72-72A8,8,0,0,0,136,56v64H40a8,8,0,0,0,0,16h96v64a8,8,0,0,0,13.66,5.66l72-72A8,8,0,0,0,221.66,122.34ZM152,180.69V75.31L204.69,128Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M218.83,130.83l-72,72a4,4,0,0,1-5.66-5.66L206.34,132H40a4,4,0,0,1,0-8H206.34L141.17,58.83a4,4,0,0,1,5.66-5.66l72,72A4,4,0,0,1,218.83,130.83Z`}))]]),ie=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M256,136a12,12,0,0,1-12,12h-8v8a12,12,0,0,1-24,0v-8h-8a12,12,0,0,1,0-24h8v-8a12,12,0,0,1,24,0v8h8A12,12,0,0,1,256,136Zm-54.81,56.28a12,12,0,1,1-18.38,15.44C169.12,191.42,145,172,108,172c-28.89,0-55.46,12.68-74.81,35.72a12,12,0,0,1-18.38-15.44A124.08,124.08,0,0,1,63.5,156.53a72,72,0,1,1,89,0A124,124,0,0,1,201.19,192.28ZM108,148a48,48,0,1,0-48-48A48.05,48.05,0,0,0,108,148Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M168,100a60,60,0,1,1-60-60A60,60,0,0,1,168,100Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M256,136a8,8,0,0,1-8,8H232v16a8,8,0,0,1-16,0V144H200a8,8,0,0,1,0-16h16V112a8,8,0,0,1,16,0v16h16A8,8,0,0,1,256,136Zm-57.87,58.85a8,8,0,0,1-12.26,10.3C165.75,181.19,138.09,168,108,168s-57.75,13.19-77.87,37.15a8,8,0,0,1-12.25-10.3c14.94-17.78,33.52-30.41,54.17-37.17a68,68,0,1,1,71.9,0C164.6,164.44,183.18,177.07,198.13,194.85ZM108,152a52,52,0,1,0-52-52A52.06,52.06,0,0,0,108,152Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M256,136a8,8,0,0,1-8,8H232v16a8,8,0,0,1-16,0V144H200a8,8,0,0,1,0-16h16V112a8,8,0,0,1,16,0v16h16A8,8,0,0,1,256,136ZM144,157.68a68,68,0,1,0-71.9,0c-20.65,6.76-39.23,19.39-54.17,37.17A8,8,0,0,0,24,208H192a8,8,0,0,0,6.13-13.15C183.18,177.07,164.6,164.44,144,157.68Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M254,136a6,6,0,0,1-6,6H230v18a6,6,0,0,1-12,0V142H200a6,6,0,0,1,0-12h18V112a6,6,0,0,1,12,0v18h18A6,6,0,0,1,254,136Zm-57.41,60.14a6,6,0,1,1-9.18,7.72C166.9,179.45,138.69,166,108,166s-58.89,13.45-79.41,37.86a6,6,0,0,1-9.18-7.72C35.14,177.41,55,164.48,77,158.25a66,66,0,1,1,62,0C161,164.48,180.86,177.41,196.59,196.14ZM108,154a54,54,0,1,0-54-54A54.06,54.06,0,0,0,108,154Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M256,136a8,8,0,0,1-8,8H232v16a8,8,0,0,1-16,0V144H200a8,8,0,0,1,0-16h16V112a8,8,0,0,1,16,0v16h16A8,8,0,0,1,256,136Zm-57.87,58.85a8,8,0,0,1-12.26,10.3C165.75,181.19,138.09,168,108,168s-57.75,13.19-77.87,37.15a8,8,0,0,1-12.25-10.3c14.94-17.78,33.52-30.41,54.17-37.17a68,68,0,1,1,71.9,0C164.6,164.44,183.18,177.07,198.13,194.85ZM108,152a52,52,0,1,0-52-52A52.06,52.06,0,0,0,108,152Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M252,136a4,4,0,0,1-4,4H228v20a4,4,0,0,1-8,0V140H200a4,4,0,0,1,0-8h20V112a4,4,0,0,1,8,0v20h20A4,4,0,0,1,252,136Zm-56.94,61.43a4,4,0,0,1-6.12,5.14C168,177.7,139.3,164,108,164s-60,13.7-80.94,38.57a4,4,0,1,1-6.12-5.14c16.71-19.9,38.13-33.13,61.89-38.59a64,64,0,1,1,50.34,0C156.93,164.3,178.35,177.53,195.06,197.43ZM108,156a56,56,0,1,0-56-56A56.06,56.06,0,0,0,108,156Z`}))]]),j=k.forwardRef((e,t)=>k.createElement(x,{ref:t,...e,weights:A}));j.displayName=`ArrowRightIcon`;var ae=j,M=k.forwardRef((e,t)=>k.createElement(x,{ref:t,...e,weights:ie}));M.displayName=`UserPlusIcon`;var oe=M,N=class extends Error{status;problems;code;constructor(e,t,n=[],r=``){super(e),this.status=t,this.problems=n,this.code=r}},P=`pitot:unauthorized`,F=`/settings/ingest`;function I(){let e=new URLSearchParams(window.location.search).get(`return_to`);if(!e)return``;let t=new URL(e,window.location.origin);return t.origin!==window.location.origin||t.pathname!==`/api/auth/oauth/authorize`&&t.pathname!==F?``:`${t.pathname}${t.search}`}function se(){return I()||(window.location.pathname===F?F:``)}function ce(e){return!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||e.id===``?`none`:`user`}function L(){window.dispatchEvent(new Event(P))}async function R(e,t={}){let n=new Headers(t.headers);n.set(`Pitot-Request`,`1`);let r=await fetch(e,{...t,headers:n,credentials:`same-origin`});if(r.status===401&&L(),r.status===403){let e=await r.clone().json().catch(()=>({}));throw new N(e.message??`You do not have permission to perform this action.`,r.status,[],e.code??``)}return r}async function z(){let e=await R(`/api/auth/logout`,{method:`POST`});if(!e.ok&&e.status!==401)throw Error(`Sign-out failed — your session is still active.`);e.status!==401&&L(),window.location.assign(`/`)}var B={home:`https://pitot.dev/docs`,ingest:`https://pitot.dev/docs/get-started/send-telemetry`,connect:`https://pitot.dev/docs/guides/mcp`,authentication:`https://pitot.dev/docs/concepts/authentication`},V=(0,k.createContext)(null);function H(){let e=(0,k.useContext)(V);if(!e)throw Error(`Pitot runtime status is unavailable`);return e}var le=(0,k.createContext)(null);function ue(){let e=(0,k.useContext)(le);if(!e)throw Error(`Pitot viewer is unavailable`);return e}function de(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||t.id===``||t.status!==`active`&&t.status!==`suspended`?null:{id:t.id,email:typeof t.email==`string`?t.email:``,display_name:typeof t.display_name==`string`?t.display_name:``,status:t.status,role:typeof t.role==`string`?t.role:``}}async function U(e,t){let n=await fetch(e,{method:t===void 0?`GET`:`POST`,headers:t===void 0?void 0:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t),credentials:`same-origin`}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.message??`Request failed (${n.status})`);return r}function fe(){return typeof window>`u`?``:new URLSearchParams(window.location.search).get(`setup_token`)??``}function pe(){return typeof window>`u`?``:new URLSearchParams(window.location.search).get(`login_token`)??``}function W({children:e}){let t=re(),[n,r]=(0,k.useState)(null),[i,a]=(0,k.useState)(!1),[s,l]=(0,k.useState)(`none`),[u,d]=(0,k.useState)(null),[v,x]=(0,k.useState)(!1),[S,w]=(0,k.useState)(``),[E,D]=(0,k.useState)(``),[A,ie]=(0,k.useState)(fe),[j,M]=(0,k.useState)(pe),[N,F]=(0,k.useState)(``),[L,R]=(0,k.useState)(!1),[z,H]=(0,k.useState)(0),[ue,W]=(0,k.useState)(()=>Date.now()),[me,G]=(0,k.useState)(null),[K,q]=(0,k.useState)(!1),[J,Y]=(0,k.useState)(``),[X,he]=(0,k.useState)(null),[ge,_e]=(0,k.useState)(!1),ve=(0,k.useRef)(null),Z=I(),Q=s===`user`;async function ye(){let e=await fetch(`/api/auth/me`,{credentials:`same-origin`});if(!e.ok){l(`none`),d(null);return}let t=await e.json().catch(()=>null);l(ce(t)),d(de(t))}async function $(){try{let e=await fetch(`/api/auth/me`,{credentials:`same-origin`});if(!e.ok)return;d(de(await e.json().catch(()=>null)))}catch{}}(0,k.useEffect)(()=>{let e=new URL(window.location.href);(e.searchParams.has(`setup_token`)||e.searchParams.has(`login_token`))&&(e.searchParams.delete(`setup_token`),e.searchParams.delete(`login_token`),t({href:e.pathname+e.search+e.hash,replace:!0}))},[t]),(0,k.useEffect)(()=>{U(`/api/auth/status`).then(r).catch(e=>Y(String(e))).finally(()=>a(!0)),ye().catch(()=>l(`none`)).finally(()=>x(!0));let e=()=>{l(`none`),d(null)};return window.addEventListener(P,e),()=>window.removeEventListener(P,e)},[]),(0,k.useEffect)(()=>{v&&s===`none`&&j&&(q(!0),Y(``),U(`/api/auth/link/verify`,{token:j}).then(()=>{l(`user`),$()}).catch(e=>Y(e instanceof Error?e.message:String(e))).finally(()=>{M(``),q(!1)}))},[j,v,s]),(0,k.useEffect)(()=>{Q&&v&&Z&&window.location.replace(Z)},[Q,Z,v]),(0,k.useEffect)(()=>{if(z<=Date.now())return;let e=setInterval(()=>{W(Date.now()),Date.now()>=z&&clearInterval(e)},1e3);return()=>clearInterval(e)},[z]);let be=Math.max(0,Math.ceil((z-ue)/1e3));async function xe(e){try{await navigator.clipboard.writeText(e),_e(!0)}catch{Y(`Clipboard access failed. Select and copy the token manually.`)}}if(X?.ingest_token)return(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),size:`lg`,children:(0,C.jsxs)(c,{gap:`lg`,children:[(0,C.jsx)(p,{eyebrow:`Setup complete`,title:`Save your ingest token`}),(0,C.jsx)(m,{c:`dimmed`,children:`Pitot shows this token once. Store it with your collector secrets before continuing.`}),(0,C.jsxs)(c,{gap:`xs`,children:[(0,C.jsx)(m,{size:`sm`,fw:600,children:`OTLP endpoint`}),(0,C.jsx)(O,{block:!0,children:X.suggested_endpoint??window.location.origin})]}),(0,C.jsxs)(c,{gap:`xs`,children:[(0,C.jsx)(m,{size:`sm`,fw:600,children:`Header`}),(0,C.jsxs)(O,{block:!0,children:[X.ingest_header_name??`Authorization`,`: Bearer `,X.ingest_token]})]}),J&&(0,C.jsx)(y,{tone:`danger`,children:J}),(0,C.jsxs)(o,{grow:!0,align:`stretch`,children:[(0,C.jsx)(h,{variant:`light`,radius:`md`,leftSection:ge?(0,C.jsx)(ee,{size:16,weight:`bold`}):(0,C.jsx)(ne,{size:16}),onClick:()=>void xe(`${X.ingest_header_name??`Authorization`}: Bearer ${X.ingest_token}`),children:ge?`Copied`:`Copy header`}),(0,C.jsx)(h,{radius:`md`,rightSection:(0,C.jsx)(ae,{size:16,weight:`bold`}),onClick:()=>{l(`user`),he(null),$()},children:`Continue to Pitot`})]}),(0,C.jsx)(h,{variant:`subtle`,size:`compact-xs`,onClick:()=>void xe(X.ingest_token??``),children:`Copy token only`})]})});if(!v||!i||j)return(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsx)(f,{state:`loading`,loadingLabel:`Loading sign-in`,rows:4})});if(!n)return(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsxs)(c,{gap:`lg`,children:[(0,C.jsx)(p,{title:`Pitot is unavailable`}),(0,C.jsx)(y,{tone:`danger`,children:J||`Authentication status could not be loaded.`})]})});if(Q&&Z)return null;if(Q)return(0,C.jsx)(V.Provider,{value:n,children:(0,C.jsx)(le.Provider,{value:u??{id:``,email:S,display_name:E,status:`active`,role:``},children:e})});if(n&&!n.setup_required&&n.auth_mode===`oidc`){let e=se(),t=e?`/api/auth/oidc/start?return_to=${encodeURIComponent(e)}`:`/api/auth/oidc/start`;return(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsxs)(c,{gap:28,children:[(0,C.jsx)(p,{title:`Sign in to Pitot`,description:`Use your organization’s identity provider to continue.`}),J&&(0,C.jsx)(y,{tone:`danger`,children:J}),(0,C.jsx)(h,{component:`a`,href:t,size:`md`,radius:`md`,rightSection:(0,C.jsx)(ae,{size:17,weight:`bold`}),children:`Continue with SSO`})]})})}async function Se(){if(!(K||!n?.smtp_configured||L&&be>0)){q(!0),G(L?`resend`:`send`),Y(``);try{await U(`/api/auth/code/send`,{email:S}),R(!0),F(``),H(Date.now()+3e4),W(Date.now())}catch(e){Y(e instanceof Error?e.message:String(e))}finally{q(!1),G(null)}}}async function Ce(e){if(!(K||e.length!==6)){q(!0),G(`verify`),Y(``);try{await U(`/api/auth/code/verify`,{email:S,code:e}),l(`user`),R(!1),F(``),H(0),$()}catch(e){F(``),Y(e instanceof Error?e.message:String(e))}finally{q(!1),G(null)}}}function we(){R(!1),F(``),H(0),Y(``)}async function Te(e){e.preventDefault(),q(!0),Y(``);try{let e=await U(`/api/auth/setup`,{email:S,display_name:E,setup_token:A});e.ingest_token?he(e):(l(`user`),$())}catch(e){Y(e instanceof Error?e.message:String(e))}finally{q(!1)}}return n.setup_required?(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsxs)(c,{gap:28,children:[(0,C.jsx)(p,{eyebrow:`One-time setup`,title:`Create the first admin`,description:`Use the one-time token printed by the Pitot process.`}),(0,C.jsx)(`form`,{onSubmit:Te,children:(0,C.jsxs)(c,{gap:`md`,children:[(0,C.jsx)(b,{label:`Email`,placeholder:`you@company.com`,type:`email`,required:!0,value:S,onChange:e=>w(e.currentTarget.value),autoFocus:!0}),(0,C.jsx)(b,{label:`Display name`,placeholder:`Your display name`,value:E,onChange:e=>D(e.currentTarget.value)}),(0,C.jsx)(b,{label:`Setup token`,placeholder:`from the setup URL printed at startup`,required:!0,value:A,onChange:e=>ie(e.currentTarget.value),autoComplete:`one-time-code`}),J&&(0,C.jsx)(y,{tone:`danger`,children:J}),(0,C.jsx)(h,{type:`submit`,loading:K,leftSection:(0,C.jsx)(oe,{size:17,weight:`bold`}),children:`Create admin`})]})})]})}):(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsx)(`fieldset`,{disabled:!n.smtp_configured,style:{border:0,padding:0,margin:0,minWidth:0},children:(0,C.jsx)(te,{step:L?`code`:`email`,title:`Sign in to Pitot`,description:n.smtp_configured?n.self_signup?`We'll email you a 6-digit code. New here? This creates your account.`:`We'll email you a 6-digit code.`:`Email delivery is not configured. Ask the operator to run pitot login-link with your email address.`,email:S,onEmailChange:w,inputRef:ve,onSendCode:()=>{ve.current?.reportValidity()&&Se()},code:N,onCodeChange:F,onVerify:e=>void Ce(e),onChangeEmail:we,onResend:()=>void Se(),resendIn:be,pending:me,error:J||void 0,stepLabels:!1,expiresInMinutes:5,codeNote:(0,C.jsx)(m,{size:`xs`,c:`dimmed`,children:`Codes expire in 5 minutes. Check your spam folder if the email hasn’t arrived.`}),labels:{continue:`Continue with email`,verify:`Verify code`,resend:`Resend code`,changeEmail:`Change email`,codeSent:()=>(0,C.jsxs)(C.Fragment,{children:[`Enter the code sent to `,(0,C.jsx)(m,{span:!0,inherit:!0,fw:700,children:S}),`.`]}),resendIn:e=>`Resend in ${e}`}})})})}export{R as a,O as c,B as i,T as l,H as n,z as o,ue as r,N as s,W as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/auth-DcVParCH.js b/internal/ui/dist/assets/auth-DcVParCH.js new file mode 100644 index 000000000..1a26b1113 --- /dev/null +++ b/internal/ui/dist/assets/auth-DcVParCH.js @@ -0,0 +1 @@ +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{Dt as r,Et as i,Ft as a,G as o,Nt as s,T as c,Tt as l,Xt as u,Zt as d,a as f,g as p,i as ee,j as m,k as h,m as g,n as _,o as te,qt as v,r as ne,s as y,w as b,x}from"./brand-D6fP-cLS.js";import{n as re}from"./useNavigate-B1zgPEUp.js";var S={root:`m_849cf0da`},C=t(),w={underline:`hover`},T=i(e=>{let{underline:t,className:n,unstyled:r,mod:i,...o}=a(`Anchor`,w,e);return(0,C.jsx)(m,{component:`a`,className:u({[S.root]:!r},n),...o,mod:[{underline:t},i],__staticSelector:`Anchor`,unstyled:r})});T.classes=S,T.displayName=`@mantine/core/Anchor`;var E={root:`m_b183c0a2`},D=d((e,{color:t})=>({root:{"--code-bg":t?v(t,e):void 0}})),O=r(e=>{let t=a(`Code`,null,e),{classNames:n,className:r,style:i,styles:o,unstyled:c,vars:u,color:d,block:f,mod:p,attributes:ee,...m}=t,h=s({name:`Code`,props:t,classes:E,className:r,style:i,classNames:n,styles:o,unstyled:c,attributes:ee,vars:u,varsResolver:D});return(0,C.jsx)(l,{component:f?`pre`:`code`,mod:[{block:f},p],...h(`root`),...m,dir:`ltr`})});O.classes=E,O.varsResolver=D,O.displayName=`@mantine/core/Code`;var k=n(e(),1),A=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,128l-72,72V56Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M221.66,122.34l-72-72A8,8,0,0,0,136,56v64H40a8,8,0,0,0,0,16h96v64a8,8,0,0,0,13.66,5.66l72-72A8,8,0,0,0,221.66,122.34ZM152,180.69V75.31L204.69,128Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M218.83,130.83l-72,72a4,4,0,0,1-5.66-5.66L206.34,132H40a4,4,0,0,1,0-8H206.34L141.17,58.83a4,4,0,0,1,5.66-5.66l72,72A4,4,0,0,1,218.83,130.83Z`}))]]),ie=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M256,136a12,12,0,0,1-12,12h-8v8a12,12,0,0,1-24,0v-8h-8a12,12,0,0,1,0-24h8v-8a12,12,0,0,1,24,0v8h8A12,12,0,0,1,256,136Zm-54.81,56.28a12,12,0,1,1-18.38,15.44C169.12,191.42,145,172,108,172c-28.89,0-55.46,12.68-74.81,35.72a12,12,0,0,1-18.38-15.44A124.08,124.08,0,0,1,63.5,156.53a72,72,0,1,1,89,0A124,124,0,0,1,201.19,192.28ZM108,148a48,48,0,1,0-48-48A48.05,48.05,0,0,0,108,148Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M168,100a60,60,0,1,1-60-60A60,60,0,0,1,168,100Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M256,136a8,8,0,0,1-8,8H232v16a8,8,0,0,1-16,0V144H200a8,8,0,0,1,0-16h16V112a8,8,0,0,1,16,0v16h16A8,8,0,0,1,256,136Zm-57.87,58.85a8,8,0,0,1-12.26,10.3C165.75,181.19,138.09,168,108,168s-57.75,13.19-77.87,37.15a8,8,0,0,1-12.25-10.3c14.94-17.78,33.52-30.41,54.17-37.17a68,68,0,1,1,71.9,0C164.6,164.44,183.18,177.07,198.13,194.85ZM108,152a52,52,0,1,0-52-52A52.06,52.06,0,0,0,108,152Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M256,136a8,8,0,0,1-8,8H232v16a8,8,0,0,1-16,0V144H200a8,8,0,0,1,0-16h16V112a8,8,0,0,1,16,0v16h16A8,8,0,0,1,256,136ZM144,157.68a68,68,0,1,0-71.9,0c-20.65,6.76-39.23,19.39-54.17,37.17A8,8,0,0,0,24,208H192a8,8,0,0,0,6.13-13.15C183.18,177.07,164.6,164.44,144,157.68Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M254,136a6,6,0,0,1-6,6H230v18a6,6,0,0,1-12,0V142H200a6,6,0,0,1,0-12h18V112a6,6,0,0,1,12,0v18h18A6,6,0,0,1,254,136Zm-57.41,60.14a6,6,0,1,1-9.18,7.72C166.9,179.45,138.69,166,108,166s-58.89,13.45-79.41,37.86a6,6,0,0,1-9.18-7.72C35.14,177.41,55,164.48,77,158.25a66,66,0,1,1,62,0C161,164.48,180.86,177.41,196.59,196.14ZM108,154a54,54,0,1,0-54-54A54.06,54.06,0,0,0,108,154Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M256,136a8,8,0,0,1-8,8H232v16a8,8,0,0,1-16,0V144H200a8,8,0,0,1,0-16h16V112a8,8,0,0,1,16,0v16h16A8,8,0,0,1,256,136Zm-57.87,58.85a8,8,0,0,1-12.26,10.3C165.75,181.19,138.09,168,108,168s-57.75,13.19-77.87,37.15a8,8,0,0,1-12.25-10.3c14.94-17.78,33.52-30.41,54.17-37.17a68,68,0,1,1,71.9,0C164.6,164.44,183.18,177.07,198.13,194.85ZM108,152a52,52,0,1,0-52-52A52.06,52.06,0,0,0,108,152Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M252,136a4,4,0,0,1-4,4H228v20a4,4,0,0,1-8,0V140H200a4,4,0,0,1,0-8h20V112a4,4,0,0,1,8,0v20h20A4,4,0,0,1,252,136Zm-56.94,61.43a4,4,0,0,1-6.12,5.14C168,177.7,139.3,164,108,164s-60,13.7-80.94,38.57a4,4,0,1,1-6.12-5.14c16.71-19.9,38.13-33.13,61.89-38.59a64,64,0,1,1,50.34,0C156.93,164.3,178.35,177.53,195.06,197.43ZM108,156a56,56,0,1,0-56-56A56.06,56.06,0,0,0,108,156Z`}))]]),j=k.forwardRef((e,t)=>k.createElement(x,{ref:t,...e,weights:A}));j.displayName=`ArrowRightIcon`;var ae=j,M=k.forwardRef((e,t)=>k.createElement(x,{ref:t,...e,weights:ie}));M.displayName=`UserPlusIcon`;var oe=M,N=class extends Error{status;problems;code;constructor(e,t,n=[],r=``){super(e),this.status=t,this.problems=n,this.code=r,this.code===`invalid_fanql`&&(this.code=`invalid_pitotql`)}},P=`pitot:unauthorized`,F=`/settings/ingest`;function I(){let e=new URLSearchParams(window.location.search).get(`return_to`);if(!e)return``;let t=new URL(e,window.location.origin);return t.origin!==window.location.origin||t.pathname!==`/api/auth/oauth/authorize`&&t.pathname!==F?``:`${t.pathname}${t.search}`}function se(){return I()||(window.location.pathname===F?F:``)}function ce(e){return!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||e.id===``?`none`:`user`}function L(){window.dispatchEvent(new Event(P))}async function R(e,t={}){let n=new Headers(t.headers);n.set(`Pitot-Request`,`1`);let r=await fetch(e,{...t,headers:n,credentials:`same-origin`});if(r.status===401&&L(),r.status===403){let e=await r.clone().json().catch(()=>({}));throw new N(e.message??`You do not have permission to perform this action.`,r.status,[],e.code??``)}return r}async function z(){let e=await R(`/api/auth/logout`,{method:`POST`});if(!e.ok&&e.status!==401)throw Error(`Sign-out failed — your session is still active.`);e.status!==401&&L(),window.location.assign(`/`)}var B={home:`https://pitot.dev/docs`,ingest:`https://pitot.dev/docs/get-started/send-telemetry`,connect:`https://pitot.dev/docs/guides/mcp`,authentication:`https://pitot.dev/docs/concepts/authentication`},V=(0,k.createContext)(null);function H(){let e=(0,k.useContext)(V);if(!e)throw Error(`Pitot runtime status is unavailable`);return e}var le=(0,k.createContext)(null);function ue(){let e=(0,k.useContext)(le);if(!e)throw Error(`Pitot viewer is unavailable`);return e}function de(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||t.id===``||t.status!==`active`&&t.status!==`suspended`?null:{id:t.id,email:typeof t.email==`string`?t.email:``,display_name:typeof t.display_name==`string`?t.display_name:``,status:t.status,role:typeof t.role==`string`?t.role:``}}async function U(e,t){let n=await fetch(e,{method:t===void 0?`GET`:`POST`,headers:t===void 0?void 0:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t),credentials:`same-origin`}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.message??`Request failed (${n.status})`);return r}function fe(){return typeof window>`u`?``:new URLSearchParams(window.location.search).get(`setup_token`)??``}function pe(){return typeof window>`u`?``:new URLSearchParams(window.location.search).get(`login_token`)??``}function W({children:e}){let t=re(),[n,r]=(0,k.useState)(null),[i,a]=(0,k.useState)(!1),[s,l]=(0,k.useState)(`none`),[u,d]=(0,k.useState)(null),[v,x]=(0,k.useState)(!1),[S,w]=(0,k.useState)(``),[E,D]=(0,k.useState)(``),[A,ie]=(0,k.useState)(fe),[j,M]=(0,k.useState)(pe),[N,F]=(0,k.useState)(``),[L,R]=(0,k.useState)(!1),[z,H]=(0,k.useState)(0),[ue,W]=(0,k.useState)(()=>Date.now()),[me,G]=(0,k.useState)(null),[K,q]=(0,k.useState)(!1),[J,Y]=(0,k.useState)(``),[X,he]=(0,k.useState)(null),[ge,_e]=(0,k.useState)(!1),ve=(0,k.useRef)(null),Z=I(),Q=s===`user`;async function ye(){let e=await fetch(`/api/auth/me`,{credentials:`same-origin`});if(!e.ok){l(`none`),d(null);return}let t=await e.json().catch(()=>null);l(ce(t)),d(de(t))}async function $(){try{let e=await fetch(`/api/auth/me`,{credentials:`same-origin`});if(!e.ok)return;d(de(await e.json().catch(()=>null)))}catch{}}(0,k.useEffect)(()=>{let e=new URL(window.location.href);(e.searchParams.has(`setup_token`)||e.searchParams.has(`login_token`))&&(e.searchParams.delete(`setup_token`),e.searchParams.delete(`login_token`),t({href:e.pathname+e.search+e.hash,replace:!0}))},[t]),(0,k.useEffect)(()=>{U(`/api/auth/status`).then(r).catch(e=>Y(String(e))).finally(()=>a(!0)),ye().catch(()=>l(`none`)).finally(()=>x(!0));let e=()=>{l(`none`),d(null)};return window.addEventListener(P,e),()=>window.removeEventListener(P,e)},[]),(0,k.useEffect)(()=>{v&&s===`none`&&j&&(q(!0),Y(``),U(`/api/auth/link/verify`,{token:j}).then(()=>{l(`user`),$()}).catch(e=>Y(e instanceof Error?e.message:String(e))).finally(()=>{M(``),q(!1)}))},[j,v,s]),(0,k.useEffect)(()=>{Q&&v&&Z&&window.location.replace(Z)},[Q,Z,v]),(0,k.useEffect)(()=>{if(z<=Date.now())return;let e=setInterval(()=>{W(Date.now()),Date.now()>=z&&clearInterval(e)},1e3);return()=>clearInterval(e)},[z]);let be=Math.max(0,Math.ceil((z-ue)/1e3));async function xe(e){try{await navigator.clipboard.writeText(e),_e(!0)}catch{Y(`Clipboard access failed. Select and copy the token manually.`)}}if(X?.ingest_token)return(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),size:`lg`,children:(0,C.jsxs)(c,{gap:`lg`,children:[(0,C.jsx)(p,{eyebrow:`Setup complete`,title:`Save your ingest token`}),(0,C.jsx)(m,{c:`dimmed`,children:`Pitot shows this token once. Store it with your collector secrets before continuing.`}),(0,C.jsxs)(c,{gap:`xs`,children:[(0,C.jsx)(m,{size:`sm`,fw:600,children:`OTLP endpoint`}),(0,C.jsx)(O,{block:!0,children:X.suggested_endpoint??window.location.origin})]}),(0,C.jsxs)(c,{gap:`xs`,children:[(0,C.jsx)(m,{size:`sm`,fw:600,children:`Header`}),(0,C.jsxs)(O,{block:!0,children:[X.ingest_header_name??`Authorization`,`: Bearer `,X.ingest_token]})]}),J&&(0,C.jsx)(y,{tone:`danger`,children:J}),(0,C.jsxs)(o,{grow:!0,align:`stretch`,children:[(0,C.jsx)(h,{variant:`light`,radius:`md`,leftSection:ge?(0,C.jsx)(ee,{size:16,weight:`bold`}):(0,C.jsx)(ne,{size:16}),onClick:()=>void xe(`${X.ingest_header_name??`Authorization`}: Bearer ${X.ingest_token}`),children:ge?`Copied`:`Copy header`}),(0,C.jsx)(h,{radius:`md`,rightSection:(0,C.jsx)(ae,{size:16,weight:`bold`}),onClick:()=>{l(`user`),he(null),$()},children:`Continue to Pitot`})]}),(0,C.jsx)(h,{variant:`subtle`,size:`compact-xs`,onClick:()=>void xe(X.ingest_token??``),children:`Copy token only`})]})});if(!v||!i||j)return(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsx)(f,{state:`loading`,loadingLabel:`Loading sign-in`,rows:4})});if(!n)return(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsxs)(c,{gap:`lg`,children:[(0,C.jsx)(p,{title:`Pitot is unavailable`}),(0,C.jsx)(y,{tone:`danger`,children:J||`Authentication status could not be loaded.`})]})});if(Q&&Z)return null;if(Q)return(0,C.jsx)(V.Provider,{value:n,children:(0,C.jsx)(le.Provider,{value:u??{id:``,email:S,display_name:E,status:`active`,role:``},children:e})});if(n&&!n.setup_required&&n.auth_mode===`oidc`){let e=se(),t=e?`/api/auth/oidc/start?return_to=${encodeURIComponent(e)}`:`/api/auth/oidc/start`;return(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsxs)(c,{gap:28,children:[(0,C.jsx)(p,{title:`Sign in to Pitot`,description:`Use your organization’s identity provider to continue.`}),J&&(0,C.jsx)(y,{tone:`danger`,children:J}),(0,C.jsx)(h,{component:`a`,href:t,size:`md`,radius:`md`,rightSection:(0,C.jsx)(ae,{size:17,weight:`bold`}),children:`Continue with SSO`})]})})}async function Se(){if(!(K||!n?.smtp_configured||L&&be>0)){q(!0),G(L?`resend`:`send`),Y(``);try{await U(`/api/auth/code/send`,{email:S}),R(!0),F(``),H(Date.now()+3e4),W(Date.now())}catch(e){Y(e instanceof Error?e.message:String(e))}finally{q(!1),G(null)}}}async function Ce(e){if(!(K||e.length!==6)){q(!0),G(`verify`),Y(``);try{await U(`/api/auth/code/verify`,{email:S,code:e}),l(`user`),R(!1),F(``),H(0),$()}catch(e){F(``),Y(e instanceof Error?e.message:String(e))}finally{q(!1),G(null)}}}function we(){R(!1),F(``),H(0),Y(``)}async function Te(e){e.preventDefault(),q(!0),Y(``);try{let e=await U(`/api/auth/setup`,{email:S,display_name:E,setup_token:A});e.ingest_token?he(e):(l(`user`),$())}catch(e){Y(e instanceof Error?e.message:String(e))}finally{q(!1)}}return n.setup_required?(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsxs)(c,{gap:28,children:[(0,C.jsx)(p,{eyebrow:`One-time setup`,title:`Create the first admin`,description:`Use the one-time token printed by the Pitot process.`}),(0,C.jsx)(`form`,{onSubmit:Te,children:(0,C.jsxs)(c,{gap:`md`,children:[(0,C.jsx)(b,{label:`Email`,placeholder:`you@company.com`,type:`email`,required:!0,value:S,onChange:e=>w(e.currentTarget.value),autoFocus:!0}),(0,C.jsx)(b,{label:`Display name`,placeholder:`Your display name`,value:E,onChange:e=>D(e.currentTarget.value)}),(0,C.jsx)(b,{label:`Setup token`,placeholder:`from the setup URL printed at startup`,required:!0,value:A,onChange:e=>ie(e.currentTarget.value),autoComplete:`one-time-code`}),J&&(0,C.jsx)(y,{tone:`danger`,children:J}),(0,C.jsx)(h,{type:`submit`,loading:K,leftSection:(0,C.jsx)(oe,{size:17,weight:`bold`}),children:`Create admin`})]})})]})}):(0,C.jsx)(g,{surface:`plain`,brand:(0,C.jsx)(_,{}),footer:(0,C.jsx)(T,{href:B.home,size:`xs`,target:`_blank`,rel:`noopener noreferrer`,children:`Docs`}),children:(0,C.jsx)(`fieldset`,{disabled:!n.smtp_configured,style:{border:0,padding:0,margin:0,minWidth:0},children:(0,C.jsx)(te,{step:L?`code`:`email`,title:`Sign in to Pitot`,description:n.smtp_configured?n.self_signup?`We'll email you a 6-digit code. New here? This creates your account.`:`We'll email you a 6-digit code.`:`Email delivery is not configured. Ask the operator to run pitot login-link with your email address.`,email:S,onEmailChange:w,inputRef:ve,onSendCode:()=>{ve.current?.reportValidity()&&Se()},code:N,onCodeChange:F,onVerify:e=>void Ce(e),onChangeEmail:we,onResend:()=>void Se(),resendIn:be,pending:me,error:J||void 0,stepLabels:!1,expiresInMinutes:5,codeNote:(0,C.jsx)(m,{size:`xs`,c:`dimmed`,children:`Codes expire in 5 minutes. Check your spam folder if the email hasn’t arrived.`}),labels:{continue:`Continue with email`,verify:`Verify code`,resend:`Resend code`,changeEmail:`Change email`,codeSent:()=>(0,C.jsxs)(C.Fragment,{children:[`Enter the code sent to `,(0,C.jsx)(m,{span:!0,inherit:!0,fw:700,children:S}),`.`]}),resendIn:e=>`Resend in ${e}`}})})})}export{R as a,O as c,B as i,T as l,H as n,z as o,ue as r,N as s,W as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat-C1c_TZwI.js b/internal/ui/dist/assets/chat-C1c_TZwI.js new file mode 100644 index 000000000..7d193e657 --- /dev/null +++ b/internal/ui/dist/assets/chat-C1c_TZwI.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-app-frame-a5HZdAse.js","assets/useRouter-ByJ6_rwb.js","assets/brand-D6fP-cLS.js","assets/auth-DcVParCH.js","assets/useNavigate-B1zgPEUp.js","assets/index-D7FG-NN3.js","assets/preload-helper-DJZNfKNH.js","assets/lazyRouteComponent-DiWTNBZT.js","assets/theme-DXTVNXHm.js","assets/search-P7VEnlsD.js","assets/noop-mXPS5vjY.js","assets/format-BZjbsxwM.js","assets/useQuery-BLTYSIvG.js","assets/search-pvW8SUhM.js","assets/index-CzwgFH1g.css"])))=>i.map(i=>d[i]); +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{$ as r,Ct as i,Dt as a,Ft as o,G as s,Nt as c,S as l,T as u,Tt as d,Zt as f,a as p,f as m,g as h,i as g,j as _,k as v,n as y,p as b,pn as x,q as S,r as C,s as w,tt as T,x as E}from"./brand-D6fP-cLS.js";import{n as D,t as ee}from"./preload-helper-DJZNfKNH.js";import{t as O}from"./Table-D4ZwUno3.js";import{a as k,n as A,t as j}from"./format-BZjbsxwM.js";import{t as M}from"./Textarea-r3wuKNbO.js";import{n as N,r as P,t as F}from"./lib-BLIvzI-_.js";import{C as I,D as L,E as te,S as ne,T as re,b as ie,ct as R,w as ae,x as z,y as oe}from"./index-D7FG-NN3.js";import{t as se}from"./dashboard-change-chips-BJ-GZE9U.js";var B={root:`m_7485cace`},V=t(),ce={strategy:`block`},H=f((e,{size:t,fluid:n})=>({root:{"--container-size":n?void 0:x(t,`container-size`)}})),U=a(e=>{let t=o(`Container`,ce,e),{classNames:n,className:r,style:i,styles:a,unstyled:s,vars:l,fluid:u,mod:f,attributes:p,strategy:m,...h}=t,g=c({name:`Container`,classes:B,props:t,className:r,style:i,classNames:n,styles:a,unstyled:s,attributes:p,vars:l,varsResolver:H});return(0,V.jsx)(d,{mod:[{fluid:u,strategy:m},f],...g(`root`),...h})});U.classes=B,U.varsResolver=H,U.displayName=`@mantine/core/Container`;var W={root:`m_d08caa0`},G=a(e=>{let t=o(`Typography`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:s,attributes:l,...u}=t,f=c({name:`Typography`,classes:W,props:t,className:r,style:i,classNames:n,styles:a,unstyled:s,attributes:l});return(0,V.jsx)(d,{...f(`root`),...u})});G.classes=W,G.displayName=`@mantine/core/Typography`;var K=n(e(),1),le=new Map([[`bold`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M208.49,152.49l-72,72a12,12,0,0,1-17,0l-72-72a12,12,0,0,1,17-17L116,187V40a12,12,0,0,1,24,0V187l51.51-51.52a12,12,0,0,1,17,17Z`}))],[`duotone`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M200,144l-72,72L56,144Z`,opacity:`0.2`}),K.createElement(`path`,{d:`M207.39,140.94A8,8,0,0,0,200,136H136V40a8,8,0,0,0-16,0v96H56a8,8,0,0,0-5.66,13.66l72,72a8,8,0,0,0,11.32,0l72-72A8,8,0,0,0,207.39,140.94ZM128,204.69,75.31,152H180.69Z`}))],[`fill`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72A8,8,0,0,1,56,136h64V40a8,8,0,0,1,16,0v96h64a8,8,0,0,1,5.66,13.66Z`}))],[`light`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M204.24,148.24l-72,72a6,6,0,0,1-8.48,0l-72-72a6,6,0,0,1,8.48-8.48L122,201.51V40a6,6,0,0,1,12,0V201.51l61.76-61.75a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72a8,8,0,0,1,11.32-11.32L120,196.69V40a8,8,0,0,1,16,0V196.69l58.34-58.35a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M202.83,146.83l-72,72a4,4,0,0,1-5.66,0l-72-72a4,4,0,0,1,5.66-5.66L124,206.34V40a4,4,0,0,1,8,0V206.34l65.17-65.17a4,4,0,0,1,5.66,5.66Z`}))]]),ue=new Map([[`bold`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z`}))],[`duotone`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M176,128,96,208V48Z`,opacity:`0.2`}),K.createElement(`path`,{d:`M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z`}))],[`fill`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`light`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z`}))],[`regular`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`thin`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z`}))]]),de=new Map([[`bold`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M230.14,25.86a20,20,0,0,0-19.57-5.11l-.22.07L18.44,79a20,20,0,0,0-3.06,37.25L99,157l40.71,83.65a19.81,19.81,0,0,0,18,11.38c.57,0,1.15,0,1.73-.07A19.82,19.82,0,0,0,177,237.56L235.18,45.65a1.42,1.42,0,0,0,.07-.22A20,20,0,0,0,230.14,25.86ZM156.91,221.07l-34.37-70.64,46-45.95a12,12,0,0,0-17-17l-46,46L34.93,99.09,210,46Z`}))],[`duotone`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M223.69,42.18l-58.22,192a8,8,0,0,1-14.92,1.25L108,148,20.58,105.45a8,8,0,0,1,1.25-14.92l192-58.22A8,8,0,0,1,223.69,42.18Z`,opacity:`0.2`}),K.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`fill`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M231.4,44.34s0,.1,0,.15l-58.2,191.94a15.88,15.88,0,0,1-14,11.51q-.69.06-1.38.06a15.86,15.86,0,0,1-14.42-9.15L107,164.15a4,4,0,0,1,.77-4.58l57.92-57.92a8,8,0,0,0-11.31-11.31L96.43,148.26a4,4,0,0,1-4.58.77L17.08,112.64a16,16,0,0,1,2.49-29.8l191.94-58.2.15,0A16,16,0,0,1,231.4,44.34Z`}))],[`light`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M225.88,30.12a13.83,13.83,0,0,0-13.7-3.58l-.11,0L20.14,84.77A14,14,0,0,0,18,110.85l85.56,41.64L145.12,238a13.87,13.87,0,0,0,12.61,8c.4,0,.81,0,1.21-.05a13.9,13.9,0,0,0,12.29-10.09l58.2-191.93,0-.11A13.83,13.83,0,0,0,225.88,30.12Zm-8,10.4L159.73,232.43l0,.11a2,2,0,0,1-3.76.26l-40.68-83.58,49-49a6,6,0,1,0-8.49-8.49l-49,49L23.15,100a2,2,0,0,1,.31-3.74l.11,0L215.48,38.08a1.94,1.94,0,0,1,1.92.52A2,2,0,0,1,217.92,40.52Z`}))],[`regular`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`thin`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M224.47,31.52a11.87,11.87,0,0,0-11.82-3L20.74,86.67a12,12,0,0,0-1.91,22.38L105,151l41.92,86.15A11.88,11.88,0,0,0,157.74,244c.34,0,.69,0,1,0a11.89,11.89,0,0,0,10.52-8.63l58.21-192,0-.08A11.85,11.85,0,0,0,224.47,31.52Zm-4.62,9.54-58.23,192a4,4,0,0,1-7.48.59l-41.3-84.86,50-50a4,4,0,1,0-5.66-5.66l-50,50-84.9-41.31a3.88,3.88,0,0,1-2.27-4,3.93,3.93,0,0,1,3-3.54L214.9,36.16A3.93,3.93,0,0,1,216,36a4,4,0,0,1,2.79,1.19A3.93,3.93,0,0,1,219.85,41.06Z`}))]]),fe=new Map([[`bold`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M200,36H56A20,20,0,0,0,36,56V200a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,160H60V60H196Z`}))],[`duotone`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z`,opacity:`0.2`}),K.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`fill`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`}))],[`light`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M200,42H56A14,14,0,0,0,42,56V200a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,158a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H200a2,2,0,0,1,2,2Z`}))],[`regular`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`thin`,K.createElement(K.Fragment,null,K.createElement(`path`,{d:`M200,44H56A12,12,0,0,0,44,56V200a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,156a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H200a4,4,0,0,1,4,4Z`}))]]),q=K.forwardRef((e,t)=>K.createElement(E,{ref:t,...e,weights:le}));q.displayName=`ArrowDownIcon`;var pe=q,J=K.forwardRef((e,t)=>K.createElement(E,{ref:t,...e,weights:ue}));J.displayName=`CaretRightIcon`;var Y=J,X=K.forwardRef((e,t)=>K.createElement(E,{ref:t,...e,weights:de}));X.displayName=`PaperPlaneTiltIcon`;var me=X,he=K.forwardRef((e,t)=>K.createElement(E,{ref:t,...e,weights:fe}));he.displayName=`StopIcon`;var ge=he;function _e(e){return e.dashboard.panels.length===1?e.dashboard.panels[0].title:e.dashboard.name}function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Missing panel view`);let t=e;if(!t.view||![`preset`,`query`].includes(t.view.kind)||!/^[a-f0-9]{64}$/.test(t.view.key))throw Error(`Invalid panel view identity`);if(t.dashboard?.version!==1||!Array.isArray(t.dashboard.panels)||!t.dashboard.panels.length||t.dashboard.panels.length>40||!Array.isArray(t.results)||t.dashboard.panels.some(e=>!e||typeof e.id!=`string`||!e.id)||t.results.some(e=>!e||typeof e.id!=`string`))throw Error(`Invalid panel view`);let n=new Set(t.dashboard.panels.map(e=>e.id));if(n.size!==t.dashboard.panels.length||t.results.length!==n.size||new Set(t.results.map(e=>e.id)).size!==n.size||t.results.some(e=>!n.has(e.id)||![`ok`,`empty`,`error`,`invalid`].includes(e.status)))throw Error(`Panel results do not match the view`);if(t.vars!==void 0&&(!t.vars||typeof t.vars!=`object`||Array.isArray(t.vars)||Object.values(t.vars).some(e=>typeof e!=`string`&&!(Array.isArray(e)&&e.every(e=>typeof e==`string`)))))throw Error(`Invalid panel variables`);if(t.trace!==void 0&&(!t.trace?.data||!Array.isArray(t.trace.data.spans)||!Array.isArray(t.trace.data.logs)||!Array.isArray(t.trace.data.services)))throw Error(`Invalid trace detail`);return t}var ye=new WeakSet;function be(e){if(!e||typeof e!=`object`||Array.isArray(e))return;if(ye.has(e))return e;let t=e;if(Object.keys(t).sort().join(`,`)===`is_error,resource_uri,tool_input,tool_name,tool_result`&&t.resource_uri===`ui://pitot/panels.html`&&typeof t.tool_name==`string`&&t.tool_name&&typeof t.is_error==`boolean`&&t.tool_input&&typeof t.tool_input==`object`&&!Array.isArray(t.tool_input)){try{ve(t.tool_result)}catch{return}return ye.add(t),t}}var xe=16,Se=new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function Ce(e){let t=(0,K.useRef)(null),n=(0,K.useRef)(null),r=(0,K.useRef)(null),i=(0,K.useRef)(!0),a=(0,K.useRef)(e),o=(0,K.useRef)(()=>{}),s=(0,K.useRef)(null),c=(0,K.useRef)(new Set),l=(0,K.useRef)(null),u=(0,K.useRef)(null),[d,f]=(0,K.useState)(!1),p=(0,K.useCallback)(()=>{let e=t.current,n=r.current?.lastElementChild,i=!e||!n||n.getBoundingClientRect().bottom>e.getBoundingClientRect().top+e.clientTop+e.clientHeight+1;f(!!e&&i&&e.scrollHeight-e.clientHeight-e.scrollTop>1)},[]),m=(0,K.useCallback)(()=>{let e=t.current;if(!e)return;let n=e.getBoundingClientRect().top+e.clientTop,r=[...e.querySelectorAll(`[data-chat-anchor]`)].find(e=>e.getBoundingClientRect().bottom>n);l.current=r?{node:r,top:r.getBoundingClientRect().top}:null},[]),h=(0,K.useCallback)((e,t)=>{e.scrollTop=t,u.current=e.scrollTop},[]),g=(0,K.useCallback)(()=>{let e=t.current;if(e){if(r.current){let t=n.current&&parseFloat(getComputedStyle(n.current).paddingBottom)||0;r.current.style.minHeight=`${Math.max(0,e.clientHeight-xe-t)}px`,i.current&&h(e,e.scrollTop+r.current.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-xe)}if(!i.current){let t=l.current;t?.node.isConnected&&h(e,e.scrollTop+t.node.getBoundingClientRect().top-t.top),m()}p()}},[m,h,p]),_=(0,K.useCallback)(()=>{let e=t.current,i=n.current;if(!e||!i){s.current?.disconnect(),s.current=null,c.current.clear();return}s.current??=new ResizeObserver(g);let a=new Set([e,i,...i.querySelectorAll(`[data-chat-anchor]`)]);r.current&&a.add(r.current);for(let e of c.current)a.has(e)||s.current.unobserve(e);for(let e of a)c.current.has(e)||s.current.observe(e);c.current=a},[g]),v=(0,K.useCallback)(e=>{if(o.current(),t.current=e,u.current=null,l.current=null,i.current=!0,_(),!e)return;let n=!1,r=()=>{i.current=!1,m()},a=e=>{let t=e.target;!e.defaultPrevented&&Se.has(e.key)&&(t instanceof HTMLElement&&(t.closest(`input, textarea, select, [contenteditable]`)||(e.key===` `?t.closest(`button`):t.closest(`[role=slider]`)))||r())},s=()=>{n=!0},c=()=>{n=!1},d=()=>{n&&e.scrollTop!==u.current&&r(),i.current||m(),p()};e.addEventListener(`scroll`,d,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchmove`,r,{passive:!0}),e.addEventListener(`keydown`,a),e.addEventListener(`pointerdown`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c),o.current=()=>{e.removeEventListener(`scroll`,d),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchmove`,r),e.removeEventListener(`keydown`,a),e.removeEventListener(`pointerdown`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),o.current=()=>{}},g()},[g,m,_,p]),y=(0,K.useCallback)(e=>{n.current=e,_()},[_]),b=(0,K.useCallback)(e=>{r.current?.style.removeProperty(`min-height`),r.current=e,_()},[_]);return(0,K.useLayoutEffect)(()=>{a.current!==e&&(a.current=e,i.current=!0,l.current=null),_(),g()}),{scrollRef:v,contentRef:y,turnRef:b,showJump:d,jumpToLatest:(0,K.useCallback)(()=>{let e=t.current;e&&(e.focus({preventScroll:!0}),i.current=!1,h(e,e.scrollHeight),m(),p())},[m,h,p])}}function we(e=1500){let[t,n]=(0,K.useState)(`idle`),r=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]);function i(t){r.current&&clearTimeout(r.current),n(`idle`),(navigator.clipboard?navigator.clipboard.writeText(t):Promise.reject(Error(`clipboard unavailable`))).then(()=>n(`copied`),()=>n(`failed`)).finally(()=>{r.current=setTimeout(()=>n(`idle`),e)})}return{state:t,copy:i}}var Z=e=>e!==`invalid`&&e!==`not_run`;function Te({receipt:e,running:t=!1,activity:n=``,awaitingAnswer:a=!1,initialExpanded:o=!1}){let[c,l]=(0,K.useState)(o),d=(0,K.useId)(),f=e.saved,h=f?.receipt.save_check,g=t=>Object.hasOwn(e.panel_titles,t)?e.panel_titles[t]:t,y=(h?.panels??e.panels).filter(e=>e.status===`invalid`).length,b=[...new Set([...e.explanations.filter(t=>!e.problems.some(e=>t.startsWith(`${g(e.panel_id)}:`))),...e.problems.map(e=>`${g(e.panel_id)}: ${e.message}`)])],x=Object.values(e.stages).filter(e=>e.state===`complete`).length,S=[e.stages.schema.state===`complete`?`Read telemetry`:void 0,e.panel_count===void 0?void 0:k(e.panel_count,`panel`),h?.checked?`Checked in ${j(h.elapsed_ms)}`:void 0,f?`Saved v${f.version}`:void 0].filter(Boolean).join(` · `)||`Building dashboard`,C=[...f?ne(f.receipt):[],...new Map(e.corrections.map(e=>[e.panel_id,`Fixed ${e.title}`])).values()];return(0,V.jsx)(r,{"data-build-receipt":e.turn_id,"data-dashboard-result":f?.id,"data-chat-anchor":!0,withBorder:!0,radius:`md`,p:`sm`,children:(0,V.jsxs)(u,{gap:6,children:[(0,V.jsxs)(s,{gap:`xs`,justify:`space-between`,children:[(0,V.jsxs)(_,{component:`div`,size:`sm`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[S,y>0&&(0,V.jsxs)(V.Fragment,{children:[` · `,(0,V.jsx)(m,{tone:`danger`,children:k(y,`invalid panel`)})]}),(0,V.jsxs)(_,{span:!0,c:`dimmed`,size:`xs`,children:[` · `,k(x,`stage`),` complete`]})]}),(0,V.jsxs)(v,{component:`button`,variant:`subtle`,color:`gray`,size:`compact-xs`,"aria-expanded":c,"aria-controls":d,onClick:()=>l(e=>!e),children:[`Details`,C.length>4?` (+${C.length-4})`:``]})]}),t&&a&&(0,V.jsx)(`div`,{"data-build-running":!0,children:(0,V.jsx)(p,{state:`loading`,loadingLabel:n||`Analyzing your system`,rows:0})}),(0,V.jsx)(se,{labels:C.slice(0,4)}),b.map(e=>t?e.split(` · `).filter(e=>!e.endsWith(`: incomplete`)).join(` · `):e).filter(Boolean).map((e,t)=>(0,V.jsx)(_,{size:`xs`,c:`dimmed`,"data-receipt-attention":!0,children:e},t)),f&&(0,V.jsx)(v,{renderRoot:e=>(0,V.jsx)(D,{...e,to:`/dashboards/$dashboardId`,params:{dashboardId:f.id},search:{}}),variant:`subtle`,size:`compact-sm`,color:`gray`,style:{alignSelf:`flex-start`},children:`Open dashboard`}),(0,V.jsx)(i,{expanded:c,id:d,children:(0,V.jsxs)(u,{gap:4,children:[f&&(0,V.jsxs)(_,{size:`xs`,children:[f.label,` `,f.name,` · opens the current dashboard`]}),(0,V.jsx)(_,{size:`xs`,fw:600,children:`Build stages`}),Object.entries(e.stages).map(([n,r])=>(0,V.jsxs)(_,{component:`div`,size:`xs`,children:[(0,V.jsxs)(m,{tone:r.state===`failed`?`danger`:r.state===`complete`?`success`:r.state===`interrupted`?`warning`:`neutral`,children:[ae[n],`: `,t&&r.state===`incomplete`?`in progress`:r.state]}),r.elapsed_ms!==void 0&&(r.state===`complete`||n===`preview`&&e.panels.some(e=>Z(e.status)))?` · ${j(r.elapsed_ms)}`:``]},n)),e.save_attempts.map((e,t)=>e.state===`retried`&&(0,V.jsxs)(_,{size:`xs`,c:`dimmed`,children:[`Save attempt `,t+1,`: retried`]},e.call_id)),!!e.context_counts.deploys&&(0,V.jsxs)(_,{size:`xs`,children:[e.context_counts.deploys,` deploys observed`]}),!!e.context_counts.anomalies&&(0,V.jsxs)(_,{size:`xs`,children:[e.context_counts.anomalies,` anomalies observed`]}),(0,V.jsx)(_,{size:`xs`,fw:600,children:`Panel preview`}),e.panels.map(e=>(0,V.jsxs)(_,{component:`div`,size:`xs`,children:[`Preview · `,g(e.id),`: `,(0,V.jsx)(m,{tone:e.status===`ok`?`success`:e.status===`empty`||e.status===`not_run`?`neutral`:`danger`,children:e.status===`ok`?`Ok`:e.status.charAt(0).toUpperCase()+e.status.slice(1)}),Z(e.status)&&e.elapsed_ms!==void 0?` · ${j(e.elapsed_ms)}`:``]},e.id)),h&&(0,V.jsx)(_,{size:`xs`,fw:600,children:`Save verification`}),h&&(0,V.jsxs)(_,{size:`xs`,children:[`Save check: `,h.checked?`checked`:`incomplete`,h.checked?` · ${j(h.elapsed_ms)}`:``]}),h?.panels.map(e=>(0,V.jsxs)(_,{component:`div`,size:`xs`,children:[`Save · `,g(e.id),`: `,(0,V.jsx)(m,{tone:e.status===`ok`?`success`:e.status===`empty`||e.status===`not_run`?`neutral`:`danger`,children:e.status===`ok`?`Ok`:e.status.charAt(0).toUpperCase()+e.status.slice(1)}),Z(e.status)&&` · ${k(e.rows??0,`row`)}`,Z(e.status)&&e.elapsed_ms!==void 0?` · ${j(e.elapsed_ms)}`:``]},e.id)),C.slice(4).map((e,t)=>(0,V.jsx)(_,{size:`xs`,children:e},t)),e.corrections.map((e,t)=>(0,V.jsxs)(_,{size:`xs`,children:[`Fixed `,e.title,`: `,e.message]},t))]})})]})})}var Ee=(0,K.lazy)(()=>ee(()=>import(`./mcp-app-frame-a5HZdAse.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),De=e=>e.tool_result.view.kind===`preset`;function Oe(e){let t=new Map,n=new Set,r=[],i=()=>{let e=new Map;for(let t of r){let n=t.content.tool_result.view.key;e.set(n,t)}let i=new Set([...e.values()].map(e=>e.id)),a=[...e.values()].some(e=>De(e.content)),o=r.filter(e=>i.has(e.id)).at(-1)?.id;for(let e of r)i.has(e.id)?t.set(e.id,{content:e.content,expanded:De(e.content)||!a&&e.id===o}):n.add(e.id);r=[]};for(let t of e)if(t.role===`user`&&i(),t.role===`activity`&&t.activityType===`mcp-app`){let e=be(t.content);e&&r.push({id:t.id,content:e})}return i(),{views:t,duplicates:n}}function ke(e,t){return Array.isArray(e)?e.flatMap(e=>{if(!L(e)||typeof e.message!=`string`)return[];let n=typeof e.path==`string`?/^panels\[(\d+)\](?:\.|$)/.exec(e.path)?.[1]:void 0,r=n===void 0?void 0:t?.[Number(n)];return[r&&!e.message.startsWith(r)?`${r}: ${e.message}`:e.message]}):[]}function Ae(e){let t=new Map,n=new Map,r=new Map,i=`unattributed`;for(let a of e){if(a.role===`user`&&(n.clear(),r.clear(),i=a.id),a.role===`assistant`){i=a.id;for(let e of a.toolCalls??[]){let t=[`create_dashboard`,`replace_dashboard`].includes(e.function.name)?re(e.function.arguments)?.dashboard:void 0,r=L(t)&&Array.isArray(t.panels)?t.panels.map(e=>L(e)&&typeof e.title==`string`?e.title:``):void 0;n.set(e.id,{assistant:i,name:e.function.name,titles:r})}}if(a.role===`tool`){let e=re(a.content);if(!a.error&&!e?.error&&e?.isError!==!0)continue;let o=n.get(a.toolCallId);if(o&&te.has(o.name)&&I(a))continue;let s=L(e?.error)?e?.error:void 0;if(s?.code===`no_data`||s?.code===`unknown_service`)continue;let c=o?.assistant??i,l=r.get(c)??a.id;r.set(c,l);let u=t.get(l)??[],d=typeof s?.message==`string`?s.message:typeof a.error==`string`&&a.error?a.error:`Could not complete this step. Try again.`,f=[`create_dashboard`,`edit_dashboard`,`replace_dashboard`].includes(o?.name??``)&&(s?.code===`invalid_spec`||s?.code===`dashboard_version_conflict`);u.push({name:oe(o?.name??``),message:d,details:f?ke(e?.problems,o?.titles):[],readOnly:s?.code===`answer_only`,rejected:f}),t.set(l,u)}}return t}function je({failures:e}){let[t,n]=(0,K.useState)({rejected:!1,failed:!1}),r=e.filter(e=>e.rejected),i=e.filter(e=>!e.readOnly&&!e.rejected),a=[{key:`rejected`,items:r,label:`${r.length} ${r.length===1?`draft`:`drafts`} rejected`},{key:`failed`,items:i,label:`${i.length} ${i.length===1?`step`:`steps`} failed`}];return(0,V.jsxs)(d,{"data-chat-anchor":!0,children:[e.some(e=>e.readOnly)&&(0,V.jsx)(_,{size:`sm`,c:`dimmed`,children:`Not saved: Explain is read-only`}),a.map(({key:e,items:r,label:i})=>r.length>0&&(0,V.jsxs)(d,{children:[(0,V.jsxs)(T,{className:`chat-app-toggle`,"aria-expanded":t[e],onClick:()=>n(t=>({...t,[e]:!t[e]})),style:{color:`var(--mantine-color-dimmed)`},children:[(0,V.jsx)(`span`,{className:`chat-app-chevron`,"aria-hidden":`true`,children:t[e]?(0,V.jsx)(P,{size:14}):(0,V.jsx)(Y,{size:14})}),(0,V.jsx)(`span`,{className:`chat-app-summary`,children:i})]}),t[e]&&(0,V.jsx)(u,{gap:`xs`,pl:`md`,children:r.flatMap((e,t)=>(e.details.length?e.details:[`${e.name}: ${e.message}`]).map((e,n)=>(0,V.jsx)(_,{size:`sm`,c:`dimmed`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e},`${t}-${n}`)))})]},e))]})}function Me({view:e}){let[t,n]=(0,K.useState)(e.expanded);(0,K.useEffect)(()=>n(e.expanded),[e.expanded]);let i=e.content.tool_result,a=_e(i),o=[...new Set(i.dashboard.panels.map(e=>e.viz===`timeseries`?`time series`:e.viz.replaceAll(`_`,` `)))].join(`, `),s=i.results.reduce((e,t)=>e+(t.frame?.rows??0),0),c=new Map;for(let e of i.results)e.status!==`ok`&&c.set(e.status,(c.get(e.status)??0)+1);let l=i.dashboard.panels.length>1?Array.from(c,([e,t])=>`${t} ${e}`).join(` · `):c.size?[...c.keys()].join(`, `):`${s} ${s===1?`row`:`rows`}`;return(0,V.jsxs)(r,{"data-chat-app":!0,"data-chat-anchor":!0,withBorder:!0,radius:`md`,style:{overflow:`hidden`},children:[(0,V.jsxs)(T,{className:`chat-app-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,V.jsx)(`span`,{className:`chat-app-chevron`,"aria-hidden":`true`,children:t?(0,V.jsx)(P,{size:14}):(0,V.jsx)(Y,{size:14})}),(0,V.jsx)(`span`,{className:`chat-app-summary`,children:[a,o,l].filter(Boolean).join(` · `)})]}),t&&(0,V.jsx)(K.Suspense,{fallback:(0,V.jsx)(p,{state:`loading`,loadingLabel:`Preparing view…`}),children:(0,V.jsx)(Ee,{content:e.content})})]})}var Ne=[`Summarize system health for the last hour`,`Find the source of elevated errors`,`Map the current service dependencies`,`Show the slowest endpoints`];function Pe(){let{agentAvailable:e,messages:t,messageTimes:n,ready:i,running:a,activity:o,stopped:c,error:l,threadMissing:f,send:m,retry:g,reloadThread:y,newThread:b}=z(),x=ie(t),C=t.filter(e=>e.role===`user`).at(-1)?.id,{scrollRef:T,contentRef:E,turnRef:D,showJump:ee,jumpToLatest:O}=Ce(C);if(!e)return(0,V.jsx)(U,{size:`sm`,py:96,children:(0,V.jsx)(r,{withBorder:!0,radius:`md`,p:{base:`xl`,sm:40},children:(0,V.jsxs)(u,{gap:`md`,children:[(0,V.jsx)(_,{fw:700,size:`xs`,tt:`uppercase`,lts:`0.12em`,children:`Optional capability`}),(0,V.jsx)(h,{title:`Chat`,description:`Chat is not configured`}),(0,V.jsx)(_,{c:`dimmed`,children:`Add an AI provider key to enable chat. Telemetry ingest, dashboards, traces, logs, and metrics remain available without it.`}),(0,V.jsx)(v,{component:`a`,href:`/dashboards`,variant:`light`,mt:`sm`,children:`Open dashboards`})]})})});let k=Oe(t),A=Ae(t),j=t.filter(e=>k.duplicates.has(e.id)?!1:e.role===`tool`?A.has(e.id):e.role===`assistant`?!e.toolCalls?.length&&typeof e.content==`string`&&e.content.trim().length>0:e.role===`activity`?e.activityType===`mcp-app`||e.activityType===`agent-outcome`:e.role===`user`),M=t.findIndex(e=>e.id===C),N=t.slice(M+1).some(e=>e.role===`assistant`&&!e.toolCalls?.length&&typeof e.content==`string`&&e.content.length>0),P=t.slice(M+1).filter(e=>e.role===`assistant`&&!e.toolCalls?.length&&typeof e.content==`string`&&e.content.trim().length>0).at(-1),F=[];for(let e of j)(e.role===`user`||F.length===0)&&F.push({id:e.id,messages:[]}),F.at(-1).messages.push(e);F.length===0&&F.push({id:`draft`,messages:[]});let I=e=>A.has(e.id)?(0,V.jsx)(je,{failures:A.get(e.id)},e.id):(0,V.jsxs)(d,{children:[(0,V.jsx)(Le,{message:e,time:n[e.id],appView:k.views.get(e.id)}),x.has(e.id)&&(0,V.jsx)(d,{mt:`sm`,children:(0,V.jsx)(Te,{receipt:x.get(e.id),running:a&&e.id===C,awaitingAnswer:!N,activity:o})})]},e.id);return(0,V.jsxs)(d,{className:`chat-pane`,children:[(0,V.jsx)(U,{size:880,w:`100%`,px:{base:`md`,sm:`xl`},py:`md`,children:(0,V.jsx)(h,{title:`Chat`,description:`Investigate your telemetry with Pitot.`})}),(0,V.jsxs)(d,{className:`chat-viewport`,children:[(0,V.jsx)(d,{className:`chat-scroll`,ref:T,tabIndex:0,role:`log`,"aria-label":`Conversation`,children:(0,V.jsxs)(U,{size:880,px:{base:`md`,sm:`xl`},py:`lg`,ref:E,children:[f&&(0,V.jsx)(w,{tone:`warning`,title:`This chat no longer exists`,children:(0,V.jsxs)(s,{justify:`space-between`,children:[(0,V.jsx)(_,{size:`sm`,children:`It was deleted, or the link is wrong.`}),(0,V.jsx)(v,{size:`compact-sm`,variant:`light`,onClick:b,children:`New chat`})]})}),!f&&!i&&l&&(0,V.jsx)(Q,{message:l,onRetry:y,onNewThread:b}),!f&&!i&&!l&&(0,V.jsx)(p,{state:`loading`,loadingLabel:`Loading chat`,rows:5}),!f&&i&&(0,V.jsxs)(V.Fragment,{children:[j.length===0&&(0,V.jsx)(Ie,{onSelect:m}),(0,V.jsx)(u,{gap:`lg`,children:F.map((e,t)=>(0,V.jsxs)(u,{gap:`lg`,ref:e.id===C?D:void 0,"data-chat-turn":e.id===C?C:void 0,children:[e.messages.filter(e=>e.id!==P?.id).map(I),t===F.length-1&&(0,V.jsxs)(V.Fragment,{children:[P&&(0,V.jsx)(d,{"data-answer-position":!0,children:(0,V.jsx)(Le,{message:P,time:n[P.id]})},`answer-${C??`draft`}`),a&&!N&&!x.has(C??``)&&(0,V.jsx)(p,{state:`loading`,loadingLabel:o||`Analyzing your system`,rows:0}),c&&(0,V.jsx)(_,{c:`dimmed`,size:`sm`,children:`Stopped`}),l&&(0,V.jsx)(Q,{message:l,onRetry:g})]})]},e.id))})]})]})}),ee&&(0,V.jsx)(R,{label:`Jump to latest`,children:(0,V.jsx)(S,{className:`chat-jump`,variant:`default`,size:36,"aria-label":`Jump to latest`,onClick:O,children:(0,V.jsx)(pe,{size:18,"aria-hidden":`true`})})})]}),!f&&(0,V.jsx)(Fe,{})]})}function Q({message:e,onRetry:t,onNewThread:n}){return(0,V.jsx)(w,{tone:`danger`,title:`Something went wrong`,children:(0,V.jsxs)(s,{justify:`space-between`,gap:`sm`,wrap:`nowrap`,children:[(0,V.jsx)(_,{size:`sm`,children:e}),(0,V.jsxs)(s,{gap:`xs`,wrap:`nowrap`,children:[n&&(0,V.jsx)(v,{size:`compact-sm`,variant:`subtle`,color:`bad`,onClick:n,children:`New chat`}),(0,V.jsx)(v,{size:`compact-sm`,variant:`light`,color:`bad`,onClick:t,children:`Retry`})]})]})})}function Fe(){let{input:e,setInput:t,inputRef:n,submit:i,send:a,stop:o,ready:c,running:l}=z();return(0,V.jsx)(d,{className:`chat-composer`,children:(0,V.jsxs)(U,{size:880,px:{base:`md`,sm:`xl`},children:[(0,V.jsx)(r,{component:`form`,onSubmit:i,className:`chat-composer-field`,style:{borderColor:`var(--composer-border, var(--labstack-control-border))`},withBorder:!0,radius:`sm`,py:6,pl:`lg`,pr:6,children:(0,V.jsxs)(s,{align:`flex-end`,gap:`xs`,wrap:`nowrap`,children:[(0,V.jsx)(M,{ref:n,"aria-label":`Message Pitot`,value:e,onChange:e=>t(e.currentTarget.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),a(e))},placeholder:l?`Pitot is working…`:`Ask about health, errors, or latency…`,disabled:!c,autosize:!0,minRows:1,maxRows:8,variant:`unstyled`,flex:1}),l?(0,V.jsx)(R,{label:`Stop`,children:(0,V.jsx)(S,{type:`button`,variant:`default`,size:40,"aria-label":`Stop`,onClick:o,children:(0,V.jsx)(ge,{size:16,weight:`fill`})})}):(0,V.jsx)(S,{type:`submit`,variant:`filled`,size:40,disabled:!e.trim()||!c,"aria-label":`Send message`,children:(0,V.jsx)(me,{size:17,weight:`fill`})})]})}),(0,V.jsx)(_,{c:`dimmed`,size:`xs`,ta:`center`,mt:6,children:`Enter to send, Shift+Enter for a new line`})]})})}function Ie({onSelect:e}){return(0,V.jsxs)(u,{align:`center`,gap:`md`,pt:{base:32,sm:88},pb:`xl`,ta:`center`,children:[(0,V.jsx)(y,{size:`large`}),(0,V.jsx)(l,{order:2,fz:24,fw:500,lh:1.25,maw:560,children:`What do you want to know about your system?`}),(0,V.jsx)(s,{justify:`center`,gap:`xs`,mt:`xs`,maw:b.prose,children:Ne.map(t=>(0,V.jsx)(v,{variant:`default`,size:`sm`,onClick:()=>void e(t),children:t},t))})]})}function Le({message:e,time:t,appView:n}){if(e.role===`activity`)return e.activityType===`agent-outcome`&&e.content&&typeof e.content==`object`&&`message`in e.content&&typeof e.content.message==`string`?`status`in e.content&&e.content.status===`stopped`?(0,V.jsx)(_,{c:`dimmed`,size:`sm`,"data-chat-anchor":!0,children:e.content.message}):(0,V.jsx)(d,{"data-chat-anchor":!0,children:(0,V.jsx)(w,{tone:`danger`,title:`Something went wrong`,children:e.content.message})}):e.activityType===`mcp-app`?n?(0,V.jsx)(Me,{view:n}):(0,V.jsx)(d,{"data-chat-anchor":!0,children:(0,V.jsx)(w,{tone:`danger`,children:`This view could not be loaded. Please try again.`})}):null;if(e.role===`assistant`&&e.toolCalls?.length)return null;let i=typeof e.content==`string`?e.content:JSON.stringify(e.content);if(!i&&e.role===`assistant`)return null;let a=e.role===`user`,o=t?new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(new Date(t)):``;return(0,V.jsxs)(d,{className:`chat-message`,"data-chat-anchor":!0,"data-role":a?`user`:`assistant`,children:[a?(0,V.jsx)(r,{radius:`md`,px:`md`,py:`sm`,bg:`var(--labstack-inset)`,maw:`70%`,ml:`auto`,w:`fit-content`,children:(0,V.jsx)(_,{style:{whiteSpace:`pre-wrap`},children:i})}):(0,V.jsx)(G,{className:`chat-markdown`,children:(0,V.jsx)(N,{remarkPlugins:[F,ze],components:Be,children:i})}),(o||!a)&&(0,V.jsxs)(s,{className:`chat-message-meta`,gap:6,justify:a?`flex-end`:`flex-start`,mt:4,h:24,children:[o&&t&&(0,V.jsx)(_,{c:`dimmed`,size:`xs`,title:A(t),children:o}),!a&&(0,V.jsx)(Re,{text:i,label:`Copy message`})]})]})}function Re({text:e,label:t}){let{state:n,copy:r}=we();return(0,V.jsx)(R,{label:n===`failed`?`Could not copy`:n===`copied`?`Copied`:t,children:(0,V.jsx)(S,{variant:`subtle`,color:`gray`,size:`sm`,"aria-label":t,"data-state":n===`idle`?void 0:n,onClick:()=>r(e),children:n===`copied`?(0,V.jsx)(g,{size:13,weight:`bold`}):(0,V.jsx)(C,{size:13})})})}function ze(){return e=>{let t=[],n=e=>{if(e.type===`table`&&e.children){let t=e=>e.value??e.children?.map(t).join(``)??``,n=e.children.slice(1);e.align=(e.children[0]?.children??[]).map((r,i)=>n.length&&n.every(e=>/^[-+−]?\d[\d,.]*(?:%|\s?(?:ms|s|K|M))?$/.test(t(e.children?.[i]??{type:`text`}).trim()))?`right`:e.align?.[i]??null)}if(e.type===`heading`&&e.depth!==void 0){let n=e.depth;for(;t.length&&t.at(-1)>=n;)t.pop();t.push(n),e.depth=Math.min(6,t.length+1)}e.children?.forEach(n)};n(e)}}var Be={table:({children:e})=>(0,V.jsx)(d,{className:`chat-table`,children:(0,V.jsx)(O,{stickyHeader:!0,highlightOnHover:!0,withTableBorder:!0,verticalSpacing:`xs`,fz:`sm`,children:e})}),thead:({children:e})=>(0,V.jsx)(O.Thead,{children:e}),tbody:({children:e})=>(0,V.jsx)(O.Tbody,{children:e}),tr:({children:e})=>(0,V.jsx)(O.Tr,{children:e}),th:({children:e,style:t})=>(0,V.jsx)(O.Th,{style:t,children:e}),td:({children:e,style:t})=>(0,V.jsx)(O.Td,{style:t,ta:typeof e==`string`&&/^[-+−]?\d[\d,.]*(?:%|\s?(?:ms|s|K|M))?$/.test(e.trim())?`right`:void 0,ff:typeof e==`string`&&/^[-+−]?\d/.test(e.trim())?`monospace`:void 0,children:e}),pre:({children:e})=>(0,V.jsx)(Ve,{children:e}),a:({href:e,children:t})=>(0,V.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t})};function Ve({children:e}){let t=$(e);return(0,V.jsxs)(d,{className:`chat-code`,pos:`relative`,children:[(0,V.jsx)(d,{className:`chat-code-actions`,pos:`absolute`,top:6,right:6,children:(0,V.jsx)(Re,{text:t,label:`Copy code`})}),(0,V.jsx)(`pre`,{children:e})]})}function $(e){return typeof e==`string`?e:Array.isArray(e)?e.map($).join(``):e&&typeof e==`object`&&`props`in e?$(e.props.children):``}export{be as n,Pe as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat-DMtvX_Pa.js b/internal/ui/dist/assets/chat-DMtvX_Pa.js deleted file mode 100644 index 0776df0a4..000000000 --- a/internal/ui/dist/assets/chat-DMtvX_Pa.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-app-frame-C1fa0h58.js","assets/useRouter-ByJ6_rwb.js","assets/brand-D6fP-cLS.js","assets/auth-DWqIkMZS.js","assets/useNavigate-B1zgPEUp.js","assets/index-C1Pd14SU.js","assets/preload-helper-DJZNfKNH.js","assets/lazyRouteComponent-DiWTNBZT.js","assets/theme-DXTVNXHm.js","assets/search-D_K9J6yO.js","assets/noop-mXPS5vjY.js","assets/format-BZjbsxwM.js","assets/useQuery-BLTYSIvG.js","assets/search-CDra9nG2.js","assets/index-CzwgFH1g.css"])))=>i.map(i=>d[i]); -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{$ as r,Ct as i,Dt as a,Ft as o,G as s,Nt as c,S as l,T as u,Tt as d,Zt as f,a as p,f as m,g as h,i as g,j as _,k as v,n as y,p as b,pn as x,q as S,r as C,s as w,tt as T,x as E}from"./brand-D6fP-cLS.js";import{n as D,t as ee}from"./preload-helper-DJZNfKNH.js";import{t as O}from"./Table-D4ZwUno3.js";import{a as k,n as A,t as j}from"./format-BZjbsxwM.js";import{t as M}from"./Textarea-r3wuKNbO.js";import{n as N,r as P,t as F}from"./lib-BLIvzI-_.js";import{C as I,D as L,E as te,S as ne,T as re,b as ie,ct as R,w as ae,x as oe,y as se}from"./index-C1Pd14SU.js";import{t as ce}from"./dashboard-change-chips-BJ-GZE9U.js";var z={root:`m_7485cace`},B=t(),le={strategy:`block`},V=f((e,{size:t,fluid:n})=>({root:{"--container-size":n?void 0:x(t,`container-size`)}})),H=a(e=>{let t=o(`Container`,le,e),{classNames:n,className:r,style:i,styles:a,unstyled:s,vars:l,fluid:u,mod:f,attributes:p,strategy:m,...h}=t,g=c({name:`Container`,classes:z,props:t,className:r,style:i,classNames:n,styles:a,unstyled:s,attributes:p,vars:l,varsResolver:V});return(0,B.jsx)(d,{mod:[{fluid:u,strategy:m},f],...g(`root`),...h})});H.classes=z,H.varsResolver=V,H.displayName=`@mantine/core/Container`;var U={root:`m_d08caa0`},W=a(e=>{let t=o(`Typography`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:s,attributes:l,...u}=t,f=c({name:`Typography`,classes:U,props:t,className:r,style:i,classNames:n,styles:a,unstyled:s,attributes:l});return(0,B.jsx)(d,{...f(`root`),...u})});W.classes=U,W.displayName=`@mantine/core/Typography`;var G=n(e(),1),ue=new Map([[`bold`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M208.49,152.49l-72,72a12,12,0,0,1-17,0l-72-72a12,12,0,0,1,17-17L116,187V40a12,12,0,0,1,24,0V187l51.51-51.52a12,12,0,0,1,17,17Z`}))],[`duotone`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M200,144l-72,72L56,144Z`,opacity:`0.2`}),G.createElement(`path`,{d:`M207.39,140.94A8,8,0,0,0,200,136H136V40a8,8,0,0,0-16,0v96H56a8,8,0,0,0-5.66,13.66l72,72a8,8,0,0,0,11.32,0l72-72A8,8,0,0,0,207.39,140.94ZM128,204.69,75.31,152H180.69Z`}))],[`fill`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72A8,8,0,0,1,56,136h64V40a8,8,0,0,1,16,0v96h64a8,8,0,0,1,5.66,13.66Z`}))],[`light`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M204.24,148.24l-72,72a6,6,0,0,1-8.48,0l-72-72a6,6,0,0,1,8.48-8.48L122,201.51V40a6,6,0,0,1,12,0V201.51l61.76-61.75a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72a8,8,0,0,1,11.32-11.32L120,196.69V40a8,8,0,0,1,16,0V196.69l58.34-58.35a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M202.83,146.83l-72,72a4,4,0,0,1-5.66,0l-72-72a4,4,0,0,1,5.66-5.66L124,206.34V40a4,4,0,0,1,8,0V206.34l65.17-65.17a4,4,0,0,1,5.66,5.66Z`}))]]),de=new Map([[`bold`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z`}))],[`duotone`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M176,128,96,208V48Z`,opacity:`0.2`}),G.createElement(`path`,{d:`M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z`}))],[`fill`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`light`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z`}))],[`regular`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`thin`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z`}))]]),fe=new Map([[`bold`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M230.14,25.86a20,20,0,0,0-19.57-5.11l-.22.07L18.44,79a20,20,0,0,0-3.06,37.25L99,157l40.71,83.65a19.81,19.81,0,0,0,18,11.38c.57,0,1.15,0,1.73-.07A19.82,19.82,0,0,0,177,237.56L235.18,45.65a1.42,1.42,0,0,0,.07-.22A20,20,0,0,0,230.14,25.86ZM156.91,221.07l-34.37-70.64,46-45.95a12,12,0,0,0-17-17l-46,46L34.93,99.09,210,46Z`}))],[`duotone`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M223.69,42.18l-58.22,192a8,8,0,0,1-14.92,1.25L108,148,20.58,105.45a8,8,0,0,1,1.25-14.92l192-58.22A8,8,0,0,1,223.69,42.18Z`,opacity:`0.2`}),G.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`fill`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M231.4,44.34s0,.1,0,.15l-58.2,191.94a15.88,15.88,0,0,1-14,11.51q-.69.06-1.38.06a15.86,15.86,0,0,1-14.42-9.15L107,164.15a4,4,0,0,1,.77-4.58l57.92-57.92a8,8,0,0,0-11.31-11.31L96.43,148.26a4,4,0,0,1-4.58.77L17.08,112.64a16,16,0,0,1,2.49-29.8l191.94-58.2.15,0A16,16,0,0,1,231.4,44.34Z`}))],[`light`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M225.88,30.12a13.83,13.83,0,0,0-13.7-3.58l-.11,0L20.14,84.77A14,14,0,0,0,18,110.85l85.56,41.64L145.12,238a13.87,13.87,0,0,0,12.61,8c.4,0,.81,0,1.21-.05a13.9,13.9,0,0,0,12.29-10.09l58.2-191.93,0-.11A13.83,13.83,0,0,0,225.88,30.12Zm-8,10.4L159.73,232.43l0,.11a2,2,0,0,1-3.76.26l-40.68-83.58,49-49a6,6,0,1,0-8.49-8.49l-49,49L23.15,100a2,2,0,0,1,.31-3.74l.11,0L215.48,38.08a1.94,1.94,0,0,1,1.92.52A2,2,0,0,1,217.92,40.52Z`}))],[`regular`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`thin`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M224.47,31.52a11.87,11.87,0,0,0-11.82-3L20.74,86.67a12,12,0,0,0-1.91,22.38L105,151l41.92,86.15A11.88,11.88,0,0,0,157.74,244c.34,0,.69,0,1,0a11.89,11.89,0,0,0,10.52-8.63l58.21-192,0-.08A11.85,11.85,0,0,0,224.47,31.52Zm-4.62,9.54-58.23,192a4,4,0,0,1-7.48.59l-41.3-84.86,50-50a4,4,0,1,0-5.66-5.66l-50,50-84.9-41.31a3.88,3.88,0,0,1-2.27-4,3.93,3.93,0,0,1,3-3.54L214.9,36.16A3.93,3.93,0,0,1,216,36a4,4,0,0,1,2.79,1.19A3.93,3.93,0,0,1,219.85,41.06Z`}))]]),pe=new Map([[`bold`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M200,36H56A20,20,0,0,0,36,56V200a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,160H60V60H196Z`}))],[`duotone`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z`,opacity:`0.2`}),G.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`fill`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`}))],[`light`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M200,42H56A14,14,0,0,0,42,56V200a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,158a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H200a2,2,0,0,1,2,2Z`}))],[`regular`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`thin`,G.createElement(G.Fragment,null,G.createElement(`path`,{d:`M200,44H56A12,12,0,0,0,44,56V200a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,156a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H200a4,4,0,0,1,4,4Z`}))]]),K=G.forwardRef((e,t)=>G.createElement(E,{ref:t,...e,weights:ue}));K.displayName=`ArrowDownIcon`;var me=K,q=G.forwardRef((e,t)=>G.createElement(E,{ref:t,...e,weights:de}));q.displayName=`CaretRightIcon`;var J=q,he=G.forwardRef((e,t)=>G.createElement(E,{ref:t,...e,weights:fe}));he.displayName=`PaperPlaneTiltIcon`;var ge=he,_e=G.forwardRef((e,t)=>G.createElement(E,{ref:t,...e,weights:pe}));_e.displayName=`StopIcon`;var ve=_e;function ye(e){return e.dashboard.panels.length===1?e.dashboard.panels[0].title:e.dashboard.name}function be(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Missing panel view`);let t=e;if(!t.view||![`preset`,`query`].includes(t.view.kind)||!/^[a-f0-9]{64}$/.test(t.view.key))throw Error(`Invalid panel view identity`);if(t.dashboard?.version!==1||!Array.isArray(t.dashboard.panels)||!t.dashboard.panels.length||t.dashboard.panels.length>40||!Array.isArray(t.results)||t.dashboard.panels.some(e=>!e||typeof e.id!=`string`||!e.id)||t.results.some(e=>!e||typeof e.id!=`string`))throw Error(`Invalid panel view`);let n=new Set(t.dashboard.panels.map(e=>e.id));if(n.size!==t.dashboard.panels.length||t.results.length!==n.size||new Set(t.results.map(e=>e.id)).size!==n.size||t.results.some(e=>!n.has(e.id)||![`ok`,`empty`,`error`,`invalid`].includes(e.status)))throw Error(`Panel results do not match the view`);if(t.vars!==void 0&&(!t.vars||typeof t.vars!=`object`||Array.isArray(t.vars)||Object.values(t.vars).some(e=>typeof e!=`string`&&!(Array.isArray(e)&&e.every(e=>typeof e==`string`)))))throw Error(`Invalid panel variables`);if(t.trace!==void 0&&(!t.trace?.data||!Array.isArray(t.trace.data.spans)||!Array.isArray(t.trace.data.logs)||!Array.isArray(t.trace.data.services)))throw Error(`Invalid trace detail`);return t}var xe=new WeakSet;function Y(e){if(!e||typeof e!=`object`||Array.isArray(e))return;if(xe.has(e))return e;let t=e;if(t.resource_uri===`ui://fanout/panels.html`)return Y({...t,resource_uri:`ui://pitot/panels.html`});if(Object.keys(t).sort().join(`,`)===`is_error,resource_uri,tool_input,tool_name,tool_result`&&t.resource_uri===`ui://pitot/panels.html`&&typeof t.tool_name==`string`&&t.tool_name&&typeof t.is_error==`boolean`&&t.tool_input&&typeof t.tool_input==`object`&&!Array.isArray(t.tool_input)){try{be(t.tool_result)}catch{return}return xe.add(t),t}}var Se=16,Ce=new Set([`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `]);function we(e){let t=(0,G.useRef)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(null),i=(0,G.useRef)(!0),a=(0,G.useRef)(e),o=(0,G.useRef)(()=>{}),s=(0,G.useRef)(null),c=(0,G.useRef)(new Set),l=(0,G.useRef)(null),u=(0,G.useRef)(null),[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(()=>{let e=t.current,n=r.current?.lastElementChild,i=!e||!n||n.getBoundingClientRect().bottom>e.getBoundingClientRect().top+e.clientTop+e.clientHeight+1;f(!!e&&i&&e.scrollHeight-e.clientHeight-e.scrollTop>1)},[]),m=(0,G.useCallback)(()=>{let e=t.current;if(!e)return;let n=e.getBoundingClientRect().top+e.clientTop,r=[...e.querySelectorAll(`[data-chat-anchor]`)].find(e=>e.getBoundingClientRect().bottom>n);l.current=r?{node:r,top:r.getBoundingClientRect().top}:null},[]),h=(0,G.useCallback)((e,t)=>{e.scrollTop=t,u.current=e.scrollTop},[]),g=(0,G.useCallback)(()=>{let e=t.current;if(e){if(r.current){let t=n.current&&parseFloat(getComputedStyle(n.current).paddingBottom)||0;r.current.style.minHeight=`${Math.max(0,e.clientHeight-Se-t)}px`,i.current&&h(e,e.scrollTop+r.current.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Se)}if(!i.current){let t=l.current;t?.node.isConnected&&h(e,e.scrollTop+t.node.getBoundingClientRect().top-t.top),m()}p()}},[m,h,p]),_=(0,G.useCallback)(()=>{let e=t.current,i=n.current;if(!e||!i){s.current?.disconnect(),s.current=null,c.current.clear();return}s.current??=new ResizeObserver(g);let a=new Set([e,i,...i.querySelectorAll(`[data-chat-anchor]`)]);r.current&&a.add(r.current);for(let e of c.current)a.has(e)||s.current.unobserve(e);for(let e of a)c.current.has(e)||s.current.observe(e);c.current=a},[g]),v=(0,G.useCallback)(e=>{if(o.current(),t.current=e,u.current=null,l.current=null,i.current=!0,_(),!e)return;let n=!1,r=()=>{i.current=!1,m()},a=e=>{let t=e.target;!e.defaultPrevented&&Ce.has(e.key)&&(t instanceof HTMLElement&&(t.closest(`input, textarea, select, [contenteditable]`)||(e.key===` `?t.closest(`button`):t.closest(`[role=slider]`)))||r())},s=()=>{n=!0},c=()=>{n=!1},d=()=>{n&&e.scrollTop!==u.current&&r(),i.current||m(),p()};e.addEventListener(`scroll`,d,{passive:!0}),e.addEventListener(`wheel`,r,{passive:!0}),e.addEventListener(`touchmove`,r,{passive:!0}),e.addEventListener(`keydown`,a),e.addEventListener(`pointerdown`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c),o.current=()=>{e.removeEventListener(`scroll`,d),e.removeEventListener(`wheel`,r),e.removeEventListener(`touchmove`,r),e.removeEventListener(`keydown`,a),e.removeEventListener(`pointerdown`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),o.current=()=>{}},g()},[g,m,_,p]),y=(0,G.useCallback)(e=>{n.current=e,_()},[_]),b=(0,G.useCallback)(e=>{r.current?.style.removeProperty(`min-height`),r.current=e,_()},[_]);return(0,G.useLayoutEffect)(()=>{a.current!==e&&(a.current=e,i.current=!0,l.current=null),_(),g()}),{scrollRef:v,contentRef:y,turnRef:b,showJump:d,jumpToLatest:(0,G.useCallback)(()=>{let e=t.current;e&&(e.focus({preventScroll:!0}),i.current=!1,h(e,e.scrollHeight),m(),p())},[m,h,p])}}function Te(e=1500){let[t,n]=(0,G.useState)(`idle`),r=(0,G.useRef)(null);(0,G.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]);function i(t){r.current&&clearTimeout(r.current),n(`idle`),(navigator.clipboard?navigator.clipboard.writeText(t):Promise.reject(Error(`clipboard unavailable`))).then(()=>n(`copied`),()=>n(`failed`)).finally(()=>{r.current=setTimeout(()=>n(`idle`),e)})}return{state:t,copy:i}}var X=e=>e!==`invalid`&&e!==`not_run`;function Ee({receipt:e,running:t=!1,activity:n=``,awaitingAnswer:a=!1,initialExpanded:o=!1}){let[c,l]=(0,G.useState)(o),d=(0,G.useId)(),f=e.saved,h=f?.receipt.save_check,g=t=>Object.hasOwn(e.panel_titles,t)?e.panel_titles[t]:t,y=(h?.panels??e.panels).filter(e=>e.status===`invalid`).length,b=[...new Set([...e.explanations.filter(t=>!e.problems.some(e=>t.startsWith(`${g(e.panel_id)}:`))),...e.problems.map(e=>`${g(e.panel_id)}: ${e.message}`)])],x=Object.values(e.stages).filter(e=>e.state===`complete`).length,S=[e.stages.schema.state===`complete`?`Read telemetry`:void 0,e.panel_count===void 0?void 0:k(e.panel_count,`panel`),h?.checked?`Checked in ${j(h.elapsed_ms)}`:void 0,f?`Saved v${f.version}`:void 0].filter(Boolean).join(` · `)||`Building dashboard`,C=[...f?ne(f.receipt):[],...new Map(e.corrections.map(e=>[e.panel_id,`Fixed ${e.title}`])).values()];return(0,B.jsx)(r,{"data-build-receipt":e.turn_id,"data-dashboard-result":f?.id,"data-chat-anchor":!0,withBorder:!0,radius:`md`,p:`sm`,children:(0,B.jsxs)(u,{gap:6,children:[(0,B.jsxs)(s,{gap:`xs`,justify:`space-between`,children:[(0,B.jsxs)(_,{component:`div`,size:`sm`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[S,y>0&&(0,B.jsxs)(B.Fragment,{children:[` · `,(0,B.jsx)(m,{tone:`danger`,children:k(y,`invalid panel`)})]}),(0,B.jsxs)(_,{span:!0,c:`dimmed`,size:`xs`,children:[` · `,k(x,`stage`),` complete`]})]}),(0,B.jsxs)(v,{component:`button`,variant:`subtle`,color:`gray`,size:`compact-xs`,"aria-expanded":c,"aria-controls":d,onClick:()=>l(e=>!e),children:[`Details`,C.length>4?` (+${C.length-4})`:``]})]}),t&&a&&(0,B.jsx)(`div`,{"data-build-running":!0,children:(0,B.jsx)(p,{state:`loading`,loadingLabel:n||`Analyzing your system`,rows:0})}),(0,B.jsx)(ce,{labels:C.slice(0,4)}),b.map(e=>t?e.split(` · `).filter(e=>!e.endsWith(`: incomplete`)).join(` · `):e).filter(Boolean).map((e,t)=>(0,B.jsx)(_,{size:`xs`,c:`dimmed`,"data-receipt-attention":!0,children:e},t)),f&&(0,B.jsx)(v,{renderRoot:e=>(0,B.jsx)(D,{...e,to:`/dashboards/$dashboardId`,params:{dashboardId:f.id},search:{}}),variant:`subtle`,size:`compact-sm`,color:`gray`,style:{alignSelf:`flex-start`},children:`Open dashboard`}),(0,B.jsx)(i,{expanded:c,id:d,children:(0,B.jsxs)(u,{gap:4,children:[f&&(0,B.jsxs)(_,{size:`xs`,children:[f.label,` `,f.name,` · opens the current dashboard`]}),(0,B.jsx)(_,{size:`xs`,fw:600,children:`Build stages`}),Object.entries(e.stages).map(([n,r])=>(0,B.jsxs)(_,{component:`div`,size:`xs`,children:[(0,B.jsxs)(m,{tone:r.state===`failed`?`danger`:r.state===`complete`?`success`:r.state===`interrupted`?`warning`:`neutral`,children:[ae[n],`: `,t&&r.state===`incomplete`?`in progress`:r.state]}),r.elapsed_ms!==void 0&&(r.state===`complete`||n===`preview`&&e.panels.some(e=>X(e.status)))?` · ${j(r.elapsed_ms)}`:``]},n)),e.save_attempts.map((e,t)=>e.state===`retried`&&(0,B.jsxs)(_,{size:`xs`,c:`dimmed`,children:[`Save attempt `,t+1,`: retried`]},e.call_id)),!!e.context_counts.deploys&&(0,B.jsxs)(_,{size:`xs`,children:[e.context_counts.deploys,` deploys observed`]}),!!e.context_counts.anomalies&&(0,B.jsxs)(_,{size:`xs`,children:[e.context_counts.anomalies,` anomalies observed`]}),(0,B.jsx)(_,{size:`xs`,fw:600,children:`Panel preview`}),e.panels.map(e=>(0,B.jsxs)(_,{component:`div`,size:`xs`,children:[`Preview · `,g(e.id),`: `,(0,B.jsx)(m,{tone:e.status===`ok`?`success`:e.status===`empty`||e.status===`not_run`?`neutral`:`danger`,children:e.status===`ok`?`Ok`:e.status.charAt(0).toUpperCase()+e.status.slice(1)}),X(e.status)&&e.elapsed_ms!==void 0?` · ${j(e.elapsed_ms)}`:``]},e.id)),h&&(0,B.jsx)(_,{size:`xs`,fw:600,children:`Save verification`}),h&&(0,B.jsxs)(_,{size:`xs`,children:[`Save check: `,h.checked?`checked`:`incomplete`,h.checked?` · ${j(h.elapsed_ms)}`:``]}),h?.panels.map(e=>(0,B.jsxs)(_,{component:`div`,size:`xs`,children:[`Save · `,g(e.id),`: `,(0,B.jsx)(m,{tone:e.status===`ok`?`success`:e.status===`empty`||e.status===`not_run`?`neutral`:`danger`,children:e.status===`ok`?`Ok`:e.status.charAt(0).toUpperCase()+e.status.slice(1)}),X(e.status)&&` · ${k(e.rows??0,`row`)}`,X(e.status)&&e.elapsed_ms!==void 0?` · ${j(e.elapsed_ms)}`:``]},e.id)),C.slice(4).map((e,t)=>(0,B.jsx)(_,{size:`xs`,children:e},t)),e.corrections.map((e,t)=>(0,B.jsxs)(_,{size:`xs`,children:[`Fixed `,e.title,`: `,e.message]},t))]})})]})})}var De=(0,G.lazy)(()=>ee(()=>import(`./mcp-app-frame-C1fa0h58.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),Oe=e=>e.tool_result.view.kind===`preset`;function ke(e){let t=new Map,n=new Set,r=[],i=()=>{let e=new Map;for(let t of r){let n=t.content.tool_result.view.key;e.set(n,t)}let i=new Set([...e.values()].map(e=>e.id)),a=[...e.values()].some(e=>Oe(e.content)),o=r.filter(e=>i.has(e.id)).at(-1)?.id;for(let e of r)i.has(e.id)?t.set(e.id,{content:e.content,expanded:Oe(e.content)||!a&&e.id===o}):n.add(e.id);r=[]};for(let t of e)if(t.role===`user`&&i(),t.role===`activity`&&t.activityType===`mcp-app`){let e=Y(t.content);e&&r.push({id:t.id,content:e})}return i(),{views:t,duplicates:n}}function Ae(e,t){return Array.isArray(e)?e.flatMap(e=>{if(!L(e)||typeof e.message!=`string`)return[];let n=typeof e.path==`string`?/^panels\[(\d+)\](?:\.|$)/.exec(e.path)?.[1]:void 0,r=n===void 0?void 0:t?.[Number(n)];return[r&&!e.message.startsWith(r)?`${r}: ${e.message}`:e.message]}):[]}function je(e){let t=new Map,n=new Map,r=new Map,i=`unattributed`;for(let a of e){if(a.role===`user`&&(n.clear(),r.clear(),i=a.id),a.role===`assistant`){i=a.id;for(let e of a.toolCalls??[]){let t=[`create_dashboard`,`replace_dashboard`].includes(e.function.name)?re(e.function.arguments)?.dashboard:void 0,r=L(t)&&Array.isArray(t.panels)?t.panels.map(e=>L(e)&&typeof e.title==`string`?e.title:``):void 0;n.set(e.id,{assistant:i,name:e.function.name,titles:r})}}if(a.role===`tool`){let e=re(a.content);if(!a.error&&!e?.error&&e?.isError!==!0)continue;let o=n.get(a.toolCallId);if(o&&te.has(o.name)&&I(a))continue;let s=L(e?.error)?e?.error:void 0;if(s?.code===`no_data`||s?.code===`unknown_service`)continue;let c=o?.assistant??i,l=r.get(c)??a.id;r.set(c,l);let u=t.get(l)??[],d=typeof s?.message==`string`?s.message:typeof a.error==`string`&&a.error?a.error:`Could not complete this step. Try again.`,f=[`create_dashboard`,`edit_dashboard`,`replace_dashboard`].includes(o?.name??``)&&(s?.code===`invalid_spec`||s?.code===`dashboard_version_conflict`);u.push({name:se(o?.name??``),message:d,details:f?Ae(e?.problems,o?.titles):[],readOnly:s?.code===`answer_only`,rejected:f}),t.set(l,u)}}return t}function Me({failures:e}){let[t,n]=(0,G.useState)({rejected:!1,failed:!1}),r=e.filter(e=>e.rejected),i=e.filter(e=>!e.readOnly&&!e.rejected),a=[{key:`rejected`,items:r,label:`${r.length} ${r.length===1?`draft`:`drafts`} rejected`},{key:`failed`,items:i,label:`${i.length} ${i.length===1?`step`:`steps`} failed`}];return(0,B.jsxs)(d,{"data-chat-anchor":!0,children:[e.some(e=>e.readOnly)&&(0,B.jsx)(_,{size:`sm`,c:`dimmed`,children:`Not saved: Explain is read-only`}),a.map(({key:e,items:r,label:i})=>r.length>0&&(0,B.jsxs)(d,{children:[(0,B.jsxs)(T,{className:`chat-app-toggle`,"aria-expanded":t[e],onClick:()=>n(t=>({...t,[e]:!t[e]})),style:{color:`var(--mantine-color-dimmed)`},children:[(0,B.jsx)(`span`,{className:`chat-app-chevron`,"aria-hidden":`true`,children:t[e]?(0,B.jsx)(P,{size:14}):(0,B.jsx)(J,{size:14})}),(0,B.jsx)(`span`,{className:`chat-app-summary`,children:i})]}),t[e]&&(0,B.jsx)(u,{gap:`xs`,pl:`md`,children:r.flatMap((e,t)=>(e.details.length?e.details:[`${e.name}: ${e.message}`]).map((e,n)=>(0,B.jsx)(_,{size:`sm`,c:`dimmed`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e},`${t}-${n}`)))})]},e))]})}function Ne({view:e}){let[t,n]=(0,G.useState)(e.expanded);(0,G.useEffect)(()=>n(e.expanded),[e.expanded]);let i=e.content.tool_result,a=ye(i),o=[...new Set(i.dashboard.panels.map(e=>e.viz===`timeseries`?`time series`:e.viz.replaceAll(`_`,` `)))].join(`, `),s=i.results.reduce((e,t)=>e+(t.frame?.rows??0),0),c=new Map;for(let e of i.results)e.status!==`ok`&&c.set(e.status,(c.get(e.status)??0)+1);let l=i.dashboard.panels.length>1?Array.from(c,([e,t])=>`${t} ${e}`).join(` · `):c.size?[...c.keys()].join(`, `):`${s} ${s===1?`row`:`rows`}`;return(0,B.jsxs)(r,{"data-chat-app":!0,"data-chat-anchor":!0,withBorder:!0,radius:`md`,style:{overflow:`hidden`},children:[(0,B.jsxs)(T,{className:`chat-app-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,B.jsx)(`span`,{className:`chat-app-chevron`,"aria-hidden":`true`,children:t?(0,B.jsx)(P,{size:14}):(0,B.jsx)(J,{size:14})}),(0,B.jsx)(`span`,{className:`chat-app-summary`,children:[a,o,l].filter(Boolean).join(` · `)})]}),t&&(0,B.jsx)(G.Suspense,{fallback:(0,B.jsx)(p,{state:`loading`,loadingLabel:`Preparing view…`}),children:(0,B.jsx)(De,{content:e.content})})]})}var Pe=[`Summarize system health for the last hour`,`Find the source of elevated errors`,`Map the current service dependencies`,`Show the slowest endpoints`];function Fe(){let{agentAvailable:e,messages:t,messageTimes:n,ready:i,running:a,activity:o,stopped:c,error:l,threadMissing:f,send:m,retry:g,reloadThread:y,newThread:b}=oe(),x=ie(t),C=t.filter(e=>e.role===`user`).at(-1)?.id,{scrollRef:T,contentRef:E,turnRef:D,showJump:ee,jumpToLatest:O}=we(C);if(!e)return(0,B.jsx)(H,{size:`sm`,py:96,children:(0,B.jsx)(r,{withBorder:!0,radius:`md`,p:{base:`xl`,sm:40},children:(0,B.jsxs)(u,{gap:`md`,children:[(0,B.jsx)(_,{fw:700,size:`xs`,tt:`uppercase`,lts:`0.12em`,children:`Optional capability`}),(0,B.jsx)(h,{title:`Chat`,description:`Chat is not configured`}),(0,B.jsx)(_,{c:`dimmed`,children:`Add an AI provider key to enable chat. Telemetry ingest, dashboards, traces, logs, and metrics remain available without it.`}),(0,B.jsx)(v,{component:`a`,href:`/dashboards`,variant:`light`,mt:`sm`,children:`Open dashboards`})]})})});let k=ke(t),A=je(t),j=t.filter(e=>k.duplicates.has(e.id)?!1:e.role===`tool`?A.has(e.id):e.role===`assistant`?!e.toolCalls?.length&&typeof e.content==`string`&&e.content.trim().length>0:e.role===`activity`?e.activityType===`mcp-app`||e.activityType===`agent-outcome`:e.role===`user`),M=t.findIndex(e=>e.id===C),N=t.slice(M+1).some(e=>e.role===`assistant`&&!e.toolCalls?.length&&typeof e.content==`string`&&e.content.length>0),P=t.slice(M+1).filter(e=>e.role===`assistant`&&!e.toolCalls?.length&&typeof e.content==`string`&&e.content.trim().length>0).at(-1),F=[];for(let e of j)(e.role===`user`||F.length===0)&&F.push({id:e.id,messages:[]}),F.at(-1).messages.push(e);F.length===0&&F.push({id:`draft`,messages:[]});let I=e=>A.has(e.id)?(0,B.jsx)(Me,{failures:A.get(e.id)},e.id):(0,B.jsxs)(d,{children:[(0,B.jsx)(Re,{message:e,time:n[e.id],appView:k.views.get(e.id)}),x.has(e.id)&&(0,B.jsx)(d,{mt:`sm`,children:(0,B.jsx)(Ee,{receipt:x.get(e.id),running:a&&e.id===C,awaitingAnswer:!N,activity:o})})]},e.id);return(0,B.jsxs)(d,{className:`chat-pane`,children:[(0,B.jsx)(H,{size:880,w:`100%`,px:{base:`md`,sm:`xl`},py:`md`,children:(0,B.jsx)(h,{title:`Chat`,description:`Investigate your telemetry with Pitot.`})}),(0,B.jsxs)(d,{className:`chat-viewport`,children:[(0,B.jsx)(d,{className:`chat-scroll`,ref:T,tabIndex:0,role:`log`,"aria-label":`Conversation`,children:(0,B.jsxs)(H,{size:880,px:{base:`md`,sm:`xl`},py:`lg`,ref:E,children:[f&&(0,B.jsx)(w,{tone:`warning`,title:`This chat no longer exists`,children:(0,B.jsxs)(s,{justify:`space-between`,children:[(0,B.jsx)(_,{size:`sm`,children:`It was deleted, or the link is wrong.`}),(0,B.jsx)(v,{size:`compact-sm`,variant:`light`,onClick:b,children:`New chat`})]})}),!f&&!i&&l&&(0,B.jsx)(Z,{message:l,onRetry:y,onNewThread:b}),!f&&!i&&!l&&(0,B.jsx)(p,{state:`loading`,loadingLabel:`Loading chat`,rows:5}),!f&&i&&(0,B.jsxs)(B.Fragment,{children:[j.length===0&&(0,B.jsx)(Le,{onSelect:m}),(0,B.jsx)(u,{gap:`lg`,children:F.map((e,t)=>(0,B.jsxs)(u,{gap:`lg`,ref:e.id===C?D:void 0,"data-chat-turn":e.id===C?C:void 0,children:[e.messages.filter(e=>e.id!==P?.id).map(I),t===F.length-1&&(0,B.jsxs)(B.Fragment,{children:[P&&(0,B.jsx)(d,{"data-answer-position":!0,children:(0,B.jsx)(Re,{message:P,time:n[P.id]})},`answer-${C??`draft`}`),a&&!N&&!x.has(C??``)&&(0,B.jsx)(p,{state:`loading`,loadingLabel:o||`Analyzing your system`,rows:0}),c&&(0,B.jsx)(_,{c:`dimmed`,size:`sm`,children:`Stopped`}),l&&(0,B.jsx)(Z,{message:l,onRetry:g})]})]},e.id))})]})]})}),ee&&(0,B.jsx)(R,{label:`Jump to latest`,children:(0,B.jsx)(S,{className:`chat-jump`,variant:`default`,size:36,"aria-label":`Jump to latest`,onClick:O,children:(0,B.jsx)(me,{size:18,"aria-hidden":`true`})})})]}),!f&&(0,B.jsx)(Ie,{})]})}function Z({message:e,onRetry:t,onNewThread:n}){return(0,B.jsx)(w,{tone:`danger`,title:`Something went wrong`,children:(0,B.jsxs)(s,{justify:`space-between`,gap:`sm`,wrap:`nowrap`,children:[(0,B.jsx)(_,{size:`sm`,children:e}),(0,B.jsxs)(s,{gap:`xs`,wrap:`nowrap`,children:[n&&(0,B.jsx)(v,{size:`compact-sm`,variant:`subtle`,color:`bad`,onClick:n,children:`New chat`}),(0,B.jsx)(v,{size:`compact-sm`,variant:`light`,color:`bad`,onClick:t,children:`Retry`})]})]})})}function Ie(){let{input:e,setInput:t,inputRef:n,submit:i,send:a,stop:o,ready:c,running:l}=oe();return(0,B.jsx)(d,{className:`chat-composer`,children:(0,B.jsxs)(H,{size:880,px:{base:`md`,sm:`xl`},children:[(0,B.jsx)(r,{component:`form`,onSubmit:i,className:`chat-composer-field`,style:{borderColor:`var(--composer-border, var(--labstack-control-border))`},withBorder:!0,radius:`sm`,py:6,pl:`lg`,pr:6,children:(0,B.jsxs)(s,{align:`flex-end`,gap:`xs`,wrap:`nowrap`,children:[(0,B.jsx)(M,{ref:n,"aria-label":`Message Pitot`,value:e,onChange:e=>t(e.currentTarget.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),a(e))},placeholder:l?`Pitot is working…`:`Ask about health, errors, or latency…`,disabled:!c,autosize:!0,minRows:1,maxRows:8,variant:`unstyled`,flex:1}),l?(0,B.jsx)(R,{label:`Stop`,children:(0,B.jsx)(S,{type:`button`,variant:`default`,size:40,"aria-label":`Stop`,onClick:o,children:(0,B.jsx)(ve,{size:16,weight:`fill`})})}):(0,B.jsx)(S,{type:`submit`,variant:`filled`,size:40,disabled:!e.trim()||!c,"aria-label":`Send message`,children:(0,B.jsx)(ge,{size:17,weight:`fill`})})]})}),(0,B.jsx)(_,{c:`dimmed`,size:`xs`,ta:`center`,mt:6,children:`Enter to send, Shift+Enter for a new line`})]})})}function Le({onSelect:e}){return(0,B.jsxs)(u,{align:`center`,gap:`md`,pt:{base:32,sm:88},pb:`xl`,ta:`center`,children:[(0,B.jsx)(y,{size:`large`}),(0,B.jsx)(l,{order:2,fz:24,fw:500,lh:1.25,maw:560,children:`What do you want to know about your system?`}),(0,B.jsx)(s,{justify:`center`,gap:`xs`,mt:`xs`,maw:b.prose,children:Pe.map(t=>(0,B.jsx)(v,{variant:`default`,size:`sm`,onClick:()=>void e(t),children:t},t))})]})}function Re({message:e,time:t,appView:n}){if(e.role===`activity`)return e.activityType===`agent-outcome`&&e.content&&typeof e.content==`object`&&`message`in e.content&&typeof e.content.message==`string`?`status`in e.content&&e.content.status===`stopped`?(0,B.jsx)(_,{c:`dimmed`,size:`sm`,"data-chat-anchor":!0,children:e.content.message}):(0,B.jsx)(d,{"data-chat-anchor":!0,children:(0,B.jsx)(w,{tone:`danger`,title:`Something went wrong`,children:e.content.message})}):e.activityType===`mcp-app`?n?(0,B.jsx)(Ne,{view:n}):(0,B.jsx)(d,{"data-chat-anchor":!0,children:(0,B.jsx)(w,{tone:`danger`,children:`This view could not be loaded. Please try again.`})}):null;if(e.role===`assistant`&&e.toolCalls?.length)return null;let i=typeof e.content==`string`?e.content:JSON.stringify(e.content);if(!i&&e.role===`assistant`)return null;let a=e.role===`user`,o=t?new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(new Date(t)):``;return(0,B.jsxs)(d,{className:`chat-message`,"data-chat-anchor":!0,"data-role":a?`user`:`assistant`,children:[a?(0,B.jsx)(r,{radius:`md`,px:`md`,py:`sm`,bg:`var(--labstack-inset)`,maw:`70%`,ml:`auto`,w:`fit-content`,children:(0,B.jsx)(_,{style:{whiteSpace:`pre-wrap`},children:i})}):(0,B.jsx)(W,{className:`chat-markdown`,children:(0,B.jsx)(N,{remarkPlugins:[F,ze],components:Be,children:i})}),(o||!a)&&(0,B.jsxs)(s,{className:`chat-message-meta`,gap:6,justify:a?`flex-end`:`flex-start`,mt:4,h:24,children:[o&&t&&(0,B.jsx)(_,{c:`dimmed`,size:`xs`,title:A(t),children:o}),!a&&(0,B.jsx)(Q,{text:i,label:`Copy message`})]})]})}function Q({text:e,label:t}){let{state:n,copy:r}=Te();return(0,B.jsx)(R,{label:n===`failed`?`Could not copy`:n===`copied`?`Copied`:t,children:(0,B.jsx)(S,{variant:`subtle`,color:`gray`,size:`sm`,"aria-label":t,"data-state":n===`idle`?void 0:n,onClick:()=>r(e),children:n===`copied`?(0,B.jsx)(g,{size:13,weight:`bold`}):(0,B.jsx)(C,{size:13})})})}function ze(){return e=>{let t=[],n=e=>{if(e.type===`table`&&e.children){let t=e=>e.value??e.children?.map(t).join(``)??``,n=e.children.slice(1);e.align=(e.children[0]?.children??[]).map((r,i)=>n.length&&n.every(e=>/^[-+−]?\d[\d,.]*(?:%|\s?(?:ms|s|K|M))?$/.test(t(e.children?.[i]??{type:`text`}).trim()))?`right`:e.align?.[i]??null)}if(e.type===`heading`&&e.depth!==void 0){let n=e.depth;for(;t.length&&t.at(-1)>=n;)t.pop();t.push(n),e.depth=Math.min(6,t.length+1)}e.children?.forEach(n)};n(e)}}var Be={table:({children:e})=>(0,B.jsx)(d,{className:`chat-table`,children:(0,B.jsx)(O,{stickyHeader:!0,highlightOnHover:!0,withTableBorder:!0,verticalSpacing:`xs`,fz:`sm`,children:e})}),thead:({children:e})=>(0,B.jsx)(O.Thead,{children:e}),tbody:({children:e})=>(0,B.jsx)(O.Tbody,{children:e}),tr:({children:e})=>(0,B.jsx)(O.Tr,{children:e}),th:({children:e,style:t})=>(0,B.jsx)(O.Th,{style:t,children:e}),td:({children:e,style:t})=>(0,B.jsx)(O.Td,{style:t,ta:typeof e==`string`&&/^[-+−]?\d[\d,.]*(?:%|\s?(?:ms|s|K|M))?$/.test(e.trim())?`right`:void 0,ff:typeof e==`string`&&/^[-+−]?\d/.test(e.trim())?`monospace`:void 0,children:e}),pre:({children:e})=>(0,B.jsx)(Ve,{children:e}),a:({href:e,children:t})=>(0,B.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t})};function Ve({children:e}){let t=$(e);return(0,B.jsxs)(d,{className:`chat-code`,pos:`relative`,children:[(0,B.jsx)(d,{className:`chat-code-actions`,pos:`absolute`,top:6,right:6,children:(0,B.jsx)(Q,{text:t,label:`Copy code`})}),(0,B.jsx)(`pre`,{children:e})]})}function $(e){return typeof e==`string`?e:Array.isArray(e)?e.map($).join(``):e&&typeof e==`object`&&`props`in e?$(e.props.children):``}export{Y as n,Fe as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat._threadId-D5uvUdcn.js b/internal/ui/dist/assets/chat._threadId-D5uvUdcn.js deleted file mode 100644 index 282ccdb8b..000000000 --- a/internal/ui/dist/assets/chat._threadId-D5uvUdcn.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./chat-DMtvX_Pa.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat._threadId-DpKCqGxd.js b/internal/ui/dist/assets/chat._threadId-DpKCqGxd.js new file mode 100644 index 000000000..d0cee006c --- /dev/null +++ b/internal/ui/dist/assets/chat._threadId-DpKCqGxd.js @@ -0,0 +1 @@ +import{t as e}from"./chat-C1c_TZwI.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat.index-D5uvUdcn.js b/internal/ui/dist/assets/chat.index-D5uvUdcn.js deleted file mode 100644 index 282ccdb8b..000000000 --- a/internal/ui/dist/assets/chat.index-D5uvUdcn.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./chat-DMtvX_Pa.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat.index-DpKCqGxd.js b/internal/ui/dist/assets/chat.index-DpKCqGxd.js new file mode 100644 index 000000000..d0cee006c --- /dev/null +++ b/internal/ui/dist/assets/chat.index-DpKCqGxd.js @@ -0,0 +1 @@ +import{t as e}from"./chat-C1c_TZwI.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/dashboards._dashboardId-C_KLDd8s.js b/internal/ui/dist/assets/dashboards._dashboardId-DVwJCShe.js similarity index 63% rename from internal/ui/dist/assets/dashboards._dashboardId-C_KLDd8s.js rename to internal/ui/dist/assets/dashboards._dashboardId-DVwJCShe.js index 2a7be1cf6..17eff5140 100644 --- a/internal/ui/dist/assets/dashboards._dashboardId-C_KLDd8s.js +++ b/internal/ui/dist/assets/dashboards._dashboardId-DVwJCShe.js @@ -1 +1 @@ -import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{i as n,s as r}from"./search-D_K9J6yO.js";import{t as i}from"./page-BABqeqdg.js";import{t as a}from"./index-C1Pd14SU.js";var o=e();function s(){let{dashboardId:e}=a.useParams(),s=n(a.useSearch()),c=t(),l=(t,n,i)=>void c({to:`/dashboards/$dashboardId`,params:{dashboardId:t},search:r(n),replace:i,resetScroll:t!==e});return(0,o.jsx)(i,{dashboardId:e,search:s,onSearch:(t,n)=>l(e,t,n),onOpen:(e,t)=>l(e,{},t)})}export{s as component}; \ No newline at end of file +import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{i as n,s as r}from"./search-P7VEnlsD.js";import{t as i}from"./page-DQgl1M0H.js";import{t as a}from"./index-D7FG-NN3.js";var o=e();function s(){let{dashboardId:e}=a.useParams(),s=n(a.useSearch()),c=t(),l=(t,n,i)=>void c({to:`/dashboards/$dashboardId`,params:{dashboardId:t},search:r(n),replace:i,resetScroll:t!==e});return(0,o.jsx)(i,{dashboardId:e,search:s,onSearch:(t,n)=>l(e,t,n),onOpen:(e,t)=>l(e,{},t)})}export{s as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/dashboards.index-N7UkPeK5.js b/internal/ui/dist/assets/dashboards.index-BXpuj_Hg.js similarity index 56% rename from internal/ui/dist/assets/dashboards.index-N7UkPeK5.js rename to internal/ui/dist/assets/dashboards.index-BXpuj_Hg.js index dabb3fe73..0bc09633d 100644 --- a/internal/ui/dist/assets/dashboards.index-N7UkPeK5.js +++ b/internal/ui/dist/assets/dashboards.index-BXpuj_Hg.js @@ -1 +1 @@ -import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{i as n,s as r}from"./search-D_K9J6yO.js";import{t as i}from"./page-BABqeqdg.js";import{n as a}from"./index-C1Pd14SU.js";var o=e();function s(){let e=n(a.useSearch()),s=t();return(0,o.jsx)(i,{search:e,onSearch:()=>void 0,onOpen:(t,n)=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:t},search:r(e),replace:n})})}export{s as component}; \ No newline at end of file +import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{i as n,s as r}from"./search-P7VEnlsD.js";import{t as i}from"./page-DQgl1M0H.js";import{n as a}from"./index-D7FG-NN3.js";var o=e();function s(){let e=n(a.useSearch()),s=t();return(0,o.jsx)(i,{search:e,onSearch:()=>void 0,onOpen:(t,n)=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:t},search:r(e),replace:n})})}export{s as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/explore-D4KpDh3K.js b/internal/ui/dist/assets/explore-BocWcl6s.js similarity index 57% rename from internal/ui/dist/assets/explore-D4KpDh3K.js rename to internal/ui/dist/assets/explore-BocWcl6s.js index ebc7c5c6f..a2b412f16 100644 --- a/internal/ui/dist/assets/explore-D4KpDh3K.js +++ b/internal/ui/dist/assets/explore-BocWcl6s.js @@ -1 +1 @@ -import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{i as n,r}from"./search-CDra9nG2.js";import{a as i}from"./index-C1Pd14SU.js";import{t as a}from"./page-1Rod7OFH.js";var o=e();function s(){let e=r(i.useSearch()),s=t();return(0,o.jsx)(a,{search:e,onSearch:(e,t)=>void s({to:`/explore`,search:n(e),replace:t}),onSaved:e=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:e}})})}export{s as component}; \ No newline at end of file +import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{i as n,r}from"./search-pvW8SUhM.js";import{a as i}from"./index-D7FG-NN3.js";import{t as a}from"./page-DSor7wHc.js";var o=e();function s(){let e=r(i.useSearch()),s=t();return(0,o.jsx)(a,{search:e,onSearch:(e,t)=>void s({to:`/explore`,search:n(e),replace:t}),onSaved:e=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:e}})})}export{s as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/index-C1Pd14SU.js b/internal/ui/dist/assets/index-D7FG-NN3.js similarity index 99% rename from internal/ui/dist/assets/index-C1Pd14SU.js rename to internal/ui/dist/assets/index-D7FG-NN3.js index dc32a4589..4d78094bc 100644 --- a/internal/ui/dist/assets/index-C1Pd14SU.js +++ b/internal/ui/dist/assets/index-D7FG-NN3.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/new-dashboard-D58ui2mw.js","assets/useRouter-ByJ6_rwb.js","assets/brand-D6fP-cLS.js","assets/search-D_K9J6yO.js","assets/noop-mXPS5vjY.js","assets/format-BZjbsxwM.js","assets/auth-DWqIkMZS.js","assets/useNavigate-B1zgPEUp.js","assets/useQuery-BLTYSIvG.js","assets/page-1Rod7OFH.js","assets/toolbar-DV46cPGs.js","assets/theme-DXTVNXHm.js","assets/CopyButton-BIdC6qm1.js","assets/Table-D4ZwUno3.js","assets/live-data-meta-CUyw2snU.js","assets/lib-BLIvzI-_.js","assets/loading-skeleton-D1hXpfUI.js","assets/NumberInput-CixyOph4.js","assets/search-CDra9nG2.js","assets/save-dialog-Chbkq2Xp.js","assets/discard-NZfxCIcK.js","assets/routes-D2AdaqvY.js","assets/alerts-CYKuszTJ.js","assets/Textarea-r3wuKNbO.js","assets/useMutation-B1CTivyp.js","assets/explore-D4KpDh3K.js","assets/logs-DQVfH3k6.js","assets/search-page-uYBxylji.js","assets/settings-_0QC4d6a.js","assets/settings-BhplbQY-.js","assets/traces-DQY6WBcG.js","assets/chat.index-D5uvUdcn.js","assets/chat-DMtvX_Pa.js","assets/preload-helper-DJZNfKNH.js","assets/dashboard-change-chips-BJ-GZE9U.js","assets/chat._threadId-D5uvUdcn.js","assets/dashboards.index-N7UkPeK5.js","assets/page-BABqeqdg.js","assets/dashboards._dashboardId-C_KLDd8s.js","assets/settings_.ingest-7LDcHtKJ.js"])))=>i.map(i=>d[i]); -import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./useRouter-ByJ6_rwb.js";import{Bt as s,C as c,Cn as l,D as u,Dt as d,Et as f,Ft as p,G as m,Gt as h,Ht as g,It as _,Kt as v,Lt as y,Mt as b,Nt as x,Qt as ee,Rt as S,Sn as C,T as te,Tt as w,Ut as ne,Vt as re,W as ie,Wt as ae,X as oe,Xt as se,Yt as ce,Z as le,Zt as ue,_t as de,a as fe,at as pe,bn as T,bt as me,cn as he,ct as ge,dn as _e,dt as ve,ft as ye,gn as be,hn as xe,ht as Se,in as Ce,it as E,j as D,k as we,kt as Te,lt as Ee,mn as De,mt as Oe,nn as ke,nt as O,ot as Ae,pn as je,pt as Me,q as Ne,qt as Pe,rn as Fe,rt as Ie,s as Le,sn as Re,st as ze,t as Be,tt as Ve,u as He,ut as Ue,vt as We,w as Ge,wt as Ke,x as qe,xn as Je,xt as Ye,yn as Xe,zt as Ze}from"./brand-D6fP-cLS.js";import{i as Qe,n as $e,t as et}from"./useNavigate-B1zgPEUp.js";import{a as tt,d as nt,g as rt,i as it,m as at,o as ot,t as st,u as ct}from"./preload-helper-DJZNfKNH.js";import{a as lt,i as ut,n as dt,r as ft,t as pt}from"./lazyRouteComponent-DiWTNBZT.js";import{_ as mt,a as ht,c as gt,d as _t,f as vt,g as yt,h as bt,m as xt,n as St,o as Ct,p as wt,r as Tt,s as Et,u as Dt}from"./theme-DXTVNXHm.js";import{A as Ot,c as kt,i as At,k as jt,l as Mt,m as Nt,p as Pt,s as Ft,y as It}from"./search-D_K9J6yO.js";import{t as Lt}from"./noop-mXPS5vjY.js";import{c as Rt,i as zt,l as Bt,o as Vt,s as Ht,t as Ut}from"./format-BZjbsxwM.js";import{a as Wt,i as Gt,n as Kt,o as qt,r as Jt,t as Yt}from"./auth-DWqIkMZS.js";import{C as Xt,T as Zt,_ as Qt,a as $t,b as en,c as tn,d as nn,f as rn,g as an,h as on,i as sn,l as cn,m as ln,n as un,o as dn,p as fn,r as pn,s as mn,t as hn,u as gn,v as _n,w as vn,y as yn}from"./useQuery-BLTYSIvG.js";import{i as bn,r as xn}from"./search-CDra9nG2.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Sn=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,ee||(ee=!0,re());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}}var ee=!1,S=-1,C=5,te=-1;function w(){return g?!0:!(e.unstable_now()-tet&&w());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():ee=!1}}}var re;if(typeof y==`function`)re=function(){y(ne)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=ne,re=function(){ae.postMessage(null)}}else re=function(){_(ne,0)};function oe(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,re()))),r},e.unstable_shouldYield=w,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Cn=e(((e,t)=>{t.exports=Sn()})),wn=e((e=>{var n=Cn(),r=t(),i=l();function a(e){var t=`https://react.dev/errors/`+e;if(1Ee||(e.current=Te[Ee],Te[Ee]=null,Ee--)}function ke(e,t){Ee++,Te[Ee]=e.current,e.current=t}var O=De(null),Ae=De(null),je=De(null),Me=De(null);function Ne(e,t){switch(ke(je,t),ke(Ae,e),ke(O,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Sp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Sp(t),e=Cp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Oe(O),ke(O,e)}function Pe(){Oe(O),Oe(Ae),Oe(je)}function Fe(e){var t=e.memoizedState;t!==null&&(yh._currentValue=t.memoizedState,ke(Me,e)),t=O.current;var n=Cp(t,e.type);t!==n&&(ke(Ae,e),ke(O,n))}function Ie(e){Ae.current===e&&(Oe(O),Oe(Ae)),Me.current===e&&(Oe(Me),yh._currentValue=we)}var Le,Re;function ze(e){if(Le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Le=t&&t[1]||``,Re=-1i.map(i=>d[i]); +import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./useRouter-ByJ6_rwb.js";import{Bt as s,C as c,Cn as l,D as u,Dt as d,Et as f,Ft as p,G as m,Gt as h,Ht as g,It as _,Kt as v,Lt as y,Mt as b,Nt as x,Qt as ee,Rt as S,Sn as C,T as te,Tt as w,Ut as ne,Vt as re,W as ie,Wt as ae,X as oe,Xt as se,Yt as ce,Z as le,Zt as ue,_t as de,a as fe,at as pe,bn as T,bt as me,cn as he,ct as ge,dn as _e,dt as ve,ft as ye,gn as be,hn as xe,ht as Se,in as Ce,it as E,j as D,k as we,kt as Te,lt as Ee,mn as De,mt as Oe,nn as ke,nt as O,ot as Ae,pn as je,pt as Me,q as Ne,qt as Pe,rn as Fe,rt as Ie,s as Le,sn as Re,st as ze,t as Be,tt as Ve,u as He,ut as Ue,vt as We,w as Ge,wt as Ke,x as qe,xn as Je,xt as Ye,yn as Xe,zt as Ze}from"./brand-D6fP-cLS.js";import{i as Qe,n as $e,t as et}from"./useNavigate-B1zgPEUp.js";import{a as tt,d as nt,g as rt,i as it,m as at,o as ot,t as st,u as ct}from"./preload-helper-DJZNfKNH.js";import{a as lt,i as ut,n as dt,r as ft,t as pt}from"./lazyRouteComponent-DiWTNBZT.js";import{_ as mt,a as ht,c as gt,d as _t,f as vt,g as yt,h as bt,m as xt,n as St,o as Ct,p as wt,r as Tt,s as Et,u as Dt}from"./theme-DXTVNXHm.js";import{A as Ot,c as kt,i as At,k as jt,l as Mt,m as Nt,p as Pt,s as Ft,y as It}from"./search-P7VEnlsD.js";import{t as Lt}from"./noop-mXPS5vjY.js";import{c as Rt,i as zt,l as Bt,o as Vt,s as Ht,t as Ut}from"./format-BZjbsxwM.js";import{a as Wt,i as Gt,n as Kt,o as qt,r as Jt,t as Yt}from"./auth-DcVParCH.js";import{C as Xt,T as Zt,_ as Qt,a as $t,b as en,c as tn,d as nn,f as rn,g as an,h as on,i as sn,l as cn,m as ln,n as un,o as dn,p as fn,r as pn,s as mn,t as hn,u as gn,v as _n,w as vn,y as yn}from"./useQuery-BLTYSIvG.js";import{i as bn,r as xn}from"./search-pvW8SUhM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Sn=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,ee||(ee=!0,re());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}}var ee=!1,S=-1,C=5,te=-1;function w(){return g?!0:!(e.unstable_now()-tet&&w());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():ee=!1}}}var re;if(typeof y==`function`)re=function(){y(ne)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=ne,re=function(){ae.postMessage(null)}}else re=function(){_(ne,0)};function oe(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,re()))),r},e.unstable_shouldYield=w,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Cn=e(((e,t)=>{t.exports=Sn()})),wn=e((e=>{var n=Cn(),r=t(),i=l();function a(e){var t=`https://react.dev/errors/`+e;if(1Ee||(e.current=Te[Ee],Te[Ee]=null,Ee--)}function ke(e,t){Ee++,Te[Ee]=e.current,e.current=t}var O=De(null),Ae=De(null),je=De(null),Me=De(null);function Ne(e,t){switch(ke(je,t),ke(Ae,e),ke(O,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Sp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Sp(t),e=Cp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Oe(O),ke(O,e)}function Pe(){Oe(O),Oe(Ae),Oe(je)}function Fe(e){var t=e.memoizedState;t!==null&&(yh._currentValue=t.memoizedState,ke(Me,e)),t=O.current;var n=Cp(t,e.type);t!==n&&(ke(Ae,e),ke(O,n))}function Ie(e){Ae.current===e&&(Oe(O),Oe(Ae)),Me.current===e&&(Oe(Me),yh._currentValue=we)}var Le,Re;function ze(e){if(Le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Le=t&&t[1]||``,Re=-1)`:-11&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function $p(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;$p(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var em=new Set([`type`,`properties`,`required`,`additionalProperties`]),tm=[`oneOf`,`anyOf`];function nm(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function rm(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!em.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??nm(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Js(n,r,e.length===1?e[0]:rm(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=nm(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function im(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of em)if(t in e)return;let n=t.filter(e=>tm.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=rm(t);else{let e=n[0],i=tm.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>rm([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,qp(e,r))}function am(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):qp(i,s),qp(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())$p(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])im(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}qp(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Js(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:cm(t,`input`,e.processors),output:cm(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function om(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return om(r.element,n);if(r.type===`set`)return om(r.valueType,n);if(r.type===`lazy`)return om(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return om(r.innerType,n);if(r.type===`intersection`)return om(r.left,n)||om(r.right,n);if(r.type===`record`||r.type===`map`)return om(r.keyType,n)||om(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:om(r.in,n)||om(r.out,n);if(r.type===`object`){for(let e in r.shape)if(om(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(om(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(om(e,n))return!0;return!!(r.rest&&om(r.rest,n))}return!1}var sm=(e,t={})=>n=>{let r=Jp({...n,processors:t});return Xp(e,r),Qp(r,e),am(r,e)},cm=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Jp({...i??{},target:a,io:t,processors:n});return Xp(e,o),Qp(o,e),am(o,e)},lm=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},um=(e,t,n)=>{(e[t]===void 0||n{lm(e,`minimum`,t),um(e,`maximum`,t)},fm=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},pm=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},mm=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},hm=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},gm=(e,t)=>lm(e,`minimum`,t.minimum),_m=(e,t)=>um(e,`maximum`,t.maximum),vm=e=>(t,n)=>{hm(t,n.format);let[r,i]=e[n.format];lm(t,`minimum`,r),um(t,`maximum`,i)},ym={greater_than:(e,t)=>lm(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>um(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>fm(e,t.value),number_format:vm(mc),bigint_format:vm(hc),min_length:gm,max_length:_m,length_equals:(e,t)=>dm(e,t.length),min_size:gm,max_size:_m,size_equals:(e,t)=>dm(e,t.size),string_format:(e,t)=>{hm(e,t.format),t.pattern&&pm(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>mm(e,t.mime)};function bm(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)ym[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&lm(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&lm(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&um(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&um(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&fm(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&mm(t,i.mime);for(let e of i.patterns??[])pm(t,e);return t}var xm={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Sm=new Map([[md,Xl],[gd,Zl]]),Cm=e=>Sm.get(e)??e,wm=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=bm(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=xm[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Cm);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Tm=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=bm(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Yp(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Em=(e,t,n,r)=>{n.type=`boolean`},Dm=(e,t,n,r)=>{Yp(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},Om=(e,t,n,r)=>{Yp(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},km=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Am=(e,t,n,r)=>{Yp(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},jm=(e,t,n,r)=>{Yp(e,t,n,r,`Void cannot be represented in JSON Schema`)},Mm=(e,t,n,r)=>{n.not={}},Nm=(e,t,n,r)=>{},Pm=(e,t,n,r)=>{},Fm=(e,t,n,r)=>{Yp(e,t,n,r,`Date cannot be represented in JSON Schema`)},Im=(e,t,n,r)=>{let i=e._zod.def,a=Rs(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Lm=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Yp(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Yp(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Rm=(e,t,n,r)=>{Yp(e,t,n,r,`NaN cannot be represented in JSON Schema`)},zm=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},Bm=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=bm(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},Vm=(e,t,n,r)=>{n.type=`boolean`},Hm=(e,t,n,r)=>{Yp(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Um=(e,t,n,r)=>{Yp(e,t,n,r,`Function types cannot be represented in JSON Schema`)},Wm=(e,t,n,r)=>{Yp(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Gm=(e,t,n,r)=>{Yp(e,t,n,r,`Map cannot be represented in JSON Schema`)},Km=(e,t,n,r)=>{Yp(e,t,n,r,`Set cannot be represented in JSON Schema`)},qm=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=bm(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Xp(a.element,t,{...r,path:[...r.path,`items`]})};function Jm(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Jm(t.out):t.type===`catch`?Jm(t.innerType):e._zod.optin}var Ym=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Yp(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Js(i.properties,e,Xp(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Jm(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Xp(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Xm=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Xp(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Zm=(e,t,n,r)=>{let i=e._zod.def,a=Xp(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Xp(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Qm=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Xp(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Xp(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?Jm(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=bm(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function $m(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=$m(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>$m(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?cu:su).source),p):p}var eh=new WeakMap;function th(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of eh.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=$m(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var nh=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=bm(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Xp(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Js(i.patternProperties,Cm(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Xp(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=eh.get(t);n||(n=[],eh.set(t,n),t.deferred.push(()=>th(t))),n.push(e)}i.additionalProperties=Xp(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Jm(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},rh=(e,t,n,r)=>{let i=e._zod.def,a=Xp(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ih=(e,t,n,r)=>{let i=e._zod.def;Xp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ah=Symbol();function oh(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Yp(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ah):JSON.parse(o)}var sh=(e,t,n,r)=>{let i=e._zod.def;Xp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=oh(i.defaultValue,e,t,n,r);o!==ah&&(n.default=o)},ch=(e,t,n,r)=>{let i=e._zod.def;Xp(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=oh(i.defaultValue,e,t,n,r);o!==ah&&(n._prefault=o)},lh=(e,t,n,r)=>{let i=e._zod.def;Xp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Yp(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},uh=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Xp(o,t,r);let s=t.seen.get(e);s.ref=o},dh=(e,t,n,r)=>{let i=e._zod.def;Xp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},fh=(e,t,n,r)=>{let i=e._zod.def;Xp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ph=(e,t,n,r)=>{let i=e._zod.def;Xp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},mh=(e,t,n,r)=>{let i=e._zod.innerType;Xp(i,t,r);let a=t.seen.get(e);a.ref=i},hh={string:wm,number:Tm,boolean:Em,bigint:Dm,symbol:Om,null:km,undefined:Am,void:jm,never:Mm,any:Nm,unknown:Pm,date:Fm,enum:Im,literal:Lm,nan:Rm,template_literal:zm,file:Bm,success:Vm,custom:Hm,function:Um,transform:Wm,map:Gm,set:Km,array:qm,object:Ym,union:Xm,intersection:Zm,tuple:Qm,record:nh,nullable:rh,nonoptional:ih,default:sh,prefault:ch,catch:lh,pipe:uh,readonly:dh,promise:fh,optional:ph,lazy:mh};function gh(e,t){if(`_idmap`in e){let n=e,r=Jp({...t,processors:hh}),i={};for(let e of n._idmap.entries()){let[t,n]=e;Xp(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Qp(r,n),Js(a,t,am(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Jp({...t,processors:hh});return Xp(e,n),Qp(n,e),am(n,e)}var _h=new WeakSet([Object.prototype,Error.prototype]);function vh(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var yh=R(`ZodError`,(e,t)=>{ul.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);_h.has(n)||(_h.add(n),vh(n,`format`,e=>t=>pl(e,t)),vh(n,`flatten`,e=>t=>fl(e,t)),vh(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Bs,2)}),vh(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Bs,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),bh=hl(yh),xh=gl(yh),Sh=_l(yh),Ch=yl(yh),wh=Tl(yh),Th=El(yh),Eh=Dl(yh),Dh=Ol(yh),Oh=kl(yh),kh=Al(yh),Ah=jl(yh),jh=Ml(yh);function Mh(){nl.localeError||rl(Ff())}function Nh(){nl.memoizer||rl({memoizer:Mf()})}var Ph=R(`ZodType`,(e,t)=>(Mh(),Pu.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(tc(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return dc(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(l_(e,t))},superRefine(e,t){return this.check(u_(e,t))},overwrite(e){return this.check(Ip(e))},optional(){return Vg(this)},exactOptional(){return Ug(this)},nullable(){return Gg(this)},nullish(){return Vg(Gg(this))},nonoptional(e){return Zg(this,e)},array(){return wg(this)},or(e){return Og([this,e])},and(e){return Mg(this,e)},transform(e){return t_(this,zg(e))},default(e){return qg(this,e)},prefault(e){return Yg(this,e)},catch(e){return $g(this,e)},pipe(e){return t_(this,e)},readonly(){return i_(this)},describe(e){let t=this.clone();return zf.add(t,{description:e}),t},meta(...e){if(e.length===0)return zf.get(this);let t=this.clone();return zf.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return zc(this,`~standard`,{...Lu(this),jsonSchema:{input:cm(this,`input`),output:cm(this,`output`)}})},set"~standard"(e){Rc(this,`~standard`,e)},parse:function e(t,n){return bh(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await xh(this,t,n,{callee:e})},safeParse(e,t){return Sh(this,e,t)},async safeParseAsync(e,t){return Ch(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Rc(this,`spa`,e)},validate(e,t){return Sl(this,e,t)},validateAsync(e,t){return wl(this,e,t)},encode:function e(t,n){return wh(this,t,n,{callee:e})},decode:function e(t,n){return Th(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Eh(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Dh(this,t,n,{callee:e})},safeEncode(e,t){return Oh(this,e,t)},safeDecode(e,t){return kh(this,e,t)},async safeEncodeAsync(e,t){return Ah(this,e,t)},async safeDecodeAsync(e,t){return jh(this,e,t)},toJSONSchema(e){return sm(this,{})(e)},get description(){return zf.get(this)?.description},get _def(){return this._zod.def}}),Fh=R(`_ZodString`,(e,t)=>{Ru.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wm(e,t,n,r)},Bc({format:e=>bm(e).format??null,minLength:e=>bm(e).minimum??null,maxLength:e=>bm(e).maximum??null},{regex(...e){return this.check(Ap(...e))},includes(...e){return this.check(Np(...e))},startsWith(...e){return this.check(Pp(...e))},endsWith(...e){return this.check(Fp(...e))},min(...e){return this.check(Op(...e))},max(...e){return this.check(Dp(...e))},length(...e){return this.check(kp(...e))},nonempty(...e){return this.check(Op(1,...e))},lowercase(e){return this.check(jp(e))},uppercase(e){return this.check(Mp(e))},trim(){return this.check(Rp())},normalize(...e){return this.check(Lp(...e))},toLowerCase(){return this.check(zp())},toUpperCase(){return this.check(Bp())},slugify(){return this.check(Vp())}})),Ih=R(`ZodString`,(e,t)=>{Ru.init(e,t),Fh.init(e,t)},{email(e){return this.check(Hf(Hh,e))},url(e){return this.check(Jf(Kh,e))},jwt(e){return this.check(cp(cg,e))},emoji(e){return this.check(Yf(Jh,e))},guid(e){return this.check(Uf(Wh,e))},uuid(e){return this.check(Wf(Gh,e))},uuidv4(e){return this.check(Gf(Gh,e))},uuidv6(e){return this.check(Kf(Gh,e))},uuidv7(e){return this.check(qf(Gh,e))},nanoid(e){return this.check(Xf(Yh,e))},cuid(e){return this.check(Zf(Xh,e))},cuid2(e){return this.check(Qf(Zh,e))},ulid(e){return this.check(V(Qh,e))},base64(e){return this.check(ap(ag,e))},base64url(e){return this.check(op(og,e))},xid(e){return this.check($f($h,e))},ksuid(e){return this.check(ep(eg,e))},ipv4(e){return this.check(tp(tg,e))},ipv6(e){return this.check(np(ng,e))},cidrv4(e){return this.check(rp(rg,e))},cidrv6(e){return this.check(ip(ig,e))},e164(e){return this.check(sp(sg,e))},datetime(e){return this.check(lp(Rh,e))},date(e){return this.check(up(zh,e))},time(e){return this.check(dp(Bh,e))},duration(e){return this.check(fp(Vh,e))}});function H(e){return Vf(Ih,e)}var Lh=R(`ZodStringFormat`,(e,t)=>{zu.init(e,t),Fh.init(e,t)}),Rh=R(`ZodISODateTime`,(e,t)=>{id.init(e,t),Lh.init(e,t)}),zh=R(`ZodISODate`,(e,t)=>{ad.init(e,t),Lh.init(e,t)}),Bh=R(`ZodISOTime`,(e,t)=>{od.init(e,t),Lh.init(e,t)}),Vh=R(`ZodISODuration`,(e,t)=>{sd.init(e,t),Lh.init(e,t)}),Hh=R(`ZodEmail`,(e,t)=>{Hu.init(e,t),Lh.init(e,t)});function Uh(e){return Hf(Hh,e)}var Wh=R(`ZodGUID`,(e,t)=>{Bu.init(e,t),Lh.init(e,t)}),Gh=R(`ZodUUID`,(e,t)=>{Vu.init(e,t),Lh.init(e,t)}),Kh=R(`ZodURL`,(e,t)=>{Xu.init(e,t),Lh.init(e,t)});function qh(e){return Jf(Kh,e)}var Jh=R(`ZodEmoji`,(e,t)=>{Zu.init(e,t),Lh.init(e,t)}),Yh=R(`ZodNanoID`,(e,t)=>{Qu.init(e,t),Lh.init(e,t)}),Xh=R(`ZodCUID`,(e,t)=>{$u.init(e,t),Lh.init(e,t)}),Zh=R(`ZodCUID2`,(e,t)=>{ed.init(e,t),Lh.init(e,t)}),Qh=R(`ZodULID`,(e,t)=>{td.init(e,t),Lh.init(e,t)}),$h=R(`ZodXID`,(e,t)=>{nd.init(e,t),Lh.init(e,t)}),eg=R(`ZodKSUID`,(e,t)=>{rd.init(e,t),Lh.init(e,t)}),tg=R(`ZodIPv4`,(e,t)=>{cd.init(e,t),Lh.init(e,t)}),ng=R(`ZodIPv6`,(e,t)=>{ld.init(e,t),Lh.init(e,t)}),rg=R(`ZodCIDRv4`,(e,t)=>{ud.init(e,t),Lh.init(e,t)}),ig=R(`ZodCIDRv6`,(e,t)=>{fd.init(e,t),Lh.init(e,t)}),ag=R(`ZodBase64`,(e,t)=>{hd.init(e,t),Lh.init(e,t)}),og=R(`ZodBase64URL`,(e,t)=>{vd.init(e,t),Lh.init(e,t)}),sg=R(`ZodE164`,(e,t)=>{yd.init(e,t),Lh.init(e,t)}),cg=R(`ZodJWT`,(e,t)=>{xd.init(e,t),Lh.init(e,t)}),lg=R(`ZodNumber`,(e,t)=>{Sd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tm(e,t,n,r),e.isFinite=!0},Bc({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=bm(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=bm(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=bm(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>bm(e).format??null},{gt(e,t){return this.check(wp(e,t))},gte(e,t){return this.check(Tp(e,t))},min(e,t){return this.check(Tp(e,t))},lt(e,t){return this.check(Sp(e,t))},lte(e,t){return this.check(Cp(e,t))},max(e,t){return this.check(Cp(e,t))},int(e){return this.check(U(e))},safe(e){return this.check(U(e))},positive(e){return this.check(wp(0,e))},nonnegative(e){return this.check(Tp(0,e))},negative(e){return this.check(Sp(0,e))},nonpositive(e){return this.check(Cp(0,e))},multipleOf(e,t){return this.check(Ep(e,t))},step(e,t){return this.check(Ep(e,t))},finite(){return this}}));function ug(e){return pp(lg,e)}var dg=R(`ZodNumberFormat`,(e,t)=>{Cd.init(e,t),lg.init(e,t)});function U(e){return hp(dg,e)}var fg=R(`ZodBoolean`,(e,t)=>{wd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Em(e,t,n,r)});function pg(e){return gp(fg,e)}var mg=R(`ZodUndefined`,(e,t)=>{Td.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Am(e,t,n,r)});function hg(e){return _p(mg,e)}var gg=R(`ZodNull`,(e,t)=>{Ed.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>km(e,t,n,r)});function _g(e){return vp(gg,e)}var vg=R(`ZodAny`,(e,t)=>{Dd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function W(){return yp(vg)}var yg=R(`ZodUnknown`,(e,t)=>{Od.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function bg(){return bp(yg)}var xg=R(`ZodNever`,(e,t)=>{kd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mm(e,t,n,r)});function Sg(e){return xp(xg,e)}var Cg=R(`ZodArray`,(e,t)=>{Nh(),Nd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qm(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Op(e,t))},nonempty(e){return this.check(Op(1,e))},max(e,t){return this.check(Dp(e,t))},length(e,t){return this.check(kp(e,t))},unwrap(){return this.element}});function wg(e,t){return Hp(Cg,e,t)}var Tg=R(`ZodObject`,(e,t)=>{Nh(),zd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ym(e,t,n,r),Kc(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Ig(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(tc(this._zod.def,{catchall:e}))},passthrough(){return this.clone(tc(this._zod.def,{catchall:bg()}))},loose(){return this.clone(tc(this._zod.def,{catchall:bg()}))},strict(){return this.clone(tc(this._zod.def,{catchall:Sg()}))},strip(){return this.clone(tc(this._zod.def,{catchall:void 0}))},extend(e){return yc(this,e)},safeExtend(e){return xc(this,e)},merge(e){return Sc(this,e)},pick(e){return gc(this,e)},omit(e){return vc(this,e)},partial(...e){return Cc(Bg,this,e[0])},exactPartial(...e){return Cc(Hg,this,e[0],`exactPartial`)},required(...e){return wc(Xg,this,e[0])}});function Eg(e,t){return new Tg({type:`object`,shape:e??{},...I(t)})}function G(e,t){return new Tg({type:`object`,shape:e,catchall:bg(),...I(t)})}var Dg=R(`ZodUnion`,(e,t)=>{Vd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xm(e,t,n,r),e.options=t.options});function Og(e,t){return new Dg({type:`union`,options:e,...I(t)})}var kg=R(`ZodDiscriminatedUnion`,(e,t)=>{Dg.init(e,t),Ud.init(e,t)});function Ag(e,t,n){return new kg({type:`union`,options:t,discriminator:e,...I(n)})}var jg=R(`ZodIntersection`,(e,t)=>{Wd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zm(e,t,n,r)});function Mg(e,t){return new jg({type:`intersection`,left:e,right:t})}var Ng=R(`ZodRecord`,(e,t)=>{Nh(),qd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nh(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Pg(e,t,n){return!t||!t._zod?new Ng({type:`record`,keyType:H(),valueType:e,...I(t)}):new Ng({type:`record`,keyType:e,valueType:t,...I(n)})}var Fg=R(`ZodEnum`,(e,t)=>{Jd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Im(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Fg({...t,checks:[],...I(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Fg({...t,checks:[],...I(r),entries:i})}});function Ig(e,t){return new Fg({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var Lg=R(`ZodLiteral`,(e,t)=>{Yd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lm(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function K(e,t){return new Lg({type:`literal`,values:Array.isArray(e)?e:[e],...I(t)})}var Rg=R(`ZodTransform`,(e,t)=>{Nh(),Xd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wm(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new tl(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ic(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Ic(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function zg(e){return new Rg({type:`transform`,transform:e})}var Bg=R(`ZodOptional`,(e,t)=>{Qd.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ph(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vg(e){return new Bg({type:`optional`,innerType:e})}var Hg=R(`ZodExactOptional`,(e,t)=>{$d.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ph(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ug(e){return new Hg({type:`optional`,innerType:e})}var Wg=R(`ZodNullable`,(e,t)=>{ef.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gg(e){return new Wg({type:`nullable`,innerType:e})}var Kg=R(`ZodDefault`,(e,t)=>{tf.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qg(e,t){return new Kg({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():cc(t)}})}var Jg=R(`ZodPrefault`,(e,t)=>{rf.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ch(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yg(e,t){return new Jg({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():cc(t)}})}var Xg=R(`ZodNonOptional`,(e,t)=>{af.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ih(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zg(e,t){return new Xg({type:`nonoptional`,innerType:e,...I(t)})}var Qg=R(`ZodCatch`,(e,t)=>{cf.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $g(e,t){return new Qg({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Jc(t)})}var e_=R(`ZodPipe`,(e,t)=>{lf.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uh(e,t,n,r),e.in=t.in,e.out=t.out});function t_(e,t){return new e_({type:`pipe`,in:e,out:t})}var n_=R(`ZodPreprocess`,(e,t)=>{e_.init(e,t),df.init(e,t)}),r_=R(`ZodReadonly`,(e,t)=>{ff.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dh(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function i_(e){return new r_({type:`readonly`,innerType:e})}var a_=R(`ZodLazy`,(e,t)=>{mf.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mh(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function o_(e){return new a_({type:`lazy`,getter:e})}var s_=R(`ZodCustom`,(e,t)=>{hf.init(e,t),Ph.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hm(e,t,n,r)});function c_(e,t){return Up(s_,e??(()=>!0),t)}function l_(e,t={}){return Wp(s_,e,t)}function u_(e,t){return Gp(e,t)}function d_(e,t){return new n_({type:`pipe`,in:zg(e),out:t})}var f_=Ig(j),q=c_(e=>typeof e==`object`&&!!e&&!Array.isArray(e)),J=H(),p_=Ig([`developer`,`system`,`assistant`,`user`]),m_=G({type:K(j.TEXT_MESSAGE_START),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H(),role:p_.optional(),name:H().optional()}),h_=G({type:K(j.TEXT_MESSAGE_CONTENT),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H(),delta:H()}),g_=G({type:K(j.TEXT_MESSAGE_END),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H()}),__=G({type:K(j.TEXT_MESSAGE_CHUNK),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H().optional(),role:p_.optional(),delta:H().optional(),name:H().optional()}),v_=G({type:K(j.TOOL_CALL_START),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),toolCallId:H(),toolCallName:H(),parentMessageId:H().optional()}),y_=G({type:K(j.TOOL_CALL_ARGS),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),toolCallId:H(),delta:H()}),b_=G({type:K(j.TOOL_CALL_END),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),toolCallId:H()}),x_=G({type:K(j.TOOL_CALL_CHUNK),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),toolCallId:H().optional(),toolCallName:H().optional(),parentMessageId:H().optional(),delta:H().optional()}),S_=G({type:K(`text`),id:H().optional(),text:H(),metadata:W().refine(e=>e!==null).optional()}),C_=Ag(`type`,[G({type:K(`data`),value:H(),mimeType:H()}),G({type:K(`url`),value:H(),mimeType:H().optional()}),G({type:K(`file`),value:H(),provider:H().optional(),mimeType:H().optional()})]),w_=Ag(`type`,[S_,G({type:K(`image`),id:H().optional(),source:C_,metadata:W().refine(e=>e!==null).optional()}),G({type:K(`audio`),id:H().optional(),source:C_,metadata:W().refine(e=>e!==null).optional()}),G({type:K(`video`),id:H().optional(),source:C_,metadata:W().refine(e=>e!==null).optional()}),G({type:K(`document`),id:H().optional(),source:C_,metadata:W().refine(e=>e!==null).optional()})]),T_=G({type:K(j.TOOL_CALL_RESULT),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H(),toolCallId:H(),content:Og([H(),wg(w_)]),role:K(`tool`).optional()}),E_=W(),D_=G({type:K(j.STATE_SNAPSHOT),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),snapshot:E_.refine(e=>e!==void 0)}),O_=H().regex(RegExp(`^(/([^/~]|~[01])*)*$`)),k_=wg(Ag(`op`,[G({op:K(`add`),path:O_,value:W().refine(e=>e!==void 0)}).meta({specOpen:!0}),G({op:K(`remove`),path:O_}).meta({specOpen:!0}),G({op:K(`replace`),path:O_,value:W().refine(e=>e!==void 0)}).meta({specOpen:!0}),G({op:K(`move`),from:O_,path:O_}).meta({specOpen:!0}),G({op:K(`copy`),from:O_,path:O_}).meta({specOpen:!0}),G({op:K(`test`),path:O_,value:W().refine(e=>e!==void 0)}).meta({specOpen:!0})])),A_=G({type:K(j.STATE_DELTA),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),delta:k_}),j_=G({subagentRunId:J.optional(),id:H(),role:K(`developer`),name:H().optional(),encryptedValue:H().optional(),metadata:q.optional(),content:H()}),M_=G({subagentRunId:J.optional(),id:H(),role:K(`system`),name:H().optional(),encryptedValue:H().optional(),metadata:q.optional(),content:H()}),N_=G({name:H(),arguments:H()}),P_=G({id:H(),type:K(`function`),function:N_,encryptedValue:H().optional(),metadata:q.optional()}),F_=Ag(`role`,[j_,M_,G({subagentRunId:J.optional(),id:H(),role:K(`assistant`),name:H().optional(),encryptedValue:H().optional(),metadata:q.optional(),content:H().optional(),toolCalls:wg(P_).optional()}),G({subagentRunId:J.optional(),id:H(),role:K(`user`),name:H().optional(),encryptedValue:H().optional(),metadata:q.optional(),content:Og([H(),wg(w_)])}),G({subagentRunId:J.optional(),id:H(),role:K(`tool`),content:Og([H(),wg(w_)]),toolCallId:H(),error:H().optional(),encryptedValue:H().optional(),metadata:q.optional()}),G({subagentRunId:J.optional(),id:H(),role:K(`activity`),activityType:H(),content:c_(e=>typeof e==`object`&&!!e&&!Array.isArray(e)),metadata:q.optional()}),G({subagentRunId:J.optional(),id:H(),role:K(`reasoning`),content:H(),encryptedValue:H().optional(),metadata:q.optional()})]),I_=G({type:K(j.MESSAGES_SNAPSHOT),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),messages:wg(F_)}),L_=G({type:K(j.ACTIVITY_SNAPSHOT),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H(),activityType:H(),content:c_(e=>typeof e==`object`&&!!e&&!Array.isArray(e)),replace:pg().optional()}),R_=G({type:K(j.ACTIVITY_DELTA),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H(),activityType:H(),patch:k_}),z_=G({type:K(j.RAW),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),event:W().refine(e=>e!==void 0),source:H().optional()}),B_=G({type:K(j.CUSTOM),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),name:H(),value:W().refine(e=>e!==void 0)}),V_=G({name:H(),description:H(),parameters:W().refine(e=>e!==null).optional(),metadata:q.optional()}),H_=G({description:H(),value:H()}),U_=G({interruptId:H(),status:Ig([`resolved`,`cancelled`]),payload:W().refine(e=>e!==null).optional(),metadata:q.optional()}),W_=G({threadId:H(),runId:H(),protocolVersion:H().optional(),parentRunId:H().optional(),state:E_.refine(e=>e!==null).nullable().transform(e=>e??void 0).optional(),messages:wg(F_),tools:wg(V_).default(()=>[]),context:wg(H_).default(()=>[]),forwardedProps:W().refine(e=>e!==null).optional(),resume:wg(U_).optional()}),G_=G({type:K(j.RUN_STARTED),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),threadId:H(),runId:H(),protocolVersion:H().optional(),parentRunId:H().optional(),input:W_.optional()}),K_=G({type:K(`success`),pendingToolCallIds:wg(H()).optional()}),q_=G({subagentRunId:J.optional(),id:H(),reason:H(),message:H().optional(),toolCallId:H().optional(),responseSchema:c_(e=>typeof e==`object`&&!!e&&!Array.isArray(e)).optional(),expiresAt:H().optional(),metadata:q.optional()}),J_=Ag(`type`,[K_,G({type:K(`interrupt`),interrupts:wg(q_).min(1)}),G({type:K(`cancelled`)})]),Y_=G({provider:H().optional(),model:H().optional(),inputTokens:U().min(0).max(9007199254740991).optional(),outputTokens:U().min(0).max(9007199254740991).optional(),totalTokens:U().min(0).max(9007199254740991).optional(),reasoningTokens:U().min(0).max(9007199254740991).optional(),cachedInputTokens:U().min(0).max(9007199254740991).optional(),cacheWriteInputTokens:U().min(0).max(9007199254740991).optional()}),X_=G({type:K(j.RUN_FINISHED),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),threadId:H(),runId:H(),result:W().refine(e=>e!==null).optional(),outcome:J_.optional(),usage:wg(Y_).optional()}),Z_=G({type:K(j.RUN_ERROR),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),message:H(),code:H().optional(),usage:wg(Y_).optional()}),Q_=G({type:K(j.STEP_STARTED),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),stepName:H()}),$_=G({type:K(j.STEP_FINISHED),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),stepName:H()}),ev=G({type:K(j.REASONING_START),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H()}),tv=G({type:K(j.REASONING_MESSAGE_START),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H(),role:K(`reasoning`)}),nv=G({type:K(j.REASONING_MESSAGE_CONTENT),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H(),delta:H()}),rv=G({type:K(j.REASONING_MESSAGE_END),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H()}),iv=G({type:K(j.REASONING_MESSAGE_CHUNK),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H().optional(),delta:H().optional()}),av=G({type:K(j.REASONING_END),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),messageId:H()}),ov=Ig([`tool-call`,`message`]),sv=G({type:K(j.REASONING_ENCRYPTED_VALUE),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J.optional(),subtype:ov,entityId:H(),encryptedValue:H()}),cv=G({type:K(j.SUBAGENT_STARTED),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J,name:H(),description:H().optional(),parentSubagentRunId:J.optional(),parentToolCallId:H().optional(),parentMessageId:H().optional()}),lv=Ag(`type`,[G({type:K(`success`)}),G({type:K(`suspended`),interruptIds:wg(H()).optional()})]),uv=Ag(`type`,[m_,h_,g_,__,v_,y_,b_,x_,T_,D_,A_,I_,L_,R_,z_,B_,G_,X_,Z_,Q_,$_,ev,tv,nv,rv,iv,av,sv,cv,G({type:K(j.SUBAGENT_FINISHED),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J,result:W().refine(e=>e!==null).optional(),outcome:lv.optional()}),G({type:K(j.SUBAGENT_ERROR),timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional(),subagentRunId:J,message:H(),code:H().optional()})]);Ig([`developer`,`system`,`assistant`,`user`,`tool`,`activity`,`reasoning`]);var dv=G({name:H(),description:H().optional()}),fv=G({name:H().optional(),type:H().optional(),description:H().optional(),version:H().optional(),provider:H().optional(),documentationUrl:H().optional(),metadata:q.optional()}),pv=G({streaming:pg().optional(),websocket:pg().optional(),httpBinary:pg().optional(),pushNotifications:pg().optional(),resumable:pg().optional()}),mv=G({supported:pg().optional(),items:wg(V_).optional(),parallelCalls:pg().optional(),clientProvided:pg().optional()}),hv=G({structuredOutput:pg().optional(),supportedMimeTypes:wg(H()).optional()}),gv=G({snapshots:pg().optional(),deltas:pg().optional(),memory:pg().optional(),persistentState:pg().optional()}),_v=G({supported:pg().optional(),delegation:pg().optional(),handoffs:pg().optional(),subagents:wg(dv).optional()}),vv=G({supported:pg().optional(),streaming:pg().optional(),encrypted:pg().optional()}),yv=G({image:pg().optional(),audio:pg().optional(),video:pg().optional(),pdf:pg().optional(),file:pg().optional()}),bv=G({image:pg().optional(),audio:pg().optional()}),xv=G({input:yv.optional(),output:bv.optional()}),Sv=G({codeExecution:pg().optional(),sandboxed:pg().optional(),maxIterations:U().min(0).max(9007199254740991).optional(),maxExecutionTime:U().min(0).max(9007199254740991).optional()}),Cv=G({supported:pg().optional(),approvals:pg().optional(),interventions:pg().optional(),feedback:pg().optional(),interrupts:pg().optional(),approveWithEdits:pg().optional()});G({identity:fv.optional(),transport:pv.optional(),tools:mv.optional(),output:hv.optional(),state:gv.optional(),multiAgent:_v.optional(),reasoning:vv.optional(),multimodal:xv.optional(),execution:Sv.optional(),humanInTheLoop:Cv.optional(),custom:c_(e=>typeof e==`object`&&!!e&&!Array.isArray(e)).optional()}),G({subagentRunId:J.optional()}),G({type:f_,timestamp:U().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:W().refine(e=>e!==null).optional(),metadata:q.optional()}),G({subagentRunId:J.optional(),id:H(),role:H(),name:H().optional(),encryptedValue:H().optional(),metadata:q.optional()}),q.optional();function wv(){let e=this.buf,t=this.pos,n=0,r=0;for(let i=0;i<28;i+=7){let a=e[t++];if(n|=(a&127)<>4,!(i&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}for(let i=3;i<=31;i+=7){let a=e[t++];if(r|=(a&127)<=Tv&&(i+=r/Tv|0,r%=Tv)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?jv(r,i):Av(r,i)}function Dv(e,t){let n=Av(e,t),r=n.hi&2147483648;r&&(n=jv(n.lo,n.hi));let i=Ov(n.lo,n.hi);return r?`-`+i:i}function Ov(e,t){if({lo:e,hi:t}=kv(e,t),t<=2097151)return String(Tv*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+Mv(o)+Mv(a)}function kv(e,t){return{lo:e>>>0,hi:t>>>0}}function Av(e,t){return{lo:e|0,hi:t|0}}function jv(e,t){return t=~t,e?e=~e+1:t+=1,Av(e,t)}var Mv=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Nv(){let e=this.buf[this.pos++];if(!(e&128))return this.assertBounds(),e;let t=e&127;if(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}var Pv=Fv();function Fv(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(globalThis.Deno||globalThis.Bun||typeof process!=`object`||{}.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||ri||ta.call(e)),zv(i)}return Rv}function Vv(e){return(t,n)=>{let r=e(t);return n.set(r),{written:r.byteLength}}}var Hv;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(Hv||={});var Y=class{constructor(e){this.stackPos=[],this.encodeUtf8Into=e?Vv(e):Bv().encodeUtf8Into,this.buffer=Gv,this.viewCache=Kv,this.pos=0}ensureCapacity(e){let t=this.pos+e;if(t>this.buffer.length){let e=this.buffer.length||Uv;for(;e0&&n.set(this.buffer),this.buffer=n}}view(){let e=this.buffer,t=this.viewCache;if(t.byteLength===e.byteLength)return t;let n=new DataView(e.buffer);return this.viewCache=n,n}finish(){let e=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],e}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(Wv),this.buffer[this.pos++]=0,this}join(){let e=this.stackPos.pop();if(e===void 0)throw Error(`invalid state, fork stack empty`);let t=this.pos-e-Wv,n=Jv(t);return n>Wv&&(this.ensureCapacity(n-Wv),this.buffer.copyWithin(e+n,e+Wv,this.pos)),this.pos=e,this.uint32(t),this.pos+=t,this}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.ensureCapacity(e.length),this.buffer.set(e,this.pos),this.pos+=e.length,this}uint32(e){if(Xv(e),this.ensureCapacity(5),e<128)return this.buffer[this.pos++]=e,this;for(;e>127;)this.buffer[this.pos++]=e&127|128,e>>>=7;return this.buffer[this.pos++]=e,this}int32(e){if(Yv(e),e>=0)return this.uint32(e);this.ensureCapacity(10);for(let t=0;t<9;t++)this.buffer[this.pos++]=e&127|128,e>>=7;return this.buffer[this.pos++]=1,this}bool(e){return this.ensureCapacity(1),this.buffer[this.pos++]=+!!e,this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){typeof e!=`string`&&(e=String(e));let t=e.length;if(t<=qv){this.ensureCapacity(t+1);let n=this.buffer,r=this.pos;n[r++]=t;let i=0;for(;i127)break;n[r++]=t}if(i==t)return this.pos=r,this}this.ensureCapacity(t*3+5);let n=Jv(t),r=this.buffer,i=this.pos,{written:a}=this.encodeUtf8Into(e,r.subarray(i+n)),o=Jv(a);return o!=n&&r.copyWithin(i+o,i+n,i+n+a),this.uint32(a),this.pos+=a,this}float(e){return Zv(e),this.ensureCapacity(4),this.view().setFloat32(this.pos,e,!0),this.pos+=4,this}double(e){return this.ensureCapacity(8),this.view().setFloat64(this.pos,e,!0),this.pos+=8,this}fixed32(e){return Xv(e),this.ensureCapacity(4),this.view().setUint32(this.pos,e,!0),this.pos+=4,this}sfixed32(e){return Yv(e),this.ensureCapacity(4),this.view().setInt32(this.pos,e,!0),this.pos+=4,this}sint32(e){return Yv(e),this.uint32((e<<1^e>>31)>>>0)}sfixed64(e){let t=Pv.enc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}fixed64(e){let t=Pv.uEnc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}int64(e){let t=Pv.enc(e);return this.writeVarint64(t.lo,t.hi)}sint64(e){let t=Pv.enc(e),n=t.hi>>31,r=t.lo<<1^n,i=(t.hi<<1|t.lo>>>31)^n;return this.writeVarint64(r,i)}uint64(e){let t=Pv.uEnc(e);return this.writeVarint64(t.lo,t.hi)}writeVarint64(e,t){this.ensureCapacity(10);let n=this.buffer,r=this.pos;for(let i=0;i<28;i+=7){let a=e>>>i,o=!(!(a>>>7)&&t==0);if(n[r++]=(o?a|128:a)&255,!o)return this.pos=r,this}let i=e>>>28&15|(t&7)<<4,a=!!(t>>3);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this;for(let e=3;e<31;e+=7){let i=t>>>e,a=!!(i>>>7);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this}return n[r++]=t>>>31&1,this.pos=r,this}},Uv=128,Wv=1,Gv=new Uint8Array,Kv=new DataView(Gv.buffer),qv=32;function Jv(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}var X=class{constructor(e,t=Bv().decodeUtf8){this.decodeUtf8=t,this.varint64Lo=0,this.varint64Hi=0,this.varint64=wv,this.uint32=Nv,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||n==5&&this.buf[this.pos-1]>15)throw Error(`illegal tag: varint overflows uint32`);let r=t>>>3,i=t&7;if(r<=0||i>5)throw Error(`illegal tag: field no `+r+` wire type `+i);return[r,i]}skip(e,t,n=100){let r=this.pos;switch(e){case Hv.Varint:for(;this.buf[this.pos++]&128;);break;case Hv.Bit64:this.pos+=4;case Hv.Bit32:this.pos+=4;break;case Hv.LengthDelimited:let r=this.uint32();this.pos+=r;break;case Hv.StartGroup:if(n<=0)throw Error(`maximum recursion depth reached`);for(;;){let[e,r]=this.tag();if(r===Hv.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(r,e,n-1)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return this.varint64(),Pv.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),Pv.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let e=this.varint64Lo,t=this.varint64Hi,n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,Pv.dec(e,t)}bool(){let e=this.buf[this.pos];return e<128?(this.pos++,e!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Pv.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Pv.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){let t=this.bytes(),n=t.length;if(n<=qv){let r=Array(n);for(let i=0;i127)return this.decodeUtf8(t,e);r[i]=n}return String.fromCharCode.apply(String,r)}return this.decodeUtf8(t,e)}};function Yv(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid int32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int32: `+e)}function Xv(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid uint32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint32: `+e)}function Zv(e){if(typeof e==`string`){let t=e;if(e=Number(e),Number.isNaN(e)&&t!==`NaN`)throw Error(`invalid float32: `+t)}else if(typeof e!=`number`)throw Error(`invalid float32: `+typeof e);if(!Number.isFinite(Math.fround(e))&&Number.isFinite(e))throw Error(`invalid float32: `+e)}var Qv=function(e){return e[e.NULL_VALUE=0]=`NULL_VALUE`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function $v(){return{fields:{}}}var ey={encode(e,t=new Y){return Object.entries(e.fields).forEach(([e,n])=>{n!==void 0&&ny.encode({key:e,value:n},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=$v();for(;n.pos>>3){case 1:{if(e!==10)break;let t=ny.decode(n,n.uint32());t.value!==void 0&&(i.fields[t.key]=t.value);continue}}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ey.fromPartial(e??{})},fromPartial(e){let t=$v();return t.fields=Object.entries(e.fields??{}).reduce((e,[t,n])=>(n!==void 0&&(e[t]=n),e),{}),t},wrap(e){let t=$v();if(e!==void 0)for(let n of Object.keys(e))t.fields[n]=e[n];return t},unwrap(e){let t={};if(e.fields)for(let n of Object.keys(e.fields))t[n]=e.fields[n];return t}};function ty(){return{key:``,value:void 0}}var ny={encode(e,t=new Y){return e.key!==``&&t.uint32(10).string(e.key),e.value!==void 0&&Z.encode(Z.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=ty();for(;n.pos>>3){case 1:if(e!==10)break;i.key=n.string();continue;case 2:if(e!==18)break;i.value=Z.unwrap(Z.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ny.fromPartial(e??{})},fromPartial(e){let t=ty();return t.key=e.key??``,t.value=e.value??void 0,t}};function ry(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var Z={encode(e,t=new Y){return e.nullValue!==void 0&&t.uint32(8).int32(e.nullValue),e.numberValue!==void 0&&t.uint32(17).double(e.numberValue),e.stringValue!==void 0&&t.uint32(26).string(e.stringValue),e.boolValue!==void 0&&t.uint32(32).bool(e.boolValue),e.structValue!==void 0&&ey.encode(ey.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&ay.encode(ay.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=ry();for(;n.pos>>3){case 1:if(e!==8)break;i.nullValue=n.int32();continue;case 2:if(e!==17)break;i.numberValue=n.double();continue;case 3:if(e!==26)break;i.stringValue=n.string();continue;case 4:if(e!==32)break;i.boolValue=n.bool();continue;case 5:if(e!==42)break;i.structValue=ey.unwrap(ey.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.listValue=ay.unwrap(ay.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Z.fromPartial(e??{})},fromPartial(e){let t=ry();return t.nullValue=e.nullValue??void 0,t.numberValue=e.numberValue??void 0,t.stringValue=e.stringValue??void 0,t.boolValue=e.boolValue??void 0,t.structValue=e.structValue??void 0,t.listValue=e.listValue??void 0,t},wrap(e){let t=ry();if(e===null)t.nullValue=Qv.NULL_VALUE;else if(typeof e==`boolean`)t.boolValue=e;else if(typeof e==`number`)t.numberValue=e;else if(typeof e==`string`)t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if(typeof e==`object`)t.structValue=e;else if(e!==void 0)throw new globalThis.Error(`Unsupported any value type: `+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function iy(){return{values:[]}}var ay={encode(e,t=new Y){for(let n of e.values)Z.encode(Z.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=iy();for(;n.pos>>3){case 1:if(e!==10)break;i.values.push(Z.unwrap(Z.decode(n,n.uint32())));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ay.fromPartial(e??{})},fromPartial(e){let t=iy();return t.values=e.values?.map(e=>e)||[],t},wrap(e){let t=iy();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty(`values`)&&globalThis.Array.isArray(e.values)?e.values:e}},oy=function(e){return e[e.ADD=0]=`ADD`,e[e.REMOVE=1]=`REMOVE`,e[e.REPLACE=2]=`REPLACE`,e[e.MOVE=3]=`MOVE`,e[e.COPY=4]=`COPY`,e[e.TEST=5]=`TEST`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function sy(){return{op:0,path:``,from:void 0,value:void 0}}var cy={encode(e,t=new Y){return e.op!==0&&t.uint32(8).int32(e.op),e.path!==``&&t.uint32(18).string(e.path),e.from!==void 0&&t.uint32(26).string(e.from),e.value!==void 0&&Z.encode(Z.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=sy();for(;n.pos>>3){case 1:if(e!==8)break;i.op=n.int32();continue;case 2:if(e!==18)break;i.path=n.string();continue;case 3:if(e!==26)break;i.from=n.string();continue;case 4:if(e!==34)break;i.value=Z.unwrap(Z.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return cy.fromPartial(e??{})},fromPartial(e){let t=sy();return t.op=e.op??0,t.path=e.path??``,t.from=e.from??void 0,t.value=e.value??void 0,t}};function ly(){return{text:``,id:void 0,metadata:void 0}}var uy={encode(e,t=new Y){return e.text!==``&&t.uint32(10).string(e.text),e.id!==void 0&&t.uint32(18).string(e.id),e.metadata!==void 0&&Z.encode(Z.wrap(e.metadata),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=ly();for(;n.pos>>3){case 1:if(e!==10)break;i.text=n.string();continue;case 2:if(e!==18)break;i.id=n.string();continue;case 3:if(e!==26)break;i.metadata=Z.unwrap(Z.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return uy.fromPartial(e??{})},fromPartial(e){let t=ly();return t.text=e.text??``,t.id=e.id??void 0,t.metadata=e.metadata??void 0,t}};function dy(){return{source:void 0,metadata:void 0,id:void 0}}var fy={encode(e,t=new Y){return e.source!==void 0&&by.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Z.encode(Z.wrap(e.metadata),t.uint32(18).fork()).join(),e.id!==void 0&&t.uint32(26).string(e.id),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=dy();for(;n.pos>>3){case 1:if(e!==10)break;i.source=by.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Z.unwrap(Z.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.id=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return fy.fromPartial(e??{})},fromPartial(e){let t=dy();return t.source=e.source!==void 0&&e.source!==null?by.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t.id=e.id??void 0,t}};function py(){return{value:``,mimeType:``}}var my={encode(e,t=new Y){return e.value!==``&&t.uint32(10).string(e.value),e.mimeType!==``&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=py();for(;n.pos>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return my.fromPartial(e??{})},fromPartial(e){let t=py();return t.value=e.value??``,t.mimeType=e.mimeType??``,t}};function hy(){return{value:``,mimeType:void 0}}var gy={encode(e,t=new Y){return e.value!==``&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=hy();for(;n.pos>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return gy.fromPartial(e??{})},fromPartial(e){let t=hy();return t.value=e.value??``,t.mimeType=e.mimeType??void 0,t}};function _y(){return{value:``,provider:void 0,mimeType:void 0}}var vy={encode(e,t=new Y){return e.value!==``&&t.uint32(10).string(e.value),e.provider!==void 0&&t.uint32(18).string(e.provider),e.mimeType!==void 0&&t.uint32(26).string(e.mimeType),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=_y();for(;n.pos>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.provider=n.string();continue;case 3:if(e!==26)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return vy.fromPartial(e??{})},fromPartial(e){let t=_y();return t.value=e.value??``,t.provider=e.provider??void 0,t.mimeType=e.mimeType??void 0,t}};function yy(){return{data:void 0,url:void 0,file:void 0}}var by={encode(e,t=new Y){return e.data!==void 0&&my.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&gy.encode(e.url,t.uint32(18).fork()).join(),e.file!==void 0&&vy.encode(e.file,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=yy();for(;n.pos>>3){case 1:if(e!==10)break;i.data=my.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.url=gy.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.file=vy.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return by.fromPartial(e??{})},fromPartial(e){let t=yy();return t.data=e.data!==void 0&&e.data!==null?my.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?gy.fromPartial(e.url):void 0,t.file=e.file!==void 0&&e.file!==null?vy.fromPartial(e.file):void 0,t}};function xy(){return{source:void 0,metadata:void 0,id:void 0}}var Sy={encode(e,t=new Y){return e.source!==void 0&&by.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Z.encode(Z.wrap(e.metadata),t.uint32(18).fork()).join(),e.id!==void 0&&t.uint32(26).string(e.id),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=xy();for(;n.pos>>3){case 1:if(e!==10)break;i.source=by.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Z.unwrap(Z.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.id=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Sy.fromPartial(e??{})},fromPartial(e){let t=xy();return t.source=e.source!==void 0&&e.source!==null?by.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t.id=e.id??void 0,t}};function Cy(){return{source:void 0,metadata:void 0,id:void 0}}var wy={encode(e,t=new Y){return e.source!==void 0&&by.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Z.encode(Z.wrap(e.metadata),t.uint32(18).fork()).join(),e.id!==void 0&&t.uint32(26).string(e.id),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Cy();for(;n.pos>>3){case 1:if(e!==10)break;i.source=by.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Z.unwrap(Z.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.id=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return wy.fromPartial(e??{})},fromPartial(e){let t=Cy();return t.source=e.source!==void 0&&e.source!==null?by.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t.id=e.id??void 0,t}};function Ty(){return{source:void 0,metadata:void 0,id:void 0}}var Ey={encode(e,t=new Y){return e.source!==void 0&&by.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&Z.encode(Z.wrap(e.metadata),t.uint32(18).fork()).join(),e.id!==void 0&&t.uint32(26).string(e.id),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Ty();for(;n.pos>>3){case 1:if(e!==10)break;i.source=by.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=Z.unwrap(Z.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.id=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ey.fromPartial(e??{})},fromPartial(e){let t=Ty();return t.source=e.source!==void 0&&e.source!==null?by.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t.id=e.id??void 0,t}};function Dy(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Oy={encode(e,t=new Y){return e.text!==void 0&&uy.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&fy.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&Sy.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&wy.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&Ey.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Dy();for(;n.pos>>3){case 1:if(e!==10)break;i.text=uy.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.image=fy.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.audio=Sy.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.video=wy.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.document=Ey.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Oy.fromPartial(e??{})},fromPartial(e){let t=Dy();return t.text=e.text!==void 0&&e.text!==null?uy.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?fy.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?Sy.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?wy.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?Ey.fromPartial(e.document):void 0,t}};function ky(){return{id:``,type:``,function:void 0,metadata:void 0,encryptedValue:void 0}}var Ay={encode(e,t=new Y){return e.id!==``&&t.uint32(10).string(e.id),e.type!==``&&t.uint32(18).string(e.type),e.function!==void 0&&My.encode(e.function,t.uint32(26).fork()).join(),e.metadata!==void 0&&ey.encode(ey.wrap(e.metadata),t.uint32(34).fork()).join(),e.encryptedValue!==void 0&&t.uint32(42).string(e.encryptedValue),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=ky();for(;n.pos>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.type=n.string();continue;case 3:if(e!==26)break;i.function=My.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.metadata=ey.unwrap(ey.decode(n,n.uint32()));continue;case 5:if(e!==42)break;i.encryptedValue=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ay.fromPartial(e??{})},fromPartial(e){let t=ky();return t.id=e.id??``,t.type=e.type??``,t.function=e.function!==void 0&&e.function!==null?My.fromPartial(e.function):void 0,t.metadata=e.metadata??void 0,t.encryptedValue=e.encryptedValue??void 0,t}};function jy(){return{name:``,arguments:``}}var My={encode(e,t=new Y){return e.name!==``&&t.uint32(10).string(e.name),e.arguments!==``&&t.uint32(18).string(e.arguments),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=jy();for(;n.pos>>3){case 1:if(e!==10)break;i.name=n.string();continue;case 2:if(e!==18)break;i.arguments=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return My.fromPartial(e??{})},fromPartial(e){let t=jy();return t.name=e.name??``,t.arguments=e.arguments??``,t}};function Ny(){return{id:``,role:``,content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[],metadata:void 0,subagentRunId:void 0,encryptedValue:void 0,activityType:void 0,activityContent:void 0}}var Py={encode(e,t=new Y){e.id!==``&&t.uint32(10).string(e.id),e.role!==``&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let n of e.toolCalls)Ay.encode(n,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let n of e.contentParts)Oy.encode(n,t.uint32(66).fork()).join();return e.metadata!==void 0&&ey.encode(ey.wrap(e.metadata),t.uint32(74).fork()).join(),e.subagentRunId!==void 0&&t.uint32(82).string(e.subagentRunId),e.encryptedValue!==void 0&&t.uint32(90).string(e.encryptedValue),e.activityType!==void 0&&t.uint32(98).string(e.activityType),e.activityContent!==void 0&&ey.encode(ey.wrap(e.activityContent),t.uint32(106).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Ny();for(;n.pos>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.role=n.string();continue;case 3:if(e!==26)break;i.content=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue;case 5:if(e!==42)break;i.toolCalls.push(Ay.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.toolCallId=n.string();continue;case 7:if(e!==58)break;i.error=n.string();continue;case 8:if(e!==66)break;i.contentParts.push(Oy.decode(n,n.uint32()));continue;case 9:if(e!==74)break;i.metadata=ey.unwrap(ey.decode(n,n.uint32()));continue;case 10:if(e!==82)break;i.subagentRunId=n.string();continue;case 11:if(e!==90)break;i.encryptedValue=n.string();continue;case 12:if(e!==98)break;i.activityType=n.string();continue;case 13:if(e!==106)break;i.activityContent=ey.unwrap(ey.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Py.fromPartial(e??{})},fromPartial(e){let t=Ny();return t.id=e.id??``,t.role=e.role??``,t.content=e.content??void 0,t.name=e.name??void 0,t.toolCalls=e.toolCalls?.map(e=>Ay.fromPartial(e))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(e=>Oy.fromPartial(e))||[],t.metadata=e.metadata??void 0,t.subagentRunId=e.subagentRunId??void 0,t.encryptedValue=e.encryptedValue??void 0,t.activityType=e.activityType??void 0,t.activityContent=e.activityContent??void 0,t}};function Fy(){return{name:``,description:``,parameters:void 0,metadata:void 0}}var Iy={encode(e,t=new Y){return e.name!==``&&t.uint32(10).string(e.name),e.description!==``&&t.uint32(18).string(e.description),e.parameters!==void 0&&Z.encode(Z.wrap(e.parameters),t.uint32(26).fork()).join(),e.metadata!==void 0&&ey.encode(ey.wrap(e.metadata),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Fy();for(;n.pos>>3){case 1:if(e!==10)break;i.name=n.string();continue;case 2:if(e!==18)break;i.description=n.string();continue;case 3:if(e!==26)break;i.parameters=Z.unwrap(Z.decode(n,n.uint32()));continue;case 4:if(e!==34)break;i.metadata=ey.unwrap(ey.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Iy.fromPartial(e??{})},fromPartial(e){let t=Fy();return t.name=e.name??``,t.description=e.description??``,t.parameters=e.parameters??void 0,t.metadata=e.metadata??void 0,t}};function Ly(){return{description:``,value:``}}var Ry={encode(e,t=new Y){return e.description!==``&&t.uint32(10).string(e.description),e.value!==``&&t.uint32(18).string(e.value),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Ly();for(;n.pos>>3){case 1:if(e!==10)break;i.description=n.string();continue;case 2:if(e!==18)break;i.value=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ry.fromPartial(e??{})},fromPartial(e){let t=Ly();return t.description=e.description??``,t.value=e.value??``,t}};function zy(){return{interruptId:``,status:``,payload:void 0,metadata:void 0}}var By={encode(e,t=new Y){return e.interruptId!==``&&t.uint32(10).string(e.interruptId),e.status!==``&&t.uint32(18).string(e.status),e.payload!==void 0&&Z.encode(Z.wrap(e.payload),t.uint32(26).fork()).join(),e.metadata!==void 0&&ey.encode(ey.wrap(e.metadata),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=zy();for(;n.pos>>3){case 1:if(e!==10)break;i.interruptId=n.string();continue;case 2:if(e!==18)break;i.status=n.string();continue;case 3:if(e!==26)break;i.payload=Z.unwrap(Z.decode(n,n.uint32()));continue;case 4:if(e!==34)break;i.metadata=ey.unwrap(ey.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return By.fromPartial(e??{})},fromPartial(e){let t=zy();return t.interruptId=e.interruptId??``,t.status=e.status??``,t.payload=e.payload??void 0,t.metadata=e.metadata??void 0,t}};function Vy(){return{threadId:``,runId:``,parentRunId:void 0,state:void 0,messages:[],tools:[],context:[],forwardedProps:void 0,resume:[],protocolVersion:void 0}}var Hy={encode(e,t=new Y){e.threadId!==``&&t.uint32(10).string(e.threadId),e.runId!==``&&t.uint32(18).string(e.runId),e.parentRunId!==void 0&&t.uint32(26).string(e.parentRunId),e.state!==void 0&&Z.encode(Z.wrap(e.state),t.uint32(34).fork()).join();for(let n of e.messages)Py.encode(n,t.uint32(42).fork()).join();for(let n of e.tools)Iy.encode(n,t.uint32(50).fork()).join();for(let n of e.context)Ry.encode(n,t.uint32(58).fork()).join();e.forwardedProps!==void 0&&Z.encode(Z.wrap(e.forwardedProps),t.uint32(66).fork()).join();for(let n of e.resume)By.encode(n,t.uint32(74).fork()).join();return e.protocolVersion!==void 0&&t.uint32(82).string(e.protocolVersion),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Vy();for(;n.pos>>3){case 1:if(e!==10)break;i.threadId=n.string();continue;case 2:if(e!==18)break;i.runId=n.string();continue;case 3:if(e!==26)break;i.parentRunId=n.string();continue;case 4:if(e!==34)break;i.state=Z.unwrap(Z.decode(n,n.uint32()));continue;case 5:if(e!==42)break;i.messages.push(Py.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.tools.push(Iy.decode(n,n.uint32()));continue;case 7:if(e!==58)break;i.context.push(Ry.decode(n,n.uint32()));continue;case 8:if(e!==66)break;i.forwardedProps=Z.unwrap(Z.decode(n,n.uint32()));continue;case 9:if(e!==74)break;i.resume.push(By.decode(n,n.uint32()));continue;case 10:if(e!==82)break;i.protocolVersion=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Hy.fromPartial(e??{})},fromPartial(e){let t=Vy();return t.threadId=e.threadId??``,t.runId=e.runId??``,t.parentRunId=e.parentRunId??void 0,t.state=e.state??void 0,t.messages=e.messages?.map(e=>Py.fromPartial(e))||[],t.tools=e.tools?.map(e=>Iy.fromPartial(e))||[],t.context=e.context?.map(e=>Ry.fromPartial(e))||[],t.forwardedProps=e.forwardedProps??void 0,t.resume=e.resume?.map(e=>By.fromPartial(e))||[],t.protocolVersion=e.protocolVersion??void 0,t}};function Uy(){return{id:``,reason:``,message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0,subagentRunId:void 0}}var Wy={encode(e,t=new Y){return e.id!==``&&t.uint32(10).string(e.id),e.reason!==``&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&Z.encode(Z.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&Z.encode(Z.wrap(e.metadata),t.uint32(58).fork()).join(),e.subagentRunId!==void 0&&t.uint32(66).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Uy();for(;n.pos>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.reason=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue;case 4:if(e!==34)break;i.toolCallId=n.string();continue;case 5:if(e!==42)break;i.responseSchema=Z.unwrap(Z.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.expiresAt=n.string();continue;case 7:if(e!==58)break;i.metadata=Z.unwrap(Z.decode(n,n.uint32()));continue;case 8:if(e!==66)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Wy.fromPartial(e??{})},fromPartial(e){let t=Uy();return t.id=e.id??``,t.reason=e.reason??``,t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t.subagentRunId=e.subagentRunId??void 0,t}},Gy=function(e){return e[e.TEXT_MESSAGE_START=0]=`TEXT_MESSAGE_START`,e[e.TEXT_MESSAGE_CONTENT=1]=`TEXT_MESSAGE_CONTENT`,e[e.TEXT_MESSAGE_END=2]=`TEXT_MESSAGE_END`,e[e.TOOL_CALL_START=3]=`TOOL_CALL_START`,e[e.TOOL_CALL_ARGS=4]=`TOOL_CALL_ARGS`,e[e.TOOL_CALL_END=5]=`TOOL_CALL_END`,e[e.STATE_SNAPSHOT=6]=`STATE_SNAPSHOT`,e[e.STATE_DELTA=7]=`STATE_DELTA`,e[e.MESSAGES_SNAPSHOT=8]=`MESSAGES_SNAPSHOT`,e[e.RAW=9]=`RAW`,e[e.CUSTOM=10]=`CUSTOM`,e[e.RUN_STARTED=11]=`RUN_STARTED`,e[e.RUN_FINISHED=12]=`RUN_FINISHED`,e[e.RUN_ERROR=13]=`RUN_ERROR`,e[e.STEP_STARTED=14]=`STEP_STARTED`,e[e.STEP_FINISHED=15]=`STEP_FINISHED`,e[e.SUBAGENT_STARTED=16]=`SUBAGENT_STARTED`,e[e.SUBAGENT_FINISHED=17]=`SUBAGENT_FINISHED`,e[e.SUBAGENT_ERROR=18]=`SUBAGENT_ERROR`,e[e.TEXT_MESSAGE_CHUNK=19]=`TEXT_MESSAGE_CHUNK`,e[e.TOOL_CALL_CHUNK=20]=`TOOL_CALL_CHUNK`,e[e.TOOL_CALL_RESULT=21]=`TOOL_CALL_RESULT`,e[e.ACTIVITY_SNAPSHOT=22]=`ACTIVITY_SNAPSHOT`,e[e.ACTIVITY_DELTA=23]=`ACTIVITY_DELTA`,e[e.REASONING_START=24]=`REASONING_START`,e[e.REASONING_MESSAGE_START=25]=`REASONING_MESSAGE_START`,e[e.REASONING_MESSAGE_CONTENT=26]=`REASONING_MESSAGE_CONTENT`,e[e.REASONING_MESSAGE_END=27]=`REASONING_MESSAGE_END`,e[e.REASONING_MESSAGE_CHUNK=28]=`REASONING_MESSAGE_CHUNK`,e[e.REASONING_END=29]=`REASONING_END`,e[e.REASONING_ENCRYPTED_VALUE=30]=`REASONING_ENCRYPTED_VALUE`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function Ky(){return{type:0,timestamp:void 0,rawEvent:void 0,metadata:void 0}}var Q={encode(e,t=new Y){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&Z.encode(Z.wrap(e.rawEvent),t.uint32(26).fork()).join(),e.metadata!==void 0&&ey.encode(ey.wrap(e.metadata),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Ky();for(;n.pos>>3){case 1:if(e!==8)break;i.type=n.int32();continue;case 2:if(e!==16)break;i.timestamp=ax(n.int64());continue;case 3:if(e!==26)break;i.rawEvent=Z.unwrap(Z.decode(n,n.uint32()));continue;case 4:if(e!==34)break;i.metadata=ey.unwrap(ey.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Q.fromPartial(e??{})},fromPartial(e){let t=Ky();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t.metadata=e.metadata??void 0,t}};function qy(){return{baseEvent:void 0,messageId:``,role:void 0,name:void 0,subagentRunId:void 0}}var Jy={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),e.subagentRunId!==void 0&&t.uint32(42).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=qy();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue;case 5:if(e!==42)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Jy.fromPartial(e??{})},fromPartial(e){let t=qy();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.role=e.role??void 0,t.name=e.name??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function Yy(){return{baseEvent:void 0,messageId:``,delta:``,subagentRunId:void 0}}var Xy={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.delta!==``&&t.uint32(26).string(e.delta),e.subagentRunId!==void 0&&t.uint32(34).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Yy();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue;case 4:if(e!==34)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Xy.fromPartial(e??{})},fromPartial(e){let t=Yy();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.delta=e.delta??``,t.subagentRunId=e.subagentRunId??void 0,t}};function Zy(){return{baseEvent:void 0,messageId:``,subagentRunId:void 0}}var Qy={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Zy();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Qy.fromPartial(e??{})},fromPartial(e){let t=Zy();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.subagentRunId=e.subagentRunId??void 0,t}};function $y(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0,subagentRunId:void 0}}var eb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),e.subagentRunId!==void 0&&t.uint32(50).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=$y();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.delta=n.string();continue;case 5:if(e!==42)break;i.name=n.string();continue;case 6:if(e!==50)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return eb.fromPartial(e??{})},fromPartial(e){let t=$y();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function tb(){return{baseEvent:void 0,toolCallId:``,toolCallName:``,parentMessageId:void 0,subagentRunId:void 0}}var nb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.toolCallName!==``&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.subagentRunId!==void 0&&t.uint32(42).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=tb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue;case 5:if(e!==42)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return nb.fromPartial(e??{})},fromPartial(e){let t=tb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.toolCallName=e.toolCallName??``,t.parentMessageId=e.parentMessageId??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function rb(){return{baseEvent:void 0,toolCallId:``,delta:``,subagentRunId:void 0}}var ib={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.delta!==``&&t.uint32(26).string(e.delta),e.subagentRunId!==void 0&&t.uint32(34).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=rb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue;case 4:if(e!==34)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ib.fromPartial(e??{})},fromPartial(e){let t=rb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.delta=e.delta??``,t.subagentRunId=e.subagentRunId??void 0,t}};function ab(){return{baseEvent:void 0,toolCallId:``,subagentRunId:void 0}}var ob={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=ab();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ob.fromPartial(e??{})},fromPartial(e){let t=ab();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.subagentRunId=e.subagentRunId??void 0,t}};function sb(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0,subagentRunId:void 0}}var cb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),e.subagentRunId!==void 0&&t.uint32(50).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=sb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue;case 5:if(e!==42)break;i.delta=n.string();continue;case 6:if(e!==50)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return cb.fromPartial(e??{})},fromPartial(e){let t=sb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??void 0,t.toolCallName=e.toolCallName??void 0,t.parentMessageId=e.parentMessageId??void 0,t.delta=e.delta??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function lb(){return{baseEvent:void 0,subagentRunId:void 0,messageId:``,toolCallId:``,content:void 0,role:void 0,contentParts:[]}}var ub={encode(e,t=new Y){e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==``&&t.uint32(26).string(e.messageId),e.toolCallId!==``&&t.uint32(34).string(e.toolCallId),e.content!==void 0&&t.uint32(42).string(e.content),e.role!==void 0&&t.uint32(50).string(e.role);for(let n of e.contentParts)Oy.encode(n,t.uint32(58).fork()).join();return t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=lb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue;case 4:if(e!==34)break;i.toolCallId=n.string();continue;case 5:if(e!==42)break;i.content=n.string();continue;case 6:if(e!==50)break;i.role=n.string();continue;case 7:if(e!==58)break;i.contentParts.push(Oy.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ub.fromPartial(e??{})},fromPartial(e){let t=lb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??``,t.toolCallId=e.toolCallId??``,t.content=e.content??void 0,t.role=e.role??void 0,t.contentParts=e.contentParts?.map(e=>Oy.fromPartial(e))||[],t}};function db(){return{baseEvent:void 0,snapshot:void 0,subagentRunId:void 0}}var fb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&Z.encode(Z.wrap(e.snapshot),t.uint32(18).fork()).join(),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=db();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.snapshot=Z.unwrap(Z.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return fb.fromPartial(e??{})},fromPartial(e){let t=db();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function pb(){return{baseEvent:void 0,delta:[],subagentRunId:void 0}}var mb={encode(e,t=new Y){e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)cy.encode(n,t.uint32(18).fork()).join();return e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=pb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.delta.push(cy.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return mb.fromPartial(e??{})},fromPartial(e){let t=pb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(e=>cy.fromPartial(e))||[],t.subagentRunId=e.subagentRunId??void 0,t}};function hb(){return{baseEvent:void 0,messages:[]}}var gb={encode(e,t=new Y){e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)Py.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=hb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messages.push(Py.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return gb.fromPartial(e??{})},fromPartial(e){let t=hb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(e=>Py.fromPartial(e))||[],t}};function _b(){return{baseEvent:void 0,subagentRunId:void 0,messageId:``,activityType:``,content:void 0,replace:void 0}}var vb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==``&&t.uint32(26).string(e.messageId),e.activityType!==``&&t.uint32(34).string(e.activityType),e.content!==void 0&&ey.encode(ey.wrap(e.content),t.uint32(42).fork()).join(),e.replace!==void 0&&t.uint32(48).bool(e.replace),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=_b();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue;case 4:if(e!==34)break;i.activityType=n.string();continue;case 5:if(e!==42)break;i.content=ey.unwrap(ey.decode(n,n.uint32()));continue;case 6:if(e!==48)break;i.replace=n.bool();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return vb.fromPartial(e??{})},fromPartial(e){let t=_b();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??``,t.activityType=e.activityType??``,t.content=e.content??void 0,t.replace=e.replace??void 0,t}};function yb(){return{baseEvent:void 0,subagentRunId:void 0,messageId:``,activityType:``,patch:[]}}var bb={encode(e,t=new Y){e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==``&&t.uint32(26).string(e.messageId),e.activityType!==``&&t.uint32(34).string(e.activityType);for(let n of e.patch)cy.encode(n,t.uint32(42).fork()).join();return t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=yb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue;case 4:if(e!==34)break;i.activityType=n.string();continue;case 5:if(e!==42)break;i.patch.push(cy.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return bb.fromPartial(e??{})},fromPartial(e){let t=yb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??``,t.activityType=e.activityType??``,t.patch=e.patch?.map(e=>cy.fromPartial(e))||[],t}};function xb(){return{baseEvent:void 0,event:void 0,source:void 0,subagentRunId:void 0}}var Sb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&Z.encode(Z.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),e.subagentRunId!==void 0&&t.uint32(34).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=xb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.event=Z.unwrap(Z.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.source=n.string();continue;case 4:if(e!==34)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Sb.fromPartial(e??{})},fromPartial(e){let t=xb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function Cb(){return{baseEvent:void 0,name:``,value:void 0,subagentRunId:void 0}}var wb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==``&&t.uint32(18).string(e.name),e.value!==void 0&&Z.encode(Z.wrap(e.value),t.uint32(26).fork()).join(),e.subagentRunId!==void 0&&t.uint32(34).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Cb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.name=n.string();continue;case 3:if(e!==26)break;i.value=Z.unwrap(Z.decode(n,n.uint32()));continue;case 4:if(e!==34)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return wb.fromPartial(e??{})},fromPartial(e){let t=Cb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.name=e.name??``,t.value=e.value??void 0,t.subagentRunId=e.subagentRunId??void 0,t}};function Tb(){return{baseEvent:void 0,threadId:``,runId:``,parentRunId:void 0,input:void 0,protocolVersion:void 0}}var Eb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),e.parentRunId!==void 0&&t.uint32(34).string(e.parentRunId),e.input!==void 0&&Hy.encode(e.input,t.uint32(42).fork()).join(),e.protocolVersion!==void 0&&t.uint32(50).string(e.protocolVersion),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Tb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue;case 4:if(e!==34)break;i.parentRunId=n.string();continue;case 5:if(e!==42)break;i.input=Hy.decode(n,n.uint32());continue;case 6:if(e!==50)break;i.protocolVersion=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Eb.fromPartial(e??{})},fromPartial(e){let t=Tb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t.parentRunId=e.parentRunId??void 0,t.input=e.input!==void 0&&e.input!==null?Hy.fromPartial(e.input):void 0,t.protocolVersion=e.protocolVersion??void 0,t}};function Db(){return{baseEvent:void 0,threadId:``,runId:``,result:void 0,outcome:``,interrupts:[],usage:[],pendingToolCallIds:[]}}var Ob={encode(e,t=new Y){e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),e.result!==void 0&&Z.encode(Z.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==``&&t.uint32(42).string(e.outcome);for(let n of e.interrupts)Wy.encode(n,t.uint32(50).fork()).join();for(let n of e.usage)ix.encode(n,t.uint32(58).fork()).join();for(let n of e.pendingToolCallIds)t.uint32(66).string(n);return t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Db();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue;case 4:if(e!==34)break;i.result=Z.unwrap(Z.decode(n,n.uint32()));continue;case 5:if(e!==42)break;i.outcome=n.string();continue;case 6:if(e!==50)break;i.interrupts.push(Wy.decode(n,n.uint32()));continue;case 7:if(e!==58)break;i.usage.push(ix.decode(n,n.uint32()));continue;case 8:if(e!==66)break;i.pendingToolCallIds.push(n.string());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ob.fromPartial(e??{})},fromPartial(e){let t=Db();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t.result=e.result??void 0,t.outcome=e.outcome??``,t.interrupts=e.interrupts?.map(e=>Wy.fromPartial(e))||[],t.usage=e.usage?.map(e=>ix.fromPartial(e))||[],t.pendingToolCallIds=e.pendingToolCallIds?.map(e=>e)||[],t}};function kb(){return{baseEvent:void 0,code:void 0,message:``,usage:[]}}var Ab={encode(e,t=new Y){e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==``&&t.uint32(26).string(e.message);for(let n of e.usage)ix.encode(n,t.uint32(34).fork()).join();return t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=kb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.code=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue;case 4:if(e!==34)break;i.usage.push(ix.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ab.fromPartial(e??{})},fromPartial(e){let t=kb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??``,t.usage=e.usage?.map(e=>ix.fromPartial(e))||[],t}};function jb(){return{baseEvent:void 0,stepName:``,subagentRunId:void 0}}var Mb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=jb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue;case 3:if(e!==26)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Mb.fromPartial(e??{})},fromPartial(e){let t=jb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t.subagentRunId=e.subagentRunId??void 0,t}};function Nb(){return{baseEvent:void 0,stepName:``,subagentRunId:void 0}}var Pb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),e.subagentRunId!==void 0&&t.uint32(26).string(e.subagentRunId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Nb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue;case 3:if(e!==26)break;i.subagentRunId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Pb.fromPartial(e??{})},fromPartial(e){let t=Nb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t.subagentRunId=e.subagentRunId??void 0,t}};function Fb(){return{baseEvent:void 0,subagentRunId:void 0,messageId:``}}var Ib={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==``&&t.uint32(26).string(e.messageId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Fb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ib.fromPartial(e??{})},fromPartial(e){let t=Fb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??``,t}};function Lb(){return{baseEvent:void 0,subagentRunId:void 0,messageId:``,role:``}}var Rb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==``&&t.uint32(26).string(e.messageId),e.role!==``&&t.uint32(34).string(e.role),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Lb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue;case 4:if(e!==34)break;i.role=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Rb.fromPartial(e??{})},fromPartial(e){let t=Lb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??``,t.role=e.role??``,t}};function zb(){return{baseEvent:void 0,subagentRunId:void 0,messageId:``,delta:``}}var Bb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==``&&t.uint32(26).string(e.messageId),e.delta!==``&&t.uint32(34).string(e.delta),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=zb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue;case 4:if(e!==34)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Bb.fromPartial(e??{})},fromPartial(e){let t=zb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??``,t.delta=e.delta??``,t}};function Vb(){return{baseEvent:void 0,subagentRunId:void 0,messageId:``}}var Hb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==``&&t.uint32(26).string(e.messageId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Vb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Hb.fromPartial(e??{})},fromPartial(e){let t=Vb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??``,t}};function Ub(){return{baseEvent:void 0,subagentRunId:void 0,messageId:void 0,delta:void 0}}var Wb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==void 0&&t.uint32(26).string(e.messageId),e.delta!==void 0&&t.uint32(34).string(e.delta),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Ub();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue;case 4:if(e!==34)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Wb.fromPartial(e??{})},fromPartial(e){let t=Ub();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??void 0,t.delta=e.delta??void 0,t}};function Gb(){return{baseEvent:void 0,subagentRunId:void 0,messageId:``}}var Kb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.messageId!==``&&t.uint32(26).string(e.messageId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Gb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.messageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Kb.fromPartial(e??{})},fromPartial(e){let t=Gb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.messageId=e.messageId??``,t}};function qb(){return{baseEvent:void 0,subagentRunId:void 0,subtype:``,entityId:``,encryptedValue:``}}var Jb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==void 0&&t.uint32(18).string(e.subagentRunId),e.subtype!==``&&t.uint32(26).string(e.subtype),e.entityId!==``&&t.uint32(34).string(e.entityId),e.encryptedValue!==``&&t.uint32(42).string(e.encryptedValue),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=qb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.subtype=n.string();continue;case 4:if(e!==34)break;i.entityId=n.string();continue;case 5:if(e!==42)break;i.encryptedValue=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Jb.fromPartial(e??{})},fromPartial(e){let t=qb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??void 0,t.subtype=e.subtype??``,t.entityId=e.entityId??``,t.encryptedValue=e.encryptedValue??``,t}};function Yb(){return{baseEvent:void 0,subagentRunId:``,name:``,description:void 0,parentSubagentRunId:void 0,parentToolCallId:void 0,parentMessageId:void 0}}var Xb={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==``&&t.uint32(18).string(e.subagentRunId),e.name!==``&&t.uint32(26).string(e.name),e.description!==void 0&&t.uint32(34).string(e.description),e.parentSubagentRunId!==void 0&&t.uint32(42).string(e.parentSubagentRunId),e.parentToolCallId!==void 0&&t.uint32(50).string(e.parentToolCallId),e.parentMessageId!==void 0&&t.uint32(58).string(e.parentMessageId),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Yb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.name=n.string();continue;case 4:if(e!==34)break;i.description=n.string();continue;case 5:if(e!==42)break;i.parentSubagentRunId=n.string();continue;case 6:if(e!==50)break;i.parentToolCallId=n.string();continue;case 7:if(e!==58)break;i.parentMessageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Xb.fromPartial(e??{})},fromPartial(e){let t=Yb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??``,t.name=e.name??``,t.description=e.description??void 0,t.parentSubagentRunId=e.parentSubagentRunId??void 0,t.parentToolCallId=e.parentToolCallId??void 0,t.parentMessageId=e.parentMessageId??void 0,t}};function Zb(){return{baseEvent:void 0,subagentRunId:``,result:void 0,outcome:``,interruptIds:[]}}var Qb={encode(e,t=new Y){e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==``&&t.uint32(18).string(e.subagentRunId),e.result!==void 0&&Z.encode(Z.wrap(e.result),t.uint32(26).fork()).join(),e.outcome!==``&&t.uint32(34).string(e.outcome);for(let n of e.interruptIds)t.uint32(42).string(n);return t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=Zb();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.result=Z.unwrap(Z.decode(n,n.uint32()));continue;case 4:if(e!==34)break;i.outcome=n.string();continue;case 5:if(e!==42)break;i.interruptIds.push(n.string());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Qb.fromPartial(e??{})},fromPartial(e){let t=Zb();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??``,t.result=e.result??void 0,t.outcome=e.outcome??``,t.interruptIds=e.interruptIds?.map(e=>e)||[],t}};function $b(){return{baseEvent:void 0,subagentRunId:``,message:``,code:void 0}}var ex={encode(e,t=new Y){return e.baseEvent!==void 0&&Q.encode(e.baseEvent,t.uint32(10).fork()).join(),e.subagentRunId!==``&&t.uint32(18).string(e.subagentRunId),e.message!==``&&t.uint32(26).string(e.message),e.code!==void 0&&t.uint32(34).string(e.code),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=$b();for(;n.pos>>3){case 1:if(e!==10)break;i.baseEvent=Q.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.subagentRunId=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue;case 4:if(e!==34)break;i.code=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ex.fromPartial(e??{})},fromPartial(e){let t=$b();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?Q.fromPartial(e.baseEvent):void 0,t.subagentRunId=e.subagentRunId??``,t.message=e.message??``,t.code=e.code??void 0,t}};function tx(){return{textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0,subagentStarted:void 0,subagentFinished:void 0,subagentError:void 0,toolCallResult:void 0,activitySnapshot:void 0,activityDelta:void 0,reasoningStart:void 0,reasoningMessageStart:void 0,reasoningMessageContent:void 0,reasoningMessageEnd:void 0,reasoningMessageChunk:void 0,reasoningEnd:void 0,reasoningEncryptedValue:void 0}}var nx={encode(e,t=new Y){return e.textMessageStart!==void 0&&Jy.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&Xy.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&Qy.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&nb.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&ib.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&ob.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&fb.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&mb.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&gb.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&Sb.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&wb.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&Eb.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&Ob.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&Ab.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&Mb.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&Pb.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&eb.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&cb.encode(e.toolCallChunk,t.uint32(146).fork()).join(),e.subagentStarted!==void 0&&Xb.encode(e.subagentStarted,t.uint32(154).fork()).join(),e.subagentFinished!==void 0&&Qb.encode(e.subagentFinished,t.uint32(162).fork()).join(),e.subagentError!==void 0&&ex.encode(e.subagentError,t.uint32(170).fork()).join(),e.toolCallResult!==void 0&&ub.encode(e.toolCallResult,t.uint32(178).fork()).join(),e.activitySnapshot!==void 0&&vb.encode(e.activitySnapshot,t.uint32(186).fork()).join(),e.activityDelta!==void 0&&bb.encode(e.activityDelta,t.uint32(194).fork()).join(),e.reasoningStart!==void 0&&Ib.encode(e.reasoningStart,t.uint32(202).fork()).join(),e.reasoningMessageStart!==void 0&&Rb.encode(e.reasoningMessageStart,t.uint32(210).fork()).join(),e.reasoningMessageContent!==void 0&&Bb.encode(e.reasoningMessageContent,t.uint32(218).fork()).join(),e.reasoningMessageEnd!==void 0&&Hb.encode(e.reasoningMessageEnd,t.uint32(226).fork()).join(),e.reasoningMessageChunk!==void 0&&Wb.encode(e.reasoningMessageChunk,t.uint32(234).fork()).join(),e.reasoningEnd!==void 0&&Kb.encode(e.reasoningEnd,t.uint32(242).fork()).join(),e.reasoningEncryptedValue!==void 0&&Jb.encode(e.reasoningEncryptedValue,t.uint32(250).fork()).join(),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=tx();for(;n.pos>>3){case 1:if(e!==10)break;i.textMessageStart=Jy.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.textMessageContent=Xy.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.textMessageEnd=Qy.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.toolCallStart=nb.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.toolCallArgs=ib.decode(n,n.uint32());continue;case 6:if(e!==50)break;i.toolCallEnd=ob.decode(n,n.uint32());continue;case 7:if(e!==58)break;i.stateSnapshot=fb.decode(n,n.uint32());continue;case 8:if(e!==66)break;i.stateDelta=mb.decode(n,n.uint32());continue;case 9:if(e!==74)break;i.messagesSnapshot=gb.decode(n,n.uint32());continue;case 10:if(e!==82)break;i.raw=Sb.decode(n,n.uint32());continue;case 11:if(e!==90)break;i.custom=wb.decode(n,n.uint32());continue;case 12:if(e!==98)break;i.runStarted=Eb.decode(n,n.uint32());continue;case 13:if(e!==106)break;i.runFinished=Ob.decode(n,n.uint32());continue;case 14:if(e!==114)break;i.runError=Ab.decode(n,n.uint32());continue;case 15:if(e!==122)break;i.stepStarted=Mb.decode(n,n.uint32());continue;case 16:if(e!==130)break;i.stepFinished=Pb.decode(n,n.uint32());continue;case 17:if(e!==138)break;i.textMessageChunk=eb.decode(n,n.uint32());continue;case 18:if(e!==146)break;i.toolCallChunk=cb.decode(n,n.uint32());continue;case 19:if(e!==154)break;i.subagentStarted=Xb.decode(n,n.uint32());continue;case 20:if(e!==162)break;i.subagentFinished=Qb.decode(n,n.uint32());continue;case 21:if(e!==170)break;i.subagentError=ex.decode(n,n.uint32());continue;case 22:if(e!==178)break;i.toolCallResult=ub.decode(n,n.uint32());continue;case 23:if(e!==186)break;i.activitySnapshot=vb.decode(n,n.uint32());continue;case 24:if(e!==194)break;i.activityDelta=bb.decode(n,n.uint32());continue;case 25:if(e!==202)break;i.reasoningStart=Ib.decode(n,n.uint32());continue;case 26:if(e!==210)break;i.reasoningMessageStart=Rb.decode(n,n.uint32());continue;case 27:if(e!==218)break;i.reasoningMessageContent=Bb.decode(n,n.uint32());continue;case 28:if(e!==226)break;i.reasoningMessageEnd=Hb.decode(n,n.uint32());continue;case 29:if(e!==234)break;i.reasoningMessageChunk=Wb.decode(n,n.uint32());continue;case 30:if(e!==242)break;i.reasoningEnd=Kb.decode(n,n.uint32());continue;case 31:if(e!==250)break;i.reasoningEncryptedValue=Jb.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return nx.fromPartial(e??{})},fromPartial(e){let t=tx();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?Jy.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?Xy.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?Qy.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?nb.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?ib.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?ob.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?fb.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?mb.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?gb.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?Sb.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?wb.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?Eb.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?Ob.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?Ab.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?Mb.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?Pb.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?eb.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?cb.fromPartial(e.toolCallChunk):void 0,t.subagentStarted=e.subagentStarted!==void 0&&e.subagentStarted!==null?Xb.fromPartial(e.subagentStarted):void 0,t.subagentFinished=e.subagentFinished!==void 0&&e.subagentFinished!==null?Qb.fromPartial(e.subagentFinished):void 0,t.subagentError=e.subagentError!==void 0&&e.subagentError!==null?ex.fromPartial(e.subagentError):void 0,t.toolCallResult=e.toolCallResult!==void 0&&e.toolCallResult!==null?ub.fromPartial(e.toolCallResult):void 0,t.activitySnapshot=e.activitySnapshot!==void 0&&e.activitySnapshot!==null?vb.fromPartial(e.activitySnapshot):void 0,t.activityDelta=e.activityDelta!==void 0&&e.activityDelta!==null?bb.fromPartial(e.activityDelta):void 0,t.reasoningStart=e.reasoningStart!==void 0&&e.reasoningStart!==null?Ib.fromPartial(e.reasoningStart):void 0,t.reasoningMessageStart=e.reasoningMessageStart!==void 0&&e.reasoningMessageStart!==null?Rb.fromPartial(e.reasoningMessageStart):void 0,t.reasoningMessageContent=e.reasoningMessageContent!==void 0&&e.reasoningMessageContent!==null?Bb.fromPartial(e.reasoningMessageContent):void 0,t.reasoningMessageEnd=e.reasoningMessageEnd!==void 0&&e.reasoningMessageEnd!==null?Hb.fromPartial(e.reasoningMessageEnd):void 0,t.reasoningMessageChunk=e.reasoningMessageChunk!==void 0&&e.reasoningMessageChunk!==null?Wb.fromPartial(e.reasoningMessageChunk):void 0,t.reasoningEnd=e.reasoningEnd!==void 0&&e.reasoningEnd!==null?Kb.fromPartial(e.reasoningEnd):void 0,t.reasoningEncryptedValue=e.reasoningEncryptedValue!==void 0&&e.reasoningEncryptedValue!==null?Jb.fromPartial(e.reasoningEncryptedValue):void 0,t}};function rx(){return{provider:void 0,model:void 0,inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0,cacheWriteInputTokens:void 0}}var ix={encode(e,t=new Y){return e.provider!==void 0&&t.uint32(10).string(e.provider),e.model!==void 0&&t.uint32(18).string(e.model),e.inputTokens!==void 0&&t.uint32(24).int64(e.inputTokens),e.outputTokens!==void 0&&t.uint32(32).int64(e.outputTokens),e.totalTokens!==void 0&&t.uint32(40).int64(e.totalTokens),e.reasoningTokens!==void 0&&t.uint32(48).int64(e.reasoningTokens),e.cachedInputTokens!==void 0&&t.uint32(56).int64(e.cachedInputTokens),e.cacheWriteInputTokens!==void 0&&t.uint32(64).int64(e.cacheWriteInputTokens),t},decode(e,t){let n=e instanceof X?e:new X(e),r=t===void 0?n.len:n.pos+t,i=rx();for(;n.pos>>3){case 1:if(e!==10)break;i.provider=n.string();continue;case 2:if(e!==18)break;i.model=n.string();continue;case 3:if(e!==24)break;i.inputTokens=ax(n.int64());continue;case 4:if(e!==32)break;i.outputTokens=ax(n.int64());continue;case 5:if(e!==40)break;i.totalTokens=ax(n.int64());continue;case 6:if(e!==48)break;i.reasoningTokens=ax(n.int64());continue;case 7:if(e!==56)break;i.cachedInputTokens=ax(n.int64());continue;case 8:if(e!==64)break;i.cacheWriteInputTokens=ax(n.int64());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ix.fromPartial(e??{})},fromPartial(e){let t=rx();return t.provider=e.provider??void 0,t.model=e.model??void 0,t.inputTokens=e.inputTokens??void 0,t.outputTokens=e.outputTokens??void 0,t.totalTokens=e.totalTokens??void 0,t.reasoningTokens=e.reasoningTokens??void 0,t.cachedInputTokens=e.cachedInputTokens??void 0,t.cacheWriteInputTokens=e.cacheWriteInputTokens??void 0,t}};function ax(e){let t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error(`Value is larger than Number.MAX_SAFE_INTEGER`);if(te&&typeof e==`object`?e:void 0,sx=e=>Array.isArray(e)?e:[],cx=()=>typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS,lx=()=>{cx()||console.warn(`[ag-ui][proto] Dropped a content part this build does not know: the protocol has a variant this SDK predates.`)};new Set(Object.values(j));var ux={textMessageStart:`TEXT_MESSAGE_START`,textMessageContent:`TEXT_MESSAGE_CONTENT`,textMessageEnd:`TEXT_MESSAGE_END`,textMessageChunk:`TEXT_MESSAGE_CHUNK`,toolCallStart:`TOOL_CALL_START`,toolCallArgs:`TOOL_CALL_ARGS`,toolCallEnd:`TOOL_CALL_END`,toolCallChunk:`TOOL_CALL_CHUNK`,toolCallResult:`TOOL_CALL_RESULT`,stateSnapshot:`STATE_SNAPSHOT`,stateDelta:`STATE_DELTA`,messagesSnapshot:`MESSAGES_SNAPSHOT`,activitySnapshot:`ACTIVITY_SNAPSHOT`,activityDelta:`ACTIVITY_DELTA`,raw:`RAW`,custom:`CUSTOM`,runStarted:`RUN_STARTED`,runFinished:`RUN_FINISHED`,runError:`RUN_ERROR`,stepStarted:`STEP_STARTED`,stepFinished:`STEP_FINISHED`,reasoningStart:`REASONING_START`,reasoningMessageStart:`REASONING_MESSAGE_START`,reasoningMessageContent:`REASONING_MESSAGE_CONTENT`,reasoningMessageEnd:`REASONING_MESSAGE_END`,reasoningMessageChunk:`REASONING_MESSAGE_CHUNK`,reasoningEnd:`REASONING_END`,reasoningEncryptedValue:`REASONING_ENCRYPTED_VALUE`,subagentStarted:`SUBAGENT_STARTED`,subagentFinished:`SUBAGENT_FINISHED`,subagentError:`SUBAGENT_ERROR`},dx=new Set([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]),fx=e=>{let t=ox(e);if(t){if([t.data,t.url,t.file].filter(Boolean).length>1)throw Error(`Invalid event: source carries more than one arm`);if(t.data){let e=t.data;return{type:`data`,value:e.value,mimeType:e.mimeType}}if(t.url){let e=t.url;return{type:`url`,value:e.value,mimeType:e.mimeType}}if(t.file){let e=t.file;return{type:`file`,value:e.value,provider:e.provider,mimeType:e.mimeType}}}},px=e=>{let t=ox(e);if(t){if([t.text,t.image,t.audio,t.video,t.document].filter(Boolean).length>1)throw Error(`Invalid event: content part carries more than one arm`);if(t.text){let e=t.text;return{type:`text`,id:e.id,text:e.text,metadata:e.metadata}}if(t.image){let e=t.image;return e.source!==void 0&&fx(e.source)===void 0?void 0:{type:`image`,id:e.id,source:fx(e.source),metadata:e.metadata}}if(t.audio){let e=t.audio;return e.source!==void 0&&fx(e.source)===void 0?void 0:{type:`audio`,id:e.id,source:fx(e.source),metadata:e.metadata}}if(t.video){let e=t.video;return e.source!==void 0&&fx(e.source)===void 0?void 0:{type:`video`,id:e.id,source:fx(e.source),metadata:e.metadata}}if(t.document){let e=t.document;return e.source!==void 0&&fx(e.source)===void 0?void 0:{type:`document`,id:e.id,source:fx(e.source),metadata:e.metadata}}}},mx=new Set([`activity`]),hx=new Set([`user`,`tool`]),gx=new Set([`developer`,`system`,`assistant`,`user`,`tool`,`activity`,`reasoning`]),_x=e=>{let t=ox(e)??{},n={...t},r=typeof t.role==`string`?t.role:``,i=gx.has(r),a=i?hx.has(r):sx(t.contentParts).length>0,o=i?mx.has(r):!a&&t.activityContent!==void 0;if(!i&&(t.content===void 0?0:1)+ +(sx(t.contentParts).length>0)+(t.activityContent===void 0?0:1)>1)throw Error(`Invalid event: message carries more than one content form`);if(i){if(!a&&sx(t.contentParts).length>0)throw Error(`Invalid event: message carries content parts for a role that has none`);if(t.activityContent!==void 0&&!o)throw Error(`Invalid event: message carries activity content for a non-activity role`);if(o&&t.content!==void 0)throw Error(`Invalid event: activity content cannot ride with other content forms`);if(a&&t.content!==void 0&&sx(t.contentParts).length>0)throw Error(`Invalid event: message carries both string content and content parts`)}return a&&t.content===void 0&&(n.content=sx(t.contentParts).map(e=>{let t=px(e);return t===void 0&&lx(),t}).filter(e=>e!==void 0)),o&&t.activityContent!==void 0&&(n.content=t.activityContent),delete n.activityContent,delete n.contentParts,sx(t.toolCalls).length===0&&delete n.toolCalls,Object.keys(n).forEach(e=>{n[e]===void 0&&delete n[e]}),n},vx=e=>{if(Array.isArray(e)){for(let t of e)vx(t);return}let t=ox(e);if(t)for(let e of Object.keys(t))t[e]===void 0?delete t[e]:vx(t[e])},yx=e=>{let t=ox(e);if(!t)return;let n={};return t.threadId!==void 0&&(n.threadId=t.threadId),t.runId!==void 0&&(n.runId=t.runId),t.protocolVersion!==void 0&&(n.protocolVersion=t.protocolVersion),t.parentRunId!==void 0&&(n.parentRunId=t.parentRunId),t.state!==void 0&&(n.state=t.state),n.messages=sx(t.messages).map(_x).filter(e=>e!==void 0),n.tools=sx(t.tools),n.context=sx(t.context),t.forwardedProps!==void 0&&(n.forwardedProps=t.forwardedProps),n.resume=sx(t.resume),n},bx={TextMessageStartEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},BaseEvent:{singular:new Set([3,4]),descend:{},google:{3:`google.protobuf.Value`,4:`google.protobuf.Struct`}},TextMessageContentEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},TextMessageEndEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ToolCallStartEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ToolCallArgsEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ToolCallEndEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},StateSnapshotEvent:{singular:new Set([1,2]),descend:{1:`BaseEvent`},google:{2:`google.protobuf.Value`}},StateDeltaEvent:{singular:new Set([1]),descend:{1:`BaseEvent`,2:`JsonPatchOperation`}},JsonPatchOperation:{singular:new Set([4]),descend:{},google:{4:`google.protobuf.Value`}},MessagesSnapshotEvent:{singular:new Set([1]),descend:{1:`BaseEvent`,2:`Message`}},Message:{singular:new Set([9,13]),descend:{5:`ToolCall`,8:`InputContent`},google:{9:`google.protobuf.Struct`,13:`google.protobuf.Struct`}},ToolCall:{singular:new Set([3,4]),descend:{},google:{4:`google.protobuf.Struct`}},InputContent:{singular:new Set([1,2,3,4,5]),descend:{1:`TextInputPart`,2:`ImageInputPart`,3:`AudioInputPart`,4:`VideoInputPart`,5:`DocumentInputPart`},arms:new Set([1,2,3,4,5])},TextInputPart:{singular:new Set([3]),descend:{},google:{3:`google.protobuf.Value`}},ImageInputPart:{singular:new Set([1,2]),descend:{1:`InputContentSource`},google:{2:`google.protobuf.Value`}},InputContentSource:{singular:new Set([1,2,3]),descend:{},arms:new Set([1,2,3])},AudioInputPart:{singular:new Set([1,2]),descend:{1:`InputContentSource`},google:{2:`google.protobuf.Value`}},VideoInputPart:{singular:new Set([1,2]),descend:{1:`InputContentSource`},google:{2:`google.protobuf.Value`}},DocumentInputPart:{singular:new Set([1,2]),descend:{1:`InputContentSource`},google:{2:`google.protobuf.Value`}},RawEvent:{singular:new Set([1,2]),descend:{1:`BaseEvent`},google:{2:`google.protobuf.Value`}},CustomEvent:{singular:new Set([1,3]),descend:{1:`BaseEvent`},google:{3:`google.protobuf.Value`}},RunStartedEvent:{singular:new Set([1,5]),descend:{1:`BaseEvent`,5:`RunAgentInput`}},RunAgentInput:{singular:new Set([4,8]),descend:{5:`Message`,6:`Tool`,9:`ResumeEntry`},google:{4:`google.protobuf.Value`,8:`google.protobuf.Value`}},Tool:{singular:new Set([3,4]),descend:{},google:{3:`google.protobuf.Value`,4:`google.protobuf.Struct`}},ResumeEntry:{singular:new Set([3,4]),descend:{},google:{3:`google.protobuf.Value`,4:`google.protobuf.Struct`}},RunFinishedEvent:{singular:new Set([1,4]),descend:{1:`BaseEvent`,6:`Interrupt`},google:{4:`google.protobuf.Value`}},Interrupt:{singular:new Set([5,7]),descend:{},google:{5:`google.protobuf.Value`,7:`google.protobuf.Value`}},RunErrorEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},StepStartedEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},StepFinishedEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},TextMessageChunkEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ToolCallChunkEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},SubagentStartedEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},SubagentFinishedEvent:{singular:new Set([1,3]),descend:{1:`BaseEvent`},google:{3:`google.protobuf.Value`}},SubagentErrorEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ToolCallResultEvent:{singular:new Set([1]),descend:{1:`BaseEvent`,7:`InputContent`}},ActivitySnapshotEvent:{singular:new Set([1,5]),descend:{1:`BaseEvent`},google:{5:`google.protobuf.Struct`}},ActivityDeltaEvent:{singular:new Set([1]),descend:{1:`BaseEvent`,5:`JsonPatchOperation`}},ReasoningStartEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ReasoningMessageStartEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ReasoningMessageContentEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ReasoningMessageEndEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ReasoningMessageChunkEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ReasoningEndEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},ReasoningEncryptedValueEvent:{singular:new Set([1]),descend:{1:`BaseEvent`}},"google.protobuf.Struct":{singular:new Set,descend:{1:`google.protobuf.Struct.FieldsEntry`}},"google.protobuf.Struct.FieldsEntry":{singular:new Set([2]),descend:{2:`google.protobuf.Value`}},"google.protobuf.Value":{singular:new Set([5,6]),descend:{5:`google.protobuf.Struct`,6:`google.protobuf.ListValue`},arms:new Set([1,2,3,4,5,6]),armWireTypes:{1:0,2:1,3:2,4:0,5:2,6:2}},"google.protobuf.ListValue":{singular:new Set,descend:{1:`google.protobuf.Value`}}},xx={1:`TextMessageStartEvent`,2:`TextMessageContentEvent`,3:`TextMessageEndEvent`,4:`ToolCallStartEvent`,5:`ToolCallArgsEvent`,6:`ToolCallEndEvent`,7:`StateSnapshotEvent`,8:`StateDeltaEvent`,9:`MessagesSnapshotEvent`,10:`RawEvent`,11:`CustomEvent`,12:`RunStartedEvent`,13:`RunFinishedEvent`,14:`RunErrorEvent`,15:`StepStartedEvent`,16:`StepFinishedEvent`,17:`TextMessageChunkEvent`,18:`ToolCallChunkEvent`,19:`SubagentStartedEvent`,20:`SubagentFinishedEvent`,21:`SubagentErrorEvent`,22:`ToolCallResultEvent`,23:`ActivitySnapshotEvent`,24:`ActivityDeltaEvent`,25:`ReasoningStartEvent`,26:`ReasoningMessageStartEvent`,27:`ReasoningMessageContentEvent`,28:`ReasoningMessageEndEvent`,29:`ReasoningMessageChunkEvent`,30:`ReasoningEndEvent`,31:`ReasoningEncryptedValueEvent`};function Sx(e,t){let n=0,r=0;for(;;){if(t.offset>=e.length)throw Error(`Invalid event`);let i=e[t.offset++];if(r<28?n+=(i&127)*2**r:r===28&&(n+=(i&15)*2**28),r+=7,!(i&128))return n}}function Cx(e,t){let n={offset:0},r=0,i=0;for(;n.offsete.length)throw Error(`Invalid event`);if(r===0){if(t.arms?.has(o)){if(i!==0&&i!==o)throw Error(`Invalid event`);i=o}let r=t.descend[o];if(r!==void 0){let t=bx[r];t!==void 0&&Cx(e.subarray(n.offset,n.offset+a),t)}}n.offset+=a}else if(s===5)n.offset+=4;else throw Error(`Invalid event`);if(n.offset>e.length)throw Error(`Invalid event`)}if(r!==0)throw Error(`Invalid event`)}function wx(e){let t=new Set,n={offset:0},r=0;for(;n.offset0&&!t.has(a))throw Error(`Invalid event`);t.add(a)}if(o===0)Sx(e,n);else if(o===1)n.offset+=8;else if(o===2){let t=Sx(e,n);if(n.offset+t>e.length)throw Error(`Invalid event`);if(r===0){let r=xx[a];if(r!==void 0){let i=bx[r];i!==void 0&&Cx(e.subarray(n.offset,n.offset+t),i)}}n.offset+=t}else if(o===5)n.offset+=4;else throw Error(`Invalid event`);if(n.offset>e.length)throw Error(`Invalid event`)}if(r!==0)throw Error(`Invalid event`)}function Tx(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function Ex(e,t){let n=new X(e),r=[],i=new Map,a,o=!1;for(;n.pos1||n!==t){s.push(new Y().uint32(e.number*8+2).bytes(n).finish()),o=!0;continue}}s.push(e.raw)}return o?Tx(s):e}var Dx=class extends Error{constructor(e=`Unknown event type`){super(e),this.name=`AGUIUnknownEventTypeError`}};function Ox(e,t,n,r){let i=0,a=0,o=0;for(;;){if(t.offset>=e.length||o>=n)return-1;let s=e[t.offset++];if(o+=1,o===n&&s>r)return-1;if(i+=(s&127)*2**a,a+=7,!(s&128))return i}}var kx=(e,t)=>Ox(e,t,5,15),Ax=(e,t)=>Ox(e,t,10,1);function jx(e){let t={offset:0},n=[];for(;t.offsete.length)return!1;t.offset+=n}else return!1;if(t.offset>e.length)return!1}return n.length===0}function Mx(e){let t={offset:0},n=[],r=0;for(;t.offsete.length)return!1;if(s){if(dx.has(a)||!jx(e.subarray(t.offset,t.offset+n)))return!1;r+=1}t.offset+=n}else return!1;if(t.offset>e.length)return!1}return n.length===0&&r>0}function Nx(e){wx(e);let t=nx.decode(Ex(e,{singular:dx,descend:xx})),n=Object.entries(t).filter(([,e])=>e!==void 0);if(n.length!==1)throw n.length===0&&Mx(e)?new Dx:Error(`Invalid event`);let r=n[0],i=ux[r[0]];if(i===void 0)throw Error(`Invalid event`);let a=r[1],o=ox(a.baseEvent);if(!o)throw Error(`Invalid event`);let s=Gy[o.type];if(s!==i)throw Error(`Invalid event: envelope carries `+i+` but the base event declares `+String(s));if(a.type=i,a.timestamp=o.timestamp,a.rawEvent=o.rawEvent,o.metadata!==void 0&&(a.metadata=o.metadata),delete a.baseEvent,a.type===`MESSAGES_SNAPSHOT`&&Array.isArray(a.messages)&&(a.messages=a.messages.map(_x).filter(e=>e!==void 0)),a.type===`RUN_FINISHED`){let e=a,t=typeof e.outcome==`string`&&e.outcome!==``?e.outcome:void 0,n={};n.pendingToolCallIds=e.pendingToolCallIds,delete e.pendingToolCallIds,n.interrupts=e.interrupts,delete e.interrupts,delete e.outcome,t===void 0&&(sx(n.pendingToolCallIds).length>0&&(e.pendingToolCallIds=n.pendingToolCallIds),sx(n.interrupts).length>0&&(e.interrupts=n.interrupts)),t===`success`&&(e.outcome={type:`success`,...sx(n.pendingToolCallIds).length>0?{pendingToolCallIds:n.pendingToolCallIds}:{},...sx(n.interrupts).length>0?{interrupts:n.interrupts}:{}}),t===`interrupt`&&(e.outcome={type:`interrupt`,interrupts:sx(n.interrupts),...sx(n.pendingToolCallIds).length>0?{pendingToolCallIds:n.pendingToolCallIds}:{}}),t===`cancelled`&&(e.outcome={type:`cancelled`,...sx(n.pendingToolCallIds).length>0?{pendingToolCallIds:n.pendingToolCallIds}:{},...sx(n.interrupts).length>0?{interrupts:n.interrupts}:{}}),t!==void 0&&![`success`,`interrupt`,`cancelled`].includes(t)&&(e.outcome={type:t,...sx(n.pendingToolCallIds).length>0?{pendingToolCallIds:n.pendingToolCallIds}:{},...sx(n.interrupts).length>0?{interrupts:n.interrupts}:{}})}if(a.type===`SUBAGENT_FINISHED`){let e=a,t=typeof e.outcome==`string`&&e.outcome!==``?e.outcome:void 0,n={};n.interruptIds=e.interruptIds,delete e.interruptIds,delete e.outcome,t===void 0&&sx(n.interruptIds).length>0&&(e.interruptIds=n.interruptIds),t===`success`&&(e.outcome={type:`success`,...sx(n.interruptIds).length>0?{interruptIds:n.interruptIds}:{}}),t===`suspended`&&(e.outcome={type:`suspended`,...sx(n.interruptIds).length>0?{interruptIds:n.interruptIds}:{}}),t!==void 0&&![`success`,`suspended`].includes(t)&&(e.outcome={type:t,...sx(n.interruptIds).length>0?{interruptIds:n.interruptIds}:{}})}if(a.type===`STATE_DELTA`&&Array.isArray(a.delta)&&(a.delta=a.delta.map(e=>{let t=oy[e.op];return e.op=typeof t==`string`&&t!==`UNRECOGNIZED`?t.toLowerCase():String(e.op),Object.keys(e).forEach(t=>{e[t]===void 0&&delete e[t]}),e})),a.type===`ACTIVITY_DELTA`&&Array.isArray(a.patch)&&(a.patch=a.patch.map(e=>{let t=oy[e.op];return e.op=typeof t==`string`&&t!==`UNRECOGNIZED`?t.toLowerCase():String(e.op),Object.keys(e).forEach(t=>{e[t]===void 0&&delete e[t]}),e})),a.type===`RUN_FINISHED`&&Array.isArray(a.usage)&&a.usage.length===0&&delete a.usage,a.type===`RUN_ERROR`&&Array.isArray(a.usage)&&a.usage.length===0&&delete a.usage,a.type===`TOOL_CALL_RESULT`){let e=a;if(e.content!==void 0&&sx(e.contentParts).length>0)throw Error(`Invalid event: content carries both string content and content parts`);e.content===void 0&&(e.content=sx(e.contentParts).map(e=>{let t=px(e);return t===void 0&&lx(),t}).filter(e=>e!==void 0)),delete e.contentParts}return a.type===`RUN_STARTED`&&a.input!==void 0&&(a.input=yx(a.input)),vx(a),a}var Px=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Fx=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(Px);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},Ix=e=>e===`*`||e===`x`||e===`X`,Lx=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},Rx=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],zx=(e,t)=>{if(Ix(e)||Ix(t))return 0;let[n,r]=Rx(Lx(e),Lx(t));return n>r?1:n{for(let n=0;n{let n=Fx(e),r=Fx(t),i=n.pop(),a=r.pop(),o=Bx(n,r);return o===0?i&&a?Bx(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o},Hx=e=>typeof e==`string`&&/^[v\d]/.test(e)&&Px.test(e),Ux=`@ag-ui/client`;function Wx(e){if(!e.metadata||!Object.prototype.hasOwnProperty.call(e.metadata,Ux))return;let t=e.metadata?.[Ux];if(!t||typeof t!=`object`||Array.isArray(t))return[];if(!Object.prototype.hasOwnProperty.call(t,`authoritativeActivityTypes`))return;let n=t.authoritativeActivityTypes;return n===null?null:Array.isArray(n)&&n.every(e=>typeof e==`string`)?n:[]}var $=e=>{if(typeof structuredClone==`function`)return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function Gx(){return qi()}function Kx(e){return e instanceof TypeError&&/read[- ]?only|not extensible|cannot add property|cannot delete property|can't be deleted|unable to delete property|object is frozen|is not writable/i.test(e.message)}function qx(e){if(Object.freeze(e),typeof e==`object`&&e)for(let t of Object.values(e))typeof t==`object`&&t&&!Object.isFrozen(t)&&qx(t);return e}var Jx=524288;function Yx(e,t,n){let r=0,i=[e,t],a=new WeakSet;for(;i.length>0;){let e=i.pop();if(typeof e==`string`){if(r+=e.length,r>n)return!0}else if(typeof e==`object`&&e){if(a.has(e))continue;if(a.add(e),Array.isArray(e))for(let t=0;tn)return!0;i.push(e[o])}}}}return!1}async function Xx(e,t,n,r){let i=typeof process<`u`&&!0,a=i&&!!{}.VITEST_WORKER_ID,o=i&&!!{}.VITEST_WORKER_ID,s=o&&!Yx(t,n,Jx),c=s?$(t):t,l=s?$(n):n,u=!1,d=!1,f;for(let t of e)try{s&&(qx(c),qx(l));let e=await r(t,c,l);if(e===void 0)continue;let n=!1;if(e.messages!==void 0&&e.messages!==c&&(c=$(e.messages),u=!0,n=!0),e.state!==void 0&&e.state!==l&&(l=$(e.state),d=!0,n=!0),s&&n&&Yx(c,l,Jx)&&(s=!1),f=e.stopPropagation,f===!0)break}catch(e){if(a&&e instanceof TypeError)throw e;s&&o&&Kx(e)?console.error(`AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.`,e):console.error(`Subscriber error:`,e);continue}return{...u?{messages:Object.isFrozen(c)?$(c):c}:{},...d?{state:Object.isFrozen(l)?$(l):l}:{},...f===void 0?{}:{stopPropagation:f}}}function Zx(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,n=e.lifecycle??!0,r=e.verbose??!1;return{enabled:t||n,events:t,lifecycle:n,verbose:r}}function Qx(e){if(e instanceof $x)return e;if(e===!0)return new $x(Zx(!0))}var $x=class{constructor(e){this.config=e}event(e,t,n,r){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof n==`string`?n:JSON.stringify(n)):console.debug(`[${e}] ${t}`,r??n))}lifecycle(e,t,n){this.config.lifecycle&&(n?console.debug(`[${e}] ${t}`,n):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function eS(e){return e.enabled?new $x(e):void 0}function tS(e,t,n){if(t){let r=e.find(e=>e.id===t);if(r?.role===`assistant`)return r;r&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${r.role}' message, not assistant — falling back to toolCallId`);let i={id:r?n:t,role:`assistant`,toolCalls:[]};return e.push(i),i}let r={id:n,role:`assistant`,toolCalls:[]};return e.push(r),r}function nS(e,t){return!e||t.metadata===void 0?!1:(e.metadata=$i(e.metadata,$(t.metadata)),!0)}var rS=e=>typeof e==`object`&&e?e.role:void 0;function iS(e){if(rS(e)!==`assistant`)return[];let t=e.toolCalls;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e.id;typeof t==`string`&&n.push(t)}return n}function aS(e){let t=new Map,n=new Map,r=(e,t)=>{t.answered=!0,n.set(e,n.get(e)-1)},i=new Map,a=new Map,o=(e,t,n)=>{let r=e.get(t);r?r.push(n):e.set(t,[n])},s=-1;for(let c=0;c=0&&u[e].issuer===s;e--)u[e].answered||(d=u[e]);if(d){r(e,d);continue}n.get(e)>0&&o(i,e,c)}else if(u!==`activity`&&u!==`reasoning`){s=c;for(let e of iS(l))o(t,e,{issuer:c,answered:!1}),n.set(e,(n.get(e)??0)+1)}}let c=new Map,l=[],u=(e,t,n)=>{r(e,n),o(c,n.issuer,t),l[t]=!0};for(let[e,n]of i){let r=t.get(e),i=r.length-1;for(let t=n.length-1;t>=0;t--){let a=n[t];for(;i>=0&&(r[i].answered||r[i].issuer>=a);)i--;if(i<0)break;u(e,a,r[i])}}for(let[e,n]of a){let r=t.get(e);r?.length!==1||r[0].answered||u(e,n[0],r[0])}if(c.size===0)return e;for(let e of c.values())e.sort((e,t)=>e-t);let d=[],f,p=()=>{if(f){let t=d.length;for(let e=d.length-1;e>=0;e--){let n=d[e],r=rS(n);if(typeof n==`object`&&n&&r!==`activity`&&r!==`reasoning`)break;r===`reasoning`&&(t=e)}let n=d.splice(t);for(let t of f)d.push(e[t]);for(let e of n)d.push(e)}f=void 0};for(let t=0;te?.function?{...e,function:{...e.function}}:{...e})),t}function sS(e,t,n){let r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let i of r){let r=i===`content`?n:e[i],a=t[i];if(i===`toolCalls`&&Array.isArray(r)&&Array.isArray(a)){if(!cS(r,a))return!1}else if(r!==a)return!1}return!0}function cS(e,t){if(e.length!==t.length)return!1;for(let n=0;n{let a=Qx(i),o=$(n.messages),s=$(e.state),c={},l=new Set,u=new Set,d=[],f=new Set,p=e=>{let t=e.outcome?.type===`success`?e.outcome.pendingToolCallIds:void 0;return t!==void 0&&t.length>0?[...t]:d.filter(e=>!f.has(e))},m=e=>{e.messages!==void 0&&(o=e.messages,c.messages=e.messages),e.state!==void 0&&(s=e.state,c.state=e.state)},h=new WeakMap,g=e=>e.map(e=>{let t=h.get(e);if(t!==void 0&&sS(t.copy,e,t.content))return t.copy;let n=oS(e);return h.set(e,{copy:n,content:e.content}),n}),_=()=>{let e={};return c.messages!==void 0&&(e.messages=g(c.messages)),c.state!==void 0&&(e.state=$(c.state)),c={},e.messages!==void 0||e.state!==void 0?_s(e):zo};return t.pipe(Os(async t=>{let i=await Xx(r,o,s,(r,i,a)=>r.onEvent?.({event:t,agent:n,input:e,messages:i,state:a}));if(m(i),i.stopPropagation===!0?a?.event(`APPLY`,`Event dropped:`,t,{type:t.type,reason:`stopPropagation by subscriber`}):a?.event(`APPLY`,`Event applied:`,t,{type:t.type,subscribers:r.length}),i.stopPropagation===!0)return _();switch(t.type){case j.TEXT_MESSAGE_START:{let i=await Xx(r,o,s,(r,i,a)=>r.onTextMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(i),i.stopPropagation!==!0){let{messageId:e,role:n=`assistant`,name:r,subagentRunId:i}=t,a=o.find(t=>t.id===e);if(a?.role===`activity`)return console.warn(`TEXT_MESSAGE_START: Message '${e}' is an activity message — message ids must be unique across activity and text messages`),_();let s=a;if(!s){let t={id:e,role:n,content:``,...r!==void 0&&{name:r},...i!=null&&{subagentRunId:i}};o.push(t),s=t}let c=nS(s,t);(!a||c)&&m({messages:o})}return _()}case j.TEXT_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${i}'`),_();if(c.role===`activity`)return console.warn(`TEXT_MESSAGE_CONTENT: Message '${i}' is an activity message — message ids must be unique across activity and text messages`),_();let l=await Xx(r,o,s,(r,i,a)=>r.onTextMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,textMessageBuffer:typeof c.content==`string`?c.content:``}));return m(l),l.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,nS(c,t),m({messages:o})),_()}case j.TEXT_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);if(!a)return console.warn(`TEXT_MESSAGE_END: No message found with ID '${i}'`),_();if(a.role===`activity`)return console.warn(`TEXT_MESSAGE_END: Message '${i}' is an activity message — message ids must be unique across activity and text messages`),_();let c=await Xx(r,o,s,(r,i,o)=>r.onTextMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,textMessageBuffer:typeof a.content==`string`?a.content:``}));return m(c),c.stopPropagation!==!0&&nS(a,t)&&m({messages:o}),await Promise.all(r.map(t=>t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e}))),_()}case j.TOOL_CALL_START:{let i=await Xx(r,o,s,(r,i,a)=>r.onToolCallStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(i),i.stopPropagation!==!0){let{toolCallId:e,toolCallName:n,parentMessageId:r,subagentRunId:i}=t;d.includes(e)||d.push(e);let a=o.find(t=>t.toolCalls?.some(t=>t.id===e))?.toolCalls?.find(t=>t.id===e);if(l.has(e)||(l.add(e),a&&u.add(e)),a){let r=a.function.name!==n;return r&&(console.warn(`TOOL_CALL_START: tool call '${e}' already exists with name '${a.function.name}' — updating it to '${n}'`),a.function.name=n),(nS(a,t)||r)&&m({messages:o}),_()}let s=new Set(o.map(e=>e.id)),c=tS(o,r,e);!s.has(c.id)&&i!=null&&c.subagentRunId===void 0&&(c.subagentRunId=i),c.toolCalls??=[];let f={id:e,type:`function`,function:{name:n,arguments:``}};c.toolCalls.push(f),nS(f,t),m({messages:o})}return _()}case j.TOOL_CALL_ARGS:{let{toolCallId:i,delta:a}=t,c=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!c)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${i}'`),_();let l=c.toolCalls?.find(e=>e.id===i);if(!l)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${i}'`),_();let d=await Xx(r,o,s,(r,a,o)=>{let s=u.has(i)?``:l.function.arguments,c=l.function.name,d={};try{d=Ls(s)}catch{}return r.onToolCallArgsEvent?.({event:t,messages:a,state:o,agent:n,input:e,toolCallBuffer:s,toolCallName:c,partialToolCallArgs:d})});return m(d),d.stopPropagation!==!0&&(u.delete(i)?l.function.arguments=a:l.function.arguments+=a,nS(l,t),m({messages:o})),_()}case j.TOOL_CALL_END:{let{toolCallId:i}=t,a=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!a)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${i}'`),_();let c=a.toolCalls?.find(e=>e.id===i);if(!c)return console.warn(`TOOL_CALL_END: No tool call found with ID '${i}'`),_();let d=await Xx(r,o,s,(r,i,a)=>{let o=c.function.arguments,s=c.function.name,l={};try{l=JSON.parse(o)}catch{}return r.onToolCallEndEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallName:s,toolCallArgs:l})});return m(d),d.stopPropagation!==!0&&(l.delete(i),u.delete(i)),d.stopPropagation!==!0&&nS(c,t)&&m({messages:o}),await Promise.all(r.map(t=>t.onNewToolCall?.({toolCall:c,messages:o,state:s,agent:n,input:e}))),_()}case j.TOOL_CALL_RESULT:{let i=await Xx(r,o,s,(r,i,a)=>r.onToolCallResultEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(i),i.stopPropagation!==!0){let{messageId:i,toolCallId:a,content:c,role:l,subagentRunId:u}=t;f.add(a);let d=o.findIndex(e=>e.id===i&&e.role===`tool`&&e.toolCallId===a),p={...d===-1?{}:o[d],id:i,toolCallId:a,role:l||`tool`,content:c,...u!=null&&{subagentRunId:u}};if(u??delete p.subagentRunId,nS(p,t),d!==-1)o[d]=p;else{let t=-1,i=-1,c=!1;for(let e=o.length-1;e>=0;e--){let n=o[e];if(rS(n)===`tool`&&n.toolCallId===a)c=!0;else if(iS(n).includes(a)){if(i===-1&&(i=e),!c){t=e;break}c=!1}}if(t===-1&&(t=i),t===-1)o.push(p);else{let e=t+1;for(;et.onNewMessage?.({message:p,messages:o,state:s,agent:n,input:e})))}m({messages:o})}return _()}case j.STATE_SNAPSHOT:{let i=await Xx(r,o,s,(r,i,a)=>r.onStateSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(i),i.stopPropagation!==!0){let{snapshot:e}=t;s=$(e),m({state:s})}return _()}case j.STATE_DELTA:{let i=await Xx(r,o,s,(r,i,a)=>r.onStateDeltaEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(i),i.stopPropagation!==!0){let{delta:e}=t;try{s=Ia.applyPatch(s,$(e),!0,!1).newDocument,m({state:s})}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Failed to apply state patch:\nCurrent state: ${JSON.stringify(s,null,2)}\nPatch operations: ${JSON.stringify(e,null,2)}\nError: ${n}`)}}return _()}case j.MESSAGES_SNAPSHOT:{let i=await Xx(r,o,s,(r,i,a)=>r.onMessagesSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(i),i.stopPropagation!==!0){let e=$(t.messages).map(e=>{if(e.subagentRunId!==null)return e;let t={...e};return delete t.subagentRunId,t}),n=new Map(e.map(e=>[e.id,e])),r=Wx(t),i=e.some(e=>e.role===`activity`),a=e.some(e=>e.role===`reasoning`),s=e=>e.role===`activity`&&(r?!r.includes(e.activityType):r!==null&&!i)||e.role===`reasoning`&&!a;o=o.filter(e=>n.has(e.id)||s(e)).map(e=>n.get(e.id)??e);let c=new Set(o.map(e=>e.id));for(let t of e)c.has(t.id)||o.push(t);o=aS(o),m({messages:o})}return _()}case j.ACTIVITY_SNAPSHOT:{let i=t,a=o.findIndex(e=>e.id===i.messageId),c=a>=0?o[a]:void 0,l=c?.role===`activity`?c:void 0,u=i.replace??!0,d=await Xx(r,o,s,(t,r,a)=>t.onActivitySnapshotEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:l,existingMessage:c}));if(m(d),d.stopPropagation!==!0){let t={id:i.messageId,role:`activity`,activityType:i.activityType,content:$(i.content),...i.subagentRunId!=null&&{subagentRunId:i.subagentRunId}},c,d;a===-1?(o.push(t),c=t,d=t):l?(u&&(o[a]={...l,activityType:i.activityType,content:$(i.content),subagentRunId:i.subagentRunId},i.subagentRunId??delete o[a].subagentRunId),d=o[a]):u&&(o[a]=t,c=t,d=t),nS(d,i),m({messages:o}),c&&await Promise.all(r.map(t=>t.onNewMessage?.({message:c,messages:o,state:s,agent:n,input:e})))}return _()}case j.ACTIVITY_DELTA:{let i=t,a=o.findIndex(e=>e.id===i.messageId);if(a===-1)return _();let c=o[a];if(c.role!==`activity`)return console.warn(`ACTIVITY_DELTA: Message '${i.messageId}' is not an activity message`),_();let l=c,u=await Xx(r,o,s,(t,r,a)=>t.onActivityDeltaEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:l}));if(m(u),u.stopPropagation!==!0)try{nS(l,i)&&m({messages:o});let e=$(l.content??{}),t=Ia.applyPatch(e,i.patch??[],!0,!1).newDocument;o[a]={...l,content:$(t),activityType:i.activityType},m({messages:o})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`Failed to apply activity patch for '${i.messageId}': ${t}`)}return _()}case j.RAW:return m(await Xx(r,o,s,(r,i,a)=>r.onRawEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.CUSTOM:return m(await Xx(r,o,s,(r,i,a)=>r.onCustomEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.RUN_STARTED:{let i=await Xx(r,o,s,(r,i,a)=>r.onRunStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(i),d=[],f=new Set,i.stopPropagation!==!0){l.clear(),u.clear();let e=t;if(e.input?.messages){for(let t of e.input.messages){let e=t;if(t.subagentRunId===null){let n={...t};delete n.subagentRunId,e=n}o.find(t=>t.id===e.id)||o.push(e)}m({messages:o})}}return _()}case j.RUN_FINISHED:{let i=t,a=i.outcome?.type===`interrupt`?{event:i,outcome:`interrupt`,interrupts:i.outcome.interrupts}:i.outcome?.type===`cancelled`?{event:i,outcome:`cancelled`}:{event:i,outcome:`success`,result:i.result,pendingToolCallIds:p(i)},c=await Xx(r,o,s,(t,r,i)=>t.onRunFinishedEvent?.({...a,messages:r,state:i,agent:n,input:e}));return m(c),c.stopPropagation!==!0&&(n.pendingInterrupts=a.outcome===`interrupt`?a.interrupts.map(e=>{if(e.subagentRunId!==null)return e;let t={...e};return delete t.subagentRunId,t}):[]),_()}case j.RUN_ERROR:return m(await Xx(r,o,s,(r,i,a)=>r.onRunErrorEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.STEP_STARTED:return m(await Xx(r,o,s,(r,i,a)=>r.onStepStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.STEP_FINISHED:return m(await Xx(r,o,s,(r,i,a)=>r.onStepFinishedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.TEXT_MESSAGE_CHUNK:throw Error(`TEXT_MESSAGE_CHUNK must be transformed before being applied`);case j.TOOL_CALL_CHUNK:throw Error(`TOOL_CALL_CHUNK must be transformed before being applied`);case j.REASONING_START:return m(await Xx(r,o,s,(r,i,a)=>r.onReasoningStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.REASONING_MESSAGE_START:{let i=await Xx(r,o,s,(r,i,a)=>r.onReasoningMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(i),i.stopPropagation!==!0){let{messageId:e,subagentRunId:n}=t,r=o.find(t=>t.id===e);if(r?.role===`activity`)return console.warn(`REASONING_MESSAGE_START: Message '${e}' is an activity message — message ids must be unique across activity and reasoning messages`),_();let i=r;if(!i){let t={id:e,role:`reasoning`,content:``,...n!=null&&{subagentRunId:n}};o.push(t),i=t}let a=nS(i,t);(!r||a)&&m({messages:o})}return _()}case j.REASONING_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${i}'`),_();if(c.role===`activity`)return console.warn(`REASONING_MESSAGE_CONTENT: Message '${i}' is an activity message — message ids must be unique across activity and reasoning messages`),_();let l=await Xx(r,o,s,(r,i,a)=>r.onReasoningMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,reasoningMessageBuffer:typeof c.content==`string`?c.content:``}));return m(l),l.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,nS(c,t),m({messages:o})),_()}case j.REASONING_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);if(!a)return console.warn(`REASONING_MESSAGE_END: No message found with ID '${i}'`),_();if(a.role===`activity`)return console.warn(`REASONING_MESSAGE_END: Message '${i}' is an activity message — message ids must be unique across activity and reasoning messages`),_();let c=await Xx(r,o,s,(r,i,o)=>r.onReasoningMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,reasoningMessageBuffer:typeof a.content==`string`?a.content:``}));return m(c),c.stopPropagation!==!0&&nS(a,t)&&m({messages:o}),await Promise.all(r.map(t=>t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e}))),_()}case j.REASONING_MESSAGE_CHUNK:throw Error(`REASONING_MESSAGE_CHUNK must be transformed before being applied`);case j.REASONING_END:return m(await Xx(r,o,s,(r,i,a)=>r.onReasoningEndEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.REASONING_ENCRYPTED_VALUE:{let{subtype:i,entityId:a,encryptedValue:l}=t,u=await Xx(r,o,s,(r,i,a)=>r.onReasoningEncryptedValueEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(m(u),u.stopPropagation!==!0){let e=!1;if(i===`tool-call`){for(let t of o)if(t.role===`assistant`&&t.toolCalls){let n=t.toolCalls.find(e=>e.id===a);if(n){n.encryptedValue=l,e=!0;break}}}else{let t=o.find(e=>e.id===a);t?.role!==`activity`&&t&&(t.encryptedValue=l,e=!0)}e&&(c.messages=o)}return _()}case j.SUBAGENT_STARTED:return m(await Xx(r,o,s,(r,i,a)=>r.onSubagentStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.SUBAGENT_FINISHED:return m(await Xx(r,o,s,(r,i,a)=>r.onSubagentFinishedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_();case j.SUBAGENT_ERROR:return m(await Xx(r,o,s,(r,i,a)=>r.onSubagentErrorEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),_()}return t.type,_()}),Cs(),r.length>0?js({}):e=>e)};function uS(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][compat] Converting deprecated ${e} to ${t}. The old shape leaves the protocol after its shim window — see the repo-root DEPRECATIONS.md. Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)}var dS=e=>t=>{let n=Qx(e),r=new Set,i=new Set,a=new Set,o=new Set,s={message:new Map,toolCall:new Map,activity:new Map,reasoning:new Map},c=!1,l=!1,u=!1,d=new Map,f=e=>{let t=d.get(e);return t||(t=new Map,d.set(e,t)),t},p=()=>{for(let e of d.values())if(e.size>0)return!0;return!1},m=new Map,h=new Set,g=!1,_=!1,v=()=>{_=!1,r.clear(),i.clear(),a.clear(),o.clear(),s.message.clear(),s.toolCall.clear(),s.activity.clear(),s.reasoning.clear(),d.clear(),m.clear(),h.clear(),c=!1,l=!1,g=!0},y=(e,t)=>{let n=e??[];if(Array.isArray(n))for(let e of n){if(!e||typeof e.id!=`string`)continue;if(e.subagentRunId===null)return new M(`Cannot send a message (id '${e.id}') with 'subagentRunId: null'. The field is optional — omit it entirely.`);let n=e.role===`reasoning`?s.reasoning:e.role===`activity`?s.activity:s.message;(t||!n.has(e.id))&&n.set(e.id,{subagentRunId:e.subagentRunId});for(let n of e.toolCalls??[])n&&typeof n.id==`string`&&(t||!s.toolCall.has(n.id))&&s.toolCall.set(n.id,{subagentRunId:e.subagentRunId??void 0})}},b=(e,t,n,r,i)=>{if(t!==void 0&&n&&n.subagentRunId!==t)return new M(`Cannot send '${e}': subagentRunId '${t}' does not match the ${r} '${i}' opener's subagent '${n.subagentRunId??`(the parent agent)`}'.`)};return t.pipe(Ss(e=>{let t=e.type;if(n?.event(`VERIFY`,`Event:`,e,{type:e.type}),l&&t!==j.RUN_STARTED)return F(()=>new M(`Cannot send event type '${t}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(c&&t!==j.RUN_ERROR&&t!==j.RUN_STARTED)return F(()=>new M(`Cannot send event type '${t}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(!u){if(u=!0,t!==j.RUN_STARTED&&t!==j.RUN_ERROR)return F(()=>new M(`First event must be 'RUN_STARTED'`))}else if(t===j.RUN_STARTED){if(g&&!c&&!l)return F(()=>new M(`Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run.`));(c||l)&&v()}if(e.subagentRunId===null){_||(_=!0,uS(`subagentRunId: null`,`an absent field`));let{subagentRunId:t,...n}=e;e=n}if(t===j.SUBAGENT_STARTED||t===j.SUBAGENT_FINISHED||t===j.SUBAGENT_ERROR){let n=t===j.SUBAGENT_STARTED?[`description`,`parentSubagentRunId`,`parentToolCallId`,`parentMessageId`]:t===j.SUBAGENT_FINISHED?[`outcome`]:[`code`];for(let r of n)if(e[r]===null)return F(()=>new M(`Cannot send '${t}' with '${r}: null'. The field is optional — omit it entirely.`));let r=e.outcome;if(r!=null&&r.type!==`success`&&r.type!==`suspended`)return F(()=>new M(`Cannot send '${t}' with outcome type '${String(r.type)}'. The outcome is either { type: "success" } or { type: "suspended" }.`));if(r&&r.interruptIds===null)return F(()=>new M(`Cannot send '${t}' with 'outcome.interruptIds: null'. The field is optional — omit it entirely.`));if(r&&Array.isArray(r.interruptIds)&&r.interruptIds.some(e=>typeof e!=`string`))return F(()=>new M(`Cannot send '${t}' with a non-string entry in 'outcome.interruptIds'. Interrupt ids are strings.`))}if(t===j.RUN_FINISHED){let t=e.outcome;if(t?.type===`interrupt`&&Array.isArray(t.interrupts)){for(let e of t.interrupts)if(e&&e.subagentRunId===null)return F(()=>new M(`Cannot send 'RUN_FINISHED' with an interrupt (id '${e.id}') carrying 'subagentRunId: null'. The field is optional — omit it entirely.`))}}switch(t){case j.TEXT_MESSAGE_START:{let n=e.messageId;if(r.has(n))return F(()=>new M(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${n}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`));let i=s.message.get(n);if(i){let r=b(t,e.subagentRunId,i,`message`,n);if(r)return F(()=>r)}return r.add(n),i||s.message.set(n,{subagentRunId:e.subagentRunId}),_s(e)}case j.TEXT_MESSAGE_CONTENT:{let n=e.messageId;if(!r.has(n))return F(()=>new M(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${n}'. Start a text message with 'TEXT_MESSAGE_START' first.`));let i=b(t,e.subagentRunId,s.message.get(n),`message`,n);return i?F(()=>i):_s(e)}case j.TEXT_MESSAGE_END:{let n=e.messageId;if(!r.has(n))return F(()=>new M(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${n}'. A 'TEXT_MESSAGE_START' event must be sent first.`));let i=b(t,e.subagentRunId,s.message.get(n),`message`,n);return i?F(()=>i):(r.delete(n),_s(e))}case j.TOOL_CALL_START:{let n=e.toolCallId;if(i.has(n))return F(()=>new M(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${n}' is already in progress. Complete it with 'TOOL_CALL_END' first.`));let r=e.parentMessageId,a=e.subagentRunId,o;if(r!==void 0){let e=s.message.get(r);if(e){if(a!==void 0&&a!==e.subagentRunId)return F(()=>new M(`Cannot send 'TOOL_CALL_START': subagentRunId '${a}' does not match its parent message '${r}' owner '${e.subagentRunId??`(the parent agent)`}'. A tool call belongs to the message that carries it.`));o=e}}let c=s.toolCall.get(n);if(c){let e=b(t,a,c,`tool call`,n);if(e)return F(()=>e);if(a===void 0&&o&&o.subagentRunId!==c.subagentRunId)return F(()=>new M(`Cannot send 'TOOL_CALL_START': tool call '${n}' is owned by '${c.subagentRunId??`(the parent agent)`}' but its parent message '${r}' is owned by '${o.subagentRunId??`(the parent agent)`}'. A tool call belongs to the message that carries it.`))}return i.add(n),c||s.toolCall.set(n,a===void 0?o??{subagentRunId:void 0}:{subagentRunId:a}),_s(e)}case j.TOOL_CALL_ARGS:{let n=e.toolCallId;if(!i.has(n))return F(()=>new M(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${n}'. Start a tool call with 'TOOL_CALL_START' first.`));let r=b(t,e.subagentRunId,s.toolCall.get(n),`tool call`,n);return r?F(()=>r):_s(e)}case j.TOOL_CALL_END:{let n=e.toolCallId;if(!i.has(n))return F(()=>new M(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${n}'. A 'TOOL_CALL_START' event must be sent first.`));let r=b(t,e.subagentRunId,s.toolCall.get(n),`tool call`,n);return r?F(()=>r):(i.delete(n),_s(e))}case j.STEP_STARTED:{let t=e.stepName,n=e.subagentRunId;return f(n).has(t)?F(()=>new M(`Step "${t}" is already active for 'STEP_STARTED'${n===void 0?``:` in subagent '${n}'`}`)):(f(n).set(t,!0),_s(e))}case j.STEP_FINISHED:{let t=e.stepName,n=e.subagentRunId;if(!f(n).has(t)){let e,r=!1;for(let[i,a]of d)if(i!==n&&a.has(t)){e=i,r=!0;break}return F(r?()=>new M(`Cannot send 'STEP_FINISHED' for step "${t}" attributed to ${n===void 0?`the parent agent`:`subagent '${n}'`}: that step is open under ${e===void 0?`the parent agent`:`subagent '${e}'`}. A step must be finished by whoever started it.`):()=>new M(`Cannot send 'STEP_FINISHED' for step "${t}" that was not started`))}return f(n).delete(t),_s(e)}case j.ACTIVITY_SNAPSHOT:{let t=e.messageId;return(!s.activity.has(t)||e.replace!==!1)&&s.activity.set(t,{subagentRunId:e.subagentRunId}),_s(e)}case j.TOOL_CALL_RESULT:{let t=e.messageId;return typeof t==`string`&&s.message.set(t,{subagentRunId:e.subagentRunId}),_s(e)}case j.REASONING_START:case j.REASONING_MESSAGE_START:{let n=e.messageId,r=t===j.REASONING_START,i=r?a:o;if(i.has(n))return F(()=>new M(r?`Cannot send 'REASONING_START' event: A reasoning span with ID '${n}' is already in progress. Complete it with 'REASONING_END' first.`:`Cannot send 'REASONING_MESSAGE_START' event: A reasoning message with ID '${n}' is already in progress. Complete it with 'REASONING_MESSAGE_END' first.`));let c=s.reasoning.get(n);if(c){let r=b(t,e.subagentRunId,c,`reasoning message`,n);if(r)return F(()=>r)}return i.add(n),c||s.reasoning.set(n,{subagentRunId:e.subagentRunId}),_s(e)}case j.REASONING_MESSAGE_CONTENT:case j.REASONING_MESSAGE_END:case j.REASONING_END:{let n=e.messageId,r=t===j.REASONING_END,i=r?a:o;if(!i.has(n))return F(()=>new M(r?`Cannot send 'REASONING_END' event: No active reasoning span found with ID '${n}'. A 'REASONING_START' event must be sent first.`:`Cannot send '${t}' event: No active reasoning message found with ID '${n}'. Start a reasoning message with 'REASONING_MESSAGE_START' first.`));let c=b(t,e.subagentRunId,s.reasoning.get(n),`reasoning message`,n);return c?F(()=>c):((t===j.REASONING_END||t===j.REASONING_MESSAGE_END)&&i.delete(n),_s(e))}case j.REASONING_ENCRYPTED_VALUE:{let n=e.entityId,r=e.subtype,i=r===`tool-call`?s.toolCall.get(n):r===`message`?s.message.get(n)??s.reasoning.get(n):s.reasoning.get(n),a=r===`tool-call`?`tool call`:r===`message`?`message`:`reasoning message`,o=b(t,e.subagentRunId,i,a,n);return o?F(()=>o):_s(e)}case j.ACTIVITY_DELTA:{let n=e.messageId,r=b(t,e.subagentRunId,s.activity.get(n),`activity`,n);return r?F(()=>r):_s(e)}case j.SUBAGENT_STARTED:{if(typeof e.subagentRunId!=`string`)return F(()=>new M(`Cannot send 'SUBAGENT_STARTED' without a 'subagentRunId'.`));if(typeof e.name!=`string`)return F(()=>new M(`Cannot send 'SUBAGENT_STARTED' without a 'name'.`));let t=e.subagentRunId,n=e.parentSubagentRunId;return m.has(t)?F(()=>new M(`Cannot send 'SUBAGENT_STARTED': subagent '${t}' is already active. Finish it with 'SUBAGENT_FINISHED' first.`)):h.has(t)?F(()=>new M(`Cannot send 'SUBAGENT_STARTED': subagent '${t}' has already finished in this run. Subagent IDs are per-invocation and cannot be reused.`)):n!==void 0&&!m.has(n)&&!h.has(n)?F(()=>new M(`Cannot send 'SUBAGENT_STARTED': parentSubagentRunId '${n}' has not been started in this run.`)):(m.set(t,!0),_s(e))}case j.SUBAGENT_FINISHED:case j.SUBAGENT_ERROR:{if(typeof e.subagentRunId!=`string`)return F(()=>new M(`Cannot send '${t}' without a 'subagentRunId'.`));if(t===j.SUBAGENT_ERROR&&typeof e.message!=`string`)return F(()=>new M(`Cannot send 'SUBAGENT_ERROR' without a 'message'.`));let n=e.subagentRunId;return m.has(n)?(m.delete(n),h.add(n),_s(e)):F(()=>new M(`Cannot send '${t}': no active subagent found with ID '${n}'. A 'SUBAGENT_STARTED' event must be sent first.`))}case j.MESSAGES_SNAPSHOT:{let t=y(e.messages,!0);if(t)return F(()=>t)}return _s(e);case j.RUN_STARTED:g=!0;{let t=y((e.input??{}).messages,!1);if(t)return F(()=>t)}return _s(e);case j.RUN_FINISHED:if(p()){let e=[];for(let[t,n]of d)for(let r of n.keys())e.push(t===void 0?r:`${r} (subagent '${t}')`);let t=e.join(`, `);return F(()=>new M(`Cannot send 'RUN_FINISHED' while steps are still active: ${t}`))}if(r.size>0){let e=Array.from(r.keys()).join(`, `);return F(()=>new M(`Cannot send 'RUN_FINISHED' while text messages are still active: ${e}`))}if(o.size>0){let e=Array.from(o.keys()).join(`, `);return F(()=>new M(`Cannot send 'RUN_FINISHED' while reasoning messages are still active: ${e}`))}if(a.size>0){let e=Array.from(a.keys()).join(`, `);return F(()=>new M(`Cannot send 'RUN_FINISHED' while reasoning spans are still active: ${e}`))}if(i.size>0){let e=Array.from(i.keys()).join(`, `);return F(()=>new M(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${e}`))}if(m.size>0){let e=Array.from(m.keys()).join(`, `);return F(()=>new M(`Cannot send 'RUN_FINISHED' while subagents are still active: ${e}`))}return c=!0,_s(e);case j.RUN_ERROR:return l=!0,_s(e);case j.CUSTOM:return _s(e);default:return _s(e)}}))},fS=function(e){return e.HEADERS=`headers`,e.DATA=`data`,e}({}),pS=e=>Ts(()=>gs(e())).pipe(Ns(e=>{if(!e.ok){let t=e.headers.get(`content-type`)||``;return gs(e.text()).pipe(Ss(n=>{let r=n;if(t.includes(`application/json`))try{r=JSON.parse(n)}catch{}let i=Error(`HTTP ${e.status}: ${typeof r==`string`?r:JSON.stringify(r)}`);return i.status=e.status,i.payload=r,F(()=>i)}))}let t={type:fS.HEADERS,status:e.status,headers:e.headers},n=e.body?.getReader();return n?new Eo(e=>{let r=!1;return e.next(t),(async()=>{try{for(;!e.closed;){let{done:t,value:i}=await n.read();if(t){r=!0;break}let a={type:fS.DATA,data:i};e.next(a)}e.complete()}catch(t){r=!0,e.error(t)}})(),()=>{r||n.cancel().catch(e=>{e?.name!==`AbortError`&&console.warn(`Failed to cancel HTTP response stream:`,e)})}}):F(()=>Error(`Failed to getReader() from response`))})),mS=10485760,hS=(e,t)=>{let n=Qx(t),r=new Fo,i=new TextDecoder(`utf-8`,{fatal:!1}),a=``;e.subscribe({next:e=>{if(e.type!==fS.HEADERS&&e.type===fS.DATA&&e.data){let t=i.decode(e.data,{stream:!0});a+=t;let n=a.split(/\n\n/);a=n.pop()||``;for(let e of n)o(e);if(a.length>mS){r.error(Error(`SSE buffer size exceeded maximum limit of ${mS/1048576} MB`));return}}},error:e=>r.error(e),complete:()=>{a&&(a+=i.decode(),o(a)),r.complete()}});function o(e){let t=e.split(` `),i=[];for(let e of t)e.startsWith(`data:`)&&i.push(e.slice(5).replace(/^ /,``));if(i.length>0)try{let e=i.join(` `),t=JSON.parse(e);n?.event(`SSE`,`Event received:`,t,{type:t?.type}),r.next(t)}catch(e){r.error(e)}}return r.asObservable()},gS=10485760,_S=()=>typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS,vS=(e,t)=>{let n=Qx(t),r=new Fo,i=new Uint8Array,a=!1;e.subscribe({next:e=>{if(e.type!==fS.HEADERS&&e.type===fS.DATA&&e.data){let t=new Uint8Array(i.length+e.data.length);t.set(i,0),t.set(e.data,i.length),i=t,o()}},error:e=>r.error(e),complete:()=>{if(o(),!a){if(i.length>0){r.error(Error(`The binary stream ended mid-frame: ${i.length} trailing bytes could not be read as a complete message.`));return}r.complete()}}});function o(){if(!a)for(;i.length>=4;){let e=4+new DataView(i.buffer,i.byteOffset,4).getUint32(0,!1);if(e>gS){r.error(Error(`Protobuf message size exceeded maximum limit of ${gS/1048576} MB`));return}if(i.length{let n=Qx(t),r=new Fo,i=new Ro(1),a=!1,o,s=!1,c=()=>{s=!0,o?.unsubscribe()},l=e=>{c(),r.error(e)},u=()=>{c(),r.complete()};return o=e.subscribe({next:e=>{if(i.next(e),e.type===fS.HEADERS&&!a){a=!0;let t=e.headers.get(`content-type`);n?.lifecycle(`HTTP`,`Stream format detected:`,{contentType:t,parser:t===`application/vnd.ag-ui.event+proto`?`protobuf`:`sse`}),t===`application/vnd.ag-ui.event+proto`?vS(i,n).subscribe({next:e=>r.next(e),error:e=>l(e),complete:()=>u()}):hS(i,n).subscribe({next:e=>{if(typeof e!=`object`||!e||Array.isArray(e)){let t=Error(`Invalid event: the frame is not a JSON object.`);n?.event(`HTTP`,`Event invalid:`,{json:e,error:String(t)}),l(t);return}let t=e;if(typeof t.type!=`string`||t.type.length===0){let t=Error(`Invalid event: the frame carries no event type.`);n?.event(`HTTP`,`Event invalid:`,{json:e,error:String(t)}),l(t);return}n?.event(`HTTP`,`Event received:`,e,{type:t.type}),r.next(e)},error:e=>{if(e?.name===`AbortError`){r.next({type:j.RUN_ERROR,message:e.message||`Request aborted`,code:`abort`,rawEvent:e}),u();return}return l(e)},complete:()=>u()})}else a||l(Error(`No headers event received before data events`))},error:e=>{i.error(e),l(e)},complete:()=>{i.complete()}}),s&&o.unsubscribe(),r.asObservable()},bS={TextMessageStart:`TextMessageStart`,TextMessageContent:`TextMessageContent`,TextMessageEnd:`TextMessageEnd`,ActionExecutionStart:`ActionExecutionStart`,ActionExecutionArgs:`ActionExecutionArgs`,ActionExecutionEnd:`ActionExecutionEnd`,ActionExecutionResult:`ActionExecutionResult`,AgentStateMessage:`AgentStateMessage`,MetaEvent:`MetaEvent`,RunStarted:`RunStarted`,RunFinished:`RunFinished`,RunError:`RunError`,NodeStarted:`NodeStarted`,NodeFinished:`NodeFinished`},xS=e=>{if(typeof e==`string`)return e;if(!Array.isArray(e))return;let t=e.filter(e=>e.type===`text`).map(e=>e.text).filter(e=>e.length>0);if(t.length!==0)return t.join(` -`)};function SS(e,t){return ta(t)&&CS(`[ag-ui][legacy] The result of tool call '${e}' carries content parts the legacy protocol cannot represent; only its text parts are bridged and the rest is dropped.`),ea(t)}var CS=e=>{typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(e)},wS=(e,t,n)=>r=>{let i={},a=!0,o=!0,s=``,c=null,l=null,u=[],d={},f=!1,p=e=>{typeof e==`object`&&e&&(`messages`in e&&delete e.messages,i=e)};return r.pipe(Ss(r=>{switch(r.type){case j.TEXT_MESSAGE_START:{let e=r;return[{type:bS.TextMessageStart,messageId:e.messageId,role:e.role}]}case j.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:bS.TextMessageContent,messageId:e.messageId,content:e.delta}]}case j.TEXT_MESSAGE_END:{let e=r;return[{type:bS.TextMessageEnd,messageId:e.messageId}]}case j.TOOL_CALL_START:{let e=r;return u.push({id:e.toolCallId,type:`function`,function:{name:e.toolCallName,arguments:``}}),o=!0,d[e.toolCallId]=e.toolCallName,[{type:bS.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case j.TOOL_CALL_ARGS:{let c=r,d=u.find(e=>e.id===c.toolCallId);if(!d)return CS(`[ag-ui][legacy] TOOL_CALL_ARGS: No tool call found with ID '${c.toolCallId}'`),[];d.function.arguments+=c.delta;let f=!1;if(l){let e=l.find(e=>e.tool==d.function.name);if(e)try{let t=JSON.parse(Ls(d.function.arguments));e.tool_argument&&e.tool_argument in t?(p({...i,[e.state_key]:t[e.tool_argument]}),f=!0):e.tool_argument||(p({...i,[e.state_key]:t}),f=!0)}catch{}}return[{type:bS.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...f?[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case j.TOOL_CALL_END:{let e=r;return[{type:bS.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case j.TOOL_CALL_RESULT:{let e=r,t=d[e.toolCallId];return(t===void 0||t===``)&&CS(`[ag-ui][legacy] No usable tool name was seen for tool call '${e.toolCallId}' (${t===void 0?`no TOOL_CALL_START reached this bridge`:`its TOOL_CALL_START carried an empty toolCallName`}), so its result is being bridged with the fabricated action name "unknown". Downstream consumers route on that name.`),[{type:bS.ActionExecutionResult,actionExecutionId:e.toolCallId,result:SS(e.toolCallId,e.content),actionName:t||`unknown`}]}case j.RAW:return f||(f=!0,CS(`[ag-ui][legacy] Dropping RAW events: the legacy runtime protocol has no equivalent, so the provider payloads they carry do not reach the legacy stream. Reported once per stream.`)),[];case j.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value}return[{type:bS.MetaEvent,name:e.name,value:e.value}]}case j.STATE_SNAPSHOT:return p(r.snapshot),[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case j.STATE_DELTA:{let c=r,l;try{l=Ia.applyPatch(i,c.delta,!0,!1).newDocument}catch(e){let t=e instanceof Error?e.message:String(e);return CS(`[ag-ui][legacy] Failed to apply state patch:\nCurrent state: ${JSON.stringify(i,null,2)}\nPatch operations: ${JSON.stringify(c.delta,null,2)}\nError: ${t}`),[]}return p(l),[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]}case j.MESSAGES_SNAPSHOT:return c=r.messages,[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:c}:{}}),active:!0}];case j.RUN_STARTED:return[];case j.RUN_FINISHED:{if(c&&(i.messages=c),Object.keys(i).length===0)return[];let r=null;if(c)try{r=TS(c)}catch(e){return[{type:bS.RunError,message:e.message}]}return[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...r?{messages:r}:{}}),active:!1}]}case j.RUN_ERROR:{let e=r;return[{type:bS.RunError,message:e.message,code:e.code}]}case j.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case j.STEP_FINISHED:return u=[],l=null,[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function TS(e){let t=[];for(let n of e)if(n.role===`assistant`||n.role===`user`||n.role===`system`){let e=xS(n.content);if(e){let r={id:n.id,role:n.role,content:e};t.push(r)}if(n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0)for(let e of n.toolCalls){let r;try{r=JSON.parse(e.function.arguments)}catch(t){throw Error(`Failed to parse arguments for tool call '${e.id}' (${e.function.name}): ${t.message}`)}let i={id:e.id,name:e.function.name,arguments:r,parentMessageId:n.id};t.push(i)}}else if(n.role===`tool`){let r=`unknown`;for(let t of e)if(t.role===`assistant`&&t.toolCalls?.length){for(let e of t.toolCalls)if(e.id===n.toolCallId){r=e.function.name;break}}let i={id:n.id,result:SS(n.toolCallId,n.content),actionExecutionId:n.toolCallId,actionName:r};t.push(i)}return t}var ES=e=>e.kind===`tool`?e.fields.toolCallId:e.fields.messageId,DS=e=>e===`tool`?`toolCallId`:`messageId`,OS=(e,t,n,r,i)=>{if(r!==void 0&&r!==i)throw Error(`Cannot continue ${e} '${t}': chunk ${n} '${r}' does not match the open stream's ${n} ${i===void 0?`(absent)`:`'${i}'`}.`)},kS=(e,t)=>t.metadata===void 0?e:{...e,metadata:t.metadata},AS=(e,t)=>{let n=kS(e,t);return t.rawEvent===void 0?n:{...n,rawEvent:t.rawEvent}},jS=e=>new Set(Object.keys(e.shape)),MS=jS(__),NS=jS(x_),PS=jS(iv),FS=(e,t)=>{let n;for(let r of Object.keys(e))t.has(r)||((n??={})[r]=e[r]);return n},IS=e=>{typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][transform] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)},LS=(e,t,n,r)=>{if(t===void 0||n||e.length===0)return;let i=e[e.length-1],a=Object.keys(t).filter(e=>Object.prototype.hasOwnProperty.call(i,e));a.length>0&&IS(`A ${r} carried ${a.map(e=>`'${e}'`).join(`, `)}, which the synthesized ${String(i.type)} already describes. The synthesized value is kept and the chunk's is dropped — this stage does not judge a described field, so the producer's value cannot be substituted for its own.`),e[e.length-1]={...t,...i}},RS=e=>t=>{let n=Qx(e),r=new Map,i=e=>{let t=r.get(e);if(!t)return[];switch(r.delete(e),t.kind){case`text`:{let e={type:j.TEXT_MESSAGE_END,messageId:t.fields.messageId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`TEXT_MESSAGE_END`,e,{messageId:e.messageId}),[e]}case`tool`:{let e={type:j.TOOL_CALL_END,toolCallId:t.fields.toolCallId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`TOOL_CALL_END`,e,{toolCallId:e.toolCallId}),[e]}case`reasoning`:{let e={type:j.REASONING_MESSAGE_END,messageId:t.fields.messageId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`REASONING_MESSAGE_END`,e,{messageId:e.messageId}),[e]}}},a=()=>[...r.keys()].flatMap(e=>i(e)),o=(e,t)=>{for(let[n,i]of r)if(i.kind===e&&ES(i)===t)return{owner:n}},s=(e,t,n,i,a)=>{if(t!==void 0){let r=o(e,t);if(r){if(n!==void 0&&n!==r.owner)throw Error(`Cannot continue ${a} '${t}': chunk subagentRunId '${n}' does not match the open stream's subagent '${r.owner??`(the parent agent)`}'.`);return r.owner}return n}if(n!==void 0)return n;if(r.get(void 0)?.kind===e)return;let s=[...r.entries()].filter(([,t])=>t.kind===e);if(s.length===1)return s[0][0];if(s.length>1)throw Error(`Ambiguous ${i}: it carries neither a ${DS(e)} nor a subagentRunId, but ${s.length} lanes have an open ${a}. Attribute the chunk to the subagent it belongs to.`)};return t.pipe(Ss(e=>{switch(e.type){case j.TEXT_MESSAGE_START:case j.TEXT_MESSAGE_CONTENT:case j.TEXT_MESSAGE_END:case j.TOOL_CALL_START:case j.TOOL_CALL_ARGS:case j.TOOL_CALL_END:case j.TOOL_CALL_RESULT:case j.STATE_SNAPSHOT:case j.STATE_DELTA:case j.CUSTOM:case j.STEP_STARTED:case j.STEP_FINISHED:case j.REASONING_START:case j.REASONING_MESSAGE_START:case j.REASONING_MESSAGE_CONTENT:case j.REASONING_MESSAGE_END:case j.REASONING_END:return[...i(e.subagentRunId??void 0),e];case j.RUN_STARTED:case j.RUN_FINISHED:case j.RUN_ERROR:case j.MESSAGES_SNAPSHOT:return[...a(),e];case j.RAW:case j.ACTIVITY_SNAPSHOT:case j.ACTIVITY_DELTA:case j.REASONING_ENCRYPTED_VALUE:case j.SUBAGENT_STARTED:return[e];case j.SUBAGENT_FINISHED:case j.SUBAGENT_ERROR:{let t=e.subagentRunId;return t==null?[e]:[...i(t),e]}case j.TEXT_MESSAGE_CHUNK:{let t=e,a=FS(e,MS),o=s(`text`,t.messageId,t.subagentRunId??void 0,`TEXT_MESSAGE_CHUNK`,`text message`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`text`&&(t.messageId===void 0||t.messageId===c.fields.messageId))OS(`text message`,c.fields.messageId,`role`,t.role,c.fields.role),OS(`text message`,c.fields.messageId,`name`,t.name,c.fields.name),d=c.fields;else{if(l.push(...i(o)),t.messageId===void 0)throw Error(`First TEXT_MESSAGE_CHUNK must have a messageId`);d={messageId:t.messageId,role:t.role===void 0?`assistant`:t.role,name:t.name,subagentRunId:t.subagentRunId},r.set(o,{kind:`text`,fields:d});let e=kS({type:j.TEXT_MESSAGE_START,messageId:t.messageId,role:d.role,...t.name!==void 0&&{name:t.name},...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=AS({...a,type:j.TEXT_MESSAGE_CONTENT,messageId:d.messageId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`TEXT_MESSAGE_CONTENT`,r,{messageId:d.messageId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:j.TEXT_MESSAGE_CONTENT,messageId:d.messageId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return LS(l,a,u,`TEXT_MESSAGE_CHUNK`),l}case j.TOOL_CALL_CHUNK:{let t=e,a=FS(e,NS),o=s(`tool`,t.toolCallId,t.subagentRunId??void 0,`TOOL_CALL_CHUNK`,`tool call`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`tool`&&(t.toolCallId===void 0||t.toolCallId===c.fields.toolCallId))OS(`tool call`,c.fields.toolCallId,`toolCallName`,t.toolCallName,c.fields.toolCallName),OS(`tool call`,c.fields.toolCallId,`parentMessageId`,t.parentMessageId,c.fields.parentMessageId),d=c.fields;else{if(l.push(...i(o)),t.toolCallId===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallId`);if(t.toolCallName===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallName`);d={toolCallId:t.toolCallId,toolCallName:t.toolCallName,parentMessageId:t.parentMessageId,subagentRunId:t.subagentRunId},r.set(o,{kind:`tool`,fields:d});let e=kS({type:j.TOOL_CALL_START,toolCallId:t.toolCallId,toolCallName:t.toolCallName,...t.parentMessageId!==void 0&&{parentMessageId:t.parentMessageId},...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_START`,e,{toolCallId:t.toolCallId,toolCallName:t.toolCallName})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=AS({...a,type:j.TOOL_CALL_ARGS,toolCallId:d.toolCallId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`TOOL_CALL_ARGS`,r,{toolCallId:d.toolCallId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:j.TOOL_CALL_ARGS,toolCallId:d.toolCallId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return LS(l,a,u,`TOOL_CALL_CHUNK`),l}case j.REASONING_MESSAGE_CHUNK:{let t=e,a=FS(e,PS),o=s(`reasoning`,t.messageId,t.subagentRunId??void 0,`REASONING_MESSAGE_CHUNK`,`reasoning message`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`reasoning`&&(t.messageId===void 0||t.messageId===c.fields.messageId))d=c.fields;else{if(l.push(...i(o)),t.messageId===void 0)throw Error(`First REASONING_MESSAGE_CHUNK must have a messageId`);d={messageId:t.messageId,subagentRunId:t.subagentRunId},r.set(o,{kind:`reasoning`,fields:d});let e=kS({type:j.REASONING_MESSAGE_START,messageId:t.messageId,role:`reasoning`,...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=AS({...a,type:j.REASONING_MESSAGE_CONTENT,messageId:d.messageId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`REASONING_MESSAGE_CONTENT`,r,{messageId:d.messageId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:j.REASONING_MESSAGE_CONTENT,messageId:d.messageId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return LS(l,a,u,`REASONING_MESSAGE_CHUNK`),l}}return e.type,[e]}),Ms(()=>{a()}))},zS=1e6;function BS(e){if(e===void 0)return zS;if(e===1/0||Number.isSafeInteger(e)&&e>0)return e;throw new M(`Invalid enforcement entry budget ${String(e)}: expected a positive integer, or Infinity to disable it.`)}var VS=class extends M{constructor(e,t){super(`Enforcement limit exceeded at '${t||`(root)`}': the payload has more than ${e} entries to validate. If it is legitimate, raise or disable the limit (maxEnforcedEntries on the agent, or maxEntries in the enforcement options).`),this.name=`AGUIEnforcementLimitError`,this.limit=e,this.path=t}},HS=Symbol(`agui.strip.drop`);function US(e,t,n){if(e.used+=t,e.used>e.max)throw new VS(e.max,n)}function WS(e){let t=e;for(;;){if(t instanceof Bg||t instanceof Wg||t instanceof Kg||t instanceof r_||t instanceof Qg){t=t.unwrap();continue}if(t instanceof e_){t=t.def.in;continue}if(t instanceof a_){t=t.def.getter();continue}return t}}function GS(e){let t=e.def;return typeof t?.discriminator==`string`?t.discriminator:void 0}function KS(e){let t=e,n=Array.isArray(t.def?.values)?t.def.values:t.values?Array.from(t.values):void 0;return n&&n.length===1?n[0]:t.value}function qS(e){let t=WS(e);return t instanceof Lg?KS(t):void 0}function JS(e,t,n,r,i){let a=WS(t);if(a instanceof Tg){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=a.shape,o=e,s={},c=a.meta()?.specOpen===!0,l=Object.keys(o);US(i,l.length,n);for(let e of l){let a=Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;if(a===void 0){if(c){s[e]=o[e];continue}r.push(`${n}/${e}`);continue}let l=r.length,u=JS(o[e],a,`${n}/${e}`,r,i);if(u===HS){if(r.length=l,a.safeParse(void 0).success){r.push(`${n}/${e}`);continue}return HS}s[e]=u}return s}if(a instanceof Cg){if(!Array.isArray(e))return e;US(i,e.length,n);let t=a.element,o=[];return e.forEach((e,a)=>{let s=r.length,c=JS(e,t,`${n}/${a}`,r,i);if(c===HS){r.length=s,r.push(`${n}/${a}`);return}o.push(c)}),o}if(a instanceof Ng){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=a.def.valueType,o=e,s={},c=Object.keys(o);US(i,c.length,n);for(let e of c){let a=r.length,c=JS(o[e],t,`${n}/${e}`,r,i);if(c===HS){r.length=a,r.push(`${n}/${e}`);continue}s[e]=c}return s}if(a instanceof Dg){let t=a.options,o=GS(a);if(o!==void 0){if(typeof e!=`object`||!e||Array.isArray(e))return e;let a=e[o];for(let s of t){let t=WS(s);if(!(t instanceof Tg))continue;let c=t.shape;if(qS(c[o])===a)return JS(e,s,n,r,i)}return HS}let s=t.filter(e=>WS(e)instanceof Tg),c=typeof e==`object`&&!!e&&!Array.isArray(e);if(s.length>1&&c)return e;for(let a of t){let t=WS(a);if(t instanceof Cg&&Array.isArray(e)||t instanceof Tg&&c)return JS(e,a,n,r,i)}return e}return e}function YS(e,t,n){let r=[],i=JS(e,t,``,r,{used:0,max:BS(n?.maxEntries)});if(i===HS)throw Error(`Internal error: the stripper found the whole value unrecognisable, which the schemas are not supposed to allow — schema/stripper mismatch.`);return{value:i,stripped:r}}var XS=new Set(Object.values(j));function ZS(e){return XS.has(e.type)}var QS=new Map(uv.options.map(e=>{let t=e.shape;return[String(KS(t.type)),e]})),$S=()=>typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS;function eC(e){$S()||console.warn(`[ag-ui][enforce] ${e}`)}var tC=(e,t)=>{let n=BS(t?.maxEntries);return t=>{let r=Qx(e);return t.pipe(Ss(e=>{if(!ZS(e)){eC(`Dropping unrecognised event '${String(e.type)}': no middleware translated it and the protocol does not describe it.`);let t={type:e.type};return r?.event(`ENFORCE`,`Unrecognised event dropped:`,t,t),zo}let t=QS.get(e.type);if(t===void 0)throw Error(`No validator for recognised event type '${String(e.type)}'`);let{value:i,stripped:a}=YS(e,t,{maxEntries:n});for(let t of a)eC(`Removed unrecognised material at '${t}' on ${String(e.type)}. Nothing handled it; see the repo-root DEPRECATIONS.md if it is a retired shape.`);return _s(t.parse(i))}))}};function nC(e,t){let n=BS(t?.maxEntries),{value:r,stripped:i}=YS(Zi(e,`RunAgentInput`),W_,{maxEntries:n});for(let e of i)eC(`Removed unrecognised material at '${e}' from the outgoing input.`);return W_.parse(r)}var rC=class{runNext(e,t){return t.run(e).pipe(RS(!1))}runNextWithState(e,t){let n=$(e.messages||[]),r=$(e.state===void 0?{}:e.state),i=new Ro;return lS(e,i,t,[]).subscribe({next:e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)},error:()=>{}}),this.runNext(e,t).pipe(Os(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:$(n),state:$(r)})))}},iC=class extends rC{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function aC(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:`document`}function oC(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`binary`&&`mimeType`in e&&typeof e.mimeType==`string`}function sC(e){let t=aC(e.mimeType);return e.data?{type:t,source:{type:`data`,value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:`url`,value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:((typeof process>`u`||!{}.SUPPRESS_TRANSFORMATION_WARNINGS)&&console.warn(`[ag-ui][compat] A binary content part carries only an id ('${e.id??``}') and cannot be converted to a modern media part; a 1.0 peer will not accept it. Provide data or a url. See the repo-root DEPRECATIONS.md.`),e)}function cC(e,t,n){if(typeof e!=`object`||!e||!(`type`in e)||e.type!==t.type||!(`source`in e))return!1;let r=e.source;return typeof r!=`object`||!r||!(`type`in r)||r.type!==t.source.type||!(`value`in r)||r.value!==t.source.value||!(`mimeType`in r)||r.mimeType!==t.source.mimeType?!1:!n||`metadata`in e&&typeof e.metadata==`object`&&e.metadata!==null&&`filename`in e.metadata&&e.metadata.filename===n}function lC(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.flatMap(e=>{if(oC(e)){let n=sC(e);return n.type!==`binary`&&t.some(t=>cC(t,n,e.filename))?[]:[n]}return[e]});return{...e,content:n}}var uC=`THINKING_START`,dC=`THINKING_END`,fC=`THINKING_TEXT_MESSAGE_START`,pC=`THINKING_TEXT_MESSAGE_CONTENT`,mC=`THINKING_TEXT_MESSAGE_END`;function hC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var gC={event:[`rawEvent`,`subagentRunId`],[j.RUN_STARTED]:[`parentRunId`,`input`],[j.RUN_FINISHED]:[`result`,`outcome`],[j.RUN_ERROR]:[`usage`],[j.SUBAGENT_FINISHED]:[`result`],[j.TOOL_CALL_START]:[`parentMessageId`],[j.TOOL_CALL_CHUNK]:[`parentMessageId`],[j.TOOL_CALL_RESULT]:[`role`],"RUN_FINISHED.outcome":[`pendingToolCallIds`],"RUN_FINISHED.usage[]":[`provider`,`reasoningTokens`,`cachedInputTokens`,`cacheWriteInputTokens`],RunAgentInput:[`forwardedProps`],Tool:[`parameters`],ResumeEntry:[`payload`],"input content":[`metadata`]},_C=new Map(Object.entries(gC).filter(([e])=>Object.values(j).includes(e))),vC=e=>uS(e,`an absent field`);function yC(e,t,n,r){if(!hC(e))return e;let i;for(let a of t)e[a]===null&&(r(n===void 0?`${a}: null`:`${n}.${a}: null`),i??={...e},delete i[a]);return i??e}function bC(e,t,n){if(!hC(e)||!Array.isArray(e[t]))return e;let r=e[t],i=r.map(n);return i.some((e,t)=>e!==r[t])?{...e,[t]:i}:e}function xC(e,t){return bC(e,`content`,e=>{if(!hC(e))return e;switch(e.type){case`image`:case`audio`:case`video`:case`document`:return yC(e,gC[`input content`],`${e.type} input content`,t);default:return e}})}function SC(e,t=vC){let n=yC(e,gC.RunAgentInput,`RunAgentInput`,t);return n=bC(n,`tools`,e=>yC(e,gC.Tool,`Tool`,t)),n=bC(n,`resume`,e=>yC(e,gC.ResumeEntry,`ResumeEntry`,t)),bC(n,`messages`,e=>xC(e,t))}var CC=class extends rC{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null,this.nullsNoticedThisRun=new Set,this.noticeNullOncePerRun=e=>{this.nullsNoticedThisRun.has(e)||(this.nullsNoticedThisRun.add(e),uS(e,`an absent field`))}}warn(e,t){uS(e,t)}mintedContinuationId(e,t){if(t!==null)return t;let n=Gx();return this.warnAside(`Minting a messageId ('${n}') for ${e}: no THINKING opener preceded it, so there was no id to continue. The id is this client's invention, not the producer's, and verification will reject the translated event for naming something nothing opened.`),n}warnAside(e){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][compat] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.nullsNoticedThisRun.clear(),e.messages=e.messages.map(lC),t.run(e).pipe(bs(e=>this.transformEvent(e)))}transformEvent(e){let t=this.noticeNullOncePerRun;e.type===j.RUN_STARTED&&this.nullsNoticedThisRun.clear(),e=yC(e,gC.event,void 0,t);let n=_C.get(e.type);switch(n&&(e=yC(e,n,e.type,t)),e.type){case uC:{this.currentReasoningId=Gx();let{title:t,...n}=e;return this.warn(uC,j.REASONING_START),t!==void 0&&this.warnAside(`Dropping ${uC}.title ${JSON.stringify(t)}: ${j.REASONING_START} has no title field, so the span's label cannot be carried and nothing downstream can recover it.`),{...n,type:j.REASONING_START,messageId:this.currentReasoningId}}case fC:return this.currentMessageId=Gx(),this.warn(fC,j.REASONING_MESSAGE_START),{...e,type:j.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`reasoning`};case pC:{let{delta:t,...n}=e;return this.warn(pC,j.REASONING_MESSAGE_CONTENT),{...n,type:j.REASONING_MESSAGE_CONTENT,messageId:this.mintedContinuationId(pC,this.currentMessageId),delta:t}}case mC:{let t=this.mintedContinuationId(mC,this.currentMessageId);return this.currentMessageId=null,this.warn(mC,j.REASONING_MESSAGE_END),{...e,type:j.REASONING_MESSAGE_END,messageId:t}}case dC:{let t=this.mintedContinuationId(dC,this.currentReasoningId);return this.currentReasoningId=null,this.warn(dC,j.REASONING_END),{...e,type:j.REASONING_END,messageId:t}}case j.RUN_FINISHED:{let n=e,r=yC(n.outcome,gC[`RUN_FINISHED.outcome`],`RUN_FINISHED.outcome`,t);return bC(r===n.outcome?n:{...n,outcome:r},`usage`,e=>yC(e,gC[`RUN_FINISHED.usage[]`],`RUN_FINISHED.usage[]`,t))}case j.MESSAGES_SNAPSHOT:{let t=e;return Array.isArray(t.messages)?{...t,messages:t.messages.map(e=>this.upgradeInboundMessage(e))}:e}case j.RUN_STARTED:{let n=SC(e.input,t),r=n===e.input?e:{...e,input:n},i=r;return!i.input||!Array.isArray(i.input.messages)?r:{...i,input:{...i.input,messages:i.input.messages.map(e=>this.upgradeInboundMessage(e))}}}default:return e}}upgradeInboundMessage(e){e=xC(e,this.noticeNullOncePerRun);let t=e.content;return!Array.isArray(t)||!t.some(e=>typeof e==`object`&&!!e&&e.type===`binary`)?e:(this.warn(`binary input content`,`the modern media content parts`),lC(e))}},wC=()=>e=>Ts(()=>{let t=new CC;return e.pipe(bs(e=>t.transformEvent(e)))});function TC(e,t=new Date){return e.expiresAt!==void 0&&new Date(e.expiresAt)<=t}function EC(){return typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS}function DC(e){EC()||console.warn(`[ag-ui][compat] Flattening message content for a <=0.0.39 peer DROPS non-text parts (${e.join(`, `)}). The peer cannot receive them; upgrade it to keep media content. See the repo-root DEPRECATIONS.md.`)}function OC(e){EC()||console.warn(`[ag-ui][compat] Not flattening message content for a <=0.0.39 peer: ${e} content part(s) claim type "text" but carry a malformed 'text' value. That is a defect in the message, not media the peer cannot represent, and a downgrade must not repair it — the content is passed on unchanged so the outgoing enforcement boundary reports it. See the repo-root DEPRECATIONS.md.`)}function kC(e){let t=e.content;if(Array.isArray(t)){let n=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`,r=e=>n(e)&&typeof e.text==`string`,i=t.filter(e=>n(e)&&!r(e));if(i.length>0)return OC(i.length),e;let a=t.filter(e=>!r(e)).map(e=>typeof e==`object`&&e&&`type`in e?String(e.type):typeof e);a.length>0&&DC(a);let o=t.filter(r).map(e=>e.text).join(``);return{...e,content:o}}return typeof t==`string`?e:t===void 0?{...e,content:``}:e}var AC=class extends rC{run(e,t){let{parentRunId:n,...r}=e,i={...r,messages:r.messages.map(kC)};return this.runNext(i,t)}},jC=`THINKING_START`,MC=`THINKING_END`,NC=`THINKING_TEXT_MESSAGE_START`,PC=`THINKING_TEXT_MESSAGE_CONTENT`,FC=`THINKING_TEXT_MESSAGE_END`,IC=class extends rC{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(bs(e=>this.transformEvent(e)))}transformEvent(e){switch(e.type){case jC:{this.currentReasoningId=Gx();let{title:t,...n}=e;return this.warnAboutTransformation(jC,j.REASONING_START),{...n,type:j.REASONING_START,messageId:this.currentReasoningId}}case NC:return this.currentMessageId=Gx(),this.warnAboutTransformation(NC,j.REASONING_MESSAGE_START),{...e,type:j.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`reasoning`};case PC:{let{delta:t,...n}=e;return this.warnAboutTransformation(PC,j.REASONING_MESSAGE_CONTENT),{...n,type:j.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??Gx(),delta:t}}case FC:{let t=this.currentMessageId??Gx();return this.warnAboutTransformation(FC,j.REASONING_MESSAGE_END),{...e,type:j.REASONING_MESSAGE_END,messageId:t}}case MC:{let t=this.currentReasoningId??Gx();return this.warnAboutTransformation(MC,j.REASONING_END),{...e,type:j.REASONING_END,messageId:t}}default:return e}}},LC=`SUBAGENT_STARTED`,RC=`SUBAGENT_FINISHED`,zC=`SUBAGENT_ERROR`;function BC(e){if(e&&typeof e==`object`&&`subagentRunId`in e){let{subagentRunId:t,...n}=e;return n}return e}function VC(e){return e.map(e=>BC(e))}var HC=class extends rC{warnDroppedLifecycleEvent(e){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is dropping ${e} because the target agent predates subagent support. To remove this warning, upgrade your AG-UI integration package. To suppress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){let n={...e,messages:(e.messages??[]).map(e=>BC(e))};return this.runNext(n,t).pipe(Fs(e=>{let t=e.type;(t===LC||t===RC||t===zC)&&this.warnDroppedLifecycleEvent(t)}),Es(e=>{let t=e.type;return t!==LC&&t!==RC&&t!==zC}),bs(e=>{let t=BC(e);if(t.type===j.MESSAGES_SNAPSHOT){let e=t;if(Array.isArray(e.messages))return{...e,messages:VC(e.messages)}}if(t.type===j.RUN_FINISHED){let e=t;if(e.outcome&&Array.isArray(e.outcome.interrupts))return{...e,outcome:{...e.outcome,interrupts:e.outcome.interrupts.map(e=>BC(e))}}}if(t.type===j.RUN_STARTED){let e=t;if(e.input&&Array.isArray(e.input.messages))return{...e,input:{...e.input,messages:VC(e.input.messages)}}}return t}))}},UC=`1.0.4`,WC=!1,GC=new WeakSet,KC=(e,t)=>/^\d+\.\d+$/.test(e)?Vx(e,t)>0?`newer`:`not-newer`:`uninterpretable`,qC=e=>{let t=e.protocolVersion;if(t!==void 0&&t!==`1.0`)switch(KC(t,`1.0`)){case`uninterpretable`:console.warn(`[ag-ui] The producer declared protocol version '${t}', which this client cannot interpret.`);return;case`newer`:console.warn(`[ag-ui] The producer speaks protocol ${t}; this client speaks 1.0. Unrecognised material will be stripped with warnings.`);return;case`not-newer`:return}},JC=class e{resolvePeerCeiling(t){if(this.resolvingPeerCeiling)return UC;let n=Object.getOwnPropertyDescriptor(this,`maxVersion`),r=Object.getOwnPropertyDescriptor(this,`maxProtocolVersion`),i=Object.getPrototypeOf(this);for(;i&&i!==e.prototype;)n??=Object.getOwnPropertyDescriptor(i,`maxVersion`),r??=Object.getOwnPropertyDescriptor(i,`maxProtocolVersion`),i=Object.getPrototypeOf(i);if(t===`maxVersion`&&n)return UC;let a=t===`maxProtocolVersion`?n:r;if(!a)return UC;this.resolvingPeerCeiling=!0;try{return a.get?a.get.call(this):a.value}finally{this.resolvingPeerCeiling=!1}}get maxProtocolVersion(){return this.resolvePeerCeiling(`maxProtocolVersion`)}get maxVersion(){return!this.resolvingPeerCeiling&&!WC&&(WC=!0,console.warn(`[ag-ui] AbstractAgent.maxVersion is deprecated — use maxProtocolVersion. Same value; the new name says whose version it is and that it is a ceiling.`)),this.resolvePeerCeiling(`maxVersion`)}get debug(){return this._debug}set debug(e){this._debug=Zx(e),this._debugLogger=eS(this._debug)}get threadId(){return this._threadId??=qi()}set threadId(e){this._threadId=e}get maxEnforcedEntries(){return this._maxEnforcedEntries}set maxEnforcedEntries(e){this._maxEnforcedEntries=BS(e)}get debugLogger(){return this._debugLogger}set debugLogger(e){this._debugLogger=typeof e==`boolean`?e?eS(Zx(!0)):void 0:e}resolvedCeilingDuringConstruction(){let e=this.maxProtocolVersion;if(typeof e!=`string`||!Hx(e))throw new M(`maxProtocolVersion resolved to ${JSON.stringify(e)} during construction, which is not a version this client can compare. A ceiling read from an instance field is not available yet — return a literal from the getter.`);return e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:i,debug:a,maxEnforcedEntries:o}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.resolvingPeerCeiling=!1,this.agentId=e,this.description=t??``,this._threadId=n,this.messages=$(r??[]),this.state=$(i??{}),this._debug=Zx(a),this._debugLogger=eS(this._debug),this._maxEnforcedEntries=BS(o);let s=this.resolvedCeilingDuringConstruction();Vx(s,`0.0.39`)<=0&&this.middlewares.unshift(new AC),Vx(s,`0.0.45`)<=0&&this.middlewares.unshift(new IC),Vx(s,`0.0.57`)<=0&&this.middlewares.unshift(new HC)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(e=>typeof e==`function`?new iC(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??qi();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle(`LIFECYCLE`,`Run started:`,{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunStartedEvent:({event:e})=>qC(e),onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];GC.add(n),await this.onInitialize(n,a),this.activeRunDetach$=new Fo;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await ys(wo(()=>[...this.middlewares,new CC].reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(n),tC(this.debugLogger,{maxEntries:this.maxEnforcedEntries}),RS(this.debugLogger),dS(this.debugLogger),e=>e.pipe(Ps(this.activeRunDetach$)),e=>this.applyBeforeSourceError(n,e,a),Ds(e=>(this.debugLogger?.lifecycle(`LIFECYCLE`,`Run errored:`,{agentId:this.agentId,error:e instanceof Error?e.message:String(e)}),this.isRunning=!1,this.onError(n,e,a))),Ms(()=>{this.debugLogger?.lifecycle(`LIFECYCLE`,`Run finished:`,{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(_s(null)));let s=$(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new Qi}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??qi();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunStartedEvent:({event:e})=>qC(e),onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new Fo;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await ys(wo(()=>Ts(()=>this.connect(n)),e=>tC(this.debugLogger,{maxEntries:this.maxEnforcedEntries})(wC()(e)),RS(this.debugLogger),dS(this.debugLogger),e=>e.pipe(Ps(this.activeRunDetach$)),e=>this.applyBeforeSourceError(n,e,a),Ds(e=>(this.isRunning=!1,e instanceof Qi?zo:this.onError(n,e,a))),Ms(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(_s(null)),{defaultValue:void 0});let s=$(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}applyBeforeSourceError(e,t,n){return Ts(()=>{let r,i=t.pipe(Ds(e=>(r={error:e},zo)));return this.processApplyEvents(e,this.apply(e,i,n),n).pipe(As(Ts(()=>{let e=r;return e?F(()=>e.error):zo})))})}apply(e,t,n){return lS(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(Fs(t=>{t.messages&&(this.messages=t.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),t.state!==void 0&&(this.state=t.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=$(this.messages);for(let e of t)e.subagentRunId===null&&delete e.subagentRunId;let n=aS(t.filter(e=>e.role!==`activity`));return{threadId:this.threadId,runId:e?.runId||qi(),...Vx(this.maxProtocolVersion,UC)>=0&&{protocolVersion:`1.0`},tools:$(e?.tools??[]),context:$(e?.context??[]),forwardedProps:$(e?.forwardedProps??{}),state:$(this.state),messages:n,...e?.resume===void 0?{}:{resume:$(e.resume)}}}async onInitialize(e,t){if(GC.has(e)&&this.pendingInterrupts.length>0){let t=new Set((e.resume??[]).map(e=>e.interruptId)),n=this.pendingInterrupts.map(e=>e.id).filter(e=>!t.has(e));if(n.length>0)throw new M(`Thread has ${n.length} pending interrupt(s) not addressed by resume: ${n.join(`, `)}`);for(let t of this.pendingInterrupts)if(TC(t)&&(e.resume??[]).find(e=>e.interruptId===t.id)?.status!==`cancelled`)throw new M(`Interrupt ${t.id} expired at ${t.expiresAt} and can no longer be answered. Cancel it to continue the thread.`)}let n=await Xx(t,this.messages,this.state,(t,n,r)=>t.onRunInitialized?.({messages:n,state:r,agent:this,input:e}));if(n.messages!==void 0||n.state!==void 0){if(n.messages){this.messages=n.messages;for(let e of n.messages)e.subagentRunId===null&&delete e.subagentRunId;e.messages=aS(n.messages.filter(e=>e.role!==`activity`)),t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})}n.state!==void 0&&(this.state=n.state,e.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}}onError(e,t,n){return gs(Xx(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.({error:t,messages:r,state:i,agent:this,input:e}))).pipe(bs(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),i.state!==void 0&&(this.state=i.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),i.stopPropagation!==!0){let e=String(t);if(t.name!==`AbortError`&&t.message!==`Fetch is aborted`&&t.message!==`signal is aborted without reason`&&t.message!==`component unmounted`&&e!==`component unmounted`)throw console.error(`Agent execution failed:`,t),t}return{}}))}async onFinalize(e,t){let n=await Xx(t,this.messages,this.state,(t,n,r)=>t.onRunFinalized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=$(this.messages),e.state=$(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e._maxEnforcedEntries=this._maxEnforcedEntries,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=$(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role===`assistant`&&e.toolCalls)for(let t of e.toolCalls)for(let e of this.subscribers)await e.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role===`assistant`&&t.toolCalls)for(let e of t.toolCalls)for(let t of this.subscribers)await t.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=$(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=$(e),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??qi();let t=this.prepareRunAgentInput(e);return[...this.middlewares,new CC].reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(t).pipe(tC(this.debugLogger,{maxEntries:this.maxEnforcedEntries}),RS(this.debugLogger),dS(this.debugLogger),wS(this.threadId,t.runId,this.agentId),e=>e.pipe(bs(e=>(this.debugLogger?.event(`LEGACY`,`Event:`,e,{type:e.type}),e))))}};function YC(e){if(!Array.isArray(e.messages))return e;let t=!1,n=e.messages.map(e=>{if(e.subagentRunId===null){t=!0;let n={...e};return delete n.subagentRunId,n}return e});return t?{...e,messages:n}:e}var XC=class extends JC{requestInit(e){return{method:`POST`,headers:{...this.headers,"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(YC(e)),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=$(e.headers??{}),this.fetch=e.fetch??((e,t)=>fetch(e,t))}run(e){return yS(pS(()=>this.fetch(this.url,this.requestInit(nC(e,{maxEntries:this.maxEnforcedEntries})))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=$(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}},ZC=class extends pn{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:$t(t,n.data),hasPreviousPage:dn(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},QC=class extends mn{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||$C(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=tn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),gn.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function $C(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var ew=class extends rn{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new QC({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=tw(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=tw(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=tw(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=tw(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){gn.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>an(t,e))}findAll(e={}){return this.getAll().filter(t=>an(e,t))}notify(e){gn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return gn.batch(()=>Promise.all(e.map(e=>e.continue().catch(_n))))}};function tw(e){return e.options.scope?.id}var nw=class extends rn{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??on(r,t),a=this.get(i);return a||(a=new sn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){gn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Qt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Qt(e,t)):t}notify(e){gn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){gn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){gn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},rw=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new nw,this.#t=e.mutationCache||new ew,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=nn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=cn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(en(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=fn(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return gn.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;gn.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return gn.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=gn.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(_n).catch(_n)}invalidateQueries(e,t={}){return gn.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=gn.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(_n)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(_n)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(en(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(en(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(_n).catch(_n)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(_n).catch(_n)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return cn.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ln(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{yn(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ln(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{yn(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=on(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Xt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function iw(e,t){return un(e,ZC,t)}var aw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M225.29,165.93C216.61,151,212,129.57,212,104a84,84,0,0,0-168,0c0,25.58-4.59,47-13.27,61.93A20.08,20.08,0,0,0,30.66,186,19.77,19.77,0,0,0,48,196H84.18a44,44,0,0,0,87.64,0H208a19.77,19.77,0,0,0,17.31-10A20.08,20.08,0,0,0,225.29,165.93ZM128,212a20,20,0,0,1-19.6-16h39.2A20,20,0,0,1,128,212ZM54.66,172C63.51,154,68,131.14,68,104a60,60,0,0,1,120,0c0,27.13,4.48,50,13.33,68Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M208,192H48a8,8,0,0,1-6.88-12C47.71,168.6,56,139.81,56,104a72,72,0,0,1,144,0c0,35.82,8.3,64.6,14.9,76A8,8,0,0,1,208,192Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M220.07,176.94C214.41,167.2,206,139.73,206,104a78,78,0,1,0-156,0c0,35.74-8.42,63.2-14.08,72.94A14,14,0,0,0,48,198H90.48a38,38,0,0,0,75,0H208a14,14,0,0,0,12.06-21.06ZM128,218a26,26,0,0,1-25.29-20h50.58A26,26,0,0,1,128,218Zm81.71-33a1.9,1.9,0,0,1-1.7,1H48a1.9,1.9,0,0,1-1.7-1,2,2,0,0,1,0-2C53.87,170,62,139.69,62,104a66,66,0,1,1,132,0c0,35.68,8.14,65.95,15.71,79A2,2,0,0,1,209.71,185Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M218.35,178C212.58,168,204,140.13,204,104a76,76,0,1,0-152,0c0,36.13-8.59,64-14.36,73.95A12,12,0,0,0,48,196H92.23a36,36,0,0,0,71.54,0H208A12,12,0,0,0,218.35,178ZM128,220a28,28,0,0,1-27.71-24h55.42A28,28,0,0,1,128,220Zm83.45-34a3.91,3.91,0,0,1-3.44,2H48a3.91,3.91,0,0,1-3.44-2,4,4,0,0,1,0-4C52,169.17,60,139.32,60,104a68,68,0,1,1,136,0c0,35.31,8,65.17,15.44,78A4,4,0,0,1,211.45,186Z`}))]]),ow=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,44H160a43.86,43.86,0,0,0-32,13.85A43.86,43.86,0,0,0,96,44H24A12,12,0,0,0,12,56V200a12,12,0,0,0,12,12H96a20,20,0,0,1,20,20,12,12,0,0,0,24,0,20,20,0,0,1,20-20h72a12,12,0,0,0,12-12V56A12,12,0,0,0,232,44ZM96,188H36V68H96a20,20,0,0,1,20,20V192.81A43.79,43.79,0,0,0,96,188Zm124,0H160a43.71,43.71,0,0,0-20,4.83V88a20,20,0,0,1,20-20h60Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,56V200H160a32,32,0,0,0-32,32,32,32,0,0,0-32-32H24V56H96a32,32,0,0,1,32,32,32,32,0,0,1,32-32Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M240,56V200a8,8,0,0,1-8,8H160a24,24,0,0,0-24,23.94,7.9,7.9,0,0,1-5.12,7.55A8,8,0,0,1,120,232a24,24,0,0,0-24-24H24a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H88a32,32,0,0,1,32,32v87.73a8.17,8.17,0,0,0,7.47,8.25,8,8,0,0,0,8.53-8V80a32,32,0,0,1,32-32h64A8,8,0,0,1,240,56Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,50H160a38,38,0,0,0-32,17.55A38,38,0,0,0,96,50H24a6,6,0,0,0-6,6V200a6,6,0,0,0,6,6H96a26,26,0,0,1,26,26,6,6,0,0,0,12,0,26,26,0,0,1,26-26h72a6,6,0,0,0,6-6V56A6,6,0,0,0,232,50ZM96,194H30V62H96a26,26,0,0,1,26,26V204.31A37.86,37.86,0,0,0,96,194Zm130,0H160a37.87,37.87,0,0,0-26,10.32V88a26,26,0,0,1,26-26h66Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,52H160a36,36,0,0,0-32,19.54A36,36,0,0,0,96,52H24a4,4,0,0,0-4,4V200a4,4,0,0,0,4,4H96a28,28,0,0,1,28,28,4,4,0,0,0,8,0,28,28,0,0,1,28-28h72a4,4,0,0,0,4-4V56A4,4,0,0,0,232,52ZM96,196H28V60H96a28,28,0,0,1,28,28V209.4A35.93,35.93,0,0,0,96,196Zm132,0H160a35.94,35.94,0,0,0-28,13.41V88a28,28,0,0,1,28-28h68Z`}))]]),sw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,20A108,108,0,0,0,31.85,177.23L21,209.66A20,20,0,0,0,46.34,235l32.43-10.81A108,108,0,1,0,128,20Zm0,192a84,84,0,0,1-42.06-11.27,12,12,0,0,0-6-1.62,12.1,12.1,0,0,0-3.8.62l-29.79,9.93,9.93-29.79a12,12,0,0,0-1-9.81A84,84,0,1,1,128,212Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,128A96,96,0,0,1,79.93,211.11h0L42.54,223.58a8,8,0,0,1-10.12-10.12l12.47-37.39h0A96,96,0,1,1,224,128Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,128A104,104,0,0,1,79.12,219.82L45.07,231.17a16,16,0,0,1-20.24-20.24l11.35-34.05A104,104,0,1,1,232,128Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,26A102,102,0,0,0,38.35,176.69L26.73,211.56a14,14,0,0,0,17.71,17.71l34.87-11.62A102,102,0,1,0,128,26Zm0,192a90,90,0,0,1-45.06-12.08,6.09,6.09,0,0,0-3-.81,6.2,6.2,0,0,0-1.9.31L40.65,217.88a2,2,0,0,1-2.53-2.53L50.58,178a6,6,0,0,0-.5-4.91A90,90,0,1,1,128,218Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,28A100,100,0,0,0,40.53,176.5l-11.9,35.69a12,12,0,0,0,15.18,15.18l35.69-11.9A100,100,0,1,0,128,28Zm0,192a92,92,0,0,1-46.07-12.35,4.05,4.05,0,0,0-2-.54,3.93,3.93,0,0,0-1.27.21L41.28,219.78a4,4,0,0,1-5.06-5.06l12.46-37.38a4,4,0,0,0-.33-3.27A92,92,0,1,1,128,220Z`}))]]),cw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212ZM163.27,77l-56,24a12,12,0,0,0-6.3,6.3l-24,56A12,12,0,0,0,92.73,179l56-24a12,12,0,0,0,6.3-6.3l24-56A12,12,0,0,0,163.27,77Zm-28.41,57.89-24,10.29,10.29-24,24-10.29Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,32a96,96,0,1,0,96,96A96,96,0,0,0,128,32Zm16,112L80,176l32-64,64-32Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM172.42,72.84l-64,32a8.05,8.05,0,0,0-3.58,3.58l-32,64A8,8,0,0,0,80,184a8.1,8.1,0,0,0,3.58-.84l64-32a8.05,8.05,0,0,0,3.58-3.58l32-64a8,8,0,0,0-10.74-10.74ZM138,138,97.89,158.11,118,118l40.15-20.07Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm51.58,57.79-32,64a4.08,4.08,0,0,1-1.79,1.79l-64,32a4,4,0,0,1-5.37-5.37l32-64a4.08,4.08,0,0,1,1.79-1.79l64-32A4,4,0,0,1,179.58,81.79Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218ZM173.32,74.63l-64,32a6,6,0,0,0-2.69,2.69l-32,64A6,6,0,0,0,80,182a6.06,6.06,0,0,0,2.68-.63l64-32a6,6,0,0,0,2.69-2.69l32-64a6,6,0,0,0-8.05-8.05Zm-33.79,64.9L93.42,162.58l23-46.11,46.11-23Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM172.42,72.84l-64,32a8.05,8.05,0,0,0-3.58,3.58l-32,64A8,8,0,0,0,80,184a8.1,8.1,0,0,0,3.58-.84l64-32a8.05,8.05,0,0,0,3.58-3.58l32-64a8,8,0,0,0-10.74-10.74ZM138,138,97.89,158.11,118,118l40.15-20.07Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220ZM174.21,76.42l-64,32a4.08,4.08,0,0,0-1.79,1.79l-32,64A4,4,0,0,0,80,180a4.05,4.05,0,0,0,1.79-.42l64-32a4.08,4.08,0,0,0,1.79-1.79l32-64a4,4,0,0,0-5.37-5.37ZM141,141l-52.08,26L115,115l52.08-26Z`}))]]),lw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,76a52,52,0,1,0,52,52A52.06,52.06,0,0,0,128,76Zm0,80a28,28,0,1,1,28-28A28,28,0,0,1,128,156Zm92-27.21v-1.58l14-17.51a12,12,0,0,0,2.23-10.59A111.75,111.75,0,0,0,225,71.89,12,12,0,0,0,215.89,66L193.61,63.5l-1.11-1.11L190,40.1A12,12,0,0,0,184.11,31a111.67,111.67,0,0,0-27.23-11.27A12,12,0,0,0,146.3,22L128.79,36h-1.58L109.7,22a12,12,0,0,0-10.59-2.23A111.75,111.75,0,0,0,71.89,31.05,12,12,0,0,0,66,40.11L63.5,62.39,62.39,63.5,40.1,66A12,12,0,0,0,31,71.89,111.67,111.67,0,0,0,19.77,99.12,12,12,0,0,0,22,109.7l14,17.51v1.58L22,146.3a12,12,0,0,0-2.23,10.59,111.75,111.75,0,0,0,11.29,27.22A12,12,0,0,0,40.11,190l22.28,2.48,1.11,1.11L66,215.9A12,12,0,0,0,71.89,225a111.67,111.67,0,0,0,27.23,11.27A12,12,0,0,0,109.7,234l17.51-14h1.58l17.51,14a12,12,0,0,0,10.59,2.23A111.75,111.75,0,0,0,184.11,225a12,12,0,0,0,5.91-9.06l2.48-22.28,1.11-1.11L215.9,190a12,12,0,0,0,9.06-5.91,111.67,111.67,0,0,0,11.27-27.23A12,12,0,0,0,234,146.3Zm-24.12-4.89a70.1,70.1,0,0,1,0,8.2,12,12,0,0,0,2.61,8.22l12.84,16.05A86.47,86.47,0,0,1,207,166.86l-20.43,2.27a12,12,0,0,0-7.65,4,69,69,0,0,1-5.8,5.8,12,12,0,0,0-4,7.65L166.86,207a86.47,86.47,0,0,1-10.49,4.35l-16.05-12.85a12,12,0,0,0-7.5-2.62c-.24,0-.48,0-.72,0a70.1,70.1,0,0,1-8.2,0,12.06,12.06,0,0,0-8.22,2.6L99.63,211.33A86.47,86.47,0,0,1,89.14,207l-2.27-20.43a12,12,0,0,0-4-7.65,69,69,0,0,1-5.8-5.8,12,12,0,0,0-7.65-4L49,166.86a86.47,86.47,0,0,1-4.35-10.49l12.84-16.05a12,12,0,0,0,2.61-8.22,70.1,70.1,0,0,1,0-8.2,12,12,0,0,0-2.61-8.22L44.67,99.63A86.47,86.47,0,0,1,49,89.14l20.43-2.27a12,12,0,0,0,7.65-4,69,69,0,0,1,5.8-5.8,12,12,0,0,0,4-7.65L89.14,49a86.47,86.47,0,0,1,10.49-4.35l16.05,12.85a12.06,12.06,0,0,0,8.22,2.6,70.1,70.1,0,0,1,8.2,0,12,12,0,0,0,8.22-2.6l16.05-12.85A86.47,86.47,0,0,1,166.86,49l2.27,20.43a12,12,0,0,0,4,7.65,69,69,0,0,1,5.8,5.8,12,12,0,0,0,7.65,4L207,89.14a86.47,86.47,0,0,1,4.35,10.49l-12.84,16.05A12,12,0,0,0,195.88,123.9Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M207.86,123.18l16.78-21a99.14,99.14,0,0,0-10.07-24.29l-26.7-3a81,81,0,0,0-6.81-6.81l-3-26.71a99.43,99.43,0,0,0-24.3-10l-21,16.77a81.59,81.59,0,0,0-9.64,0l-21-16.78A99.14,99.14,0,0,0,77.91,41.43l-3,26.7a81,81,0,0,0-6.81,6.81l-26.71,3a99.43,99.43,0,0,0-10,24.3l16.77,21a81.59,81.59,0,0,0,0,9.64l-16.78,21a99.14,99.14,0,0,0,10.07,24.29l26.7,3a81,81,0,0,0,6.81,6.81l3,26.71a99.43,99.43,0,0,0,24.3,10l21-16.77a81.59,81.59,0,0,0,9.64,0l21,16.78a99.14,99.14,0,0,0,24.29-10.07l3-26.7a81,81,0,0,0,6.81-6.81l26.71-3a99.43,99.43,0,0,0,10-24.3l-16.77-21A81.59,81.59,0,0,0,207.86,123.18ZM128,168a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.6,107.6,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.29,107.29,0,0,0-26.25-10.86,8,8,0,0,0-7.06,1.48L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.6,107.6,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8.06,8.06,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8.06,8.06,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,130.16q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.6,107.6,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.29,107.29,0,0,0-26.25-10.86,8,8,0,0,0-7.06,1.48L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.6,107.6,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06ZM128,168a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,82a46,46,0,1,0,46,46A46.06,46.06,0,0,0,128,82Zm0,80a34,34,0,1,1,34-34A34,34,0,0,1,128,162ZM214,130.84c.06-1.89.06-3.79,0-5.68L229.33,106a6,6,0,0,0,1.11-5.29A105.34,105.34,0,0,0,219.76,74.9a6,6,0,0,0-4.53-3l-24.45-2.71q-1.93-2.07-4-4l-2.72-24.46a6,6,0,0,0-3-4.53,105.65,105.65,0,0,0-25.77-10.66A6,6,0,0,0,150,26.68l-19.2,15.37c-1.89-.06-3.79-.06-5.68,0L106,26.67a6,6,0,0,0-5.29-1.11A105.34,105.34,0,0,0,74.9,36.24a6,6,0,0,0-3,4.53L69.23,65.22q-2.07,1.94-4,4L40.76,72a6,6,0,0,0-4.53,3,105.65,105.65,0,0,0-10.66,25.77A6,6,0,0,0,26.68,106l15.37,19.2c-.06,1.89-.06,3.79,0,5.68L26.67,150.05a6,6,0,0,0-1.11,5.29A105.34,105.34,0,0,0,36.24,181.1a6,6,0,0,0,4.53,3l24.45,2.71q1.94,2.07,4,4L72,215.24a6,6,0,0,0,3,4.53,105.65,105.65,0,0,0,25.77,10.66,6,6,0,0,0,5.29-1.11L125.16,214c1.89.06,3.79.06,5.68,0l19.21,15.38a6,6,0,0,0,3.75,1.31,6.2,6.2,0,0,0,1.54-.2,105.34,105.34,0,0,0,25.76-10.68,6,6,0,0,0,3-4.53l2.71-24.45q2.07-1.93,4-4l24.46-2.72a6,6,0,0,0,4.53-3,105.49,105.49,0,0,0,10.66-25.77,6,6,0,0,0-1.11-5.29Zm-3.1,41.63-23.64,2.63a6,6,0,0,0-3.82,2,75.14,75.14,0,0,1-6.31,6.31,6,6,0,0,0-2,3.82l-2.63,23.63A94.28,94.28,0,0,1,155.14,218l-18.57-14.86a6,6,0,0,0-3.75-1.31h-.36a78.07,78.07,0,0,1-8.92,0,6,6,0,0,0-4.11,1.3L100.87,218a94.13,94.13,0,0,1-17.34-7.17L80.9,187.21a6,6,0,0,0-2-3.82,75.14,75.14,0,0,1-6.31-6.31,6,6,0,0,0-3.82-2l-23.63-2.63A94.28,94.28,0,0,1,38,155.14l14.86-18.57a6,6,0,0,0,1.3-4.11,78.07,78.07,0,0,1,0-8.92,6,6,0,0,0-1.3-4.11L38,100.87a94.13,94.13,0,0,1,7.17-17.34L68.79,80.9a6,6,0,0,0,3.82-2,75.14,75.14,0,0,1,6.31-6.31,6,6,0,0,0,2-3.82l2.63-23.63A94.28,94.28,0,0,1,100.86,38l18.57,14.86a6,6,0,0,0,4.11,1.3,78.07,78.07,0,0,1,8.92,0,6,6,0,0,0,4.11-1.3L155.13,38a94.13,94.13,0,0,1,17.34,7.17l2.63,23.64a6,6,0,0,0,2,3.82,75.14,75.14,0,0,1,6.31,6.31,6,6,0,0,0,3.82,2l23.63,2.63A94.28,94.28,0,0,1,218,100.86l-14.86,18.57a6,6,0,0,0-1.3,4.11,78.07,78.07,0,0,1,0,8.92,6,6,0,0,0,1.3,4.11L218,155.13A94.13,94.13,0,0,1,210.85,172.47Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,80a36,36,0,1,1,36-36A36,36,0,0,1,128,164Zm83.93-32.49q.13-3.51,0-7l15.83-19.79a4,4,0,0,0,.75-3.53A103.64,103.64,0,0,0,218,75.9a4,4,0,0,0-3-2l-25.19-2.8c-1.58-1.71-3.24-3.37-4.95-4.95L182.07,41a4,4,0,0,0-2-3A104,104,0,0,0,154.82,27.5a4,4,0,0,0-3.53.74L131.51,44.07q-3.51-.14-7,0L104.7,28.24a4,4,0,0,0-3.53-.75A103.64,103.64,0,0,0,75.9,38a4,4,0,0,0-2,3l-2.8,25.19c-1.71,1.58-3.37,3.24-4.95,4.95L41,73.93a4,4,0,0,0-3,2A104,104,0,0,0,27.5,101.18a4,4,0,0,0,.74,3.53l15.83,19.78q-.14,3.51,0,7L28.24,151.3a4,4,0,0,0-.75,3.53A103.64,103.64,0,0,0,38,180.1a4,4,0,0,0,3,2l25.19,2.8c1.58,1.71,3.24,3.37,4.95,4.95l2.8,25.2a4,4,0,0,0,2,3,104,104,0,0,0,25.28,10.46,4,4,0,0,0,3.53-.74l19.78-15.83q3.51.13,7,0l19.79,15.83a4,4,0,0,0,2.5.88,4,4,0,0,0,1-.13A103.64,103.64,0,0,0,180.1,218a4,4,0,0,0,2-3l2.8-25.19c1.71-1.58,3.37-3.24,4.95-4.95l25.2-2.8a4,4,0,0,0,3-2,104,104,0,0,0,10.46-25.28,4,4,0,0,0-.74-3.53Zm.17,42.83-24.67,2.74a4,4,0,0,0-2.55,1.32,76.2,76.2,0,0,1-6.48,6.48,4,4,0,0,0-1.32,2.55l-2.74,24.66a95.45,95.45,0,0,1-19.64,8.15l-19.38-15.51a4,4,0,0,0-2.5-.87h-.24a73.67,73.67,0,0,1-9.16,0,4,4,0,0,0-2.74.87l-19.37,15.5a95.33,95.33,0,0,1-19.65-8.13l-2.74-24.67a4,4,0,0,0-1.32-2.55,76.2,76.2,0,0,1-6.48-6.48,4,4,0,0,0-2.55-1.32l-24.66-2.74a95.45,95.45,0,0,1-8.15-19.64l15.51-19.38a4,4,0,0,0,.87-2.74,77.76,77.76,0,0,1,0-9.16,4,4,0,0,0-.87-2.74l-15.5-19.37A95.33,95.33,0,0,1,43.9,81.66l24.67-2.74a4,4,0,0,0,2.55-1.32,76.2,76.2,0,0,1,6.48-6.48,4,4,0,0,0,1.32-2.55l2.74-24.66a95.45,95.45,0,0,1,19.64-8.15l19.38,15.51a4,4,0,0,0,2.74.87,73.67,73.67,0,0,1,9.16,0,4,4,0,0,0,2.74-.87l19.37-15.5a95.33,95.33,0,0,1,19.65,8.13l2.74,24.67a4,4,0,0,0,1.32,2.55,76.2,76.2,0,0,1,6.48,6.48,4,4,0,0,0,2.55,1.32l24.66,2.74a95.45,95.45,0,0,1,8.15,19.64l-15.51,19.38a4,4,0,0,0-.87,2.74,77.76,77.76,0,0,1,0,9.16,4,4,0,0,0,.87,2.74l15.5,19.37A95.33,95.33,0,0,1,212.1,174.34Z`}))]]),uw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M28,64A12,12,0,0,1,40,52H216a12,12,0,0,1,0,24H40A12,12,0,0,1,28,64Zm12,76h64a12,12,0,0,0,0-24H40a12,12,0,0,0,0,24Zm80,40H40a12,12,0,0,0,0,24h80a12,12,0,0,0,0-24Zm120.49,20.49a12,12,0,0,1-17,0l-18.08-18.08a44,44,0,1,1,17-17l18.08,18.07A12,12,0,0,1,240.49,200.49ZM184,164a20,20,0,1,0-20-20A20,20,0,0,0,184,164Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,144a32,32,0,1,1-32-32A32,32,0,0,1,216,144Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M32,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H40A8,8,0,0,1,32,64Zm8,72h72a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm88,48H40a8,8,0,0,0,0,16h88a8,8,0,0,0,0-16Zm109.66,13.66a8,8,0,0,1-11.32,0L206,177.36A40,40,0,1,1,217.36,166l20.3,20.3A8,8,0,0,1,237.66,197.66ZM184,168a24,24,0,1,0-24-24A24,24,0,0,0,184,168Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M32,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H40A8,8,0,0,1,32,64Zm8,72h72a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm88,48H40a8,8,0,0,0,0,16h88a8,8,0,0,0,0-16Zm109.66,2.34L217.36,166A40,40,0,1,0,206,177.36l20.3,20.3a8,8,0,0,0,11.32-11.32Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M34,64a6,6,0,0,1,6-6H216a6,6,0,0,1,0,12H40A6,6,0,0,1,34,64Zm6,70h72a6,6,0,0,0,0-12H40a6,6,0,0,0,0,12Zm88,52H40a6,6,0,0,0,0,12h88a6,6,0,0,0,0-12Zm108.24,10.24a6,6,0,0,1-8.48,0l-21.49-21.48a38.06,38.06,0,1,1,8.49-8.49l21.48,21.49A6,6,0,0,1,236.24,196.24ZM184,170a26,26,0,1,0-26-26A26,26,0,0,0,184,170Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M32,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H40A8,8,0,0,1,32,64Zm8,72h72a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm88,48H40a8,8,0,0,0,0,16h88a8,8,0,0,0,0-16Zm109.66,13.66a8,8,0,0,1-11.32,0L206,177.36A40,40,0,1,1,217.36,166l20.3,20.3A8,8,0,0,1,237.66,197.66ZM184,168a24,24,0,1,0-24-24A24,24,0,0,0,184,168Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M36,64a4,4,0,0,1,4-4H216a4,4,0,0,1,0,8H40A4,4,0,0,1,36,64Zm4,68h72a4,4,0,0,0,0-8H40a4,4,0,0,0,0,8Zm88,56H40a4,4,0,0,0,0,8h88a4,4,0,0,0,0-8Zm106.83,6.83a4,4,0,0,1-5.66,0l-22.72-22.72a36.06,36.06,0,1,1,5.66-5.66l22.72,22.72A4,4,0,0,1,234.83,194.83ZM184,172a28,28,0,1,0-28-28A28,28,0,0,0,184,172Z`}))]]),dw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z`}))]]),fw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M236.37,139.4a12,12,0,0,0-12-3A84.07,84.07,0,0,1,119.6,31.59a12,12,0,0,0-15-15A108.86,108.86,0,0,0,49.69,55.07,108,108,0,0,0,136,228a107.09,107.09,0,0,0,64.93-21.69,108.86,108.86,0,0,0,38.44-54.94A12,12,0,0,0,236.37,139.4Zm-49.88,47.74A84,84,0,0,1,68.86,69.51,84.93,84.93,0,0,1,92.27,48.29Q92,52.13,92,56A108.12,108.12,0,0,0,200,164q3.87,0,7.71-.27A84.79,84.79,0,0,1,186.49,187.14Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M227.89,147.89A96,96,0,1,1,108.11,28.11,96.09,96.09,0,0,0,227.89,147.89Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M235.54,150.21a104.84,104.84,0,0,1-37,52.91A104,104,0,0,1,32,120,103.09,103.09,0,0,1,52.88,57.48a104.84,104.84,0,0,1,52.91-37,8,8,0,0,1,10,10,88.08,88.08,0,0,0,109.8,109.8,8,8,0,0,1,10,10Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232.13,143.64a6,6,0,0,0-6-1.49A90.07,90.07,0,0,1,113.86,29.85a6,6,0,0,0-7.49-7.48A102.88,102.88,0,0,0,54.48,58.68,102,102,0,0,0,197.32,201.52a102.88,102.88,0,0,0,36.31-51.89A6,6,0,0,0,232.13,143.64Zm-42,48.29a90,90,0,0,1-126-126A90.9,90.9,0,0,1,99.65,37.66,102.06,102.06,0,0,0,218.34,156.35,90.9,90.9,0,0,1,190.1,191.93Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M230.72,145.06a4,4,0,0,0-4-1A92.08,92.08,0,0,1,111.94,29.27a4,4,0,0,0-5-5A100.78,100.78,0,0,0,56.08,59.88a100,100,0,0,0,140,140,100.78,100.78,0,0,0,35.59-50.87A4,4,0,0,0,230.72,145.06ZM191.3,193.53A92,92,0,0,1,62.47,64.7a93,93,0,0,1,39.88-30.35,100.09,100.09,0,0,0,119.3,119.3A93,93,0,0,1,191.3,193.53Z`}))]]),pw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M200,164a36.07,36.07,0,0,0-33.94,24H72a28,28,0,0,1,0-56h96a44,44,0,0,0,0-88H72a12,12,0,0,0,0,24h96a20,20,0,0,1,0,40H72a52,52,0,0,0,0,104h94.06A36,36,0,1,0,200,164Zm0,48a12,12,0,1,1,12-12A12,12,0,0,1,200,212Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,200a24,24,0,1,1-24-24A24,24,0,0,1,224,200Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M200,168a32.06,32.06,0,0,0-31,24H72a32,32,0,0,1,0-64h96a40,40,0,0,0,0-80H72a8,8,0,0,0,0,16h96a24,24,0,0,1,0,48H72a48,48,0,0,0,0,96h97a32,32,0,1,0,31-40Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,200,216Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M228,200a28,28,0,0,1-54.83,8H72a48,48,0,0,1,0-96h96a24,24,0,0,0,0-48H72a8,8,0,0,1,0-16h96a40,40,0,0,1,0,80H72a32,32,0,0,0,0,64H173.17A28,28,0,0,1,228,200Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M200,170a30.05,30.05,0,0,0-29.4,24H72a34,34,0,0,1,0-68h96a38,38,0,0,0,0-76H72a6,6,0,0,0,0,12h96a26,26,0,0,1,0,52H72a46,46,0,0,0,0,92h98.6A30,30,0,1,0,200,170Zm0,48a18,18,0,1,1,18-18A18,18,0,0,1,200,218Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M200,168a32.06,32.06,0,0,0-31,24H72a32,32,0,0,1,0-64h96a40,40,0,0,0,0-80H72a8,8,0,0,0,0,16h96a24,24,0,0,1,0,48H72a48,48,0,0,0,0,96h97a32,32,0,1,0,31-40Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,200,216Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M200,172a28,28,0,0,0-27.71,24H72a36,36,0,0,1,0-72h96a36,36,0,0,0,0-72H72a4,4,0,0,0,0,8h96a28,28,0,0,1,0,56H72a44,44,0,0,0,0,88H172.29A28,28,0,1,0,200,172Zm0,48a20,20,0,1,1,20-20A20,20,0,0,1,200,220Z`}))]]),mw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M240.49,15.51a12,12,0,0,0-17,0L173.94,65.09l-2.54-2.55a36.05,36.05,0,0,0-50.91,0L100,83l-3.51-3.52a12,12,0,0,0-17,17L83,100,62.54,120.49a36,36,0,0,0,0,50.91l2.55,2.54L15.51,223.51a12,12,0,0,0,17,17l49.57-49.58,2.54,2.55a36.06,36.06,0,0,0,50.91,0L156,173l3.51,3.52a12,12,0,0,0,17-17L173,156l20.49-20.49a36,36,0,0,0,0-50.91l-2.55-2.54,49.58-49.57A12,12,0,0,0,240.49,15.51Zm-121.95,161a12,12,0,0,1-17,0L79.51,154.43a12,12,0,0,1,0-17L100,117l39,39Zm58-57.95h0L156,139l-39-39,20.49-20.49a12,12,0,0,1,17,0l22.06,22.06a12,12,0,0,1,0,17ZM85.27,33.37a12,12,0,0,1,21.46-10.74l8,16A12,12,0,1,1,93.27,49.37Zm-68,57.26a12,12,0,0,1,16.1-5.36l16,8a12,12,0,1,1-10.74,21.46l-16-8A12,12,0,0,1,17.27,90.63Zm221.46,74.74a12,12,0,0,1-16.1,5.36l-16-8a12,12,0,0,1,10.74-21.46l16,8A12,12,0,0,1,238.73,165.37Zm-68,57.26a12,12,0,1,1-21.46,10.74l-8-16a12,12,0,0,1,21.46-10.74Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M185,127,127,185a24,24,0,0,1-33.94,0L71,162.91A24,24,0,0,1,71,129L129,71a24,24,0,0,1,33.94,0L185,93.09A24,24,0,0,1,185,127Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32.06,32.06,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94h0L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22a16,16,0,0,1,0,22.63ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM29,103.43l20,8A8,8,0,1,0,55,96.57l-20-8A8,8,0,0,0,29,103.43ZM227,152.57l-20-8A8,8,0,1,0,201,159.43l20,8A8,8,0,0,0,227,152.57ZM159.43,201A8,8,0,0,0,144.57,207l8,20A8,8,0,1,0,167.43,221ZM237.91,18.52a8,8,0,0,0-11.5-.18L174,70.75l-5.38-5.38a32,32,0,0,0-45.28,0L106.14,82.54a4,4,0,0,0,0,5.66l61.7,61.66a4,4,0,0,0,5.66,0l16.74-16.74a32.76,32.76,0,0,0,9.81-22.52,31.82,31.82,0,0,0-9.37-23.17l-5.38-5.37,52.2-52.17A8.22,8.22,0,0,0,237.91,18.52ZM85.64,90.34a8,8,0,0,0-11.49.18,8.22,8.22,0,0,0,.41,11.37L80.67,108,65.34,123.31A31.82,31.82,0,0,0,56,146.47,32.75,32.75,0,0,0,65.77,169l5,4.94L18.49,226.13a8.21,8.21,0,0,0-.61,11.1,8,8,0,0,0,11.72.43L82,185.25l5.37,5.38a32.1,32.1,0,0,0,45.29,0L148,175.31l6.34,6.35a8,8,0,0,0,11.32-11.32Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M236.24,19.76a6,6,0,0,0-8.48,0L173.94,73.57l-6.79-6.78a30,30,0,0,0-42.42,0L100,91.51l-7.76-7.75a6,6,0,0,0-8.48,8.48L91.51,100,66.79,124.73a30,30,0,0,0,0,42.42l6.78,6.79L19.76,227.76a6,6,0,1,0,8.48,8.48l53.82-53.81,6.79,6.78a30,30,0,0,0,42.42,0L156,164.49l7.76,7.75a6,6,0,0,0,8.48-8.48L164.49,156l24.72-24.73a30,30,0,0,0,0-42.42l-6.78-6.79,53.81-53.82A6,6,0,0,0,236.24,19.76Zm-113.45,161a18,18,0,0,1-25.46,0L75.27,158.67a18,18,0,0,1,0-25.46L100,108.49,147.51,156Zm57.94-57.94L156,147.51,108.49,100l24.72-24.73a18,18,0,0,1,25.46,0l22.06,22.06a18,18,0,0,1,0,25.46ZM90.43,34.23a6,6,0,0,1,11.14-4.46l8,20a6,6,0,1,1-11.14,4.46Zm-64,59.54a6,6,0,0,1,7.8-3.34l20,8a6,6,0,1,1-4.46,11.14l-20-8A6,6,0,0,1,26.43,93.77Zm203.14,68.46a6,6,0,0,1-7.8,3.34l-20-8a6,6,0,0,1,4.46-11.14l20,8A6,6,0,0,1,229.57,162.23Zm-64,59.54a6,6,0,1,1-11.14,4.46l-8-20a6,6,0,0,1,11.14-4.46Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32,32,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22A16,16,0,0,1,179.31,121.37ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M234.83,21.17a4,4,0,0,0-5.66,0L173.94,76.4l-8.2-8.2a28,28,0,0,0-39.6,0L100,94.34l-9.17-9.17a4,4,0,0,0-5.66,5.66L94.34,100,68.2,126.14a28,28,0,0,0,0,39.6l8.2,8.2L21.17,229.17a4,4,0,0,0,5.66,5.66L82.06,179.6l8.2,8.2a28,28,0,0,0,39.6,0L156,161.66l9.17,9.17a4,4,0,0,0,5.66-5.66L161.66,156l26.14-26.14a28,28,0,0,0,0-39.6l-8.2-8.2,55.23-55.23A4,4,0,0,0,234.83,21.17Zm-110.63,161a20,20,0,0,1-28.28,0L73.86,160.08a20,20,0,0,1,0-28.28L100,105.66,150.34,156Zm57.94-57.94L156,150.34,105.66,100,131.8,73.86a20,20,0,0,1,28.28,0l22.06,22.06A20,20,0,0,1,182.14,124.2ZM92.29,33.49a4,4,0,1,1,7.42-3l8,20a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,104,56a4,4,0,0,1-3.71-2.51Zm-64,61a4,4,0,0,1,5.2-2.22l20,8A4,4,0,0,1,52,108a3.91,3.91,0,0,1-1.49-.29l-20-8A4,4,0,0,1,28.29,94.51Zm199.42,67A4,4,0,0,1,224,164a3.91,3.91,0,0,1-1.49-.29l-20-8a4,4,0,1,1,3-7.42l20,8A4,4,0,0,1,227.71,161.49Zm-64,61a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,160,228a4,4,0,0,1-3.71-2.51l-8-20a4,4,0,0,1,7.42-3Z`}))]]),hw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),gw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M144,180a16,16,0,1,1-16-16A16,16,0,0,1,144,180Zm92-52A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128ZM128,64c-24.26,0-44,17.94-44,40v4a12,12,0,0,0,24,0v-4c0-8.82,9-16,20-16s20,7.18,20,16-9,16-20,16a12,12,0,0,0-12,12v8a12,12,0,0,0,23.73,2.56C158.31,137.88,172,122.37,172,104,172,81.94,152.26,64,128,64Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,168a12,12,0,1,1,12-12A12,12,0,0,1,128,192Zm8-48.72V144a8,8,0,0,1-16,0v-8a8,8,0,0,1,8-8c13.23,0,24-9,24-20s-10.77-20-24-20-24,9-24,20v4a8,8,0,0,1-16,0v-4c0-19.85,17.94-36,40-36s40,16.15,40,36C168,125.38,154.24,139.93,136,143.28Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M138,180a10,10,0,1,1-10-10A10,10,0,0,1,138,180ZM128,74c-21,0-38,15.25-38,34v4a6,6,0,0,0,12,0v-4c0-12.13,11.66-22,26-22s26,9.87,26,22-11.66,22-26,22a6,6,0,0,0-6,6v8a6,6,0,0,0,12,0v-2.42c18.11-2.58,32-16.66,32-33.58C166,89.25,149,74,128,74Zm102,54A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M136,180a8,8,0,1,1-8-8A8,8,0,0,1,136,180ZM128,76c-19.85,0-36,14.36-36,32v4a4,4,0,0,0,8,0v-4c0-13.23,12.56-24,28-24s28,10.77,28,24-12.56,24-28,24a4,4,0,0,0-4,4v8a4,4,0,0,0,8,0v-4.2c18-1.77,32-15.36,32-31.8C164,90.36,147.85,76,128,76Zm100,52A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),_w=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,36H40A20,20,0,0,0,20,56V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V56A20,20,0,0,0,216,36ZM44,60H76V196H44ZM212,196H100V60H212Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M88,48V208H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM40,56H80V200H40ZM216,200H96V56H216V200Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H88V56H216V200Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14H216a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42ZM38,200V56a2,2,0,0,1,2-2H82V202H40A2,2,0,0,1,38,200Zm180,0a2,2,0,0,1-2,2H94V54H216a2,2,0,0,1,2,2Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM40,56H80V200H40ZM216,200H96V56H216V200Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44ZM36,200V56a4,4,0,0,1,4-4H84V204H40A4,4,0,0,1,36,200Zm184,0a4,4,0,0,1-4,4H92V52H216a4,4,0,0,1,4,4Z`}))]]),vw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M124,216a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V40A12,12,0,0,1,48,28h64a12,12,0,0,1,0,24H60V204h52A12,12,0,0,1,124,216Zm108.49-96.49-40-40a12,12,0,0,0-17,17L195,116H112a12,12,0,0,0,0,24h83l-19.52,19.51a12,12,0,0,0,17,17l40-40A12,12,0,0,0,232.49,119.51Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,56V200a16,16,0,0,1-16,16H48V40H208A16,16,0,0,1,224,56Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40A8,8,0,0,0,176,88v32H112a8,8,0,0,0,0,16h64v32a8,8,0,0,0,13.66,5.66l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M118,216a6,6,0,0,1-6,6H48a6,6,0,0,1-6-6V40a6,6,0,0,1,6-6h64a6,6,0,0,1,0,12H54V210h58A6,6,0,0,1,118,216Zm110.24-92.24-40-40a6,6,0,0,0-8.48,8.48L209.51,122H112a6,6,0,0,0,0,12h97.51l-29.75,29.76a6,6,0,1,0,8.48,8.48l40-40A6,6,0,0,0,228.24,123.76Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M116,216a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h64a4,4,0,0,1,0,8H52V212h60A4,4,0,0,1,116,216Zm110.83-90.83-40-40a4,4,0,0,0-5.66,5.66L214.34,124H112a4,4,0,0,0,0,8H214.34l-33.17,33.17a4,4,0,0,0,5.66,5.66l40-40A4,4,0,0,0,226.83,125.17Z`}))]]),yw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M199,125.31l-49.88-18.39L130.69,57a19.92,19.92,0,0,0-37.38,0L74.92,106.92,25,125.31a19.92,19.92,0,0,0,0,37.38l49.88,18.39L93.31,231a19.92,19.92,0,0,0,37.38,0l18.39-49.88L199,162.69a19.92,19.92,0,0,0,0-37.38Zm-63.38,35.16a12,12,0,0,0-7.11,7.11L112,212.28l-16.47-44.7a12,12,0,0,0-7.11-7.11L43.72,144l44.7-16.47a12,12,0,0,0,7.11-7.11L112,75.72l16.47,44.7a12,12,0,0,0,7.11,7.11L180.28,144ZM140,40a12,12,0,0,1,12-12h12V16a12,12,0,0,1,24,0V28h12a12,12,0,0,1,0,24H188V64a12,12,0,0,1-24,0V52H152A12,12,0,0,1,140,40ZM252,88a12,12,0,0,1-12,12h-4v4a12,12,0,0,1-24,0v-4h-4a12,12,0,0,1,0-24h4V72a12,12,0,0,1,24,0v4h4A12,12,0,0,1,252,88Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M194.82,151.43l-55.09,20.3-20.3,55.09a7.92,7.92,0,0,1-14.86,0l-20.3-55.09-55.09-20.3a7.92,7.92,0,0,1,0-14.86l55.09-20.3,20.3-55.09a7.92,7.92,0,0,1,14.86,0l20.3,55.09,55.09,20.3A7.92,7.92,0,0,1,194.82,151.43Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M208,144a15.78,15.78,0,0,1-10.42,14.94L146,178l-19,51.62a15.92,15.92,0,0,1-29.88,0L78,178l-51.62-19a15.92,15.92,0,0,1,0-29.88L78,110l19-51.62a15.92,15.92,0,0,1,29.88,0L146,110l51.62,19A15.78,15.78,0,0,1,208,144ZM152,48h16V64a8,8,0,0,0,16,0V48h16a8,8,0,0,0,0-16H184V16a8,8,0,0,0-16,0V32H152a8,8,0,0,0,0,16Zm88,32h-8V72a8,8,0,0,0-16,0v8h-8a8,8,0,0,0,0,16h8v8a8,8,0,0,0,16,0V96h8a8,8,0,0,0,0-16Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M196.89,130.94,144.4,111.6,125.06,59.11a13.92,13.92,0,0,0-26.12,0L79.6,111.6,27.11,130.94a13.92,13.92,0,0,0,0,26.12L79.6,176.4l19.34,52.49a13.92,13.92,0,0,0,26.12,0L144.4,176.4l52.49-19.34a13.92,13.92,0,0,0,0-26.12Zm-4.15,14.86-55.08,20.3a6,6,0,0,0-3.56,3.56l-20.3,55.08a1.92,1.92,0,0,1-3.6,0L89.9,169.66a6,6,0,0,0-3.56-3.56L31.26,145.8a1.92,1.92,0,0,1,0-3.6l55.08-20.3a6,6,0,0,0,3.56-3.56l20.3-55.08a1.92,1.92,0,0,1,3.6,0l20.3,55.08a6,6,0,0,0,3.56,3.56l55.08,20.3a1.92,1.92,0,0,1,0,3.6ZM146,40a6,6,0,0,1,6-6h18V16a6,6,0,0,1,12,0V34h18a6,6,0,0,1,0,12H182V64a6,6,0,0,1-12,0V46H152A6,6,0,0,1,146,40ZM246,88a6,6,0,0,1-6,6H230v10a6,6,0,0,1-12,0V94H208a6,6,0,0,1,0-12h10V72a6,6,0,0,1,12,0V82h10A6,6,0,0,1,246,88Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M196.2,132.81l-53.36-19.65L123.19,59.8a11.93,11.93,0,0,0-22.38,0L81.16,113.16,27.8,132.81a11.93,11.93,0,0,0,0,22.38l53.36,19.65,19.65,53.36a11.93,11.93,0,0,0,22.38,0l19.65-53.36,53.36-19.65a11.93,11.93,0,0,0,0-22.38Zm-2.77,14.87L138.35,168a4,4,0,0,0-2.37,2.37l-20.3,55.08a3.92,3.92,0,0,1-7.36,0L88,170.35A4,4,0,0,0,85.65,168l-55.08-20.3a3.92,3.92,0,0,1,0-7.36L85.65,120A4,4,0,0,0,88,117.65l20.3-55.08a3.92,3.92,0,0,1,7.36,0L136,117.65a4,4,0,0,0,2.37,2.37l55.08,20.3a3.92,3.92,0,0,1,0,7.36ZM148,40a4,4,0,0,1,4-4h20V16a4,4,0,0,1,8,0V36h20a4,4,0,0,1,0,8H180V64a4,4,0,0,1-8,0V44H152A4,4,0,0,1,148,40Zm96,48a4,4,0,0,1-4,4H228v12a4,4,0,0,1-8,0V92H208a4,4,0,0,1,0-8h12V72a4,4,0,0,1,8,0V84h12A4,4,0,0,1,244,88Z`}))]]),bw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M100,36H56A20,20,0,0,0,36,56v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,100,36ZM96,96H60V60H96ZM200,36H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,60H160V60h36Zm-96,40H56a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,100,136Zm-4,60H60V160H96Zm104-60H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,200,136Zm-4,60H160V160h36Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M112,56v48a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8h48A8,8,0,0,1,112,56Zm88-8H152a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V56A8,8,0,0,0,200,48Zm-96,96H56a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V152A8,8,0,0,0,104,144Zm96,0H152a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V152A8,8,0,0,0,200,144Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M200,136H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48ZM104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,56v48a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40h48A16,16,0,0,1,120,56Zm80-16H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm-96,96H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm96,0H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M104,42H56A14,14,0,0,0,42,56v48a14,14,0,0,0,14,14h48a14,14,0,0,0,14-14V56A14,14,0,0,0,104,42Zm2,62a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2h48a2,2,0,0,1,2,2Zm94-62H152a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14h48a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,62a2,2,0,0,1-2,2H152a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2h48a2,2,0,0,1,2,2Zm-98,34H56a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14h48a14,14,0,0,0,14-14V152A14,14,0,0,0,104,138Zm2,62a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V152a2,2,0,0,1,2-2h48a2,2,0,0,1,2,2Zm94-62H152a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14h48a14,14,0,0,0,14-14V152A14,14,0,0,0,200,138Zm2,62a2,2,0,0,1-2,2H152a2,2,0,0,1-2-2V152a2,2,0,0,1,2-2h48a2,2,0,0,1,2,2Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M104,44H56A12,12,0,0,0,44,56v48a12,12,0,0,0,12,12h48a12,12,0,0,0,12-12V56A12,12,0,0,0,104,44Zm4,60a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4Zm92-60H152a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12h48a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,60a4,4,0,0,1-4,4H152a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4ZM104,140H56a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12h48a12,12,0,0,0,12-12V152A12,12,0,0,0,104,140Zm4,60a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V152a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4Zm92-60H152a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12h48a12,12,0,0,0,12-12V152A12,12,0,0,0,200,140Zm4,60a4,4,0,0,1-4,4H152a4,4,0,0,1-4-4V152a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4Z`}))]]),xw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M243,96a20.33,20.33,0,0,0-17.74-14l-56.59-4.57L146.83,24.62a20.36,20.36,0,0,0-37.66,0L87.35,77.44,30.76,82A20.45,20.45,0,0,0,19.1,117.88l43.18,37.24-13.2,55.7A20.37,20.37,0,0,0,79.57,233L128,203.19,176.43,233a20.39,20.39,0,0,0,30.49-22.15l-13.2-55.7,43.18-37.24A20.43,20.43,0,0,0,243,96ZM172.53,141.7a12,12,0,0,0-3.84,11.86L181.58,208l-47.29-29.08a12,12,0,0,0-12.58,0L74.42,208l12.89-54.4a12,12,0,0,0-3.84-11.86L41.2,105.24l55.4-4.47a12,12,0,0,0,10.13-7.38L128,41.89l21.27,51.5a12,12,0,0,0,10.13,7.38l55.4,4.47Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M229.06,108.79l-48.7,42,14.88,62.79a8.4,8.4,0,0,1-12.52,9.17L128,189.09,73.28,222.74a8.4,8.4,0,0,1-12.52-9.17l14.88-62.79-48.7-42A8.46,8.46,0,0,1,31.73,94L95.64,88.8l24.62-59.6a8.36,8.36,0,0,1,15.48,0l24.62,59.6L224.27,94A8.46,8.46,0,0,1,229.06,108.79Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M239.18,97.26A16.38,16.38,0,0,0,224.92,86l-59-4.76L143.14,26.15a16.36,16.36,0,0,0-30.27,0L90.11,81.23,31.08,86a16.46,16.46,0,0,0-9.37,28.86l45,38.83L53,211.75a16.38,16.38,0,0,0,24.5,17.82L128,198.49l50.53,31.08A16.4,16.4,0,0,0,203,211.75l-13.76-58.07,45-38.83A16.43,16.43,0,0,0,239.18,97.26Zm-15.34,5.47-48.7,42a8,8,0,0,0-2.56,7.91l14.88,62.8a.37.37,0,0,1-.17.48c-.18.14-.23.11-.38,0l-54.72-33.65a8,8,0,0,0-8.38,0L69.09,215.94c-.15.09-.19.12-.38,0a.37.37,0,0,1-.17-.48l14.88-62.8a8,8,0,0,0-2.56-7.91l-48.7-42c-.12-.1-.23-.19-.13-.5s.18-.27.33-.29l63.92-5.16A8,8,0,0,0,103,91.86l24.62-59.61c.08-.17.11-.25.35-.25s.27.08.35.25L153,91.86a8,8,0,0,0,6.75,4.92l63.92,5.16c.15,0,.24,0,.33.29S224,102.63,223.84,102.73Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M234.29,114.85l-45,38.83L203,211.75a16.4,16.4,0,0,1-24.5,17.82L128,198.49,77.47,229.57A16.4,16.4,0,0,1,53,211.75l13.76-58.07-45-38.83A16.46,16.46,0,0,1,31.08,86l59-4.76,22.76-55.08a16.36,16.36,0,0,1,30.27,0l22.75,55.08,59,4.76a16.46,16.46,0,0,1,9.37,28.86Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M237.28,97.87A14.18,14.18,0,0,0,224.76,88l-60.25-4.87-23.22-56.2a14.37,14.37,0,0,0-26.58,0L91.49,83.11,31.24,88a14.18,14.18,0,0,0-12.52,9.89A14.43,14.43,0,0,0,23,113.32L69,152.93l-14,59.25a14.4,14.4,0,0,0,5.59,15,14.1,14.1,0,0,0,15.91.6L128,196.12l51.58,31.71a14.1,14.1,0,0,0,15.91-.6,14.4,14.4,0,0,0,5.59-15l-14-59.25L233,113.32A14.43,14.43,0,0,0,237.28,97.87Zm-12.14,6.37-48.69,42a6,6,0,0,0-1.92,5.92l14.88,62.79a2.35,2.35,0,0,1-.95,2.57,2.24,2.24,0,0,1-2.6.1L131.14,184a6,6,0,0,0-6.28,0L70.14,217.61a2.24,2.24,0,0,1-2.6-.1,2.35,2.35,0,0,1-1-2.57l14.88-62.79a6,6,0,0,0-1.92-5.92l-48.69-42a2.37,2.37,0,0,1-.73-2.65,2.28,2.28,0,0,1,2.07-1.65l63.92-5.16a6,6,0,0,0,5.06-3.69l24.63-59.6a2.35,2.35,0,0,1,4.38,0l24.63,59.6a6,6,0,0,0,5.06,3.69l63.92,5.16a2.28,2.28,0,0,1,2.07,1.65A2.37,2.37,0,0,1,225.14,104.24Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M239.18,97.26A16.38,16.38,0,0,0,224.92,86l-59-4.76L143.14,26.15a16.36,16.36,0,0,0-30.27,0L90.11,81.23,31.08,86a16.46,16.46,0,0,0-9.37,28.86l45,38.83L53,211.75a16.38,16.38,0,0,0,24.5,17.82L128,198.49l50.53,31.08A16.4,16.4,0,0,0,203,211.75l-13.76-58.07,45-38.83A16.43,16.43,0,0,0,239.18,97.26Zm-15.34,5.47-48.7,42a8,8,0,0,0-2.56,7.91l14.88,62.8a.37.37,0,0,1-.17.48c-.18.14-.23.11-.38,0l-54.72-33.65a8,8,0,0,0-8.38,0L69.09,215.94c-.15.09-.19.12-.38,0a.37.37,0,0,1-.17-.48l14.88-62.8a8,8,0,0,0-2.56-7.91l-48.7-42c-.12-.1-.23-.19-.13-.5s.18-.27.33-.29l63.92-5.16A8,8,0,0,0,103,91.86l24.62-59.61c.08-.17.11-.25.35-.25s.27.08.35.25L153,91.86a8,8,0,0,0,6.75,4.92l63.92,5.16c.15,0,.24,0,.33.29S224,102.63,223.84,102.73Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M235.36,98.49A12.21,12.21,0,0,0,224.59,90l-61.47-5L139.44,27.67a12.37,12.37,0,0,0-22.88,0L92.88,85,31.41,90a12.45,12.45,0,0,0-7.07,21.84l46.85,40.41L56.87,212.64a12.35,12.35,0,0,0,18.51,13.49L128,193.77l52.62,32.36a12.12,12.12,0,0,0,13.69-.51,12.28,12.28,0,0,0,4.82-13l-14.32-60.42,46.85-40.41A12.29,12.29,0,0,0,235.36,98.49Zm-8.93,7.26-48.68,42a4,4,0,0,0-1.28,3.95l14.87,62.79a4.37,4.37,0,0,1-1.72,4.65,4.24,4.24,0,0,1-4.81.18L130.1,185.67a4,4,0,0,0-4.2,0L71.19,219.32a4.24,4.24,0,0,1-4.81-.18,4.37,4.37,0,0,1-1.72-4.65L79.53,151.7a4,4,0,0,0-1.28-3.95l-48.68-42A4.37,4.37,0,0,1,28.25,101a4.31,4.31,0,0,1,3.81-3L96,92.79a4,4,0,0,0,3.38-2.46L124,30.73a4.35,4.35,0,0,1,8.08,0l24.62,59.6A4,4,0,0,0,160,92.79l63.9,5.15a4.31,4.31,0,0,1,3.81,3A4.37,4.37,0,0,1,226.43,105.75Z`}))]]),Sw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M116,36V20a12,12,0,0,1,24,0V36a12,12,0,0,1-24,0Zm80,92a68,68,0,1,1-68-68A68.07,68.07,0,0,1,196,128Zm-24,0a44,44,0,1,0-44,44A44.05,44.05,0,0,0,172,128ZM51.51,68.49a12,12,0,1,0,17-17l-12-12a12,12,0,0,0-17,17Zm0,119-12,12a12,12,0,0,0,17,17l12-12a12,12,0,1,0-17-17ZM196,72a12,12,0,0,0,8.49-3.51l12-12a12,12,0,0,0-17-17l-12,12A12,12,0,0,0,196,72Zm8.49,115.51a12,12,0,0,0-17,17l12,12a12,12,0,0,0,17-17ZM48,128a12,12,0,0,0-12-12H20a12,12,0,0,0,0,24H36A12,12,0,0,0,48,128Zm80,80a12,12,0,0,0-12,12v16a12,12,0,0,0,24,0V220A12,12,0,0,0,128,208Zm108-92H220a12,12,0,0,0,0,24h16a12,12,0,0,0,0-24Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M184,128a56,56,0,1,1-56-56A56,56,0,0,1,184,128Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm8,24a64,64,0,1,0,64,64A64.07,64.07,0,0,0,128,64ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M122,40V16a6,6,0,0,1,12,0V40a6,6,0,0,1-12,0Zm68,88a62,62,0,1,1-62-62A62.07,62.07,0,0,1,190,128Zm-12,0a50,50,0,1,0-50,50A50.06,50.06,0,0,0,178,128ZM59.76,68.24a6,6,0,1,0,8.48-8.48l-16-16a6,6,0,0,0-8.48,8.48Zm0,119.52-16,16a6,6,0,1,0,8.48,8.48l16-16a6,6,0,1,0-8.48-8.48ZM192,70a6,6,0,0,0,4.24-1.76l16-16a6,6,0,0,0-8.48-8.48l-16,16A6,6,0,0,0,192,70Zm4.24,117.76a6,6,0,0,0-8.48,8.48l16,16a6,6,0,0,0,8.48-8.48ZM46,128a6,6,0,0,0-6-6H16a6,6,0,0,0,0,12H40A6,6,0,0,0,46,128Zm82,82a6,6,0,0,0-6,6v24a6,6,0,0,0,12,0V216A6,6,0,0,0,128,210Zm112-88H216a6,6,0,0,0,0,12h24a6,6,0,0,0,0-12Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M124,40V16a4,4,0,0,1,8,0V40a4,4,0,0,1-8,0Zm64,88a60,60,0,1,1-60-60A60.07,60.07,0,0,1,188,128Zm-8,0a52,52,0,1,0-52,52A52.06,52.06,0,0,0,180,128ZM61.17,66.83a4,4,0,0,0,5.66-5.66l-16-16a4,4,0,0,0-5.66,5.66Zm0,122.34-16,16a4,4,0,0,0,5.66,5.66l16-16a4,4,0,0,0-5.66-5.66ZM192,68a4,4,0,0,0,2.83-1.17l16-16a4,4,0,1,0-5.66-5.66l-16,16A4,4,0,0,0,192,68Zm2.83,121.17a4,4,0,0,0-5.66,5.66l16,16a4,4,0,0,0,5.66-5.66ZM40,124H16a4,4,0,0,0,0,8H40a4,4,0,0,0,0-8Zm88,88a4,4,0,0,0-4,4v24a4,4,0,0,0,8,0V216A4,4,0,0,0,128,212Zm112-88H216a4,4,0,0,0,0,8h24a4,4,0,0,0,0-8Z`}))]]),Cw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:aw}));Cw.displayName=`BellIcon`;var ww=Cw,Tw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:ow}));Tw.displayName=`BookOpenIcon`;var Ew=Tw,Dw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:sw}));Dw.displayName=`ChatCircleIcon`;var Ow=Dw,kw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:cw}));kw.displayName=`CompassIcon`;var Aw=kw,jw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:lw}));jw.displayName=`GearIcon`;var Mw=jw,Nw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:uw}));Nw.displayName=`ListMagnifyingGlassIcon`;var Pw=Nw,Fw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:dw}));Fw.displayName=`MagnifyingGlassIcon`;var Iw=Fw,Lw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:fw}));Lw.displayName=`MoonIcon`;var Rw=Lw,zw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:pw}));zw.displayName=`PathIcon`;var Bw=zw,Vw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:mw}));Vw.displayName=`PlugsConnectedIcon`;var Hw=Vw,Uw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:hw}));Uw.displayName=`PlusIcon`;var Ww=Uw,Gw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:gw}));Gw.displayName=`QuestionIcon`;var Kw=Gw,qw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:_w}));qw.displayName=`SidebarSimpleIcon`;var Jw=qw,Yw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:vw}));Yw.displayName=`SignOutIcon`;var Xw=Yw,Zw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:yw}));Zw.displayName=`SparkleIcon`;var Qw=Zw,$w=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:bw}));$w.displayName=`SquaresFourIcon`;var eT=$w,tT=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:xw}));tT.displayName=`StarIcon`;var nT=tT,rT=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:Sw}));rT.displayName=`SunIcon`;var iT=rT,aT=[`agent-threads`];async function oT(e){let t=await Wt(e);if(!t.ok)throw Error(`Request failed (${t.status})`);return t.json()}var sT=new Set([`create_dashboard`,`edit_dashboard`,`replace_dashboard`,`restore_dashboard_version`]);function cT(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function lT(e){if(typeof e==`string`)try{let t=JSON.parse(e);if(cT(t))return t}catch{}}var uT=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),dT=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0;function fT(e){return cT(e)&&typeof e.id==`string`&&[`ok`,`empty`,`error`,`invalid`,`not_run`,`partial`,`stale`].includes(String(e.status))&&(e.rows===void 0||dT(e.rows))&&(e.elapsed_ms===void 0||dT(e.elapsed_ms))&&(e.diagnosis===void 0||typeof e.diagnosis==`string`)&&(e.error===void 0||typeof e.error==`string`)}function pT(e){if(!cT(e)||!Number.isInteger(e.base_version)||Number(e.base_version)<0||!Number.isInteger(e.version)||Number(e.version)<1||!Array.isArray(e.changes)||typeof e.layout_changed!=`boolean`||e.dashboard_fields!==void 0&&!uT(e.dashboard_fields)||!e.changes.every(e=>cT(e)&&typeof e.panel_id==`string`&&typeof e.title==`string`&&[`added`,`changed`,`removed`].includes(String(e.kind))&&(e.fields===void 0||uT(e.fields)&&!e.fields.includes(`grid`))&&(e.position_changed===void 0||typeof e.position_changed==`boolean`)))return!1;let t=e.save_check;return cT(t)&&typeof t.checked==`boolean`&&dT(t.elapsed_ms)&&Array.isArray(t.panels)&&t.panels.every(e=>fT(e)&&Number.isInteger(e.rows)&&Number(e.rows)>=0)&&new Set(t.panels.map(e=>e.id)).size===t.panels.length&&(t.reason===void 0||typeof t.reason==`string`)&&(!t.checked||t.panels.every(e=>e.status!==`not_run`))}function mT(e,t,n){let r=-1;n.forEach((n,i)=>{n.role===`tool`&&n.toolCallId===e&&n.content===t&&(r=i)});let i=r<0?n.length:r,a=-1;if(n.slice(0,i).forEach((e,t)=>{e.role===`user`&&(a=t)}),a<0)return null;let o=n.slice(a+1,i).flatMap(e=>e.role===`assistant`?e.toolCalls??[]:[]).filter(t=>t.id===e),s=o.length===1?o[0].function.name:void 0;if(!s||!sT.has(s))return null;let c=lT(t),l=c?.dashboard,u=c?.receipt;return!c||c.error||c.isError||!cT(l)||typeof l.id!=`string`||!l.id||typeof l.name!=`string`||!l.name||!pT(u)||l.version!==u.version||r>=0&&n[r].error?null:{id:l.id,name:l.name,version:u.version,label:s===`create_dashboard`?`Created`:s===`restore_dashboard_version`?`Restored`:`Updated`,receipt:u}}var hT={viz:`chart type`,sql:`SQL`,content:`text`,x_unit:`x-axis unit`,options:`display options`,drill:`drill-down`,click:`click action`,time:`time range`,annotations:`markers`,better:`better direction`,reduce:`summary`,min:`minimum`,max:`maximum`},gT=e=>Object.hasOwn(hT,e)?hT[e]:e.replaceAll(`_`,` `),_T=e=>e.kind===`added`?`+ ${e.title}`:e.kind===`removed`?`− ${e.title}`:`~ ${e.title}${e.fields?.length?`: `+e.fields.map(gT).join(`, `):``}${e.position_changed?` · moved`:``}`;function vT(e){return[...e.changes.map(_T),...e.layout_changed?[`Layout adjusted`]:[],...e.dashboard_fields?.map(e=>`Dashboard: ${gT(e)}`)??[]]}function yT(e,t,n){return e.filter(e=>n.has(e.panel_id)&&!t.some(t=>t.panel_id===e.panel_id&&t.path===e.path))}var bT={schema:`Telemetry`,context:`Context`,draft:`Draft`,validation:`Validation`,preview:`Preview`,save:`Save`},xT=new Set([`get_insights`,`query_telemetry`,`get_overview`,`get_service_topology`,`get_service_dependencies`,`get_service_performance`,`inspect_trace`,`search_logs`]),ST=(e,t)=>Array.isArray(e)?e.flatMap(e=>cT(e)&&typeof e.path==`string`&&typeof e.message==`string`?[{panel_id:t,path:e.path,message:e.message}]:[]):[],CT=e=>{let t=lT(e)?.error;return cT(t)?t.code:void 0},wT=e=>e.role===`tool`&&CT(e.content)===`interrupted`,TT=e=>![`invalid`,`not_run`].includes(e.status);function ET(e,t){let n=e.findIndex(e=>e.id===t&&e.role===`user`);if(n<0)return null;let r=e.findIndex((e,t)=>t>n&&e.role===`user`),i=e.slice(n+1,r<0?void 0:r),a=new Set(i.flatMap(e=>e.role===`tool`&&CT(e.content)===`answer_only`?[e.toolCallId]:[])),o=i.flatMap((e,t)=>e.role===`assistant`?(e.toolCalls??[]).map(e=>({call:e,index:t})):[]).filter(({call:e})=>!a.has(e.id));if(!o.some(({call:e})=>sT.has(e.function.name)||e.function.name===`preview_panels`))return null;let s={schema:{state:`unobserved`},context:{state:`unobserved`},draft:{state:`unobserved`},validation:{state:`unobserved`},preview:{state:`unobserved`},save:{state:`unobserved`}},c={turn_id:t,stages:s,panel_titles:{},panels:[],problems:[],corrections:[],save_attempts:[],explanations:[],context_counts:{deploys:0,anomalies:0}},l=new Map,u=new Map;for(let{call:e}of o)l.set(e.id,(l.get(e.id)??0)+1);i.forEach((e,t)=>{if(e.role===`tool`){let n=u.get(e.toolCallId)??[];n.push({index:t,message:e}),u.set(e.toolCallId,n)}});let d=new Map,f=new Map,p=[],m,h=!1,g=!1,_=(e,t)=>{for(let n of yT(y.get(e)??[],t,new Set([e])))p.some(e=>e.panel_id===n.panel_id&&e.path===n.path)||p.push(n);y.set(e,t)},v=new Map,y=new Map,b=new Set,x=!1,ee=!1;for(let{call:t,index:n}of o){if(l.get(t.id)!==1)continue;let r=t.function.name,i=lT(t.function.arguments),a=(u.get(t.id)??[]).filter(e=>e.index>n),o=a.length===1||sT.has(r)&&a.length>1&&a.slice(0,-1).every(e=>wT(e.message))?a.at(-1).message:void 0,S=o&&lT(o.content),C=!!S&&o?.role===`tool`&&!o.error&&!S.error&&!S.isError,te=o?C?`complete`:`failed`:`incomplete`;if(r===`get_telemetry_schema`&&(s.schema={state:te}),xT.has(r)){let e=o?.role===`tool`&&!o.error&&!S?.error&&!S?.isError&&typeof o.content==`string`&&o.content.length>0;if(s.context={state:o?e?`complete`:`failed`:`incomplete`},C)for(let[e,t]of[[`deploys`,[`deploys`,`deployments`]],[`anomalies`,[`anomalies`]]])for(let n of t)Array.isArray(S[n])&&(c.context_counts[e]+=S[n].length)}if(r===`preview_panels`||r===`create_dashboard`||r===`replace_dashboard`){let e=r===`preview_panels`?i?.panels:cT(i?.dashboard)?i.dashboard.panels:void 0;if(Array.isArray(e)){c.panel_count=e.length,s.draft={state:`complete`};for(let t of e)cT(t)&&typeof t.id==`string`&&typeof t.title==`string`&&t.title.trim()&&f.set(t.id,t.title)}}if(r===`preview_panels`){x=!0;let e=Array.isArray(i?.panels)?i.panels.flatMap(e=>cT(e)&&typeof e.id==`string`?[e.id]:[]):[];for(let t of e)v.set(t,{id:t,status:`not_run`});let t=C&&Array.isArray(S.panels)&&S.panels.every(fT)?S.panels:void 0,n=typeof S?.elapsed_ms==`number`&&S.elapsed_ms>=0?S.elapsed_ms:void 0;if(s.validation={state:t?t.some(e=>e.status===`invalid`||e.status===`not_run`)||ST(S?.problems,`dashboard`).length?`failed`:`complete`:te===`complete`?`failed`:te},s.preview={state:t?t.every(TT)?`complete`:`incomplete`:te===`complete`?`failed`:te,elapsed_ms:n},!t||e.length===0||t.length!==e.length||new Set(t.map(e=>e.id)).size!==e.length||t.some(t=>!e.includes(t.id))){ee=e.length===0;for(let t of e)o&&b.add(t);continue}ee=!1;for(let t of e)b.delete(t);for(let e of t){let t=ST(e.problems,e.id);if(e.status!==`not_run`)_(e.id,t);else{let n=y.get(e.id)??[];y.set(e.id,[...n,...t.filter(e=>!n.some(t=>t.path===e.path))])}v.set(e.id,e)}c.problems=[...y.values()].flat().concat(ST(S?.problems,`dashboard`))}if(sT.has(r)){let n=o&&mT(t.id,o.content,e),r=!!o&&wT(o),i=!r&&o?.role===`tool`&&(!!o.error||!!S?.error||!!S?.isError);if(g=!!i,h=!!o&&!n&&!i&&!r,s.save={state:n?`complete`:r?`interrupted`:i?`failed`:`incomplete`},n)for(let e of c.save_attempts)e.state===`failed`&&(e.state=`retried`);if(c.save_attempts.push({call_id:t.id,state:s.save.state}),n){m?.id!==n.id&&(m=n,d.clear());for(let e of n.receipt.changes){e.title.trim()&&f.set(e.panel_id,e.title);let t=d.get(e.panel_id);if(t?.kind===`added`&&e.kind===`removed`){d.delete(e.panel_id);continue}if(t?.kind===`added`){d.set(e.panel_id,{panel_id:e.panel_id,title:e.title,kind:`added`});continue}if(e.kind===`removed`){d.set(e.panel_id,e);continue}t&&e.kind===`changed`?d.set(e.panel_id,{...e,fields:[...new Set([...t.fields??[],...e.fields??[]])].sort(),position_changed:t.position_changed||e.position_changed}):d.set(e.panel_id,t?.kind===`removed`&&e.kind===`added`?{...e,kind:`changed`}:e)}let e=S?.dashboard,t=cT(e)?e.spec:void 0;if(cT(t)&&Array.isArray(t.panels))for(let e of t.panels)cT(e)&&typeof e.id==`string`&&typeof e.title==`string`&&e.title.trim()&&f.set(e.id,e.title);let r=c.saved?.id===n.id?c.saved.receipt:void 0;c.saved={...n,label:m.label,receipt:{...n.receipt,base_version:m.receipt.base_version,changes:[...d.values()],layout_changed:m.receipt.base_version!==0&&(n.receipt.layout_changed||!!r?.layout_changed),dashboard_fields:m.receipt.base_version===0?void 0:[...new Set([...r?.dashboard_fields??[],...n.receipt.dashboard_fields??[]])].sort()}},c.panel_count=n.receipt.save_check.panels.length,s.draft={state:`complete`};let i=new Set(n.receipt.save_check.panels.map(e=>e.id));for(let e of n.receipt.save_check.panels)e.status===`invalid`?_(e.id,ST(e.problems,e.id)):TT(e)&&(_(e.id,[]),b.delete(e.id));p=p.filter(e=>i.has(e.panel_id)),c.problems=[...y.values()].flat().filter(e=>i.has(e.panel_id))}}}if(h)return null;c.panel_titles=Object.fromEntries(f),c.corrections=p.map(e=>({...e,title:f.get(e.panel_id)??e.panel_id}));let S=c.saved?new Set(c.saved.receipt.save_check.panels.map(e=>e.id)):void 0;if(c.panels=[...v.values()].filter(e=>!S||S.has(e.id)),x){let e=ee||[...b].some(e=>!S||S.has(e)),t=c.panels.some(e=>e.status===`not_run`),n=c.problems.length>0;s.validation.state=e||n?`failed`:t?`incomplete`:`complete`,s.preview.state=e?`failed`:t||n||c.panels.some(e=>e.status===`invalid`)?`incomplete`:`complete`}let C=c.saved?.receipt.save_check;C&&!C.checked&&c.explanations.push(`Save check incomplete: ${C.reason||`Panels were not checked`}`);for(let e of C?.panels??c.panels)e.status!==`ok`&&c.explanations.push(`${f.get(e.id)??e.id}: ${e.status}${e.error||e.diagnosis?` — ${e.error||e.diagnosis}`:``}`);for(let e of c.problems)c.explanations.push(`${f.get(e.panel_id)??e.panel_id}: ${e.message}`);let te=Object.entries(s).filter(([,e])=>e.state===`incomplete`||e.state===`failed`).map(([e,t])=>`${bT[e]}: ${t.state}`);return te.length&&c.explanations.push(te.join(` · `)),s.save.state===`interrupted`&&c.explanations.push(`Save interrupted · outcome unknown`),g&&c.explanations.push(c.saved?`A later change failed; v${c.saved.version} remains saved`:`Save failed · dashboard was not saved`),c}var DT=(0,k.createContext)(null);function OT(){let e=(0,k.useContext)(DT);if(!e)throw Error(`Pitot app context is unavailable`);return e}var kT=`Build me a dashboard for my services, showing request volume, latency, and errors. Ask me which services to monitor first.`,AT={query_telemetry:{activity:`Querying telemetry…`,title:`Telemetry panels`},get_overview:{activity:`Checking system health…`,title:`System health`},get_service_topology:{activity:`Mapping service dependencies…`,title:`Service map`},get_service_dependencies:{activity:`Tracing service dependencies…`,title:`Service dependencies`},list_panel_exemplars:{activity:`Finding example traces…`,title:`Example traces`},resolve_panel_variables:{activity:`Reading filter choices…`,title:`Filter choices`},query_panel_fragment:{activity:`Refreshing panels…`,title:`Panel refresh`},get_service_performance:{activity:`Reading performance signals…`,title:`Performance`},inspect_trace:{activity:`Inspecting a trace…`,title:`Trace lookup`},search_logs:{activity:`Searching logs…`,title:`Logs`},get_insights:{activity:`Reviewing detected anomalies…`,title:`Detected anomalies`},get_telemetry_schema:{activity:`Reading what telemetry exists…`,title:`Telemetry discovery`},preview_panels:{activity:`Checking dashboard panels…`,title:`Panel check`},list_dashboards:{activity:`Looking through your dashboards…`,title:`Dashboards`},get_dashboard:{activity:`Opening your dashboard…`,title:`Dashboard`},create_dashboard:{activity:`Building your dashboard…`,title:`Dashboard save`},edit_dashboard:{activity:`Updating your dashboard…`,title:`Dashboard save`},replace_dashboard:{activity:`Redesigning your dashboard…`,title:`Dashboard save`},list_dashboard_versions:{activity:`Reading your dashboard history…`,title:`Dashboard history`},restore_dashboard_version:{activity:`Restoring your dashboard…`,title:`Dashboard`}};function jT(e){return AT[e]?.activity??`Working on it…`}function MT(e){return AT[e]?.title??`Analysis step`}function NT(e){switch(e){case`provider_unavailable`:return`Pitot could not reach the model provider. Please try again.`;case`step_limit`:return`Pitot reached its step limit before finishing. Try a narrower question.`;case`time_limit`:return`Pitot reached its 5-minute time limit. Try a smaller request.`;default:return`Pitot could not complete this analysis. Please try again.`}}function PT(e){let t=(0,k.useRef)(new Map);return(0,k.useMemo)(()=>{let n=new Map,r=new Set,i=e.flatMap((e,t)=>e.role===`user`?[t]:[]);i.forEach((a,o)=>{let s=i[o+1]??e.length,c=e[a],l=e[s-1];r.add(c.id);let u=t.current.get(c.id),d=u&&u.last===l&&u.length===s-a?u.receipt:ET(e.slice(a,s),c.id);oe.msecs?(e.seq=UT(n),e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function HT(e,t,n,r,i=0){if(e.length<16)throw Error(`Random bytes length must be >= 16`);if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),n??=UT(e),r[i++]=t/1099511627776&255,r[i++]=t/4294967296&255,r[i++]=t/16777216&255,r[i++]=t/65536&255,r[i++]=t/256&255,r[i++]=t&255,r[i++]=112|n>>>28&15,r[i++]=n>>>20&255,r[i++]=128|n>>>14&63,r[i++]=n>>>6&255,r[i++]=n<<2&255|e[10]&3,r[i++]=e[11],r[i++]=e[12],r[i++]=e[13],r[i++]=e[14],r[i++]=e[15],r}function UT(e){return(e[6]&127)<<24|e[7]<<16|e[8]<<8|e[9]}function WT(){return BT()}function GT(){let{setColorScheme:e}=ar(),t=cr(`light`,{getInitialValueInEffect:!0}),n=t===`dark`?`light`:`dark`,[r,i]=(0,k.useState)(!1);return(0,A.jsx)(Bi,{label:`Switch to ${n} theme`,opened:r,children:(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,"aria-label":`Switch to ${n} theme`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),onClick:()=>{i(!1),e(n)},children:t===`dark`?(0,A.jsx)(iT,{size:17,weight:`bold`}):(0,A.jsx)(Rw,{size:17,weight:`bold`})})})}function KT(){let e=(0,k.useRef)(null);return(0,k.useRef)({remember(t){e.current=t instanceof HTMLElement?t:null},restore(t){let n=e.current;requestAnimationFrame(()=>(n?.isConnected?n:t)?.focus())}}).current}var qT=`pitot:shortcuts`,JT=0,YT=new Set,XT=()=>{for(let e of YT)e()};function ZT(e){(0,k.useEffect)(()=>(window.addEventListener(qT,e),JT+=1,XT(),()=>{window.removeEventListener(qT,e),--JT,XT()}),[e])}function QT(){return(0,k.useSyncExternalStore)(e=>(YT.add(e),()=>YT.delete(e)),()=>JT>0,()=>!1)}function $T(){let e=QT(),t=(0,k.useRef)(null);return(0,A.jsxs)(Ot,{position:`bottom-end`,withinPortal:!0,shadow:`md`,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Bi,{label:`Help`,children:(0,A.jsx)(Ne,{ref:t,variant:`subtle`,color:`gray`,"aria-label":`Help`,children:(0,A.jsx)(Kw,{size:18,weight:`bold`})})})}),(0,A.jsxs)(Ot.Dropdown,{children:[(0,A.jsx)(Ot.Item,{component:`a`,href:Gt.home,target:`_blank`,rel:`noopener noreferrer`,leftSection:(0,A.jsx)(Ew,{size:15}),children:`Documentation`}),e&&(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Et,{size:15}),rightSection:(0,A.jsx)(Ei,{size:`xs`,children:`?`}),onClick:()=>{t.current?.focus(),window.dispatchEvent(new Event(qT))},children:`Keyboard shortcuts`})]})]})}var eE=new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}),tE=new Intl.NumberFormat(`en`,{maximumFractionDigits:2});function nE(e){return Math.abs(e)<1e-4?e.toExponential(2).replace(/\.?(0+)(?=e)/,``):String(Number(e.toPrecision(3)))}function rE(e,t=tE){return e!==0&&Math.abs(e)<1?nE(e):t.format(e)}function iE(e,t){let n=t===`s`?e*1e3:t===`ns`?e/1e6:e;return e!==0&&n===0?`${nE(e)} ${t}`:n!==0&&Math.abs(n)<1?`${nE(n)} ms`:Ut(n)}var aE=[`B`,`KiB`,`MiB`,`GiB`,`TiB`];function oE(e){let t=e,n=0;for(;Math.abs(t)>=1024&&n=1e4?eE:tE);default:return rE(t,Math.abs(t)>=1e4?eE:tE)}}var cE={ms:1,s:1e3,ns:1e-6},lE=[[36e5,`h`],[6e4,`m`],[1e3,`s`],[1,`ms`]];function uE(e,t){let n=e===void 0?void 0:cE[e];if(e===`bytes`&&t&&t.interval>0){let e=Math.max(Math.abs(t.min),Math.abs(t.max)),n=[4,3,2,1].find(n=>e>=1024**n&&Math.abs(t.interval/1024**n*100-Math.round(t.interval/1024**n*100))<1e-6)??0;return e=>Number.isFinite(e)?`${rE(e/1024**n)} ${aE[n]}`:`—`}if(e===`percent`&&t&&t.interval>0){let e=[0,1,2,3,4].find(e=>{let n=t.interval*10**e;return Math.round(n)!==0&&Math.abs(n-Math.round(n))<1e-6*Math.abs(n)});if(e!==void 0){let t=new Intl.NumberFormat(`en`,{minimumFractionDigits:e,maximumFractionDigits:e});return e=>Number.isFinite(e)?`${t.format(e)}%`:`—`}}if(n!==void 0&&t&&t.interval>0){let e=Math.max(Math.abs(t.min),Math.abs(t.max))*n,r=t.interval*n,[i,a]=lE.find(([t])=>e>=t&&Math.abs(r/t*100-Math.round(r/t*100))<1e-6)??[1,`ms`];return e=>Number.isFinite(e)?`${rE(e*n/i)} ${a}`:`—`}return t=>(!e||e===`count`)&&Math.abs(t)>=1e3?rE(t,eE):e===`ms`||e===`s`||e===`ns`?sE(e,t).replace(/(\.\d*?)0+([a-z]*)$/,`$1$2`).replace(/\.([a-z]*)$/,`$1`):sE(e,t)}function dE(e){return e!==void 0&&e!==`count`&&/[^\d\s]$/.test(uE(e)(1).trim())}function fE(e,t,n){return uE(e,n)(t??NaN).replace(/(?<=\d)(ms|ns|s|m|h)\b/g,` $1`)}function pE(e){return Math.max(3,Math.min(10,Math.round(e/70)))-1}function mE(e,t){let n=t===`ms`?1:t===`s`?1e3:t===`ns`?1e-6:void 0,r=e=>{let t=10**Math.floor(Math.log10(e));return[1,2,5,10].map(e=>e*t).find(t=>t>=e)};if(t===`bytes`){let t=Math.min(4,Math.max(0,Math.floor(Math.log(e)/Math.log(1024)))),n=r(Math.max(e/1024**t,+(t===0)));return(n>=1e3&&t<4?1024:n)*1024**t}if(n===void 0)return r(e);let i=e*n,a=[1,10,100,1e3,1e4,6e4,6e5,36e5,36e6].flatMap(e=>[1,2,5].map(t=>e*t)).sort((e,t)=>e-t);return(i<1?r(i):a.find(e=>e>=i)??r(i/36e5)*36e5)/n}function hE(e,t,n,r){e=Number.isFinite(e)?Math.min(0,e):0,t=Number.isFinite(t)?Math.max(0,t):1,t===e&&(t=e+1);let i=pE(r),a=mE(Math.max(t-e,2**-52)/i,n);for(let r=0;r<64&&Math.ceil(t/a)-Math.floor(e/a)>i;r++)a=mE(a*1.01,n);return{min:Math.floor(e/a)*a,max:Math.ceil(t/a)*a,interval:a,splitNumber:i,pitot_unit:n}}function gE(e,t){if(e.type!==`value`&&e.type!==`log`)return e;if(e.type!==`value`||typeof e.min!=`number`||typeof e.max!=`number`)return{...e,splitNumber:pE(t)};let n=typeof e.pitot_unit==`string`?e.pitot_unit:void 0,r=hE(e.min,e.max,n,t);return{...e,...r,...n&&(n in cE||n===`bytes`||n===`percent`)?{axisLabel:{...e.axisLabel,formatter:uE(n,r)}}:{}}}function _E(e,t,n){let r=e=>sE(n,e),i=``;if(n===`ms`||n===`s`||n===`ns`){let a=n===`s`?1e3:n===`ns`?1e-6:1,o=Math.abs((e??t??0)*a),s=o>=6e4?6e4:o>=1e3?1e3:1;i=s===6e4?` min`:s===1e3?` s`:` ms`;let c=s===6e4?1:s===1e3?+(o<1e4):2,l=new Intl.NumberFormat(void 0,{maximumFractionDigits:c});r=e=>l.format(e*a/s)}return t===null&&e!==null?`≥${r(e)}${i}`:(e===null||e===0)&&t!==null?`<${r(t)}${i}`:`${e===null?`−∞`:r(e)}–${t===null?`∞`:r(t)}${i}`}function vE(e){let t=new Date(e);return t.getHours()===0&&t.getMinutes()===0&&t.getSeconds()===0?t.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}function yE(e,t=new Date,n){let r=new Date(e);if(!Number.isFinite(r.getTime()))return`—`;let i=new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`,...r.getFullYear()===t.getFullYear()?{}:{year:`numeric`},hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(r),a=i.filter(e=>[`month`,`day`,`year`].includes(e.type)).map(e=>e.value),o=i.filter(e=>[`hour`,`minute`,`second`].includes(e.type)).map(e=>e.value);return`${a.join(` `)} ${o.join(`:`)}`}var bE=[{path:`/explore`,label:`Explore`,Icon:Aw},{path:`/logs`,label:`Logs`,Icon:Pw},{path:`/traces`,label:`Traces`,Icon:Bw},{path:`/alerts`,label:`Alerts`,Icon:ww},{path:`/settings`,label:`Settings`,Icon:Mw}];async function xE(e,t){let n=new URLSearchParams({page_size:`30`});e&&n.set(`q`,e),t&&n.set(`cursor`,t);let r=await Wt(`/api/agent/threads?${n}`);if(!r.ok)throw Error(`Unable to load chats (${r.status})`);return r.json()}function SE({collapsed:e=!1,agentAvailable:t,activeThreadID:n,activeDashboardID:r,activePath:i,autoFocusSearch:a=!1,onNewChat:o,onSelectThread:s,onDeletedThread:l,onSelectDashboard:d,onCreateDashboard:f,onNewDashboard:p,onNavigate:h,onInvestigateService:g,ref:_}){let v=Zt(),[y,b]=(0,k.useState)(``),[x]=er(y.trim(),250),[ee,S]=(0,k.useState)(null),[C,w]=(0,k.useState)(null),[ne,re]=(0,k.useState)(``),[ie,ae]=(0,k.useState)(``),[oe,se]=(0,k.useState)(!1),ce=(0,k.useRef)(null);(0,k.useImperativeHandle)(_,()=>({focusSearch:()=>ce.current?.focus()}),[]),(0,k.useEffect)(()=>{a&&requestAnimationFrame(()=>ce.current?.focus())},[a]);let le=iw({queryKey:[...aT,x],queryFn:({pageParam:e})=>xE(x,e),initialPageParam:``,getNextPageParam:e=>e.next_cursor??void 0,enabled:t}),ue=hn({queryKey:Pt,queryFn:It,refetchInterval:3e4,staleTime:Nt}),de=(0,k.useMemo)(()=>le.data?.pages.flatMap(e=>e.items)??[],[le.data]),pe=(0,k.useMemo)(()=>OE(de),[de]),T=hn({queryKey:[`telemetry-schema`,`1h`],queryFn:()=>oT(`/api/telemetry/schema?window=1h`),enabled:t&&!!x&&!!g,staleTime:6e4}),me=(0,k.useMemo)(()=>{if(!x)return[];let e=x.toLowerCase();return(T.data?.services??[]).map(e=>e.value).filter(t=>t.toLowerCase().includes(e)).slice(0,6)},[T.data,x]),he=(0,k.useMemo)(()=>{let e=ue.data??[],t=x.toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)):e},[ue.data,x]);function ge(e){ae(``),re(e.title),S(e)}async function _e(){if(ee&&ne.trim()){se(!0),ae(``);try{let e=await Wt(`/api/agent/threads/${encodeURIComponent(ee.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:ne.trim()})});if(!e.ok)throw Error(`Unable to rename chat (${e.status})`);await v.invalidateQueries({queryKey:aT}),S(null)}catch(e){ae(e instanceof Error?e.message:`Unable to rename this chat.`)}finally{se(!1)}}}async function ve(){if(C){se(!0),ae(``);try{let e=await Wt(`/api/agent/threads/${encodeURIComponent(C.id)}`,{method:`DELETE`});if(!e.ok)throw Error(`Unable to delete chat (${e.status})`);let t=C.id;w(null),await v.invalidateQueries({queryKey:aT}),await v.invalidateQueries({queryKey:Pt}),l(t)}catch(e){ae(e instanceof Error?e.message:`Unable to delete this chat.`)}finally{se(!1)}}}return e?(0,A.jsxs)(te,{gap:4,component:`nav`,"aria-label":`Navigation`,children:[t&&(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,size:46,"aria-label":`New chat`,title:`New chat`,onClick:o,children:(0,A.jsx)(Ww,{size:18})}),t&&(0,A.jsxs)(Ot,{position:`right-start`,withinPortal:!0,shadow:`md`,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,size:46,"aria-label":`Chats`,title:`Chats`,className:`rail-row`,"data-active":!!n||void 0,children:(0,A.jsx)(Ow,{size:18})})}),(0,A.jsxs)(Ot.Dropdown,{maw:280,children:[(0,A.jsx)(Ot.Label,{children:`Recent chats`}),le.isPending?(0,A.jsx)(Ot.Item,{disabled:!0,children:`Loading chats…`}):le.isError?(0,A.jsx)(Ot.Item,{onClick:()=>void le.refetch(),children:`Chats could not be loaded. Retry`}):de.length===0&&(0,A.jsx)(Ot.Item,{disabled:!0,children:`No chats yet`}),de.slice(0,10).map(e=>(0,A.jsx)(Ot.Item,{"aria-current":e.id===n?`page`:void 0,fw:e.id===n?600:void 0,onClick:()=>s(e.id),children:(0,A.jsx)(D,{size:`sm`,truncate:!0,children:e.title||`Untitled chat`})},e.id))]})]}),bE.map(({path:e,label:t,Icon:n})=>(0,A.jsx)(Ne,{component:`a`,href:e,title:t,"aria-label":t,"aria-current":i===e||i?.startsWith(`${e}/`)?`page`:void 0,className:`rail-row`,"data-active":i===e||i?.startsWith(`${e}/`)||void 0,variant:`subtle`,color:`gray`,size:46,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),h(e))},children:(0,A.jsx)(n,{size:18})},e)),(0,A.jsxs)(Ot,{position:`right-start`,withinPortal:!0,shadow:`md`,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,size:46,"aria-label":`Dashboards`,title:`Dashboards`,className:`rail-row`,"data-active":!!r||void 0,children:(0,A.jsx)(eT,{size:18})})}),(0,A.jsxs)(Ot.Dropdown,{maw:280,children:[(0,A.jsx)(Ot.Label,{children:`Dashboards`}),ue.isPending&&(0,A.jsx)(Ot.Item,{disabled:!0,children:`Loading dashboards…`}),ue.isError&&(0,A.jsx)(Ot.Item,{onClick:()=>void ue.refetch(),children:`Dashboards could not be loaded. Retry`}),(ue.data??[]).map(e=>(0,A.jsx)(Ot.Item,{"aria-current":e.id===r?`page`:void 0,fw:e.id===r?600:void 0,onClick:()=>d(e.id),children:(0,A.jsx)(D,{size:`sm`,truncate:!0,children:e.name})},e.id)),ue.data?.length?(0,A.jsx)(Ot.Divider,{}):null,(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Ww,{size:14}),onClick:p,children:`New dashboard`})]})]})]}):(0,A.jsxs)(te,{gap:`sm`,h:`100%`,component:`nav`,"aria-label":`Navigation`,children:[t&&(0,A.jsx)(we,{leftSection:(0,A.jsx)(Ww,{size:16,weight:`bold`}),onClick:o,children:`New chat`}),(0,A.jsx)(O,{type:`auto`,offsetScrollbars:!0,flex:1,mx:-4,px:4,children:(0,A.jsxs)(te,{gap:`lg`,pb:`sm`,children:[t&&(0,A.jsxs)(te,{gap:4,children:[(0,A.jsx)(CE,{children:`Chats`}),le.isLoading&&(0,A.jsx)(fe,{state:`loading`,rows:3}),le.isError&&(0,A.jsx)(fe,{state:`error`,error:{message:`Chats could not be loaded.`,onRetry:()=>void le.refetch()}}),!le.isLoading&&!le.isError&&de.length===0&&(0,A.jsx)(D,{size:`xs`,c:`dimmed`,px:`sm`,children:x?`No matching chats. Try another name.`:`No chats yet. Start one above.`}),pe.map(e=>(0,A.jsxs)(te,{gap:2,children:[pe.length>1&&(0,A.jsx)(D,{c:`dimmed`,size:`xs`,px:`sm`,pt:4,children:e.label}),e.threads.map(e=>(0,A.jsx)(wE,{thread:e,active:(i?i.startsWith(`/chat/`):!r)&&e.id===n,onSelect:()=>s(e.id),onRename:()=>ge(e),onDelete:()=>{ae(``),w(e)}},e.id))]},e.label)),le.hasNextPage&&(0,A.jsx)(we,{variant:`subtle`,color:`gray`,size:`compact-sm`,loading:le.isFetchingNextPage,onClick:()=>void le.fetchNextPage(),children:`See all`})]}),t&&x&&g&&T.isLoading&&(0,A.jsx)(fe,{state:`loading`,rows:3}),t&&x&&g&&(T.isSuccess||T.isError)&&(0,A.jsxs)(te,{gap:4,children:[(0,A.jsx)(CE,{children:`Services`}),T.isError&&(0,A.jsx)(D,{c:`dimmed`,size:`sm`,px:`sm`,children:`Services could not be searched`}),T.isSuccess&&me.length===0&&(0,A.jsx)(fe,{state:`empty`,variant:`inline`,empty:{title:`No matching services`,description:`Try a different service name.`,action:(0,A.jsx)(we,{variant:`subtle`,size:`compact-xs`,onClick:()=>b(``),children:`Clear search`})}}),me.map(e=>(0,A.jsx)(Ve,{className:`rail-row`,p:`sm`,onClick:()=>g(e),children:(0,A.jsx)(D,{size:`sm`,fw:500,truncate:!0,children:e})},e))]}),(0,A.jsx)(te,{gap:0,children:bE.map(({path:e,label:t,Icon:n})=>{let r=i===e;return(0,A.jsx)(Ve,{component:`a`,href:e,className:`rail-row`,"data-active":r||void 0,"aria-current":r?`page`:void 0,p:`sm`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),h(e))},children:(0,A.jsxs)(m,{gap:`xs`,wrap:`nowrap`,children:[(0,A.jsx)(n,{size:16}),(0,A.jsx)(D,{size:`sm`,fw:r?600:500,children:t})]})},e)})}),(0,A.jsxs)(te,{gap:4,children:[(0,A.jsx)(CE,{children:`Dashboards`}),ue.isLoading&&(0,A.jsx)(fe,{state:`loading`,rows:3}),ue.isError&&(0,A.jsx)(Le,{tone:`danger`,children:`Dashboards could not be loaded.`}),!ue.isLoading&&!ue.isError&&x&&he.length===0&&(0,A.jsx)(fe,{state:`empty`,variant:`inline`,empty:{title:`No matching dashboards`,description:`Try a different dashboard name.`,action:(0,A.jsx)(we,{variant:`subtle`,size:`compact-xs`,onClick:()=>b(``),children:`Clear search`})}}),he.map(e=>{let n=(!i||i.startsWith(`/dashboards`))&&e.id===r;return(0,A.jsxs)(te,{gap:0,children:[(0,A.jsx)(Ve,{component:`a`,href:`/dashboards/${encodeURIComponent(e.id)}`,className:`rail-row`,"data-active":n||void 0,"aria-current":n?`page`:void 0,p:`sm`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),d(e.id))},children:(0,A.jsxs)(m,{justify:`space-between`,gap:`sm`,wrap:`nowrap`,children:[(0,A.jsxs)(m,{gap:`xs`,wrap:`nowrap`,style:{minWidth:0,flex:1},children:[(0,A.jsx)(eT,{size:16,style:{flexShrink:0}}),(0,A.jsx)(D,{size:`sm`,fw:n?600:500,truncate:!0,title:e.name,children:e.name})]}),e.is_default&&(0,A.jsx)(Bi,{label:`Default`,children:(0,A.jsx)(c,{size:16,variant:`light`,color:`gray`,role:`img`,"aria-label":`Default`,style:{flexShrink:0},children:(0,A.jsx)(nT,{size:12,weight:`fill`,"aria-hidden":`true`})})})]})}),t&&e.origin&&(0,A.jsx)(Ve,{component:`a`,href:`/chat/${encodeURIComponent(e.origin.thread_id)}`,"data-request-provenance":!0,px:`sm`,pb:`xs`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),s(e.origin.thread_id))},children:(0,A.jsxs)(D,{size:`xs`,c:`dimmed`,lineClamp:2,title:`Built from: ${e.origin.request_excerpt}`,children:[`Built from: `,e.origin.request_excerpt]})})]},e.id)}),(0,A.jsx)(we,{variant:`subtle`,color:`gray`,size:`sm`,px:`sm`,justify:`flex-start`,leftSection:(0,A.jsx)(Ww,{size:14}),onClick:p,children:`New dashboard`}),t&&(0,A.jsx)(we,{variant:`subtle`,color:`gray`,size:`sm`,px:`sm`,justify:`flex-start`,leftSection:(0,A.jsx)(Qw,{size:14,weight:`fill`}),onClick:f,children:`Create with AI`})]})]})}),(0,A.jsx)(Ge,{ref:ce,value:y,onChange:e=>b(e.currentTarget.value),leftSection:(0,A.jsx)(Iw,{size:15}),rightSection:(0,A.jsx)(Ei,{size:`xs`,children:`⌘K`}),rightSectionWidth:44,placeholder:`Search`,"aria-label":`Search chats, dashboards and services`,size:`sm`}),(0,A.jsx)(u,{opened:ee!==null,onClose:()=>!oe&&S(null),title:`Rename chat`,centered:!0,children:(0,A.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),_e()},children:(0,A.jsxs)(te,{children:[(0,A.jsx)(Ge,{label:`Name`,value:ne,onChange:e=>re(e.currentTarget.value),maxLength:120,autoFocus:!0}),ie&&(0,A.jsx)(Le,{tone:`danger`,children:ie}),(0,A.jsxs)(m,{justify:`flex-end`,children:[(0,A.jsx)(we,{variant:`default`,onClick:()=>S(null),disabled:oe,children:`Cancel`}),(0,A.jsx)(we,{type:`submit`,loading:oe,disabled:!ne.trim(),children:`Save`})]})]})})}),(0,A.jsxs)(He,{opened:C!==null,onClose:()=>w(null),title:`Delete chat?`,confirmLabel:`Delete chat`,tone:`danger`,pending:oe?`confirm`:null,error:ie||void 0,onConfirm:()=>void ve(),children:[`This permanently removes `,(0,A.jsx)(D,{span:!0,ff:`monospace`,children:C?.title}),` and its saved messages.`]})]})}function CE({children:e}){return(0,A.jsx)(D,{c:`dimmed`,size:`xs`,fw:700,tt:`uppercase`,lts:`0.08em`,px:`sm`,children:e})}function wE({thread:e,active:t,onSelect:n,onRename:r,onDelete:i}){return(0,A.jsx)(w,{"data-active":t||void 0,className:`rail-row`,children:(0,A.jsxs)(m,{gap:2,wrap:`nowrap`,children:[(0,A.jsx)(Ve,{onClick:n,"aria-current":t?`page`:void 0,p:`sm`,flex:1,style:{minWidth:0},children:(0,A.jsxs)(te,{gap:0,pl:24,style:{position:`relative`},children:[(0,A.jsx)(Ow,{size:16,style:{position:`absolute`,left:0,top:2}}),(0,A.jsx)(D,{size:`sm`,fw:t?600:500,truncate:!0,title:e.title,children:e.title}),(0,A.jsx)(D,{c:`dimmed`,size:`xs`,ff:`monospace`,children:kE(e.updated_at)})]})}),(0,A.jsxs)(Ot,{position:`bottom-end`,withinPortal:!0,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Ne,{className:`rail-row-actions`,variant:`subtle`,color:`gray`,size:`sm`,mr:4,"aria-label":`Actions for ${e.title}`,children:(0,A.jsx)(jt,{size:18,weight:`bold`})})}),(0,A.jsxs)(Ot.Dropdown,{children:[(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Ct,{size:15}),onClick:r,children:`Rename`}),(0,A.jsx)(Ot.Item,{color:`bad`,leftSection:(0,A.jsx)(ht,{size:15}),onClick:i,children:`Delete`})]})]})]})})}function TE(e){return e.includes(`T`)?new Date(e):new Date(`${e.replace(` `,`T`)}Z`)}function EE(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}var DE=[`Today`,`Yesterday`,`Previous 7 days`,`Older`];function OE(e){let t=EE(new Date),n=new Map;for(let r of e){let e=Math.floor((t-EE(TE(r.updated_at)))/864e5),i=e<=0?`Today`:e===1?`Yesterday`:e<=7?`Previous 7 days`:`Older`,a=n.get(i)??[];a.push(r),n.set(i,a)}return DE.filter(e=>n.has(e)).map(e=>({label:e,threads:n.get(e)}))}function kE(e){return yE(TE(e).valueOf())}var AE=(0,k.lazy)(()=>st(()=>import(`./new-dashboard-D58ui2mw.js`).then(e=>({default:e.NewDashboard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])));function jE({children:e}){let{agentAvailable:t,threadID:n,threadMissing:r,newThread:i,selectThread:a,openChat:o}=OT(),s=$e(),c=Qn({select:e=>e.location.pathname}),{dashboardId:l}=ut({strict:!1}),u=c===`/chat`||c.startsWith(`/chat/`),[d,f]=tr(!1),[p,h]=(0,k.useState)(!1),[g,_]=(0,k.useState)(!1),[v,y]=(0,k.useState)(``),[b,x]=(0,k.useState)(!1),ee=(0,k.useRef)(null),S=(0,k.useRef)(null),C=KT(),te=he(`(max-width: 62em)`),ne=he(`(max-width: 48em)`),re=(0,k.useRef)(te),ie=()=>{te?(_(!0),f.open()):(h(!1),requestAnimationFrame(()=>ee.current?.focusSearch()))};re.current=te,(0,k.useEffect)(()=>{f.close()},[c]),(0,k.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),re.current?(_(!0),f.open()):(h(!1),requestAnimationFrame(()=>ee.current?.focusSearch())))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let ae={agentAvailable:t,activeThreadID:u&&!r&&c!==`/chat`?n:void 0,activeDashboardID:l,activePath:c,onNewChat:i,onSelectThread:a,onDeletedThread:e=>{e===n&&i()},onSelectDashboard:e=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:e},search:{}}),onCreateDashboard:()=>o(kT),onNewDashboard:()=>{C.remember(re.current?S.current:document.activeElement),f.close(),x(!0)},onNavigate:e=>void s({to:e}),onInvestigateService:e=>o(`Investigate the ${e} service. Explain its errors and latency.`)},oe=()=>{x(!1),C.restore()};return(0,A.jsxs)(li,{header:{height:56},navbar:{width:p?56:248,breakpoint:`md`,collapsed:{mobile:!0}},padding:0,children:[(0,A.jsx)(`a`,{className:`skip-link`,href:`#main`,children:`Skip to content`}),(0,A.jsx)(li.Header,{children:(0,A.jsxs)(m,{h:`100%`,px:{base:`sm`,sm:`md`},justify:`space-between`,wrap:`nowrap`,children:[(0,A.jsxs)(m,{gap:`sm`,wrap:`nowrap`,children:[(0,A.jsx)(Ci,{ref:S,hiddenFrom:`md`,opened:d,"aria-expanded":d,onClick:()=>{_(!1),f.toggle()},size:`sm`,"aria-label":d?`Close navigation`:`Open navigation`}),(0,A.jsx)(Ne,{visibleFrom:`md`,variant:`subtle`,color:`gray`,"aria-label":p?`Expand navigation`:`Collapse navigation`,"aria-expanded":!p,onClick:()=>h(e=>!e),children:(0,A.jsx)(Jw,{size:18})}),(0,A.jsx)(Be,{size:`small`})]}),ne?(0,A.jsx)(Ne,{variant:`default`,size:`lg`,"aria-label":`Search`,onClick:ie,children:(0,A.jsx)(Iw,{size:16})}):(0,A.jsx)(we,{variant:`default`,color:`gray`,leftSection:(0,A.jsx)(Iw,{size:16}),onClick:ie,children:`Search · ⌘K`}),(0,A.jsx)(w,{id:`shell-time-range`,visibleFrom:`sm`}),(0,A.jsxs)(m,{gap:`xs`,wrap:`nowrap`,children:[(0,A.jsx)($T,{}),(0,A.jsx)(GT,{}),(0,A.jsx)(ME,{onError:y})]})]})}),(0,A.jsx)(li.Navbar,{p:p?4:`sm`,children:(0,A.jsx)(SE,{ref:ee,...ae,collapsed:p})}),(0,A.jsx)(gt,{opened:d,onClose:f.close,returnFocus:!b,hiddenFrom:`md`,size:288,padding:`sm`,title:(0,A.jsx)(Be,{size:`small`}),overlayProps:{backgroundOpacity:.24,blur:1},children:(0,A.jsx)(SE,{...ae,autoFocusSearch:d&&g})}),(0,A.jsxs)(li.Main,{id:`main`,tabIndex:-1,children:[v&&(0,A.jsx)(Le,{tone:`danger`,onDismiss:()=>y(``),children:v}),e]}),b&&(0,A.jsx)(k.Suspense,{fallback:null,children:(0,A.jsx)(AE,{onClose:oe,onCreated:e=>{x(!1),s({to:`/dashboards/$dashboardId`,params:{dashboardId:e},search:{}})}})})]})}function ME({onError:e}){let t=$e(),n=Jt(),r=(n.display_name.trim()||n.email.trim()||`?`).charAt(0).toUpperCase();return(0,A.jsxs)(Ot,{position:`bottom-end`,withinPortal:!0,shadow:`md`,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,size:`lg`,radius:`xl`,"aria-label":`${r} account menu`,children:(0,A.jsx)(bi,{size:26,radius:`xl`,color:`gray`,children:r})})}),(0,A.jsxs)(Ot.Dropdown,{children:[(0,A.jsx)(Ot.Label,{children:n.email||`Signed in`}),(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Hw,{size:15}),onClick:()=>void t({to:`/settings`}),children:`Connect telemetry`}),(0,A.jsx)(Ot.Divider,{}),(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Xw,{size:15}),onClick:()=>void qt().catch(t=>e(t instanceof Error?t.message:`Sign-out failed — your session is still active.`)),children:`Sign out`})]})]})}function NE(){let{agent_available:e}=Kt(),t=$e(),n=Zt(),{threadId:r}=ut({strict:!1}),[i,a]=(0,k.useState)(WT),o=(0,k.useRef)(new Set),s=r??i,[c,l]=(0,k.useState)([]),[u,d]=(0,k.useState)({}),[f,p]=(0,k.useState)(``),[m,h]=(0,k.useState)(!1),[g,_]=(0,k.useState)(!1),[v,y]=(0,k.useState)(``),[b,x]=(0,k.useState)(!1),ee=(0,k.useRef)(!1),[S,C]=(0,k.useState)(``),[te,w]=(0,k.useState)(``),[ne,re]=(0,k.useState)(0),ie=(0,k.useRef)(null),ae=(0,k.useRef)({}),oe=(0,k.useRef)(null),se=(0,k.useRef)(new Map),ce=(0,k.useMemo)(()=>new XC({url:`/api/agent/runs`,threadId:s,fetch:(e,t)=>Wt(e,t)}),[s]),le=!e||f===s;function ue(){se.current.clear(),y(``)}function de(e){return ee.current||e instanceof Error&&e.name===`AbortError`}(0,k.useEffect)(()=>{let t=!0;if(l([]),ae.current={},d({}),p(``),h(!1),_(!1),ee.current=!1,x(!1),ue(),w(``),!e){p(s);return}!r||o.current.has(s)?(ce.setMessages([]),p(s)):Wt(`/api/agent/threads/${encodeURIComponent(s)}`).then(async e=>{if(e.status===404)return null;if(!e.ok)throw Error(`Unable to load thread (${e.status})`);return e.json()}).then(e=>{if(t){if(e===null){h(!0),p(s);return}ce.setMessages(e.messages??[]),l(e.messages??[]),p(s)}}).catch(()=>{t&&(ie.current=null,w(`This chat could not be restored. Start a new chat or try again.`))});let i=ce.subscribe({onMessagesChanged:({messages:e})=>l([...e]),onRunInitialized:()=>{ee.current=!1,x(!1),_(!0),w(``)},onTextMessageContentEvent:({event:e})=>{e.delta&&y(``)},onToolCallStartEvent:({event:e})=>{se.current.set(e.toolCallId,jT(e.toolCallName)),y(jT(e.toolCallName))},onToolCallResultEvent:({event:e,messages:t})=>{se.current.delete(e.toolCallId),y([...se.current.values()].at(-1)??`Analyzing your system`);let r=mT(e.toolCallId,e.content,t);r&&(n.invalidateQueries({queryKey:Pt}),n.invalidateQueries({queryKey:[`dashboard`,r.id]}),n.invalidateQueries({queryKey:[`dashboard-versions`,r.id]}))},onRunErrorEvent:({event:e})=>{e.code===`abort`||ee.current?(w(``),x(!0)):(console.warn(`Agent run error`,e.code),w(NT(e.code))),_(!1),ue()},onRunFinalized:({messages:e})=>{let t=[...e];l(t),d(e=>{let n={...e};for(let e of t)e.role===`assistant`&&!n[e.id]&&(n[e.id]=Date.now());return n}),_(!1),ue(),o.current.delete(s),n.invalidateQueries({queryKey:aT})},onRunFailed:e=>{de(e.error)?(w(``),x(!0)):(console.error(`Agent run failed`,e),w(NT())),_(!1),ue(),o.current.delete(s),n.invalidateQueries({queryKey:aT})}});return()=>{t=!1,i.unsubscribe(),ce.abortRun()}},[ce,e,n,ne,s]),(0,k.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target,i=n?.matches(`input, textarea, [contenteditable='true']`);e.key===`/`&&!i&&(e.preventDefault(),r?requestAnimationFrame(()=>oe.current?.focus()):t({to:`/chat`}).then(()=>requestAnimationFrame(()=>oe.current?.focus()))),e.key===`Escape`&&n===oe.current&&(C(``),oe.current?.blur())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t,r]);async function fe(){_(!0),w(``);try{let{context:e=[],...t}=ae.current;await ce.runAgent({context:e,forwardedProps:t})}catch(e){de(e)?(w(``),x(!0)):(console.error(`Agent run failed`,e),w(NT())),_(!1),ue(),o.current.delete(s)}}async function pe(n,i){let a=n.trim();if(!e||!a||g||!le||m)return;ae.current={...i},r||(o.current.add(s),t({to:`/chat/$threadId`,params:{threadId:s},replace:!0}));let c={id:WT(),role:`user`,content:a};ce.addMessage(c),l([...ce.messages]),d(e=>({...e,[c.id]:Date.now()})),C(``),await fe()}(0,k.useEffect)(()=>{let e=ie.current;le&&r&&e&&(ie.current=null,pe(e.text,e.options))},[le,r,s]);function T(e){e.preventDefault(),pe(S)}function me(){ee.current=!0,w(``),x(!0),ce.abortRun(),_(!1),ue(),o.current.delete(s)}function he(){!g&&ce.messages.some(e=>e.role===`user`)&&fe()}function ge(n,r){if(!e)return;let i=WT();o.current.add(i),ie.current=n?{text:n,options:{...r}}:null,t({to:`/chat/$threadId`,params:{threadId:i}})}function _e(){ce.abortRun(),ie.current=null,ae.current={},a(WT()),t({to:`/chat`})}function ve(e){ie.current=null,ae.current={},t({to:`/chat/$threadId`,params:{threadId:e}})}function ye(){re(e=>e+1)}return(0,A.jsx)(DT.Provider,{value:{agentAvailable:e,threadID:s,threadMissing:m,messages:c,messageTimes:u,ready:le,running:g,activity:v,stopped:b,input:S,setInput:C,error:te,inputRef:oe,send:pe,submit:T,stop:me,retry:he,reloadThread:ye,openChat:ge,newThread:_e,selectThread:ve},children:(0,A.jsx)(jE,{children:(0,A.jsx)(Hn,{})})})}function PE(){let e=(0,k.useMemo)(()=>new rw,[]);return(0,A.jsx)(vn,{client:e,children:(0,A.jsx)(Yt,{children:(0,A.jsx)(NE,{})})})}var FE=ft({component:PE,notFoundComponent:()=>(0,A.jsx)(et,{to:`/`,replace:!0})}),IE=dt(`/`)({component:pt(()=>st(()=>import(`./routes-D2AdaqvY.js`),__vite__mapDeps([21,1,7])),`component`)}),LE=dt(`/alerts`)({component:pt(()=>st(()=>import(`./alerts-CYKuszTJ.js`),__vite__mapDeps([22,1,2,7,3,4,5,6,17,13,14,23,8,24,18,16,20])),`component`)}),RE=dt(`/explore`)({component:pt(()=>st(()=>import(`./explore-D4KpDh3K.js`),__vite__mapDeps([25,1,7,18,3,2,4,5,6,9,10,11,12,13,14,8,15,16,17,19])),`component`),validateSearch:e=>bn(xn(e))}),zE=dt(`/logs`)({component:pt(()=>st(()=>import(`./logs-DQVfH3k6.js`),__vite__mapDeps([26,1,7,18,3,2,4,5,6,27,10,11,12,13,14,8,15,16,17,19])),`component`),validateSearch:e=>bn(xn(e))}),BE=dt(`/settings`)({component:pt(()=>st(()=>import(`./settings-_0QC4d6a.js`),__vite__mapDeps([28,29,1,2,12,6,7,8,24,16])),`component`)}),VE=dt(`/traces`)({component:pt(()=>st(()=>import(`./traces-DQY6WBcG.js`),__vite__mapDeps([30,1,7,18,3,2,4,5,6,27,10,11,12,13,14,8,15,16,17,19])),`component`),validateSearch:e=>bn(xn(e))}),HE=dt(`/chat/`)({component:pt(()=>st(()=>import(`./chat.index-D5uvUdcn.js`),__vite__mapDeps([31,32,1,2,33,13,5,23,15,34])),`component`)}),UE=dt(`/chat/$threadId`)({component:pt(()=>st(()=>import(`./chat._threadId-D5uvUdcn.js`),__vite__mapDeps([35,32,1,2,33,13,5,23,15,34])),`component`)}),WE=dt(`/dashboards/`)({component:pt(()=>st(()=>import(`./dashboards.index-N7UkPeK5.js`),__vite__mapDeps([36,1,7,3,2,4,5,6,37,33,11,10,12,13,14,8,15,16,24,34])),`component`),validateSearch:e=>Ft(At(e))}),GE=dt(`/dashboards/$dashboardId`)({component:pt(()=>st(()=>import(`./dashboards._dashboardId-C_KLDd8s.js`),__vite__mapDeps([38,1,7,3,2,4,5,6,37,33,11,10,12,13,14,8,15,16,24,34])),`component`),validateSearch:e=>Ft(At(e))}),KE=dt(`/settings_/ingest`)({component:pt(()=>st(()=>import(`./settings_.ingest-7LDcHtKJ.js`),__vite__mapDeps([39,29,1,2,12,6,7,8,24,16])),`component`)}),qE=IE.update({id:`/`,path:`/`,getParentRoute:()=>FE}),JE=LE.update({id:`/alerts`,path:`/alerts`,getParentRoute:()=>FE}),YE=RE.update({id:`/explore`,path:`/explore`,getParentRoute:()=>FE}),XE=zE.update({id:`/logs`,path:`/logs`,getParentRoute:()=>FE}),ZE=BE.update({id:`/settings`,path:`/settings`,getParentRoute:()=>FE}),QE=VE.update({id:`/traces`,path:`/traces`,getParentRoute:()=>FE}),$E=HE.update({id:`/chat/`,path:`/chat/`,getParentRoute:()=>FE}),eD=UE.update({id:`/chat/$threadId`,path:`/chat/$threadId`,getParentRoute:()=>FE}),tD=WE.update({id:`/dashboards/`,path:`/dashboards/`,getParentRoute:()=>FE}),nD={IndexRoute:qE,AlertsRoute:JE,ExploreRoute:YE,LogsRoute:XE,SettingsRoute:ZE,TracesRoute:QE,ChatThreadIdRoute:eD,DashboardsDashboardIdRoute:GE.update({id:`/dashboards/$dashboardId`,path:`/dashboards/$dashboardId`,getParentRoute:()=>FE}),SettingsIngestRoute:KE.update({id:`/settings_/ingest`,path:`/settings/ingest`,getParentRoute:()=>FE}),ChatIndexRoute:$E,DashboardsIndexRoute:tD},rD=Jn({routeTree:FE._addFileChildren(nD)._addFileTypes(),parseSearch:kt,stringifySearch:Mt,defaultPreload:`intent`,scrollRestoration:!0});(0,Ji.createRoot)(document.getElementById(`root`)).render((0,A.jsx)(k.StrictMode,{children:(0,A.jsx)(xr,{theme:Tt,defaultColorScheme:`auto`,cssVariablesResolver:St,children:(0,A.jsx)(Zn,{router:rD})})}));export{Og as $,$C as A,Ag as B,wT as C,cT as D,sT as E,_g as F,G,Mg as H,hg as I,Eg as J,Sg as K,W as L,Rh as M,lg as N,oT as O,Ig as P,H as Q,wg as R,vT as S,lT as T,o_ as U,Uh as V,K as W,d_ as X,Vg as Y,Pg as Z,KT as _,RE as a,up as at,PT as b,_E as c,Bi as ct,yE as d,bg as et,sE as f,ZT as g,pE as h,zE as i,mp as it,zh as j,Ww as k,fE as l,Ei as lt,hE as m,WE as n,Sh as nt,gE as o,lp as ot,dE as p,ug as q,VE as r,gh as rt,uE as s,Xc as st,GE as t,qh as tt,vE as u,cr as ut,kT as v,bT as w,OT as x,MT as y,pg as z}; \ No newline at end of file +`)};function SS(e,t){return ta(t)&&CS(`[ag-ui][legacy] The result of tool call '${e}' carries content parts the legacy protocol cannot represent; only its text parts are bridged and the rest is dropped.`),ea(t)}var CS=e=>{typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(e)},wS=(e,t,n)=>r=>{let i={},a=!0,o=!0,s=``,c=null,l=null,u=[],d={},f=!1,p=e=>{typeof e==`object`&&e&&(`messages`in e&&delete e.messages,i=e)};return r.pipe(Ss(r=>{switch(r.type){case j.TEXT_MESSAGE_START:{let e=r;return[{type:bS.TextMessageStart,messageId:e.messageId,role:e.role}]}case j.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:bS.TextMessageContent,messageId:e.messageId,content:e.delta}]}case j.TEXT_MESSAGE_END:{let e=r;return[{type:bS.TextMessageEnd,messageId:e.messageId}]}case j.TOOL_CALL_START:{let e=r;return u.push({id:e.toolCallId,type:`function`,function:{name:e.toolCallName,arguments:``}}),o=!0,d[e.toolCallId]=e.toolCallName,[{type:bS.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case j.TOOL_CALL_ARGS:{let c=r,d=u.find(e=>e.id===c.toolCallId);if(!d)return CS(`[ag-ui][legacy] TOOL_CALL_ARGS: No tool call found with ID '${c.toolCallId}'`),[];d.function.arguments+=c.delta;let f=!1;if(l){let e=l.find(e=>e.tool==d.function.name);if(e)try{let t=JSON.parse(Ls(d.function.arguments));e.tool_argument&&e.tool_argument in t?(p({...i,[e.state_key]:t[e.tool_argument]}),f=!0):e.tool_argument||(p({...i,[e.state_key]:t}),f=!0)}catch{}}return[{type:bS.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...f?[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case j.TOOL_CALL_END:{let e=r;return[{type:bS.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case j.TOOL_CALL_RESULT:{let e=r,t=d[e.toolCallId];return(t===void 0||t===``)&&CS(`[ag-ui][legacy] No usable tool name was seen for tool call '${e.toolCallId}' (${t===void 0?`no TOOL_CALL_START reached this bridge`:`its TOOL_CALL_START carried an empty toolCallName`}), so its result is being bridged with the fabricated action name "unknown". Downstream consumers route on that name.`),[{type:bS.ActionExecutionResult,actionExecutionId:e.toolCallId,result:SS(e.toolCallId,e.content),actionName:t||`unknown`}]}case j.RAW:return f||(f=!0,CS(`[ag-ui][legacy] Dropping RAW events: the legacy runtime protocol has no equivalent, so the provider payloads they carry do not reach the legacy stream. Reported once per stream.`)),[];case j.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value}return[{type:bS.MetaEvent,name:e.name,value:e.value}]}case j.STATE_SNAPSHOT:return p(r.snapshot),[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case j.STATE_DELTA:{let c=r,l;try{l=Ia.applyPatch(i,c.delta,!0,!1).newDocument}catch(e){let t=e instanceof Error?e.message:String(e);return CS(`[ag-ui][legacy] Failed to apply state patch:\nCurrent state: ${JSON.stringify(i,null,2)}\nPatch operations: ${JSON.stringify(c.delta,null,2)}\nError: ${t}`),[]}return p(l),[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]}case j.MESSAGES_SNAPSHOT:return c=r.messages,[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:c}:{}}),active:!0}];case j.RUN_STARTED:return[];case j.RUN_FINISHED:{if(c&&(i.messages=c),Object.keys(i).length===0)return[];let r=null;if(c)try{r=TS(c)}catch(e){return[{type:bS.RunError,message:e.message}]}return[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...r?{messages:r}:{}}),active:!1}]}case j.RUN_ERROR:{let e=r;return[{type:bS.RunError,message:e.message,code:e.code}]}case j.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case j.STEP_FINISHED:return u=[],l=null,[{type:bS.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function TS(e){let t=[];for(let n of e)if(n.role===`assistant`||n.role===`user`||n.role===`system`){let e=xS(n.content);if(e){let r={id:n.id,role:n.role,content:e};t.push(r)}if(n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0)for(let e of n.toolCalls){let r;try{r=JSON.parse(e.function.arguments)}catch(t){throw Error(`Failed to parse arguments for tool call '${e.id}' (${e.function.name}): ${t.message}`)}let i={id:e.id,name:e.function.name,arguments:r,parentMessageId:n.id};t.push(i)}}else if(n.role===`tool`){let r=`unknown`;for(let t of e)if(t.role===`assistant`&&t.toolCalls?.length){for(let e of t.toolCalls)if(e.id===n.toolCallId){r=e.function.name;break}}let i={id:n.id,result:SS(n.toolCallId,n.content),actionExecutionId:n.toolCallId,actionName:r};t.push(i)}return t}var ES=e=>e.kind===`tool`?e.fields.toolCallId:e.fields.messageId,DS=e=>e===`tool`?`toolCallId`:`messageId`,OS=(e,t,n,r,i)=>{if(r!==void 0&&r!==i)throw Error(`Cannot continue ${e} '${t}': chunk ${n} '${r}' does not match the open stream's ${n} ${i===void 0?`(absent)`:`'${i}'`}.`)},kS=(e,t)=>t.metadata===void 0?e:{...e,metadata:t.metadata},AS=(e,t)=>{let n=kS(e,t);return t.rawEvent===void 0?n:{...n,rawEvent:t.rawEvent}},jS=e=>new Set(Object.keys(e.shape)),MS=jS(__),NS=jS(x_),PS=jS(iv),FS=(e,t)=>{let n;for(let r of Object.keys(e))t.has(r)||((n??={})[r]=e[r]);return n},IS=e=>{typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][transform] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)},LS=(e,t,n,r)=>{if(t===void 0||n||e.length===0)return;let i=e[e.length-1],a=Object.keys(t).filter(e=>Object.prototype.hasOwnProperty.call(i,e));a.length>0&&IS(`A ${r} carried ${a.map(e=>`'${e}'`).join(`, `)}, which the synthesized ${String(i.type)} already describes. The synthesized value is kept and the chunk's is dropped — this stage does not judge a described field, so the producer's value cannot be substituted for its own.`),e[e.length-1]={...t,...i}},RS=e=>t=>{let n=Qx(e),r=new Map,i=e=>{let t=r.get(e);if(!t)return[];switch(r.delete(e),t.kind){case`text`:{let e={type:j.TEXT_MESSAGE_END,messageId:t.fields.messageId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`TEXT_MESSAGE_END`,e,{messageId:e.messageId}),[e]}case`tool`:{let e={type:j.TOOL_CALL_END,toolCallId:t.fields.toolCallId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`TOOL_CALL_END`,e,{toolCallId:e.toolCallId}),[e]}case`reasoning`:{let e={type:j.REASONING_MESSAGE_END,messageId:t.fields.messageId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`REASONING_MESSAGE_END`,e,{messageId:e.messageId}),[e]}}},a=()=>[...r.keys()].flatMap(e=>i(e)),o=(e,t)=>{for(let[n,i]of r)if(i.kind===e&&ES(i)===t)return{owner:n}},s=(e,t,n,i,a)=>{if(t!==void 0){let r=o(e,t);if(r){if(n!==void 0&&n!==r.owner)throw Error(`Cannot continue ${a} '${t}': chunk subagentRunId '${n}' does not match the open stream's subagent '${r.owner??`(the parent agent)`}'.`);return r.owner}return n}if(n!==void 0)return n;if(r.get(void 0)?.kind===e)return;let s=[...r.entries()].filter(([,t])=>t.kind===e);if(s.length===1)return s[0][0];if(s.length>1)throw Error(`Ambiguous ${i}: it carries neither a ${DS(e)} nor a subagentRunId, but ${s.length} lanes have an open ${a}. Attribute the chunk to the subagent it belongs to.`)};return t.pipe(Ss(e=>{switch(e.type){case j.TEXT_MESSAGE_START:case j.TEXT_MESSAGE_CONTENT:case j.TEXT_MESSAGE_END:case j.TOOL_CALL_START:case j.TOOL_CALL_ARGS:case j.TOOL_CALL_END:case j.TOOL_CALL_RESULT:case j.STATE_SNAPSHOT:case j.STATE_DELTA:case j.CUSTOM:case j.STEP_STARTED:case j.STEP_FINISHED:case j.REASONING_START:case j.REASONING_MESSAGE_START:case j.REASONING_MESSAGE_CONTENT:case j.REASONING_MESSAGE_END:case j.REASONING_END:return[...i(e.subagentRunId??void 0),e];case j.RUN_STARTED:case j.RUN_FINISHED:case j.RUN_ERROR:case j.MESSAGES_SNAPSHOT:return[...a(),e];case j.RAW:case j.ACTIVITY_SNAPSHOT:case j.ACTIVITY_DELTA:case j.REASONING_ENCRYPTED_VALUE:case j.SUBAGENT_STARTED:return[e];case j.SUBAGENT_FINISHED:case j.SUBAGENT_ERROR:{let t=e.subagentRunId;return t==null?[e]:[...i(t),e]}case j.TEXT_MESSAGE_CHUNK:{let t=e,a=FS(e,MS),o=s(`text`,t.messageId,t.subagentRunId??void 0,`TEXT_MESSAGE_CHUNK`,`text message`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`text`&&(t.messageId===void 0||t.messageId===c.fields.messageId))OS(`text message`,c.fields.messageId,`role`,t.role,c.fields.role),OS(`text message`,c.fields.messageId,`name`,t.name,c.fields.name),d=c.fields;else{if(l.push(...i(o)),t.messageId===void 0)throw Error(`First TEXT_MESSAGE_CHUNK must have a messageId`);d={messageId:t.messageId,role:t.role===void 0?`assistant`:t.role,name:t.name,subagentRunId:t.subagentRunId},r.set(o,{kind:`text`,fields:d});let e=kS({type:j.TEXT_MESSAGE_START,messageId:t.messageId,role:d.role,...t.name!==void 0&&{name:t.name},...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=AS({...a,type:j.TEXT_MESSAGE_CONTENT,messageId:d.messageId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`TEXT_MESSAGE_CONTENT`,r,{messageId:d.messageId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:j.TEXT_MESSAGE_CONTENT,messageId:d.messageId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return LS(l,a,u,`TEXT_MESSAGE_CHUNK`),l}case j.TOOL_CALL_CHUNK:{let t=e,a=FS(e,NS),o=s(`tool`,t.toolCallId,t.subagentRunId??void 0,`TOOL_CALL_CHUNK`,`tool call`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`tool`&&(t.toolCallId===void 0||t.toolCallId===c.fields.toolCallId))OS(`tool call`,c.fields.toolCallId,`toolCallName`,t.toolCallName,c.fields.toolCallName),OS(`tool call`,c.fields.toolCallId,`parentMessageId`,t.parentMessageId,c.fields.parentMessageId),d=c.fields;else{if(l.push(...i(o)),t.toolCallId===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallId`);if(t.toolCallName===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallName`);d={toolCallId:t.toolCallId,toolCallName:t.toolCallName,parentMessageId:t.parentMessageId,subagentRunId:t.subagentRunId},r.set(o,{kind:`tool`,fields:d});let e=kS({type:j.TOOL_CALL_START,toolCallId:t.toolCallId,toolCallName:t.toolCallName,...t.parentMessageId!==void 0&&{parentMessageId:t.parentMessageId},...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_START`,e,{toolCallId:t.toolCallId,toolCallName:t.toolCallName})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=AS({...a,type:j.TOOL_CALL_ARGS,toolCallId:d.toolCallId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`TOOL_CALL_ARGS`,r,{toolCallId:d.toolCallId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:j.TOOL_CALL_ARGS,toolCallId:d.toolCallId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return LS(l,a,u,`TOOL_CALL_CHUNK`),l}case j.REASONING_MESSAGE_CHUNK:{let t=e,a=FS(e,PS),o=s(`reasoning`,t.messageId,t.subagentRunId??void 0,`REASONING_MESSAGE_CHUNK`,`reasoning message`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`reasoning`&&(t.messageId===void 0||t.messageId===c.fields.messageId))d=c.fields;else{if(l.push(...i(o)),t.messageId===void 0)throw Error(`First REASONING_MESSAGE_CHUNK must have a messageId`);d={messageId:t.messageId,subagentRunId:t.subagentRunId},r.set(o,{kind:`reasoning`,fields:d});let e=kS({type:j.REASONING_MESSAGE_START,messageId:t.messageId,role:`reasoning`,...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=AS({...a,type:j.REASONING_MESSAGE_CONTENT,messageId:d.messageId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`REASONING_MESSAGE_CONTENT`,r,{messageId:d.messageId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:j.REASONING_MESSAGE_CONTENT,messageId:d.messageId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return LS(l,a,u,`REASONING_MESSAGE_CHUNK`),l}}return e.type,[e]}),Ms(()=>{a()}))},zS=1e6;function BS(e){if(e===void 0)return zS;if(e===1/0||Number.isSafeInteger(e)&&e>0)return e;throw new M(`Invalid enforcement entry budget ${String(e)}: expected a positive integer, or Infinity to disable it.`)}var VS=class extends M{constructor(e,t){super(`Enforcement limit exceeded at '${t||`(root)`}': the payload has more than ${e} entries to validate. If it is legitimate, raise or disable the limit (maxEnforcedEntries on the agent, or maxEntries in the enforcement options).`),this.name=`AGUIEnforcementLimitError`,this.limit=e,this.path=t}},HS=Symbol(`agui.strip.drop`);function US(e,t,n){if(e.used+=t,e.used>e.max)throw new VS(e.max,n)}function WS(e){let t=e;for(;;){if(t instanceof Bg||t instanceof Wg||t instanceof Kg||t instanceof r_||t instanceof Qg){t=t.unwrap();continue}if(t instanceof e_){t=t.def.in;continue}if(t instanceof a_){t=t.def.getter();continue}return t}}function GS(e){let t=e.def;return typeof t?.discriminator==`string`?t.discriminator:void 0}function KS(e){let t=e,n=Array.isArray(t.def?.values)?t.def.values:t.values?Array.from(t.values):void 0;return n&&n.length===1?n[0]:t.value}function qS(e){let t=WS(e);return t instanceof Lg?KS(t):void 0}function JS(e,t,n,r,i){let a=WS(t);if(a instanceof Tg){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=a.shape,o=e,s={},c=a.meta()?.specOpen===!0,l=Object.keys(o);US(i,l.length,n);for(let e of l){let a=Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;if(a===void 0){if(c){s[e]=o[e];continue}r.push(`${n}/${e}`);continue}let l=r.length,u=JS(o[e],a,`${n}/${e}`,r,i);if(u===HS){if(r.length=l,a.safeParse(void 0).success){r.push(`${n}/${e}`);continue}return HS}s[e]=u}return s}if(a instanceof Cg){if(!Array.isArray(e))return e;US(i,e.length,n);let t=a.element,o=[];return e.forEach((e,a)=>{let s=r.length,c=JS(e,t,`${n}/${a}`,r,i);if(c===HS){r.length=s,r.push(`${n}/${a}`);return}o.push(c)}),o}if(a instanceof Ng){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=a.def.valueType,o=e,s={},c=Object.keys(o);US(i,c.length,n);for(let e of c){let a=r.length,c=JS(o[e],t,`${n}/${e}`,r,i);if(c===HS){r.length=a,r.push(`${n}/${e}`);continue}s[e]=c}return s}if(a instanceof Dg){let t=a.options,o=GS(a);if(o!==void 0){if(typeof e!=`object`||!e||Array.isArray(e))return e;let a=e[o];for(let s of t){let t=WS(s);if(!(t instanceof Tg))continue;let c=t.shape;if(qS(c[o])===a)return JS(e,s,n,r,i)}return HS}let s=t.filter(e=>WS(e)instanceof Tg),c=typeof e==`object`&&!!e&&!Array.isArray(e);if(s.length>1&&c)return e;for(let a of t){let t=WS(a);if(t instanceof Cg&&Array.isArray(e)||t instanceof Tg&&c)return JS(e,a,n,r,i)}return e}return e}function YS(e,t,n){let r=[],i=JS(e,t,``,r,{used:0,max:BS(n?.maxEntries)});if(i===HS)throw Error(`Internal error: the stripper found the whole value unrecognisable, which the schemas are not supposed to allow — schema/stripper mismatch.`);return{value:i,stripped:r}}var XS=new Set(Object.values(j));function ZS(e){return XS.has(e.type)}var QS=new Map(uv.options.map(e=>{let t=e.shape;return[String(KS(t.type)),e]})),$S=()=>typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS;function eC(e){$S()||console.warn(`[ag-ui][enforce] ${e}`)}var tC=(e,t)=>{let n=BS(t?.maxEntries);return t=>{let r=Qx(e);return t.pipe(Ss(e=>{if(!ZS(e)){eC(`Dropping unrecognised event '${String(e.type)}': no middleware translated it and the protocol does not describe it.`);let t={type:e.type};return r?.event(`ENFORCE`,`Unrecognised event dropped:`,t,t),zo}let t=QS.get(e.type);if(t===void 0)throw Error(`No validator for recognised event type '${String(e.type)}'`);let{value:i,stripped:a}=YS(e,t,{maxEntries:n});for(let t of a)eC(`Removed unrecognised material at '${t}' on ${String(e.type)}. Nothing handled it; see the repo-root DEPRECATIONS.md if it is a retired shape.`);return _s(t.parse(i))}))}};function nC(e,t){let n=BS(t?.maxEntries),{value:r,stripped:i}=YS(Zi(e,`RunAgentInput`),W_,{maxEntries:n});for(let e of i)eC(`Removed unrecognised material at '${e}' from the outgoing input.`);return W_.parse(r)}var rC=class{runNext(e,t){return t.run(e).pipe(RS(!1))}runNextWithState(e,t){let n=$(e.messages||[]),r=$(e.state===void 0?{}:e.state),i=new Ro;return lS(e,i,t,[]).subscribe({next:e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)},error:()=>{}}),this.runNext(e,t).pipe(Os(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:$(n),state:$(r)})))}},iC=class extends rC{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function aC(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:`document`}function oC(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`binary`&&`mimeType`in e&&typeof e.mimeType==`string`}function sC(e){let t=aC(e.mimeType);return e.data?{type:t,source:{type:`data`,value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:`url`,value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:((typeof process>`u`||!{}.SUPPRESS_TRANSFORMATION_WARNINGS)&&console.warn(`[ag-ui][compat] A binary content part carries only an id ('${e.id??``}') and cannot be converted to a modern media part; a 1.0 peer will not accept it. Provide data or a url. See the repo-root DEPRECATIONS.md.`),e)}function cC(e,t,n){if(typeof e!=`object`||!e||!(`type`in e)||e.type!==t.type||!(`source`in e))return!1;let r=e.source;return typeof r!=`object`||!r||!(`type`in r)||r.type!==t.source.type||!(`value`in r)||r.value!==t.source.value||!(`mimeType`in r)||r.mimeType!==t.source.mimeType?!1:!n||`metadata`in e&&typeof e.metadata==`object`&&e.metadata!==null&&`filename`in e.metadata&&e.metadata.filename===n}function lC(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.flatMap(e=>{if(oC(e)){let n=sC(e);return n.type!==`binary`&&t.some(t=>cC(t,n,e.filename))?[]:[n]}return[e]});return{...e,content:n}}var uC=`THINKING_START`,dC=`THINKING_END`,fC=`THINKING_TEXT_MESSAGE_START`,pC=`THINKING_TEXT_MESSAGE_CONTENT`,mC=`THINKING_TEXT_MESSAGE_END`;function hC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var gC={event:[`rawEvent`,`subagentRunId`],[j.RUN_STARTED]:[`parentRunId`,`input`],[j.RUN_FINISHED]:[`result`,`outcome`],[j.RUN_ERROR]:[`usage`],[j.SUBAGENT_FINISHED]:[`result`],[j.TOOL_CALL_START]:[`parentMessageId`],[j.TOOL_CALL_CHUNK]:[`parentMessageId`],[j.TOOL_CALL_RESULT]:[`role`],"RUN_FINISHED.outcome":[`pendingToolCallIds`],"RUN_FINISHED.usage[]":[`provider`,`reasoningTokens`,`cachedInputTokens`,`cacheWriteInputTokens`],RunAgentInput:[`forwardedProps`],Tool:[`parameters`],ResumeEntry:[`payload`],"input content":[`metadata`]},_C=new Map(Object.entries(gC).filter(([e])=>Object.values(j).includes(e))),vC=e=>uS(e,`an absent field`);function yC(e,t,n,r){if(!hC(e))return e;let i;for(let a of t)e[a]===null&&(r(n===void 0?`${a}: null`:`${n}.${a}: null`),i??={...e},delete i[a]);return i??e}function bC(e,t,n){if(!hC(e)||!Array.isArray(e[t]))return e;let r=e[t],i=r.map(n);return i.some((e,t)=>e!==r[t])?{...e,[t]:i}:e}function xC(e,t){return bC(e,`content`,e=>{if(!hC(e))return e;switch(e.type){case`image`:case`audio`:case`video`:case`document`:return yC(e,gC[`input content`],`${e.type} input content`,t);default:return e}})}function SC(e,t=vC){let n=yC(e,gC.RunAgentInput,`RunAgentInput`,t);return n=bC(n,`tools`,e=>yC(e,gC.Tool,`Tool`,t)),n=bC(n,`resume`,e=>yC(e,gC.ResumeEntry,`ResumeEntry`,t)),bC(n,`messages`,e=>xC(e,t))}var CC=class extends rC{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null,this.nullsNoticedThisRun=new Set,this.noticeNullOncePerRun=e=>{this.nullsNoticedThisRun.has(e)||(this.nullsNoticedThisRun.add(e),uS(e,`an absent field`))}}warn(e,t){uS(e,t)}mintedContinuationId(e,t){if(t!==null)return t;let n=Gx();return this.warnAside(`Minting a messageId ('${n}') for ${e}: no THINKING opener preceded it, so there was no id to continue. The id is this client's invention, not the producer's, and verification will reject the translated event for naming something nothing opened.`),n}warnAside(e){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][compat] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.nullsNoticedThisRun.clear(),e.messages=e.messages.map(lC),t.run(e).pipe(bs(e=>this.transformEvent(e)))}transformEvent(e){let t=this.noticeNullOncePerRun;e.type===j.RUN_STARTED&&this.nullsNoticedThisRun.clear(),e=yC(e,gC.event,void 0,t);let n=_C.get(e.type);switch(n&&(e=yC(e,n,e.type,t)),e.type){case uC:{this.currentReasoningId=Gx();let{title:t,...n}=e;return this.warn(uC,j.REASONING_START),t!==void 0&&this.warnAside(`Dropping ${uC}.title ${JSON.stringify(t)}: ${j.REASONING_START} has no title field, so the span's label cannot be carried and nothing downstream can recover it.`),{...n,type:j.REASONING_START,messageId:this.currentReasoningId}}case fC:return this.currentMessageId=Gx(),this.warn(fC,j.REASONING_MESSAGE_START),{...e,type:j.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`reasoning`};case pC:{let{delta:t,...n}=e;return this.warn(pC,j.REASONING_MESSAGE_CONTENT),{...n,type:j.REASONING_MESSAGE_CONTENT,messageId:this.mintedContinuationId(pC,this.currentMessageId),delta:t}}case mC:{let t=this.mintedContinuationId(mC,this.currentMessageId);return this.currentMessageId=null,this.warn(mC,j.REASONING_MESSAGE_END),{...e,type:j.REASONING_MESSAGE_END,messageId:t}}case dC:{let t=this.mintedContinuationId(dC,this.currentReasoningId);return this.currentReasoningId=null,this.warn(dC,j.REASONING_END),{...e,type:j.REASONING_END,messageId:t}}case j.RUN_FINISHED:{let n=e,r=yC(n.outcome,gC[`RUN_FINISHED.outcome`],`RUN_FINISHED.outcome`,t);return bC(r===n.outcome?n:{...n,outcome:r},`usage`,e=>yC(e,gC[`RUN_FINISHED.usage[]`],`RUN_FINISHED.usage[]`,t))}case j.MESSAGES_SNAPSHOT:{let t=e;return Array.isArray(t.messages)?{...t,messages:t.messages.map(e=>this.upgradeInboundMessage(e))}:e}case j.RUN_STARTED:{let n=SC(e.input,t),r=n===e.input?e:{...e,input:n},i=r;return!i.input||!Array.isArray(i.input.messages)?r:{...i,input:{...i.input,messages:i.input.messages.map(e=>this.upgradeInboundMessage(e))}}}default:return e}}upgradeInboundMessage(e){e=xC(e,this.noticeNullOncePerRun);let t=e.content;return!Array.isArray(t)||!t.some(e=>typeof e==`object`&&!!e&&e.type===`binary`)?e:(this.warn(`binary input content`,`the modern media content parts`),lC(e))}},wC=()=>e=>Ts(()=>{let t=new CC;return e.pipe(bs(e=>t.transformEvent(e)))});function TC(e,t=new Date){return e.expiresAt!==void 0&&new Date(e.expiresAt)<=t}function EC(){return typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS}function DC(e){EC()||console.warn(`[ag-ui][compat] Flattening message content for a <=0.0.39 peer DROPS non-text parts (${e.join(`, `)}). The peer cannot receive them; upgrade it to keep media content. See the repo-root DEPRECATIONS.md.`)}function OC(e){EC()||console.warn(`[ag-ui][compat] Not flattening message content for a <=0.0.39 peer: ${e} content part(s) claim type "text" but carry a malformed 'text' value. That is a defect in the message, not media the peer cannot represent, and a downgrade must not repair it — the content is passed on unchanged so the outgoing enforcement boundary reports it. See the repo-root DEPRECATIONS.md.`)}function kC(e){let t=e.content;if(Array.isArray(t)){let n=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`,r=e=>n(e)&&typeof e.text==`string`,i=t.filter(e=>n(e)&&!r(e));if(i.length>0)return OC(i.length),e;let a=t.filter(e=>!r(e)).map(e=>typeof e==`object`&&e&&`type`in e?String(e.type):typeof e);a.length>0&&DC(a);let o=t.filter(r).map(e=>e.text).join(``);return{...e,content:o}}return typeof t==`string`?e:t===void 0?{...e,content:``}:e}var AC=class extends rC{run(e,t){let{parentRunId:n,...r}=e,i={...r,messages:r.messages.map(kC)};return this.runNext(i,t)}},jC=`THINKING_START`,MC=`THINKING_END`,NC=`THINKING_TEXT_MESSAGE_START`,PC=`THINKING_TEXT_MESSAGE_CONTENT`,FC=`THINKING_TEXT_MESSAGE_END`,IC=class extends rC{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(bs(e=>this.transformEvent(e)))}transformEvent(e){switch(e.type){case jC:{this.currentReasoningId=Gx();let{title:t,...n}=e;return this.warnAboutTransformation(jC,j.REASONING_START),{...n,type:j.REASONING_START,messageId:this.currentReasoningId}}case NC:return this.currentMessageId=Gx(),this.warnAboutTransformation(NC,j.REASONING_MESSAGE_START),{...e,type:j.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`reasoning`};case PC:{let{delta:t,...n}=e;return this.warnAboutTransformation(PC,j.REASONING_MESSAGE_CONTENT),{...n,type:j.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??Gx(),delta:t}}case FC:{let t=this.currentMessageId??Gx();return this.warnAboutTransformation(FC,j.REASONING_MESSAGE_END),{...e,type:j.REASONING_MESSAGE_END,messageId:t}}case MC:{let t=this.currentReasoningId??Gx();return this.warnAboutTransformation(MC,j.REASONING_END),{...e,type:j.REASONING_END,messageId:t}}default:return e}}},LC=`SUBAGENT_STARTED`,RC=`SUBAGENT_FINISHED`,zC=`SUBAGENT_ERROR`;function BC(e){if(e&&typeof e==`object`&&`subagentRunId`in e){let{subagentRunId:t,...n}=e;return n}return e}function VC(e){return e.map(e=>BC(e))}var HC=class extends rC{warnDroppedLifecycleEvent(e){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is dropping ${e} because the target agent predates subagent support. To remove this warning, upgrade your AG-UI integration package. To suppress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){let n={...e,messages:(e.messages??[]).map(e=>BC(e))};return this.runNext(n,t).pipe(Fs(e=>{let t=e.type;(t===LC||t===RC||t===zC)&&this.warnDroppedLifecycleEvent(t)}),Es(e=>{let t=e.type;return t!==LC&&t!==RC&&t!==zC}),bs(e=>{let t=BC(e);if(t.type===j.MESSAGES_SNAPSHOT){let e=t;if(Array.isArray(e.messages))return{...e,messages:VC(e.messages)}}if(t.type===j.RUN_FINISHED){let e=t;if(e.outcome&&Array.isArray(e.outcome.interrupts))return{...e,outcome:{...e.outcome,interrupts:e.outcome.interrupts.map(e=>BC(e))}}}if(t.type===j.RUN_STARTED){let e=t;if(e.input&&Array.isArray(e.input.messages))return{...e,input:{...e.input,messages:VC(e.input.messages)}}}return t}))}},UC=`1.0.4`,WC=!1,GC=new WeakSet,KC=(e,t)=>/^\d+\.\d+$/.test(e)?Vx(e,t)>0?`newer`:`not-newer`:`uninterpretable`,qC=e=>{let t=e.protocolVersion;if(t!==void 0&&t!==`1.0`)switch(KC(t,`1.0`)){case`uninterpretable`:console.warn(`[ag-ui] The producer declared protocol version '${t}', which this client cannot interpret.`);return;case`newer`:console.warn(`[ag-ui] The producer speaks protocol ${t}; this client speaks 1.0. Unrecognised material will be stripped with warnings.`);return;case`not-newer`:return}},JC=class e{resolvePeerCeiling(t){if(this.resolvingPeerCeiling)return UC;let n=Object.getOwnPropertyDescriptor(this,`maxVersion`),r=Object.getOwnPropertyDescriptor(this,`maxProtocolVersion`),i=Object.getPrototypeOf(this);for(;i&&i!==e.prototype;)n??=Object.getOwnPropertyDescriptor(i,`maxVersion`),r??=Object.getOwnPropertyDescriptor(i,`maxProtocolVersion`),i=Object.getPrototypeOf(i);if(t===`maxVersion`&&n)return UC;let a=t===`maxProtocolVersion`?n:r;if(!a)return UC;this.resolvingPeerCeiling=!0;try{return a.get?a.get.call(this):a.value}finally{this.resolvingPeerCeiling=!1}}get maxProtocolVersion(){return this.resolvePeerCeiling(`maxProtocolVersion`)}get maxVersion(){return!this.resolvingPeerCeiling&&!WC&&(WC=!0,console.warn(`[ag-ui] AbstractAgent.maxVersion is deprecated — use maxProtocolVersion. Same value; the new name says whose version it is and that it is a ceiling.`)),this.resolvePeerCeiling(`maxVersion`)}get debug(){return this._debug}set debug(e){this._debug=Zx(e),this._debugLogger=eS(this._debug)}get threadId(){return this._threadId??=qi()}set threadId(e){this._threadId=e}get maxEnforcedEntries(){return this._maxEnforcedEntries}set maxEnforcedEntries(e){this._maxEnforcedEntries=BS(e)}get debugLogger(){return this._debugLogger}set debugLogger(e){this._debugLogger=typeof e==`boolean`?e?eS(Zx(!0)):void 0:e}resolvedCeilingDuringConstruction(){let e=this.maxProtocolVersion;if(typeof e!=`string`||!Hx(e))throw new M(`maxProtocolVersion resolved to ${JSON.stringify(e)} during construction, which is not a version this client can compare. A ceiling read from an instance field is not available yet — return a literal from the getter.`);return e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:i,debug:a,maxEnforcedEntries:o}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.resolvingPeerCeiling=!1,this.agentId=e,this.description=t??``,this._threadId=n,this.messages=$(r??[]),this.state=$(i??{}),this._debug=Zx(a),this._debugLogger=eS(this._debug),this._maxEnforcedEntries=BS(o);let s=this.resolvedCeilingDuringConstruction();Vx(s,`0.0.39`)<=0&&this.middlewares.unshift(new AC),Vx(s,`0.0.45`)<=0&&this.middlewares.unshift(new IC),Vx(s,`0.0.57`)<=0&&this.middlewares.unshift(new HC)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(e=>typeof e==`function`?new iC(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??qi();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle(`LIFECYCLE`,`Run started:`,{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunStartedEvent:({event:e})=>qC(e),onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];GC.add(n),await this.onInitialize(n,a),this.activeRunDetach$=new Fo;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await ys(wo(()=>[...this.middlewares,new CC].reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(n),tC(this.debugLogger,{maxEntries:this.maxEnforcedEntries}),RS(this.debugLogger),dS(this.debugLogger),e=>e.pipe(Ps(this.activeRunDetach$)),e=>this.applyBeforeSourceError(n,e,a),Ds(e=>(this.debugLogger?.lifecycle(`LIFECYCLE`,`Run errored:`,{agentId:this.agentId,error:e instanceof Error?e.message:String(e)}),this.isRunning=!1,this.onError(n,e,a))),Ms(()=>{this.debugLogger?.lifecycle(`LIFECYCLE`,`Run finished:`,{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(_s(null)));let s=$(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new Qi}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??qi();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunStartedEvent:({event:e})=>qC(e),onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new Fo;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await ys(wo(()=>Ts(()=>this.connect(n)),e=>tC(this.debugLogger,{maxEntries:this.maxEnforcedEntries})(wC()(e)),RS(this.debugLogger),dS(this.debugLogger),e=>e.pipe(Ps(this.activeRunDetach$)),e=>this.applyBeforeSourceError(n,e,a),Ds(e=>(this.isRunning=!1,e instanceof Qi?zo:this.onError(n,e,a))),Ms(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(_s(null)),{defaultValue:void 0});let s=$(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}applyBeforeSourceError(e,t,n){return Ts(()=>{let r,i=t.pipe(Ds(e=>(r={error:e},zo)));return this.processApplyEvents(e,this.apply(e,i,n),n).pipe(As(Ts(()=>{let e=r;return e?F(()=>e.error):zo})))})}apply(e,t,n){return lS(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(Fs(t=>{t.messages&&(this.messages=t.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),t.state!==void 0&&(this.state=t.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=$(this.messages);for(let e of t)e.subagentRunId===null&&delete e.subagentRunId;let n=aS(t.filter(e=>e.role!==`activity`));return{threadId:this.threadId,runId:e?.runId||qi(),...Vx(this.maxProtocolVersion,UC)>=0&&{protocolVersion:`1.0`},tools:$(e?.tools??[]),context:$(e?.context??[]),forwardedProps:$(e?.forwardedProps??{}),state:$(this.state),messages:n,...e?.resume===void 0?{}:{resume:$(e.resume)}}}async onInitialize(e,t){if(GC.has(e)&&this.pendingInterrupts.length>0){let t=new Set((e.resume??[]).map(e=>e.interruptId)),n=this.pendingInterrupts.map(e=>e.id).filter(e=>!t.has(e));if(n.length>0)throw new M(`Thread has ${n.length} pending interrupt(s) not addressed by resume: ${n.join(`, `)}`);for(let t of this.pendingInterrupts)if(TC(t)&&(e.resume??[]).find(e=>e.interruptId===t.id)?.status!==`cancelled`)throw new M(`Interrupt ${t.id} expired at ${t.expiresAt} and can no longer be answered. Cancel it to continue the thread.`)}let n=await Xx(t,this.messages,this.state,(t,n,r)=>t.onRunInitialized?.({messages:n,state:r,agent:this,input:e}));if(n.messages!==void 0||n.state!==void 0){if(n.messages){this.messages=n.messages;for(let e of n.messages)e.subagentRunId===null&&delete e.subagentRunId;e.messages=aS(n.messages.filter(e=>e.role!==`activity`)),t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})}n.state!==void 0&&(this.state=n.state,e.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}}onError(e,t,n){return gs(Xx(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.({error:t,messages:r,state:i,agent:this,input:e}))).pipe(bs(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),i.state!==void 0&&(this.state=i.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),i.stopPropagation!==!0){let e=String(t);if(t.name!==`AbortError`&&t.message!==`Fetch is aborted`&&t.message!==`signal is aborted without reason`&&t.message!==`component unmounted`&&e!==`component unmounted`)throw console.error(`Agent execution failed:`,t),t}return{}}))}async onFinalize(e,t){let n=await Xx(t,this.messages,this.state,(t,n,r)=>t.onRunFinalized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=$(this.messages),e.state=$(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e._maxEnforcedEntries=this._maxEnforcedEntries,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=$(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role===`assistant`&&e.toolCalls)for(let t of e.toolCalls)for(let e of this.subscribers)await e.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role===`assistant`&&t.toolCalls)for(let e of t.toolCalls)for(let t of this.subscribers)await t.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=$(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=$(e),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??qi();let t=this.prepareRunAgentInput(e);return[...this.middlewares,new CC].reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(t).pipe(tC(this.debugLogger,{maxEntries:this.maxEnforcedEntries}),RS(this.debugLogger),dS(this.debugLogger),wS(this.threadId,t.runId,this.agentId),e=>e.pipe(bs(e=>(this.debugLogger?.event(`LEGACY`,`Event:`,e,{type:e.type}),e))))}};function YC(e){if(!Array.isArray(e.messages))return e;let t=!1,n=e.messages.map(e=>{if(e.subagentRunId===null){t=!0;let n={...e};return delete n.subagentRunId,n}return e});return t?{...e,messages:n}:e}var XC=class extends JC{requestInit(e){return{method:`POST`,headers:{...this.headers,"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(YC(e)),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=$(e.headers??{}),this.fetch=e.fetch??((e,t)=>fetch(e,t))}run(e){return yS(pS(()=>this.fetch(this.url,this.requestInit(nC(e,{maxEntries:this.maxEnforcedEntries})))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=$(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}},ZC=class extends pn{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:$t(t,n.data),hasPreviousPage:dn(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},QC=class extends mn{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||$C(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=tn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),gn.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function $C(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var ew=class extends rn{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new QC({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=tw(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=tw(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=tw(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=tw(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){gn.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>an(t,e))}findAll(e={}){return this.getAll().filter(t=>an(e,t))}notify(e){gn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return gn.batch(()=>Promise.all(e.map(e=>e.continue().catch(_n))))}};function tw(e){return e.options.scope?.id}var nw=class extends rn{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??on(r,t),a=this.get(i);return a||(a=new sn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){gn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Qt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Qt(e,t)):t}notify(e){gn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){gn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){gn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},rw=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new nw,this.#t=e.mutationCache||new ew,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=nn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=cn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(en(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=fn(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return gn.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;gn.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return gn.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=gn.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(_n).catch(_n)}invalidateQueries(e,t={}){return gn.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=gn.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(_n)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(_n)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(en(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(en(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(_n).catch(_n)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(_n).catch(_n)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return cn.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ln(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{yn(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ln(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{yn(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=on(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Xt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function iw(e,t){return un(e,ZC,t)}var aw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M225.29,165.93C216.61,151,212,129.57,212,104a84,84,0,0,0-168,0c0,25.58-4.59,47-13.27,61.93A20.08,20.08,0,0,0,30.66,186,19.77,19.77,0,0,0,48,196H84.18a44,44,0,0,0,87.64,0H208a19.77,19.77,0,0,0,17.31-10A20.08,20.08,0,0,0,225.29,165.93ZM128,212a20,20,0,0,1-19.6-16h39.2A20,20,0,0,1,128,212ZM54.66,172C63.51,154,68,131.14,68,104a60,60,0,0,1,120,0c0,27.13,4.48,50,13.33,68Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M208,192H48a8,8,0,0,1-6.88-12C47.71,168.6,56,139.81,56,104a72,72,0,0,1,144,0c0,35.82,8.3,64.6,14.9,76A8,8,0,0,1,208,192Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M220.07,176.94C214.41,167.2,206,139.73,206,104a78,78,0,1,0-156,0c0,35.74-8.42,63.2-14.08,72.94A14,14,0,0,0,48,198H90.48a38,38,0,0,0,75,0H208a14,14,0,0,0,12.06-21.06ZM128,218a26,26,0,0,1-25.29-20h50.58A26,26,0,0,1,128,218Zm81.71-33a1.9,1.9,0,0,1-1.7,1H48a1.9,1.9,0,0,1-1.7-1,2,2,0,0,1,0-2C53.87,170,62,139.69,62,104a66,66,0,1,1,132,0c0,35.68,8.14,65.95,15.71,79A2,2,0,0,1,209.71,185Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M218.35,178C212.58,168,204,140.13,204,104a76,76,0,1,0-152,0c0,36.13-8.59,64-14.36,73.95A12,12,0,0,0,48,196H92.23a36,36,0,0,0,71.54,0H208A12,12,0,0,0,218.35,178ZM128,220a28,28,0,0,1-27.71-24h55.42A28,28,0,0,1,128,220Zm83.45-34a3.91,3.91,0,0,1-3.44,2H48a3.91,3.91,0,0,1-3.44-2,4,4,0,0,1,0-4C52,169.17,60,139.32,60,104a68,68,0,1,1,136,0c0,35.31,8,65.17,15.44,78A4,4,0,0,1,211.45,186Z`}))]]),ow=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,44H160a43.86,43.86,0,0,0-32,13.85A43.86,43.86,0,0,0,96,44H24A12,12,0,0,0,12,56V200a12,12,0,0,0,12,12H96a20,20,0,0,1,20,20,12,12,0,0,0,24,0,20,20,0,0,1,20-20h72a12,12,0,0,0,12-12V56A12,12,0,0,0,232,44ZM96,188H36V68H96a20,20,0,0,1,20,20V192.81A43.79,43.79,0,0,0,96,188Zm124,0H160a43.71,43.71,0,0,0-20,4.83V88a20,20,0,0,1,20-20h60Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,56V200H160a32,32,0,0,0-32,32,32,32,0,0,0-32-32H24V56H96a32,32,0,0,1,32,32,32,32,0,0,1,32-32Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M240,56V200a8,8,0,0,1-8,8H160a24,24,0,0,0-24,23.94,7.9,7.9,0,0,1-5.12,7.55A8,8,0,0,1,120,232a24,24,0,0,0-24-24H24a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H88a32,32,0,0,1,32,32v87.73a8.17,8.17,0,0,0,7.47,8.25,8,8,0,0,0,8.53-8V80a32,32,0,0,1,32-32h64A8,8,0,0,1,240,56Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,50H160a38,38,0,0,0-32,17.55A38,38,0,0,0,96,50H24a6,6,0,0,0-6,6V200a6,6,0,0,0,6,6H96a26,26,0,0,1,26,26,6,6,0,0,0,12,0,26,26,0,0,1,26-26h72a6,6,0,0,0,6-6V56A6,6,0,0,0,232,50ZM96,194H30V62H96a26,26,0,0,1,26,26V204.31A37.86,37.86,0,0,0,96,194Zm130,0H160a37.87,37.87,0,0,0-26,10.32V88a26,26,0,0,1,26-26h66Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,52H160a36,36,0,0,0-32,19.54A36,36,0,0,0,96,52H24a4,4,0,0,0-4,4V200a4,4,0,0,0,4,4H96a28,28,0,0,1,28,28,4,4,0,0,0,8,0,28,28,0,0,1,28-28h72a4,4,0,0,0,4-4V56A4,4,0,0,0,232,52ZM96,196H28V60H96a28,28,0,0,1,28,28V209.4A35.93,35.93,0,0,0,96,196Zm132,0H160a35.94,35.94,0,0,0-28,13.41V88a28,28,0,0,1,28-28h68Z`}))]]),sw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,20A108,108,0,0,0,31.85,177.23L21,209.66A20,20,0,0,0,46.34,235l32.43-10.81A108,108,0,1,0,128,20Zm0,192a84,84,0,0,1-42.06-11.27,12,12,0,0,0-6-1.62,12.1,12.1,0,0,0-3.8.62l-29.79,9.93,9.93-29.79a12,12,0,0,0-1-9.81A84,84,0,1,1,128,212Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,128A96,96,0,0,1,79.93,211.11h0L42.54,223.58a8,8,0,0,1-10.12-10.12l12.47-37.39h0A96,96,0,1,1,224,128Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232,128A104,104,0,0,1,79.12,219.82L45.07,231.17a16,16,0,0,1-20.24-20.24l11.35-34.05A104,104,0,1,1,232,128Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,26A102,102,0,0,0,38.35,176.69L26.73,211.56a14,14,0,0,0,17.71,17.71l34.87-11.62A102,102,0,1,0,128,26Zm0,192a90,90,0,0,1-45.06-12.08,6.09,6.09,0,0,0-3-.81,6.2,6.2,0,0,0-1.9.31L40.65,217.88a2,2,0,0,1-2.53-2.53L50.58,178a6,6,0,0,0-.5-4.91A90,90,0,1,1,128,218Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,28A100,100,0,0,0,40.53,176.5l-11.9,35.69a12,12,0,0,0,15.18,15.18l35.69-11.9A100,100,0,1,0,128,28Zm0,192a92,92,0,0,1-46.07-12.35,4.05,4.05,0,0,0-2-.54,3.93,3.93,0,0,0-1.27.21L41.28,219.78a4,4,0,0,1-5.06-5.06l12.46-37.38a4,4,0,0,0-.33-3.27A92,92,0,1,1,128,220Z`}))]]),cw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212ZM163.27,77l-56,24a12,12,0,0,0-6.3,6.3l-24,56A12,12,0,0,0,92.73,179l56-24a12,12,0,0,0,6.3-6.3l24-56A12,12,0,0,0,163.27,77Zm-28.41,57.89-24,10.29,10.29-24,24-10.29Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,32a96,96,0,1,0,96,96A96,96,0,0,0,128,32Zm16,112L80,176l32-64,64-32Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM172.42,72.84l-64,32a8.05,8.05,0,0,0-3.58,3.58l-32,64A8,8,0,0,0,80,184a8.1,8.1,0,0,0,3.58-.84l64-32a8.05,8.05,0,0,0,3.58-3.58l32-64a8,8,0,0,0-10.74-10.74ZM138,138,97.89,158.11,118,118l40.15-20.07Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm51.58,57.79-32,64a4.08,4.08,0,0,1-1.79,1.79l-64,32a4,4,0,0,1-5.37-5.37l32-64a4.08,4.08,0,0,1,1.79-1.79l64-32A4,4,0,0,1,179.58,81.79Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218ZM173.32,74.63l-64,32a6,6,0,0,0-2.69,2.69l-32,64A6,6,0,0,0,80,182a6.06,6.06,0,0,0,2.68-.63l64-32a6,6,0,0,0,2.69-2.69l32-64a6,6,0,0,0-8.05-8.05Zm-33.79,64.9L93.42,162.58l23-46.11,46.11-23Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216ZM172.42,72.84l-64,32a8.05,8.05,0,0,0-3.58,3.58l-32,64A8,8,0,0,0,80,184a8.1,8.1,0,0,0,3.58-.84l64-32a8.05,8.05,0,0,0,3.58-3.58l32-64a8,8,0,0,0-10.74-10.74ZM138,138,97.89,158.11,118,118l40.15-20.07Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220ZM174.21,76.42l-64,32a4.08,4.08,0,0,0-1.79,1.79l-32,64A4,4,0,0,0,80,180a4.05,4.05,0,0,0,1.79-.42l64-32a4.08,4.08,0,0,0,1.79-1.79l32-64a4,4,0,0,0-5.37-5.37ZM141,141l-52.08,26L115,115l52.08-26Z`}))]]),lw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,76a52,52,0,1,0,52,52A52.06,52.06,0,0,0,128,76Zm0,80a28,28,0,1,1,28-28A28,28,0,0,1,128,156Zm92-27.21v-1.58l14-17.51a12,12,0,0,0,2.23-10.59A111.75,111.75,0,0,0,225,71.89,12,12,0,0,0,215.89,66L193.61,63.5l-1.11-1.11L190,40.1A12,12,0,0,0,184.11,31a111.67,111.67,0,0,0-27.23-11.27A12,12,0,0,0,146.3,22L128.79,36h-1.58L109.7,22a12,12,0,0,0-10.59-2.23A111.75,111.75,0,0,0,71.89,31.05,12,12,0,0,0,66,40.11L63.5,62.39,62.39,63.5,40.1,66A12,12,0,0,0,31,71.89,111.67,111.67,0,0,0,19.77,99.12,12,12,0,0,0,22,109.7l14,17.51v1.58L22,146.3a12,12,0,0,0-2.23,10.59,111.75,111.75,0,0,0,11.29,27.22A12,12,0,0,0,40.11,190l22.28,2.48,1.11,1.11L66,215.9A12,12,0,0,0,71.89,225a111.67,111.67,0,0,0,27.23,11.27A12,12,0,0,0,109.7,234l17.51-14h1.58l17.51,14a12,12,0,0,0,10.59,2.23A111.75,111.75,0,0,0,184.11,225a12,12,0,0,0,5.91-9.06l2.48-22.28,1.11-1.11L215.9,190a12,12,0,0,0,9.06-5.91,111.67,111.67,0,0,0,11.27-27.23A12,12,0,0,0,234,146.3Zm-24.12-4.89a70.1,70.1,0,0,1,0,8.2,12,12,0,0,0,2.61,8.22l12.84,16.05A86.47,86.47,0,0,1,207,166.86l-20.43,2.27a12,12,0,0,0-7.65,4,69,69,0,0,1-5.8,5.8,12,12,0,0,0-4,7.65L166.86,207a86.47,86.47,0,0,1-10.49,4.35l-16.05-12.85a12,12,0,0,0-7.5-2.62c-.24,0-.48,0-.72,0a70.1,70.1,0,0,1-8.2,0,12.06,12.06,0,0,0-8.22,2.6L99.63,211.33A86.47,86.47,0,0,1,89.14,207l-2.27-20.43a12,12,0,0,0-4-7.65,69,69,0,0,1-5.8-5.8,12,12,0,0,0-7.65-4L49,166.86a86.47,86.47,0,0,1-4.35-10.49l12.84-16.05a12,12,0,0,0,2.61-8.22,70.1,70.1,0,0,1,0-8.2,12,12,0,0,0-2.61-8.22L44.67,99.63A86.47,86.47,0,0,1,49,89.14l20.43-2.27a12,12,0,0,0,7.65-4,69,69,0,0,1,5.8-5.8,12,12,0,0,0,4-7.65L89.14,49a86.47,86.47,0,0,1,10.49-4.35l16.05,12.85a12.06,12.06,0,0,0,8.22,2.6,70.1,70.1,0,0,1,8.2,0,12,12,0,0,0,8.22-2.6l16.05-12.85A86.47,86.47,0,0,1,166.86,49l2.27,20.43a12,12,0,0,0,4,7.65,69,69,0,0,1,5.8,5.8,12,12,0,0,0,7.65,4L207,89.14a86.47,86.47,0,0,1,4.35,10.49l-12.84,16.05A12,12,0,0,0,195.88,123.9Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M207.86,123.18l16.78-21a99.14,99.14,0,0,0-10.07-24.29l-26.7-3a81,81,0,0,0-6.81-6.81l-3-26.71a99.43,99.43,0,0,0-24.3-10l-21,16.77a81.59,81.59,0,0,0-9.64,0l-21-16.78A99.14,99.14,0,0,0,77.91,41.43l-3,26.7a81,81,0,0,0-6.81,6.81l-26.71,3a99.43,99.43,0,0,0-10,24.3l16.77,21a81.59,81.59,0,0,0,0,9.64l-16.78,21a99.14,99.14,0,0,0,10.07,24.29l26.7,3a81,81,0,0,0,6.81,6.81l3,26.71a99.43,99.43,0,0,0,24.3,10l21-16.77a81.59,81.59,0,0,0,9.64,0l21,16.78a99.14,99.14,0,0,0,24.29-10.07l3-26.7a81,81,0,0,0,6.81-6.81l26.71-3a99.43,99.43,0,0,0,10-24.3l-16.77-21A81.59,81.59,0,0,0,207.86,123.18ZM128,168a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.6,107.6,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.29,107.29,0,0,0-26.25-10.86,8,8,0,0,0-7.06,1.48L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.6,107.6,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8.06,8.06,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8.06,8.06,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,130.16q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.6,107.6,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.29,107.29,0,0,0-26.25-10.86,8,8,0,0,0-7.06,1.48L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.6,107.6,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06ZM128,168a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,82a46,46,0,1,0,46,46A46.06,46.06,0,0,0,128,82Zm0,80a34,34,0,1,1,34-34A34,34,0,0,1,128,162ZM214,130.84c.06-1.89.06-3.79,0-5.68L229.33,106a6,6,0,0,0,1.11-5.29A105.34,105.34,0,0,0,219.76,74.9a6,6,0,0,0-4.53-3l-24.45-2.71q-1.93-2.07-4-4l-2.72-24.46a6,6,0,0,0-3-4.53,105.65,105.65,0,0,0-25.77-10.66A6,6,0,0,0,150,26.68l-19.2,15.37c-1.89-.06-3.79-.06-5.68,0L106,26.67a6,6,0,0,0-5.29-1.11A105.34,105.34,0,0,0,74.9,36.24a6,6,0,0,0-3,4.53L69.23,65.22q-2.07,1.94-4,4L40.76,72a6,6,0,0,0-4.53,3,105.65,105.65,0,0,0-10.66,25.77A6,6,0,0,0,26.68,106l15.37,19.2c-.06,1.89-.06,3.79,0,5.68L26.67,150.05a6,6,0,0,0-1.11,5.29A105.34,105.34,0,0,0,36.24,181.1a6,6,0,0,0,4.53,3l24.45,2.71q1.94,2.07,4,4L72,215.24a6,6,0,0,0,3,4.53,105.65,105.65,0,0,0,25.77,10.66,6,6,0,0,0,5.29-1.11L125.16,214c1.89.06,3.79.06,5.68,0l19.21,15.38a6,6,0,0,0,3.75,1.31,6.2,6.2,0,0,0,1.54-.2,105.34,105.34,0,0,0,25.76-10.68,6,6,0,0,0,3-4.53l2.71-24.45q2.07-1.93,4-4l24.46-2.72a6,6,0,0,0,4.53-3,105.49,105.49,0,0,0,10.66-25.77,6,6,0,0,0-1.11-5.29Zm-3.1,41.63-23.64,2.63a6,6,0,0,0-3.82,2,75.14,75.14,0,0,1-6.31,6.31,6,6,0,0,0-2,3.82l-2.63,23.63A94.28,94.28,0,0,1,155.14,218l-18.57-14.86a6,6,0,0,0-3.75-1.31h-.36a78.07,78.07,0,0,1-8.92,0,6,6,0,0,0-4.11,1.3L100.87,218a94.13,94.13,0,0,1-17.34-7.17L80.9,187.21a6,6,0,0,0-2-3.82,75.14,75.14,0,0,1-6.31-6.31,6,6,0,0,0-3.82-2l-23.63-2.63A94.28,94.28,0,0,1,38,155.14l14.86-18.57a6,6,0,0,0,1.3-4.11,78.07,78.07,0,0,1,0-8.92,6,6,0,0,0-1.3-4.11L38,100.87a94.13,94.13,0,0,1,7.17-17.34L68.79,80.9a6,6,0,0,0,3.82-2,75.14,75.14,0,0,1,6.31-6.31,6,6,0,0,0,2-3.82l2.63-23.63A94.28,94.28,0,0,1,100.86,38l18.57,14.86a6,6,0,0,0,4.11,1.3,78.07,78.07,0,0,1,8.92,0,6,6,0,0,0,4.11-1.3L155.13,38a94.13,94.13,0,0,1,17.34,7.17l2.63,23.64a6,6,0,0,0,2,3.82,75.14,75.14,0,0,1,6.31,6.31,6,6,0,0,0,3.82,2l23.63,2.63A94.28,94.28,0,0,1,218,100.86l-14.86,18.57a6,6,0,0,0-1.3,4.11,78.07,78.07,0,0,1,0,8.92,6,6,0,0,0,1.3,4.11L218,155.13A94.13,94.13,0,0,1,210.85,172.47Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,80a36,36,0,1,1,36-36A36,36,0,0,1,128,164Zm83.93-32.49q.13-3.51,0-7l15.83-19.79a4,4,0,0,0,.75-3.53A103.64,103.64,0,0,0,218,75.9a4,4,0,0,0-3-2l-25.19-2.8c-1.58-1.71-3.24-3.37-4.95-4.95L182.07,41a4,4,0,0,0-2-3A104,104,0,0,0,154.82,27.5a4,4,0,0,0-3.53.74L131.51,44.07q-3.51-.14-7,0L104.7,28.24a4,4,0,0,0-3.53-.75A103.64,103.64,0,0,0,75.9,38a4,4,0,0,0-2,3l-2.8,25.19c-1.71,1.58-3.37,3.24-4.95,4.95L41,73.93a4,4,0,0,0-3,2A104,104,0,0,0,27.5,101.18a4,4,0,0,0,.74,3.53l15.83,19.78q-.14,3.51,0,7L28.24,151.3a4,4,0,0,0-.75,3.53A103.64,103.64,0,0,0,38,180.1a4,4,0,0,0,3,2l25.19,2.8c1.58,1.71,3.24,3.37,4.95,4.95l2.8,25.2a4,4,0,0,0,2,3,104,104,0,0,0,25.28,10.46,4,4,0,0,0,3.53-.74l19.78-15.83q3.51.13,7,0l19.79,15.83a4,4,0,0,0,2.5.88,4,4,0,0,0,1-.13A103.64,103.64,0,0,0,180.1,218a4,4,0,0,0,2-3l2.8-25.19c1.71-1.58,3.37-3.24,4.95-4.95l25.2-2.8a4,4,0,0,0,3-2,104,104,0,0,0,10.46-25.28,4,4,0,0,0-.74-3.53Zm.17,42.83-24.67,2.74a4,4,0,0,0-2.55,1.32,76.2,76.2,0,0,1-6.48,6.48,4,4,0,0,0-1.32,2.55l-2.74,24.66a95.45,95.45,0,0,1-19.64,8.15l-19.38-15.51a4,4,0,0,0-2.5-.87h-.24a73.67,73.67,0,0,1-9.16,0,4,4,0,0,0-2.74.87l-19.37,15.5a95.33,95.33,0,0,1-19.65-8.13l-2.74-24.67a4,4,0,0,0-1.32-2.55,76.2,76.2,0,0,1-6.48-6.48,4,4,0,0,0-2.55-1.32l-24.66-2.74a95.45,95.45,0,0,1-8.15-19.64l15.51-19.38a4,4,0,0,0,.87-2.74,77.76,77.76,0,0,1,0-9.16,4,4,0,0,0-.87-2.74l-15.5-19.37A95.33,95.33,0,0,1,43.9,81.66l24.67-2.74a4,4,0,0,0,2.55-1.32,76.2,76.2,0,0,1,6.48-6.48,4,4,0,0,0,1.32-2.55l2.74-24.66a95.45,95.45,0,0,1,19.64-8.15l19.38,15.51a4,4,0,0,0,2.74.87,73.67,73.67,0,0,1,9.16,0,4,4,0,0,0,2.74-.87l19.37-15.5a95.33,95.33,0,0,1,19.65,8.13l2.74,24.67a4,4,0,0,0,1.32,2.55,76.2,76.2,0,0,1,6.48,6.48,4,4,0,0,0,2.55,1.32l24.66,2.74a95.45,95.45,0,0,1,8.15,19.64l-15.51,19.38a4,4,0,0,0-.87,2.74,77.76,77.76,0,0,1,0,9.16,4,4,0,0,0,.87,2.74l15.5,19.37A95.33,95.33,0,0,1,212.1,174.34Z`}))]]),uw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M28,64A12,12,0,0,1,40,52H216a12,12,0,0,1,0,24H40A12,12,0,0,1,28,64Zm12,76h64a12,12,0,0,0,0-24H40a12,12,0,0,0,0,24Zm80,40H40a12,12,0,0,0,0,24h80a12,12,0,0,0,0-24Zm120.49,20.49a12,12,0,0,1-17,0l-18.08-18.08a44,44,0,1,1,17-17l18.08,18.07A12,12,0,0,1,240.49,200.49ZM184,164a20,20,0,1,0-20-20A20,20,0,0,0,184,164Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,144a32,32,0,1,1-32-32A32,32,0,0,1,216,144Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M32,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H40A8,8,0,0,1,32,64Zm8,72h72a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm88,48H40a8,8,0,0,0,0,16h88a8,8,0,0,0,0-16Zm109.66,13.66a8,8,0,0,1-11.32,0L206,177.36A40,40,0,1,1,217.36,166l20.3,20.3A8,8,0,0,1,237.66,197.66ZM184,168a24,24,0,1,0-24-24A24,24,0,0,0,184,168Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M32,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H40A8,8,0,0,1,32,64Zm8,72h72a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm88,48H40a8,8,0,0,0,0,16h88a8,8,0,0,0,0-16Zm109.66,2.34L217.36,166A40,40,0,1,0,206,177.36l20.3,20.3a8,8,0,0,0,11.32-11.32Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M34,64a6,6,0,0,1,6-6H216a6,6,0,0,1,0,12H40A6,6,0,0,1,34,64Zm6,70h72a6,6,0,0,0,0-12H40a6,6,0,0,0,0,12Zm88,52H40a6,6,0,0,0,0,12h88a6,6,0,0,0,0-12Zm108.24,10.24a6,6,0,0,1-8.48,0l-21.49-21.48a38.06,38.06,0,1,1,8.49-8.49l21.48,21.49A6,6,0,0,1,236.24,196.24ZM184,170a26,26,0,1,0-26-26A26,26,0,0,0,184,170Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M32,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H40A8,8,0,0,1,32,64Zm8,72h72a8,8,0,0,0,0-16H40a8,8,0,0,0,0,16Zm88,48H40a8,8,0,0,0,0,16h88a8,8,0,0,0,0-16Zm109.66,13.66a8,8,0,0,1-11.32,0L206,177.36A40,40,0,1,1,217.36,166l20.3,20.3A8,8,0,0,1,237.66,197.66ZM184,168a24,24,0,1,0-24-24A24,24,0,0,0,184,168Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M36,64a4,4,0,0,1,4-4H216a4,4,0,0,1,0,8H40A4,4,0,0,1,36,64Zm4,68h72a4,4,0,0,0,0-8H40a4,4,0,0,0,0,8Zm88,56H40a4,4,0,0,0,0,8h88a4,4,0,0,0,0-8Zm106.83,6.83a4,4,0,0,1-5.66,0l-22.72-22.72a36.06,36.06,0,1,1,5.66-5.66l22.72,22.72A4,4,0,0,1,234.83,194.83ZM184,172a28,28,0,1,0-28-28A28,28,0,0,0,184,172Z`}))]]),dw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z`}))]]),fw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M236.37,139.4a12,12,0,0,0-12-3A84.07,84.07,0,0,1,119.6,31.59a12,12,0,0,0-15-15A108.86,108.86,0,0,0,49.69,55.07,108,108,0,0,0,136,228a107.09,107.09,0,0,0,64.93-21.69,108.86,108.86,0,0,0,38.44-54.94A12,12,0,0,0,236.37,139.4Zm-49.88,47.74A84,84,0,0,1,68.86,69.51,84.93,84.93,0,0,1,92.27,48.29Q92,52.13,92,56A108.12,108.12,0,0,0,200,164q3.87,0,7.71-.27A84.79,84.79,0,0,1,186.49,187.14Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M227.89,147.89A96,96,0,1,1,108.11,28.11,96.09,96.09,0,0,0,227.89,147.89Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M235.54,150.21a104.84,104.84,0,0,1-37,52.91A104,104,0,0,1,32,120,103.09,103.09,0,0,1,52.88,57.48a104.84,104.84,0,0,1,52.91-37,8,8,0,0,1,10,10,88.08,88.08,0,0,0,109.8,109.8,8,8,0,0,1,10,10Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M232.13,143.64a6,6,0,0,0-6-1.49A90.07,90.07,0,0,1,113.86,29.85a6,6,0,0,0-7.49-7.48A102.88,102.88,0,0,0,54.48,58.68,102,102,0,0,0,197.32,201.52a102.88,102.88,0,0,0,36.31-51.89A6,6,0,0,0,232.13,143.64Zm-42,48.29a90,90,0,0,1-126-126A90.9,90.9,0,0,1,99.65,37.66,102.06,102.06,0,0,0,218.34,156.35,90.9,90.9,0,0,1,190.1,191.93Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M230.72,145.06a4,4,0,0,0-4-1A92.08,92.08,0,0,1,111.94,29.27a4,4,0,0,0-5-5A100.78,100.78,0,0,0,56.08,59.88a100,100,0,0,0,140,140,100.78,100.78,0,0,0,35.59-50.87A4,4,0,0,0,230.72,145.06ZM191.3,193.53A92,92,0,0,1,62.47,64.7a93,93,0,0,1,39.88-30.35,100.09,100.09,0,0,0,119.3,119.3A93,93,0,0,1,191.3,193.53Z`}))]]),pw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M200,164a36.07,36.07,0,0,0-33.94,24H72a28,28,0,0,1,0-56h96a44,44,0,0,0,0-88H72a12,12,0,0,0,0,24h96a20,20,0,0,1,0,40H72a52,52,0,0,0,0,104h94.06A36,36,0,1,0,200,164Zm0,48a12,12,0,1,1,12-12A12,12,0,0,1,200,212Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,200a24,24,0,1,1-24-24A24,24,0,0,1,224,200Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M200,168a32.06,32.06,0,0,0-31,24H72a32,32,0,0,1,0-64h96a40,40,0,0,0,0-80H72a8,8,0,0,0,0,16h96a24,24,0,0,1,0,48H72a48,48,0,0,0,0,96h97a32,32,0,1,0,31-40Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,200,216Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M228,200a28,28,0,0,1-54.83,8H72a48,48,0,0,1,0-96h96a24,24,0,0,0,0-48H72a8,8,0,0,1,0-16h96a40,40,0,0,1,0,80H72a32,32,0,0,0,0,64H173.17A28,28,0,0,1,228,200Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M200,170a30.05,30.05,0,0,0-29.4,24H72a34,34,0,0,1,0-68h96a38,38,0,0,0,0-76H72a6,6,0,0,0,0,12h96a26,26,0,0,1,0,52H72a46,46,0,0,0,0,92h98.6A30,30,0,1,0,200,170Zm0,48a18,18,0,1,1,18-18A18,18,0,0,1,200,218Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M200,168a32.06,32.06,0,0,0-31,24H72a32,32,0,0,1,0-64h96a40,40,0,0,0,0-80H72a8,8,0,0,0,0,16h96a24,24,0,0,1,0,48H72a48,48,0,0,0,0,96h97a32,32,0,1,0,31-40Zm0,48a16,16,0,1,1,16-16A16,16,0,0,1,200,216Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M200,172a28,28,0,0,0-27.71,24H72a36,36,0,0,1,0-72h96a36,36,0,0,0,0-72H72a4,4,0,0,0,0,8h96a28,28,0,0,1,0,56H72a44,44,0,0,0,0,88H172.29A28,28,0,1,0,200,172Zm0,48a20,20,0,1,1,20-20A20,20,0,0,1,200,220Z`}))]]),mw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M240.49,15.51a12,12,0,0,0-17,0L173.94,65.09l-2.54-2.55a36.05,36.05,0,0,0-50.91,0L100,83l-3.51-3.52a12,12,0,0,0-17,17L83,100,62.54,120.49a36,36,0,0,0,0,50.91l2.55,2.54L15.51,223.51a12,12,0,0,0,17,17l49.57-49.58,2.54,2.55a36.06,36.06,0,0,0,50.91,0L156,173l3.51,3.52a12,12,0,0,0,17-17L173,156l20.49-20.49a36,36,0,0,0,0-50.91l-2.55-2.54,49.58-49.57A12,12,0,0,0,240.49,15.51Zm-121.95,161a12,12,0,0,1-17,0L79.51,154.43a12,12,0,0,1,0-17L100,117l39,39Zm58-57.95h0L156,139l-39-39,20.49-20.49a12,12,0,0,1,17,0l22.06,22.06a12,12,0,0,1,0,17ZM85.27,33.37a12,12,0,0,1,21.46-10.74l8,16A12,12,0,1,1,93.27,49.37Zm-68,57.26a12,12,0,0,1,16.1-5.36l16,8a12,12,0,1,1-10.74,21.46l-16-8A12,12,0,0,1,17.27,90.63Zm221.46,74.74a12,12,0,0,1-16.1,5.36l-16-8a12,12,0,0,1,10.74-21.46l16,8A12,12,0,0,1,238.73,165.37Zm-68,57.26a12,12,0,1,1-21.46,10.74l-8-16a12,12,0,0,1,21.46-10.74Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M185,127,127,185a24,24,0,0,1-33.94,0L71,162.91A24,24,0,0,1,71,129L129,71a24,24,0,0,1,33.94,0L185,93.09A24,24,0,0,1,185,127Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32.06,32.06,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94h0L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22a16,16,0,0,1,0,22.63ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM29,103.43l20,8A8,8,0,1,0,55,96.57l-20-8A8,8,0,0,0,29,103.43ZM227,152.57l-20-8A8,8,0,1,0,201,159.43l20,8A8,8,0,0,0,227,152.57ZM159.43,201A8,8,0,0,0,144.57,207l8,20A8,8,0,1,0,167.43,221ZM237.91,18.52a8,8,0,0,0-11.5-.18L174,70.75l-5.38-5.38a32,32,0,0,0-45.28,0L106.14,82.54a4,4,0,0,0,0,5.66l61.7,61.66a4,4,0,0,0,5.66,0l16.74-16.74a32.76,32.76,0,0,0,9.81-22.52,31.82,31.82,0,0,0-9.37-23.17l-5.38-5.37,52.2-52.17A8.22,8.22,0,0,0,237.91,18.52ZM85.64,90.34a8,8,0,0,0-11.49.18,8.22,8.22,0,0,0,.41,11.37L80.67,108,65.34,123.31A31.82,31.82,0,0,0,56,146.47,32.75,32.75,0,0,0,65.77,169l5,4.94L18.49,226.13a8.21,8.21,0,0,0-.61,11.1,8,8,0,0,0,11.72.43L82,185.25l5.37,5.38a32.1,32.1,0,0,0,45.29,0L148,175.31l6.34,6.35a8,8,0,0,0,11.32-11.32Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M236.24,19.76a6,6,0,0,0-8.48,0L173.94,73.57l-6.79-6.78a30,30,0,0,0-42.42,0L100,91.51l-7.76-7.75a6,6,0,0,0-8.48,8.48L91.51,100,66.79,124.73a30,30,0,0,0,0,42.42l6.78,6.79L19.76,227.76a6,6,0,1,0,8.48,8.48l53.82-53.81,6.79,6.78a30,30,0,0,0,42.42,0L156,164.49l7.76,7.75a6,6,0,0,0,8.48-8.48L164.49,156l24.72-24.73a30,30,0,0,0,0-42.42l-6.78-6.79,53.81-53.82A6,6,0,0,0,236.24,19.76Zm-113.45,161a18,18,0,0,1-25.46,0L75.27,158.67a18,18,0,0,1,0-25.46L100,108.49,147.51,156Zm57.94-57.94L156,147.51,108.49,100l24.72-24.73a18,18,0,0,1,25.46,0l22.06,22.06a18,18,0,0,1,0,25.46ZM90.43,34.23a6,6,0,0,1,11.14-4.46l8,20a6,6,0,1,1-11.14,4.46Zm-64,59.54a6,6,0,0,1,7.8-3.34l20,8a6,6,0,1,1-4.46,11.14l-20-8A6,6,0,0,1,26.43,93.77Zm203.14,68.46a6,6,0,0,1-7.8,3.34l-20-8a6,6,0,0,1,4.46-11.14l20,8A6,6,0,0,1,229.57,162.23Zm-64,59.54a6,6,0,1,1-11.14,4.46l-8-20a6,6,0,0,1,11.14-4.46Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32,32,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22A16,16,0,0,1,179.31,121.37ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M234.83,21.17a4,4,0,0,0-5.66,0L173.94,76.4l-8.2-8.2a28,28,0,0,0-39.6,0L100,94.34l-9.17-9.17a4,4,0,0,0-5.66,5.66L94.34,100,68.2,126.14a28,28,0,0,0,0,39.6l8.2,8.2L21.17,229.17a4,4,0,0,0,5.66,5.66L82.06,179.6l8.2,8.2a28,28,0,0,0,39.6,0L156,161.66l9.17,9.17a4,4,0,0,0,5.66-5.66L161.66,156l26.14-26.14a28,28,0,0,0,0-39.6l-8.2-8.2,55.23-55.23A4,4,0,0,0,234.83,21.17Zm-110.63,161a20,20,0,0,1-28.28,0L73.86,160.08a20,20,0,0,1,0-28.28L100,105.66,150.34,156Zm57.94-57.94L156,150.34,105.66,100,131.8,73.86a20,20,0,0,1,28.28,0l22.06,22.06A20,20,0,0,1,182.14,124.2ZM92.29,33.49a4,4,0,1,1,7.42-3l8,20a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,104,56a4,4,0,0,1-3.71-2.51Zm-64,61a4,4,0,0,1,5.2-2.22l20,8A4,4,0,0,1,52,108a3.91,3.91,0,0,1-1.49-.29l-20-8A4,4,0,0,1,28.29,94.51Zm199.42,67A4,4,0,0,1,224,164a3.91,3.91,0,0,1-1.49-.29l-20-8a4,4,0,1,1,3-7.42l20,8A4,4,0,0,1,227.71,161.49Zm-64,61a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,160,228a4,4,0,0,1-3.71-2.51l-8-20a4,4,0,0,1,7.42-3Z`}))]]),hw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),gw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M144,180a16,16,0,1,1-16-16A16,16,0,0,1,144,180Zm92-52A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128ZM128,64c-24.26,0-44,17.94-44,40v4a12,12,0,0,0,24,0v-4c0-8.82,9-16,20-16s20,7.18,20,16-9,16-20,16a12,12,0,0,0-12,12v8a12,12,0,0,0,23.73,2.56C158.31,137.88,172,122.37,172,104,172,81.94,152.26,64,128,64Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,168a12,12,0,1,1,12-12A12,12,0,0,1,128,192Zm8-48.72V144a8,8,0,0,1-16,0v-8a8,8,0,0,1,8-8c13.23,0,24-9,24-20s-10.77-20-24-20-24,9-24,20v4a8,8,0,0,1-16,0v-4c0-19.85,17.94-36,40-36s40,16.15,40,36C168,125.38,154.24,139.93,136,143.28Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M138,180a10,10,0,1,1-10-10A10,10,0,0,1,138,180ZM128,74c-21,0-38,15.25-38,34v4a6,6,0,0,0,12,0v-4c0-12.13,11.66-22,26-22s26,9.87,26,22-11.66,22-26,22a6,6,0,0,0-6,6v8a6,6,0,0,0,12,0v-2.42c18.11-2.58,32-16.66,32-33.58C166,89.25,149,74,128,74Zm102,54A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M140,180a12,12,0,1,1-12-12A12,12,0,0,1,140,180ZM128,72c-22.06,0-40,16.15-40,36v4a8,8,0,0,0,16,0v-4c0-11,10.77-20,24-20s24,9,24,20-10.77,20-24,20a8,8,0,0,0-8,8v8a8,8,0,0,0,16,0v-.72c18.24-3.35,32-17.9,32-35.28C168,88.15,150.06,72,128,72Zm104,56A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M136,180a8,8,0,1,1-8-8A8,8,0,0,1,136,180ZM128,76c-19.85,0-36,14.36-36,32v4a4,4,0,0,0,8,0v-4c0-13.23,12.56-24,28-24s28,10.77,28,24-12.56,24-28,24a4,4,0,0,0-4,4v8a4,4,0,0,0,8,0v-4.2c18-1.77,32-15.36,32-31.8C164,90.36,147.85,76,128,76Zm100,52A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),_w=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,36H40A20,20,0,0,0,20,56V200a20,20,0,0,0,20,20H216a20,20,0,0,0,20-20V56A20,20,0,0,0,216,36ZM44,60H76V196H44ZM212,196H100V60H212Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M88,48V208H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM40,56H80V200H40ZM216,200H96V56H216V200Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,160H88V56H216V200Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14H216a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42ZM38,200V56a2,2,0,0,1,2-2H82V202H40A2,2,0,0,1,38,200Zm180,0a2,2,0,0,1-2,2H94V54H216a2,2,0,0,1,2,2Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM40,56H80V200H40ZM216,200H96V56H216V200Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44ZM36,200V56a4,4,0,0,1,4-4H84V204H40A4,4,0,0,1,36,200Zm184,0a4,4,0,0,1-4,4H92V52H216a4,4,0,0,1,4,4Z`}))]]),vw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M124,216a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V40A12,12,0,0,1,48,28h64a12,12,0,0,1,0,24H60V204h52A12,12,0,0,1,124,216Zm108.49-96.49-40-40a12,12,0,0,0-17,17L195,116H112a12,12,0,0,0,0,24h83l-19.52,19.51a12,12,0,0,0,17,17l40-40A12,12,0,0,0,232.49,119.51Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M224,56V200a16,16,0,0,1-16,16H48V40H208A16,16,0,0,1,224,56Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40A8,8,0,0,0,176,88v32H112a8,8,0,0,0,0,16h64v32a8,8,0,0,0,13.66,5.66l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M118,216a6,6,0,0,1-6,6H48a6,6,0,0,1-6-6V40a6,6,0,0,1,6-6h64a6,6,0,0,1,0,12H54V210h58A6,6,0,0,1,118,216Zm110.24-92.24-40-40a6,6,0,0,0-8.48,8.48L209.51,122H112a6,6,0,0,0,0,12h97.51l-29.75,29.76a6,6,0,1,0,8.48,8.48l40-40A6,6,0,0,0,228.24,123.76Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M116,216a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h64a4,4,0,0,1,0,8H52V212h60A4,4,0,0,1,116,216Zm110.83-90.83-40-40a4,4,0,0,0-5.66,5.66L214.34,124H112a4,4,0,0,0,0,8H214.34l-33.17,33.17a4,4,0,0,0,5.66,5.66l40-40A4,4,0,0,0,226.83,125.17Z`}))]]),yw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M199,125.31l-49.88-18.39L130.69,57a19.92,19.92,0,0,0-37.38,0L74.92,106.92,25,125.31a19.92,19.92,0,0,0,0,37.38l49.88,18.39L93.31,231a19.92,19.92,0,0,0,37.38,0l18.39-49.88L199,162.69a19.92,19.92,0,0,0,0-37.38Zm-63.38,35.16a12,12,0,0,0-7.11,7.11L112,212.28l-16.47-44.7a12,12,0,0,0-7.11-7.11L43.72,144l44.7-16.47a12,12,0,0,0,7.11-7.11L112,75.72l16.47,44.7a12,12,0,0,0,7.11,7.11L180.28,144ZM140,40a12,12,0,0,1,12-12h12V16a12,12,0,0,1,24,0V28h12a12,12,0,0,1,0,24H188V64a12,12,0,0,1-24,0V52H152A12,12,0,0,1,140,40ZM252,88a12,12,0,0,1-12,12h-4v4a12,12,0,0,1-24,0v-4h-4a12,12,0,0,1,0-24h4V72a12,12,0,0,1,24,0v4h4A12,12,0,0,1,252,88Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M194.82,151.43l-55.09,20.3-20.3,55.09a7.92,7.92,0,0,1-14.86,0l-20.3-55.09-55.09-20.3a7.92,7.92,0,0,1,0-14.86l55.09-20.3,20.3-55.09a7.92,7.92,0,0,1,14.86,0l20.3,55.09,55.09,20.3A7.92,7.92,0,0,1,194.82,151.43Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M208,144a15.78,15.78,0,0,1-10.42,14.94L146,178l-19,51.62a15.92,15.92,0,0,1-29.88,0L78,178l-51.62-19a15.92,15.92,0,0,1,0-29.88L78,110l19-51.62a15.92,15.92,0,0,1,29.88,0L146,110l51.62,19A15.78,15.78,0,0,1,208,144ZM152,48h16V64a8,8,0,0,0,16,0V48h16a8,8,0,0,0,0-16H184V16a8,8,0,0,0-16,0V32H152a8,8,0,0,0,0,16Zm88,32h-8V72a8,8,0,0,0-16,0v8h-8a8,8,0,0,0,0,16h8v8a8,8,0,0,0,16,0V96h8a8,8,0,0,0,0-16Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M196.89,130.94,144.4,111.6,125.06,59.11a13.92,13.92,0,0,0-26.12,0L79.6,111.6,27.11,130.94a13.92,13.92,0,0,0,0,26.12L79.6,176.4l19.34,52.49a13.92,13.92,0,0,0,26.12,0L144.4,176.4l52.49-19.34a13.92,13.92,0,0,0,0-26.12Zm-4.15,14.86-55.08,20.3a6,6,0,0,0-3.56,3.56l-20.3,55.08a1.92,1.92,0,0,1-3.6,0L89.9,169.66a6,6,0,0,0-3.56-3.56L31.26,145.8a1.92,1.92,0,0,1,0-3.6l55.08-20.3a6,6,0,0,0,3.56-3.56l20.3-55.08a1.92,1.92,0,0,1,3.6,0l20.3,55.08a6,6,0,0,0,3.56,3.56l55.08,20.3a1.92,1.92,0,0,1,0,3.6ZM146,40a6,6,0,0,1,6-6h18V16a6,6,0,0,1,12,0V34h18a6,6,0,0,1,0,12H182V64a6,6,0,0,1-12,0V46H152A6,6,0,0,1,146,40ZM246,88a6,6,0,0,1-6,6H230v10a6,6,0,0,1-12,0V94H208a6,6,0,0,1,0-12h10V72a6,6,0,0,1,12,0V82h10A6,6,0,0,1,246,88Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M196.2,132.81l-53.36-19.65L123.19,59.8a11.93,11.93,0,0,0-22.38,0L81.16,113.16,27.8,132.81a11.93,11.93,0,0,0,0,22.38l53.36,19.65,19.65,53.36a11.93,11.93,0,0,0,22.38,0l19.65-53.36,53.36-19.65a11.93,11.93,0,0,0,0-22.38Zm-2.77,14.87L138.35,168a4,4,0,0,0-2.37,2.37l-20.3,55.08a3.92,3.92,0,0,1-7.36,0L88,170.35A4,4,0,0,0,85.65,168l-55.08-20.3a3.92,3.92,0,0,1,0-7.36L85.65,120A4,4,0,0,0,88,117.65l20.3-55.08a3.92,3.92,0,0,1,7.36,0L136,117.65a4,4,0,0,0,2.37,2.37l55.08,20.3a3.92,3.92,0,0,1,0,7.36ZM148,40a4,4,0,0,1,4-4h20V16a4,4,0,0,1,8,0V36h20a4,4,0,0,1,0,8H180V64a4,4,0,0,1-8,0V44H152A4,4,0,0,1,148,40Zm96,48a4,4,0,0,1-4,4H228v12a4,4,0,0,1-8,0V92H208a4,4,0,0,1,0-8h12V72a4,4,0,0,1,8,0V84h12A4,4,0,0,1,244,88Z`}))]]),bw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M100,36H56A20,20,0,0,0,36,56v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,100,36ZM96,96H60V60H96ZM200,36H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,60H160V60h36Zm-96,40H56a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,100,136Zm-4,60H60V160H96Zm104-60H156a20,20,0,0,0-20,20v44a20,20,0,0,0,20,20h44a20,20,0,0,0,20-20V156A20,20,0,0,0,200,136Zm-4,60H160V160h36Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M112,56v48a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8h48A8,8,0,0,1,112,56Zm88-8H152a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V56A8,8,0,0,0,200,48Zm-96,96H56a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V152A8,8,0,0,0,104,144Zm96,0H152a8,8,0,0,0-8,8v48a8,8,0,0,0,8,8h48a8,8,0,0,0,8-8V152A8,8,0,0,0,200,144Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M200,136H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48ZM104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,56v48a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40h48A16,16,0,0,1,120,56Zm80-16H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm-96,96H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm96,0H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M104,42H56A14,14,0,0,0,42,56v48a14,14,0,0,0,14,14h48a14,14,0,0,0,14-14V56A14,14,0,0,0,104,42Zm2,62a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2h48a2,2,0,0,1,2,2Zm94-62H152a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14h48a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,62a2,2,0,0,1-2,2H152a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2h48a2,2,0,0,1,2,2Zm-98,34H56a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14h48a14,14,0,0,0,14-14V152A14,14,0,0,0,104,138Zm2,62a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V152a2,2,0,0,1,2-2h48a2,2,0,0,1,2,2Zm94-62H152a14,14,0,0,0-14,14v48a14,14,0,0,0,14,14h48a14,14,0,0,0,14-14V152A14,14,0,0,0,200,138Zm2,62a2,2,0,0,1-2,2H152a2,2,0,0,1-2-2V152a2,2,0,0,1,2-2h48a2,2,0,0,1,2,2Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M104,40H56A16,16,0,0,0,40,56v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,104,40Zm0,64H56V56h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,64H152V56h48v48Zm-96,32H56a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,104,136Zm0,64H56V152h48v48Zm96-64H152a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h48a16,16,0,0,0,16-16V152A16,16,0,0,0,200,136Zm0,64H152V152h48v48Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M104,44H56A12,12,0,0,0,44,56v48a12,12,0,0,0,12,12h48a12,12,0,0,0,12-12V56A12,12,0,0,0,104,44Zm4,60a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4Zm92-60H152a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12h48a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,60a4,4,0,0,1-4,4H152a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4ZM104,140H56a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12h48a12,12,0,0,0,12-12V152A12,12,0,0,0,104,140Zm4,60a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V152a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4Zm92-60H152a12,12,0,0,0-12,12v48a12,12,0,0,0,12,12h48a12,12,0,0,0,12-12V152A12,12,0,0,0,200,140Zm4,60a4,4,0,0,1-4,4H152a4,4,0,0,1-4-4V152a4,4,0,0,1,4-4h48a4,4,0,0,1,4,4Z`}))]]),xw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M243,96a20.33,20.33,0,0,0-17.74-14l-56.59-4.57L146.83,24.62a20.36,20.36,0,0,0-37.66,0L87.35,77.44,30.76,82A20.45,20.45,0,0,0,19.1,117.88l43.18,37.24-13.2,55.7A20.37,20.37,0,0,0,79.57,233L128,203.19,176.43,233a20.39,20.39,0,0,0,30.49-22.15l-13.2-55.7,43.18-37.24A20.43,20.43,0,0,0,243,96ZM172.53,141.7a12,12,0,0,0-3.84,11.86L181.58,208l-47.29-29.08a12,12,0,0,0-12.58,0L74.42,208l12.89-54.4a12,12,0,0,0-3.84-11.86L41.2,105.24l55.4-4.47a12,12,0,0,0,10.13-7.38L128,41.89l21.27,51.5a12,12,0,0,0,10.13,7.38l55.4,4.47Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M229.06,108.79l-48.7,42,14.88,62.79a8.4,8.4,0,0,1-12.52,9.17L128,189.09,73.28,222.74a8.4,8.4,0,0,1-12.52-9.17l14.88-62.79-48.7-42A8.46,8.46,0,0,1,31.73,94L95.64,88.8l24.62-59.6a8.36,8.36,0,0,1,15.48,0l24.62,59.6L224.27,94A8.46,8.46,0,0,1,229.06,108.79Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M239.18,97.26A16.38,16.38,0,0,0,224.92,86l-59-4.76L143.14,26.15a16.36,16.36,0,0,0-30.27,0L90.11,81.23,31.08,86a16.46,16.46,0,0,0-9.37,28.86l45,38.83L53,211.75a16.38,16.38,0,0,0,24.5,17.82L128,198.49l50.53,31.08A16.4,16.4,0,0,0,203,211.75l-13.76-58.07,45-38.83A16.43,16.43,0,0,0,239.18,97.26Zm-15.34,5.47-48.7,42a8,8,0,0,0-2.56,7.91l14.88,62.8a.37.37,0,0,1-.17.48c-.18.14-.23.11-.38,0l-54.72-33.65a8,8,0,0,0-8.38,0L69.09,215.94c-.15.09-.19.12-.38,0a.37.37,0,0,1-.17-.48l14.88-62.8a8,8,0,0,0-2.56-7.91l-48.7-42c-.12-.1-.23-.19-.13-.5s.18-.27.33-.29l63.92-5.16A8,8,0,0,0,103,91.86l24.62-59.61c.08-.17.11-.25.35-.25s.27.08.35.25L153,91.86a8,8,0,0,0,6.75,4.92l63.92,5.16c.15,0,.24,0,.33.29S224,102.63,223.84,102.73Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M234.29,114.85l-45,38.83L203,211.75a16.4,16.4,0,0,1-24.5,17.82L128,198.49,77.47,229.57A16.4,16.4,0,0,1,53,211.75l13.76-58.07-45-38.83A16.46,16.46,0,0,1,31.08,86l59-4.76,22.76-55.08a16.36,16.36,0,0,1,30.27,0l22.75,55.08,59,4.76a16.46,16.46,0,0,1,9.37,28.86Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M237.28,97.87A14.18,14.18,0,0,0,224.76,88l-60.25-4.87-23.22-56.2a14.37,14.37,0,0,0-26.58,0L91.49,83.11,31.24,88a14.18,14.18,0,0,0-12.52,9.89A14.43,14.43,0,0,0,23,113.32L69,152.93l-14,59.25a14.4,14.4,0,0,0,5.59,15,14.1,14.1,0,0,0,15.91.6L128,196.12l51.58,31.71a14.1,14.1,0,0,0,15.91-.6,14.4,14.4,0,0,0,5.59-15l-14-59.25L233,113.32A14.43,14.43,0,0,0,237.28,97.87Zm-12.14,6.37-48.69,42a6,6,0,0,0-1.92,5.92l14.88,62.79a2.35,2.35,0,0,1-.95,2.57,2.24,2.24,0,0,1-2.6.1L131.14,184a6,6,0,0,0-6.28,0L70.14,217.61a2.24,2.24,0,0,1-2.6-.1,2.35,2.35,0,0,1-1-2.57l14.88-62.79a6,6,0,0,0-1.92-5.92l-48.69-42a2.37,2.37,0,0,1-.73-2.65,2.28,2.28,0,0,1,2.07-1.65l63.92-5.16a6,6,0,0,0,5.06-3.69l24.63-59.6a2.35,2.35,0,0,1,4.38,0l24.63,59.6a6,6,0,0,0,5.06,3.69l63.92,5.16a2.28,2.28,0,0,1,2.07,1.65A2.37,2.37,0,0,1,225.14,104.24Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M239.18,97.26A16.38,16.38,0,0,0,224.92,86l-59-4.76L143.14,26.15a16.36,16.36,0,0,0-30.27,0L90.11,81.23,31.08,86a16.46,16.46,0,0,0-9.37,28.86l45,38.83L53,211.75a16.38,16.38,0,0,0,24.5,17.82L128,198.49l50.53,31.08A16.4,16.4,0,0,0,203,211.75l-13.76-58.07,45-38.83A16.43,16.43,0,0,0,239.18,97.26Zm-15.34,5.47-48.7,42a8,8,0,0,0-2.56,7.91l14.88,62.8a.37.37,0,0,1-.17.48c-.18.14-.23.11-.38,0l-54.72-33.65a8,8,0,0,0-8.38,0L69.09,215.94c-.15.09-.19.12-.38,0a.37.37,0,0,1-.17-.48l14.88-62.8a8,8,0,0,0-2.56-7.91l-48.7-42c-.12-.1-.23-.19-.13-.5s.18-.27.33-.29l63.92-5.16A8,8,0,0,0,103,91.86l24.62-59.61c.08-.17.11-.25.35-.25s.27.08.35.25L153,91.86a8,8,0,0,0,6.75,4.92l63.92,5.16c.15,0,.24,0,.33.29S224,102.63,223.84,102.73Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M235.36,98.49A12.21,12.21,0,0,0,224.59,90l-61.47-5L139.44,27.67a12.37,12.37,0,0,0-22.88,0L92.88,85,31.41,90a12.45,12.45,0,0,0-7.07,21.84l46.85,40.41L56.87,212.64a12.35,12.35,0,0,0,18.51,13.49L128,193.77l52.62,32.36a12.12,12.12,0,0,0,13.69-.51,12.28,12.28,0,0,0,4.82-13l-14.32-60.42,46.85-40.41A12.29,12.29,0,0,0,235.36,98.49Zm-8.93,7.26-48.68,42a4,4,0,0,0-1.28,3.95l14.87,62.79a4.37,4.37,0,0,1-1.72,4.65,4.24,4.24,0,0,1-4.81.18L130.1,185.67a4,4,0,0,0-4.2,0L71.19,219.32a4.24,4.24,0,0,1-4.81-.18,4.37,4.37,0,0,1-1.72-4.65L79.53,151.7a4,4,0,0,0-1.28-3.95l-48.68-42A4.37,4.37,0,0,1,28.25,101a4.31,4.31,0,0,1,3.81-3L96,92.79a4,4,0,0,0,3.38-2.46L124,30.73a4.35,4.35,0,0,1,8.08,0l24.62,59.6A4,4,0,0,0,160,92.79l63.9,5.15a4.31,4.31,0,0,1,3.81,3A4.37,4.37,0,0,1,226.43,105.75Z`}))]]),Sw=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M116,36V20a12,12,0,0,1,24,0V36a12,12,0,0,1-24,0Zm80,92a68,68,0,1,1-68-68A68.07,68.07,0,0,1,196,128Zm-24,0a44,44,0,1,0-44,44A44.05,44.05,0,0,0,172,128ZM51.51,68.49a12,12,0,1,0,17-17l-12-12a12,12,0,0,0-17,17Zm0,119-12,12a12,12,0,0,0,17,17l12-12a12,12,0,1,0-17-17ZM196,72a12,12,0,0,0,8.49-3.51l12-12a12,12,0,0,0-17-17l-12,12A12,12,0,0,0,196,72Zm8.49,115.51a12,12,0,0,0-17,17l12,12a12,12,0,0,0,17-17ZM48,128a12,12,0,0,0-12-12H20a12,12,0,0,0,0,24H36A12,12,0,0,0,48,128Zm80,80a12,12,0,0,0-12,12v16a12,12,0,0,0,24,0V220A12,12,0,0,0,128,208Zm108-92H220a12,12,0,0,0,0,24h16a12,12,0,0,0,0-24Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M184,128a56,56,0,1,1-56-56A56,56,0,0,1,184,128Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm8,24a64,64,0,1,0,64,64A64.07,64.07,0,0,0,128,64ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M122,40V16a6,6,0,0,1,12,0V40a6,6,0,0,1-12,0Zm68,88a62,62,0,1,1-62-62A62.07,62.07,0,0,1,190,128Zm-12,0a50,50,0,1,0-50,50A50.06,50.06,0,0,0,178,128ZM59.76,68.24a6,6,0,1,0,8.48-8.48l-16-16a6,6,0,0,0-8.48,8.48Zm0,119.52-16,16a6,6,0,1,0,8.48,8.48l16-16a6,6,0,1,0-8.48-8.48ZM192,70a6,6,0,0,0,4.24-1.76l16-16a6,6,0,0,0-8.48-8.48l-16,16A6,6,0,0,0,192,70Zm4.24,117.76a6,6,0,0,0-8.48,8.48l16,16a6,6,0,0,0,8.48-8.48ZM46,128a6,6,0,0,0-6-6H16a6,6,0,0,0,0,12H40A6,6,0,0,0,46,128Zm82,82a6,6,0,0,0-6,6v24a6,6,0,0,0,12,0V216A6,6,0,0,0,128,210Zm112-88H216a6,6,0,0,0,0,12h24a6,6,0,0,0,0-12Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M124,40V16a4,4,0,0,1,8,0V40a4,4,0,0,1-8,0Zm64,88a60,60,0,1,1-60-60A60.07,60.07,0,0,1,188,128Zm-8,0a52,52,0,1,0-52,52A52.06,52.06,0,0,0,180,128ZM61.17,66.83a4,4,0,0,0,5.66-5.66l-16-16a4,4,0,0,0-5.66,5.66Zm0,122.34-16,16a4,4,0,0,0,5.66,5.66l16-16a4,4,0,0,0-5.66-5.66ZM192,68a4,4,0,0,0,2.83-1.17l16-16a4,4,0,1,0-5.66-5.66l-16,16A4,4,0,0,0,192,68Zm2.83,121.17a4,4,0,0,0-5.66,5.66l16,16a4,4,0,0,0,5.66-5.66ZM40,124H16a4,4,0,0,0,0,8H40a4,4,0,0,0,0-8Zm88,88a4,4,0,0,0-4,4v24a4,4,0,0,0,8,0V216A4,4,0,0,0,128,212Zm112-88H216a4,4,0,0,0,0,8h24a4,4,0,0,0,0-8Z`}))]]),Cw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:aw}));Cw.displayName=`BellIcon`;var ww=Cw,Tw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:ow}));Tw.displayName=`BookOpenIcon`;var Ew=Tw,Dw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:sw}));Dw.displayName=`ChatCircleIcon`;var Ow=Dw,kw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:cw}));kw.displayName=`CompassIcon`;var Aw=kw,jw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:lw}));jw.displayName=`GearIcon`;var Mw=jw,Nw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:uw}));Nw.displayName=`ListMagnifyingGlassIcon`;var Pw=Nw,Fw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:dw}));Fw.displayName=`MagnifyingGlassIcon`;var Iw=Fw,Lw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:fw}));Lw.displayName=`MoonIcon`;var Rw=Lw,zw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:pw}));zw.displayName=`PathIcon`;var Bw=zw,Vw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:mw}));Vw.displayName=`PlugsConnectedIcon`;var Hw=Vw,Uw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:hw}));Uw.displayName=`PlusIcon`;var Ww=Uw,Gw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:gw}));Gw.displayName=`QuestionIcon`;var Kw=Gw,qw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:_w}));qw.displayName=`SidebarSimpleIcon`;var Jw=qw,Yw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:vw}));Yw.displayName=`SignOutIcon`;var Xw=Yw,Zw=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:yw}));Zw.displayName=`SparkleIcon`;var Qw=Zw,$w=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:bw}));$w.displayName=`SquaresFourIcon`;var eT=$w,tT=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:xw}));tT.displayName=`StarIcon`;var nT=tT,rT=k.forwardRef((e,t)=>k.createElement(qe,{ref:t,...e,weights:Sw}));rT.displayName=`SunIcon`;var iT=rT,aT=[`agent-threads`];async function oT(e){let t=await Wt(e);if(!t.ok)throw Error(`Request failed (${t.status})`);return t.json()}var sT=new Set([`create_dashboard`,`edit_dashboard`,`replace_dashboard`,`restore_dashboard_version`]);function cT(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function lT(e){if(typeof e==`string`)try{let t=JSON.parse(e);if(cT(t))return t}catch{}}var uT=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),dT=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0;function fT(e){return cT(e)&&typeof e.id==`string`&&[`ok`,`empty`,`error`,`invalid`,`not_run`,`partial`,`stale`].includes(String(e.status))&&(e.rows===void 0||dT(e.rows))&&(e.elapsed_ms===void 0||dT(e.elapsed_ms))&&(e.diagnosis===void 0||typeof e.diagnosis==`string`)&&(e.error===void 0||typeof e.error==`string`)}function pT(e){if(!cT(e)||!Number.isInteger(e.base_version)||Number(e.base_version)<0||!Number.isInteger(e.version)||Number(e.version)<1||!Array.isArray(e.changes)||typeof e.layout_changed!=`boolean`||e.dashboard_fields!==void 0&&!uT(e.dashboard_fields)||!e.changes.every(e=>cT(e)&&typeof e.panel_id==`string`&&typeof e.title==`string`&&[`added`,`changed`,`removed`].includes(String(e.kind))&&(e.fields===void 0||uT(e.fields)&&!e.fields.includes(`grid`))&&(e.position_changed===void 0||typeof e.position_changed==`boolean`)))return!1;let t=e.save_check;return cT(t)&&typeof t.checked==`boolean`&&dT(t.elapsed_ms)&&Array.isArray(t.panels)&&t.panels.every(e=>fT(e)&&Number.isInteger(e.rows)&&Number(e.rows)>=0)&&new Set(t.panels.map(e=>e.id)).size===t.panels.length&&(t.reason===void 0||typeof t.reason==`string`)&&(!t.checked||t.panels.every(e=>e.status!==`not_run`))}function mT(e,t,n){let r=-1;n.forEach((n,i)=>{n.role===`tool`&&n.toolCallId===e&&n.content===t&&(r=i)});let i=r<0?n.length:r,a=-1;if(n.slice(0,i).forEach((e,t)=>{e.role===`user`&&(a=t)}),a<0)return null;let o=n.slice(a+1,i).flatMap(e=>e.role===`assistant`?e.toolCalls??[]:[]).filter(t=>t.id===e),s=o.length===1?o[0].function.name:void 0;if(!s||!sT.has(s))return null;let c=lT(t),l=c?.dashboard,u=c?.receipt;return!c||c.error||c.isError||!cT(l)||typeof l.id!=`string`||!l.id||typeof l.name!=`string`||!l.name||!pT(u)||l.version!==u.version||r>=0&&n[r].error?null:{id:l.id,name:l.name,version:u.version,label:s===`create_dashboard`?`Created`:s===`restore_dashboard_version`?`Restored`:`Updated`,receipt:u}}var hT={viz:`chart type`,sql:`SQL`,content:`text`,x_unit:`x-axis unit`,options:`display options`,drill:`drill-down`,click:`click action`,time:`time range`,annotations:`markers`,better:`better direction`,reduce:`summary`,min:`minimum`,max:`maximum`},gT=e=>Object.hasOwn(hT,e)?hT[e]:e.replaceAll(`_`,` `),_T=e=>e.kind===`added`?`+ ${e.title}`:e.kind===`removed`?`− ${e.title}`:`~ ${e.title}${e.fields?.length?`: `+e.fields.map(gT).join(`, `):``}${e.position_changed?` · moved`:``}`;function vT(e){return[...e.changes.map(_T),...e.layout_changed?[`Layout adjusted`]:[],...e.dashboard_fields?.map(e=>`Dashboard: ${gT(e)}`)??[]]}function yT(e,t,n){return e.filter(e=>n.has(e.panel_id)&&!t.some(t=>t.panel_id===e.panel_id&&t.path===e.path))}var bT={schema:`Telemetry`,context:`Context`,draft:`Draft`,validation:`Validation`,preview:`Preview`,save:`Save`},xT=new Set([`get_insights`,`query_telemetry`,`get_overview`,`get_service_topology`,`get_service_dependencies`,`get_service_performance`,`inspect_trace`,`search_logs`]),ST=(e,t)=>Array.isArray(e)?e.flatMap(e=>cT(e)&&typeof e.path==`string`&&typeof e.message==`string`?[{panel_id:t,path:e.path,message:e.message}]:[]):[],CT=e=>{let t=lT(e)?.error;return cT(t)?t.code:void 0},wT=e=>e.role===`tool`&&CT(e.content)===`interrupted`,TT=e=>![`invalid`,`not_run`].includes(e.status);function ET(e,t){let n=e.findIndex(e=>e.id===t&&e.role===`user`);if(n<0)return null;let r=e.findIndex((e,t)=>t>n&&e.role===`user`),i=e.slice(n+1,r<0?void 0:r),a=new Set(i.flatMap(e=>e.role===`tool`&&CT(e.content)===`answer_only`?[e.toolCallId]:[])),o=i.flatMap((e,t)=>e.role===`assistant`?(e.toolCalls??[]).map(e=>({call:e,index:t})):[]).filter(({call:e})=>!a.has(e.id));if(!o.some(({call:e})=>sT.has(e.function.name)||e.function.name===`preview_panels`))return null;let s={schema:{state:`unobserved`},context:{state:`unobserved`},draft:{state:`unobserved`},validation:{state:`unobserved`},preview:{state:`unobserved`},save:{state:`unobserved`}},c={turn_id:t,stages:s,panel_titles:{},panels:[],problems:[],corrections:[],save_attempts:[],explanations:[],context_counts:{deploys:0,anomalies:0}},l=new Map,u=new Map;for(let{call:e}of o)l.set(e.id,(l.get(e.id)??0)+1);i.forEach((e,t)=>{if(e.role===`tool`){let n=u.get(e.toolCallId)??[];n.push({index:t,message:e}),u.set(e.toolCallId,n)}});let d=new Map,f=new Map,p=[],m,h=!1,g=!1,_=(e,t)=>{for(let n of yT(y.get(e)??[],t,new Set([e])))p.some(e=>e.panel_id===n.panel_id&&e.path===n.path)||p.push(n);y.set(e,t)},v=new Map,y=new Map,b=new Set,x=!1,ee=!1;for(let{call:t,index:n}of o){if(l.get(t.id)!==1)continue;let r=t.function.name,i=lT(t.function.arguments),a=(u.get(t.id)??[]).filter(e=>e.index>n),o=a.length===1||sT.has(r)&&a.length>1&&a.slice(0,-1).every(e=>wT(e.message))?a.at(-1).message:void 0,S=o&&lT(o.content),C=!!S&&o?.role===`tool`&&!o.error&&!S.error&&!S.isError,te=o?C?`complete`:`failed`:`incomplete`;if(r===`get_telemetry_schema`&&(s.schema={state:te}),xT.has(r)){let e=o?.role===`tool`&&!o.error&&!S?.error&&!S?.isError&&typeof o.content==`string`&&o.content.length>0;if(s.context={state:o?e?`complete`:`failed`:`incomplete`},C)for(let[e,t]of[[`deploys`,[`deploys`,`deployments`]],[`anomalies`,[`anomalies`]]])for(let n of t)Array.isArray(S[n])&&(c.context_counts[e]+=S[n].length)}if(r===`preview_panels`||r===`create_dashboard`||r===`replace_dashboard`){let e=r===`preview_panels`?i?.panels:cT(i?.dashboard)?i.dashboard.panels:void 0;if(Array.isArray(e)){c.panel_count=e.length,s.draft={state:`complete`};for(let t of e)cT(t)&&typeof t.id==`string`&&typeof t.title==`string`&&t.title.trim()&&f.set(t.id,t.title)}}if(r===`preview_panels`){x=!0;let e=Array.isArray(i?.panels)?i.panels.flatMap(e=>cT(e)&&typeof e.id==`string`?[e.id]:[]):[];for(let t of e)v.set(t,{id:t,status:`not_run`});let t=C&&Array.isArray(S.panels)&&S.panels.every(fT)?S.panels:void 0,n=typeof S?.elapsed_ms==`number`&&S.elapsed_ms>=0?S.elapsed_ms:void 0;if(s.validation={state:t?t.some(e=>e.status===`invalid`||e.status===`not_run`)||ST(S?.problems,`dashboard`).length?`failed`:`complete`:te===`complete`?`failed`:te},s.preview={state:t?t.every(TT)?`complete`:`incomplete`:te===`complete`?`failed`:te,elapsed_ms:n},!t||e.length===0||t.length!==e.length||new Set(t.map(e=>e.id)).size!==e.length||t.some(t=>!e.includes(t.id))){ee=e.length===0;for(let t of e)o&&b.add(t);continue}ee=!1;for(let t of e)b.delete(t);for(let e of t){let t=ST(e.problems,e.id);if(e.status!==`not_run`)_(e.id,t);else{let n=y.get(e.id)??[];y.set(e.id,[...n,...t.filter(e=>!n.some(t=>t.path===e.path))])}v.set(e.id,e)}c.problems=[...y.values()].flat().concat(ST(S?.problems,`dashboard`))}if(sT.has(r)){let n=o&&mT(t.id,o.content,e),r=!!o&&wT(o),i=!r&&o?.role===`tool`&&(!!o.error||!!S?.error||!!S?.isError);if(g=!!i,h=!!o&&!n&&!i&&!r,s.save={state:n?`complete`:r?`interrupted`:i?`failed`:`incomplete`},n)for(let e of c.save_attempts)e.state===`failed`&&(e.state=`retried`);if(c.save_attempts.push({call_id:t.id,state:s.save.state}),n){m?.id!==n.id&&(m=n,d.clear());for(let e of n.receipt.changes){e.title.trim()&&f.set(e.panel_id,e.title);let t=d.get(e.panel_id);if(t?.kind===`added`&&e.kind===`removed`){d.delete(e.panel_id);continue}if(t?.kind===`added`){d.set(e.panel_id,{panel_id:e.panel_id,title:e.title,kind:`added`});continue}if(e.kind===`removed`){d.set(e.panel_id,e);continue}t&&e.kind===`changed`?d.set(e.panel_id,{...e,fields:[...new Set([...t.fields??[],...e.fields??[]])].sort(),position_changed:t.position_changed||e.position_changed}):d.set(e.panel_id,t?.kind===`removed`&&e.kind===`added`?{...e,kind:`changed`}:e)}let e=S?.dashboard,t=cT(e)?e.spec:void 0;if(cT(t)&&Array.isArray(t.panels))for(let e of t.panels)cT(e)&&typeof e.id==`string`&&typeof e.title==`string`&&e.title.trim()&&f.set(e.id,e.title);let r=c.saved?.id===n.id?c.saved.receipt:void 0;c.saved={...n,label:m.label,receipt:{...n.receipt,base_version:m.receipt.base_version,changes:[...d.values()],layout_changed:m.receipt.base_version!==0&&(n.receipt.layout_changed||!!r?.layout_changed),dashboard_fields:m.receipt.base_version===0?void 0:[...new Set([...r?.dashboard_fields??[],...n.receipt.dashboard_fields??[]])].sort()}},c.panel_count=n.receipt.save_check.panels.length,s.draft={state:`complete`};let i=new Set(n.receipt.save_check.panels.map(e=>e.id));for(let e of n.receipt.save_check.panels)e.status===`invalid`?_(e.id,ST(e.problems,e.id)):TT(e)&&(_(e.id,[]),b.delete(e.id));p=p.filter(e=>i.has(e.panel_id)),c.problems=[...y.values()].flat().filter(e=>i.has(e.panel_id))}}}if(h)return null;c.panel_titles=Object.fromEntries(f),c.corrections=p.map(e=>({...e,title:f.get(e.panel_id)??e.panel_id}));let S=c.saved?new Set(c.saved.receipt.save_check.panels.map(e=>e.id)):void 0;if(c.panels=[...v.values()].filter(e=>!S||S.has(e.id)),x){let e=ee||[...b].some(e=>!S||S.has(e)),t=c.panels.some(e=>e.status===`not_run`),n=c.problems.length>0;s.validation.state=e||n?`failed`:t?`incomplete`:`complete`,s.preview.state=e?`failed`:t||n||c.panels.some(e=>e.status===`invalid`)?`incomplete`:`complete`}let C=c.saved?.receipt.save_check;C&&!C.checked&&c.explanations.push(`Save check incomplete: ${C.reason||`Panels were not checked`}`);for(let e of C?.panels??c.panels)e.status!==`ok`&&c.explanations.push(`${f.get(e.id)??e.id}: ${e.status}${e.error||e.diagnosis?` — ${e.error||e.diagnosis}`:``}`);for(let e of c.problems)c.explanations.push(`${f.get(e.panel_id)??e.panel_id}: ${e.message}`);let te=Object.entries(s).filter(([,e])=>e.state===`incomplete`||e.state===`failed`).map(([e,t])=>`${bT[e]}: ${t.state}`);return te.length&&c.explanations.push(te.join(` · `)),s.save.state===`interrupted`&&c.explanations.push(`Save interrupted · outcome unknown`),g&&c.explanations.push(c.saved?`A later change failed; v${c.saved.version} remains saved`:`Save failed · dashboard was not saved`),c}var DT=(0,k.createContext)(null);function OT(){let e=(0,k.useContext)(DT);if(!e)throw Error(`Pitot app context is unavailable`);return e}var kT=`Build me a dashboard for my services, showing request volume, latency, and errors. Ask me which services to monitor first.`,AT={query_telemetry:{activity:`Querying telemetry…`,title:`Telemetry panels`},get_overview:{activity:`Checking system health…`,title:`System health`},get_service_topology:{activity:`Mapping service dependencies…`,title:`Service map`},get_service_dependencies:{activity:`Tracing service dependencies…`,title:`Service dependencies`},list_panel_exemplars:{activity:`Finding example traces…`,title:`Example traces`},resolve_panel_variables:{activity:`Reading filter choices…`,title:`Filter choices`},query_panel_fragment:{activity:`Refreshing panels…`,title:`Panel refresh`},get_service_performance:{activity:`Reading performance signals…`,title:`Performance`},inspect_trace:{activity:`Inspecting a trace…`,title:`Trace lookup`},search_logs:{activity:`Searching logs…`,title:`Logs`},get_insights:{activity:`Reviewing detected anomalies…`,title:`Detected anomalies`},get_telemetry_schema:{activity:`Reading what telemetry exists…`,title:`Telemetry discovery`},preview_panels:{activity:`Checking dashboard panels…`,title:`Panel check`},list_dashboards:{activity:`Looking through your dashboards…`,title:`Dashboards`},get_dashboard:{activity:`Opening your dashboard…`,title:`Dashboard`},create_dashboard:{activity:`Building your dashboard…`,title:`Dashboard save`},edit_dashboard:{activity:`Updating your dashboard…`,title:`Dashboard save`},replace_dashboard:{activity:`Redesigning your dashboard…`,title:`Dashboard save`},list_dashboard_versions:{activity:`Reading your dashboard history…`,title:`Dashboard history`},restore_dashboard_version:{activity:`Restoring your dashboard…`,title:`Dashboard`}};function jT(e){return AT[e]?.activity??`Working on it…`}function MT(e){return AT[e]?.title??`Analysis step`}function NT(e){switch(e){case`provider_unavailable`:return`Pitot could not reach the model provider. Please try again.`;case`step_limit`:return`Pitot reached its step limit before finishing. Try a narrower question.`;case`time_limit`:return`Pitot reached its 5-minute time limit. Try a smaller request.`;default:return`Pitot could not complete this analysis. Please try again.`}}function PT(e){let t=(0,k.useRef)(new Map);return(0,k.useMemo)(()=>{let n=new Map,r=new Set,i=e.flatMap((e,t)=>e.role===`user`?[t]:[]);i.forEach((a,o)=>{let s=i[o+1]??e.length,c=e[a],l=e[s-1];r.add(c.id);let u=t.current.get(c.id),d=u&&u.last===l&&u.length===s-a?u.receipt:ET(e.slice(a,s),c.id);oe.msecs?(e.seq=UT(n),e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function HT(e,t,n,r,i=0){if(e.length<16)throw Error(`Random bytes length must be >= 16`);if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),n??=UT(e),r[i++]=t/1099511627776&255,r[i++]=t/4294967296&255,r[i++]=t/16777216&255,r[i++]=t/65536&255,r[i++]=t/256&255,r[i++]=t&255,r[i++]=112|n>>>28&15,r[i++]=n>>>20&255,r[i++]=128|n>>>14&63,r[i++]=n>>>6&255,r[i++]=n<<2&255|e[10]&3,r[i++]=e[11],r[i++]=e[12],r[i++]=e[13],r[i++]=e[14],r[i++]=e[15],r}function UT(e){return(e[6]&127)<<24|e[7]<<16|e[8]<<8|e[9]}function WT(){return BT()}function GT(){let{setColorScheme:e}=ar(),t=cr(`light`,{getInitialValueInEffect:!0}),n=t===`dark`?`light`:`dark`,[r,i]=(0,k.useState)(!1);return(0,A.jsx)(Bi,{label:`Switch to ${n} theme`,opened:r,children:(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,"aria-label":`Switch to ${n} theme`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),onClick:()=>{i(!1),e(n)},children:t===`dark`?(0,A.jsx)(iT,{size:17,weight:`bold`}):(0,A.jsx)(Rw,{size:17,weight:`bold`})})})}function KT(){let e=(0,k.useRef)(null);return(0,k.useRef)({remember(t){e.current=t instanceof HTMLElement?t:null},restore(t){let n=e.current;requestAnimationFrame(()=>(n?.isConnected?n:t)?.focus())}}).current}var qT=`pitot:shortcuts`,JT=0,YT=new Set,XT=()=>{for(let e of YT)e()};function ZT(e){(0,k.useEffect)(()=>(window.addEventListener(qT,e),JT+=1,XT(),()=>{window.removeEventListener(qT,e),--JT,XT()}),[e])}function QT(){return(0,k.useSyncExternalStore)(e=>(YT.add(e),()=>YT.delete(e)),()=>JT>0,()=>!1)}function $T(){let e=QT(),t=(0,k.useRef)(null);return(0,A.jsxs)(Ot,{position:`bottom-end`,withinPortal:!0,shadow:`md`,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Bi,{label:`Help`,children:(0,A.jsx)(Ne,{ref:t,variant:`subtle`,color:`gray`,"aria-label":`Help`,children:(0,A.jsx)(Kw,{size:18,weight:`bold`})})})}),(0,A.jsxs)(Ot.Dropdown,{children:[(0,A.jsx)(Ot.Item,{component:`a`,href:Gt.home,target:`_blank`,rel:`noopener noreferrer`,leftSection:(0,A.jsx)(Ew,{size:15}),children:`Documentation`}),e&&(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Et,{size:15}),rightSection:(0,A.jsx)(Ei,{size:`xs`,children:`?`}),onClick:()=>{t.current?.focus(),window.dispatchEvent(new Event(qT))},children:`Keyboard shortcuts`})]})]})}var eE=new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}),tE=new Intl.NumberFormat(`en`,{maximumFractionDigits:2});function nE(e){return Math.abs(e)<1e-4?e.toExponential(2).replace(/\.?(0+)(?=e)/,``):String(Number(e.toPrecision(3)))}function rE(e,t=tE){return e!==0&&Math.abs(e)<1?nE(e):t.format(e)}function iE(e,t){let n=t===`s`?e*1e3:t===`ns`?e/1e6:e;return e!==0&&n===0?`${nE(e)} ${t}`:n!==0&&Math.abs(n)<1?`${nE(n)} ms`:Ut(n)}var aE=[`B`,`KiB`,`MiB`,`GiB`,`TiB`];function oE(e){let t=e,n=0;for(;Math.abs(t)>=1024&&n=1e4?eE:tE);default:return rE(t,Math.abs(t)>=1e4?eE:tE)}}var cE={ms:1,s:1e3,ns:1e-6},lE=[[36e5,`h`],[6e4,`m`],[1e3,`s`],[1,`ms`]];function uE(e,t){let n=e===void 0?void 0:cE[e];if(e===`bytes`&&t&&t.interval>0){let e=Math.max(Math.abs(t.min),Math.abs(t.max)),n=[4,3,2,1].find(n=>e>=1024**n&&Math.abs(t.interval/1024**n*100-Math.round(t.interval/1024**n*100))<1e-6)??0;return e=>Number.isFinite(e)?`${rE(e/1024**n)} ${aE[n]}`:`—`}if(e===`percent`&&t&&t.interval>0){let e=[0,1,2,3,4].find(e=>{let n=t.interval*10**e;return Math.round(n)!==0&&Math.abs(n-Math.round(n))<1e-6*Math.abs(n)});if(e!==void 0){let t=new Intl.NumberFormat(`en`,{minimumFractionDigits:e,maximumFractionDigits:e});return e=>Number.isFinite(e)?`${t.format(e)}%`:`—`}}if(n!==void 0&&t&&t.interval>0){let e=Math.max(Math.abs(t.min),Math.abs(t.max))*n,r=t.interval*n,[i,a]=lE.find(([t])=>e>=t&&Math.abs(r/t*100-Math.round(r/t*100))<1e-6)??[1,`ms`];return e=>Number.isFinite(e)?`${rE(e*n/i)} ${a}`:`—`}return t=>(!e||e===`count`)&&Math.abs(t)>=1e3?rE(t,eE):e===`ms`||e===`s`||e===`ns`?sE(e,t).replace(/(\.\d*?)0+([a-z]*)$/,`$1$2`).replace(/\.([a-z]*)$/,`$1`):sE(e,t)}function dE(e){return e!==void 0&&e!==`count`&&/[^\d\s]$/.test(uE(e)(1).trim())}function fE(e,t,n){return uE(e,n)(t??NaN).replace(/(?<=\d)(ms|ns|s|m|h)\b/g,` $1`)}function pE(e){return Math.max(3,Math.min(10,Math.round(e/70)))-1}function mE(e,t){let n=t===`ms`?1:t===`s`?1e3:t===`ns`?1e-6:void 0,r=e=>{let t=10**Math.floor(Math.log10(e));return[1,2,5,10].map(e=>e*t).find(t=>t>=e)};if(t===`bytes`){let t=Math.min(4,Math.max(0,Math.floor(Math.log(e)/Math.log(1024)))),n=r(Math.max(e/1024**t,+(t===0)));return(n>=1e3&&t<4?1024:n)*1024**t}if(n===void 0)return r(e);let i=e*n,a=[1,10,100,1e3,1e4,6e4,6e5,36e5,36e6].flatMap(e=>[1,2,5].map(t=>e*t)).sort((e,t)=>e-t);return(i<1?r(i):a.find(e=>e>=i)??r(i/36e5)*36e5)/n}function hE(e,t,n,r){e=Number.isFinite(e)?Math.min(0,e):0,t=Number.isFinite(t)?Math.max(0,t):1,t===e&&(t=e+1);let i=pE(r),a=mE(Math.max(t-e,2**-52)/i,n);for(let r=0;r<64&&Math.ceil(t/a)-Math.floor(e/a)>i;r++)a=mE(a*1.01,n);return{min:Math.floor(e/a)*a,max:Math.ceil(t/a)*a,interval:a,splitNumber:i,pitot_unit:n}}function gE(e,t){if(e.type!==`value`&&e.type!==`log`)return e;if(e.type!==`value`||typeof e.min!=`number`||typeof e.max!=`number`)return{...e,splitNumber:pE(t)};let n=typeof e.pitot_unit==`string`?e.pitot_unit:void 0,r=hE(e.min,e.max,n,t);return{...e,...r,...n&&(n in cE||n===`bytes`||n===`percent`)?{axisLabel:{...e.axisLabel,formatter:uE(n,r)}}:{}}}function _E(e,t,n){let r=e=>sE(n,e),i=``;if(n===`ms`||n===`s`||n===`ns`){let a=n===`s`?1e3:n===`ns`?1e-6:1,o=Math.abs((e??t??0)*a),s=o>=6e4?6e4:o>=1e3?1e3:1;i=s===6e4?` min`:s===1e3?` s`:` ms`;let c=s===6e4?1:s===1e3?+(o<1e4):2,l=new Intl.NumberFormat(void 0,{maximumFractionDigits:c});r=e=>l.format(e*a/s)}return t===null&&e!==null?`≥${r(e)}${i}`:(e===null||e===0)&&t!==null?`<${r(t)}${i}`:`${e===null?`−∞`:r(e)}–${t===null?`∞`:r(t)}${i}`}function vE(e){let t=new Date(e);return t.getHours()===0&&t.getMinutes()===0&&t.getSeconds()===0?t.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}function yE(e,t=new Date,n){let r=new Date(e);if(!Number.isFinite(r.getTime()))return`—`;let i=new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`,...r.getFullYear()===t.getFullYear()?{}:{year:`numeric`},hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(r),a=i.filter(e=>[`month`,`day`,`year`].includes(e.type)).map(e=>e.value),o=i.filter(e=>[`hour`,`minute`,`second`].includes(e.type)).map(e=>e.value);return`${a.join(` `)} ${o.join(`:`)}`}var bE=[{path:`/explore`,label:`Explore`,Icon:Aw},{path:`/logs`,label:`Logs`,Icon:Pw},{path:`/traces`,label:`Traces`,Icon:Bw},{path:`/alerts`,label:`Alerts`,Icon:ww},{path:`/settings`,label:`Settings`,Icon:Mw}];async function xE(e,t){let n=new URLSearchParams({page_size:`30`});e&&n.set(`q`,e),t&&n.set(`cursor`,t);let r=await Wt(`/api/agent/threads?${n}`);if(!r.ok)throw Error(`Unable to load chats (${r.status})`);return r.json()}function SE({collapsed:e=!1,agentAvailable:t,activeThreadID:n,activeDashboardID:r,activePath:i,autoFocusSearch:a=!1,onNewChat:o,onSelectThread:s,onDeletedThread:l,onSelectDashboard:d,onCreateDashboard:f,onNewDashboard:p,onNavigate:h,onInvestigateService:g,ref:_}){let v=Zt(),[y,b]=(0,k.useState)(``),[x]=er(y.trim(),250),[ee,S]=(0,k.useState)(null),[C,w]=(0,k.useState)(null),[ne,re]=(0,k.useState)(``),[ie,ae]=(0,k.useState)(``),[oe,se]=(0,k.useState)(!1),ce=(0,k.useRef)(null);(0,k.useImperativeHandle)(_,()=>({focusSearch:()=>ce.current?.focus()}),[]),(0,k.useEffect)(()=>{a&&requestAnimationFrame(()=>ce.current?.focus())},[a]);let le=iw({queryKey:[...aT,x],queryFn:({pageParam:e})=>xE(x,e),initialPageParam:``,getNextPageParam:e=>e.next_cursor??void 0,enabled:t}),ue=hn({queryKey:Pt,queryFn:It,refetchInterval:3e4,staleTime:Nt}),de=(0,k.useMemo)(()=>le.data?.pages.flatMap(e=>e.items)??[],[le.data]),pe=(0,k.useMemo)(()=>OE(de),[de]),T=hn({queryKey:[`telemetry-schema`,`1h`],queryFn:()=>oT(`/api/telemetry/schema?window=1h`),enabled:t&&!!x&&!!g,staleTime:6e4}),me=(0,k.useMemo)(()=>{if(!x)return[];let e=x.toLowerCase();return(T.data?.services??[]).map(e=>e.value).filter(t=>t.toLowerCase().includes(e)).slice(0,6)},[T.data,x]),he=(0,k.useMemo)(()=>{let e=ue.data??[],t=x.toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)):e},[ue.data,x]);function ge(e){ae(``),re(e.title),S(e)}async function _e(){if(ee&&ne.trim()){se(!0),ae(``);try{let e=await Wt(`/api/agent/threads/${encodeURIComponent(ee.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:ne.trim()})});if(!e.ok)throw Error(`Unable to rename chat (${e.status})`);await v.invalidateQueries({queryKey:aT}),S(null)}catch(e){ae(e instanceof Error?e.message:`Unable to rename this chat.`)}finally{se(!1)}}}async function ve(){if(C){se(!0),ae(``);try{let e=await Wt(`/api/agent/threads/${encodeURIComponent(C.id)}`,{method:`DELETE`});if(!e.ok)throw Error(`Unable to delete chat (${e.status})`);let t=C.id;w(null),await v.invalidateQueries({queryKey:aT}),await v.invalidateQueries({queryKey:Pt}),l(t)}catch(e){ae(e instanceof Error?e.message:`Unable to delete this chat.`)}finally{se(!1)}}}return e?(0,A.jsxs)(te,{gap:4,component:`nav`,"aria-label":`Navigation`,children:[t&&(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,size:46,"aria-label":`New chat`,title:`New chat`,onClick:o,children:(0,A.jsx)(Ww,{size:18})}),t&&(0,A.jsxs)(Ot,{position:`right-start`,withinPortal:!0,shadow:`md`,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,size:46,"aria-label":`Chats`,title:`Chats`,className:`rail-row`,"data-active":!!n||void 0,children:(0,A.jsx)(Ow,{size:18})})}),(0,A.jsxs)(Ot.Dropdown,{maw:280,children:[(0,A.jsx)(Ot.Label,{children:`Recent chats`}),le.isPending?(0,A.jsx)(Ot.Item,{disabled:!0,children:`Loading chats…`}):le.isError?(0,A.jsx)(Ot.Item,{onClick:()=>void le.refetch(),children:`Chats could not be loaded. Retry`}):de.length===0&&(0,A.jsx)(Ot.Item,{disabled:!0,children:`No chats yet`}),de.slice(0,10).map(e=>(0,A.jsx)(Ot.Item,{"aria-current":e.id===n?`page`:void 0,fw:e.id===n?600:void 0,onClick:()=>s(e.id),children:(0,A.jsx)(D,{size:`sm`,truncate:!0,children:e.title||`Untitled chat`})},e.id))]})]}),bE.map(({path:e,label:t,Icon:n})=>(0,A.jsx)(Ne,{component:`a`,href:e,title:t,"aria-label":t,"aria-current":i===e||i?.startsWith(`${e}/`)?`page`:void 0,className:`rail-row`,"data-active":i===e||i?.startsWith(`${e}/`)||void 0,variant:`subtle`,color:`gray`,size:46,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),h(e))},children:(0,A.jsx)(n,{size:18})},e)),(0,A.jsxs)(Ot,{position:`right-start`,withinPortal:!0,shadow:`md`,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,size:46,"aria-label":`Dashboards`,title:`Dashboards`,className:`rail-row`,"data-active":!!r||void 0,children:(0,A.jsx)(eT,{size:18})})}),(0,A.jsxs)(Ot.Dropdown,{maw:280,children:[(0,A.jsx)(Ot.Label,{children:`Dashboards`}),ue.isPending&&(0,A.jsx)(Ot.Item,{disabled:!0,children:`Loading dashboards…`}),ue.isError&&(0,A.jsx)(Ot.Item,{onClick:()=>void ue.refetch(),children:`Dashboards could not be loaded. Retry`}),(ue.data??[]).map(e=>(0,A.jsx)(Ot.Item,{"aria-current":e.id===r?`page`:void 0,fw:e.id===r?600:void 0,onClick:()=>d(e.id),children:(0,A.jsx)(D,{size:`sm`,truncate:!0,children:e.name})},e.id)),ue.data?.length?(0,A.jsx)(Ot.Divider,{}):null,(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Ww,{size:14}),onClick:p,children:`New dashboard`})]})]})]}):(0,A.jsxs)(te,{gap:`sm`,h:`100%`,component:`nav`,"aria-label":`Navigation`,children:[t&&(0,A.jsx)(we,{leftSection:(0,A.jsx)(Ww,{size:16,weight:`bold`}),onClick:o,children:`New chat`}),(0,A.jsx)(O,{type:`auto`,offsetScrollbars:!0,flex:1,mx:-4,px:4,children:(0,A.jsxs)(te,{gap:`lg`,pb:`sm`,children:[t&&(0,A.jsxs)(te,{gap:4,children:[(0,A.jsx)(CE,{children:`Chats`}),le.isLoading&&(0,A.jsx)(fe,{state:`loading`,rows:3}),le.isError&&(0,A.jsx)(fe,{state:`error`,error:{message:`Chats could not be loaded.`,onRetry:()=>void le.refetch()}}),!le.isLoading&&!le.isError&&de.length===0&&(0,A.jsx)(D,{size:`xs`,c:`dimmed`,px:`sm`,children:x?`No matching chats. Try another name.`:`No chats yet. Start one above.`}),pe.map(e=>(0,A.jsxs)(te,{gap:2,children:[pe.length>1&&(0,A.jsx)(D,{c:`dimmed`,size:`xs`,px:`sm`,pt:4,children:e.label}),e.threads.map(e=>(0,A.jsx)(wE,{thread:e,active:(i?i.startsWith(`/chat/`):!r)&&e.id===n,onSelect:()=>s(e.id),onRename:()=>ge(e),onDelete:()=>{ae(``),w(e)}},e.id))]},e.label)),le.hasNextPage&&(0,A.jsx)(we,{variant:`subtle`,color:`gray`,size:`compact-sm`,loading:le.isFetchingNextPage,onClick:()=>void le.fetchNextPage(),children:`See all`})]}),t&&x&&g&&T.isLoading&&(0,A.jsx)(fe,{state:`loading`,rows:3}),t&&x&&g&&(T.isSuccess||T.isError)&&(0,A.jsxs)(te,{gap:4,children:[(0,A.jsx)(CE,{children:`Services`}),T.isError&&(0,A.jsx)(D,{c:`dimmed`,size:`sm`,px:`sm`,children:`Services could not be searched`}),T.isSuccess&&me.length===0&&(0,A.jsx)(fe,{state:`empty`,variant:`inline`,empty:{title:`No matching services`,description:`Try a different service name.`,action:(0,A.jsx)(we,{variant:`subtle`,size:`compact-xs`,onClick:()=>b(``),children:`Clear search`})}}),me.map(e=>(0,A.jsx)(Ve,{className:`rail-row`,p:`sm`,onClick:()=>g(e),children:(0,A.jsx)(D,{size:`sm`,fw:500,truncate:!0,children:e})},e))]}),(0,A.jsx)(te,{gap:0,children:bE.map(({path:e,label:t,Icon:n})=>{let r=i===e;return(0,A.jsx)(Ve,{component:`a`,href:e,className:`rail-row`,"data-active":r||void 0,"aria-current":r?`page`:void 0,p:`sm`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),h(e))},children:(0,A.jsxs)(m,{gap:`xs`,wrap:`nowrap`,children:[(0,A.jsx)(n,{size:16}),(0,A.jsx)(D,{size:`sm`,fw:r?600:500,children:t})]})},e)})}),(0,A.jsxs)(te,{gap:4,children:[(0,A.jsx)(CE,{children:`Dashboards`}),ue.isLoading&&(0,A.jsx)(fe,{state:`loading`,rows:3}),ue.isError&&(0,A.jsx)(Le,{tone:`danger`,children:`Dashboards could not be loaded.`}),!ue.isLoading&&!ue.isError&&x&&he.length===0&&(0,A.jsx)(fe,{state:`empty`,variant:`inline`,empty:{title:`No matching dashboards`,description:`Try a different dashboard name.`,action:(0,A.jsx)(we,{variant:`subtle`,size:`compact-xs`,onClick:()=>b(``),children:`Clear search`})}}),he.map(e=>{let n=(!i||i.startsWith(`/dashboards`))&&e.id===r;return(0,A.jsxs)(te,{gap:0,children:[(0,A.jsx)(Ve,{component:`a`,href:`/dashboards/${encodeURIComponent(e.id)}`,className:`rail-row`,"data-active":n||void 0,"aria-current":n?`page`:void 0,p:`sm`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),d(e.id))},children:(0,A.jsxs)(m,{justify:`space-between`,gap:`sm`,wrap:`nowrap`,children:[(0,A.jsxs)(m,{gap:`xs`,wrap:`nowrap`,style:{minWidth:0,flex:1},children:[(0,A.jsx)(eT,{size:16,style:{flexShrink:0}}),(0,A.jsx)(D,{size:`sm`,fw:n?600:500,truncate:!0,title:e.name,children:e.name})]}),e.is_default&&(0,A.jsx)(Bi,{label:`Default`,children:(0,A.jsx)(c,{size:16,variant:`light`,color:`gray`,role:`img`,"aria-label":`Default`,style:{flexShrink:0},children:(0,A.jsx)(nT,{size:12,weight:`fill`,"aria-hidden":`true`})})})]})}),t&&e.origin&&(0,A.jsx)(Ve,{component:`a`,href:`/chat/${encodeURIComponent(e.origin.thread_id)}`,"data-request-provenance":!0,px:`sm`,pb:`xs`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),s(e.origin.thread_id))},children:(0,A.jsxs)(D,{size:`xs`,c:`dimmed`,lineClamp:2,title:`Built from: ${e.origin.request_excerpt}`,children:[`Built from: `,e.origin.request_excerpt]})})]},e.id)}),(0,A.jsx)(we,{variant:`subtle`,color:`gray`,size:`sm`,px:`sm`,justify:`flex-start`,leftSection:(0,A.jsx)(Ww,{size:14}),onClick:p,children:`New dashboard`}),t&&(0,A.jsx)(we,{variant:`subtle`,color:`gray`,size:`sm`,px:`sm`,justify:`flex-start`,leftSection:(0,A.jsx)(Qw,{size:14,weight:`fill`}),onClick:f,children:`Create with AI`})]})]})}),(0,A.jsx)(Ge,{ref:ce,value:y,onChange:e=>b(e.currentTarget.value),leftSection:(0,A.jsx)(Iw,{size:15}),rightSection:(0,A.jsx)(Ei,{size:`xs`,children:`⌘K`}),rightSectionWidth:44,placeholder:`Search`,"aria-label":`Search chats, dashboards and services`,size:`sm`}),(0,A.jsx)(u,{opened:ee!==null,onClose:()=>!oe&&S(null),title:`Rename chat`,centered:!0,children:(0,A.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),_e()},children:(0,A.jsxs)(te,{children:[(0,A.jsx)(Ge,{label:`Name`,value:ne,onChange:e=>re(e.currentTarget.value),maxLength:120,autoFocus:!0}),ie&&(0,A.jsx)(Le,{tone:`danger`,children:ie}),(0,A.jsxs)(m,{justify:`flex-end`,children:[(0,A.jsx)(we,{variant:`default`,onClick:()=>S(null),disabled:oe,children:`Cancel`}),(0,A.jsx)(we,{type:`submit`,loading:oe,disabled:!ne.trim(),children:`Save`})]})]})})}),(0,A.jsxs)(He,{opened:C!==null,onClose:()=>w(null),title:`Delete chat?`,confirmLabel:`Delete chat`,tone:`danger`,pending:oe?`confirm`:null,error:ie||void 0,onConfirm:()=>void ve(),children:[`This permanently removes `,(0,A.jsx)(D,{span:!0,ff:`monospace`,children:C?.title}),` and its saved messages.`]})]})}function CE({children:e}){return(0,A.jsx)(D,{c:`dimmed`,size:`xs`,fw:700,tt:`uppercase`,lts:`0.08em`,px:`sm`,children:e})}function wE({thread:e,active:t,onSelect:n,onRename:r,onDelete:i}){return(0,A.jsx)(w,{"data-active":t||void 0,className:`rail-row`,children:(0,A.jsxs)(m,{gap:2,wrap:`nowrap`,children:[(0,A.jsx)(Ve,{onClick:n,"aria-current":t?`page`:void 0,p:`sm`,flex:1,style:{minWidth:0},children:(0,A.jsxs)(te,{gap:0,pl:24,style:{position:`relative`},children:[(0,A.jsx)(Ow,{size:16,style:{position:`absolute`,left:0,top:2}}),(0,A.jsx)(D,{size:`sm`,fw:t?600:500,truncate:!0,title:e.title,children:e.title}),(0,A.jsx)(D,{c:`dimmed`,size:`xs`,ff:`monospace`,children:kE(e.updated_at)})]})}),(0,A.jsxs)(Ot,{position:`bottom-end`,withinPortal:!0,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Ne,{className:`rail-row-actions`,variant:`subtle`,color:`gray`,size:`sm`,mr:4,"aria-label":`Actions for ${e.title}`,children:(0,A.jsx)(jt,{size:18,weight:`bold`})})}),(0,A.jsxs)(Ot.Dropdown,{children:[(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Ct,{size:15}),onClick:r,children:`Rename`}),(0,A.jsx)(Ot.Item,{color:`bad`,leftSection:(0,A.jsx)(ht,{size:15}),onClick:i,children:`Delete`})]})]})]})})}function TE(e){return e.includes(`T`)?new Date(e):new Date(`${e.replace(` `,`T`)}Z`)}function EE(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}var DE=[`Today`,`Yesterday`,`Previous 7 days`,`Older`];function OE(e){let t=EE(new Date),n=new Map;for(let r of e){let e=Math.floor((t-EE(TE(r.updated_at)))/864e5),i=e<=0?`Today`:e===1?`Yesterday`:e<=7?`Previous 7 days`:`Older`,a=n.get(i)??[];a.push(r),n.set(i,a)}return DE.filter(e=>n.has(e)).map(e=>({label:e,threads:n.get(e)}))}function kE(e){return yE(TE(e).valueOf())}var AE=(0,k.lazy)(()=>st(()=>import(`./new-dashboard-nl-y_vRO.js`).then(e=>({default:e.NewDashboard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])));function jE({children:e}){let{agentAvailable:t,threadID:n,threadMissing:r,newThread:i,selectThread:a,openChat:o}=OT(),s=$e(),c=Qn({select:e=>e.location.pathname}),{dashboardId:l}=ut({strict:!1}),u=c===`/chat`||c.startsWith(`/chat/`),[d,f]=tr(!1),[p,h]=(0,k.useState)(!1),[g,_]=(0,k.useState)(!1),[v,y]=(0,k.useState)(``),[b,x]=(0,k.useState)(!1),ee=(0,k.useRef)(null),S=(0,k.useRef)(null),C=KT(),te=he(`(max-width: 62em)`),ne=he(`(max-width: 48em)`),re=(0,k.useRef)(te),ie=()=>{te?(_(!0),f.open()):(h(!1),requestAnimationFrame(()=>ee.current?.focusSearch()))};re.current=te,(0,k.useEffect)(()=>{f.close()},[c]),(0,k.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),re.current?(_(!0),f.open()):(h(!1),requestAnimationFrame(()=>ee.current?.focusSearch())))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let ae={agentAvailable:t,activeThreadID:u&&!r&&c!==`/chat`?n:void 0,activeDashboardID:l,activePath:c,onNewChat:i,onSelectThread:a,onDeletedThread:e=>{e===n&&i()},onSelectDashboard:e=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:e},search:{}}),onCreateDashboard:()=>o(kT),onNewDashboard:()=>{C.remember(re.current?S.current:document.activeElement),f.close(),x(!0)},onNavigate:e=>void s({to:e}),onInvestigateService:e=>o(`Investigate the ${e} service. Explain its errors and latency.`)},oe=()=>{x(!1),C.restore()};return(0,A.jsxs)(li,{header:{height:56},navbar:{width:p?56:248,breakpoint:`md`,collapsed:{mobile:!0}},padding:0,children:[(0,A.jsx)(`a`,{className:`skip-link`,href:`#main`,children:`Skip to content`}),(0,A.jsx)(li.Header,{children:(0,A.jsxs)(m,{h:`100%`,px:{base:`sm`,sm:`md`},justify:`space-between`,wrap:`nowrap`,children:[(0,A.jsxs)(m,{gap:`sm`,wrap:`nowrap`,children:[(0,A.jsx)(Ci,{ref:S,hiddenFrom:`md`,opened:d,"aria-expanded":d,onClick:()=>{_(!1),f.toggle()},size:`sm`,"aria-label":d?`Close navigation`:`Open navigation`}),(0,A.jsx)(Ne,{visibleFrom:`md`,variant:`subtle`,color:`gray`,"aria-label":p?`Expand navigation`:`Collapse navigation`,"aria-expanded":!p,onClick:()=>h(e=>!e),children:(0,A.jsx)(Jw,{size:18})}),(0,A.jsx)(Be,{size:`small`})]}),ne?(0,A.jsx)(Ne,{variant:`default`,size:`lg`,"aria-label":`Search`,onClick:ie,children:(0,A.jsx)(Iw,{size:16})}):(0,A.jsx)(we,{variant:`default`,color:`gray`,leftSection:(0,A.jsx)(Iw,{size:16}),onClick:ie,children:`Search · ⌘K`}),(0,A.jsx)(w,{id:`shell-time-range`,visibleFrom:`sm`}),(0,A.jsxs)(m,{gap:`xs`,wrap:`nowrap`,children:[(0,A.jsx)($T,{}),(0,A.jsx)(GT,{}),(0,A.jsx)(ME,{onError:y})]})]})}),(0,A.jsx)(li.Navbar,{p:p?4:`sm`,children:(0,A.jsx)(SE,{ref:ee,...ae,collapsed:p})}),(0,A.jsx)(gt,{opened:d,onClose:f.close,returnFocus:!b,hiddenFrom:`md`,size:288,padding:`sm`,title:(0,A.jsx)(Be,{size:`small`}),overlayProps:{backgroundOpacity:.24,blur:1},children:(0,A.jsx)(SE,{...ae,autoFocusSearch:d&&g})}),(0,A.jsxs)(li.Main,{id:`main`,tabIndex:-1,children:[v&&(0,A.jsx)(Le,{tone:`danger`,onDismiss:()=>y(``),children:v}),e]}),b&&(0,A.jsx)(k.Suspense,{fallback:null,children:(0,A.jsx)(AE,{onClose:oe,onCreated:e=>{x(!1),s({to:`/dashboards/$dashboardId`,params:{dashboardId:e},search:{}})}})})]})}function ME({onError:e}){let t=$e(),n=Jt(),r=(n.display_name.trim()||n.email.trim()||`?`).charAt(0).toUpperCase();return(0,A.jsxs)(Ot,{position:`bottom-end`,withinPortal:!0,shadow:`md`,children:[(0,A.jsx)(Ot.Target,{children:(0,A.jsx)(Ne,{variant:`subtle`,color:`gray`,size:`lg`,radius:`xl`,"aria-label":`${r} account menu`,children:(0,A.jsx)(bi,{size:26,radius:`xl`,color:`gray`,children:r})})}),(0,A.jsxs)(Ot.Dropdown,{children:[(0,A.jsx)(Ot.Label,{children:n.email||`Signed in`}),(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Hw,{size:15}),onClick:()=>void t({to:`/settings`}),children:`Connect telemetry`}),(0,A.jsx)(Ot.Divider,{}),(0,A.jsx)(Ot.Item,{leftSection:(0,A.jsx)(Xw,{size:15}),onClick:()=>void qt().catch(t=>e(t instanceof Error?t.message:`Sign-out failed — your session is still active.`)),children:`Sign out`})]})]})}function NE(){let{agent_available:e}=Kt(),t=$e(),n=Zt(),{threadId:r}=ut({strict:!1}),[i,a]=(0,k.useState)(WT),o=(0,k.useRef)(new Set),s=r??i,[c,l]=(0,k.useState)([]),[u,d]=(0,k.useState)({}),[f,p]=(0,k.useState)(``),[m,h]=(0,k.useState)(!1),[g,_]=(0,k.useState)(!1),[v,y]=(0,k.useState)(``),[b,x]=(0,k.useState)(!1),ee=(0,k.useRef)(!1),[S,C]=(0,k.useState)(``),[te,w]=(0,k.useState)(``),[ne,re]=(0,k.useState)(0),ie=(0,k.useRef)(null),ae=(0,k.useRef)({}),oe=(0,k.useRef)(null),se=(0,k.useRef)(new Map),ce=(0,k.useMemo)(()=>new XC({url:`/api/agent/runs`,threadId:s,fetch:(e,t)=>Wt(e,t)}),[s]),le=!e||f===s;function ue(){se.current.clear(),y(``)}function de(e){return ee.current||e instanceof Error&&e.name===`AbortError`}(0,k.useEffect)(()=>{let t=!0;if(l([]),ae.current={},d({}),p(``),h(!1),_(!1),ee.current=!1,x(!1),ue(),w(``),!e){p(s);return}!r||o.current.has(s)?(ce.setMessages([]),p(s)):Wt(`/api/agent/threads/${encodeURIComponent(s)}`).then(async e=>{if(e.status===404)return null;if(!e.ok)throw Error(`Unable to load thread (${e.status})`);return e.json()}).then(e=>{if(t){if(e===null){h(!0),p(s);return}ce.setMessages(e.messages??[]),l(e.messages??[]),p(s)}}).catch(()=>{t&&(ie.current=null,w(`This chat could not be restored. Start a new chat or try again.`))});let i=ce.subscribe({onMessagesChanged:({messages:e})=>l([...e]),onRunInitialized:()=>{ee.current=!1,x(!1),_(!0),w(``)},onTextMessageContentEvent:({event:e})=>{e.delta&&y(``)},onToolCallStartEvent:({event:e})=>{se.current.set(e.toolCallId,jT(e.toolCallName)),y(jT(e.toolCallName))},onToolCallResultEvent:({event:e,messages:t})=>{se.current.delete(e.toolCallId),y([...se.current.values()].at(-1)??`Analyzing your system`);let r=mT(e.toolCallId,e.content,t);r&&(n.invalidateQueries({queryKey:Pt}),n.invalidateQueries({queryKey:[`dashboard`,r.id]}),n.invalidateQueries({queryKey:[`dashboard-versions`,r.id]}))},onRunErrorEvent:({event:e})=>{e.code===`abort`||ee.current?(w(``),x(!0)):(console.warn(`Agent run error`,e.code),w(NT(e.code))),_(!1),ue()},onRunFinalized:({messages:e})=>{let t=[...e];l(t),d(e=>{let n={...e};for(let e of t)e.role===`assistant`&&!n[e.id]&&(n[e.id]=Date.now());return n}),_(!1),ue(),o.current.delete(s),n.invalidateQueries({queryKey:aT})},onRunFailed:e=>{de(e.error)?(w(``),x(!0)):(console.error(`Agent run failed`,e),w(NT())),_(!1),ue(),o.current.delete(s),n.invalidateQueries({queryKey:aT})}});return()=>{t=!1,i.unsubscribe(),ce.abortRun()}},[ce,e,n,ne,s]),(0,k.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target,i=n?.matches(`input, textarea, [contenteditable='true']`);e.key===`/`&&!i&&(e.preventDefault(),r?requestAnimationFrame(()=>oe.current?.focus()):t({to:`/chat`}).then(()=>requestAnimationFrame(()=>oe.current?.focus()))),e.key===`Escape`&&n===oe.current&&(C(``),oe.current?.blur())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t,r]);async function fe(){_(!0),w(``);try{let{context:e=[],...t}=ae.current;await ce.runAgent({context:e,forwardedProps:t})}catch(e){de(e)?(w(``),x(!0)):(console.error(`Agent run failed`,e),w(NT())),_(!1),ue(),o.current.delete(s)}}async function pe(n,i){let a=n.trim();if(!e||!a||g||!le||m)return;ae.current={...i},r||(o.current.add(s),t({to:`/chat/$threadId`,params:{threadId:s},replace:!0}));let c={id:WT(),role:`user`,content:a};ce.addMessage(c),l([...ce.messages]),d(e=>({...e,[c.id]:Date.now()})),C(``),await fe()}(0,k.useEffect)(()=>{let e=ie.current;le&&r&&e&&(ie.current=null,pe(e.text,e.options))},[le,r,s]);function T(e){e.preventDefault(),pe(S)}function me(){ee.current=!0,w(``),x(!0),ce.abortRun(),_(!1),ue(),o.current.delete(s)}function he(){!g&&ce.messages.some(e=>e.role===`user`)&&fe()}function ge(n,r){if(!e)return;let i=WT();o.current.add(i),ie.current=n?{text:n,options:{...r}}:null,t({to:`/chat/$threadId`,params:{threadId:i}})}function _e(){ce.abortRun(),ie.current=null,ae.current={},a(WT()),t({to:`/chat`})}function ve(e){ie.current=null,ae.current={},t({to:`/chat/$threadId`,params:{threadId:e}})}function ye(){re(e=>e+1)}return(0,A.jsx)(DT.Provider,{value:{agentAvailable:e,threadID:s,threadMissing:m,messages:c,messageTimes:u,ready:le,running:g,activity:v,stopped:b,input:S,setInput:C,error:te,inputRef:oe,send:pe,submit:T,stop:me,retry:he,reloadThread:ye,openChat:ge,newThread:_e,selectThread:ve},children:(0,A.jsx)(jE,{children:(0,A.jsx)(Hn,{})})})}function PE(){let e=(0,k.useMemo)(()=>new rw,[]);return(0,A.jsx)(vn,{client:e,children:(0,A.jsx)(Yt,{children:(0,A.jsx)(NE,{})})})}var FE=ft({component:PE,notFoundComponent:()=>(0,A.jsx)(et,{to:`/`,replace:!0})}),IE=dt(`/`)({component:pt(()=>st(()=>import(`./routes-D2AdaqvY.js`),__vite__mapDeps([21,1,7])),`component`)}),LE=dt(`/alerts`)({component:pt(()=>st(()=>import(`./alerts-BlSGnTGi.js`),__vite__mapDeps([22,1,2,7,3,4,5,6,17,13,14,23,8,24,18,16,20])),`component`)}),RE=dt(`/explore`)({component:pt(()=>st(()=>import(`./explore-BocWcl6s.js`),__vite__mapDeps([25,1,7,18,3,2,4,5,6,9,10,11,12,13,14,8,15,16,17,19])),`component`),validateSearch:e=>bn(xn(e))}),zE=dt(`/logs`)({component:pt(()=>st(()=>import(`./logs-BcF87yZO.js`),__vite__mapDeps([26,1,7,18,3,2,4,5,6,27,10,11,12,13,14,8,15,16,17,19])),`component`),validateSearch:e=>bn(xn(e))}),BE=dt(`/settings`)({component:pt(()=>st(()=>import(`./settings-BCyNZMl5.js`),__vite__mapDeps([28,29,1,2,12,6,7,8,24,16])),`component`)}),VE=dt(`/traces`)({component:pt(()=>st(()=>import(`./traces-CE0ccoAt.js`),__vite__mapDeps([30,1,7,18,3,2,4,5,6,27,10,11,12,13,14,8,15,16,17,19])),`component`),validateSearch:e=>bn(xn(e))}),HE=dt(`/chat/`)({component:pt(()=>st(()=>import(`./chat.index-DpKCqGxd.js`),__vite__mapDeps([31,32,1,2,33,13,5,23,15,34])),`component`)}),UE=dt(`/chat/$threadId`)({component:pt(()=>st(()=>import(`./chat._threadId-DpKCqGxd.js`),__vite__mapDeps([35,32,1,2,33,13,5,23,15,34])),`component`)}),WE=dt(`/dashboards/`)({component:pt(()=>st(()=>import(`./dashboards.index-BXpuj_Hg.js`),__vite__mapDeps([36,1,7,3,2,4,5,6,37,33,11,10,12,13,14,8,15,16,24,34])),`component`),validateSearch:e=>Ft(At(e))}),GE=dt(`/dashboards/$dashboardId`)({component:pt(()=>st(()=>import(`./dashboards._dashboardId-DVwJCShe.js`),__vite__mapDeps([38,1,7,3,2,4,5,6,37,33,11,10,12,13,14,8,15,16,24,34])),`component`),validateSearch:e=>Ft(At(e))}),KE=dt(`/settings_/ingest`)({component:pt(()=>st(()=>import(`./settings_.ingest-CRd3tDC4.js`),__vite__mapDeps([39,29,1,2,12,6,7,8,24,16])),`component`)}),qE=IE.update({id:`/`,path:`/`,getParentRoute:()=>FE}),JE=LE.update({id:`/alerts`,path:`/alerts`,getParentRoute:()=>FE}),YE=RE.update({id:`/explore`,path:`/explore`,getParentRoute:()=>FE}),XE=zE.update({id:`/logs`,path:`/logs`,getParentRoute:()=>FE}),ZE=BE.update({id:`/settings`,path:`/settings`,getParentRoute:()=>FE}),QE=VE.update({id:`/traces`,path:`/traces`,getParentRoute:()=>FE}),$E=HE.update({id:`/chat/`,path:`/chat/`,getParentRoute:()=>FE}),eD=UE.update({id:`/chat/$threadId`,path:`/chat/$threadId`,getParentRoute:()=>FE}),tD=WE.update({id:`/dashboards/`,path:`/dashboards/`,getParentRoute:()=>FE}),nD={IndexRoute:qE,AlertsRoute:JE,ExploreRoute:YE,LogsRoute:XE,SettingsRoute:ZE,TracesRoute:QE,ChatThreadIdRoute:eD,DashboardsDashboardIdRoute:GE.update({id:`/dashboards/$dashboardId`,path:`/dashboards/$dashboardId`,getParentRoute:()=>FE}),SettingsIngestRoute:KE.update({id:`/settings_/ingest`,path:`/settings/ingest`,getParentRoute:()=>FE}),ChatIndexRoute:$E,DashboardsIndexRoute:tD},rD=Jn({routeTree:FE._addFileChildren(nD)._addFileTypes(),parseSearch:kt,stringifySearch:Mt,defaultPreload:`intent`,scrollRestoration:!0});(0,Ji.createRoot)(document.getElementById(`root`)).render((0,A.jsx)(k.StrictMode,{children:(0,A.jsx)(xr,{theme:Tt,defaultColorScheme:`auto`,cssVariablesResolver:St,children:(0,A.jsx)(Zn,{router:rD})})}));export{Og as $,$C as A,Ag as B,wT as C,cT as D,sT as E,_g as F,G,Mg as H,hg as I,Eg as J,Sg as K,W as L,Rh as M,lg as N,oT as O,Ig as P,H as Q,wg as R,vT as S,lT as T,o_ as U,Uh as V,K as W,d_ as X,Vg as Y,Pg as Z,KT as _,RE as a,up as at,PT as b,_E as c,Bi as ct,yE as d,bg as et,sE as f,ZT as g,pE as h,zE as i,mp as it,zh as j,Ww as k,fE as l,Ei as lt,hE as m,WE as n,Sh as nt,gE as o,lp as ot,dE as p,ug as q,VE as r,gh as rt,uE as s,Xc as st,GE as t,qh as tt,vE as u,cr as ut,kT as v,bT as w,OT as x,MT as y,pg as z}; \ No newline at end of file diff --git a/internal/ui/dist/assets/live-data-meta-CUyw2snU.js b/internal/ui/dist/assets/live-data-meta-CkxM9djV.js similarity index 99% rename from internal/ui/dist/assets/live-data-meta-CUyw2snU.js rename to internal/ui/dist/assets/live-data-meta-CkxM9djV.js index 64000f80c..e38a653c6 100644 --- a/internal/ui/dist/assets/live-data-meta-CUyw2snU.js +++ b/internal/ui/dist/assets/live-data-meta-CkxM9djV.js @@ -1 +1 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{Dt as r,F as i,Ft as a,Nt as o,Ot as s,P as c,Qt as l,Tt as u,Xt as d,Zt as f,_n as p,bn as m,dn as h,en as g,gn as _,in as v,j as y,jt as b,nn as x,nt as S,pn as C,qt as w,un as T}from"./brand-D6fP-cLS.js";import{M as E,j as D}from"./search-D_K9J6yO.js";import{l as O,n as k}from"./format-BZjbsxwM.js";var A=n(e(),1),j=t();function M(e,t=document){let n=t.querySelector(e);if(n)return n;let r=t.querySelectorAll(`*`);for(let t=0;tF(e))}:typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?{value:e,label:`${e}`}:e}function I(e){return e?e.map(e=>F(e)):[]}function ee(e){return e.reduce((e,t)=>`group`in t?{...e,...ee(t.items)}:(e[`${t.value}`]=t,e),{})}var L={dropdown:`m_88b62a41`,search:`m_985517d8`,options:`m_b2821a6e`,option:`m_92253aa5`,empty:`m_2530cd1d`,header:`m_858f94bd`,footer:`m_82b967cb`,group:`m_254f3e4f`,groupLabel:`m_2bb2e9e5`,chevron:`m_2943220b`,optionsDropdownOption:`m_390b5f4`,optionsDropdownCheckIcon:`m_8ee53fc2`,optionsDropdownCheckPlaceholder:`m_a530ee0a`},te={error:null},R=f((e,{size:t,color:n})=>({chevron:{"--combobox-chevron-size":C(t,`combobox-chevron-size`),"--combobox-chevron-color":n?w(n,e):void 0}})),z=r(e=>{let t=a(`ComboboxChevron`,te,e),{size:n,error:r,style:i,className:s,classNames:c,styles:l,unstyled:d,vars:f,attributes:p,mod:m,...h}=t,g=o({name:`ComboboxChevron`,classes:L,props:t,style:i,className:s,classNames:c,styles:l,unstyled:d,vars:f,varsResolver:R,attributes:p,rootSelector:`chevron`});return(0,j.jsx)(u,{component:`svg`,...h,...g(`chevron`),size:n,viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,mod:[`combobox-chevron`,{error:r},m],children:(0,j.jsx)(`path`,{d:`M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})});z.classes=L,z.varsResolver=R,z.displayName=`@mantine/core/ComboboxChevron`;var[B,V]=_(`Combobox component was not found in tree`);function H({onMouseDown:e,onClick:t,onClear:n,...r}){return(0,j.jsx)(c.ClearButton,{tabIndex:-1,"aria-hidden":!0,...r,onMouseDown:t=>{t.preventDefault(),e?.(t)},onClick:e=>{n(),t?.(e)}})}H.displayName=`@mantine/core/ComboboxClearButton`;var U=r(e=>{let{classNames:t,styles:n,className:r,style:i,hidden:o,...s}=a(`ComboboxDropdown`,null,e),c=V();return(0,j.jsx)(E.Dropdown,{...s,role:`presentation`,"data-hidden":o||void 0,"data-floating-height":c.floatingHeight||void 0,...c.getStyles(`dropdown`,{className:r,style:i,classNames:t,styles:n})})});U.classes=L,U.displayName=`@mantine/core/ComboboxDropdown`;var ne={refProp:`ref`},W=r(e=>{let{children:t,refProp:n,ref:r}=a(`ComboboxDropdownTarget`,ne,e);if(V(),!p(t))throw Error(`Combobox.DropdownTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);return(0,j.jsx)(E.Target,{ref:r,refProp:n,children:t})});W.displayName=`@mantine/core/ComboboxDropdownTarget`;var G=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`ComboboxEmpty`,null,e),c=V();return(0,j.jsx)(u,{...c.getStyles(`empty`,{className:n,classNames:t,styles:i,style:r}),...s})});G.classes=L,G.displayName=`@mantine/core/ComboboxEmpty`;function K({onKeyDown:e,onClick:t,withKeyboardNavigation:n,withAriaAttributes:r,withExpandedAttribute:i,targetType:a,autoComplete:o}){let s=V(),[c,l]=(0,A.useState)(null),u=t=>{if(e?.(t),!s.readOnly&&n){if(t.nativeEvent.isComposing)return;if(t.nativeEvent.code===`ArrowDown`&&(t.preventDefault(),s.store.dropdownOpened?l(s.store.selectNextOption()):(s.store.openDropdown(`keyboard`),l(s.store.selectActiveOption()),s.store.updateSelectedOptionIndex(`selected`,{scrollIntoView:!0}))),t.nativeEvent.code===`ArrowUp`&&(t.preventDefault(),s.store.dropdownOpened?l(s.store.selectPreviousOption()):(s.store.openDropdown(`keyboard`),l(s.store.selectActiveOption()),s.store.updateSelectedOptionIndex(`selected`,{scrollIntoView:!0}))),t.nativeEvent.code===`Enter`||t.nativeEvent.code===`NumpadEnter`){if(t.nativeEvent.keyCode===229)return;let e=s.store.getSelectedOptionIndex();s.store.dropdownOpened&&e!==-1?(t.preventDefault(),s.store.clickSelectedOption()):a===`button`&&(t.preventDefault(),s.store.openDropdown(`keyboard`))}t.key===`Escape`&&s.store.closeDropdown(`keyboard`),t.nativeEvent.code===`Space`&&a===`button`&&(t.preventDefault(),s.store.toggleDropdown(`keyboard`))}},d=r?{...i?{role:`combobox`}:{},"aria-haspopup":`listbox`,"aria-expanded":i?!!(s.store.listId&&s.store.dropdownOpened):void 0,"aria-controls":s.store.dropdownOpened&&s.store.listId?s.store.listId:void 0,"aria-activedescendant":s.store.dropdownOpened&&c||void 0,autoComplete:o,"data-expanded":s.store.dropdownOpened||void 0,"data-mantine-stop-propagation":s.store.dropdownOpened||void 0}:{},f=e=>{a===`button`&&e.currentTarget.focus(),t?.(e)};return{...d,onKeyDown:u,onClick:f}}var re={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},ie=r(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:o,targetType:s,autoComplete:c,ref:u,...d}=a(`ComboboxEventsTarget`,re,e),f=l(t);if(!f)throw Error(`Combobox.EventsTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let p=V(),m=K({targetType:s,withAriaAttributes:i,withKeyboardNavigation:r,withExpandedAttribute:o,onKeyDown:f.props.onKeyDown,onClick:f.props.onClick,autoComplete:c});return(0,A.cloneElement)(f,{...m,...d,[n]:x(u,p.store.targetRef,O(f))})});ie.displayName=`@mantine/core/ComboboxEventsTarget`;var q=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`ComboboxFooter`,null,e),c=V();return(0,j.jsx)(u,{...c.getStyles(`footer`,{className:n,classNames:t,style:r,styles:i}),...s,onMouseDown:e=>{e.preventDefault()}})});q.classes=L,q.displayName=`@mantine/core/ComboboxFooter`;var J=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,children:s,label:c,id:l,...d}=a(`ComboboxGroup`,null,e),f=V(),p=v(l),m=c!=null&&c!==!1&&c!==``;return(0,j.jsxs)(u,{role:`group`,"aria-labelledby":m?p:void 0,...f.getStyles(`group`,{className:n,classNames:t,style:r,styles:i}),...d,children:[m&&(0,j.jsx)(`div`,{id:p,...f.getStyles(`groupLabel`,{classNames:t,styles:i}),children:c}),s]})});J.classes=L,J.displayName=`@mantine/core/ComboboxGroup`;var Y=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`ComboboxHeader`,null,e),c=V();return(0,j.jsx)(u,{...c.getStyles(`header`,{className:n,classNames:t,style:r,styles:i}),...s,onMouseDown:e=>{e.preventDefault()}})});Y.classes=L,Y.displayName=`@mantine/core/ComboboxHeader`;function ae({value:e,valuesDivider:t=`,`,...n}){return(0,j.jsx)(`input`,{type:`hidden`,value:Array.isArray(e)?e.join(t):e?`${e}`:``,...n})}ae.displayName=`@mantine/core/ComboboxHiddenInput`;var X=r(e=>{let t=a(`ComboboxOption`,null,e),{classNames:n,className:r,style:i,styles:o,vars:s,onClick:c,id:l,active:d,onMouseDown:f,onMouseOver:p,disabled:m,selected:h,mod:g,..._}=t,v=V(),y=(0,A.useId)(),b=l||y;return(0,j.jsx)(u,{...v.getStyles(`option`,{className:r,classNames:n,styles:o,style:i}),"aria-disabled":m||void 0,..._,id:b,mod:[`combobox-option`,{"combobox-active":d,"combobox-disabled":m,"combobox-selected":h},g],role:`option`,onClick:e=>{m?e.preventDefault():(v.onOptionSubmit?.(t.value,t),c?.(e))},onMouseDown:e=>{e.preventDefault(),f?.(e)},onMouseOver:e=>{v.resetSelectionOnOptionHover&&v.store.resetSelectedOption(),p?.(e)}})});X.classes=L,X.displayName=`@mantine/core/ComboboxOption`;var oe=r(e=>{let{classNames:t,className:n,style:r,styles:i,id:o,onMouseDown:s,labelledBy:c,...l}=a(`ComboboxOptions`,null,e),d=V(),f=v(o);return(0,A.useEffect)(()=>{d.store.setListId(f)},[f]),(0,j.jsx)(u,{...d.getStyles(`options`,{className:n,style:r,classNames:t,styles:i}),...l,id:f,role:`listbox`,"aria-labelledby":c,onMouseDown:e=>{e.preventDefault(),s?.(e)}})});oe.classes=L,oe.displayName=`@mantine/core/ComboboxOptions`;var se={withAriaAttributes:!0,withKeyboardNavigation:!0},ce=r(e=>{let{classNames:t,styles:n,unstyled:r,vars:i,withAriaAttributes:o,onKeyDown:s,onClick:l,withKeyboardNavigation:u,size:d,ref:f,...p}=a(`ComboboxSearch`,se,e),m=V(),h=m.getStyles(`search`),g=K({targetType:`input`,withAriaAttributes:o,withKeyboardNavigation:u,withExpandedAttribute:!1,onKeyDown:s,onClick:l,autoComplete:`off`});return(0,j.jsx)(c,{ref:x(f,m.store.searchRef),classNames:[{input:h.className},t],styles:[{input:h.style},n],size:d||m.size,...g,...p,__staticSelector:`Combobox`})});ce.classes=L,ce.displayName=`@mantine/core/ComboboxSearch`;var le={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},ue=r(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:o,targetType:s,autoComplete:c,ref:u,...d}=a(`ComboboxTarget`,le,e),f=l(t);if(!f)throw Error(`Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let p=V(),m=K({targetType:s,withAriaAttributes:i,withKeyboardNavigation:r,withExpandedAttribute:o,onKeyDown:f.props.onKeyDown,onClick:f.props.onClick,autoComplete:c}),h=(0,A.cloneElement)(f,{...m,...d});return(0,j.jsx)(E.Target,{refProp:n,ref:x(u,p.store.targetRef),children:h})});ue.displayName=`@mantine/core/ComboboxTarget`;function de(e,t,n){for(let n=e-1;n>=0;--n)if(!t[n].hasAttribute(`data-combobox-disabled`))return n;if(n){for(let e=t.length-1;e>-1;--e)if(!t[e].hasAttribute(`data-combobox-disabled`))return e}return e}function fe(e,t,n){for(let n=e+1;n{s||(c(!0),i?.(e))},[c,i,s]),v=(0,A.useCallback)((e=`unknown`)=>{s&&(c(!1),r?.(e))},[c,r,s]),y=(0,A.useCallback)((e=`unknown`)=>{s?v(e):_(e)},[v,_,s]),b=(0,A.useCallback)(()=>{let e=P(f.current);M(`#${l.current} [data-combobox-selected]`,e)?.removeAttribute(`data-combobox-selected`)},[]),x=(0,A.useCallback)(e=>{let t=P(f.current),n=M(`#${l.current}`,t),r=n?N(`[data-combobox-option]`,n):null;if(!r)return null;let i=e>=r.length?0:e<0?r.length-1:e;return u.current=i,r?.[i]&&!r[i].hasAttribute(`data-combobox-disabled`)?(b(),r[i].setAttribute(`data-combobox-selected`,`true`),r[i].scrollIntoView({block:`nearest`,behavior:o}),r[i].id):null},[o,b]),S=(0,A.useCallback)(()=>{let e=P(f.current),t=M(`#${l.current} [data-combobox-active]`,e);if(t){let n=N(`#${l.current} [data-combobox-option]`,e).findIndex(e=>e===t);return x(n)}return x(0)},[x]),C=(0,A.useCallback)(()=>{let e=P(f.current),t=N(`#${l.current} [data-combobox-option]`,e);return x(fe(u.current,t,a))},[x,a]),w=(0,A.useCallback)(()=>{let e=P(f.current),t=N(`#${l.current} [data-combobox-option]`,e);return x(de(u.current,t,a))},[x,a]),T=(0,A.useCallback)(()=>{let e=P(f.current),t=N(`#${l.current} [data-combobox-option]`,e);return x(pe(t))},[x]),E=(0,A.useCallback)((e=`selected`,t)=>{if(typeof e==`number`){u.current=e;let n=P(f.current),r=N(`#${l.current} [data-combobox-option]`,n);t?.scrollIntoView&&r[e]?.scrollIntoView({block:`nearest`,behavior:o});return}h.current=window.setTimeout(()=>{let n=P(f.current),r=N(`#${l.current} [data-combobox-option]`,n),i=r.findIndex(t=>t.hasAttribute(`data-combobox-${e}`));u.current=i,t?.scrollIntoView&&r[i]?.scrollIntoView({block:`nearest`,behavior:o})},0)},[]),D=(0,A.useCallback)(()=>{u.current=-1,b()},[b]),O=(0,A.useCallback)(()=>{let e=P(f.current);(N(`#${l.current} [data-combobox-option]`,e)?.[u.current])?.click()},[]),k=(0,A.useCallback)(e=>{l.current=e},[]),j=(0,A.useCallback)(()=>{p.current=window.setTimeout(()=>d.current?.focus(),0)},[]),F=(0,A.useCallback)(()=>{m.current=window.setTimeout(()=>f.current?.focus(),0)},[]),I=(0,A.useCallback)(()=>u.current,[]);return(0,A.useEffect)(()=>()=>{window.clearTimeout(p.current),window.clearTimeout(m.current),window.clearTimeout(h.current)},[]),{dropdownOpened:s,openDropdown:_,closeDropdown:v,toggleDropdown:y,selectedOptionIndex:u.current,getSelectedOptionIndex:I,selectOption:x,selectFirstOption:T,selectActiveOption:S,selectNextOption:C,selectPreviousOption:w,resetSelectedOption:D,updateSelectedOptionIndex:E,listId:l.current,setListId:k,clickSelectedOption:O,searchRef:d,focusSearchInput:j,targetRef:f,focusTarget:F}}var he={keepMounted:!0,keepMountedMode:`display-none`,withinPortal:!0,resetSelectionOnOptionHover:!1,width:`target`,transitionProps:{transition:`fade`,duration:0},size:`sm`},ge=f((e,{size:t,dropdownPadding:n})=>({options:{"--combobox-option-fz":T(t),"--combobox-option-padding":C(t,`combobox-option-padding`)},dropdown:{"--combobox-padding":n===void 0?void 0:m(n),"--combobox-option-fz":T(t),"--combobox-option-padding":C(t,`combobox-option-padding`)}})),Z=e=>{let t=a(`Combobox`,he,e),{classNames:n,styles:r,unstyled:i,children:s,store:c,vars:l,onOptionSubmit:u,onClose:d,size:f,dropdownPadding:p,resetSelectionOnOptionHover:m,__staticSelector:h,readOnly:g,attributes:_,floatingHeight:v,middlewares:y,...b}=t,x=v===`viewport`?{...y,flip:!1,size:{...typeof y?.size==`object`?y.size:{},padding:typeof y?.size==`object`&&y.size.padding!==void 0?y.size.padding:10,apply:({availableHeight:e,availableWidth:t,elements:n,...r})=>{n.floating.style.setProperty(`--combobox-floating-max-height`,`${e}px`);let i=y?.size;typeof i==`object`&&i.apply?i.apply({availableHeight:e,availableWidth:t,elements:n,...r}):i&&Object.assign(n.floating.style,{maxWidth:`${t}px`,maxHeight:`${e}px`})}}}:y,S=me(),C=c||S,w=o({name:h||`Combobox`,classes:L,props:t,classNames:n,styles:r,unstyled:i,attributes:_,vars:l,varsResolver:ge}),T=()=>{d?.(),C.closeDropdown()};return(0,j.jsx)(B,{value:{getStyles:w,store:C,onOptionSubmit:u,size:f,resetSelectionOnOptionHover:m,readOnly:g,floatingHeight:v},children:(0,j.jsx)(E,{opened:C.dropdownOpened,...b,middlewares:x,onChange:e=>!e&&T(),withRoles:!1,unstyled:i,children:s})})};Z.extend=e=>e,Z.classes=L,Z.varsResolver=ge,Z.displayName=`@mantine/core/Combobox`,Z.Target=ue,Z.Dropdown=U,Z.Options=oe,Z.Option=X,Z.Search=ce,Z.Empty=G,Z.Chevron=z,Z.Footer=q,Z.Header=Y,Z.EventsTarget=ie,Z.DropdownTarget=W,Z.Group=J,Z.ClearButton=H,Z.HiddenInput=ae;function _e({children:e,role:t}){let n=(0,A.use)(i);return n?(0,j.jsx)(`div`,{role:t,"aria-labelledby":n.labelId,"aria-describedby":n.describedBy,children:e}):(0,j.jsx)(j.Fragment,{children:e})}var ve={root:`m_5f75b09e`,body:`m_5f6e695e`,labelWrapper:`m_d3ea56bb`,label:`m_8ee546b8`,description:`m_328f68c0`,error:`m_8e8a99cc`},ye=ve;function be({__staticSelector:e,__stylesApiProps:t,className:n,classNames:r,styles:i,unstyled:a,children:s,label:l,description:d,id:f,disabled:p,error:m,size:h,labelPosition:g=`left`,bodyElement:_=`div`,labelElement:v=`label`,variant:y,style:b,vars:x,mod:S,attributes:w,...E}){let D=o({name:e,props:t,className:n,style:b,classes:ve,classNames:r,styles:i,unstyled:a,attributes:w}),O=d?`${f}-description`:void 0,k=m&&typeof m!=`boolean`?`${f}-error`:void 0;return(0,j.jsx)(u,{...D(`root`),__vars:{"--label-fz":T(h),"--label-lh":C(h,`label-lh`)},mod:[{"label-position":g},S],variant:y,size:h,...E,children:(0,j.jsxs)(u,{component:_,htmlFor:_===`label`?f:void 0,...D(`body`),children:[s,(0,j.jsxs)(`div`,{...D(`labelWrapper`),"data-disabled":p||void 0,children:[l&&(0,j.jsx)(u,{component:v,htmlFor:v===`label`?f:void 0,...D(`label`),"data-disabled":p||void 0,children:l}),d&&(0,j.jsx)(c.Description,{id:O,size:h,__inheritStyles:!1,...D(`description`),children:d}),m&&typeof m!=`boolean`&&(0,j.jsx)(c.Error,{id:k,size:h,__inheritStyles:!1,...D(`error`),children:m})]})]})})}be.displayName=`@mantine/core/InlineInput`;function Q(e){return`group`in e}function xe({options:e,search:t,limit:n}){let r=t.trim().toLowerCase(),i=[];for(let a=0;a0)return!1;return!0}function Ce(e,t=new Set){if(Array.isArray(e))for(let n of e)if(Q(n))Ce(n.items,t);else{if(n.value===void 0)throw Error(`[@mantine/core] Each option must have value property`);if(t.has(n.value))throw Error(`[@mantine/core] Duplicate options are not supported. Option with value "${n.value}" was provided more than once`);t.add(n.value)}}function we(e,t){return Array.isArray(e)?e.includes(t):e===t}function Te({data:e,withCheckIcon:t,withAlignedLabels:n,value:r,checkIconPosition:i,unstyled:a,renderOption:o}){if(!Q(e)){let s=we(r,e.value),c=t&&(s?(0,j.jsx)(D,{className:L.optionsDropdownCheckIcon}):n?(0,j.jsx)(`div`,{className:L.optionsDropdownCheckPlaceholder}):null),l=(0,j.jsxs)(j.Fragment,{children:[i===`left`&&c,(0,j.jsx)(`span`,{children:e.label}),i===`right`&&c]});return(0,j.jsx)(Z.Option,{value:e.value,disabled:e.disabled,className:d({[L.optionsDropdownOption]:!a}),"data-reverse":i===`right`||void 0,"data-checked":s||void 0,"aria-selected":s,active:s,children:typeof o==`function`?o({option:e,checked:s}):l})}let s=e.items.map(e=>(0,j.jsx)(Te,{data:e,value:r,unstyled:a,withCheckIcon:t,withAlignedLabels:n,checkIconPosition:i,renderOption:o},`${e.value}`));return(0,j.jsx)(Z.Group,{label:e.group,children:s})}function Ee({data:e,hidden:t,hiddenWhenEmpty:n,filter:r,search:i,limit:a,maxDropdownHeight:o,floatingHeight:s,withScrollArea:c=!0,filterOptions:l=!0,withCheckIcon:u=!1,withAlignedLabels:d=!1,value:f,checkIconPosition:p,nothingFoundMessage:m,unstyled:h,labelId:g,renderOption:_,scrollAreaProps:v,"aria-label":y}){let b=V();Ce(e);let x=typeof i==`string`?(r||xe)({options:e,search:l?i:``,limit:a??1/0}):e,C=Se(x),w=x.map((e,t)=>(0,j.jsx)(Te,{data:e,withCheckIcon:u,withAlignedLabels:d,value:f,checkIconPosition:p,unstyled:h,renderOption:_},Q(e)?`group-${typeof e.group==`string`?e.group:t}`:`${e.value}`));return(0,j.jsx)(Z.Dropdown,{hidden:t||n&&C,"data-composed":!0,children:(0,j.jsxs)(Z.Options,{labelledBy:g,"aria-label":y,children:[c?(0,j.jsx)(S.Autosize,{mah:(s??b.floatingHeight)===`viewport`?`var(--combobox-floating-options-max-height)`:o??220,type:`scroll`,scrollbarSize:`var(--combobox-padding)`,offsetScrollbars:`y`,...v,children:w}):w,C&&m&&(0,j.jsx)(Z.Empty,{children:m})]})})}function De({id:e,label:t,labelProps:n,inputWrapperOrder:r}){if(t&&(!r||r.includes(`label`)))return n?.id||`${e}-label`}var Oe=(0,A.createContext)(null),ke={hiddenInputValuesSeparator:`,`},Ae=s((e=>{let{value:t,defaultValue:n,onChange:r,size:i,wrapperProps:o,children:s,readOnly:l,name:u,hiddenInputValuesSeparator:d,hiddenInputProps:f,maxSelectedValues:p,disabled:m,...h}=a(`SwitchGroup`,ke,e),[_,v]=g({value:t,defaultValue:n,finalValue:[],onChange:r}),y=e=>{let t=e.currentTarget.value;if(l)return;let n=_.includes(t);!n&&p&&_.length>=p||v(n?_.filter(e=>e!==t):[..._,t])},b=e=>{if(m)return!0;if(!p)return!1;let t=_.includes(e),n=_.length>=p;return!t&&n},x=_.join(d);return(0,j.jsx)(Oe,{value:{value:_,onChange:y,size:i,isDisabled:b},children:(0,j.jsxs)(c.Wrapper,{size:i,...o,...h,labelElement:`div`,__staticSelector:`SwitchGroup`,children:[(0,j.jsx)(_e,{role:`group`,children:s}),(0,j.jsx)(`input`,{type:`hidden`,name:u,value:x,...f})]})})}));Ae.classes=c.Wrapper.classes,Ae.displayName=`@mantine/core/SwitchGroup`;var je={root:`m_5f93f3bb`,input:`m_926b4011`,track:`m_9307d992`,thumb:`m_93039a1d`,trackLabel:`m_8277e082`},Me={labelPosition:`right`,withThumbIndicator:!0},Ne=f((e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:h(t),"--switch-height":C(r,`switch-height`),"--switch-width":C(r,`switch-width`),"--switch-thumb-size":C(r,`switch-thumb-size`),"--switch-label-font-size":C(r,`switch-label-font-size`),"--switch-track-label-padding":C(r,`switch-track-label-padding`),"--switch-color":n?w(n,e):void 0}})),$=r(e=>{let t=a(`Switch`,Me,e),{classNames:n,className:r,style:i,styles:s,unstyled:c,vars:l,color:d,label:f,offLabel:p,onLabel:m,id:h,size:_,radius:y,wrapperProps:x,thumbIcon:S,checked:C,defaultChecked:w,onChange:T,labelPosition:E,description:D,error:O,disabled:k,variant:M,rootRef:N,mod:P,withThumbIndicator:F,attributes:I,...ee}=t,L=(0,A.use)(Oe),te=_||L?.size,R=o({name:`Switch`,props:t,classes:je,className:r,style:i,classNames:n,styles:s,unstyled:c,attributes:I,vars:l,varsResolver:Ne}),{styleProps:z,rest:B}=b(ee),V=v(h),H=[D?`${V}-description`:void 0,O&&typeof O!=`boolean`?`${V}-error`:void 0,B[`aria-describedby`]].filter(Boolean).join(` `)||void 0,U={checked:L?.value.includes(B.value)??C,onChange:e=>{L?.onChange(e),T?.(e)}},ne=k||L?.isDisabled?.(B.value),[W,G]=g({value:U.checked??C,defaultValue:w,finalValue:!1});return(0,j.jsxs)(be,{...R(`root`),__staticSelector:`Switch`,__stylesApiProps:t,id:V,size:te,labelPosition:E,label:f,description:D,error:O,disabled:ne,bodyElement:`label`,labelElement:`span`,classNames:n,styles:s,unstyled:c,"data-checked":U.checked,variant:M,ref:N,mod:P,attributes:I,inert:B.inert,...z,...x,children:[(0,j.jsx)(`input`,{...B,...U,disabled:ne,checked:W,"data-checked":U.checked,onChange:e=>{U.onChange?.(e),G(e.currentTarget.checked)},id:V,type:`checkbox`,role:`switch`,inert:B.inert,"aria-describedby":H,...R(`input`)}),(0,j.jsxs)(u,{"aria-hidden":`true`,component:`span`,mod:{error:O,"label-position":E,"without-labels":!m&&!p},...R(`track`),children:[(0,j.jsx)(u,{component:`span`,mod:{"reduce-motion":!0,"with-thumb-indicator":F&&!S},...R(`thumb`),children:S}),(0,j.jsx)(`span`,{...R(`trackLabel`),children:W?m:p})]})]})});$.classes={...je,...ye},$.varsResolver=Ne,$.displayName=`@mantine/core/Switch`,$.Group=Ae;function Pe({time:e,updatedAt:t}){let[n,r]=(0,A.useState)(Date.now);(0,A.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[]);let i=e?.from&&e.to?`${k(e.from)} – ${k(e.to)}`:e?`Last ${e.range??`1h`}`:`Refresh every 30s`;return(0,j.jsxs)(y,{ff:`monospace`,size:`xs`,c:`dimmed`,children:[i,` · `,t?`Updated ${Math.max(0,Math.floor((n-t)/1e3))}s ago`:`Waiting for data`]})}export{Q as a,ee as c,Ee as i,I as l,$ as n,Z as o,De as r,me as s,Pe as t,P as u}; \ No newline at end of file +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{Dt as r,F as i,Ft as a,Nt as o,Ot as s,P as c,Qt as l,Tt as u,Xt as d,Zt as f,_n as p,bn as m,dn as h,en as g,gn as _,in as v,j as y,jt as b,nn as x,nt as S,pn as C,qt as w,un as T}from"./brand-D6fP-cLS.js";import{M as E,j as D}from"./search-P7VEnlsD.js";import{l as O,n as k}from"./format-BZjbsxwM.js";var A=n(e(),1),j=t();function M(e,t=document){let n=t.querySelector(e);if(n)return n;let r=t.querySelectorAll(`*`);for(let t=0;tF(e))}:typeof e==`number`||typeof e==`bigint`||typeof e==`boolean`?{value:e,label:`${e}`}:e}function I(e){return e?e.map(e=>F(e)):[]}function ee(e){return e.reduce((e,t)=>`group`in t?{...e,...ee(t.items)}:(e[`${t.value}`]=t,e),{})}var L={dropdown:`m_88b62a41`,search:`m_985517d8`,options:`m_b2821a6e`,option:`m_92253aa5`,empty:`m_2530cd1d`,header:`m_858f94bd`,footer:`m_82b967cb`,group:`m_254f3e4f`,groupLabel:`m_2bb2e9e5`,chevron:`m_2943220b`,optionsDropdownOption:`m_390b5f4`,optionsDropdownCheckIcon:`m_8ee53fc2`,optionsDropdownCheckPlaceholder:`m_a530ee0a`},te={error:null},R=f((e,{size:t,color:n})=>({chevron:{"--combobox-chevron-size":C(t,`combobox-chevron-size`),"--combobox-chevron-color":n?w(n,e):void 0}})),z=r(e=>{let t=a(`ComboboxChevron`,te,e),{size:n,error:r,style:i,className:s,classNames:c,styles:l,unstyled:d,vars:f,attributes:p,mod:m,...h}=t,g=o({name:`ComboboxChevron`,classes:L,props:t,style:i,className:s,classNames:c,styles:l,unstyled:d,vars:f,varsResolver:R,attributes:p,rootSelector:`chevron`});return(0,j.jsx)(u,{component:`svg`,...h,...g(`chevron`),size:n,viewBox:`0 0 15 15`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,mod:[`combobox-chevron`,{error:r},m],children:(0,j.jsx)(`path`,{d:`M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})});z.classes=L,z.varsResolver=R,z.displayName=`@mantine/core/ComboboxChevron`;var[B,V]=_(`Combobox component was not found in tree`);function H({onMouseDown:e,onClick:t,onClear:n,...r}){return(0,j.jsx)(c.ClearButton,{tabIndex:-1,"aria-hidden":!0,...r,onMouseDown:t=>{t.preventDefault(),e?.(t)},onClick:e=>{n(),t?.(e)}})}H.displayName=`@mantine/core/ComboboxClearButton`;var U=r(e=>{let{classNames:t,styles:n,className:r,style:i,hidden:o,...s}=a(`ComboboxDropdown`,null,e),c=V();return(0,j.jsx)(E.Dropdown,{...s,role:`presentation`,"data-hidden":o||void 0,"data-floating-height":c.floatingHeight||void 0,...c.getStyles(`dropdown`,{className:r,style:i,classNames:t,styles:n})})});U.classes=L,U.displayName=`@mantine/core/ComboboxDropdown`;var ne={refProp:`ref`},W=r(e=>{let{children:t,refProp:n,ref:r}=a(`ComboboxDropdownTarget`,ne,e);if(V(),!p(t))throw Error(`Combobox.DropdownTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);return(0,j.jsx)(E.Target,{ref:r,refProp:n,children:t})});W.displayName=`@mantine/core/ComboboxDropdownTarget`;var G=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`ComboboxEmpty`,null,e),c=V();return(0,j.jsx)(u,{...c.getStyles(`empty`,{className:n,classNames:t,styles:i,style:r}),...s})});G.classes=L,G.displayName=`@mantine/core/ComboboxEmpty`;function K({onKeyDown:e,onClick:t,withKeyboardNavigation:n,withAriaAttributes:r,withExpandedAttribute:i,targetType:a,autoComplete:o}){let s=V(),[c,l]=(0,A.useState)(null),u=t=>{if(e?.(t),!s.readOnly&&n){if(t.nativeEvent.isComposing)return;if(t.nativeEvent.code===`ArrowDown`&&(t.preventDefault(),s.store.dropdownOpened?l(s.store.selectNextOption()):(s.store.openDropdown(`keyboard`),l(s.store.selectActiveOption()),s.store.updateSelectedOptionIndex(`selected`,{scrollIntoView:!0}))),t.nativeEvent.code===`ArrowUp`&&(t.preventDefault(),s.store.dropdownOpened?l(s.store.selectPreviousOption()):(s.store.openDropdown(`keyboard`),l(s.store.selectActiveOption()),s.store.updateSelectedOptionIndex(`selected`,{scrollIntoView:!0}))),t.nativeEvent.code===`Enter`||t.nativeEvent.code===`NumpadEnter`){if(t.nativeEvent.keyCode===229)return;let e=s.store.getSelectedOptionIndex();s.store.dropdownOpened&&e!==-1?(t.preventDefault(),s.store.clickSelectedOption()):a===`button`&&(t.preventDefault(),s.store.openDropdown(`keyboard`))}t.key===`Escape`&&s.store.closeDropdown(`keyboard`),t.nativeEvent.code===`Space`&&a===`button`&&(t.preventDefault(),s.store.toggleDropdown(`keyboard`))}},d=r?{...i?{role:`combobox`}:{},"aria-haspopup":`listbox`,"aria-expanded":i?!!(s.store.listId&&s.store.dropdownOpened):void 0,"aria-controls":s.store.dropdownOpened&&s.store.listId?s.store.listId:void 0,"aria-activedescendant":s.store.dropdownOpened&&c||void 0,autoComplete:o,"data-expanded":s.store.dropdownOpened||void 0,"data-mantine-stop-propagation":s.store.dropdownOpened||void 0}:{},f=e=>{a===`button`&&e.currentTarget.focus(),t?.(e)};return{...d,onKeyDown:u,onClick:f}}var re={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},ie=r(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:o,targetType:s,autoComplete:c,ref:u,...d}=a(`ComboboxEventsTarget`,re,e),f=l(t);if(!f)throw Error(`Combobox.EventsTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let p=V(),m=K({targetType:s,withAriaAttributes:i,withKeyboardNavigation:r,withExpandedAttribute:o,onKeyDown:f.props.onKeyDown,onClick:f.props.onClick,autoComplete:c});return(0,A.cloneElement)(f,{...m,...d,[n]:x(u,p.store.targetRef,O(f))})});ie.displayName=`@mantine/core/ComboboxEventsTarget`;var q=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`ComboboxFooter`,null,e),c=V();return(0,j.jsx)(u,{...c.getStyles(`footer`,{className:n,classNames:t,style:r,styles:i}),...s,onMouseDown:e=>{e.preventDefault()}})});q.classes=L,q.displayName=`@mantine/core/ComboboxFooter`;var J=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,children:s,label:c,id:l,...d}=a(`ComboboxGroup`,null,e),f=V(),p=v(l),m=c!=null&&c!==!1&&c!==``;return(0,j.jsxs)(u,{role:`group`,"aria-labelledby":m?p:void 0,...f.getStyles(`group`,{className:n,classNames:t,style:r,styles:i}),...d,children:[m&&(0,j.jsx)(`div`,{id:p,...f.getStyles(`groupLabel`,{classNames:t,styles:i}),children:c}),s]})});J.classes=L,J.displayName=`@mantine/core/ComboboxGroup`;var Y=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`ComboboxHeader`,null,e),c=V();return(0,j.jsx)(u,{...c.getStyles(`header`,{className:n,classNames:t,style:r,styles:i}),...s,onMouseDown:e=>{e.preventDefault()}})});Y.classes=L,Y.displayName=`@mantine/core/ComboboxHeader`;function ae({value:e,valuesDivider:t=`,`,...n}){return(0,j.jsx)(`input`,{type:`hidden`,value:Array.isArray(e)?e.join(t):e?`${e}`:``,...n})}ae.displayName=`@mantine/core/ComboboxHiddenInput`;var X=r(e=>{let t=a(`ComboboxOption`,null,e),{classNames:n,className:r,style:i,styles:o,vars:s,onClick:c,id:l,active:d,onMouseDown:f,onMouseOver:p,disabled:m,selected:h,mod:g,..._}=t,v=V(),y=(0,A.useId)(),b=l||y;return(0,j.jsx)(u,{...v.getStyles(`option`,{className:r,classNames:n,styles:o,style:i}),"aria-disabled":m||void 0,..._,id:b,mod:[`combobox-option`,{"combobox-active":d,"combobox-disabled":m,"combobox-selected":h},g],role:`option`,onClick:e=>{m?e.preventDefault():(v.onOptionSubmit?.(t.value,t),c?.(e))},onMouseDown:e=>{e.preventDefault(),f?.(e)},onMouseOver:e=>{v.resetSelectionOnOptionHover&&v.store.resetSelectedOption(),p?.(e)}})});X.classes=L,X.displayName=`@mantine/core/ComboboxOption`;var oe=r(e=>{let{classNames:t,className:n,style:r,styles:i,id:o,onMouseDown:s,labelledBy:c,...l}=a(`ComboboxOptions`,null,e),d=V(),f=v(o);return(0,A.useEffect)(()=>{d.store.setListId(f)},[f]),(0,j.jsx)(u,{...d.getStyles(`options`,{className:n,style:r,classNames:t,styles:i}),...l,id:f,role:`listbox`,"aria-labelledby":c,onMouseDown:e=>{e.preventDefault(),s?.(e)}})});oe.classes=L,oe.displayName=`@mantine/core/ComboboxOptions`;var se={withAriaAttributes:!0,withKeyboardNavigation:!0},ce=r(e=>{let{classNames:t,styles:n,unstyled:r,vars:i,withAriaAttributes:o,onKeyDown:s,onClick:l,withKeyboardNavigation:u,size:d,ref:f,...p}=a(`ComboboxSearch`,se,e),m=V(),h=m.getStyles(`search`),g=K({targetType:`input`,withAriaAttributes:o,withKeyboardNavigation:u,withExpandedAttribute:!1,onKeyDown:s,onClick:l,autoComplete:`off`});return(0,j.jsx)(c,{ref:x(f,m.store.searchRef),classNames:[{input:h.className},t],styles:[{input:h.style},n],size:d||m.size,...g,...p,__staticSelector:`Combobox`})});ce.classes=L,ce.displayName=`@mantine/core/ComboboxSearch`;var le={refProp:`ref`,targetType:`input`,withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:`off`},ue=r(e=>{let{children:t,refProp:n,withKeyboardNavigation:r,withAriaAttributes:i,withExpandedAttribute:o,targetType:s,autoComplete:c,ref:u,...d}=a(`ComboboxTarget`,le,e),f=l(t);if(!f)throw Error(`Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let p=V(),m=K({targetType:s,withAriaAttributes:i,withKeyboardNavigation:r,withExpandedAttribute:o,onKeyDown:f.props.onKeyDown,onClick:f.props.onClick,autoComplete:c}),h=(0,A.cloneElement)(f,{...m,...d});return(0,j.jsx)(E.Target,{refProp:n,ref:x(u,p.store.targetRef),children:h})});ue.displayName=`@mantine/core/ComboboxTarget`;function de(e,t,n){for(let n=e-1;n>=0;--n)if(!t[n].hasAttribute(`data-combobox-disabled`))return n;if(n){for(let e=t.length-1;e>-1;--e)if(!t[e].hasAttribute(`data-combobox-disabled`))return e}return e}function fe(e,t,n){for(let n=e+1;n{s||(c(!0),i?.(e))},[c,i,s]),v=(0,A.useCallback)((e=`unknown`)=>{s&&(c(!1),r?.(e))},[c,r,s]),y=(0,A.useCallback)((e=`unknown`)=>{s?v(e):_(e)},[v,_,s]),b=(0,A.useCallback)(()=>{let e=P(f.current);M(`#${l.current} [data-combobox-selected]`,e)?.removeAttribute(`data-combobox-selected`)},[]),x=(0,A.useCallback)(e=>{let t=P(f.current),n=M(`#${l.current}`,t),r=n?N(`[data-combobox-option]`,n):null;if(!r)return null;let i=e>=r.length?0:e<0?r.length-1:e;return u.current=i,r?.[i]&&!r[i].hasAttribute(`data-combobox-disabled`)?(b(),r[i].setAttribute(`data-combobox-selected`,`true`),r[i].scrollIntoView({block:`nearest`,behavior:o}),r[i].id):null},[o,b]),S=(0,A.useCallback)(()=>{let e=P(f.current),t=M(`#${l.current} [data-combobox-active]`,e);if(t){let n=N(`#${l.current} [data-combobox-option]`,e).findIndex(e=>e===t);return x(n)}return x(0)},[x]),C=(0,A.useCallback)(()=>{let e=P(f.current),t=N(`#${l.current} [data-combobox-option]`,e);return x(fe(u.current,t,a))},[x,a]),w=(0,A.useCallback)(()=>{let e=P(f.current),t=N(`#${l.current} [data-combobox-option]`,e);return x(de(u.current,t,a))},[x,a]),T=(0,A.useCallback)(()=>{let e=P(f.current),t=N(`#${l.current} [data-combobox-option]`,e);return x(pe(t))},[x]),E=(0,A.useCallback)((e=`selected`,t)=>{if(typeof e==`number`){u.current=e;let n=P(f.current),r=N(`#${l.current} [data-combobox-option]`,n);t?.scrollIntoView&&r[e]?.scrollIntoView({block:`nearest`,behavior:o});return}h.current=window.setTimeout(()=>{let n=P(f.current),r=N(`#${l.current} [data-combobox-option]`,n),i=r.findIndex(t=>t.hasAttribute(`data-combobox-${e}`));u.current=i,t?.scrollIntoView&&r[i]?.scrollIntoView({block:`nearest`,behavior:o})},0)},[]),D=(0,A.useCallback)(()=>{u.current=-1,b()},[b]),O=(0,A.useCallback)(()=>{let e=P(f.current);(N(`#${l.current} [data-combobox-option]`,e)?.[u.current])?.click()},[]),k=(0,A.useCallback)(e=>{l.current=e},[]),j=(0,A.useCallback)(()=>{p.current=window.setTimeout(()=>d.current?.focus(),0)},[]),F=(0,A.useCallback)(()=>{m.current=window.setTimeout(()=>f.current?.focus(),0)},[]),I=(0,A.useCallback)(()=>u.current,[]);return(0,A.useEffect)(()=>()=>{window.clearTimeout(p.current),window.clearTimeout(m.current),window.clearTimeout(h.current)},[]),{dropdownOpened:s,openDropdown:_,closeDropdown:v,toggleDropdown:y,selectedOptionIndex:u.current,getSelectedOptionIndex:I,selectOption:x,selectFirstOption:T,selectActiveOption:S,selectNextOption:C,selectPreviousOption:w,resetSelectedOption:D,updateSelectedOptionIndex:E,listId:l.current,setListId:k,clickSelectedOption:O,searchRef:d,focusSearchInput:j,targetRef:f,focusTarget:F}}var he={keepMounted:!0,keepMountedMode:`display-none`,withinPortal:!0,resetSelectionOnOptionHover:!1,width:`target`,transitionProps:{transition:`fade`,duration:0},size:`sm`},ge=f((e,{size:t,dropdownPadding:n})=>({options:{"--combobox-option-fz":T(t),"--combobox-option-padding":C(t,`combobox-option-padding`)},dropdown:{"--combobox-padding":n===void 0?void 0:m(n),"--combobox-option-fz":T(t),"--combobox-option-padding":C(t,`combobox-option-padding`)}})),Z=e=>{let t=a(`Combobox`,he,e),{classNames:n,styles:r,unstyled:i,children:s,store:c,vars:l,onOptionSubmit:u,onClose:d,size:f,dropdownPadding:p,resetSelectionOnOptionHover:m,__staticSelector:h,readOnly:g,attributes:_,floatingHeight:v,middlewares:y,...b}=t,x=v===`viewport`?{...y,flip:!1,size:{...typeof y?.size==`object`?y.size:{},padding:typeof y?.size==`object`&&y.size.padding!==void 0?y.size.padding:10,apply:({availableHeight:e,availableWidth:t,elements:n,...r})=>{n.floating.style.setProperty(`--combobox-floating-max-height`,`${e}px`);let i=y?.size;typeof i==`object`&&i.apply?i.apply({availableHeight:e,availableWidth:t,elements:n,...r}):i&&Object.assign(n.floating.style,{maxWidth:`${t}px`,maxHeight:`${e}px`})}}}:y,S=me(),C=c||S,w=o({name:h||`Combobox`,classes:L,props:t,classNames:n,styles:r,unstyled:i,attributes:_,vars:l,varsResolver:ge}),T=()=>{d?.(),C.closeDropdown()};return(0,j.jsx)(B,{value:{getStyles:w,store:C,onOptionSubmit:u,size:f,resetSelectionOnOptionHover:m,readOnly:g,floatingHeight:v},children:(0,j.jsx)(E,{opened:C.dropdownOpened,...b,middlewares:x,onChange:e=>!e&&T(),withRoles:!1,unstyled:i,children:s})})};Z.extend=e=>e,Z.classes=L,Z.varsResolver=ge,Z.displayName=`@mantine/core/Combobox`,Z.Target=ue,Z.Dropdown=U,Z.Options=oe,Z.Option=X,Z.Search=ce,Z.Empty=G,Z.Chevron=z,Z.Footer=q,Z.Header=Y,Z.EventsTarget=ie,Z.DropdownTarget=W,Z.Group=J,Z.ClearButton=H,Z.HiddenInput=ae;function _e({children:e,role:t}){let n=(0,A.use)(i);return n?(0,j.jsx)(`div`,{role:t,"aria-labelledby":n.labelId,"aria-describedby":n.describedBy,children:e}):(0,j.jsx)(j.Fragment,{children:e})}var ve={root:`m_5f75b09e`,body:`m_5f6e695e`,labelWrapper:`m_d3ea56bb`,label:`m_8ee546b8`,description:`m_328f68c0`,error:`m_8e8a99cc`},ye=ve;function be({__staticSelector:e,__stylesApiProps:t,className:n,classNames:r,styles:i,unstyled:a,children:s,label:l,description:d,id:f,disabled:p,error:m,size:h,labelPosition:g=`left`,bodyElement:_=`div`,labelElement:v=`label`,variant:y,style:b,vars:x,mod:S,attributes:w,...E}){let D=o({name:e,props:t,className:n,style:b,classes:ve,classNames:r,styles:i,unstyled:a,attributes:w}),O=d?`${f}-description`:void 0,k=m&&typeof m!=`boolean`?`${f}-error`:void 0;return(0,j.jsx)(u,{...D(`root`),__vars:{"--label-fz":T(h),"--label-lh":C(h,`label-lh`)},mod:[{"label-position":g},S],variant:y,size:h,...E,children:(0,j.jsxs)(u,{component:_,htmlFor:_===`label`?f:void 0,...D(`body`),children:[s,(0,j.jsxs)(`div`,{...D(`labelWrapper`),"data-disabled":p||void 0,children:[l&&(0,j.jsx)(u,{component:v,htmlFor:v===`label`?f:void 0,...D(`label`),"data-disabled":p||void 0,children:l}),d&&(0,j.jsx)(c.Description,{id:O,size:h,__inheritStyles:!1,...D(`description`),children:d}),m&&typeof m!=`boolean`&&(0,j.jsx)(c.Error,{id:k,size:h,__inheritStyles:!1,...D(`error`),children:m})]})]})})}be.displayName=`@mantine/core/InlineInput`;function Q(e){return`group`in e}function xe({options:e,search:t,limit:n}){let r=t.trim().toLowerCase(),i=[];for(let a=0;a0)return!1;return!0}function Ce(e,t=new Set){if(Array.isArray(e))for(let n of e)if(Q(n))Ce(n.items,t);else{if(n.value===void 0)throw Error(`[@mantine/core] Each option must have value property`);if(t.has(n.value))throw Error(`[@mantine/core] Duplicate options are not supported. Option with value "${n.value}" was provided more than once`);t.add(n.value)}}function we(e,t){return Array.isArray(e)?e.includes(t):e===t}function Te({data:e,withCheckIcon:t,withAlignedLabels:n,value:r,checkIconPosition:i,unstyled:a,renderOption:o}){if(!Q(e)){let s=we(r,e.value),c=t&&(s?(0,j.jsx)(D,{className:L.optionsDropdownCheckIcon}):n?(0,j.jsx)(`div`,{className:L.optionsDropdownCheckPlaceholder}):null),l=(0,j.jsxs)(j.Fragment,{children:[i===`left`&&c,(0,j.jsx)(`span`,{children:e.label}),i===`right`&&c]});return(0,j.jsx)(Z.Option,{value:e.value,disabled:e.disabled,className:d({[L.optionsDropdownOption]:!a}),"data-reverse":i===`right`||void 0,"data-checked":s||void 0,"aria-selected":s,active:s,children:typeof o==`function`?o({option:e,checked:s}):l})}let s=e.items.map(e=>(0,j.jsx)(Te,{data:e,value:r,unstyled:a,withCheckIcon:t,withAlignedLabels:n,checkIconPosition:i,renderOption:o},`${e.value}`));return(0,j.jsx)(Z.Group,{label:e.group,children:s})}function Ee({data:e,hidden:t,hiddenWhenEmpty:n,filter:r,search:i,limit:a,maxDropdownHeight:o,floatingHeight:s,withScrollArea:c=!0,filterOptions:l=!0,withCheckIcon:u=!1,withAlignedLabels:d=!1,value:f,checkIconPosition:p,nothingFoundMessage:m,unstyled:h,labelId:g,renderOption:_,scrollAreaProps:v,"aria-label":y}){let b=V();Ce(e);let x=typeof i==`string`?(r||xe)({options:e,search:l?i:``,limit:a??1/0}):e,C=Se(x),w=x.map((e,t)=>(0,j.jsx)(Te,{data:e,withCheckIcon:u,withAlignedLabels:d,value:f,checkIconPosition:p,unstyled:h,renderOption:_},Q(e)?`group-${typeof e.group==`string`?e.group:t}`:`${e.value}`));return(0,j.jsx)(Z.Dropdown,{hidden:t||n&&C,"data-composed":!0,children:(0,j.jsxs)(Z.Options,{labelledBy:g,"aria-label":y,children:[c?(0,j.jsx)(S.Autosize,{mah:(s??b.floatingHeight)===`viewport`?`var(--combobox-floating-options-max-height)`:o??220,type:`scroll`,scrollbarSize:`var(--combobox-padding)`,offsetScrollbars:`y`,...v,children:w}):w,C&&m&&(0,j.jsx)(Z.Empty,{children:m})]})})}function De({id:e,label:t,labelProps:n,inputWrapperOrder:r}){if(t&&(!r||r.includes(`label`)))return n?.id||`${e}-label`}var Oe=(0,A.createContext)(null),ke={hiddenInputValuesSeparator:`,`},Ae=s((e=>{let{value:t,defaultValue:n,onChange:r,size:i,wrapperProps:o,children:s,readOnly:l,name:u,hiddenInputValuesSeparator:d,hiddenInputProps:f,maxSelectedValues:p,disabled:m,...h}=a(`SwitchGroup`,ke,e),[_,v]=g({value:t,defaultValue:n,finalValue:[],onChange:r}),y=e=>{let t=e.currentTarget.value;if(l)return;let n=_.includes(t);!n&&p&&_.length>=p||v(n?_.filter(e=>e!==t):[..._,t])},b=e=>{if(m)return!0;if(!p)return!1;let t=_.includes(e),n=_.length>=p;return!t&&n},x=_.join(d);return(0,j.jsx)(Oe,{value:{value:_,onChange:y,size:i,isDisabled:b},children:(0,j.jsxs)(c.Wrapper,{size:i,...o,...h,labelElement:`div`,__staticSelector:`SwitchGroup`,children:[(0,j.jsx)(_e,{role:`group`,children:s}),(0,j.jsx)(`input`,{type:`hidden`,name:u,value:x,...f})]})})}));Ae.classes=c.Wrapper.classes,Ae.displayName=`@mantine/core/SwitchGroup`;var je={root:`m_5f93f3bb`,input:`m_926b4011`,track:`m_9307d992`,thumb:`m_93039a1d`,trackLabel:`m_8277e082`},Me={labelPosition:`right`,withThumbIndicator:!0},Ne=f((e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:h(t),"--switch-height":C(r,`switch-height`),"--switch-width":C(r,`switch-width`),"--switch-thumb-size":C(r,`switch-thumb-size`),"--switch-label-font-size":C(r,`switch-label-font-size`),"--switch-track-label-padding":C(r,`switch-track-label-padding`),"--switch-color":n?w(n,e):void 0}})),$=r(e=>{let t=a(`Switch`,Me,e),{classNames:n,className:r,style:i,styles:s,unstyled:c,vars:l,color:d,label:f,offLabel:p,onLabel:m,id:h,size:_,radius:y,wrapperProps:x,thumbIcon:S,checked:C,defaultChecked:w,onChange:T,labelPosition:E,description:D,error:O,disabled:k,variant:M,rootRef:N,mod:P,withThumbIndicator:F,attributes:I,...ee}=t,L=(0,A.use)(Oe),te=_||L?.size,R=o({name:`Switch`,props:t,classes:je,className:r,style:i,classNames:n,styles:s,unstyled:c,attributes:I,vars:l,varsResolver:Ne}),{styleProps:z,rest:B}=b(ee),V=v(h),H=[D?`${V}-description`:void 0,O&&typeof O!=`boolean`?`${V}-error`:void 0,B[`aria-describedby`]].filter(Boolean).join(` `)||void 0,U={checked:L?.value.includes(B.value)??C,onChange:e=>{L?.onChange(e),T?.(e)}},ne=k||L?.isDisabled?.(B.value),[W,G]=g({value:U.checked??C,defaultValue:w,finalValue:!1});return(0,j.jsxs)(be,{...R(`root`),__staticSelector:`Switch`,__stylesApiProps:t,id:V,size:te,labelPosition:E,label:f,description:D,error:O,disabled:ne,bodyElement:`label`,labelElement:`span`,classNames:n,styles:s,unstyled:c,"data-checked":U.checked,variant:M,ref:N,mod:P,attributes:I,inert:B.inert,...z,...x,children:[(0,j.jsx)(`input`,{...B,...U,disabled:ne,checked:W,"data-checked":U.checked,onChange:e=>{U.onChange?.(e),G(e.currentTarget.checked)},id:V,type:`checkbox`,role:`switch`,inert:B.inert,"aria-describedby":H,...R(`input`)}),(0,j.jsxs)(u,{"aria-hidden":`true`,component:`span`,mod:{error:O,"label-position":E,"without-labels":!m&&!p},...R(`track`),children:[(0,j.jsx)(u,{component:`span`,mod:{"reduce-motion":!0,"with-thumb-indicator":F&&!S},...R(`thumb`),children:S}),(0,j.jsx)(`span`,{...R(`trackLabel`),children:W?m:p})]})]})});$.classes={...je,...ye},$.varsResolver=Ne,$.displayName=`@mantine/core/Switch`,$.Group=Ae;function Pe({time:e,updatedAt:t}){let[n,r]=(0,A.useState)(Date.now);(0,A.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(e)},[]);let i=e?.from&&e.to?`${k(e.from)} – ${k(e.to)}`:e?`Last ${e.range??`1h`}`:`Refresh every 30s`;return(0,j.jsxs)(y,{ff:`monospace`,size:`xs`,c:`dimmed`,children:[i,` · `,t?`Updated ${Math.max(0,Math.floor((n-t)/1e3))}s ago`:`Waiting for data`]})}export{Q as a,ee as c,Ee as i,I as l,$ as n,Z as o,De as r,me as s,Pe as t,P as u}; \ No newline at end of file diff --git a/internal/ui/dist/assets/logs-DQVfH3k6.js b/internal/ui/dist/assets/logs-BcF87yZO.js similarity index 59% rename from internal/ui/dist/assets/logs-DQVfH3k6.js rename to internal/ui/dist/assets/logs-BcF87yZO.js index 887a18b85..24d9c5d19 100644 --- a/internal/ui/dist/assets/logs-DQVfH3k6.js +++ b/internal/ui/dist/assets/logs-BcF87yZO.js @@ -1 +1 @@ -import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{i as n,r}from"./search-CDra9nG2.js";import{i}from"./index-C1Pd14SU.js";import{n as a,t as o}from"./search-page-uYBxylji.js";var s=e();function c(){let e=r(i.useSearch()),c=t();return(0,s.jsx)(o,{preset:a,search:e,onSearch:(e,t)=>void c({to:`/logs`,search:n(e),replace:t}),onSaved:e=>void c({to:`/dashboards/$dashboardId`,params:{dashboardId:e}})},`logs`)}export{c as component}; \ No newline at end of file +import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{i as n,r}from"./search-pvW8SUhM.js";import{i}from"./index-D7FG-NN3.js";import{n as a,t as o}from"./search-page-ug63oRqo.js";var s=e();function c(){let e=r(i.useSearch()),c=t();return(0,s.jsx)(o,{preset:a,search:e,onSearch:(e,t)=>void c({to:`/logs`,search:n(e),replace:t}),onSaved:e=>void c({to:`/dashboards/$dashboardId`,params:{dashboardId:e}})},`logs`)}export{c as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/mcp-app-frame-C1fa0h58.js b/internal/ui/dist/assets/mcp-app-frame-a5HZdAse.js similarity index 99% rename from internal/ui/dist/assets/mcp-app-frame-C1fa0h58.js rename to internal/ui/dist/assets/mcp-app-frame-a5HZdAse.js index caf9711a9..5295109af 100644 --- a/internal/ui/dist/assets/mcp-app-frame-C1fa0h58.js +++ b/internal/ui/dist/assets/mcp-app-frame-a5HZdAse.js @@ -1,4 +1,4 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{Tt as r,Y as i,a,k as o,s}from"./brand-D6fP-cLS.js";import{a as c}from"./auth-DWqIkMZS.js";import{n as l}from"./chat-DMtvX_Pa.js";import{$ as u,B as d,F as f,G as p,H as m,I as h,J as g,K as _,L as v,M as y,N as b,P as x,Q as S,R as C,U as w,V as T,W as E,X as ee,Y as D,Z as O,at as te,et as k,it as ne,j as re,nt as ie,ot as ae,q as A,rt as oe,st as se,tt as ce,ut as le,z as j}from"./index-C1Pd14SU.js";var ue={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},de;de||={};function fe(e){return ae(y,e)}function pe(e){return te(re,e)}function me(e){return ne(b,e)}function M(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function N(e,t){if(!Array.isArray(e))return[];let n=new Set(t);return e.filter(e=>{if(typeof e!=`string`||/[\s;'\"]/.test(e))return!1;let t=e.match(/^([a-z]+):\/\/([^/]+)$/i);return!!(t&&n.has(t[1].toLowerCase()))})}function he(e){let t=M(M(M(e)?.ui)?.csp),n=N(t?.connectDomains,[`http`,`https`,`ws`,`wss`]),r=N(t?.resourceDomains,[`http`,`https`]),i=N(t?.frameDomains,[`http`,`https`]),a=N(t?.baseUriDomains,[`http`,`https`]),o=r.length?` ${r.join(` `)}`:``,s=[`default-src 'none'`,`worker-src blob:`,`script-src 'self' 'unsafe-inline'${o}`,`style-src 'self' 'unsafe-inline'${o}`,`img-src 'self' data:${o}`,`media-src 'self' data:${o}`,`font-src 'self' data:${o}`,`connect-src ${n.length?n.join(` `):`'none'`}`];return i.length&&s.push(`frame-src ${i.join(` `)}`),a.length&&s.push(`base-uri ${a.join(` `)}`),`${s.join(`; `)};`}var P=Object.create,F=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,_e=Object.getOwnPropertyNames,ve=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty,I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),be=(e,t)=>{let n={};for(var r in e)F(n,r,{get:e[r],enumerable:!0});return t&&F(n,Symbol.toStringTag,{value:`Module`}),n},xe=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_e(t),a=0,o=i.length,s;at[e]).bind(null,s),enumerable:!(r=ge(t,s))||r.enumerable});return e},Se=(e,t,n)=>(n=e==null?{}:P(ve(e)),xe(t||!e||!e.__esModule?F(n,`default`,{value:e,enumerable:!0}):n,e)),Ce=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),we=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),Te=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),Ee=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`]);function De(e){return typeof e==`string`&&we.has(e.replace(/#$/,``))}function Oe(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(Ce.has(n))return`2020-12`;if(we.has(n))return`2019-09`;if(Te.has(n)||Ee.has(n))return`draft-7`;throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var ke=`2025-11-25`,Ae=[ke,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],je=`io.modelcontextprotocol/related-task`,Me=`io.modelcontextprotocol/protocolVersion`,Ne=`io.modelcontextprotocol/clientInfo`,Pe=`io.modelcontextprotocol/serverInfo`,Fe=`io.modelcontextprotocol/clientCapabilities`,Ie=`io.modelcontextprotocol/subscriptionId`,Le=`io.modelcontextprotocol/logLevel`,Re=w(()=>u([S(),A(),j(),f(),O(S(),Re),C(Re)])),L=O(S(),Re),ze=C(Re),Be=u([S(),A().int()]),Ve=S(),He=g({ttl:A().optional()}),Ue=g({taskId:S()}),We=p({progressToken:Be.optional(),[je]:Ue.optional()}),R=g({_meta:We.optional()}),Ge=R.extend({task:He.optional()}),z=g({method:S(),params:R.loose().optional()}),B=g({_meta:We.optional()}),V=g({method:S(),params:B.loose().optional()}),Ke=p({get[Pe](){return at.optional().catch(void 0)}}),H=p({_meta:Ke.optional()}),qe=u([S(),A().int()]),Je=g({jsonrpc:E(`2.0`),id:qe,...z.shape}).strict(),Ye=g({jsonrpc:E(`2.0`),...V.shape}).strict(),Xe=g({jsonrpc:E(`2.0`),id:qe,result:H}).strict(),Ze=g({jsonrpc:E(`2.0`),id:qe.optional(),error:g({code:A().int(),message:S(),data:k().optional()})}).strict(),U=u([Je,Ye,Xe,Ze]),Qe=u([Xe,Ze]),$e=H.strict(),et=B.extend({requestId:qe.optional(),reason:S().optional()}),tt=V.extend({method:E(`notifications/cancelled`),params:et}),nt=g({src:S(),mimeType:S().optional(),sizes:C(S()).optional(),theme:x([`light`,`dark`]).optional()}),rt=g({icons:C(nt).optional()}),it=g({name:S(),title:S().optional()}),at=it.extend({...it.shape,...rt.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),ot=m(g({applyDefaults:j().optional()}),L),W=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,m(g({form:ot.optional(),url:L.optional()}),L.optional())),st=p({list:L.optional(),cancel:L.optional(),requests:p({sampling:p({createMessage:L.optional()}).optional(),elicitation:p({create:L.optional()}).optional()}).optional()}),ct=p({list:L.optional(),cancel:L.optional(),requests:p({tools:p({call:L.optional()}).optional()}).optional()}),lt=g({experimental:O(S(),L).optional(),sampling:g({context:L.optional(),tools:L.optional()}).optional(),elicitation:W.optional(),roots:g({listChanged:j().optional()}).optional(),tasks:st.optional(),extensions:O(S(),L).optional()}),ut=R.extend({protocolVersion:S(),capabilities:lt,clientInfo:at}),dt=z.extend({method:E(`initialize`),params:ut}),ft=g({experimental:O(S(),L).optional(),logging:L.optional(),completions:L.optional(),prompts:g({listChanged:j().optional()}).optional(),resources:g({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:g({listChanged:j().optional()}).optional(),tasks:ct.optional(),extensions:O(S(),L).optional()}),pt=H.extend({protocolVersion:S(),capabilities:ft,serverInfo:at,instructions:S().optional()}),mt=V.extend({method:E(`notifications/initialized`),params:B.optional()}),ht=z.extend({method:E(`server/discover`),params:R.optional()}),gt=H.extend({supportedVersions:C(S()),capabilities:ft,instructions:S().optional()}),_t=z.extend({method:E(`ping`),params:R.optional()}),vt=g({progress:A(),total:D(A()),message:D(S())}),yt=g({...B.shape,...vt.shape,progressToken:Be}),bt=V.extend({method:E(`notifications/progress`),params:yt}),xt=R.extend({cursor:Ve.optional()}),St=z.extend({params:xt.optional()}),Ct=H.extend({nextCursor:Ve.optional()}),wt=g({uri:S(),mimeType:D(S()),_meta:O(S(),k()).optional()}),Tt=wt.extend({text:S()}),Et=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Dt=wt.extend({blob:Et}),Ot=x([`user`,`assistant`]),kt=g({audience:C(Ot).optional(),priority:A().min(0).max(1).optional(),lastModified:fe({offset:!0}).optional()}),At=g({...it.shape,...rt.shape,uri:S(),description:D(S()),mimeType:D(S()),size:D(A()),annotations:kt.optional(),_meta:D(p({}))}),jt=g({...it.shape,...rt.shape,uriTemplate:S(),description:D(S()),mimeType:D(S()),annotations:kt.optional(),_meta:D(p({}))}),Mt=St.extend({method:E(`resources/list`)}),Nt=Ct.extend({resources:C(At)}),Pt=St.extend({method:E(`resources/templates/list`)}),Ft=Ct.extend({resourceTemplates:C(jt)}),G=R.extend({uri:S()}),It=G,Lt=z.extend({method:E(`resources/read`),params:It}),Rt=H.extend({contents:C(u([Tt,Dt]))}),zt=V.extend({method:E(`notifications/resources/list_changed`),params:B.optional()}),Bt=G,Vt=z.extend({method:E(`resources/subscribe`),params:Bt}),Ht=G,Ut=z.extend({method:E(`resources/unsubscribe`),params:Ht}),Wt=g({toolsListChanged:j().optional(),promptsListChanged:j().optional(),resourcesListChanged:j().optional(),resourceSubscriptions:C(S()).optional()}),Gt=R.extend({notifications:Wt}),Kt=z.extend({method:E(`subscriptions/listen`),params:Gt}),qt=B.extend({notifications:Wt}),Jt=V.extend({method:E(`notifications/subscriptions/acknowledged`),params:qt}),Yt=Ke.extend({[Ie]:qe}),Xt=H.extend({_meta:Yt}),Zt=B.extend({uri:S()}),Qt=V.extend({method:E(`notifications/resources/updated`),params:Zt}),$t=g({name:S(),description:D(S()),required:D(j())}),en=g({...it.shape,...rt.shape,description:D(S()),arguments:D(C($t)),_meta:D(p({}))}),K=St.extend({method:E(`prompts/list`)}),tn=Ct.extend({prompts:C(en)}),nn=R.extend({name:S(),arguments:O(S(),S()).optional()}),rn=z.extend({method:E(`prompts/get`),params:nn}),an=g({type:E(`text`),text:S(),annotations:kt.optional(),_meta:O(S(),k()).optional()}),on=g({type:E(`image`),data:Et,mimeType:S(),annotations:kt.optional(),_meta:O(S(),k()).optional()}),sn=g({type:E(`audio`),data:Et,mimeType:S(),annotations:kt.optional(),_meta:O(S(),k()).optional()}),cn=g({type:E(`tool_use`),name:S(),id:S(),input:O(S(),k()),_meta:O(S(),k()).optional()}),ln=g({type:E(`resource`),resource:u([Tt,Dt]),annotations:kt.optional(),_meta:O(S(),k()).optional()}),un=At.extend({type:E(`resource_link`)}),dn=u([an,on,sn,un,ln]),fn=g({role:Ot,content:dn}),pn=H.extend({description:S().optional(),messages:C(fn)}),mn=V.extend({method:E(`notifications/prompts/list_changed`),params:B.optional()}),hn=g({title:S().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),gn=g({taskSupport:x([`required`,`optional`,`forbidden`]).optional()}),_n=g({...it.shape,...rt.shape,description:S().optional(),inputSchema:g({type:E(`object`),properties:O(S(),Re).optional(),required:C(S()).optional()}).catchall(k()),outputSchema:p({$schema:S().optional()}).optional(),annotations:hn.optional(),execution:gn.optional(),_meta:O(S(),k()).optional()}),vn=St.extend({method:E(`tools/list`)}),yn=Ct.extend({tools:C(_n)}),bn=H.extend({content:C(dn).default([]),structuredContent:k().optional(),isError:j().optional()}),xn=bn.or(H.extend({toolResult:k()})),Sn=Ge.extend({name:S(),arguments:O(S(),k()).optional()}),Cn=z.extend({method:E(`tools/call`),params:Sn}),wn=V.extend({method:E(`notifications/tools/list_changed`),params:B.optional()}),Tn=g({autoRefresh:j().default(!0),debounceMs:A().int().nonnegative().default(300)}),En=x([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Dn=R.extend({level:En}),On=z.extend({method:E(`logging/setLevel`),params:Dn}),kn=B.extend({level:En,logger:S().optional(),data:k()}),An=V.extend({method:E(`notifications/message`),params:kn}),jn=g({name:S().optional()}),Mn=g({hints:C(jn).optional(),costPriority:A().min(0).max(1).optional(),speedPriority:A().min(0).max(1).optional(),intelligencePriority:A().min(0).max(1).optional()}),Nn=g({mode:x([`auto`,`required`,`none`]).optional()}),Pn=g({type:E(`tool_result`),toolUseId:S().describe(`The unique identifier for the corresponding tool call.`),content:C(dn),structuredContent:k().optional(),isError:j().optional(),_meta:O(S(),k()).optional()}),Fn=d(`type`,[an,on,sn]),In=d(`type`,[an,on,sn,cn,Pn]),Ln=g({role:Ot,content:u([In,C(In)]),_meta:O(S(),k()).optional()}),Rn=Ge.extend({messages:C(Ln),modelPreferences:Mn.optional(),systemPrompt:S().optional(),includeContext:x([`none`,`thisServer`,`allServers`]).optional(),temperature:A().optional(),maxTokens:A().int(),stopSequences:C(S()).optional(),metadata:L.optional(),tools:C(_n).optional(),toolChoice:Nn.optional()}),zn=z.extend({method:E(`sampling/createMessage`),params:Rn}),Bn=H.extend({model:S(),stopReason:D(x([`endTurn`,`stopSequence`,`maxTokens`]).or(S())),role:Ot,content:Fn}),Vn=H.extend({model:S(),stopReason:D(x([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(S())),role:Ot,content:u([In,C(In)])}),Hn=g({type:E(`boolean`),title:S().optional(),description:S().optional(),default:j().optional()}),Un=g({type:E(`string`),title:S().optional(),description:S().optional(),minLength:A().optional(),maxLength:A().optional(),format:x([`email`,`uri`,`date`,`date-time`]).optional(),default:S().optional()}),Wn=g({type:x([`number`,`integer`]),title:S().optional(),description:S().optional(),minimum:A().optional(),maximum:A().optional(),default:A().optional()}),Gn=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),default:S().optional()}),Kn=g({type:E(`string`),title:S().optional(),description:S().optional(),oneOf:C(g({const:S(),title:S()})),default:S().optional()}),qn=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),enumNames:C(S()).optional(),default:S().optional()}),Jn=u([Gn,Kn]),Yn=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({type:E(`string`),enum:C(S())}),default:C(S()).optional()}),Xn=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({anyOf:C(g({const:S(),title:S()}))}),default:C(S()).optional()}),Zn=u([Yn,Xn]),Qn=u([qn,Jn,Zn]),$n=u([Qn,Hn,Un,Wn]),er=Ge.extend({mode:E(`form`).optional(),message:S(),requestedSchema:g({type:E(`object`),properties:O(S(),$n),required:C(S()).optional()}).catchall(k())}),tr=Ge.extend({mode:E(`url`),message:S(),elicitationId:S(),url:S().url()}),nr=u([er,tr]),rr=z.extend({method:E(`elicitation/create`),params:nr}),ir=B.extend({elicitationId:S()}),ar=V.extend({method:E(`notifications/elicitation/complete`),params:ir}),or=H.extend({action:x([`accept`,`decline`,`cancel`]),content:ee(e=>e===null?void 0:e,O(S(),u([S(),A(),j(),C(S())])).optional())}),sr=g({type:E(`ref/resource`),uri:S()}),cr=g({type:E(`ref/prompt`),name:S()}),lr=R.extend({ref:u([cr,sr]),argument:g({name:S(),value:S()}),context:g({arguments:O(S(),S()).optional()}).optional()}),ur=z.extend({method:E(`completion/complete`),params:lr}),dr=H.extend({completion:p({values:C(S()).max(100),total:D(A().int()),hasMore:D(j())})}),fr=g({uri:S().startsWith(`file://`),name:S().optional(),_meta:O(S(),k()).optional()}),pr=z.extend({method:E(`roots/list`),params:R.optional()}),mr=H.extend({roots:C(fr)}),hr=V.extend({method:E(`notifications/roots/list_changed`),params:B.optional()}),gr=p({ttl:A().optional(),pollInterval:A().optional()}),_r=x([`working`,`input_required`,`completed`,`failed`,`cancelled`]),vr=g({taskId:S(),status:_r,ttl:u([A(),f()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:D(A()),statusMessage:D(S())}),yr=H.extend({task:vr}),br=B.merge(vr),xr=V.extend({method:E(`notifications/tasks/status`),params:br}),Sr=z.extend({method:E(`tasks/get`),params:R.extend({taskId:S()})}),Cr=H.merge(vr),wr=z.extend({method:E(`tasks/result`),params:R.extend({taskId:S()})}),Tr=H.loose(),Er=St.extend({method:E(`tasks/list`)}),Dr=Ct.extend({tasks:C(vr)}),Or=z.extend({method:E(`tasks/cancel`),params:R.extend({taskId:S()})}),kr=H.merge(vr),Ar=u([_t,dt,ht,ur,On,rn,K,Mt,Pt,Lt,Vt,Ut,Kt,Cn,vn]),jr=u([tt,bt,mt,hr]),Mr=u([$e,Bn,Vn,or,mr]),Nr=u([_t,zn,rr,pr]),Pr=u([tt,bt,An,Qt,zt,wn,mn,Jt,ar]),Fr=u([$e,pt,gt,dr,pn,tn,Nt,Ft,Rt,bn,yn,Xt]),q=ce().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ue.custom,message:`URL must be parseable`,fatal:!0}),se}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Ir=p({resource:S().url(),authorization_servers:C(q).optional(),jwks_uri:S().url().optional(),scopes_supported:C(S()).optional(),bearer_methods_supported:C(S()).optional(),resource_signing_alg_values_supported:C(S()).optional(),resource_name:S().optional(),resource_documentation:S().optional(),resource_policy_uri:S().url().optional(),resource_tos_uri:S().url().optional(),tls_client_certificate_bound_access_tokens:j().optional(),authorization_details_types_supported:C(S()).optional(),dpop_signing_alg_values_supported:C(S()).optional(),dpop_bound_access_tokens_required:j().optional()}),Lr=p({issuer:S(),authorization_endpoint:q,token_endpoint:q,registration_endpoint:q.optional(),scopes_supported:C(S()).optional(),response_types_supported:C(S()),response_modes_supported:C(S()).optional(),grant_types_supported:C(S()).optional(),token_endpoint_auth_methods_supported:C(S()).optional(),token_endpoint_auth_signing_alg_values_supported:C(S()).optional(),service_documentation:q.optional(),revocation_endpoint:q.optional(),revocation_endpoint_auth_methods_supported:C(S()).optional(),revocation_endpoint_auth_signing_alg_values_supported:C(S()).optional(),introspection_endpoint:S().optional(),introspection_endpoint_auth_methods_supported:C(S()).optional(),introspection_endpoint_auth_signing_alg_values_supported:C(S()).optional(),code_challenge_methods_supported:C(S()).optional(),client_id_metadata_document_supported:j().optional(),authorization_response_iss_parameter_supported:j().optional().catch(void 0),dpop_signing_alg_values_supported:C(S()).optional()}),Rr=p({issuer:S(),authorization_endpoint:q,token_endpoint:q,userinfo_endpoint:q.optional(),jwks_uri:q,registration_endpoint:q.optional(),scopes_supported:C(S()).optional(),response_types_supported:C(S()),response_modes_supported:C(S()).optional(),grant_types_supported:C(S()).optional(),acr_values_supported:C(S()).optional(),subject_types_supported:C(S()),id_token_signing_alg_values_supported:C(S()),id_token_encryption_alg_values_supported:C(S()).optional(),id_token_encryption_enc_values_supported:C(S()).optional(),userinfo_signing_alg_values_supported:C(S()).optional(),userinfo_encryption_alg_values_supported:C(S()).optional(),userinfo_encryption_enc_values_supported:C(S()).optional(),request_object_signing_alg_values_supported:C(S()).optional(),request_object_encryption_alg_values_supported:C(S()).optional(),request_object_encryption_enc_values_supported:C(S()).optional(),token_endpoint_auth_methods_supported:C(S()).optional(),token_endpoint_auth_signing_alg_values_supported:C(S()).optional(),display_values_supported:C(S()).optional(),claim_types_supported:C(S()).optional(),claims_supported:C(S()).optional(),service_documentation:S().optional(),claims_locales_supported:C(S()).optional(),ui_locales_supported:C(S()).optional(),claims_parameter_supported:j().optional(),request_parameter_supported:j().optional(),request_uri_parameter_supported:j().optional(),require_request_uri_registration:j().optional(),op_policy_uri:q.optional(),op_tos_uri:q.optional(),client_id_metadata_document_supported:j().optional(),authorization_response_iss_parameter_supported:j().optional().catch(void 0)}),zr=g({...Rr.shape,...Lr.pick({code_challenge_methods_supported:!0}).shape}),Br=g({access_token:S(),id_token:S().optional(),token_type:S(),expires_in:me().optional(),scope:S().optional(),refresh_token:S().optional(),issuer:S().optional().catch(void 0)}).strip(),Vr=g({issued_token_type:E(`urn:ietf:params:oauth:token-type:id-jag`),access_token:S(),token_type:S().optional(),expires_in:A().optional(),scope:S().optional()}).strip(),Hr=g({error:S(),error_description:S().optional(),error_uri:S().optional()}),Ur=q.optional().or(E(``).transform(()=>void 0)),Wr=g({redirect_uris:C(q),token_endpoint_auth_method:S().optional(),grant_types:C(S()).optional(),response_types:C(S()).optional(),application_type:S().optional(),client_name:S().optional(),client_uri:q.optional(),logo_uri:Ur,scope:S().optional(),contacts:C(S()).optional(),tos_uri:Ur,policy_uri:S().optional(),jwks_uri:q.optional(),jwks:v().optional(),software_id:S().optional(),software_version:S().optional(),software_statement:S().optional()}).strip(),Gr=g({client_id:S(),client_secret:S().optional(),client_id_issued_at:A().optional(),client_secret_expires_at:A().optional(),issuer:S().optional().catch(void 0)}).strip(),Kr=Wr.merge(Gr),qr=g({error:S(),error_description:S().optional()}).strip(),Jr=g({token:S(),token_type_hint:S().optional()}).strip(),Yr=Symbol.for(`mcp.sdk.errorBrands`);function Xr(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Yr,{value:n,enumerable:!1,configurable:!0})}function Zr(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Yr)){let n=t[Yr];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var Qr=function(e){return e.InvalidRequest=`invalid_request`,e.InvalidClient=`invalid_client`,e.InvalidGrant=`invalid_grant`,e.UnauthorizedClient=`unauthorized_client`,e.UnsupportedGrantType=`unsupported_grant_type`,e.InvalidScope=`invalid_scope`,e.AccessDenied=`access_denied`,e.ServerError=`server_error`,e.TemporarilyUnavailable=`temporarily_unavailable`,e.UnsupportedResponseType=`unsupported_response_type`,e.UnsupportedTokenType=`unsupported_token_type`,e.InvalidToken=`invalid_token`,e.MethodNotAllowed=`method_not_allowed`,e.TooManyRequests=`too_many_requests`,e.InvalidClientMetadata=`invalid_client_metadata`,e.InvalidRedirectUri=`invalid_redirect_uri`,e.InsufficientScope=`insufficient_scope`,e.InvalidTarget=`invalid_target`,e.InvalidDpopProof=`invalid_dpop_proof`,e.UseDpopNonce=`use_dpop_nonce`,e}({}),$r=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return Zr(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Zr(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Xr(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},J=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),Y=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return Zr(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Zr(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,Xr(this,new.target)}},ei=class extends Y{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}};function ti(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function ni(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e};return delete t.issuer,t}function ri({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length=ii}function si(e){return e.filter(e=>!oi(e))}function ci(e){return e.filter(e=>oi(e))}function li(e){let t=e.structuredContent;return t===void 0||typeof t==`object`&&t&&!Array.isArray(t)||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}var ui=[`task`,`inputRequests`,`requestState`];function di(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||ui.some(t=>t in e)?e:{...e,content:[]}}function fi(){let e=w(()=>u([S(),A(),j(),f(),O(S(),e),C(e)])),t=O(S(),e),n=u([S(),A().int()]),r=S(),i=g({ttl:A().optional()}),a=g({taskId:S()}),o=p({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=g({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=g({method:S(),params:s.loose().optional()}),h=g({_meta:o.optional()}),_=g({method:S(),params:h.loose().optional()}),v=p({_meta:o.optional()}),y=u([S(),A().int()]),b=v.strict(),T=h.extend({requestId:y.optional(),reason:S().optional()}),te=_.extend({method:E(`notifications/cancelled`),params:T}),ne=g({src:S(),mimeType:S().optional(),sizes:C(S()).optional(),theme:x([`light`,`dark`]).optional()}),re=g({icons:C(ne).optional()}),ie=g({name:S(),title:S().optional()}),ae=ie.extend({...ie.shape,...re.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),oe=m(g({applyDefaults:j().optional()}),t),se=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,m(g({form:oe.optional(),url:t.optional()}),t.optional())),ce=p({list:t.optional(),cancel:t.optional(),requests:p({sampling:p({createMessage:t.optional()}).optional(),elicitation:p({create:t.optional()}).optional()}).optional()}),le=p({list:t.optional(),cancel:t.optional(),requests:p({tools:p({call:t.optional()}).optional()}).optional()}),ue=g({experimental:O(S(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:se.optional(),roots:g({listChanged:j().optional()}).optional(),tasks:ce.optional(),extensions:O(S(),t).optional()}),de=s.extend({protocolVersion:S(),capabilities:ue,clientInfo:ae}),pe=l.extend({method:E(`initialize`),params:de}),me=g({experimental:O(S(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:j().optional()}).optional(),resources:g({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:g({listChanged:j().optional()}).optional(),tasks:le.optional(),extensions:O(S(),t).optional()}),M=v.extend({protocolVersion:S(),capabilities:me,serverInfo:ae,instructions:S().optional()}),N=_.extend({method:E(`notifications/initialized`),params:h.optional()}),he=l.extend({method:E(`ping`),params:s.optional()}),P=g({progress:A(),total:D(A()),message:D(S())}),F=g({...h.shape,...P.shape,progressToken:n}),ge=_.extend({method:E(`notifications/progress`),params:F}),_e=s.extend({cursor:r.optional()}),ve=l.extend({params:_e.optional()}),ye=v.extend({nextCursor:r.optional()}),I=g({uri:S(),mimeType:D(S()),_meta:O(S(),k()).optional()}),be=I.extend({text:S()}),xe=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Se=I.extend({blob:xe}),Ce=x([`user`,`assistant`]),we=g({audience:C(Ce).optional(),priority:A().min(0).max(1).optional(),lastModified:fe({offset:!0}).optional()}),Te=g({...ie.shape,...re.shape,uri:S(),description:D(S()),mimeType:D(S()),size:D(A()),annotations:we.optional(),_meta:D(p({}))}),Ee=g({...ie.shape,...re.shape,uriTemplate:S(),description:D(S()),mimeType:D(S()),annotations:we.optional(),_meta:D(p({}))}),De=ve.extend({method:E(`resources/list`)}),Oe=ye.extend({resources:C(Te)}),ke=ve.extend({method:E(`resources/templates/list`)}),Ae=ye.extend({resourceTemplates:C(Ee)}),je=s.extend({uri:S()}),Me=je,Ne=l.extend({method:E(`resources/read`),params:Me}),Pe=v.extend({contents:C(u([be,Se]))}),Fe=_.extend({method:E(`notifications/resources/list_changed`),params:h.optional()}),Ie=je,Le=l.extend({method:E(`resources/subscribe`),params:Ie}),Re=je,L=l.extend({method:E(`resources/unsubscribe`),params:Re}),ze=h.extend({uri:S()}),Be=_.extend({method:E(`notifications/resources/updated`),params:ze}),Ve=g({name:S(),description:D(S()),required:D(j())}),He=g({...ie.shape,...re.shape,description:D(S()),arguments:D(C(Ve)),_meta:D(p({}))}),Ue=ve.extend({method:E(`prompts/list`)}),We=ye.extend({prompts:C(He)}),R=s.extend({name:S(),arguments:O(S(),S()).optional()}),Ge=l.extend({method:E(`prompts/get`),params:R}),z=g({type:E(`text`),text:S(),annotations:we.optional(),_meta:O(S(),k()).optional()}),B=g({type:E(`image`),data:xe,mimeType:S(),annotations:we.optional(),_meta:O(S(),k()).optional()}),V=g({type:E(`audio`),data:xe,mimeType:S(),annotations:we.optional(),_meta:O(S(),k()).optional()}),Ke=g({type:E(`tool_use`),name:S(),id:S(),input:O(S(),k()),_meta:O(S(),k()).optional()}),H=g({type:E(`resource`),resource:u([be,Se]),annotations:we.optional(),_meta:O(S(),k()).optional()}),qe=Te.extend({type:E(`resource_link`)}),Je=u([z,B,V,qe,H]),Ye=g({role:Ce,content:Je}),Xe=v.extend({description:S().optional(),messages:C(Ye)}),Ze=_.extend({method:E(`notifications/prompts/list_changed`),params:h.optional()}),U=g({title:S().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),Qe=g({taskSupport:x([`required`,`optional`,`forbidden`]).optional()}),$e=g({...ie.shape,...re.shape,description:S().optional(),inputSchema:g({type:E(`object`),properties:O(S(),e).optional(),required:C(S()).optional()}).catchall(k()),outputSchema:g({type:E(`object`),properties:O(S(),e).optional(),required:C(S()).optional()}).catchall(k()).optional(),annotations:U.optional(),execution:Qe.optional(),_meta:O(S(),k()).optional()}),et=ve.extend({method:E(`tools/list`)}),tt=ye.extend({tools:C($e)}),nt=v.extend({content:C(Je),structuredContent:O(S(),k()).optional(),isError:j().optional()}),rt=c.extend({name:S(),arguments:O(S(),k()).optional()}),it=l.extend({method:E(`tools/call`),params:rt}),at=_.extend({method:E(`notifications/tools/list_changed`),params:h.optional()}),ot=x([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),W=s.extend({level:ot}),st=l.extend({method:E(`logging/setLevel`),params:W}),ct=h.extend({level:ot,logger:S().optional(),data:k()}),lt=_.extend({method:E(`notifications/message`),params:ct}),ut=g({name:S().optional()}),dt=g({hints:C(ut).optional(),costPriority:A().min(0).max(1).optional(),speedPriority:A().min(0).max(1).optional(),intelligencePriority:A().min(0).max(1).optional()}),ft=g({mode:x([`auto`,`required`,`none`]).optional()}),pt=g({type:E(`tool_result`),toolUseId:S().describe(`The unique identifier for the corresponding tool call.`),content:C(Je),structuredContent:g({}).loose().optional(),isError:j().optional(),_meta:O(S(),k()).optional()}),mt=d(`type`,[z,B,V]),ht=d(`type`,[z,B,V,Ke,pt]),gt=g({role:Ce,content:u([ht,C(ht)]),_meta:O(S(),k()).optional()}),_t=c.extend({messages:C(gt),modelPreferences:dt.optional(),systemPrompt:S().optional(),includeContext:x([`none`,`thisServer`,`allServers`]).optional(),temperature:A().optional(),maxTokens:A().int(),stopSequences:C(S()).optional(),metadata:t.optional(),tools:C($e).optional(),toolChoice:ft.optional()}),vt=l.extend({method:E(`sampling/createMessage`),params:_t}),yt=v.extend({model:S(),stopReason:D(x([`endTurn`,`stopSequence`,`maxTokens`]).or(S())),role:Ce,content:mt}),bt=v.extend({model:S(),stopReason:D(x([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(S())),role:Ce,content:u([ht,C(ht)])}),xt=g({type:E(`boolean`),title:S().optional(),description:S().optional(),default:j().optional()}),St=g({type:E(`string`),title:S().optional(),description:S().optional(),minLength:A().optional(),maxLength:A().optional(),format:x([`email`,`uri`,`date`,`date-time`]).optional(),default:S().optional()}),Ct=g({type:x([`number`,`integer`]),title:S().optional(),description:S().optional(),minimum:A().optional(),maximum:A().optional(),default:A().optional()}),wt=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),default:S().optional()}),Tt=g({type:E(`string`),title:S().optional(),description:S().optional(),oneOf:C(g({const:S(),title:S()})),default:S().optional()}),Et=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),enumNames:C(S()).optional(),default:S().optional()}),Dt=u([wt,Tt]),Ot=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({type:E(`string`),enum:C(S())}),default:C(S()).optional()}),kt=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({anyOf:C(g({const:S(),title:S()}))}),default:C(S()).optional()}),At=u([Ot,kt]),jt=u([Et,Dt,At]),Mt=u([jt,xt,St,Ct]),Nt=c.extend({mode:E(`form`).optional(),message:S(),requestedSchema:g({type:E(`object`),properties:O(S(),Mt),required:C(S()).optional()}).catchall(k())}),Pt=c.extend({mode:E(`url`),message:S(),elicitationId:S(),url:S().url()}),Ft=u([Nt,Pt]),G=l.extend({method:E(`elicitation/create`),params:Ft}),It=h.extend({elicitationId:S()}),Lt=_.extend({method:E(`notifications/elicitation/complete`),params:It}),Rt=v.extend({action:x([`accept`,`decline`,`cancel`]),content:ee(e=>e===null?void 0:e,O(S(),u([S(),A(),j(),C(S())])).optional())}),zt=g({type:E(`ref/resource`),uri:S()}),Bt=g({type:E(`ref/prompt`),name:S()}),Vt=s.extend({ref:u([Bt,zt]),argument:g({name:S(),value:S()}),context:g({arguments:O(S(),S()).optional()}).optional()}),Ht=l.extend({method:E(`completion/complete`),params:Vt}),Ut=v.extend({completion:p({values:C(S()).max(100),total:D(A().int()),hasMore:D(j())})}),Wt=g({uri:S().startsWith(`file://`),name:S().optional(),_meta:O(S(),k()).optional()}),Gt=l.extend({method:E(`roots/list`),params:s.optional()}),Kt=v.extend({roots:C(Wt)}),qt=_.extend({method:E(`notifications/roots/list_changed`),params:h.optional()}),Jt=p({ttl:A().optional(),pollInterval:A().optional()}),Yt=x([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Xt=g({taskId:S(),status:Yt,ttl:u([A(),f()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:D(A()),statusMessage:D(S())}),Zt=v.extend({task:Xt}),Qt=h.merge(Xt),$t=_.extend({method:E(`notifications/tasks/status`),params:Qt}),en=l.extend({method:E(`tasks/get`),params:s.extend({taskId:S()})}),K=v.merge(Xt),tn=l.extend({method:E(`tasks/result`),params:s.extend({taskId:S()})}),nn=v.loose(),rn=ve.extend({method:E(`tasks/list`)}),an=ye.extend({tasks:C(Xt)}),on=l.extend({method:E(`tasks/cancel`),params:s.extend({taskId:S()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:h,NotificationSchema:_,ResultSchema:v,RequestIdSchema:y,EmptyResultSchema:b,CancelledNotificationParamsSchema:T,CancelledNotificationSchema:te,IconSchema:ne,IconsSchema:re,BaseMetadataSchema:ie,ImplementationSchema:ae,ClientTasksCapabilitySchema:ce,ServerTasksCapabilitySchema:le,ClientCapabilitiesSchema:ue,InitializeRequestParamsSchema:de,InitializeRequestSchema:pe,ServerCapabilitiesSchema:me,InitializeResultSchema:M,InitializedNotificationSchema:N,PingRequestSchema:he,ProgressSchema:P,ProgressNotificationParamsSchema:F,ProgressNotificationSchema:ge,PaginatedRequestParamsSchema:_e,PaginatedRequestSchema:ve,PaginatedResultSchema:ye,ResourceContentsSchema:I,TextResourceContentsSchema:be,BlobResourceContentsSchema:Se,RoleSchema:Ce,AnnotationsSchema:we,ResourceSchema:Te,ResourceTemplateSchema:Ee,ListResourcesRequestSchema:De,ListResourcesResultSchema:Oe,ListResourceTemplatesRequestSchema:ke,ListResourceTemplatesResultSchema:Ae,ResourceRequestParamsSchema:je,ReadResourceRequestParamsSchema:Me,ReadResourceRequestSchema:Ne,ReadResourceResultSchema:Pe,ResourceListChangedNotificationSchema:Fe,SubscribeRequestParamsSchema:Ie,SubscribeRequestSchema:Le,UnsubscribeRequestParamsSchema:Re,UnsubscribeRequestSchema:L,ResourceUpdatedNotificationParamsSchema:ze,ResourceUpdatedNotificationSchema:Be,PromptArgumentSchema:Ve,PromptSchema:He,ListPromptsRequestSchema:Ue,ListPromptsResultSchema:We,GetPromptRequestParamsSchema:R,GetPromptRequestSchema:Ge,TextContentSchema:z,ImageContentSchema:B,AudioContentSchema:V,ToolUseContentSchema:Ke,EmbeddedResourceSchema:H,ResourceLinkSchema:qe,ContentBlockSchema:Je,PromptMessageSchema:Ye,GetPromptResultSchema:Xe,PromptListChangedNotificationSchema:Ze,ToolAnnotationsSchema:U,ToolExecutionSchema:Qe,ToolSchema:$e,ListToolsRequestSchema:et,ListToolsResultSchema:tt,CallToolResultSchema:nt,CallToolRequestParamsSchema:rt,CallToolRequestSchema:it,ToolListChangedNotificationSchema:at,LoggingLevelSchema:ot,SetLevelRequestParamsSchema:W,SetLevelRequestSchema:st,LoggingMessageNotificationParamsSchema:ct,LoggingMessageNotificationSchema:lt,ModelHintSchema:ut,ModelPreferencesSchema:dt,ToolChoiceSchema:ft,ToolResultContentSchema:pt,SamplingContentSchema:mt,SamplingMessageContentBlockSchema:ht,SamplingMessageSchema:gt,CreateMessageRequestParamsSchema:_t,CreateMessageRequestSchema:vt,CreateMessageResultSchema:yt,CreateMessageResultWithToolsSchema:bt,BooleanSchemaSchema:xt,StringSchemaSchema:St,NumberSchemaSchema:Ct,UntitledSingleSelectEnumSchemaSchema:wt,TitledSingleSelectEnumSchemaSchema:Tt,LegacyTitledEnumSchemaSchema:Et,SingleSelectEnumSchemaSchema:Dt,UntitledMultiSelectEnumSchemaSchema:Ot,TitledMultiSelectEnumSchemaSchema:kt,MultiSelectEnumSchemaSchema:At,EnumSchemaSchema:jt,PrimitiveSchemaDefinitionSchema:Mt,ElicitRequestFormParamsSchema:Nt,ElicitRequestURLParamsSchema:Pt,ElicitRequestParamsSchema:Ft,ElicitRequestSchema:G,ElicitationCompleteNotificationParamsSchema:It,ElicitationCompleteNotificationSchema:Lt,ElicitResultSchema:Rt,ResourceTemplateReferenceSchema:zt,PromptReferenceSchema:Bt,CompleteRequestParamsSchema:Vt,CompleteRequestSchema:Ht,CompleteResultSchema:Ut,RootSchema:Wt,ListRootsRequestSchema:Gt,ListRootsResultSchema:Kt,RootsListChangedNotificationSchema:qt,TaskCreationParamsSchema:Jt,TaskStatusSchema:Yt,TaskSchema:Xt,CreateTaskResultSchema:Zt,TaskStatusNotificationParamsSchema:Qt,TaskStatusNotificationSchema:$t,GetTaskRequestSchema:en,GetTaskResultSchema:K,GetTaskPayloadRequestSchema:tn,GetTaskPayloadResultSchema:nn,ListTasksRequestSchema:rn,ListTasksResultSchema:an,CancelTaskRequestSchema:on,CancelTaskResultSchema:v.merge(Xt),ClientRequestSchema:u([he,pe,Ht,st,Ge,Ue,De,ke,Ne,Le,L,it,et,en,tn,rn,on]),ClientNotificationSchema:u([te,ge,N,qt,$t]),ClientResultSchema:u([b,yt,bt,Rt,Kt,K,an,Zt]),ServerRequestSchema:u([he,vt,G,Gt,en,tn,rn,on]),ServerNotificationSchema:u([te,ge,lt,Be,Fe,at,Ze,$t,Lt]),ServerResultSchema:u([b,M,Ut,Xe,We,Oe,Ae,Pe,nt,tt,K,an,Zt]),CallToolResultWireSchema:k().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of ui)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(di).pipe(nt)}}var pi;function mi(){return pi??=fi()}function hi(e){return e.type!==`object`}var gi=new Set([`const`,`enum`,`default`,`examples`]),_i=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function vi(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function yi(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(vi(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=De(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&vi(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=gi.has(o)?s:_i.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}var bi={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},xi={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},Si={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Ci;function wi(){if(Ci)return Ci;let e=mi();return Ci={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Ci}function Ti(e){return Object.prototype.hasOwnProperty.call(bi,e)}function Ei(e){return Object.prototype.hasOwnProperty.call(xi,e)}function Di(e){return Object.prototype.hasOwnProperty.call(Si,e)}function Oi(e){return Di(e)?wi().resultSchemas[e]:void 0}function ki(e){return Ti(e)?wi().requestSchemas[e]:void 0}function Ai(e){return Ei(e)?wi().notificationSchemas[e]:void 0}Object.keys(bi),Object.keys(xi);function ji(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mi(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Ni={ok:!1,reason:`not-in-era`};function Pi(e){return ji(e)&&ji(e.outputSchema)&&hi(e.outputSchema)}function Fi(e){return e}var Ii={era:`2025-11-25`,hasRequestMethod:Ti,hasNotificationMethod:Ei,validateRequest:(e,t)=>Mi(ki(e),t),validateResult:(e,t)=>Mi(Oi(e),t),validateNotification:(e,t)=>Mi(Ai(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Ni,validateInputResponse:()=>Ni,samplingResultVariant:((e,t)=>{let n=mi();return Mi(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=li(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&hi(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(ji(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:Fi(e)}}return{kind:`complete`,result:Fi(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>Pi(e))?t:{...t,tools:n.map(e=>Pi(e)?{...e,outputSchema:yi(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function Li(){let e=w(()=>u([S(),A(),j(),f(),O(S(),e),C(e)])),t=O(S(),e),n=u([S(),A().int()]),r=S(),i=u([S(),A().int()]),a=x([`user`,`assistant`]),o=x([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=g({ttl:A().optional()}),l=g({taskId:S()}),d=p({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),h=g({_meta:d.optional()}),_=h.extend({task:c.optional()}),v=g({_meta:d.optional()}),y=g({method:S(),params:v.loose().optional()}),b=g({src:S(),mimeType:S().optional(),sizes:C(S()).optional(),theme:x([`light`,`dark`]).optional()}),T=g({icons:C(b).optional()}),te=g({name:S(),title:S().optional()}),ne=te.extend({...te.shape,...T.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),re=m(g({applyDefaults:j().optional()}),t),ie=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,m(g({form:re.optional(),url:t.optional()}),t.optional())),ae=p({list:t.optional(),cancel:t.optional(),requests:p({sampling:p({createMessage:t.optional()}).optional(),elicitation:p({create:t.optional()}).optional()}).optional()}),oe=p({list:t.optional(),cancel:t.optional(),requests:p({tools:p({call:t.optional()}).optional()}).optional()}),se=g({experimental:O(S(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:ie.optional(),roots:g({listChanged:j().optional()}).optional(),tasks:ae.optional(),extensions:O(S(),t).optional()}),ce=g({experimental:O(S(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:j().optional()}).optional(),resources:g({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:g({listChanged:j().optional()}).optional(),tasks:oe.optional(),extensions:O(S(),t).optional()}),le=g({progress:A(),total:D(A()),message:D(S())}),ue=g({...v.shape,...le.shape,progressToken:n}),de=y.extend({method:E(`notifications/progress`),params:ue}),pe=v.extend({level:o,logger:S().optional(),data:k()}),me=y.extend({method:E(`notifications/message`),params:pe}),M=g({uri:S(),mimeType:D(S()),_meta:O(S(),k()).optional()}),N=M.extend({text:S()}),he=M.extend({blob:s}),P=g({audience:C(a).optional(),priority:A().min(0).max(1).optional(),lastModified:fe({offset:!0}).optional()}),F=g({...te.shape,...T.shape,uri:S(),description:D(S()),mimeType:D(S()),size:D(A()),annotations:P.optional(),_meta:D(p({}))}),ge=g({...te.shape,...T.shape,uriTemplate:S(),description:D(S()),mimeType:D(S()),annotations:P.optional(),_meta:D(p({}))}),_e=y.extend({method:E(`notifications/resources/list_changed`),params:v.optional()}),ve=v.extend({uri:S()}),ye=y.extend({method:E(`notifications/resources/updated`),params:ve}),I=g({name:S(),description:D(S()),required:D(j())}),be=g({...te.shape,...T.shape,description:D(S()),arguments:D(C(I)),_meta:D(p({}))}),xe=y.extend({method:E(`notifications/prompts/list_changed`),params:v.optional()}),Se=g({type:E(`text`),text:S(),annotations:P.optional(),_meta:O(S(),k()).optional()}),Ce=g({type:E(`image`),data:s,mimeType:S(),annotations:P.optional(),_meta:O(S(),k()).optional()}),we=g({type:E(`audio`),data:s,mimeType:S(),annotations:P.optional(),_meta:O(S(),k()).optional()}),Te=g({type:E(`tool_use`),name:S(),id:S(),input:O(S(),k()),_meta:O(S(),k()).optional()}),Ee=g({type:E(`resource`),resource:u([N,he]),annotations:P.optional(),_meta:O(S(),k()).optional()}),De=F.extend({type:E(`resource_link`)}),Oe=u([Se,Ce,we,De,Ee]),ke=g({role:a,content:Oe}),Ae=g({title:S().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),je=y.extend({method:E(`notifications/tools/list_changed`),params:v.optional()}),Ie=g({name:S().optional()}),Re=g({hints:C(Ie).optional(),costPriority:A().min(0).max(1).optional(),speedPriority:A().min(0).max(1).optional(),intelligencePriority:A().min(0).max(1).optional()}),L=g({mode:x([`auto`,`required`,`none`]).optional()}),ze=g({type:E(`boolean`),title:S().optional(),description:S().optional(),default:j().optional()}),Be=g({type:E(`string`),title:S().optional(),description:S().optional(),minLength:A().optional(),maxLength:A().optional(),format:x([`email`,`uri`,`date`,`date-time`]).optional(),default:S().optional()}),Ve=g({type:x([`number`,`integer`]),title:S().optional(),description:S().optional(),minimum:A().optional(),maximum:A().optional(),default:A().optional()}),He=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),default:S().optional()}),Ue=g({type:E(`string`),title:S().optional(),description:S().optional(),oneOf:C(g({const:S(),title:S()})),default:S().optional()}),We=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),enumNames:C(S()).optional(),default:S().optional()}),R=u([He,Ue]),Ge=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({type:E(`string`),enum:C(S())}),default:C(S()).optional()}),z=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({anyOf:C(g({const:S(),title:S()}))}),default:C(S()).optional()}),B=u([Ge,z]),V=u([We,R,B]),Ke=u([V,ze,Be,Ve]),H=_.extend({mode:E(`form`).optional(),message:S(),requestedSchema:g({type:E(`object`),properties:O(S(),Ke),required:C(S()).optional()}).catchall(k())}),qe=g({type:E(`ref/resource`),uri:S()}),Je=g({type:E(`ref/prompt`),name:S()}),Ye=g({uri:S().startsWith(`file://`),name:S().optional(),_meta:O(S(),k()).optional()}),Xe=se.shape,Ze=g({experimental:Xe.experimental,sampling:Xe.sampling,elicitation:Xe.elicitation,roots:Xe.roots,extensions:Xe.extensions}),U=ce.shape,Qe=g({experimental:U.experimental,logging:U.logging,completions:U.completions,prompts:U.prompts,resources:U.resources,tools:U.tools,extensions:U.extensions}),$e=p({progressToken:n.optional(),[Me]:S(),[Ne]:ne.optional(),[Fe]:Ze,[Le]:o.optional()}),et=g({...te.shape,...T.shape,description:S().optional(),inputSchema:p({$schema:S().optional(),type:E(`object`)}),outputSchema:p({$schema:S().optional()}).optional(),annotations:Ae.optional(),_meta:O(S(),k()).optional()}),tt=g({type:E(`tool_result`),toolUseId:S(),content:C(Oe),structuredContent:k().optional(),isError:j().optional(),_meta:O(S(),k()).optional()}),nt=u([Se,Ce,we,Te,tt]),rt=g({role:a,content:u([nt,C(nt)]),_meta:O(S(),k()).optional()}),it=S(),at=p({[Pe]:ne.optional().catch(void 0)}),ot=at.optional();function W(e){return p({_meta:ot,resultType:it.default(`complete`),...e})}let st=W({}),ct=W({nextCursor:r.optional()}),lt=W({content:C(Oe),structuredContent:k().optional(),isError:j().optional()}),ut=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),tools:C(et),nextCursor:r.optional()}),dt=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),prompts:C(be),nextCursor:r.optional()}),ft=W({description:S().optional(),messages:C(ke)}),pt=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),resources:C(F),nextCursor:r.optional()}),mt=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),resourceTemplates:C(ge),nextCursor:r.optional()}),ht=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),contents:C(u([N,he]))}),gt=W({completion:g({values:C(S()).max(100),total:A().int().optional(),hasMore:j().optional()}).loose()}),_t=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`])}),vt=W({ttlMs:A().int().min(0).catch(0),cacheScope:x([`public`,`private`]).catch(`private`),supportedVersions:C(S()),capabilities:Qe,instructions:S().optional()}),yt=g({messages:C(rt),modelPreferences:Re.optional(),systemPrompt:S().optional(),includeContext:x([`none`,`thisServer`,`allServers`]).optional(),temperature:A().optional(),maxTokens:A().int(),stopSequences:C(S()).optional(),metadata:t.optional(),tools:C(et).optional(),toolChoice:L.optional()}),bt=g({method:E(`sampling/createMessage`),params:yt}),xt=g({method:E(`roots/list`),params:g({_meta:O(S(),k()).optional()}).optional()}),St=g({...rt.shape,model:S(),stopReason:S().optional()}),Ct=g({roots:C(Ye)}),wt=g({action:x([`accept`,`decline`,`cancel`]),content:O(S(),u([S(),A(),j(),C(S())])).optional()}),Tt=g({mode:E(`url`),message:S(),url:S().url()}),Et=u([H,Tt]),Dt=g({method:E(`elicitation/create`),params:Et}),Ot=u([bt,xt,Dt]),kt=u([St,Ct,wt]),At=O(S(),Ot),jt=O(S(),kt),Mt=W({inputRequests:At.optional(),requestState:S().optional()}),Nt={inputResponses:jt.optional(),requestState:S().optional()},Pt=g({_meta:$e,...Nt}),Ft=p({progressToken:n.optional()});function G(e,t){return g({method:E(e),params:g({_meta:$e,...t})})}function It(e,t){return g({method:E(e),params:g({_meta:Ft.optional(),...t}).optional()})}let Lt={name:S(),arguments:O(S(),k()).optional(),...Nt},Rt={cursor:r.optional()},zt=G(`tools/call`,Lt),Bt=G(`tools/list`,Rt),Vt=G(`prompts/list`,Rt),Ht=G(`prompts/get`,{name:S(),arguments:O(S(),S()).optional(),...Nt}),Ut=G(`resources/list`,Rt),Wt=G(`resources/templates/list`,Rt),Gt=G(`resources/read`,{uri:S(),...Nt}),Kt={ref:u([Je,qe]),argument:g({name:S(),value:S()}),context:g({arguments:O(S(),S()).optional()}).optional()},qt=G(`completion/complete`,Kt),Jt=G(`server/discover`,{}),Yt=g({toolsListChanged:j().optional(),promptsListChanged:j().optional(),resourcesListChanged:j().optional(),resourceSubscriptions:C(S()).optional()}),Xt={notifications:Yt},Zt=G(`subscriptions/listen`,Xt),Qt=at.extend({"io.modelcontextprotocol/subscriptionId":i}),$t=p({_meta:Qt,resultType:it.default(`complete`)}),en={"tools/call":It(`tools/call`,Lt),"tools/list":It(`tools/list`,Rt),"prompts/get":It(`prompts/get`,{name:S(),arguments:O(S(),S()).optional()}),"prompts/list":It(`prompts/list`,Rt),"resources/list":It(`resources/list`,Rt),"resources/templates/list":It(`resources/templates/list`,Rt),"resources/read":It(`resources/read`,{uri:S()}),"completion/complete":It(`completion/complete`,Kt),"server/discover":It(`server/discover`,{}),"subscriptions/listen":It(`subscriptions/listen`,Xt)};function K(e){return p({_meta:ot,...e})}let tn={"tools/call":K({content:C(Oe),structuredContent:k().optional(),isError:j().optional()}),"tools/list":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),tools:C(et),nextCursor:r.optional()}),"prompts/get":K({description:S().optional(),messages:C(ke)}),"prompts/list":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),prompts:C(be),nextCursor:r.optional()}),"resources/list":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),resources:C(F),nextCursor:r.optional()}),"resources/templates/list":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),resourceTemplates:C(ge),nextCursor:r.optional()}),"resources/read":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),contents:C(u([N,he]))}),"completion/complete":K({completion:g({values:C(S()).max(100),total:A().int().optional(),hasMore:j().optional()}).loose()}),"server/discover":K({ttlMs:A().int().min(0).catch(0),cacheScope:x([`public`,`private`]).catch(`private`),supportedVersions:C(S()),capabilities:Qe,instructions:S().optional()}),"subscriptions/listen":K({})},nn=p({"io.modelcontextprotocol/subscriptionId":i.optional()}),rn=g({method:E(`notifications/subscriptions/acknowledged`),params:g({_meta:nn.optional(),notifications:Yt})}),an=g({_meta:nn.optional(),requestId:i,reason:S().optional()}),on=g({method:E(`notifications/cancelled`),params:an}),sn={"notifications/cancelled":on,"notifications/progress":de,"notifications/message":me,"notifications/resources/updated":ye,"notifications/resources/list_changed":_e,"notifications/tools/list_changed":je,"notifications/prompts/list_changed":xe,"notifications/subscriptions/acknowledged":rn},cn=e=>g({jsonrpc:E(`2.0`),id:u([S(),A().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:d,BaseRequestParamsSchema:h,TaskAugmentedRequestParamsSchema:_,NotificationsParamsSchema:v,NotificationSchema:y,IconSchema:b,IconsSchema:T,BaseMetadataSchema:te,ImplementationSchema:ne,ClientTasksCapabilitySchema:ae,ServerTasksCapabilitySchema:oe,ClientCapabilitiesSchema:se,ServerCapabilitiesSchema:ce,ProgressSchema:le,ProgressNotificationParamsSchema:ue,ProgressNotificationSchema:de,LoggingMessageNotificationParamsSchema:pe,LoggingMessageNotificationSchema:me,ResourceContentsSchema:M,TextResourceContentsSchema:N,BlobResourceContentsSchema:he,AnnotationsSchema:P,ResourceSchema:F,ResourceTemplateSchema:ge,ResourceListChangedNotificationSchema:_e,ResourceUpdatedNotificationParamsSchema:ve,ResourceUpdatedNotificationSchema:ye,PromptArgumentSchema:I,PromptSchema:be,PromptListChangedNotificationSchema:xe,TextContentSchema:Se,ImageContentSchema:Ce,AudioContentSchema:we,ToolUseContentSchema:Te,EmbeddedResourceSchema:Ee,ResourceLinkSchema:De,ContentBlockSchema:Oe,PromptMessageSchema:ke,ToolAnnotationsSchema:Ae,ToolListChangedNotificationSchema:je,ModelHintSchema:Ie,ModelPreferencesSchema:Re,ToolChoiceSchema:L,BooleanSchemaSchema:ze,StringSchemaSchema:Be,NumberSchemaSchema:Ve,UntitledSingleSelectEnumSchemaSchema:He,TitledSingleSelectEnumSchemaSchema:Ue,LegacyTitledEnumSchemaSchema:We,SingleSelectEnumSchemaSchema:R,UntitledMultiSelectEnumSchemaSchema:Ge,TitledMultiSelectEnumSchemaSchema:z,MultiSelectEnumSchemaSchema:B,EnumSchemaSchema:V,PrimitiveSchemaDefinitionSchema:Ke,ElicitRequestFormParamsSchema:H,ResourceTemplateReferenceSchema:qe,PromptReferenceSchema:Je,RootSchema:Ye,ClientCapabilities2026Schema:Ze,ServerCapabilities2026Schema:Qe,RequestMetaEnvelopeSchema:$e,ToolSchema:et,ToolResultContentSchema:tt,SamplingMessageContentBlockSchema:nt,SamplingMessageSchema:rt,ResultTypeSchema:it,ResultMetaSchema:at,ResultSchema:st,PaginatedResultSchema:ct,CallToolResultSchema:lt,ListToolsResultSchema:ut,ListPromptsResultSchema:dt,GetPromptResultSchema:ft,ListResourcesResultSchema:pt,ListResourceTemplatesResultSchema:mt,ReadResourceResultSchema:ht,CompleteResultSchema:gt,CacheableResultSchema:_t,DiscoverResultSchema:vt,CreateMessageRequestParamsSchema:yt,CreateMessageRequestSchema:bt,ListRootsRequestSchema:xt,CreateMessageResultSchema:St,ListRootsResultSchema:Ct,ElicitResultSchema:wt,ElicitRequestURLParamsSchema:Tt,ElicitRequestParamsSchema:Et,ElicitRequestSchema:Dt,InputRequestSchema:Ot,InputResponseSchema:kt,InputRequestsSchema:At,InputResponsesSchema:jt,InputRequiredResultSchema:Mt,InputResponseRequestParamsSchema:Pt,CallToolRequestSchema:zt,ListToolsRequestSchema:Bt,ListPromptsRequestSchema:Vt,GetPromptRequestSchema:Ht,ListResourcesRequestSchema:Ut,ListResourceTemplatesRequestSchema:Wt,ReadResourceRequestSchema:Gt,CompleteRequestSchema:qt,DiscoverRequestSchema:Jt,SubscriptionFilterSchema:Yt,SubscriptionsListenRequestSchema:Zt,SubscriptionsListenResultMetaSchema:Qt,SubscriptionsListenResultSchema:$t,dispatchRequestSchemas:en,dispatchResultSchemas:tn,NotificationMetaSchema:nn,SubscriptionsAcknowledgedNotificationSchema:rn,CancelledNotificationParamsSchema:an,CancelledNotificationSchema:on,notificationSchemas2026:sn,JSONRPCResultResponseSchema:cn(st),CallToolResultResponseSchema:cn(u([lt,Mt])),ListToolsResultResponseSchema:cn(ut),ListPromptsResultResponseSchema:cn(dt),GetPromptResultResponseSchema:cn(u([ft,Mt])),ListResourcesResultResponseSchema:cn(pt),ListResourceTemplatesResultResponseSchema:cn(mt),ReadResourceResultResponseSchema:cn(u([ht,Mt])),CompleteResultResponseSchema:cn(gt),DiscoverResultResponseSchema:cn(vt),SubscriptionsListenResultResponseSchema:cn($t)}}var Ri;function zi(){return Ri??=Li()}var Bi=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Vi(e){return Bi.includes(e)}var Hi=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Ui(e){return e[Hi]}function Wi(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Gi(e){return e===`public`||e===`private`}var X=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),Z=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return Zr(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Zr(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Xr(this,new.target)}static fromError(t,n,r){if(t===X.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new qi(e.elicitations,n)}if(t===X.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Ji({supported:e.supported,requested:e.requested},n)}if(t===X.InvalidParams||t===X.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===X.ResourceNotFound||Object.keys(e).length===1))return new Ki(e.uri,n)}if(t===X.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Yi({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},Ki=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(X.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},qi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(X.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Ji=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(X.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Yi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(X.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Xi=0,Zi=`private`,Qi=[`tools/call`,`prompts/get`,`resources/read`];function $i(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||Qi.includes(e))return t;throw new Z(X.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function ea(e,t){let n=Ui(t);if(t.resultType!==`complete`||!Vi(e))return n===void 0?t:aa(t);let r=t,i=Wi(r.ttlMs)?r.ttlMs:ra(n),a=Gi(r.cacheScope)?r.cacheScope:ia(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Hi],o}function ta(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function na(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[Pe]:t}}:!ta(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[Pe]:t}}}function ra(e){return e!==void 0&&Wi(e.ttlMs)?e.ttlMs:Xi}function ia(e){return e!==void 0&&Gi(e.cacheScope)?e.cacheScope:Zi}function aa(e){let t={...e};return delete t[Hi],t}var oa=[`elicitation/create`,`sampling/createMessage`,`roots/list`],sa;function ca(){if(sa)return sa;let e=zi();return sa={request:{"elicitation/create":g({method:E(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":g({method:E(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":g({method:E(`roots/list`),params:p({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},sa}function la(e){return oa.includes(e)}function ua(e){return la(e)?ca().request[e]:void 0}function da(e){return la(e)?ca().response[e]:void 0}var fa={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},pa={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function ma(e){return Object.prototype.hasOwnProperty.call(fa,e)}function ha(e){return Object.prototype.hasOwnProperty.call(pa,e)}function ga(e){return Object.prototype.hasOwnProperty.call(fa,e)}function _a(e){return ma(e)?zi().dispatchRequestSchemas[e]:void 0}function va(e){return ga(e)?zi().dispatchResultSchemas[e]:void 0}function ya(e){return ha(e)?zi().notificationSchemas2026[e]:void 0}Object.keys(fa),Object.keys(pa);function ba(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xa(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Sa={ok:!1,reason:`not-in-era`},Ca=[Me,Fe];function wa(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>ba(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!ba(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(ba(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}var Ta={era:`2026-07-28`,hasRequestMethod:ma,hasNotificationMethod:ha,hasInputRequestMethod:e=>ua(e)!==void 0,validateRequest:(e,t)=>xa(_a(e),t),validateResult:(e,t)=>xa(va(e),t),validateNotification:(e,t)=>xa(ya(e),t),validateInputRequest:(e,t)=>xa(ua(e),t),validateInputResponse:(e,t)=>xa(da(e),t),samplingResultVariant:()=>Sa,outboundEnvelope(e){return{[Me]:e.protocolVersion,[Ne]:e.clientInfo,[Fe]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of Ca)n in e||t.push({key:n,problem:`missing`});let n=zi().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>li(e),inputRequestSchema:ua,decodeResult(e,t){if(!ba(t))return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=ba(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:zi().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new Y(J.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=Da(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return na(ea(e,$i(e,wa(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=zi().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}},Ea;function Da(){if(Ea)return Ea;let e=zi();return Ea={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},Ea}var Oa=`2026-07-28`;function ka(e){return e!==void 0&&oi(e)?Ta:Ii}function Aa(e){return e.revision===void 0?e.era===`modern`?Ta.era:Ii.era:ka(e.revision).era}function ja(e){return Pa.some(t=>t.hasRequestMethod(e))}function Ma(e){return Pa.some(t=>t.hasNotificationMethod(e))}function Na(e){return e===`tasks/get`||e===`tasks/cancel`}var Pa=[Ii,Ta],Fa=be({AnnotationsSchema:()=>kt,AudioContentSchema:()=>sn,BaseMetadataSchema:()=>it,BaseRequestParamsSchema:()=>R,BlobResourceContentsSchema:()=>Dt,BooleanSchemaSchema:()=>Hn,CallToolRequestParamsSchema:()=>Sn,CallToolRequestSchema:()=>Cn,CallToolResultSchema:()=>bn,CancelTaskRequestSchema:()=>Or,CancelTaskResultSchema:()=>kr,CancelledNotificationParamsSchema:()=>et,CancelledNotificationSchema:()=>tt,ClientCapabilitiesSchema:()=>lt,ClientNotificationSchema:()=>jr,ClientRequestSchema:()=>Ar,ClientResultSchema:()=>Mr,ClientTasksCapabilitySchema:()=>st,CompatibilityCallToolResultSchema:()=>xn,CompleteRequestParamsSchema:()=>lr,CompleteRequestSchema:()=>ur,CompleteResultSchema:()=>dr,ContentBlockSchema:()=>dn,CreateMessageRequestParamsSchema:()=>Rn,CreateMessageRequestSchema:()=>zn,CreateMessageResultSchema:()=>Bn,CreateMessageResultWithToolsSchema:()=>Vn,CreateTaskResultSchema:()=>yr,CursorSchema:()=>Ve,DiscoverRequestSchema:()=>ht,DiscoverResultSchema:()=>gt,ElicitRequestFormParamsSchema:()=>er,ElicitRequestParamsSchema:()=>nr,ElicitRequestSchema:()=>rr,ElicitRequestURLParamsSchema:()=>tr,ElicitResultSchema:()=>or,ElicitationCompleteNotificationParamsSchema:()=>ir,ElicitationCompleteNotificationSchema:()=>ar,EmbeddedResourceSchema:()=>ln,EmptyResultSchema:()=>$e,EnumSchemaSchema:()=>Qn,GetPromptRequestParamsSchema:()=>nn,GetPromptRequestSchema:()=>rn,GetPromptResultSchema:()=>pn,GetTaskPayloadRequestSchema:()=>wr,GetTaskPayloadResultSchema:()=>Tr,GetTaskRequestSchema:()=>Sr,GetTaskResultSchema:()=>Cr,IconSchema:()=>nt,IconsSchema:()=>rt,ImageContentSchema:()=>on,ImplementationSchema:()=>at,InitializeRequestParamsSchema:()=>ut,InitializeRequestSchema:()=>dt,InitializeResultSchema:()=>pt,InitializedNotificationSchema:()=>mt,JSONArraySchema:()=>ze,JSONObjectSchema:()=>L,JSONRPCErrorResponseSchema:()=>Ze,JSONRPCMessageSchema:()=>U,JSONRPCNotificationSchema:()=>Ye,JSONRPCRequestSchema:()=>Je,JSONRPCResponseSchema:()=>Qe,JSONRPCResultResponseSchema:()=>Xe,JSONValueSchema:()=>Re,LegacyTitledEnumSchemaSchema:()=>qn,ListChangedOptionsBaseSchema:()=>Tn,ListPromptsRequestSchema:()=>K,ListPromptsResultSchema:()=>tn,ListResourceTemplatesRequestSchema:()=>Pt,ListResourceTemplatesResultSchema:()=>Ft,ListResourcesRequestSchema:()=>Mt,ListResourcesResultSchema:()=>Nt,ListRootsRequestSchema:()=>pr,ListRootsResultSchema:()=>mr,ListTasksRequestSchema:()=>Er,ListTasksResultSchema:()=>Dr,ListToolsRequestSchema:()=>vn,ListToolsResultSchema:()=>yn,LoggingLevelSchema:()=>En,LoggingMessageNotificationParamsSchema:()=>kn,LoggingMessageNotificationSchema:()=>An,ModelHintSchema:()=>jn,ModelPreferencesSchema:()=>Mn,MultiSelectEnumSchemaSchema:()=>Zn,NotificationSchema:()=>V,NotificationsParamsSchema:()=>B,NumberSchemaSchema:()=>Wn,PaginatedRequestParamsSchema:()=>xt,PaginatedRequestSchema:()=>St,PaginatedResultSchema:()=>Ct,PingRequestSchema:()=>_t,PrimitiveSchemaDefinitionSchema:()=>$n,ProgressNotificationParamsSchema:()=>yt,ProgressNotificationSchema:()=>bt,ProgressSchema:()=>vt,ProgressTokenSchema:()=>Be,PromptArgumentSchema:()=>$t,PromptListChangedNotificationSchema:()=>mn,PromptMessageSchema:()=>fn,PromptReferenceSchema:()=>cr,PromptSchema:()=>en,ReadResourceRequestParamsSchema:()=>It,ReadResourceRequestSchema:()=>Lt,ReadResourceResultSchema:()=>Rt,RelatedTaskMetadataSchema:()=>Ue,RequestIdSchema:()=>qe,RequestMetaSchema:()=>We,RequestSchema:()=>z,ResourceContentsSchema:()=>wt,ResourceLinkSchema:()=>un,ResourceListChangedNotificationSchema:()=>zt,ResourceRequestParamsSchema:()=>G,ResourceSchema:()=>At,ResourceTemplateReferenceSchema:()=>sr,ResourceTemplateSchema:()=>jt,ResourceUpdatedNotificationParamsSchema:()=>Zt,ResourceUpdatedNotificationSchema:()=>Qt,ResultMetaObjectSchema:()=>Ke,ResultSchema:()=>H,RoleSchema:()=>Ot,RootSchema:()=>fr,RootsListChangedNotificationSchema:()=>hr,SamplingContentSchema:()=>Fn,SamplingMessageContentBlockSchema:()=>In,SamplingMessageSchema:()=>Ln,ServerCapabilitiesSchema:()=>ft,ServerNotificationSchema:()=>Pr,ServerRequestSchema:()=>Nr,ServerResultSchema:()=>Fr,ServerTasksCapabilitySchema:()=>ct,SetLevelRequestParamsSchema:()=>Dn,SetLevelRequestSchema:()=>On,SingleSelectEnumSchemaSchema:()=>Jn,StringSchemaSchema:()=>Un,SubscribeRequestParamsSchema:()=>Bt,SubscribeRequestSchema:()=>Vt,SubscriptionFilterSchema:()=>Wt,SubscriptionsAcknowledgedNotificationParamsSchema:()=>qt,SubscriptionsAcknowledgedNotificationSchema:()=>Jt,SubscriptionsListenRequestParamsSchema:()=>Gt,SubscriptionsListenRequestSchema:()=>Kt,SubscriptionsListenResultMetaSchema:()=>Yt,SubscriptionsListenResultSchema:()=>Xt,TaskAugmentedRequestParamsSchema:()=>Ge,TaskCreationParamsSchema:()=>gr,TaskMetadataSchema:()=>He,TaskSchema:()=>vr,TaskStatusNotificationParamsSchema:()=>br,TaskStatusNotificationSchema:()=>xr,TaskStatusSchema:()=>_r,TextContentSchema:()=>an,TextResourceContentsSchema:()=>Tt,TitledMultiSelectEnumSchemaSchema:()=>Xn,TitledSingleSelectEnumSchemaSchema:()=>Kn,ToolAnnotationsSchema:()=>hn,ToolChoiceSchema:()=>Nn,ToolExecutionSchema:()=>gn,ToolListChangedNotificationSchema:()=>wn,ToolResultContentSchema:()=>Pn,ToolSchema:()=>_n,ToolUseContentSchema:()=>cn,UnsubscribeRequestParamsSchema:()=>Ht,UnsubscribeRequestSchema:()=>Ut,UntitledMultiSelectEnumSchemaSchema:()=>Yn,UntitledSingleSelectEnumSchemaSchema:()=>Gn}),Ia=e=>Je.safeParse(e).success,La=e=>Ye.safeParse(e).success,Ra=e=>Xe.safeParse(e).success,za=e=>Ze.safeParse(e).success,Ba=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`,Va=e=>dt.safeParse(e).success,Ha=e=>mt.safeParse(e).success,Ua=`Mcp-Param-`,Wa=`x-mcp-header`,Ga=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Ka=new Set([`string`,`integer`,`boolean`,`number`]);function qa(e){let t=[],n=new Map,r=(e,i,a)=>{if(typeof e!=`object`||!e)return;let o=e;if(Wa in o){if(!a||i.length===0)return`${Xa(i)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let e=o[Wa];if(typeof e!=`string`||e.length===0)return`${Xa(i)}: x-mcp-header MUST be a non-empty string`;if(!Ga.test(e))return`${Xa(i)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let r=typeof o.type==`string`?o.type:void 0;if(r===void 0||!Ka.has(r))return`${Xa(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${r??``}`;let s=e.toLowerCase(),c=n.get(s);if(c!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${c}')`;n.set(s,e),t.push({path:i,headerName:e,type:r})}let s=o.properties;if(typeof s==`object`&&s)for(let[e,t]of Object.entries(s)){let n=r(t,[...i,e],a);if(n!==void 0)return n}for(let e of Ja){let t=o[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Ya.has(e)?Object.values(t):[t];for(let t of n){let n=r(t,[...i,`<${e}>`],!1);if(n!==void 0)return n}}},i=r(e,[],!0);return i===void 0?{valid:!0,declarations:t}:{valid:!1,reason:i}}var Ja=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Ya=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]);function Xa(e){return e.length===0?``:e.join(`.`)}var Za=`=?base64?`,Qa=`?=`;function $a(e){if(typeof e==`string`)return e;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function eo(e){if(e.length===0||e.startsWith(Za)&&e.endsWith(Qa)||e!==e.trim())return!0;for(let t=0;t=32&&n<=126))return!0}return!1}function to(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCodePoint(e);return btoa(n)}function no(e){return eo(e)?`${Za}${to(e)}${Qa}`:e}function ro(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function io(e,t){let n={};for(let r of e){let e=ro(t,r.path);if(e==null)continue;let i=$a(e);i!==void 0&&(n[`${Ua}${r.headerName}`]=no(i))}return n}X.InvalidRequest,X.UnsupportedProtocolVersion,X.InvalidParams,X.MethodNotFound,X.InvalidParams,X.MissingRequiredClientCapability,X.ParseError,X.InvalidRequest,X.MethodNotFound,X.UnsupportedProtocolVersion,X.MissingRequiredClientCapability;var ao={"tools/call":`name`,"prompts/get":`name`,"resources/read":`uri`,"tasks/get":`taskId`,"tasks/update":`taskId`,"tasks/cancel":`taskId`};function oo(e,t){let n=Object.hasOwn(ao,e)?ao[e]:void 0;if(n===void 0)return;let r=so(t)?t[n]:void 0;return{field:n,value:typeof r==`string`?r:void 0}}function so(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function co(e,t){return ie(e,t)}function lo(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function uo(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}var fo=!1,po=`draft-2020-12`;function mo(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:po});else if(n.vendor===`zod`){if(!(`_zod`in e))throw Error(`Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().`);fo||(fo=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=oe(e,{target:po,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&ho(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}function ho(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||ho(e)))}return!1}function go(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function _o(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>go(e)).join(`, `)}:{success:!0,data:n.value}}function vo(e){let t=oe(e,{target:po,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}var yo=/\\\.\\d\{(\d+)\}/;function bo(e){let t=yo.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>fe({local:e,offset:t,precision:n}))))}function xo(e,t){let n;switch(e){case`email`:n=[T()];break;case`uri`:n=[ce()];break;case`date`:n=[pe()];break;case`date-time`:n=bo(t)}return new Set(n.map(e=>vo(e)).filter(e=>e!==void 0))}function So(e,t,n){return n!==`zod`||xo(e,t).has(t)}function Co(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wo(e){try{return mo(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Z(X.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}var To=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function Eo(e){return To.has(e)||e.startsWith(`x-`)}var Do=new Set([`$schema`,...Object.keys(er.shape.requestedSchema.shape)]),Oo={string:lo([Un,Gn,Kn,qn]),number:lo([Wn]),integer:lo([Wn]),boolean:lo([Hn]),array:lo([Yn,Xn])},ko=new Set(Un.shape.format.unwrap().options);function Ao(e,t,n,r){if(!Co(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(Oo,e.type)?Oo[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||Eo(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?ko.has(e.format)?(typeof s!=`string`||!So(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function jo(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&Co(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,Ao(n,`properties.${e}`,t,r)])):Do.has(i)?n[i]=a:Eo(i)||r.push(i);if(r.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function Mo(e,t){if(!Co(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!co($n,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function No(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>No(e,t[r],`${n}[${r}]`)):!Co(e)||!Co(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?No(r,t[e],i):Eo(e)?[]:[i]})}function Po(e){if(!uo(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=jo(wo(e.requestedSchema),t),r=co(er.shape.requestedSchema,n);if(!r.success)throw new Z(X.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${Mo(n,r.error.message)}`);let i=No(n,r.data);if(i.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function Fo(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw TypeError(`inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)`);return{resultType:`input_required`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(Fo,{elicit(e){try{return{method:`elicitation/create`,params:Po(e)}}catch(e){throw e instanceof Z?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});var Io=!0,Lo=10,Ro=250;function zo(e){return{autoFulfill:e?.autoFulfill??Io,maxRounds:e?.maxRounds??Lo}}function Bo(e,t,n){let r=t!==void 0&&Object.keys(t).length>0;return!r&&n===void 0?e:{...e,...r&&{inputResponses:t},...n!==void 0&&{requestState:n}}}function Vo(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function Ho(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof Y?t.reason:new Y(J.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof Y?t.reason:new Y(J.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function Uo(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}async function Wo(e){let{config:t,method:n,originalParams:r,requestOptions:i,hooks:a,signal:o}=e,s=e.flowStartedAt??Date.now(),c=e.firstPayload,l=0;for(;;){if(l+=1,l>t.maxRounds)throw new Y(J.InputRequiredRoundsExceeded,Vo(n,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:c.inputRequests,...c.requestState!==void 0&&{requestState:c.requestState}}});i.onprogress?.({progress:l,message:`Fulfilling input required by '${n}' (round ${l})`});let e=Object.entries(c.inputRequests??{}),u;if(e.length>0){let t=Uo(o);try{let n=await Promise.all(e.map(async([e,n])=>{try{return[e,await a.dispatchInputRequest(e,n,t.signal)]}catch(e){throw t.abort(e),e}}));u=Object.fromEntries(n)}finally{t.dispose()}}else await Ho(Ro,o);let d={...i.timeout!==void 0&&{timeout:i.timeout}};if(i.maxTotalTimeout!==void 0){let e=Date.now()-s,t=i.maxTotalTimeout-e;if(t<=0)throw new Y(J.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:i.maxTotalTimeout,totalElapsed:e});d.maxTotalTimeout=t}let f=await a.retry(Bo(r,u,c.requestState),d);if(Ba(f)){c={inputRequests:f.inputRequests??{},...f.requestState!==void 0&&{requestState:f.requestState}};continue}return f}}var Go=`AnnotationsSchema.AudioContentSchema.BaseMetadataSchema.BlobResourceContentsSchema.BooleanSchemaSchema.CallToolRequestSchema.CallToolRequestParamsSchema.CallToolResultSchema.CancelledNotificationSchema.CancelledNotificationParamsSchema.CancelTaskRequestSchema.CancelTaskResultSchema.ClientCapabilitiesSchema.ClientNotificationSchema.ClientRequestSchema.ClientResultSchema.CompatibilityCallToolResultSchema.CompleteRequestSchema.CompleteRequestParamsSchema.CompleteResultSchema.ContentBlockSchema.CreateMessageRequestSchema.CreateMessageRequestParamsSchema.CreateMessageResultSchema.CreateMessageResultWithToolsSchema.CreateTaskResultSchema.CursorSchema.DiscoverRequestSchema.DiscoverResultSchema.ElicitationCompleteNotificationSchema.ElicitationCompleteNotificationParamsSchema.ElicitRequestSchema.ElicitRequestFormParamsSchema.ElicitRequestParamsSchema.ElicitRequestURLParamsSchema.ElicitResultSchema.EmbeddedResourceSchema.EmptyResultSchema.EnumSchemaSchema.GetPromptRequestSchema.GetPromptRequestParamsSchema.GetPromptResultSchema.GetTaskPayloadRequestSchema.GetTaskPayloadResultSchema.GetTaskRequestSchema.GetTaskResultSchema.IconSchema.IconsSchema.ImageContentSchema.ImplementationSchema.InitializedNotificationSchema.InitializeRequestSchema.InitializeRequestParamsSchema.InitializeResultSchema.JSONArraySchema.JSONObjectSchema.JSONRPCErrorResponseSchema.JSONRPCMessageSchema.JSONRPCNotificationSchema.JSONRPCRequestSchema.JSONRPCResponseSchema.JSONRPCResultResponseSchema.JSONValueSchema.LegacyTitledEnumSchemaSchema.ListPromptsRequestSchema.ListPromptsResultSchema.ListResourcesRequestSchema.ListResourcesResultSchema.ListResourceTemplatesRequestSchema.ListResourceTemplatesResultSchema.ListRootsRequestSchema.ListRootsResultSchema.ListTasksRequestSchema.ListTasksResultSchema.ListToolsRequestSchema.ListToolsResultSchema.LoggingLevelSchema.LoggingMessageNotificationSchema.LoggingMessageNotificationParamsSchema.ModelHintSchema.ModelPreferencesSchema.MultiSelectEnumSchemaSchema.NotificationSchema.NumberSchemaSchema.PaginatedRequestSchema.PaginatedRequestParamsSchema.PaginatedResultSchema.PingRequestSchema.PrimitiveSchemaDefinitionSchema.ProgressSchema.ProgressNotificationSchema.ProgressNotificationParamsSchema.ProgressTokenSchema.PromptSchema.PromptArgumentSchema.PromptListChangedNotificationSchema.PromptMessageSchema.PromptReferenceSchema.ReadResourceRequestSchema.ReadResourceRequestParamsSchema.ReadResourceResultSchema.RelatedTaskMetadataSchema.RequestSchema.RequestIdSchema.RequestMetaSchema.ResourceSchema.ResourceContentsSchema.ResourceLinkSchema.ResourceListChangedNotificationSchema.ResourceRequestParamsSchema.ResourceTemplateSchema.ResourceTemplateReferenceSchema.ResourceUpdatedNotificationSchema.ResourceUpdatedNotificationParamsSchema.ResultMetaObjectSchema.ResultSchema.RoleSchema.RootSchema.RootsListChangedNotificationSchema.SamplingContentSchema.SamplingMessageSchema.SamplingMessageContentBlockSchema.ServerCapabilitiesSchema.ServerNotificationSchema.ServerRequestSchema.ServerResultSchema.SetLevelRequestSchema.SetLevelRequestParamsSchema.SingleSelectEnumSchemaSchema.StringSchemaSchema.SubscribeRequestSchema.SubscribeRequestParamsSchema.SubscriptionFilterSchema.SubscriptionsAcknowledgedNotificationSchema.SubscriptionsAcknowledgedNotificationParamsSchema.SubscriptionsListenRequestSchema.SubscriptionsListenRequestParamsSchema.SubscriptionsListenResultSchema.SubscriptionsListenResultMetaSchema.TaskAugmentedRequestParamsSchema.TaskCreationParamsSchema.TaskMetadataSchema.TaskSchema.TaskStatusSchema.TaskStatusNotificationSchema.TaskStatusNotificationParamsSchema.TextContentSchema.TextResourceContentsSchema.TitledMultiSelectEnumSchemaSchema.TitledSingleSelectEnumSchemaSchema.ToolSchema.ToolAnnotationsSchema.ToolChoiceSchema.ToolExecutionSchema.ToolListChangedNotificationSchema.ToolResultContentSchema.ToolUseContentSchema.UnsubscribeRequestSchema.UnsubscribeRequestParamsSchema.UntitledMultiSelectEnumSchemaSchema.UntitledSingleSelectEnumSchemaSchema`.split(`.`),Ko={IdJagTokenExchangeResponseSchema:Vr,OAuthClientInformationFullSchema:Kr,OAuthClientInformationSchema:Gr,OAuthClientMetadataSchema:Wr,OAuthClientRegistrationErrorSchema:qr,OAuthErrorResponseSchema:Hr,OAuthMetadataSchema:Lr,OAuthProtectedResourceMetadataSchema:Ir,OAuthTokenRevocationRequestSchema:Jr,OAuthTokensSchema:Br,OpenIdProviderDiscoveryMetadataSchema:zr,OpenIdProviderMetadataSchema:Rr},qo={},Jo={};function Yo(e,t){let n=e.slice(0,-6);qo[n]=t,Jo[n]=e=>t.safeParse(e).success}for(let e of Go)Yo(e,Fa[e]);for(let[e,t]of Object.entries(Ko))Yo(e,t);Object.freeze(qo);var Xo=Object.freeze(Jo);function Zo(e){switch(e){case`initialize`:case`notifications/initialized`:return ka(void 0);case`server/discover`:return ka(Oa);default:return}}var Qo=[Me,Ne,Fe,Le],$o=[`inputResponses`,`requestState`];function es(e,t){let n=e.params;if(!as(n))return{message:e,lifted:{}};let r=n._meta,i=as(r)?Qo.filter(e=>e in r):[],a=t===`request`?$o.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&as(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function ts(e,t){let n=e.validateResult(t,void 0);if(n.ok||n.reason!==`not-in-era`)return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function ns(e){return()=>e}var rs=ns(void 0),is=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Ae,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new Y(J.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Y(J.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Ra(e)||za(e)?this._onresponse(e):Ia(e)?this._onrequest(e,t):La(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new Y(J.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=es(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=Aa(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(Ma(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=es(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=Aa(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(X.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(ja(n.method)&&!i.hasRequestMethod(n.method)&&!(Na(n.method)&&this._customSchemaRequestMethods.has(n.method))){o(X.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(X.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(X.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:cs(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?rs:ns(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),uo(t))return u(e,t,n);let i=ts(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(X.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:X.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Ra(e)?n(e):n(Z.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(uo(t))return Na(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=ts(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return ka(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=Zo(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(ja(t)&&!e.hasRequestMethod(t))throw new Y(J.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof Y?e:new Y(J.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof Y?e:new Y(J.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(ms(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;_o(n,o).then(e=>{e.success?d(e.data):f(new Y(J.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new Y(J.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new Y(J.NotConnected,`Not connected`);if(Ma(t.method)&&!e.hasNotificationMethod(t.method))throw new Y(J.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!ja(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new Z(X.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await _o(t.params,{...r.params});if(!a.success)throw new Z(X.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!Ma(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new Z(X.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))});return}if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await _o(t.params,{...r.params});if(!i.success)throw new Z(X.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function as(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function os(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=as(a)&&as(i)?{...a,...i}:i}return n}function ss(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cs(e){let t={},n=[];if(!ss(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!ss(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function ls(e){throw new Y(J.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}function us(e,t,n,r,i){return{sessionId:i,mcpReq:{id:e,method:t,_meta:n?._meta,requestState:ns(void 0),signal:r,send:(()=>ls(`send`)),notify:()=>ls(`notify`)}}}async function ds(e,t,n,r,i){if(!ss(r)||typeof r.method!=`string`)throw new Y(J.InvalidResult,`Invalid input request '${n}': each inputRequests entry must be an embedded request object with a method`,{key:n});let a=r.method;if(!t.hasInputRequestMethod(a))throw new Y(J.InvalidResult,`Invalid input request '${n}': '${a}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:n,method:a});let o=e.getRequestHandler(a);if(o===void 0)throw new Y(J.CapabilityNotSupported,`Cannot fulfil input request '${n}': no handler is registered for '${a}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:n,method:a});let s=ss(r.params)?r.params:void 0;return await o({jsonrpc:`2.0`,id:n,method:a,...s!==void 0&&{params:s}},e.buildContext(us(n,a,s,i,e.sessionId)))}function fs(e,t){return{...e?.signal!==void 0&&{signal:e.signal},...e?.onprogress!==void 0&&{onprogress:e.onprogress},...e?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:e.resetTimeoutOnProgress},...e?.headers!==void 0&&{headers:e.headers},...t.timeout!==void 0&&{timeout:t.timeout},...t.maxTotalTimeout!==void 0&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0}}function ps(e,t,n,r){let{codec:i,request:a,options:o,flowStartedAt:s}=r,c={inputRequests:n.inputRequests,...n.requestState!==void 0&&{requestState:n.requestState}},l={dispatchInputRequest:(t,n,r)=>ds(e,i,t,n,r),retry:(e,t)=>r.retry(e,fs(o,t))};return Wo({config:t,method:a.method,originalParams:a.params,firstPayload:c,flowStartedAt:s,signal:o?.signal,requestOptions:{...o?.timeout!==void 0&&{timeout:o.timeout},...o?.maxTotalTimeout!==void 0&&{maxTotalTimeout:o.maxTotalTimeout},...o?.onprogress!==void 0&&{onprogress:o.onprogress}},hooks:l})}function ms(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var hs=Se(I((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))(),1);function gs(e){if(e)try{return hs.parse(e).type}catch{let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return t===``||e.slice(t.length).includes(`,`)?void 0:t}}function _s(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function vs(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{..._s(t.headers),..._s(r.headers)}:t.headers}):e}var ys=new Set([301,302,303,307,308]),bs=5;function xs(e,t){return e.protocol===t.protocol&&e.host===t.host||e.protocol===`http:`&&t.protocol===`https:`&&e.hostname===t.hostname&&!e.port&&!t.port}function Ss(e,t){let n=ys.has(t.status)?t.headers?.get(`location`):void 0;if(n)try{return new URL(n,e)}catch{return}}var Cs=new WeakSet;function ws(e){let t=(t,n)=>e(t,n);return Cs.add(t),t}function Ts(e){return Cs.has(e)?e:async(t,n)=>{if(n?.redirect===`error`||n?.redirect===`manual`)return e(t,n);let r=(n?.method??`GET`).toUpperCase(),i=t;for(let t=0;;t++){let a=await e(i,{...n,redirect:`manual`}),o=Ss(i,a);if(!o||t===bs)return a;let s=new URL(i),c=r===`GET`||a.status===307||a.status===308,l=!(o.username||o.password)||o.username===s.username&&o.password===s.password;if(!c||!l||!xs(s,o))return a;await a.text?.().catch(()=>{}),i=o}}}function Es(e,t){if(t.type===`opaqueredirect`)return`Redirect not followed: this runtime does not expose where it points`;let n=Ss(t.url||e,t);if(n)return n.username=n.password=n.search=n.hash=``,n.protocol===`http:`&&new URL(t.url||e).protocol===`https:`?(n.protocol=`https:`,`Redirect from https to plain http not followed; try ${n.href} as the endpoint`):`Redirect to ${n.href} not followed; use that URL as the endpoint if it is the intended server`}function Ds(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r1?t[a.href]=e:(a.hash=``,r===``?n=a:Ps(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(Ms[i])continue;let a=`${r}/${Os(i)}`,o=e[i];if(Array.isArray(o)){if(As[i]){let e=o.length;for(let r=0;r%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Vs=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Hs=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Us=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Ws=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Gs=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Ks=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},qs=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Js=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Ys=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Xs(e){return e.test.bind(e)}var Zs={date:$s,time:ec.bind(void 0,!1),"date-time":nc,duration:Ys,uri:ac,"uri-reference":Xs(zs),"uri-template":Xs(Bs),url:Xs(Vs),email:Ks,hostname:Xs(Rs),ipv4:Xs(qs),ipv6:Xs(Js),regex:sc,uuid:Xs(Hs),"json-pointer":Xs(Us),"json-pointer-uri-fragment":Xs(Ws),"relative-json-pointer":Xs(Gs)};function Qs(e){return e%4==0&&(e%100!=0||e%400==0)}function $s(e){let t=e.match(Fs);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&Qs(n)?29:Is[r])}function ec(e,t){let n=t.match(Ls);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var tc=/t|\s/i;function nc(e){let t=e.split(tc);return t.length==2&&$s(t[0])&&ec(!0,t[1])}var rc=/\/|:/,ic=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function ac(e){return rc.test(e)&&ic.test(e)}var oc=/[^\\]\\Z/;function sc(e){if(oc.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function cc(e){let t=0,n=e.length,r=0,i;for(;r=55296&&i<=56319&&r{if(typeof e!=`string`||/[\s;'\"]/.test(e))return!1;let t=e.match(/^([a-z]+):\/\/([^/]+)$/i);return!!(t&&n.has(t[1].toLowerCase()))})}function he(e){let t=M(M(M(e)?.ui)?.csp),n=N(t?.connectDomains,[`http`,`https`,`ws`,`wss`]),r=N(t?.resourceDomains,[`http`,`https`]),i=N(t?.frameDomains,[`http`,`https`]),a=N(t?.baseUriDomains,[`http`,`https`]),o=r.length?` ${r.join(` `)}`:``,s=[`default-src 'none'`,`worker-src blob:`,`script-src 'self' 'unsafe-inline'${o}`,`style-src 'self' 'unsafe-inline'${o}`,`img-src 'self' data:${o}`,`media-src 'self' data:${o}`,`font-src 'self' data:${o}`,`connect-src ${n.length?n.join(` `):`'none'`}`];return i.length&&s.push(`frame-src ${i.join(` `)}`),a.length&&s.push(`base-uri ${a.join(` `)}`),`${s.join(`; `)};`}var P=Object.create,F=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,_e=Object.getOwnPropertyNames,ve=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty,I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),be=(e,t)=>{let n={};for(var r in e)F(n,r,{get:e[r],enumerable:!0});return t&&F(n,Symbol.toStringTag,{value:`Module`}),n},xe=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_e(t),a=0,o=i.length,s;at[e]).bind(null,s),enumerable:!(r=ge(t,s))||r.enumerable});return e},Se=(e,t,n)=>(n=e==null?{}:P(ve(e)),xe(t||!e||!e.__esModule?F(n,`default`,{value:e,enumerable:!0}):n,e)),Ce=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),we=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),Te=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),Ee=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`]);function De(e){return typeof e==`string`&&we.has(e.replace(/#$/,``))}function Oe(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(Ce.has(n))return`2020-12`;if(we.has(n))return`2019-09`;if(Te.has(n)||Ee.has(n))return`draft-7`;throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var ke=`2025-11-25`,Ae=[ke,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],je=`io.modelcontextprotocol/related-task`,Me=`io.modelcontextprotocol/protocolVersion`,Ne=`io.modelcontextprotocol/clientInfo`,Pe=`io.modelcontextprotocol/serverInfo`,Fe=`io.modelcontextprotocol/clientCapabilities`,Ie=`io.modelcontextprotocol/subscriptionId`,Le=`io.modelcontextprotocol/logLevel`,Re=w(()=>u([S(),A(),j(),f(),O(S(),Re),C(Re)])),L=O(S(),Re),ze=C(Re),Be=u([S(),A().int()]),Ve=S(),He=g({ttl:A().optional()}),Ue=g({taskId:S()}),We=p({progressToken:Be.optional(),[je]:Ue.optional()}),R=g({_meta:We.optional()}),Ge=R.extend({task:He.optional()}),z=g({method:S(),params:R.loose().optional()}),B=g({_meta:We.optional()}),V=g({method:S(),params:B.loose().optional()}),Ke=p({get[Pe](){return at.optional().catch(void 0)}}),H=p({_meta:Ke.optional()}),qe=u([S(),A().int()]),Je=g({jsonrpc:E(`2.0`),id:qe,...z.shape}).strict(),Ye=g({jsonrpc:E(`2.0`),...V.shape}).strict(),Xe=g({jsonrpc:E(`2.0`),id:qe,result:H}).strict(),Ze=g({jsonrpc:E(`2.0`),id:qe.optional(),error:g({code:A().int(),message:S(),data:k().optional()})}).strict(),U=u([Je,Ye,Xe,Ze]),Qe=u([Xe,Ze]),$e=H.strict(),et=B.extend({requestId:qe.optional(),reason:S().optional()}),tt=V.extend({method:E(`notifications/cancelled`),params:et}),nt=g({src:S(),mimeType:S().optional(),sizes:C(S()).optional(),theme:x([`light`,`dark`]).optional()}),rt=g({icons:C(nt).optional()}),it=g({name:S(),title:S().optional()}),at=it.extend({...it.shape,...rt.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),ot=m(g({applyDefaults:j().optional()}),L),W=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,m(g({form:ot.optional(),url:L.optional()}),L.optional())),st=p({list:L.optional(),cancel:L.optional(),requests:p({sampling:p({createMessage:L.optional()}).optional(),elicitation:p({create:L.optional()}).optional()}).optional()}),ct=p({list:L.optional(),cancel:L.optional(),requests:p({tools:p({call:L.optional()}).optional()}).optional()}),lt=g({experimental:O(S(),L).optional(),sampling:g({context:L.optional(),tools:L.optional()}).optional(),elicitation:W.optional(),roots:g({listChanged:j().optional()}).optional(),tasks:st.optional(),extensions:O(S(),L).optional()}),ut=R.extend({protocolVersion:S(),capabilities:lt,clientInfo:at}),dt=z.extend({method:E(`initialize`),params:ut}),ft=g({experimental:O(S(),L).optional(),logging:L.optional(),completions:L.optional(),prompts:g({listChanged:j().optional()}).optional(),resources:g({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:g({listChanged:j().optional()}).optional(),tasks:ct.optional(),extensions:O(S(),L).optional()}),pt=H.extend({protocolVersion:S(),capabilities:ft,serverInfo:at,instructions:S().optional()}),mt=V.extend({method:E(`notifications/initialized`),params:B.optional()}),ht=z.extend({method:E(`server/discover`),params:R.optional()}),gt=H.extend({supportedVersions:C(S()),capabilities:ft,instructions:S().optional()}),_t=z.extend({method:E(`ping`),params:R.optional()}),vt=g({progress:A(),total:D(A()),message:D(S())}),yt=g({...B.shape,...vt.shape,progressToken:Be}),bt=V.extend({method:E(`notifications/progress`),params:yt}),xt=R.extend({cursor:Ve.optional()}),St=z.extend({params:xt.optional()}),Ct=H.extend({nextCursor:Ve.optional()}),wt=g({uri:S(),mimeType:D(S()),_meta:O(S(),k()).optional()}),Tt=wt.extend({text:S()}),Et=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Dt=wt.extend({blob:Et}),Ot=x([`user`,`assistant`]),kt=g({audience:C(Ot).optional(),priority:A().min(0).max(1).optional(),lastModified:fe({offset:!0}).optional()}),At=g({...it.shape,...rt.shape,uri:S(),description:D(S()),mimeType:D(S()),size:D(A()),annotations:kt.optional(),_meta:D(p({}))}),jt=g({...it.shape,...rt.shape,uriTemplate:S(),description:D(S()),mimeType:D(S()),annotations:kt.optional(),_meta:D(p({}))}),Mt=St.extend({method:E(`resources/list`)}),Nt=Ct.extend({resources:C(At)}),Pt=St.extend({method:E(`resources/templates/list`)}),Ft=Ct.extend({resourceTemplates:C(jt)}),G=R.extend({uri:S()}),It=G,Lt=z.extend({method:E(`resources/read`),params:It}),Rt=H.extend({contents:C(u([Tt,Dt]))}),zt=V.extend({method:E(`notifications/resources/list_changed`),params:B.optional()}),Bt=G,Vt=z.extend({method:E(`resources/subscribe`),params:Bt}),Ht=G,Ut=z.extend({method:E(`resources/unsubscribe`),params:Ht}),Wt=g({toolsListChanged:j().optional(),promptsListChanged:j().optional(),resourcesListChanged:j().optional(),resourceSubscriptions:C(S()).optional()}),Gt=R.extend({notifications:Wt}),Kt=z.extend({method:E(`subscriptions/listen`),params:Gt}),qt=B.extend({notifications:Wt}),Jt=V.extend({method:E(`notifications/subscriptions/acknowledged`),params:qt}),Yt=Ke.extend({[Ie]:qe}),Xt=H.extend({_meta:Yt}),Zt=B.extend({uri:S()}),Qt=V.extend({method:E(`notifications/resources/updated`),params:Zt}),$t=g({name:S(),description:D(S()),required:D(j())}),en=g({...it.shape,...rt.shape,description:D(S()),arguments:D(C($t)),_meta:D(p({}))}),K=St.extend({method:E(`prompts/list`)}),tn=Ct.extend({prompts:C(en)}),nn=R.extend({name:S(),arguments:O(S(),S()).optional()}),rn=z.extend({method:E(`prompts/get`),params:nn}),an=g({type:E(`text`),text:S(),annotations:kt.optional(),_meta:O(S(),k()).optional()}),on=g({type:E(`image`),data:Et,mimeType:S(),annotations:kt.optional(),_meta:O(S(),k()).optional()}),sn=g({type:E(`audio`),data:Et,mimeType:S(),annotations:kt.optional(),_meta:O(S(),k()).optional()}),cn=g({type:E(`tool_use`),name:S(),id:S(),input:O(S(),k()),_meta:O(S(),k()).optional()}),ln=g({type:E(`resource`),resource:u([Tt,Dt]),annotations:kt.optional(),_meta:O(S(),k()).optional()}),un=At.extend({type:E(`resource_link`)}),dn=u([an,on,sn,un,ln]),fn=g({role:Ot,content:dn}),pn=H.extend({description:S().optional(),messages:C(fn)}),mn=V.extend({method:E(`notifications/prompts/list_changed`),params:B.optional()}),hn=g({title:S().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),gn=g({taskSupport:x([`required`,`optional`,`forbidden`]).optional()}),_n=g({...it.shape,...rt.shape,description:S().optional(),inputSchema:g({type:E(`object`),properties:O(S(),Re).optional(),required:C(S()).optional()}).catchall(k()),outputSchema:p({$schema:S().optional()}).optional(),annotations:hn.optional(),execution:gn.optional(),_meta:O(S(),k()).optional()}),vn=St.extend({method:E(`tools/list`)}),yn=Ct.extend({tools:C(_n)}),bn=H.extend({content:C(dn).default([]),structuredContent:k().optional(),isError:j().optional()}),xn=bn.or(H.extend({toolResult:k()})),Sn=Ge.extend({name:S(),arguments:O(S(),k()).optional()}),Cn=z.extend({method:E(`tools/call`),params:Sn}),wn=V.extend({method:E(`notifications/tools/list_changed`),params:B.optional()}),Tn=g({autoRefresh:j().default(!0),debounceMs:A().int().nonnegative().default(300)}),En=x([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Dn=R.extend({level:En}),On=z.extend({method:E(`logging/setLevel`),params:Dn}),kn=B.extend({level:En,logger:S().optional(),data:k()}),An=V.extend({method:E(`notifications/message`),params:kn}),jn=g({name:S().optional()}),Mn=g({hints:C(jn).optional(),costPriority:A().min(0).max(1).optional(),speedPriority:A().min(0).max(1).optional(),intelligencePriority:A().min(0).max(1).optional()}),Nn=g({mode:x([`auto`,`required`,`none`]).optional()}),Pn=g({type:E(`tool_result`),toolUseId:S().describe(`The unique identifier for the corresponding tool call.`),content:C(dn),structuredContent:k().optional(),isError:j().optional(),_meta:O(S(),k()).optional()}),Fn=d(`type`,[an,on,sn]),In=d(`type`,[an,on,sn,cn,Pn]),Ln=g({role:Ot,content:u([In,C(In)]),_meta:O(S(),k()).optional()}),Rn=Ge.extend({messages:C(Ln),modelPreferences:Mn.optional(),systemPrompt:S().optional(),includeContext:x([`none`,`thisServer`,`allServers`]).optional(),temperature:A().optional(),maxTokens:A().int(),stopSequences:C(S()).optional(),metadata:L.optional(),tools:C(_n).optional(),toolChoice:Nn.optional()}),zn=z.extend({method:E(`sampling/createMessage`),params:Rn}),Bn=H.extend({model:S(),stopReason:D(x([`endTurn`,`stopSequence`,`maxTokens`]).or(S())),role:Ot,content:Fn}),Vn=H.extend({model:S(),stopReason:D(x([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(S())),role:Ot,content:u([In,C(In)])}),Hn=g({type:E(`boolean`),title:S().optional(),description:S().optional(),default:j().optional()}),Un=g({type:E(`string`),title:S().optional(),description:S().optional(),minLength:A().optional(),maxLength:A().optional(),format:x([`email`,`uri`,`date`,`date-time`]).optional(),default:S().optional()}),Wn=g({type:x([`number`,`integer`]),title:S().optional(),description:S().optional(),minimum:A().optional(),maximum:A().optional(),default:A().optional()}),Gn=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),default:S().optional()}),Kn=g({type:E(`string`),title:S().optional(),description:S().optional(),oneOf:C(g({const:S(),title:S()})),default:S().optional()}),qn=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),enumNames:C(S()).optional(),default:S().optional()}),Jn=u([Gn,Kn]),Yn=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({type:E(`string`),enum:C(S())}),default:C(S()).optional()}),Xn=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({anyOf:C(g({const:S(),title:S()}))}),default:C(S()).optional()}),Zn=u([Yn,Xn]),Qn=u([qn,Jn,Zn]),$n=u([Qn,Hn,Un,Wn]),er=Ge.extend({mode:E(`form`).optional(),message:S(),requestedSchema:g({type:E(`object`),properties:O(S(),$n),required:C(S()).optional()}).catchall(k())}),tr=Ge.extend({mode:E(`url`),message:S(),elicitationId:S(),url:S().url()}),nr=u([er,tr]),rr=z.extend({method:E(`elicitation/create`),params:nr}),ir=B.extend({elicitationId:S()}),ar=V.extend({method:E(`notifications/elicitation/complete`),params:ir}),or=H.extend({action:x([`accept`,`decline`,`cancel`]),content:ee(e=>e===null?void 0:e,O(S(),u([S(),A(),j(),C(S())])).optional())}),sr=g({type:E(`ref/resource`),uri:S()}),cr=g({type:E(`ref/prompt`),name:S()}),lr=R.extend({ref:u([cr,sr]),argument:g({name:S(),value:S()}),context:g({arguments:O(S(),S()).optional()}).optional()}),ur=z.extend({method:E(`completion/complete`),params:lr}),dr=H.extend({completion:p({values:C(S()).max(100),total:D(A().int()),hasMore:D(j())})}),fr=g({uri:S().startsWith(`file://`),name:S().optional(),_meta:O(S(),k()).optional()}),pr=z.extend({method:E(`roots/list`),params:R.optional()}),mr=H.extend({roots:C(fr)}),hr=V.extend({method:E(`notifications/roots/list_changed`),params:B.optional()}),gr=p({ttl:A().optional(),pollInterval:A().optional()}),_r=x([`working`,`input_required`,`completed`,`failed`,`cancelled`]),vr=g({taskId:S(),status:_r,ttl:u([A(),f()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:D(A()),statusMessage:D(S())}),yr=H.extend({task:vr}),br=B.merge(vr),xr=V.extend({method:E(`notifications/tasks/status`),params:br}),Sr=z.extend({method:E(`tasks/get`),params:R.extend({taskId:S()})}),Cr=H.merge(vr),wr=z.extend({method:E(`tasks/result`),params:R.extend({taskId:S()})}),Tr=H.loose(),Er=St.extend({method:E(`tasks/list`)}),Dr=Ct.extend({tasks:C(vr)}),Or=z.extend({method:E(`tasks/cancel`),params:R.extend({taskId:S()})}),kr=H.merge(vr),Ar=u([_t,dt,ht,ur,On,rn,K,Mt,Pt,Lt,Vt,Ut,Kt,Cn,vn]),jr=u([tt,bt,mt,hr]),Mr=u([$e,Bn,Vn,or,mr]),Nr=u([_t,zn,rr,pr]),Pr=u([tt,bt,An,Qt,zt,wn,mn,Jt,ar]),Fr=u([$e,pt,gt,dr,pn,tn,Nt,Ft,Rt,bn,yn,Xt]),q=ce().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ue.custom,message:`URL must be parseable`,fatal:!0}),se}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Ir=p({resource:S().url(),authorization_servers:C(q).optional(),jwks_uri:S().url().optional(),scopes_supported:C(S()).optional(),bearer_methods_supported:C(S()).optional(),resource_signing_alg_values_supported:C(S()).optional(),resource_name:S().optional(),resource_documentation:S().optional(),resource_policy_uri:S().url().optional(),resource_tos_uri:S().url().optional(),tls_client_certificate_bound_access_tokens:j().optional(),authorization_details_types_supported:C(S()).optional(),dpop_signing_alg_values_supported:C(S()).optional(),dpop_bound_access_tokens_required:j().optional()}),Lr=p({issuer:S(),authorization_endpoint:q,token_endpoint:q,registration_endpoint:q.optional(),scopes_supported:C(S()).optional(),response_types_supported:C(S()),response_modes_supported:C(S()).optional(),grant_types_supported:C(S()).optional(),token_endpoint_auth_methods_supported:C(S()).optional(),token_endpoint_auth_signing_alg_values_supported:C(S()).optional(),service_documentation:q.optional(),revocation_endpoint:q.optional(),revocation_endpoint_auth_methods_supported:C(S()).optional(),revocation_endpoint_auth_signing_alg_values_supported:C(S()).optional(),introspection_endpoint:S().optional(),introspection_endpoint_auth_methods_supported:C(S()).optional(),introspection_endpoint_auth_signing_alg_values_supported:C(S()).optional(),code_challenge_methods_supported:C(S()).optional(),client_id_metadata_document_supported:j().optional(),authorization_response_iss_parameter_supported:j().optional().catch(void 0),dpop_signing_alg_values_supported:C(S()).optional()}),Rr=p({issuer:S(),authorization_endpoint:q,token_endpoint:q,userinfo_endpoint:q.optional(),jwks_uri:q,registration_endpoint:q.optional(),scopes_supported:C(S()).optional(),response_types_supported:C(S()),response_modes_supported:C(S()).optional(),grant_types_supported:C(S()).optional(),acr_values_supported:C(S()).optional(),subject_types_supported:C(S()),id_token_signing_alg_values_supported:C(S()),id_token_encryption_alg_values_supported:C(S()).optional(),id_token_encryption_enc_values_supported:C(S()).optional(),userinfo_signing_alg_values_supported:C(S()).optional(),userinfo_encryption_alg_values_supported:C(S()).optional(),userinfo_encryption_enc_values_supported:C(S()).optional(),request_object_signing_alg_values_supported:C(S()).optional(),request_object_encryption_alg_values_supported:C(S()).optional(),request_object_encryption_enc_values_supported:C(S()).optional(),token_endpoint_auth_methods_supported:C(S()).optional(),token_endpoint_auth_signing_alg_values_supported:C(S()).optional(),display_values_supported:C(S()).optional(),claim_types_supported:C(S()).optional(),claims_supported:C(S()).optional(),service_documentation:S().optional(),claims_locales_supported:C(S()).optional(),ui_locales_supported:C(S()).optional(),claims_parameter_supported:j().optional(),request_parameter_supported:j().optional(),request_uri_parameter_supported:j().optional(),require_request_uri_registration:j().optional(),op_policy_uri:q.optional(),op_tos_uri:q.optional(),client_id_metadata_document_supported:j().optional(),authorization_response_iss_parameter_supported:j().optional().catch(void 0)}),zr=g({...Rr.shape,...Lr.pick({code_challenge_methods_supported:!0}).shape}),Br=g({access_token:S(),id_token:S().optional(),token_type:S(),expires_in:me().optional(),scope:S().optional(),refresh_token:S().optional(),issuer:S().optional().catch(void 0)}).strip(),Vr=g({issued_token_type:E(`urn:ietf:params:oauth:token-type:id-jag`),access_token:S(),token_type:S().optional(),expires_in:A().optional(),scope:S().optional()}).strip(),Hr=g({error:S(),error_description:S().optional(),error_uri:S().optional()}),Ur=q.optional().or(E(``).transform(()=>void 0)),Wr=g({redirect_uris:C(q),token_endpoint_auth_method:S().optional(),grant_types:C(S()).optional(),response_types:C(S()).optional(),application_type:S().optional(),client_name:S().optional(),client_uri:q.optional(),logo_uri:Ur,scope:S().optional(),contacts:C(S()).optional(),tos_uri:Ur,policy_uri:S().optional(),jwks_uri:q.optional(),jwks:v().optional(),software_id:S().optional(),software_version:S().optional(),software_statement:S().optional()}).strip(),Gr=g({client_id:S(),client_secret:S().optional(),client_id_issued_at:A().optional(),client_secret_expires_at:A().optional(),issuer:S().optional().catch(void 0)}).strip(),Kr=Wr.merge(Gr),qr=g({error:S(),error_description:S().optional()}).strip(),Jr=g({token:S(),token_type_hint:S().optional()}).strip(),Yr=Symbol.for(`mcp.sdk.errorBrands`);function Xr(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Yr,{value:n,enumerable:!1,configurable:!0})}function Zr(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Yr)){let n=t[Yr];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var Qr=function(e){return e.InvalidRequest=`invalid_request`,e.InvalidClient=`invalid_client`,e.InvalidGrant=`invalid_grant`,e.UnauthorizedClient=`unauthorized_client`,e.UnsupportedGrantType=`unsupported_grant_type`,e.InvalidScope=`invalid_scope`,e.AccessDenied=`access_denied`,e.ServerError=`server_error`,e.TemporarilyUnavailable=`temporarily_unavailable`,e.UnsupportedResponseType=`unsupported_response_type`,e.UnsupportedTokenType=`unsupported_token_type`,e.InvalidToken=`invalid_token`,e.MethodNotAllowed=`method_not_allowed`,e.TooManyRequests=`too_many_requests`,e.InvalidClientMetadata=`invalid_client_metadata`,e.InvalidRedirectUri=`invalid_redirect_uri`,e.InsufficientScope=`insufficient_scope`,e.InvalidTarget=`invalid_target`,e.InvalidDpopProof=`invalid_dpop_proof`,e.UseDpopNonce=`use_dpop_nonce`,e}({}),$r=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return Zr(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Zr(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Xr(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},J=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),Y=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return Zr(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Zr(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,Xr(this,new.target)}},ei=class extends Y{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}};function ti(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function ni(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e};return delete t.issuer,t}function ri({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length=ii}function si(e){return e.filter(e=>!oi(e))}function ci(e){return e.filter(e=>oi(e))}function li(e){let t=e.structuredContent;return t===void 0||typeof t==`object`&&t&&!Array.isArray(t)||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}var ui=[`task`,`inputRequests`,`requestState`];function di(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||ui.some(t=>t in e)?e:{...e,content:[]}}function fi(){let e=w(()=>u([S(),A(),j(),f(),O(S(),e),C(e)])),t=O(S(),e),n=u([S(),A().int()]),r=S(),i=g({ttl:A().optional()}),a=g({taskId:S()}),o=p({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=g({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=g({method:S(),params:s.loose().optional()}),h=g({_meta:o.optional()}),_=g({method:S(),params:h.loose().optional()}),v=p({_meta:o.optional()}),y=u([S(),A().int()]),b=v.strict(),T=h.extend({requestId:y.optional(),reason:S().optional()}),te=_.extend({method:E(`notifications/cancelled`),params:T}),ne=g({src:S(),mimeType:S().optional(),sizes:C(S()).optional(),theme:x([`light`,`dark`]).optional()}),re=g({icons:C(ne).optional()}),ie=g({name:S(),title:S().optional()}),ae=ie.extend({...ie.shape,...re.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),oe=m(g({applyDefaults:j().optional()}),t),se=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,m(g({form:oe.optional(),url:t.optional()}),t.optional())),ce=p({list:t.optional(),cancel:t.optional(),requests:p({sampling:p({createMessage:t.optional()}).optional(),elicitation:p({create:t.optional()}).optional()}).optional()}),le=p({list:t.optional(),cancel:t.optional(),requests:p({tools:p({call:t.optional()}).optional()}).optional()}),ue=g({experimental:O(S(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:se.optional(),roots:g({listChanged:j().optional()}).optional(),tasks:ce.optional(),extensions:O(S(),t).optional()}),de=s.extend({protocolVersion:S(),capabilities:ue,clientInfo:ae}),pe=l.extend({method:E(`initialize`),params:de}),me=g({experimental:O(S(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:j().optional()}).optional(),resources:g({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:g({listChanged:j().optional()}).optional(),tasks:le.optional(),extensions:O(S(),t).optional()}),M=v.extend({protocolVersion:S(),capabilities:me,serverInfo:ae,instructions:S().optional()}),N=_.extend({method:E(`notifications/initialized`),params:h.optional()}),he=l.extend({method:E(`ping`),params:s.optional()}),P=g({progress:A(),total:D(A()),message:D(S())}),F=g({...h.shape,...P.shape,progressToken:n}),ge=_.extend({method:E(`notifications/progress`),params:F}),_e=s.extend({cursor:r.optional()}),ve=l.extend({params:_e.optional()}),ye=v.extend({nextCursor:r.optional()}),I=g({uri:S(),mimeType:D(S()),_meta:O(S(),k()).optional()}),be=I.extend({text:S()}),xe=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Se=I.extend({blob:xe}),Ce=x([`user`,`assistant`]),we=g({audience:C(Ce).optional(),priority:A().min(0).max(1).optional(),lastModified:fe({offset:!0}).optional()}),Te=g({...ie.shape,...re.shape,uri:S(),description:D(S()),mimeType:D(S()),size:D(A()),annotations:we.optional(),_meta:D(p({}))}),Ee=g({...ie.shape,...re.shape,uriTemplate:S(),description:D(S()),mimeType:D(S()),annotations:we.optional(),_meta:D(p({}))}),De=ve.extend({method:E(`resources/list`)}),Oe=ye.extend({resources:C(Te)}),ke=ve.extend({method:E(`resources/templates/list`)}),Ae=ye.extend({resourceTemplates:C(Ee)}),je=s.extend({uri:S()}),Me=je,Ne=l.extend({method:E(`resources/read`),params:Me}),Pe=v.extend({contents:C(u([be,Se]))}),Fe=_.extend({method:E(`notifications/resources/list_changed`),params:h.optional()}),Ie=je,Le=l.extend({method:E(`resources/subscribe`),params:Ie}),Re=je,L=l.extend({method:E(`resources/unsubscribe`),params:Re}),ze=h.extend({uri:S()}),Be=_.extend({method:E(`notifications/resources/updated`),params:ze}),Ve=g({name:S(),description:D(S()),required:D(j())}),He=g({...ie.shape,...re.shape,description:D(S()),arguments:D(C(Ve)),_meta:D(p({}))}),Ue=ve.extend({method:E(`prompts/list`)}),We=ye.extend({prompts:C(He)}),R=s.extend({name:S(),arguments:O(S(),S()).optional()}),Ge=l.extend({method:E(`prompts/get`),params:R}),z=g({type:E(`text`),text:S(),annotations:we.optional(),_meta:O(S(),k()).optional()}),B=g({type:E(`image`),data:xe,mimeType:S(),annotations:we.optional(),_meta:O(S(),k()).optional()}),V=g({type:E(`audio`),data:xe,mimeType:S(),annotations:we.optional(),_meta:O(S(),k()).optional()}),Ke=g({type:E(`tool_use`),name:S(),id:S(),input:O(S(),k()),_meta:O(S(),k()).optional()}),H=g({type:E(`resource`),resource:u([be,Se]),annotations:we.optional(),_meta:O(S(),k()).optional()}),qe=Te.extend({type:E(`resource_link`)}),Je=u([z,B,V,qe,H]),Ye=g({role:Ce,content:Je}),Xe=v.extend({description:S().optional(),messages:C(Ye)}),Ze=_.extend({method:E(`notifications/prompts/list_changed`),params:h.optional()}),U=g({title:S().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),Qe=g({taskSupport:x([`required`,`optional`,`forbidden`]).optional()}),$e=g({...ie.shape,...re.shape,description:S().optional(),inputSchema:g({type:E(`object`),properties:O(S(),e).optional(),required:C(S()).optional()}).catchall(k()),outputSchema:g({type:E(`object`),properties:O(S(),e).optional(),required:C(S()).optional()}).catchall(k()).optional(),annotations:U.optional(),execution:Qe.optional(),_meta:O(S(),k()).optional()}),et=ve.extend({method:E(`tools/list`)}),tt=ye.extend({tools:C($e)}),nt=v.extend({content:C(Je),structuredContent:O(S(),k()).optional(),isError:j().optional()}),rt=c.extend({name:S(),arguments:O(S(),k()).optional()}),it=l.extend({method:E(`tools/call`),params:rt}),at=_.extend({method:E(`notifications/tools/list_changed`),params:h.optional()}),ot=x([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),W=s.extend({level:ot}),st=l.extend({method:E(`logging/setLevel`),params:W}),ct=h.extend({level:ot,logger:S().optional(),data:k()}),lt=_.extend({method:E(`notifications/message`),params:ct}),ut=g({name:S().optional()}),dt=g({hints:C(ut).optional(),costPriority:A().min(0).max(1).optional(),speedPriority:A().min(0).max(1).optional(),intelligencePriority:A().min(0).max(1).optional()}),ft=g({mode:x([`auto`,`required`,`none`]).optional()}),pt=g({type:E(`tool_result`),toolUseId:S().describe(`The unique identifier for the corresponding tool call.`),content:C(Je),structuredContent:g({}).loose().optional(),isError:j().optional(),_meta:O(S(),k()).optional()}),mt=d(`type`,[z,B,V]),ht=d(`type`,[z,B,V,Ke,pt]),gt=g({role:Ce,content:u([ht,C(ht)]),_meta:O(S(),k()).optional()}),_t=c.extend({messages:C(gt),modelPreferences:dt.optional(),systemPrompt:S().optional(),includeContext:x([`none`,`thisServer`,`allServers`]).optional(),temperature:A().optional(),maxTokens:A().int(),stopSequences:C(S()).optional(),metadata:t.optional(),tools:C($e).optional(),toolChoice:ft.optional()}),vt=l.extend({method:E(`sampling/createMessage`),params:_t}),yt=v.extend({model:S(),stopReason:D(x([`endTurn`,`stopSequence`,`maxTokens`]).or(S())),role:Ce,content:mt}),bt=v.extend({model:S(),stopReason:D(x([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(S())),role:Ce,content:u([ht,C(ht)])}),xt=g({type:E(`boolean`),title:S().optional(),description:S().optional(),default:j().optional()}),St=g({type:E(`string`),title:S().optional(),description:S().optional(),minLength:A().optional(),maxLength:A().optional(),format:x([`email`,`uri`,`date`,`date-time`]).optional(),default:S().optional()}),Ct=g({type:x([`number`,`integer`]),title:S().optional(),description:S().optional(),minimum:A().optional(),maximum:A().optional(),default:A().optional()}),wt=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),default:S().optional()}),Tt=g({type:E(`string`),title:S().optional(),description:S().optional(),oneOf:C(g({const:S(),title:S()})),default:S().optional()}),Et=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),enumNames:C(S()).optional(),default:S().optional()}),Dt=u([wt,Tt]),Ot=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({type:E(`string`),enum:C(S())}),default:C(S()).optional()}),kt=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({anyOf:C(g({const:S(),title:S()}))}),default:C(S()).optional()}),At=u([Ot,kt]),jt=u([Et,Dt,At]),Mt=u([jt,xt,St,Ct]),Nt=c.extend({mode:E(`form`).optional(),message:S(),requestedSchema:g({type:E(`object`),properties:O(S(),Mt),required:C(S()).optional()}).catchall(k())}),Pt=c.extend({mode:E(`url`),message:S(),elicitationId:S(),url:S().url()}),Ft=u([Nt,Pt]),G=l.extend({method:E(`elicitation/create`),params:Ft}),It=h.extend({elicitationId:S()}),Lt=_.extend({method:E(`notifications/elicitation/complete`),params:It}),Rt=v.extend({action:x([`accept`,`decline`,`cancel`]),content:ee(e=>e===null?void 0:e,O(S(),u([S(),A(),j(),C(S())])).optional())}),zt=g({type:E(`ref/resource`),uri:S()}),Bt=g({type:E(`ref/prompt`),name:S()}),Vt=s.extend({ref:u([Bt,zt]),argument:g({name:S(),value:S()}),context:g({arguments:O(S(),S()).optional()}).optional()}),Ht=l.extend({method:E(`completion/complete`),params:Vt}),Ut=v.extend({completion:p({values:C(S()).max(100),total:D(A().int()),hasMore:D(j())})}),Wt=g({uri:S().startsWith(`file://`),name:S().optional(),_meta:O(S(),k()).optional()}),Gt=l.extend({method:E(`roots/list`),params:s.optional()}),Kt=v.extend({roots:C(Wt)}),qt=_.extend({method:E(`notifications/roots/list_changed`),params:h.optional()}),Jt=p({ttl:A().optional(),pollInterval:A().optional()}),Yt=x([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Xt=g({taskId:S(),status:Yt,ttl:u([A(),f()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:D(A()),statusMessage:D(S())}),Zt=v.extend({task:Xt}),Qt=h.merge(Xt),$t=_.extend({method:E(`notifications/tasks/status`),params:Qt}),en=l.extend({method:E(`tasks/get`),params:s.extend({taskId:S()})}),K=v.merge(Xt),tn=l.extend({method:E(`tasks/result`),params:s.extend({taskId:S()})}),nn=v.loose(),rn=ve.extend({method:E(`tasks/list`)}),an=ye.extend({tasks:C(Xt)}),on=l.extend({method:E(`tasks/cancel`),params:s.extend({taskId:S()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:h,NotificationSchema:_,ResultSchema:v,RequestIdSchema:y,EmptyResultSchema:b,CancelledNotificationParamsSchema:T,CancelledNotificationSchema:te,IconSchema:ne,IconsSchema:re,BaseMetadataSchema:ie,ImplementationSchema:ae,ClientTasksCapabilitySchema:ce,ServerTasksCapabilitySchema:le,ClientCapabilitiesSchema:ue,InitializeRequestParamsSchema:de,InitializeRequestSchema:pe,ServerCapabilitiesSchema:me,InitializeResultSchema:M,InitializedNotificationSchema:N,PingRequestSchema:he,ProgressSchema:P,ProgressNotificationParamsSchema:F,ProgressNotificationSchema:ge,PaginatedRequestParamsSchema:_e,PaginatedRequestSchema:ve,PaginatedResultSchema:ye,ResourceContentsSchema:I,TextResourceContentsSchema:be,BlobResourceContentsSchema:Se,RoleSchema:Ce,AnnotationsSchema:we,ResourceSchema:Te,ResourceTemplateSchema:Ee,ListResourcesRequestSchema:De,ListResourcesResultSchema:Oe,ListResourceTemplatesRequestSchema:ke,ListResourceTemplatesResultSchema:Ae,ResourceRequestParamsSchema:je,ReadResourceRequestParamsSchema:Me,ReadResourceRequestSchema:Ne,ReadResourceResultSchema:Pe,ResourceListChangedNotificationSchema:Fe,SubscribeRequestParamsSchema:Ie,SubscribeRequestSchema:Le,UnsubscribeRequestParamsSchema:Re,UnsubscribeRequestSchema:L,ResourceUpdatedNotificationParamsSchema:ze,ResourceUpdatedNotificationSchema:Be,PromptArgumentSchema:Ve,PromptSchema:He,ListPromptsRequestSchema:Ue,ListPromptsResultSchema:We,GetPromptRequestParamsSchema:R,GetPromptRequestSchema:Ge,TextContentSchema:z,ImageContentSchema:B,AudioContentSchema:V,ToolUseContentSchema:Ke,EmbeddedResourceSchema:H,ResourceLinkSchema:qe,ContentBlockSchema:Je,PromptMessageSchema:Ye,GetPromptResultSchema:Xe,PromptListChangedNotificationSchema:Ze,ToolAnnotationsSchema:U,ToolExecutionSchema:Qe,ToolSchema:$e,ListToolsRequestSchema:et,ListToolsResultSchema:tt,CallToolResultSchema:nt,CallToolRequestParamsSchema:rt,CallToolRequestSchema:it,ToolListChangedNotificationSchema:at,LoggingLevelSchema:ot,SetLevelRequestParamsSchema:W,SetLevelRequestSchema:st,LoggingMessageNotificationParamsSchema:ct,LoggingMessageNotificationSchema:lt,ModelHintSchema:ut,ModelPreferencesSchema:dt,ToolChoiceSchema:ft,ToolResultContentSchema:pt,SamplingContentSchema:mt,SamplingMessageContentBlockSchema:ht,SamplingMessageSchema:gt,CreateMessageRequestParamsSchema:_t,CreateMessageRequestSchema:vt,CreateMessageResultSchema:yt,CreateMessageResultWithToolsSchema:bt,BooleanSchemaSchema:xt,StringSchemaSchema:St,NumberSchemaSchema:Ct,UntitledSingleSelectEnumSchemaSchema:wt,TitledSingleSelectEnumSchemaSchema:Tt,LegacyTitledEnumSchemaSchema:Et,SingleSelectEnumSchemaSchema:Dt,UntitledMultiSelectEnumSchemaSchema:Ot,TitledMultiSelectEnumSchemaSchema:kt,MultiSelectEnumSchemaSchema:At,EnumSchemaSchema:jt,PrimitiveSchemaDefinitionSchema:Mt,ElicitRequestFormParamsSchema:Nt,ElicitRequestURLParamsSchema:Pt,ElicitRequestParamsSchema:Ft,ElicitRequestSchema:G,ElicitationCompleteNotificationParamsSchema:It,ElicitationCompleteNotificationSchema:Lt,ElicitResultSchema:Rt,ResourceTemplateReferenceSchema:zt,PromptReferenceSchema:Bt,CompleteRequestParamsSchema:Vt,CompleteRequestSchema:Ht,CompleteResultSchema:Ut,RootSchema:Wt,ListRootsRequestSchema:Gt,ListRootsResultSchema:Kt,RootsListChangedNotificationSchema:qt,TaskCreationParamsSchema:Jt,TaskStatusSchema:Yt,TaskSchema:Xt,CreateTaskResultSchema:Zt,TaskStatusNotificationParamsSchema:Qt,TaskStatusNotificationSchema:$t,GetTaskRequestSchema:en,GetTaskResultSchema:K,GetTaskPayloadRequestSchema:tn,GetTaskPayloadResultSchema:nn,ListTasksRequestSchema:rn,ListTasksResultSchema:an,CancelTaskRequestSchema:on,CancelTaskResultSchema:v.merge(Xt),ClientRequestSchema:u([he,pe,Ht,st,Ge,Ue,De,ke,Ne,Le,L,it,et,en,tn,rn,on]),ClientNotificationSchema:u([te,ge,N,qt,$t]),ClientResultSchema:u([b,yt,bt,Rt,Kt,K,an,Zt]),ServerRequestSchema:u([he,vt,G,Gt,en,tn,rn,on]),ServerNotificationSchema:u([te,ge,lt,Be,Fe,at,Ze,$t,Lt]),ServerResultSchema:u([b,M,Ut,Xe,We,Oe,Ae,Pe,nt,tt,K,an,Zt]),CallToolResultWireSchema:k().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of ui)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(di).pipe(nt)}}var pi;function mi(){return pi??=fi()}function hi(e){return e.type!==`object`}var gi=new Set([`const`,`enum`,`default`,`examples`]),_i=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function vi(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function yi(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(vi(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=De(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&vi(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=gi.has(o)?s:_i.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}var bi={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},xi={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},Si={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Ci;function wi(){if(Ci)return Ci;let e=mi();return Ci={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Ci}function Ti(e){return Object.prototype.hasOwnProperty.call(bi,e)}function Ei(e){return Object.prototype.hasOwnProperty.call(xi,e)}function Di(e){return Object.prototype.hasOwnProperty.call(Si,e)}function Oi(e){return Di(e)?wi().resultSchemas[e]:void 0}function ki(e){return Ti(e)?wi().requestSchemas[e]:void 0}function Ai(e){return Ei(e)?wi().notificationSchemas[e]:void 0}Object.keys(bi),Object.keys(xi);function ji(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mi(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Ni={ok:!1,reason:`not-in-era`};function Pi(e){return ji(e)&&ji(e.outputSchema)&&hi(e.outputSchema)}function Fi(e){return e}var Ii={era:`2025-11-25`,hasRequestMethod:Ti,hasNotificationMethod:Ei,validateRequest:(e,t)=>Mi(ki(e),t),validateResult:(e,t)=>Mi(Oi(e),t),validateNotification:(e,t)=>Mi(Ai(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Ni,validateInputResponse:()=>Ni,samplingResultVariant:((e,t)=>{let n=mi();return Mi(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=li(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&hi(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(ji(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:Fi(e)}}return{kind:`complete`,result:Fi(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>Pi(e))?t:{...t,tools:n.map(e=>Pi(e)?{...e,outputSchema:yi(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function Li(){let e=w(()=>u([S(),A(),j(),f(),O(S(),e),C(e)])),t=O(S(),e),n=u([S(),A().int()]),r=S(),i=u([S(),A().int()]),a=x([`user`,`assistant`]),o=x([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=g({ttl:A().optional()}),l=g({taskId:S()}),d=p({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),h=g({_meta:d.optional()}),_=h.extend({task:c.optional()}),v=g({_meta:d.optional()}),y=g({method:S(),params:v.loose().optional()}),b=g({src:S(),mimeType:S().optional(),sizes:C(S()).optional(),theme:x([`light`,`dark`]).optional()}),T=g({icons:C(b).optional()}),te=g({name:S(),title:S().optional()}),ne=te.extend({...te.shape,...T.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),re=m(g({applyDefaults:j().optional()}),t),ie=ee(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,m(g({form:re.optional(),url:t.optional()}),t.optional())),ae=p({list:t.optional(),cancel:t.optional(),requests:p({sampling:p({createMessage:t.optional()}).optional(),elicitation:p({create:t.optional()}).optional()}).optional()}),oe=p({list:t.optional(),cancel:t.optional(),requests:p({tools:p({call:t.optional()}).optional()}).optional()}),se=g({experimental:O(S(),t).optional(),sampling:g({context:t.optional(),tools:t.optional()}).optional(),elicitation:ie.optional(),roots:g({listChanged:j().optional()}).optional(),tasks:ae.optional(),extensions:O(S(),t).optional()}),ce=g({experimental:O(S(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:g({listChanged:j().optional()}).optional(),resources:g({subscribe:j().optional(),listChanged:j().optional()}).optional(),tools:g({listChanged:j().optional()}).optional(),tasks:oe.optional(),extensions:O(S(),t).optional()}),le=g({progress:A(),total:D(A()),message:D(S())}),ue=g({...v.shape,...le.shape,progressToken:n}),de=y.extend({method:E(`notifications/progress`),params:ue}),pe=v.extend({level:o,logger:S().optional(),data:k()}),me=y.extend({method:E(`notifications/message`),params:pe}),M=g({uri:S(),mimeType:D(S()),_meta:O(S(),k()).optional()}),N=M.extend({text:S()}),he=M.extend({blob:s}),P=g({audience:C(a).optional(),priority:A().min(0).max(1).optional(),lastModified:fe({offset:!0}).optional()}),F=g({...te.shape,...T.shape,uri:S(),description:D(S()),mimeType:D(S()),size:D(A()),annotations:P.optional(),_meta:D(p({}))}),ge=g({...te.shape,...T.shape,uriTemplate:S(),description:D(S()),mimeType:D(S()),annotations:P.optional(),_meta:D(p({}))}),_e=y.extend({method:E(`notifications/resources/list_changed`),params:v.optional()}),ve=v.extend({uri:S()}),ye=y.extend({method:E(`notifications/resources/updated`),params:ve}),I=g({name:S(),description:D(S()),required:D(j())}),be=g({...te.shape,...T.shape,description:D(S()),arguments:D(C(I)),_meta:D(p({}))}),xe=y.extend({method:E(`notifications/prompts/list_changed`),params:v.optional()}),Se=g({type:E(`text`),text:S(),annotations:P.optional(),_meta:O(S(),k()).optional()}),Ce=g({type:E(`image`),data:s,mimeType:S(),annotations:P.optional(),_meta:O(S(),k()).optional()}),we=g({type:E(`audio`),data:s,mimeType:S(),annotations:P.optional(),_meta:O(S(),k()).optional()}),Te=g({type:E(`tool_use`),name:S(),id:S(),input:O(S(),k()),_meta:O(S(),k()).optional()}),Ee=g({type:E(`resource`),resource:u([N,he]),annotations:P.optional(),_meta:O(S(),k()).optional()}),De=F.extend({type:E(`resource_link`)}),Oe=u([Se,Ce,we,De,Ee]),ke=g({role:a,content:Oe}),Ae=g({title:S().optional(),readOnlyHint:j().optional(),destructiveHint:j().optional(),idempotentHint:j().optional(),openWorldHint:j().optional()}),je=y.extend({method:E(`notifications/tools/list_changed`),params:v.optional()}),Ie=g({name:S().optional()}),Re=g({hints:C(Ie).optional(),costPriority:A().min(0).max(1).optional(),speedPriority:A().min(0).max(1).optional(),intelligencePriority:A().min(0).max(1).optional()}),L=g({mode:x([`auto`,`required`,`none`]).optional()}),ze=g({type:E(`boolean`),title:S().optional(),description:S().optional(),default:j().optional()}),Be=g({type:E(`string`),title:S().optional(),description:S().optional(),minLength:A().optional(),maxLength:A().optional(),format:x([`email`,`uri`,`date`,`date-time`]).optional(),default:S().optional()}),Ve=g({type:x([`number`,`integer`]),title:S().optional(),description:S().optional(),minimum:A().optional(),maximum:A().optional(),default:A().optional()}),He=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),default:S().optional()}),Ue=g({type:E(`string`),title:S().optional(),description:S().optional(),oneOf:C(g({const:S(),title:S()})),default:S().optional()}),We=g({type:E(`string`),title:S().optional(),description:S().optional(),enum:C(S()),enumNames:C(S()).optional(),default:S().optional()}),R=u([He,Ue]),Ge=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({type:E(`string`),enum:C(S())}),default:C(S()).optional()}),z=g({type:E(`array`),title:S().optional(),description:S().optional(),minItems:A().optional(),maxItems:A().optional(),items:g({anyOf:C(g({const:S(),title:S()}))}),default:C(S()).optional()}),B=u([Ge,z]),V=u([We,R,B]),Ke=u([V,ze,Be,Ve]),H=_.extend({mode:E(`form`).optional(),message:S(),requestedSchema:g({type:E(`object`),properties:O(S(),Ke),required:C(S()).optional()}).catchall(k())}),qe=g({type:E(`ref/resource`),uri:S()}),Je=g({type:E(`ref/prompt`),name:S()}),Ye=g({uri:S().startsWith(`file://`),name:S().optional(),_meta:O(S(),k()).optional()}),Xe=se.shape,Ze=g({experimental:Xe.experimental,sampling:Xe.sampling,elicitation:Xe.elicitation,roots:Xe.roots,extensions:Xe.extensions}),U=ce.shape,Qe=g({experimental:U.experimental,logging:U.logging,completions:U.completions,prompts:U.prompts,resources:U.resources,tools:U.tools,extensions:U.extensions}),$e=p({progressToken:n.optional(),[Me]:S(),[Ne]:ne.optional(),[Fe]:Ze,[Le]:o.optional()}),et=g({...te.shape,...T.shape,description:S().optional(),inputSchema:p({$schema:S().optional(),type:E(`object`)}),outputSchema:p({$schema:S().optional()}).optional(),annotations:Ae.optional(),_meta:O(S(),k()).optional()}),tt=g({type:E(`tool_result`),toolUseId:S(),content:C(Oe),structuredContent:k().optional(),isError:j().optional(),_meta:O(S(),k()).optional()}),nt=u([Se,Ce,we,Te,tt]),rt=g({role:a,content:u([nt,C(nt)]),_meta:O(S(),k()).optional()}),it=S(),at=p({[Pe]:ne.optional().catch(void 0)}),ot=at.optional();function W(e){return p({_meta:ot,resultType:it.default(`complete`),...e})}let st=W({}),ct=W({nextCursor:r.optional()}),lt=W({content:C(Oe),structuredContent:k().optional(),isError:j().optional()}),ut=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),tools:C(et),nextCursor:r.optional()}),dt=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),prompts:C(be),nextCursor:r.optional()}),ft=W({description:S().optional(),messages:C(ke)}),pt=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),resources:C(F),nextCursor:r.optional()}),mt=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),resourceTemplates:C(ge),nextCursor:r.optional()}),ht=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),contents:C(u([N,he]))}),gt=W({completion:g({values:C(S()).max(100),total:A().int().optional(),hasMore:j().optional()}).loose()}),_t=W({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`])}),vt=W({ttlMs:A().int().min(0).catch(0),cacheScope:x([`public`,`private`]).catch(`private`),supportedVersions:C(S()),capabilities:Qe,instructions:S().optional()}),yt=g({messages:C(rt),modelPreferences:Re.optional(),systemPrompt:S().optional(),includeContext:x([`none`,`thisServer`,`allServers`]).optional(),temperature:A().optional(),maxTokens:A().int(),stopSequences:C(S()).optional(),metadata:t.optional(),tools:C(et).optional(),toolChoice:L.optional()}),bt=g({method:E(`sampling/createMessage`),params:yt}),xt=g({method:E(`roots/list`),params:g({_meta:O(S(),k()).optional()}).optional()}),St=g({...rt.shape,model:S(),stopReason:S().optional()}),Ct=g({roots:C(Ye)}),wt=g({action:x([`accept`,`decline`,`cancel`]),content:O(S(),u([S(),A(),j(),C(S())])).optional()}),Tt=g({mode:E(`url`),message:S(),url:S().url()}),Et=u([H,Tt]),Dt=g({method:E(`elicitation/create`),params:Et}),Ot=u([bt,xt,Dt]),kt=u([St,Ct,wt]),At=O(S(),Ot),jt=O(S(),kt),Mt=W({inputRequests:At.optional(),requestState:S().optional()}),Nt={inputResponses:jt.optional(),requestState:S().optional()},Pt=g({_meta:$e,...Nt}),Ft=p({progressToken:n.optional()});function G(e,t){return g({method:E(e),params:g({_meta:$e,...t})})}function It(e,t){return g({method:E(e),params:g({_meta:Ft.optional(),...t}).optional()})}let Lt={name:S(),arguments:O(S(),k()).optional(),...Nt},Rt={cursor:r.optional()},zt=G(`tools/call`,Lt),Bt=G(`tools/list`,Rt),Vt=G(`prompts/list`,Rt),Ht=G(`prompts/get`,{name:S(),arguments:O(S(),S()).optional(),...Nt}),Ut=G(`resources/list`,Rt),Wt=G(`resources/templates/list`,Rt),Gt=G(`resources/read`,{uri:S(),...Nt}),Kt={ref:u([Je,qe]),argument:g({name:S(),value:S()}),context:g({arguments:O(S(),S()).optional()}).optional()},qt=G(`completion/complete`,Kt),Jt=G(`server/discover`,{}),Yt=g({toolsListChanged:j().optional(),promptsListChanged:j().optional(),resourcesListChanged:j().optional(),resourceSubscriptions:C(S()).optional()}),Xt={notifications:Yt},Zt=G(`subscriptions/listen`,Xt),Qt=at.extend({"io.modelcontextprotocol/subscriptionId":i}),$t=p({_meta:Qt,resultType:it.default(`complete`)}),en={"tools/call":It(`tools/call`,Lt),"tools/list":It(`tools/list`,Rt),"prompts/get":It(`prompts/get`,{name:S(),arguments:O(S(),S()).optional()}),"prompts/list":It(`prompts/list`,Rt),"resources/list":It(`resources/list`,Rt),"resources/templates/list":It(`resources/templates/list`,Rt),"resources/read":It(`resources/read`,{uri:S()}),"completion/complete":It(`completion/complete`,Kt),"server/discover":It(`server/discover`,{}),"subscriptions/listen":It(`subscriptions/listen`,Xt)};function K(e){return p({_meta:ot,...e})}let tn={"tools/call":K({content:C(Oe),structuredContent:k().optional(),isError:j().optional()}),"tools/list":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),tools:C(et),nextCursor:r.optional()}),"prompts/get":K({description:S().optional(),messages:C(ke)}),"prompts/list":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),prompts:C(be),nextCursor:r.optional()}),"resources/list":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),resources:C(F),nextCursor:r.optional()}),"resources/templates/list":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),resourceTemplates:C(ge),nextCursor:r.optional()}),"resources/read":K({ttlMs:A().int().min(0),cacheScope:x([`public`,`private`]),contents:C(u([N,he]))}),"completion/complete":K({completion:g({values:C(S()).max(100),total:A().int().optional(),hasMore:j().optional()}).loose()}),"server/discover":K({ttlMs:A().int().min(0).catch(0),cacheScope:x([`public`,`private`]).catch(`private`),supportedVersions:C(S()),capabilities:Qe,instructions:S().optional()}),"subscriptions/listen":K({})},nn=p({"io.modelcontextprotocol/subscriptionId":i.optional()}),rn=g({method:E(`notifications/subscriptions/acknowledged`),params:g({_meta:nn.optional(),notifications:Yt})}),an=g({_meta:nn.optional(),requestId:i,reason:S().optional()}),on=g({method:E(`notifications/cancelled`),params:an}),sn={"notifications/cancelled":on,"notifications/progress":de,"notifications/message":me,"notifications/resources/updated":ye,"notifications/resources/list_changed":_e,"notifications/tools/list_changed":je,"notifications/prompts/list_changed":xe,"notifications/subscriptions/acknowledged":rn},cn=e=>g({jsonrpc:E(`2.0`),id:u([S(),A().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:d,BaseRequestParamsSchema:h,TaskAugmentedRequestParamsSchema:_,NotificationsParamsSchema:v,NotificationSchema:y,IconSchema:b,IconsSchema:T,BaseMetadataSchema:te,ImplementationSchema:ne,ClientTasksCapabilitySchema:ae,ServerTasksCapabilitySchema:oe,ClientCapabilitiesSchema:se,ServerCapabilitiesSchema:ce,ProgressSchema:le,ProgressNotificationParamsSchema:ue,ProgressNotificationSchema:de,LoggingMessageNotificationParamsSchema:pe,LoggingMessageNotificationSchema:me,ResourceContentsSchema:M,TextResourceContentsSchema:N,BlobResourceContentsSchema:he,AnnotationsSchema:P,ResourceSchema:F,ResourceTemplateSchema:ge,ResourceListChangedNotificationSchema:_e,ResourceUpdatedNotificationParamsSchema:ve,ResourceUpdatedNotificationSchema:ye,PromptArgumentSchema:I,PromptSchema:be,PromptListChangedNotificationSchema:xe,TextContentSchema:Se,ImageContentSchema:Ce,AudioContentSchema:we,ToolUseContentSchema:Te,EmbeddedResourceSchema:Ee,ResourceLinkSchema:De,ContentBlockSchema:Oe,PromptMessageSchema:ke,ToolAnnotationsSchema:Ae,ToolListChangedNotificationSchema:je,ModelHintSchema:Ie,ModelPreferencesSchema:Re,ToolChoiceSchema:L,BooleanSchemaSchema:ze,StringSchemaSchema:Be,NumberSchemaSchema:Ve,UntitledSingleSelectEnumSchemaSchema:He,TitledSingleSelectEnumSchemaSchema:Ue,LegacyTitledEnumSchemaSchema:We,SingleSelectEnumSchemaSchema:R,UntitledMultiSelectEnumSchemaSchema:Ge,TitledMultiSelectEnumSchemaSchema:z,MultiSelectEnumSchemaSchema:B,EnumSchemaSchema:V,PrimitiveSchemaDefinitionSchema:Ke,ElicitRequestFormParamsSchema:H,ResourceTemplateReferenceSchema:qe,PromptReferenceSchema:Je,RootSchema:Ye,ClientCapabilities2026Schema:Ze,ServerCapabilities2026Schema:Qe,RequestMetaEnvelopeSchema:$e,ToolSchema:et,ToolResultContentSchema:tt,SamplingMessageContentBlockSchema:nt,SamplingMessageSchema:rt,ResultTypeSchema:it,ResultMetaSchema:at,ResultSchema:st,PaginatedResultSchema:ct,CallToolResultSchema:lt,ListToolsResultSchema:ut,ListPromptsResultSchema:dt,GetPromptResultSchema:ft,ListResourcesResultSchema:pt,ListResourceTemplatesResultSchema:mt,ReadResourceResultSchema:ht,CompleteResultSchema:gt,CacheableResultSchema:_t,DiscoverResultSchema:vt,CreateMessageRequestParamsSchema:yt,CreateMessageRequestSchema:bt,ListRootsRequestSchema:xt,CreateMessageResultSchema:St,ListRootsResultSchema:Ct,ElicitResultSchema:wt,ElicitRequestURLParamsSchema:Tt,ElicitRequestParamsSchema:Et,ElicitRequestSchema:Dt,InputRequestSchema:Ot,InputResponseSchema:kt,InputRequestsSchema:At,InputResponsesSchema:jt,InputRequiredResultSchema:Mt,InputResponseRequestParamsSchema:Pt,CallToolRequestSchema:zt,ListToolsRequestSchema:Bt,ListPromptsRequestSchema:Vt,GetPromptRequestSchema:Ht,ListResourcesRequestSchema:Ut,ListResourceTemplatesRequestSchema:Wt,ReadResourceRequestSchema:Gt,CompleteRequestSchema:qt,DiscoverRequestSchema:Jt,SubscriptionFilterSchema:Yt,SubscriptionsListenRequestSchema:Zt,SubscriptionsListenResultMetaSchema:Qt,SubscriptionsListenResultSchema:$t,dispatchRequestSchemas:en,dispatchResultSchemas:tn,NotificationMetaSchema:nn,SubscriptionsAcknowledgedNotificationSchema:rn,CancelledNotificationParamsSchema:an,CancelledNotificationSchema:on,notificationSchemas2026:sn,JSONRPCResultResponseSchema:cn(st),CallToolResultResponseSchema:cn(u([lt,Mt])),ListToolsResultResponseSchema:cn(ut),ListPromptsResultResponseSchema:cn(dt),GetPromptResultResponseSchema:cn(u([ft,Mt])),ListResourcesResultResponseSchema:cn(pt),ListResourceTemplatesResultResponseSchema:cn(mt),ReadResourceResultResponseSchema:cn(u([ht,Mt])),CompleteResultResponseSchema:cn(gt),DiscoverResultResponseSchema:cn(vt),SubscriptionsListenResultResponseSchema:cn($t)}}var Ri;function zi(){return Ri??=Li()}var Bi=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Vi(e){return Bi.includes(e)}var Hi=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Ui(e){return e[Hi]}function Wi(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Gi(e){return e===`public`||e===`private`}var X=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),Z=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return Zr(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return Zr(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Xr(this,new.target)}static fromError(t,n,r){if(t===X.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new qi(e.elicitations,n)}if(t===X.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Ji({supported:e.supported,requested:e.requested},n)}if(t===X.InvalidParams||t===X.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===X.ResourceNotFound||Object.keys(e).length===1))return new Ki(e.uri,n)}if(t===X.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Yi({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},Ki=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(X.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},qi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(X.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Ji=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(X.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Yi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(X.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Xi=0,Zi=`private`,Qi=[`tools/call`,`prompts/get`,`resources/read`];function $i(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||Qi.includes(e))return t;throw new Z(X.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function ea(e,t){let n=Ui(t);if(t.resultType!==`complete`||!Vi(e))return n===void 0?t:aa(t);let r=t,i=Wi(r.ttlMs)?r.ttlMs:ra(n),a=Gi(r.cacheScope)?r.cacheScope:ia(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Hi],o}function ta(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function na(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[Pe]:t}}:!ta(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[Pe]:t}}}function ra(e){return e!==void 0&&Wi(e.ttlMs)?e.ttlMs:Xi}function ia(e){return e!==void 0&&Gi(e.cacheScope)?e.cacheScope:Zi}function aa(e){let t={...e};return delete t[Hi],t}var oa=[`elicitation/create`,`sampling/createMessage`,`roots/list`],sa;function ca(){if(sa)return sa;let e=zi();return sa={request:{"elicitation/create":g({method:E(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":g({method:E(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":g({method:E(`roots/list`),params:p({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},sa}function la(e){return oa.includes(e)}function ua(e){return la(e)?ca().request[e]:void 0}function da(e){return la(e)?ca().response[e]:void 0}var fa={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},pa={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function ma(e){return Object.prototype.hasOwnProperty.call(fa,e)}function ha(e){return Object.prototype.hasOwnProperty.call(pa,e)}function ga(e){return Object.prototype.hasOwnProperty.call(fa,e)}function _a(e){return ma(e)?zi().dispatchRequestSchemas[e]:void 0}function va(e){return ga(e)?zi().dispatchResultSchemas[e]:void 0}function ya(e){return ha(e)?zi().notificationSchemas2026[e]:void 0}Object.keys(fa),Object.keys(pa);function ba(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xa(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Sa={ok:!1,reason:`not-in-era`},Ca=[Me,Fe];function wa(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>ba(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!ba(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(ba(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}var Ta={era:`2026-07-28`,hasRequestMethod:ma,hasNotificationMethod:ha,hasInputRequestMethod:e=>ua(e)!==void 0,validateRequest:(e,t)=>xa(_a(e),t),validateResult:(e,t)=>xa(va(e),t),validateNotification:(e,t)=>xa(ya(e),t),validateInputRequest:(e,t)=>xa(ua(e),t),validateInputResponse:(e,t)=>xa(da(e),t),samplingResultVariant:()=>Sa,outboundEnvelope(e){return{[Me]:e.protocolVersion,[Ne]:e.clientInfo,[Fe]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of Ca)n in e||t.push({key:n,problem:`missing`});let n=zi().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>li(e),inputRequestSchema:ua,decodeResult(e,t){if(!ba(t))return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=ba(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:zi().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new Y(J.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=Da(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return na(ea(e,$i(e,wa(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=zi().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}},Ea;function Da(){if(Ea)return Ea;let e=zi();return Ea={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},Ea}var Oa=`2026-07-28`;function ka(e){return e!==void 0&&oi(e)?Ta:Ii}function Aa(e){return e.revision===void 0?e.era===`modern`?Ta.era:Ii.era:ka(e.revision).era}function ja(e){return Pa.some(t=>t.hasRequestMethod(e))}function Ma(e){return Pa.some(t=>t.hasNotificationMethod(e))}function Na(e){return e===`tasks/get`||e===`tasks/cancel`}var Pa=[Ii,Ta],Fa=be({AnnotationsSchema:()=>kt,AudioContentSchema:()=>sn,BaseMetadataSchema:()=>it,BaseRequestParamsSchema:()=>R,BlobResourceContentsSchema:()=>Dt,BooleanSchemaSchema:()=>Hn,CallToolRequestParamsSchema:()=>Sn,CallToolRequestSchema:()=>Cn,CallToolResultSchema:()=>bn,CancelTaskRequestSchema:()=>Or,CancelTaskResultSchema:()=>kr,CancelledNotificationParamsSchema:()=>et,CancelledNotificationSchema:()=>tt,ClientCapabilitiesSchema:()=>lt,ClientNotificationSchema:()=>jr,ClientRequestSchema:()=>Ar,ClientResultSchema:()=>Mr,ClientTasksCapabilitySchema:()=>st,CompatibilityCallToolResultSchema:()=>xn,CompleteRequestParamsSchema:()=>lr,CompleteRequestSchema:()=>ur,CompleteResultSchema:()=>dr,ContentBlockSchema:()=>dn,CreateMessageRequestParamsSchema:()=>Rn,CreateMessageRequestSchema:()=>zn,CreateMessageResultSchema:()=>Bn,CreateMessageResultWithToolsSchema:()=>Vn,CreateTaskResultSchema:()=>yr,CursorSchema:()=>Ve,DiscoverRequestSchema:()=>ht,DiscoverResultSchema:()=>gt,ElicitRequestFormParamsSchema:()=>er,ElicitRequestParamsSchema:()=>nr,ElicitRequestSchema:()=>rr,ElicitRequestURLParamsSchema:()=>tr,ElicitResultSchema:()=>or,ElicitationCompleteNotificationParamsSchema:()=>ir,ElicitationCompleteNotificationSchema:()=>ar,EmbeddedResourceSchema:()=>ln,EmptyResultSchema:()=>$e,EnumSchemaSchema:()=>Qn,GetPromptRequestParamsSchema:()=>nn,GetPromptRequestSchema:()=>rn,GetPromptResultSchema:()=>pn,GetTaskPayloadRequestSchema:()=>wr,GetTaskPayloadResultSchema:()=>Tr,GetTaskRequestSchema:()=>Sr,GetTaskResultSchema:()=>Cr,IconSchema:()=>nt,IconsSchema:()=>rt,ImageContentSchema:()=>on,ImplementationSchema:()=>at,InitializeRequestParamsSchema:()=>ut,InitializeRequestSchema:()=>dt,InitializeResultSchema:()=>pt,InitializedNotificationSchema:()=>mt,JSONArraySchema:()=>ze,JSONObjectSchema:()=>L,JSONRPCErrorResponseSchema:()=>Ze,JSONRPCMessageSchema:()=>U,JSONRPCNotificationSchema:()=>Ye,JSONRPCRequestSchema:()=>Je,JSONRPCResponseSchema:()=>Qe,JSONRPCResultResponseSchema:()=>Xe,JSONValueSchema:()=>Re,LegacyTitledEnumSchemaSchema:()=>qn,ListChangedOptionsBaseSchema:()=>Tn,ListPromptsRequestSchema:()=>K,ListPromptsResultSchema:()=>tn,ListResourceTemplatesRequestSchema:()=>Pt,ListResourceTemplatesResultSchema:()=>Ft,ListResourcesRequestSchema:()=>Mt,ListResourcesResultSchema:()=>Nt,ListRootsRequestSchema:()=>pr,ListRootsResultSchema:()=>mr,ListTasksRequestSchema:()=>Er,ListTasksResultSchema:()=>Dr,ListToolsRequestSchema:()=>vn,ListToolsResultSchema:()=>yn,LoggingLevelSchema:()=>En,LoggingMessageNotificationParamsSchema:()=>kn,LoggingMessageNotificationSchema:()=>An,ModelHintSchema:()=>jn,ModelPreferencesSchema:()=>Mn,MultiSelectEnumSchemaSchema:()=>Zn,NotificationSchema:()=>V,NotificationsParamsSchema:()=>B,NumberSchemaSchema:()=>Wn,PaginatedRequestParamsSchema:()=>xt,PaginatedRequestSchema:()=>St,PaginatedResultSchema:()=>Ct,PingRequestSchema:()=>_t,PrimitiveSchemaDefinitionSchema:()=>$n,ProgressNotificationParamsSchema:()=>yt,ProgressNotificationSchema:()=>bt,ProgressSchema:()=>vt,ProgressTokenSchema:()=>Be,PromptArgumentSchema:()=>$t,PromptListChangedNotificationSchema:()=>mn,PromptMessageSchema:()=>fn,PromptReferenceSchema:()=>cr,PromptSchema:()=>en,ReadResourceRequestParamsSchema:()=>It,ReadResourceRequestSchema:()=>Lt,ReadResourceResultSchema:()=>Rt,RelatedTaskMetadataSchema:()=>Ue,RequestIdSchema:()=>qe,RequestMetaSchema:()=>We,RequestSchema:()=>z,ResourceContentsSchema:()=>wt,ResourceLinkSchema:()=>un,ResourceListChangedNotificationSchema:()=>zt,ResourceRequestParamsSchema:()=>G,ResourceSchema:()=>At,ResourceTemplateReferenceSchema:()=>sr,ResourceTemplateSchema:()=>jt,ResourceUpdatedNotificationParamsSchema:()=>Zt,ResourceUpdatedNotificationSchema:()=>Qt,ResultMetaObjectSchema:()=>Ke,ResultSchema:()=>H,RoleSchema:()=>Ot,RootSchema:()=>fr,RootsListChangedNotificationSchema:()=>hr,SamplingContentSchema:()=>Fn,SamplingMessageContentBlockSchema:()=>In,SamplingMessageSchema:()=>Ln,ServerCapabilitiesSchema:()=>ft,ServerNotificationSchema:()=>Pr,ServerRequestSchema:()=>Nr,ServerResultSchema:()=>Fr,ServerTasksCapabilitySchema:()=>ct,SetLevelRequestParamsSchema:()=>Dn,SetLevelRequestSchema:()=>On,SingleSelectEnumSchemaSchema:()=>Jn,StringSchemaSchema:()=>Un,SubscribeRequestParamsSchema:()=>Bt,SubscribeRequestSchema:()=>Vt,SubscriptionFilterSchema:()=>Wt,SubscriptionsAcknowledgedNotificationParamsSchema:()=>qt,SubscriptionsAcknowledgedNotificationSchema:()=>Jt,SubscriptionsListenRequestParamsSchema:()=>Gt,SubscriptionsListenRequestSchema:()=>Kt,SubscriptionsListenResultMetaSchema:()=>Yt,SubscriptionsListenResultSchema:()=>Xt,TaskAugmentedRequestParamsSchema:()=>Ge,TaskCreationParamsSchema:()=>gr,TaskMetadataSchema:()=>He,TaskSchema:()=>vr,TaskStatusNotificationParamsSchema:()=>br,TaskStatusNotificationSchema:()=>xr,TaskStatusSchema:()=>_r,TextContentSchema:()=>an,TextResourceContentsSchema:()=>Tt,TitledMultiSelectEnumSchemaSchema:()=>Xn,TitledSingleSelectEnumSchemaSchema:()=>Kn,ToolAnnotationsSchema:()=>hn,ToolChoiceSchema:()=>Nn,ToolExecutionSchema:()=>gn,ToolListChangedNotificationSchema:()=>wn,ToolResultContentSchema:()=>Pn,ToolSchema:()=>_n,ToolUseContentSchema:()=>cn,UnsubscribeRequestParamsSchema:()=>Ht,UnsubscribeRequestSchema:()=>Ut,UntitledMultiSelectEnumSchemaSchema:()=>Yn,UntitledSingleSelectEnumSchemaSchema:()=>Gn}),Ia=e=>Je.safeParse(e).success,La=e=>Ye.safeParse(e).success,Ra=e=>Xe.safeParse(e).success,za=e=>Ze.safeParse(e).success,Ba=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`,Va=e=>dt.safeParse(e).success,Ha=e=>mt.safeParse(e).success,Ua=`Mcp-Param-`,Wa=`x-mcp-header`,Ga=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Ka=new Set([`string`,`integer`,`boolean`,`number`]);function qa(e){let t=[],n=new Map,r=(e,i,a)=>{if(typeof e!=`object`||!e)return;let o=e;if(Wa in o){if(!a||i.length===0)return`${Xa(i)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let e=o[Wa];if(typeof e!=`string`||e.length===0)return`${Xa(i)}: x-mcp-header MUST be a non-empty string`;if(!Ga.test(e))return`${Xa(i)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let r=typeof o.type==`string`?o.type:void 0;if(r===void 0||!Ka.has(r))return`${Xa(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${r??``}`;let s=e.toLowerCase(),c=n.get(s);if(c!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${c}')`;n.set(s,e),t.push({path:i,headerName:e,type:r})}let s=o.properties;if(typeof s==`object`&&s)for(let[e,t]of Object.entries(s)){let n=r(t,[...i,e],a);if(n!==void 0)return n}for(let e of Ja){let t=o[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Ya.has(e)?Object.values(t):[t];for(let t of n){let n=r(t,[...i,`<${e}>`],!1);if(n!==void 0)return n}}},i=r(e,[],!0);return i===void 0?{valid:!0,declarations:t}:{valid:!1,reason:i}}var Ja=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Ya=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]);function Xa(e){return e.length===0?``:e.join(`.`)}var Za=`=?base64?`,Qa=`?=`;function $a(e){if(typeof e==`string`)return e;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function eo(e){if(e.length===0||e.startsWith(Za)&&e.endsWith(Qa)||e!==e.trim())return!0;for(let t=0;t=32&&n<=126))return!0}return!1}function to(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCodePoint(e);return btoa(n)}function no(e){return eo(e)?`${Za}${to(e)}${Qa}`:e}function ro(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function io(e,t){let n={};for(let r of e){let e=ro(t,r.path);if(e==null)continue;let i=$a(e);i!==void 0&&(n[`${Ua}${r.headerName}`]=no(i))}return n}X.InvalidRequest,X.UnsupportedProtocolVersion,X.InvalidParams,X.MethodNotFound,X.InvalidParams,X.MissingRequiredClientCapability,X.ParseError,X.InvalidRequest,X.MethodNotFound,X.UnsupportedProtocolVersion,X.MissingRequiredClientCapability;var ao={"tools/call":`name`,"prompts/get":`name`,"resources/read":`uri`,"tasks/get":`taskId`,"tasks/update":`taskId`,"tasks/cancel":`taskId`};function oo(e,t){let n=Object.hasOwn(ao,e)?ao[e]:void 0;if(n===void 0)return;let r=so(t)?t[n]:void 0;return{field:n,value:typeof r==`string`?r:void 0}}function so(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function co(e,t){return ie(e,t)}function lo(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function uo(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}var fo=!1,po=`draft-2020-12`;function mo(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:po});else if(n.vendor===`zod`){if(!(`_zod`in e))throw Error(`Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().`);fo||(fo=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=oe(e,{target:po,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&ho(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}function ho(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||ho(e)))}return!1}function go(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function _o(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>go(e)).join(`, `)}:{success:!0,data:n.value}}function vo(e){let t=oe(e,{target:po,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}var yo=/\\\.\\d\{(\d+)\}/;function bo(e){let t=yo.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>fe({local:e,offset:t,precision:n}))))}function xo(e,t){let n;switch(e){case`email`:n=[T()];break;case`uri`:n=[ce()];break;case`date`:n=[pe()];break;case`date-time`:n=bo(t)}return new Set(n.map(e=>vo(e)).filter(e=>e!==void 0))}function So(e,t,n){return n!==`zod`||xo(e,t).has(t)}function Co(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wo(e){try{return mo(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Z(X.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}var To=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function Eo(e){return To.has(e)||e.startsWith(`x-`)}var Do=new Set([`$schema`,...Object.keys(er.shape.requestedSchema.shape)]),Oo={string:lo([Un,Gn,Kn,qn]),number:lo([Wn]),integer:lo([Wn]),boolean:lo([Hn]),array:lo([Yn,Xn])},ko=new Set(Un.shape.format.unwrap().options);function Ao(e,t,n,r){if(!Co(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(Oo,e.type)?Oo[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||Eo(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?ko.has(e.format)?(typeof s!=`string`||!So(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function jo(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&Co(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,Ao(n,`properties.${e}`,t,r)])):Do.has(i)?n[i]=a:Eo(i)||r.push(i);if(r.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function Mo(e,t){if(!Co(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!co($n,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function No(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>No(e,t[r],`${n}[${r}]`)):!Co(e)||!Co(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?No(r,t[e],i):Eo(e)?[]:[i]})}function Po(e){if(!uo(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=jo(wo(e.requestedSchema),t),r=co(er.shape.requestedSchema,n);if(!r.success)throw new Z(X.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${Mo(n,r.error.message)}`);let i=No(n,r.data);if(i.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function Fo(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw TypeError(`inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)`);return{resultType:`input_required`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(Fo,{elicit(e){try{return{method:`elicitation/create`,params:Po(e)}}catch(e){throw e instanceof Z?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});var Io=!0,Lo=10,Ro=250;function zo(e){return{autoFulfill:e?.autoFulfill??Io,maxRounds:e?.maxRounds??Lo}}function Bo(e,t,n){let r=t!==void 0&&Object.keys(t).length>0;return!r&&n===void 0?e:{...e,...r&&{inputResponses:t},...n!==void 0&&{requestState:n}}}function Vo(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function Ho(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof Y?t.reason:new Y(J.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof Y?t.reason:new Y(J.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function Uo(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}async function Wo(e){let{config:t,method:n,originalParams:r,requestOptions:i,hooks:a,signal:o}=e,s=e.flowStartedAt??Date.now(),c=e.firstPayload,l=0;for(;;){if(l+=1,l>t.maxRounds)throw new Y(J.InputRequiredRoundsExceeded,Vo(n,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:c.inputRequests,...c.requestState!==void 0&&{requestState:c.requestState}}});i.onprogress?.({progress:l,message:`Fulfilling input required by '${n}' (round ${l})`});let e=Object.entries(c.inputRequests??{}),u;if(e.length>0){let t=Uo(o);try{let n=await Promise.all(e.map(async([e,n])=>{try{return[e,await a.dispatchInputRequest(e,n,t.signal)]}catch(e){throw t.abort(e),e}}));u=Object.fromEntries(n)}finally{t.dispose()}}else await Ho(Ro,o);let d={...i.timeout!==void 0&&{timeout:i.timeout}};if(i.maxTotalTimeout!==void 0){let e=Date.now()-s,t=i.maxTotalTimeout-e;if(t<=0)throw new Y(J.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:i.maxTotalTimeout,totalElapsed:e});d.maxTotalTimeout=t}let f=await a.retry(Bo(r,u,c.requestState),d);if(Ba(f)){c={inputRequests:f.inputRequests??{},...f.requestState!==void 0&&{requestState:f.requestState}};continue}return f}}var Go=`AnnotationsSchema.AudioContentSchema.BaseMetadataSchema.BlobResourceContentsSchema.BooleanSchemaSchema.CallToolRequestSchema.CallToolRequestParamsSchema.CallToolResultSchema.CancelledNotificationSchema.CancelledNotificationParamsSchema.CancelTaskRequestSchema.CancelTaskResultSchema.ClientCapabilitiesSchema.ClientNotificationSchema.ClientRequestSchema.ClientResultSchema.CompatibilityCallToolResultSchema.CompleteRequestSchema.CompleteRequestParamsSchema.CompleteResultSchema.ContentBlockSchema.CreateMessageRequestSchema.CreateMessageRequestParamsSchema.CreateMessageResultSchema.CreateMessageResultWithToolsSchema.CreateTaskResultSchema.CursorSchema.DiscoverRequestSchema.DiscoverResultSchema.ElicitationCompleteNotificationSchema.ElicitationCompleteNotificationParamsSchema.ElicitRequestSchema.ElicitRequestFormParamsSchema.ElicitRequestParamsSchema.ElicitRequestURLParamsSchema.ElicitResultSchema.EmbeddedResourceSchema.EmptyResultSchema.EnumSchemaSchema.GetPromptRequestSchema.GetPromptRequestParamsSchema.GetPromptResultSchema.GetTaskPayloadRequestSchema.GetTaskPayloadResultSchema.GetTaskRequestSchema.GetTaskResultSchema.IconSchema.IconsSchema.ImageContentSchema.ImplementationSchema.InitializedNotificationSchema.InitializeRequestSchema.InitializeRequestParamsSchema.InitializeResultSchema.JSONArraySchema.JSONObjectSchema.JSONRPCErrorResponseSchema.JSONRPCMessageSchema.JSONRPCNotificationSchema.JSONRPCRequestSchema.JSONRPCResponseSchema.JSONRPCResultResponseSchema.JSONValueSchema.LegacyTitledEnumSchemaSchema.ListPromptsRequestSchema.ListPromptsResultSchema.ListResourcesRequestSchema.ListResourcesResultSchema.ListResourceTemplatesRequestSchema.ListResourceTemplatesResultSchema.ListRootsRequestSchema.ListRootsResultSchema.ListTasksRequestSchema.ListTasksResultSchema.ListToolsRequestSchema.ListToolsResultSchema.LoggingLevelSchema.LoggingMessageNotificationSchema.LoggingMessageNotificationParamsSchema.ModelHintSchema.ModelPreferencesSchema.MultiSelectEnumSchemaSchema.NotificationSchema.NumberSchemaSchema.PaginatedRequestSchema.PaginatedRequestParamsSchema.PaginatedResultSchema.PingRequestSchema.PrimitiveSchemaDefinitionSchema.ProgressSchema.ProgressNotificationSchema.ProgressNotificationParamsSchema.ProgressTokenSchema.PromptSchema.PromptArgumentSchema.PromptListChangedNotificationSchema.PromptMessageSchema.PromptReferenceSchema.ReadResourceRequestSchema.ReadResourceRequestParamsSchema.ReadResourceResultSchema.RelatedTaskMetadataSchema.RequestSchema.RequestIdSchema.RequestMetaSchema.ResourceSchema.ResourceContentsSchema.ResourceLinkSchema.ResourceListChangedNotificationSchema.ResourceRequestParamsSchema.ResourceTemplateSchema.ResourceTemplateReferenceSchema.ResourceUpdatedNotificationSchema.ResourceUpdatedNotificationParamsSchema.ResultMetaObjectSchema.ResultSchema.RoleSchema.RootSchema.RootsListChangedNotificationSchema.SamplingContentSchema.SamplingMessageSchema.SamplingMessageContentBlockSchema.ServerCapabilitiesSchema.ServerNotificationSchema.ServerRequestSchema.ServerResultSchema.SetLevelRequestSchema.SetLevelRequestParamsSchema.SingleSelectEnumSchemaSchema.StringSchemaSchema.SubscribeRequestSchema.SubscribeRequestParamsSchema.SubscriptionFilterSchema.SubscriptionsAcknowledgedNotificationSchema.SubscriptionsAcknowledgedNotificationParamsSchema.SubscriptionsListenRequestSchema.SubscriptionsListenRequestParamsSchema.SubscriptionsListenResultSchema.SubscriptionsListenResultMetaSchema.TaskAugmentedRequestParamsSchema.TaskCreationParamsSchema.TaskMetadataSchema.TaskSchema.TaskStatusSchema.TaskStatusNotificationSchema.TaskStatusNotificationParamsSchema.TextContentSchema.TextResourceContentsSchema.TitledMultiSelectEnumSchemaSchema.TitledSingleSelectEnumSchemaSchema.ToolSchema.ToolAnnotationsSchema.ToolChoiceSchema.ToolExecutionSchema.ToolListChangedNotificationSchema.ToolResultContentSchema.ToolUseContentSchema.UnsubscribeRequestSchema.UnsubscribeRequestParamsSchema.UntitledMultiSelectEnumSchemaSchema.UntitledSingleSelectEnumSchemaSchema`.split(`.`),Ko={IdJagTokenExchangeResponseSchema:Vr,OAuthClientInformationFullSchema:Kr,OAuthClientInformationSchema:Gr,OAuthClientMetadataSchema:Wr,OAuthClientRegistrationErrorSchema:qr,OAuthErrorResponseSchema:Hr,OAuthMetadataSchema:Lr,OAuthProtectedResourceMetadataSchema:Ir,OAuthTokenRevocationRequestSchema:Jr,OAuthTokensSchema:Br,OpenIdProviderDiscoveryMetadataSchema:zr,OpenIdProviderMetadataSchema:Rr},qo={},Jo={};function Yo(e,t){let n=e.slice(0,-6);qo[n]=t,Jo[n]=e=>t.safeParse(e).success}for(let e of Go)Yo(e,Fa[e]);for(let[e,t]of Object.entries(Ko))Yo(e,t);Object.freeze(qo);var Xo=Object.freeze(Jo);function Zo(e){switch(e){case`initialize`:case`notifications/initialized`:return ka(void 0);case`server/discover`:return ka(Oa);default:return}}var Qo=[Me,Ne,Fe,Le],$o=[`inputResponses`,`requestState`];function es(e,t){let n=e.params;if(!as(n))return{message:e,lifted:{}};let r=n._meta,i=as(r)?Qo.filter(e=>e in r):[],a=t===`request`?$o.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&as(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function ts(e,t){let n=e.validateResult(t,void 0);if(n.ok||n.reason!==`not-in-era`)return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function ns(e){return()=>e}var rs=ns(void 0),is=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Ae,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new Y(J.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Y(J.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Ra(e)||za(e)?this._onresponse(e):Ia(e)?this._onrequest(e,t):La(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new Y(J.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=es(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=Aa(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(Ma(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=es(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=Aa(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(X.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(ja(n.method)&&!i.hasRequestMethod(n.method)&&!(Na(n.method)&&this._customSchemaRequestMethods.has(n.method))){o(X.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(X.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(X.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:cs(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?rs:ns(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),uo(t))return u(e,t,n);let i=ts(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(X.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:X.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Ra(e)?n(e):n(Z.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(uo(t))return Na(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=ts(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return ka(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=Zo(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(ja(t)&&!e.hasRequestMethod(t))throw new Y(J.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof Y?e:new Y(J.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof Y?e:new Y(J.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(ms(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;_o(n,o).then(e=>{e.success?d(e.data):f(new Y(J.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new Y(J.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new Y(J.NotConnected,`Not connected`);if(Ma(t.method)&&!e.hasNotificationMethod(t.method))throw new Y(J.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!ja(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new Z(X.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await _o(t.params,{...r.params});if(!a.success)throw new Z(X.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!Ma(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new Z(X.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))});return}if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await _o(t.params,{...r.params});if(!i.success)throw new Z(X.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function as(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function os(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=as(a)&&as(i)?{...a,...i}:i}return n}function ss(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cs(e){let t={},n=[];if(!ss(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!ss(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function ls(e){throw new Y(J.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}function us(e,t,n,r,i){return{sessionId:i,mcpReq:{id:e,method:t,_meta:n?._meta,requestState:ns(void 0),signal:r,send:(()=>ls(`send`)),notify:()=>ls(`notify`)}}}async function ds(e,t,n,r,i){if(!ss(r)||typeof r.method!=`string`)throw new Y(J.InvalidResult,`Invalid input request '${n}': each inputRequests entry must be an embedded request object with a method`,{key:n});let a=r.method;if(!t.hasInputRequestMethod(a))throw new Y(J.InvalidResult,`Invalid input request '${n}': '${a}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:n,method:a});let o=e.getRequestHandler(a);if(o===void 0)throw new Y(J.CapabilityNotSupported,`Cannot fulfil input request '${n}': no handler is registered for '${a}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:n,method:a});let s=ss(r.params)?r.params:void 0;return await o({jsonrpc:`2.0`,id:n,method:a,...s!==void 0&&{params:s}},e.buildContext(us(n,a,s,i,e.sessionId)))}function fs(e,t){return{...e?.signal!==void 0&&{signal:e.signal},...e?.onprogress!==void 0&&{onprogress:e.onprogress},...e?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:e.resetTimeoutOnProgress},...e?.headers!==void 0&&{headers:e.headers},...t.timeout!==void 0&&{timeout:t.timeout},...t.maxTotalTimeout!==void 0&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0}}function ps(e,t,n,r){let{codec:i,request:a,options:o,flowStartedAt:s}=r,c={inputRequests:n.inputRequests,...n.requestState!==void 0&&{requestState:n.requestState}},l={dispatchInputRequest:(t,n,r)=>ds(e,i,t,n,r),retry:(e,t)=>r.retry(e,fs(o,t))};return Wo({config:t,method:a.method,originalParams:a.params,firstPayload:c,flowStartedAt:s,signal:o?.signal,requestOptions:{...o?.timeout!==void 0&&{timeout:o.timeout},...o?.maxTotalTimeout!==void 0&&{maxTotalTimeout:o.maxTotalTimeout},...o?.onprogress!==void 0&&{onprogress:o.onprogress}},hooks:l})}function ms(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var hs=Se(I((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))(),1);function gs(e){if(e)try{return hs.parse(e).type}catch{let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return t===``||e.slice(t.length).includes(`,`)?void 0:t}}function _s(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function vs(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{..._s(t.headers),..._s(r.headers)}:t.headers}):e}var ys=new Set([301,302,303,307,308]),bs=5;function xs(e,t){return e.protocol===t.protocol&&e.host===t.host||e.protocol===`http:`&&t.protocol===`https:`&&e.hostname===t.hostname&&!e.port&&!t.port}function Ss(e,t){let n=ys.has(t.status)?t.headers?.get(`location`):void 0;if(n)try{return new URL(n,e)}catch{return}}var Cs=new WeakSet;function ws(e){let t=(t,n)=>e(t,n);return Cs.add(t),t}function Ts(e){return Cs.has(e)?e:async(t,n)=>{if(n?.redirect===`error`||n?.redirect===`manual`)return e(t,n);let r=(n?.method??`GET`).toUpperCase(),i=t;for(let t=0;;t++){let a=await e(i,{...n,redirect:`manual`}),o=Ss(i,a);if(!o||t===bs)return a;let s=new URL(i),c=r===`GET`||a.status===307||a.status===308,l=!(o.username||o.password)||o.username===s.username&&o.password===s.password;if(!c||!l||!xs(s,o))return a;await a.text?.().catch(()=>{}),i=o}}}function Es(e,t){if(t.type===`opaqueredirect`)return`Redirect not followed: this runtime does not expose where it points`;let n=Ss(t.url||e,t);if(n)return n.username=n.password=n.search=n.hash=``,n.protocol===`http:`&&new URL(t.url||e).protocol===`https:`?(n.protocol=`https:`,`Redirect from https to plain http not followed; try ${n.href} as the endpoint`):`Redirect to ${n.href} not followed; use that URL as the endpoint if it is the intended server`}function Ds(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r1?t[a.href]=e:(a.hash=``,r===``?n=a:Ps(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(Ms[i])continue;let a=`${r}/${Os(i)}`,o=e[i];if(Array.isArray(o)){if(As[i]){let e=o.length;for(let r=0;r%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Vs=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Hs=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Us=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Ws=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Gs=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Ks=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},qs=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Js=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Ys=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Xs(e){return e.test.bind(e)}var Zs={date:$s,time:ec.bind(void 0,!1),"date-time":nc,duration:Ys,uri:ac,"uri-reference":Xs(zs),"uri-template":Xs(Bs),url:Xs(Vs),email:Ks,hostname:Xs(Rs),ipv4:Xs(qs),ipv6:Xs(Js),regex:sc,uuid:Xs(Hs),"json-pointer":Xs(Us),"json-pointer-uri-fragment":Xs(Ws),"relative-json-pointer":Xs(Gs)};function Qs(e){return e%4==0&&(e%100!=0||e%400==0)}function $s(e){let t=e.match(Fs);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&Qs(n)?29:Is[r])}function ec(e,t){let n=t.match(Ls);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var tc=/t|\s/i;function nc(e){let t=e.split(tc);return t.length==2&&$s(t[0])&&ec(!0,t[1])}var rc=/\/|:/,ic=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function ac(e){return rc.test(e)&&ic.test(e)}var oc=/[^\\]\\Z/;function sc(e){if(oc.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function cc(e){let t=0,n=e.length,r=0,i;for(;r=55296&&i<=56319&&rDs(e,t))||I.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`}):g.some(t=>e===t)||I.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`})),v!==void 0){let t=`${s}/not`;Q(e,v,n,r,i,a,o,t).valid&&I.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let be=[];if(y!==void 0){let t=`${s}/anyOf`,l=I.length,u=!1;for(let s=0;s{let u=Object.create(c),d=Q(e,s,n,r,i,p===!0?a:null,o,`${t}/${l}`,u);return I.push(...d.errors),d.valid&&be.push(u),d.valid}).length;u===1?I.length=l:I.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((u===`object`||u===`array`)&&Object.assign(c,...be),S!==void 0){let t=`${s}/if`;if(Q(e,S,n,r,i,a,o,t,c).valid){if(C!==void 0){let l=Q(e,C,n,r,i,a,o,`${s}/then`,c);l.valid||I.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(w!==void 0){let l=Q(e,w,n,r,i,a,o,`${s}/else`,c);l.valid||I.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(u===`object`){if(_!==void 0)for(let t of _)t in e||I.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(te!==void 0&&t.lengthk&&I.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${k} properties.`}),ne!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${Os(s)}`,c=Q(s,ne,n,r,i,a,e,t);c.valid||I.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(re!==void 0){let t=`${s}/dependantRequired`;for(let n in re)if(n in e){let r=re[n];for(let i of r)i in e||I.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(ie!==void 0)for(let t in ie){let l=`${s}/dependentSchemas`;if(t in e){let s=Q(e,ie[t],n,r,i,a,o,`${l}/${Os(t)}`,c);s.valid||I.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(ae!==void 0){let t=`${s}/dependencies`;for(let s in ae)if(s in e){let c=ae[s];if(Array.isArray(c))for(let n of c)n in e||I.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=Q(e,c,n,r,i,a,o,`${t}/${Os(s)}`);l.valid||I.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(E!==void 0){let t=`${s}/properties`;for(let s in E){if(!(s in e))continue;let d=`${o}/${Os(s)}`,f=Q(e[s],E[s],n,r,i,a,d,`${t}/${Os(s)}`);if(f.valid)c[s]=l[s]=!0;else if(u=i,I.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),u)break}}if(!u&&ee!==void 0){let t=`${s}/patternProperties`;for(let s in ee){let d=new RegExp(s,`u`),f=ee[s];for(let p in e){if(!d.test(p))continue;let m=`${o}/${Os(p)}`,h=Q(e[p],f,n,r,i,a,m,`${t}/${Os(s)}`);h.valid?c[p]=l[p]=!0:(u=i,I.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...h.errors))}}}if(!u&&D!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let d=`${o}/${Os(s)}`,f=Q(e[s],D,n,r,i,a,d,t);f.valid?c[s]=!0:(u=i,I.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}else if(!u&&O!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${Os(s)}`,u=Q(e[s],O,n,r,i,a,l,t);u.valid?c[s]=!0:I.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(u===`array`){fe!==void 0&&e.length>fe&&I.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${fe}).`}),de!==void 0&&e.length=(j||0)&&(I.length=u),j===void 0&&ue===void 0&&d===0?I.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):j!==void 0&&due&&I.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${ue} items matching schema. ${d} items were found.`})}}if(!u&&ce!==void 0){let u=`${s}/unevaluatedItems`;for(;l=M||e>M)&&I.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${he?`or equal to `:``} ${M}.`})):(me!==void 0&&eM&&I.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${M}.`}),N!==void 0&&e<=N&&I.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${N}.`}),he!==void 0&&e>=he&&I.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${he}.`})),P!==void 0){let t=e%P;Math.abs(0-t)>=1.1920929e-7&&Math.abs(P-t)>=1.1920929e-7&&I.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${P}.`})}}else if(u===`string`){let t=F===void 0&&ge===void 0?0:cc(e);F!==void 0&&tge&&I.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${ge}).`}),_e!==void 0&&!new RegExp(_e,`u`).test(e)&&I.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),T!==void 0&&Zs[T]&&!Zs[T](e)&&I.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${T}".`})}return{valid:I.length===0,errors:I}}var lc=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=Ps(e)}validate(e){return Q(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),Ps(e,this.lookup)}},uc=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=Oe(e,`pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.`);return t===`draft-7`?`7`:t}getValidator(e){let t=new lc(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let n=t.validate(e);return n.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:n.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join(`; `)}}}},dc=globalThis.crypto;async function fc(e){return(await dc).getRandomValues(new Uint8Array(e))}async function pc(e){let t=``;for(;t.length128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await mc(e);return{code_verifier:t,code_challenge:await hc(t)}}var _c=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},vc=10,yc=13,bc=32;function xc(e){}function Sc(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=xc,onError:n=xc,onRetry:r=xc,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(` `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new _c(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(` `,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(` diff --git a/internal/ui/dist/assets/new-dashboard-D58ui2mw.js b/internal/ui/dist/assets/new-dashboard-nl-y_vRO.js similarity index 86% rename from internal/ui/dist/assets/new-dashboard-D58ui2mw.js rename to internal/ui/dist/assets/new-dashboard-nl-y_vRO.js index 2d4ddf577..fec7be77f 100644 --- a/internal/ui/dist/assets/new-dashboard-D58ui2mw.js +++ b/internal/ui/dist/assets/new-dashboard-nl-y_vRO.js @@ -1 +1 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,T as i,w as a}from"./brand-D6fP-cLS.js";import{f as o,p as s}from"./search-D_K9J6yO.js";import{s as c}from"./auth-DWqIkMZS.js";import{T as l}from"./useQuery-BLTYSIvG.js";import{t as u}from"./page-1Rod7OFH.js";import{t as d}from"./discard-NZfxCIcK.js";var f=n(e(),1),p=t();function m({onClose:e,onCreated:t}){let n=l(),[m,h]=(0,f.useState)(``),[g,_]=(0,f.useState)({q:``,tab:`query`,range:`1h`}),[v,y]=(0,f.useState)(!1),b=m.trim(),x=d(b!==``||v,e,`this dashboard`);return(0,p.jsxs)(r,{opened:!0,onClose:x.request,closeOnEscape:!1,title:`New dashboard`,size:`min(1280px, 100vw - 32px)`,onKeyDown:x.onKeyDown,children:[x.prompt,(0,p.jsxs)(i,{gap:0,children:[(0,p.jsx)(a,{label:`Dashboard name`,px:`lg`,value:m,onChange:e=>h(e.currentTarget.value),"data-autofocus":!0,required:!0}),(0,p.jsx)(u,{search:g,onSearch:_,context:{spec:{version:1,name:b||`New dashboard`,time:{range:g.range},panels:[]},vars:{},onDirtyChange:y,cancel:x.request,save:{label:`Create dashboard`,run:async e=>{if(!b)throw Error(`Name the dashboard first.`);let r=g.from&&g.to?{from:g.from,to:g.to}:{range:g.range};try{let i=await o({version:1,name:b,time:r,panels:[{...e,id:`panel`}]});n.invalidateQueries({queryKey:s}),t(i.id)}catch(e){throw e instanceof c&&e.problems.length>0?Error(e.problems.map(e=>e.message).join(` `)):e}}}}})]})]})}export{m as NewDashboard}; \ No newline at end of file +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,T as i,w as a}from"./brand-D6fP-cLS.js";import{f as o,p as s}from"./search-P7VEnlsD.js";import{s as c}from"./auth-DcVParCH.js";import{T as l}from"./useQuery-BLTYSIvG.js";import{t as u}from"./page-DSor7wHc.js";import{t as d}from"./discard-NZfxCIcK.js";var f=n(e(),1),p=t();function m({onClose:e,onCreated:t}){let n=l(),[m,h]=(0,f.useState)(``),[g,_]=(0,f.useState)({q:``,tab:`query`,range:`1h`}),[v,y]=(0,f.useState)(!1),b=m.trim(),x=d(b!==``||v,e,`this dashboard`);return(0,p.jsxs)(r,{opened:!0,onClose:x.request,closeOnEscape:!1,title:`New dashboard`,size:`min(1280px, 100vw - 32px)`,onKeyDown:x.onKeyDown,children:[x.prompt,(0,p.jsxs)(i,{gap:0,children:[(0,p.jsx)(a,{label:`Dashboard name`,px:`lg`,value:m,onChange:e=>h(e.currentTarget.value),"data-autofocus":!0,required:!0}),(0,p.jsx)(u,{search:g,onSearch:_,context:{spec:{version:1,name:b||`New dashboard`,time:{range:g.range},panels:[]},vars:{},onDirtyChange:y,cancel:x.request,save:{label:`Create dashboard`,run:async e=>{if(!b)throw Error(`Name the dashboard first.`);let r=g.from&&g.to?{from:g.from,to:g.to}:{range:g.range};try{let i=await o({version:1,name:b,time:r,panels:[{...e,id:`panel`}]});n.invalidateQueries({queryKey:s}),t(i.id)}catch(e){throw e instanceof c&&e.problems.length>0?Error(e.problems.map(e=>e.message).join(` `)):e}}}}})]})]})}export{m as NewDashboard}; \ No newline at end of file diff --git a/internal/ui/dist/assets/page-BABqeqdg.js b/internal/ui/dist/assets/page-DQgl1M0H.js similarity index 91% rename from internal/ui/dist/assets/page-BABqeqdg.js rename to internal/ui/dist/assets/page-DQgl1M0H.js index 537585c60..7a25a5147 100644 --- a/internal/ui/dist/assets/page-BABqeqdg.js +++ b/internal/ui/dist/assets/page-DQgl1M0H.js @@ -1,6 +1,6 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/panel-editor-BVRFoShZ.js","assets/useRouter-ByJ6_rwb.js","assets/brand-D6fP-cLS.js","assets/search-D_K9J6yO.js","assets/noop-mXPS5vjY.js","assets/format-BZjbsxwM.js","assets/auth-DWqIkMZS.js","assets/useNavigate-B1zgPEUp.js","assets/useQuery-BLTYSIvG.js","assets/save-dialog-Chbkq2Xp.js","assets/toolbar-DV46cPGs.js","assets/theme-DXTVNXHm.js","assets/CopyButton-BIdC6qm1.js","assets/Table-D4ZwUno3.js","assets/live-data-meta-CUyw2snU.js","assets/lib-BLIvzI-_.js","assets/index-C1Pd14SU.js","assets/preload-helper-DJZNfKNH.js","assets/lazyRouteComponent-DiWTNBZT.js","assets/search-CDra9nG2.js","assets/index-CzwgFH1g.css","assets/loading-skeleton-D1hXpfUI.js","assets/page-1Rod7OFH.js","assets/NumberInput-CixyOph4.js","assets/discard-NZfxCIcK.js","assets/new-dashboard-D58ui2mw.js"])))=>i.map(i=>d[i]); -import{a as e,i as t,r as n,s as r}from"./useRouter-ByJ6_rwb.js";import{$ as i,Cn as a,Ct as o,D as s,Dt as c,E as l,F as u,Ft as d,G as f,K as p,M as m,N as h,Nt as g,O as _,Ot as v,Pt as y,S as b,T as x,Tt as S,Xt as C,Zt as w,a as T,bn as E,dn as D,en as ee,et as O,f as k,g as A,gn as j,in as M,j as N,jt as P,k as F,nn as I,nt as L,pn as R,q as te,r as ne,s as re,tt as ie,w as z}from"./brand-D6fP-cLS.js";import{t as ae}from"./preload-helper-DJZNfKNH.js";import{c as oe}from"./theme-DXTVNXHm.js";import{_ as se,a as ce,c as B,h as le,i as V,l as ue,n as de,o as fe,r as H,s as U,u as pe,v as W,y as G}from"./toolbar-DV46cPGs.js";import{C as K,D as q,N as J,O as me,S as he,T as Y,_ as ge,b as _e,d as ve,f as ye,h as be,n as xe,p as Se,v as Ce,w as we,x as Te,y as Ee}from"./search-D_K9J6yO.js";import{n as De}from"./format-BZjbsxwM.js";import{a as Oe,c as ke,i as Ae,l as je,n as Me,o as Ne,r as Pe,s as Fe,t as Ie}from"./live-data-meta-CUyw2snU.js";import{c as Le,r as Re,s as ze}from"./auth-DWqIkMZS.js";import{T as Be,t as Ve}from"./useQuery-BLTYSIvG.js";import{t as He}from"./useMutation-B1CTivyp.js";import{S as Ue,ct as We,g as Ge,lt as Ke,x as qe}from"./index-C1Pd14SU.js";import{t as Je}from"./loading-skeleton-D1hXpfUI.js";import{t as Ye}from"./dashboard-change-chips-BJ-GZE9U.js";var[Xe,Ze]=j(`Accordion component was not found in the tree`),[Qe,$e]=j(`Accordion.Item component was not found in the tree`),et={root:`m_9bdbb667`,panel:`m_df78851f`,content:`m_4ba554d4`,itemTitle:`m_8fa820a0`,control:`m_4ba585b8`,"control--default":`m_6939a5e9`,"control--contained":`m_4271d21b`,label:`m_df3ffa0f`,chevron:`m_3f35ae96`,icon:`m_9bd771fe`,item:`m_9bd7b098`,"item--default":`m_fe19b709`,"item--contained":`m_1f921b3b`,"item--filled":`m_2cdf939a`,"item--separated":`m_9f59b069`},X=n(),tt=c(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,chevron:o,icon:s,onClick:c,onKeyDown:l,children:u,disabled:f,mod:p,...m}=d(`AccordionControl`,null,e),{value:h}=$e(),g=Ze(),_=g.isItemActive(h),v=typeof g.order==`number`,y=`h${g.order}`,b=(0,X.jsxs)(ie,{...g.getStyles(`control`,{className:n,classNames:t,style:r,styles:i,variant:g.variant}),unstyled:g.unstyled,mod:[`accordion-control`,{active:_,"chevron-position":g.chevronPosition,disabled:f},p],onClick:e=>{c?.(e),g.onChange(h)},type:`button`,disabled:f,"aria-expanded":_,"aria-controls":g.getRegionId(h),id:g.getControlId(h),onKeyDown:J({siblingSelector:`[data-accordion-control]`,parentSelector:`[data-accordion]`,activateOnFocus:!1,loop:g.loop,orientation:`vertical`,onKeyDown:l}),...m,children:[(0,X.jsx)(S,{component:`span`,mod:{rotate:!g.disableChevronRotation&&_,position:g.chevronPosition},...g.getStyles(`chevron`,{classNames:t,styles:i}),children:o||g.chevron}),(0,X.jsx)(`span`,{...g.getStyles(`label`,{classNames:t,styles:i}),children:u}),s&&(0,X.jsx)(S,{component:`span`,mod:{"chevron-position":g.chevronPosition},...g.getStyles(`icon`,{classNames:t,styles:i}),children:s})]});return v?(0,X.jsx)(y,{...g.getStyles(`itemTitle`,{classNames:t,styles:i}),children:b}):b});tt.displayName=`@mantine/core/AccordionControl`,tt.classes=et;var nt=c(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,value:o,mod:s,...c}=d(`AccordionItem`,null,e),l=Ze();return(0,X.jsx)(Qe,{value:{value:o},children:(0,X.jsx)(S,{mod:[{active:l.isItemActive(o)},s],...l.getStyles(`item`,{className:n,classNames:t,styles:i,style:r,variant:l.variant}),...c})})});nt.displayName=`@mantine/core/AccordionItem`,nt.classes=et;var rt=c(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,children:s,keepMounted:c,keepMountedMode:l,...u}=d(`AccordionPanel`,null,e),{value:f}=$e(),p=Ze();return(0,X.jsx)(o,{...p.getStyles(`panel`,{className:n,classNames:t,style:r,styles:i}),expanded:p.isItemActive(f),transitionDuration:p.transitionDuration??200,role:`region`,id:p.getRegionId(f),"aria-labelledby":p.getControlId(f),keepMounted:c??p.keepMounted,keepMountedMode:l??p.keepMountedMode,...u,children:(0,X.jsx)(`div`,{...p.getStyles(`content`,{classNames:t,styles:i}),children:s})})});rt.displayName=`@mantine/core/AccordionPanel`,rt.classes=et;var it={multiple:!1,loop:!0,disableChevronRotation:!1,disableCollapse:!1,chevronPosition:`right`,variant:`default`,chevronSize:`auto`,chevronIconSize:16,keepMountedMode:`activity`},at=w((e,{transitionDuration:t,chevronSize:n,radius:r})=>({root:{"--accordion-transition-duration":t===void 0?void 0:`${t}ms`,"--accordion-chevron-size":n===void 0?void 0:E(n),"--accordion-radius":r===void 0?void 0:D(r)}})),ot=v(e=>{let t=d(`Accordion`,it,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,children:c,multiple:l,value:u,defaultValue:f,onChange:p,id:h,loop:_,transitionDuration:v,disableChevronRotation:y,disableCollapse:b,chevronPosition:x,chevronSize:C,order:w,chevron:T,variant:E,radius:D,chevronIconSize:O,attributes:k,keepMounted:A,keepMountedMode:j,...N}=t,P=M(h),[F,I]=ee({value:u,defaultValue:f,finalValue:l?[]:null,onChange:p}),L=e=>Array.isArray(F)?F.includes(e):e===F,R=e=>{if(!Array.isArray(F)&&b&&e===F)return;let t=Array.isArray(F)?F.includes(e)?F.filter(t=>t!==e):[...F,e]:e===F?null:e;I(t)},te=g({name:`Accordion`,classes:et,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:k,vars:s,varsResolver:at});return(0,X.jsx)(Xe,{value:{isItemActive:L,onChange:R,getControlId:G(`${P}-control`,`Accordion.Item component was rendered with invalid value or without value`),getRegionId:G(`${P}-panel`,`Accordion.Item component was rendered with invalid value or without value`),chevron:T===null?null:T||(0,X.jsx)(m,{size:O}),transitionDuration:v,disableChevronRotation:y,chevronPosition:x,order:w,loop:_,getStyles:te,variant:E,unstyled:o,keepMounted:A,keepMountedMode:j},children:(0,X.jsx)(S,{...te(`root`),id:P,...N,variant:E,"data-accordion":!0,children:c})})});ot.classes=et,ot.varsResolver=at,ot.displayName=`@mantine/core/Accordion`,ot.Item=nt,ot.Panel=rt,ot.Control=tt,ot.Chevron=m;function st(e,t,n,r){if(t===n||r===`before`&&n===t+1||r===`after`&&n===t-1)return e;let i=e.slice(),[a]=i.splice(t,1),o=t{let t=e.lastElementChild;return t?t instanceof HTMLInputElement?t:t.querySelector(`input`):null},lt=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n{let e=i.current;e&&(i.current=null,lt(o.current,e.expectedValue)&&e.container?.querySelector(`[data-mantine-pill-index="${e.index}"]`)?.focus())});let s=(0,Z.useCallback)(e=>{a.current=e},[]);return{getPillProps:e=>{if(n)return{draggable:!0,tabIndex:-1,"data-mantine-pill-index":e,"aria-keyshortcuts":`Alt+ArrowLeft Alt+ArrowRight`,onMouseDown:e=>{e.button===0&&e.stopPropagation()},onDragStart:t=>{t.stopPropagation(),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,String(e)),r.current.draggedIndex=e;let n=t.currentTarget,i=n.getBoundingClientRect(),a=n.cloneNode(!0);a.removeAttribute(`data-dragging`),a.removeAttribute(`data-drag-over`),a.style.position=`fixed`,a.style.top=`-9999px`,a.style.left=`-9999px`,a.style.width=`${i.width}px`,a.style.height=`${i.height}px`,a.style.pointerEvents=`none`,document.body.appendChild(a),t.dataTransfer.setDragImage(a,t.clientX-i.left,t.clientY-i.top),setTimeout(()=>a.parentNode?.removeChild(a),0),requestAnimationFrame(()=>{n.setAttribute(`data-dragging`,`true`)})},onDragOver:t=>{let{draggedIndex:n}=r.current;if(n===null||n===e)return;let i=t.currentTarget,a=i.getBoundingClientRect(),o=t.clientX-a.left,s=(getComputedStyle(i).direction===`rtl`?o>a.width/2:o{let t=e.currentTarget,n=e.relatedTarget;n&&t.contains(n)||(t.removeAttribute(`data-drag-over`),r.current.currentDropTarget===t&&(r.current.currentDropTarget=null))},onDrop:n=>{n.preventDefault(),n.stopPropagation();let i=n.currentTarget,a=i.getAttribute(`data-drag-over`);i.removeAttribute(`data-drag-over`);let{draggedIndex:s}=r.current;if(s!==null&&a&&s!==e){let n=st(o.current,s,e,a);n!==o.current&&t(n)}r.current.draggedIndex=null,r.current.currentDropTarget=null},onDragEnd:e=>{e.currentTarget.removeAttribute(`data-dragging`);let t=r.current.currentDropTarget;t&&t.removeAttribute(`data-drag-over`),r.current.draggedIndex=null,r.current.currentDropTarget=null},onKeyDown:n=>{if(n.key!==`ArrowLeft`&&n.key!==`ArrowRight`)return;let r=n.currentTarget,a=getComputedStyle(r).direction===`rtl`?n.key===`ArrowLeft`:n.key===`ArrowRight`,s=a?e+1:e-1;if(n.altKey){if(s<0||s>=o.current.length)return;n.preventDefault(),n.stopPropagation();let c=a?`after`:`before`,l=st(o.current,e,s,c);if(l===o.current)return;i.current={container:r.parentElement,index:s,expectedValue:l},t(l);return}if(s<0)return;let c=r.parentElement;if(c){if(n.preventDefault(),n.stopPropagation(),s>=o.current.length){ct(c)?.focus();return}c.querySelector(`[data-mantine-pill-index="${s}"]`)?.focus()}}}},getListProps:()=>n?{ref:s}:{},handleInputKeyDown:e=>{if(!n||e.key!==`ArrowLeft`)return;let t=e.currentTarget;if(!(t.value.length===0||t.selectionStart===0&&t.selectionEnd===0))return;let r=a.current;if(!r)return;let i=r.querySelectorAll(`[data-mantine-pill-index]`);i.length!==0&&(e.preventDefault(),i[i.length-1].focus())}}}var Q=(0,Z.createContext)(null),dt={root:`m_7cda1cd6`,"root--default":`m_44da308b`,"root--contrast":`m_e3a01f8`,label:`m_1e0e6180`,remove:`m_ae386778`,group:`m_1dcfd90b`},ft=(0,Z.createContext)(null),pt=w((e,{gap:t},{size:n})=>({group:{"--pg-gap":t===void 0?R(n,`pg-gap`):R(t)}})),mt=c(e=>{let t=d(`PillGroup`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,size:c,disabled:l,attributes:u,...f}=t,p=(0,Z.use)(Q)?.size||c||void 0,m=g({name:`PillGroup`,classes:dt,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:u,vars:s,varsResolver:pt,stylesCtx:{size:p},rootSelector:`group`});return(0,X.jsx)(ft,{value:{size:p,disabled:l},children:(0,X.jsx)(S,{size:p,...m(`group`),...f})})});mt.classes=dt,mt.varsResolver=pt,mt.displayName=`@mantine/core/PillGroup`;var ht={variant:`default`},gt=w((e,{radius:t},{size:n})=>({root:{"--pill-fz":R(n,`pill-fz`),"--pill-height":R(n,`pill-height`),"--pill-radius":t===void 0?void 0:D(t)}})),_t=c(e=>{let t=d(`Pill`,ht,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,variant:c,children:l,withRemoveButton:u,onRemove:f,removeButtonProps:m,radius:h,size:_,disabled:v,mod:y,attributes:b,...x}=t,C=(0,Z.use)(ft),w=(0,Z.use)(Q),T=_||C?.size||void 0,E=w?.variant===`filled`?`contrast`:c||`default`,D=g({name:`Pill`,classes:dt,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:b,vars:s,varsResolver:gt,stylesCtx:{size:T}});return(0,X.jsxs)(S,{component:`span`,variant:E,size:T,...D(`root`,{variant:E}),mod:[{"with-remove":u&&!v,disabled:v||C?.disabled},y],...x,children:[(0,X.jsx)(`span`,{...D(`label`),children:l}),u&&(0,X.jsx)(p,{variant:`transparent`,radius:h,tabIndex:-1,"aria-hidden":!0,unstyled:o,...m,...D(`remove`,{className:m?.className,style:m?.style}),onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m?.onMouseDown?.(e)},onClick:e=>{e.stopPropagation(),f?.(),m?.onClick?.(e)}})]})});_t.classes=dt,_t.varsResolver=gt,_t.displayName=`@mantine/core/Pill`,_t.Group=mt;var vt={field:`m_45c4369d`},yt={type:`visible`},bt=c(e=>{let t=d(`PillsInputField`,yt,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,type:c,disabled:l,id:f,pointer:p,mod:m,attributes:h,ref:_,...v}=t,y=(0,Z.use)(Q),b=(0,Z.use)(u),x=g({name:`PillsInputField`,classes:vt,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,rootSelector:`field`}),C=l||y?.disabled;return(0,X.jsx)(S,{component:`input`,ref:I(_,y?.fieldRef),"data-type":c,disabled:C,mod:[{disabled:C,pointer:p},m],...x(`field`),...v,id:b?.inputId||f,"aria-invalid":y?.hasError,"aria-describedby":b?.describedBy,type:`text`,onMouseDown:e=>!p&&e.stopPropagation()})});bt.classes=vt,bt.displayName=`@mantine/core/PillsInputField`;var xt={size:`sm`},St=c(e=>{let{children:t,onMouseDown:n,onClick:r,size:i,disabled:a,__staticSelector:o,error:s,variant:c,...l}=d([`Input`,`InputWrapper`,`PillsInput`],xt,e),u=(0,Z.useRef)(null);return(0,X.jsx)(Q,{value:{fieldRef:u,size:i,disabled:a,hasError:!!s,variant:c},children:(0,X.jsx)(h,{size:i,error:s,variant:c,component:`div`,"data-no-overflow":!0,onMouseDown:e=>{e.preventDefault(),n?.(e),u.current?.focus()},onClick:e=>{e.preventDefault(),e.currentTarget.closest(`fieldset`)?.disabled||(u.current?.focus(),r?.(e))},...l,multiline:!0,disabled:a,__staticSelector:o||`PillsInput`,withAria:!1,children:t})})});St.displayName=`@mantine/core/PillsInput`,St.classes=h.classes,St.Field=bt;function Ct(e){return typeof e==`string`?e.trim().toLowerCase():e}function wt({data:e,value:t}){let n=t.map(Ct);return e.reduce((e,t)=>(Oe(t)?e.push({group:t.group,items:t.items.filter(e=>n.indexOf(Ct(e.value))===-1)}):n.indexOf(Ct(t.value))===-1&&e.push(t),e),[])}var Tt={xs:41,sm:50,md:60,lg:72,xl:89},Et={maxValues:1/0,withCheckIcon:!0,checkIconPosition:`left`,hiddenInputValuesDivider:`,`,clearSearchOnChange:!0,openOnFocus:!0,size:`sm`},Dt=v(e=>{let t=d([`Input`,`InputWrapper`,`MultiSelect`],Et,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,size:c,value:l,defaultValue:u,onChange:f,onKeyDown:p,variant:m,data:h,dropdownOpened:_,defaultDropdownOpened:v,onDropdownOpen:b,onDropdownClose:x,selectFirstOptionOnChange:S,selectFirstOptionOnDropdownOpen:C,onOptionSubmit:w,comboboxProps:T,filter:E,limit:D,withScrollArea:O,maxDropdownHeight:k,floatingHeight:A,searchValue:j,defaultSearchValue:N,onSearchChange:F,readOnly:I,disabled:L,onFocus:R,onBlur:te,radius:ne,rightSection:re,rightSectionWidth:ie,rightSectionPointerEvents:z,rightSectionProps:ae,leftSection:oe,leftSectionWidth:ce,leftSectionPointerEvents:B,leftSectionProps:le,inputContainer:V,inputWrapperOrder:ue,withAsterisk:de,labelProps:fe,descriptionProps:H,errorProps:U,successProps:pe,wrapperProps:G,description:K,label:q,error:J,success:me,maxValues:he,searchable:Y,nothingFoundMessage:ge,withCheckIcon:_e,withAlignedLabels:ve,checkIconPosition:ye,hidePickedOptions:be,withErrorStyles:xe,withSuccessStyles:Se,name:Ce,form:we,id:Te,clearable:Ee,clearSectionMode:De,clearButtonProps:Oe,hiddenInputProps:Me,placeholder:Ie,hiddenInputValuesDivider:Le,required:Re,mod:ze,renderOption:Be,renderPill:Ve,onRemove:He,onClear:Ue,onMaxValues:We,scrollAreaProps:Ge,chevronColor:Ke,attributes:qe,clearSearchOnChange:Je,openOnFocus:Ye,loading:Xe,loadingPosition:Ze,withPillsReorder:Qe,...$e}=t,et=M(Te),tt=Pe({id:et,label:q,labelProps:fe,inputWrapperOrder:ue}),nt=je(h),rt=ke(nt),it=(0,Z.useRef)({}),at=Fe({opened:_,defaultOpened:v,onDropdownOpen:()=>{b?.(),C&&at.selectFirstOption()},onDropdownClose:()=>{x?.(),at.resetSelectedOption()}}),{styleProps:ot,rest:{type:st,autoComplete:ct,...lt}}=P($e),[Q,dt]=ee({value:l,defaultValue:u,finalValue:[],onChange:f}),{getPillProps:ft,getListProps:pt,handleInputKeyDown:mt}=ut({value:Q,onChange:dt,enabled:Qe&&!L&&!I}),[ht,gt]=ee({value:j,defaultValue:N,finalValue:``,onChange:F}),vt=e=>{gt(e),at.resetSelectedOption()},yt=g({name:`MultiSelect`,classes:{},props:t,classNames:n,styles:a,unstyled:o,attributes:qe}),{resolvedClassNames:bt,resolvedStyles:xt}=y({props:t,styles:a,classNames:n}),Ct=e=>{p?.(e),!e.defaultPrevented&&(e.key===` `&&!Y&&(e.preventDefault(),at.toggleDropdown()),e.key===`Backspace`&&ht.length===0&&Q.length>0&&!I&&(He?.(Q[Q.length-1]),dt(Q.slice(0,Q.length-1))),mt(e))},Dt=Q.map((e,t)=>{let n=rt[`${e}`]||it.current[`${e}`],r=ft(t);return Ve?(0,X.jsx)(Z.Fragment,{children:Ve({option:n,value:e,onRemove:()=>{dt(Q.filter(t=>e!==t)),He?.(e)},disabled:L,reorderProps:r})},`${e}-${t}`):(0,X.jsx)(_t,{withRemoveButton:!I&&!rt[`${e}`]?.disabled,onRemove:()=>{dt(Q.filter(t=>e!==t)),He?.(e)},unstyled:o,disabled:L,...yt(`pill`),...r,children:n?.label||e},`${e}-${t}`)});(0,Z.useEffect)(()=>{S&&at.selectFirstOption()},[S,ht]),(0,Z.useEffect)(()=>{Q.forEach(e=>{`${e}`in rt&&(it.current[`${e}`]=rt[`${e}`])})},[rt,Q]);let Ot=(0,X.jsx)(Ne.ClearButton,{...Oe,onClear:()=>{Ue?.(),dt([]),vt(``)}}),kt=wt({data:nt,value:Q}),At=Ee&&Q.length>0&&!L&&!I,jt=At?{paddingInlineEnd:Tt[c]??Tt.sm}:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ne,{store:at,classNames:bt,styles:xt,unstyled:o,size:c,readOnly:I,__staticSelector:`MultiSelect`,attributes:qe,floatingHeight:A,onOptionSubmit:e=>{w?.(e),Je&&vt(``),at.updateSelectedOptionIndex(`selected`),Q.includes(rt[`${e}`].value)?(dt(Q.filter(t=>t!==rt[`${e}`].value)),He?.(rt[`${e}`].value)):Q.lengthY?at.openDropdown():at.toggleDropdown(),"data-expanded":at.dropdownOpened||void 0,id:et,required:Re,mod:ze,attributes:qe,children:(0,X.jsxs)(_t.Group,{attributes:qe,disabled:L,unstyled:o,...yt(`pillsList`,{style:jt}),...pt(),children:[Dt,(0,X.jsx)(Ne.EventsTarget,{autoComplete:ct,withExpandedAttribute:!0,children:(0,X.jsx)(St.Field,{...lt,id:et,placeholder:Ie,type:!Y&&!Ie?`hidden`:`visible`,...yt(`inputField`),unstyled:o,onFocus:e=>{R?.(e),Ye&&Y&&at.openDropdown()},onBlur:e=>{te?.(e),at.closeDropdown(),vt(``)},onKeyDown:Ct,value:ht,onChange:e=>{if(W(e)){if(!I){let t=se(rt,e.currentTarget.value);t&&!Q.includes(t.value)&&Q.lengthe*40+(e-1)*12,jt={s:3,m:6,l:10},Mt={stat:4},Nt=e=>Math.max(Mt[e.viz]??0,jt[e.height??(e.viz===`service_map`?`l`:e.viz===`stat`?`s`:`m`)]);function Pt(){return(0,X.jsxs)(x,{gap:`md`,"data-dashboard-skeleton":!0,children:[(0,X.jsxs)(x,{gap:`sm`,"data-dashboard-header-skeleton":!0,children:[(0,X.jsxs)(f,{justify:`space-between`,children:[(0,X.jsx)(l,{height:28,width:`32%`}),(0,X.jsx)(l,{height:28,width:28})]}),(0,X.jsx)(l,{height:12,width:`52%`}),(0,X.jsxs)(f,{justify:`space-between`,children:[(0,X.jsx)(l,{height:32,width:180}),(0,X.jsx)(l,{height:32,width:120})]})]}),(0,X.jsx)(S,{style:{containerType:`inline-size`},children:(0,X.jsx)(S,{className:`dashboard-loading-grid`,style:{display:`grid`,gridTemplateColumns:`repeat(12, minmax(0, 1fr))`,gap:12},children:[`stat`,`stat`,`stat`,`timeseries`,`table`].map((e,t)=>(0,X.jsxs)(i,{withBorder:!0,p:`md`,className:`dashboard-loading-panel`,"data-skeleton-columns":e===`stat`?4:6,style:{display:`flex`,flexDirection:`column`,minHeight:At(e===`stat`?4:6)},children:[(0,X.jsx)(l,{height:14,width:`44%`,mb:`xl`}),(0,X.jsx)(Je,{viz:e,rows:4})]},t))})})]})}function Ft(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function It(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function Lt(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=Ft(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=It(r,u,s[0]),f=It(i,l,s[1])),a?(p=Math.round(a.top),m=Math.round(a.left)):o?(p=Math.round(o.top),m=Math.round(o.left)):(p=Math.round((l+s[1])*n+c[1]),m=Math.round((u+s[0])*t+c[0])),!a&&!o){if(Number.isFinite(r)){let e=Math.round((u+s[0])*(t+r)+c[0])-m-d;e!==s[0]&&(d+=e-s[0])}if(Number.isFinite(i)){let e=Math.round((l+s[1])*(n+i)+c[1])-p-f;e!==s[1]&&(f+=e-s[1])}}return{top:p,left:m,width:d,height:f}}function Rt(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=Ft(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=Vt(d,0,s-r),f=Vt(f,0,l-i),{x:d,y:f}}function zt(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=Ft(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function Bt(e,t,n){let{margin:r,rowHeight:i}=e,a=Ft(e);return{w:Math.max(1,Math.round((t+r[0])/(a+r[0]))),h:Math.max(1,Math.round((n+r[1])/(i+r[1])))}}function Vt(e,t,n){return Math.max(Math.min(e,n),t)}function Ht(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function Ut(e,t){for(let n=0;nHt(e,t))}function Gt(e,t){return t===`horizontal`?qt(e):t===`vertical`||t===`wrap`?Kt(e):[...e]}function Kt(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function qt(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function Jt(e){let t=0;for(let n=0;nt&&(t=e)}}return t}function Yt(e,t){for(let n=0;ne.static===!0)}function Zt(e){return{i:e.i,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,constraints:e.constraints,isBounded:e.isBounded}}function Qt(e){let t=Array(e.length);for(let n=0;nt.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),i.y===1/0&&(i.y=Jt(n)),!i.static)n.push(i);else for(;Ut(n,i);)i.y++}}return e}function nn(e,t,n,r,i,a,o,s,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return[...e];let l=t.x,u=t.y;typeof n==`number`&&(t.x=n),typeof r==`number`&&(t.y=r),t.moved=!0;let d=Gt(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=Wt(d,t),p=f.length>0;if(p&&c)return Qt(e);if(p&&a)return t.x=l,t.y=u,t.moved=!1,e;let m=[...e];for(let e=0;et.y,d=l!==void 0&&t.x+t.w>l.x;if(!l)return nn(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return nn(e,n,void 0,n.y+1,r,c,i);if(u&&i===null){let r=n.y;return t.y=r,n.y=r+t.h,[...e]}if(d&&o)return nn(e,t,n.x,void 0,r,c,i)}let l=o?n.x+1:void 0,u=s?n.y+1:void 0;return l===void 0&&u===void 0?[...e]:nn(e,n,l,u,r,c,i)}function an(e,t,n){return Math.max(t,Math.min(n,e))}var on=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:an(t,0,Math.max(0,r-e.w)),y:an(n,0,Math.max(0,i-e.h))}},constrainSize(e,t,n,r,{cols:i,maxRows:a}){let o=r===`w`||r===`nw`||r===`sw`?e.x+e.w:i-e.x,s=r===`n`||r===`nw`||r===`ne`?e.y+e.h:a-e.y;return{w:an(t,1,Math.max(1,o)),h:an(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:an(t,e.minW??1,e.maxW??1/0),h:an(n,e.minH??1,e.maxH??1/0)}}}];function sn(e,t,n,r,i){let a={x:n,y:r};for(let n of e)n.constrainPosition&&(a=n.constrainPosition(t,a.x,a.y,i));if(t.constraints)for(let e of t.constraints)e.constrainPosition&&(a=e.constrainPosition(t,a.x,a.y,i));return a}function cn(e,t,n,r,i,a){let o={w:n,h:r};for(let n of e)n.constrainSize&&(o=n.constrainSize(t,o.w,o.h,i,a));if(t.constraints)for(let e of t.constraints)e.constrainSize&&(o=e.constrainSize(t,o.w,o.h,i,a));return o}function ln({top:e,left:t,width:n,height:r}){let i=`translate(${t}px,${e}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${n}px`,height:`${r}px`,position:`absolute`}}function un({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function dn(e){return e*100+`%`}function fn(e,t,n,r){return e+n>r?t:n}function pn(e,t,n){return e<0?t:n}function mn(e){return Math.max(0,e)}function hn(e){return Math.max(0,e)}var gn=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:pn(o,e.height,i),top:hn(o)}},_n=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:fn(e.left,e.width,o,n),left:mn(i)}},vn=(e,t,n)=>{let{top:r,height:i,width:a}=t,o=e.left+e.width-a;return o<0?{height:i,width:e.left+e.width,top:hn(r),left:0}:{height:i,width:a,top:hn(r),left:o}},yn=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:pn(r,e.height,a),top:hn(r)}},bn={n:gn,ne:(e,t,n)=>gn(e,_n(e,t,n)),e:_n,se:(e,t,n)=>yn(e,_n(e,t,n)),s:yn,sw:(e,t,n)=>yn(e,vn(e,t)),w:vn,nw:(e,t,n)=>gn(e,vn(e,t))};function xn(e,t,n,r){let i=bn[e];return i?i(t,{...t,...n},r):n}var Sn={type:`transform`,scale:1,calcStyle(e){return ln(e)}},Cn={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},wn={enabled:!0,bounded:!1,threshold:3},Tn={enabled:!0,handles:[`se`]},En={enabled:!1,defaultItem:{w:1,h:1},touchEnabled:!0,touchDragSource:`[data-rgl-draggable]`};function Dn(e,t,n,r,i){let a=r===`x`?`w`:`h`;t[r]+=1;let o=e.findIndex(e=>e.i===t.i),s=i??Xt(e).length>0;for(let i=o+1;it.y+t.h)break;Ht(t,o)&&Dn(e,o,n+t[a],r,s)}}t[r]=n}function On(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0),t.y=Math.min(r,t.y);t.y>0&&!Ut(e,t);)t.y--;let i;for(;(i=Ut(e,t))!==void 0;)Dn(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function kn(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!Ut(e,t);)t.x--;let i;for(;(i=Ut(e,t))!==void 0;)if(Dn(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!Ut(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var An={type:`vertical`,allowOverlap:!1,compact(e,t){let n=Xt(e),r=Jt(n),i=Kt(e),a=Array(e.length);for(let t=0;te[t]-e[n])}function Rn(e,t){let n=Ln(e),r=n[0];if(r===void 0)throw Error(`No breakpoints defined`);for(let i=1;ie[a]&&(r=a)}return r}function zn(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function Bn(e,t,n,r,i,a){let o=e[n];if(o)return Qt(o);let s=e[r],c=Ln(t),l=c.slice(c.indexOf(n));for(let t=0;t{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n[`fast-equals`]={}))})(e,(function(e){function t(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function n(e){return function(t,n,r,i){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r,i);var a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);var s=e(t,n,r,i);return i.delete(t),i.delete(n),s}}function r(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e){return e.constructor===Object||e.constructor==null}function a(e){return typeof e.then==`function`}function o(e,t){return e===t||e!==e&&t!==t}var s=Object.prototype.toString;function c(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,c=e.areObjectsEqual,l=e.areRegExpsEqual,u=e.areSetsEqual,d=e.createIsNestedEqual,f=d(p);function p(e,d,p){if(e===d)return!0;if(!e||!d||typeof e!=`object`||typeof d!=`object`)return e!==e&&d!==d;if(i(e)&&i(d))return c(e,d,f,p);var m=Array.isArray(e),h=Array.isArray(d);if(m||h)return m===h&&t(e,d,f,p);var g=s.call(e);return g===s.call(d)?g===`[object Date]`?n(e,d,f,p):g===`[object RegExp]`?l(e,d,f,p):g===`[object Map]`?r(e,d,f,p):g===`[object Set]`?u(e,d,f,p):g===`[object Object]`||g===`[object Arguments]`?a(e)||a(d)?!1:c(e,d,f,p):g===`[object Boolean]`||g===`[object Number]`||g===`[object String]`?o(e.valueOf(),d.valueOf()):!1:!1}return p}function l(e,t,n,r){var i=e.length;if(t.length!==i)return!1;for(;i-->0;)if(!n(e[i],t[i],i,i,e,t,r))return!1;return!0}var u=n(l);function d(e,t){return o(e.valueOf(),t.valueOf())}function f(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={},o=0;return e.forEach(function(s,c){if(i){var l=!1,u=0;t.forEach(function(i,d){!l&&!a[u]&&(l=n(c,d,o,u,e,t,r)&&n(s,i,c,d,e,t,r))&&(a[u]=!0),u++}),o++,i=l}}),i}var p=n(f),m=`_owner`,h=Object.prototype.hasOwnProperty;function g(e,t,n,r){var i=Object.keys(e),a=i.length;if(Object.keys(t).length!==a)return!1;for(var o;a-->0;){if(o=i[a],o===m){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!h.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var _=n(g);function v(e,t){return e.source===t.source&&e.flags===t.flags}function y(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={};return e.forEach(function(o,s){if(i){var c=!1,l=0;t.forEach(function(i,u){!c&&!a[l]&&(c=n(o,i,s,u,e,t,r))&&(a[l]=!0),l++}),i=c}}),i}var b=n(y),x=Object.freeze({areArraysEqual:l,areDatesEqual:d,areMapsEqual:f,areObjectsEqual:g,areRegExpsEqual:v,areSetsEqual:y,createIsNestedEqual:t}),S=Object.freeze({areArraysEqual:u,areDatesEqual:d,areMapsEqual:p,areObjectsEqual:_,areRegExpsEqual:v,areSetsEqual:b,createIsNestedEqual:t}),C=c(x);function w(e,t){return C(e,t,void 0)}var T=c(r(x,{createIsNestedEqual:function(){return o}}));function E(e,t){return T(e,t,void 0)}var D=c(S);function ee(e,t){return D(e,t,new WeakMap)}var O=c(r(S,{createIsNestedEqual:function(){return o}}));function k(e,t){return O(e,t,new WeakMap)}function A(e){return c(r(x,e(x)))}function j(e){var t=c(r(S,e(S)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=ee,e.circularShallowEqual=k,e.createCustomCircularEqual=j,e.createCustomEqual=A,e.deepEqual=w,e.sameValueZeroEqual=o,e.shallowEqual=E,Object.defineProperty(e,"__esModule",{value:!0})}))})),Un=e(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Wn=e(((e,t)=>{var n=Un();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Gn=e(((e,t)=>{t.exports=Wn()()})),$=r(Gn(),1);function Kn(e,t){for(let n=0,r=e.length;n`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;nt===e.identifier)||e.changedTouches&&Kn(e.changedTouches,e=>t===e.identifier)}function gr(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function _r(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function vr(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??_r();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;} +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/panel-editor-DrACmBUu.js","assets/useRouter-ByJ6_rwb.js","assets/brand-D6fP-cLS.js","assets/search-P7VEnlsD.js","assets/noop-mXPS5vjY.js","assets/format-BZjbsxwM.js","assets/auth-DcVParCH.js","assets/useNavigate-B1zgPEUp.js","assets/useQuery-BLTYSIvG.js","assets/save-dialog-DpwJ9nWF.js","assets/toolbar-CLcpDIVT.js","assets/theme-DXTVNXHm.js","assets/CopyButton-BIdC6qm1.js","assets/Table-D4ZwUno3.js","assets/live-data-meta-CkxM9djV.js","assets/lib-BLIvzI-_.js","assets/index-D7FG-NN3.js","assets/preload-helper-DJZNfKNH.js","assets/lazyRouteComponent-DiWTNBZT.js","assets/search-pvW8SUhM.js","assets/index-CzwgFH1g.css","assets/loading-skeleton-D1hXpfUI.js","assets/page-DSor7wHc.js","assets/NumberInput-CixyOph4.js","assets/discard-NZfxCIcK.js","assets/new-dashboard-nl-y_vRO.js"])))=>i.map(i=>d[i]); +import{a as e,i as t,r as n,s as r}from"./useRouter-ByJ6_rwb.js";import{$ as i,Cn as a,Ct as o,D as s,Dt as c,E as l,F as u,Ft as d,G as f,K as p,M as m,N as h,Nt as g,O as _,Ot as v,Pt as y,S as b,T as x,Tt as S,Xt as C,Zt as w,a as T,bn as E,dn as D,en as ee,et as O,f as k,g as A,gn as j,in as M,j as N,jt as P,k as F,nn as I,nt as L,pn as R,q as te,r as ne,s as re,tt as ie,w as z}from"./brand-D6fP-cLS.js";import{t as ae}from"./preload-helper-DJZNfKNH.js";import{c as oe}from"./theme-DXTVNXHm.js";import{_ as se,a as ce,c as B,h as le,i as V,l as ue,n as de,o as fe,r as H,s as U,u as pe,v as W,y as G}from"./toolbar-CLcpDIVT.js";import{C as K,D as q,N as J,O as me,S as he,T as Y,_ as ge,b as _e,d as ve,f as ye,h as be,n as xe,p as Se,v as Ce,w as we,x as Te,y as Ee}from"./search-P7VEnlsD.js";import{n as De}from"./format-BZjbsxwM.js";import{a as Oe,c as ke,i as Ae,l as je,n as Me,o as Ne,r as Pe,s as Fe,t as Ie}from"./live-data-meta-CkxM9djV.js";import{c as Le,r as Re,s as ze}from"./auth-DcVParCH.js";import{T as Be,t as Ve}from"./useQuery-BLTYSIvG.js";import{t as He}from"./useMutation-Diiy6DUC.js";import{S as Ue,ct as We,g as Ge,lt as Ke,x as qe}from"./index-D7FG-NN3.js";import{t as Je}from"./loading-skeleton-D1hXpfUI.js";import{t as Ye}from"./dashboard-change-chips-BJ-GZE9U.js";var[Xe,Ze]=j(`Accordion component was not found in the tree`),[Qe,$e]=j(`Accordion.Item component was not found in the tree`),et={root:`m_9bdbb667`,panel:`m_df78851f`,content:`m_4ba554d4`,itemTitle:`m_8fa820a0`,control:`m_4ba585b8`,"control--default":`m_6939a5e9`,"control--contained":`m_4271d21b`,label:`m_df3ffa0f`,chevron:`m_3f35ae96`,icon:`m_9bd771fe`,item:`m_9bd7b098`,"item--default":`m_fe19b709`,"item--contained":`m_1f921b3b`,"item--filled":`m_2cdf939a`,"item--separated":`m_9f59b069`},X=n(),tt=c(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,chevron:o,icon:s,onClick:c,onKeyDown:l,children:u,disabled:f,mod:p,...m}=d(`AccordionControl`,null,e),{value:h}=$e(),g=Ze(),_=g.isItemActive(h),v=typeof g.order==`number`,y=`h${g.order}`,b=(0,X.jsxs)(ie,{...g.getStyles(`control`,{className:n,classNames:t,style:r,styles:i,variant:g.variant}),unstyled:g.unstyled,mod:[`accordion-control`,{active:_,"chevron-position":g.chevronPosition,disabled:f},p],onClick:e=>{c?.(e),g.onChange(h)},type:`button`,disabled:f,"aria-expanded":_,"aria-controls":g.getRegionId(h),id:g.getControlId(h),onKeyDown:J({siblingSelector:`[data-accordion-control]`,parentSelector:`[data-accordion]`,activateOnFocus:!1,loop:g.loop,orientation:`vertical`,onKeyDown:l}),...m,children:[(0,X.jsx)(S,{component:`span`,mod:{rotate:!g.disableChevronRotation&&_,position:g.chevronPosition},...g.getStyles(`chevron`,{classNames:t,styles:i}),children:o||g.chevron}),(0,X.jsx)(`span`,{...g.getStyles(`label`,{classNames:t,styles:i}),children:u}),s&&(0,X.jsx)(S,{component:`span`,mod:{"chevron-position":g.chevronPosition},...g.getStyles(`icon`,{classNames:t,styles:i}),children:s})]});return v?(0,X.jsx)(y,{...g.getStyles(`itemTitle`,{classNames:t,styles:i}),children:b}):b});tt.displayName=`@mantine/core/AccordionControl`,tt.classes=et;var nt=c(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,value:o,mod:s,...c}=d(`AccordionItem`,null,e),l=Ze();return(0,X.jsx)(Qe,{value:{value:o},children:(0,X.jsx)(S,{mod:[{active:l.isItemActive(o)},s],...l.getStyles(`item`,{className:n,classNames:t,styles:i,style:r,variant:l.variant}),...c})})});nt.displayName=`@mantine/core/AccordionItem`,nt.classes=et;var rt=c(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,children:s,keepMounted:c,keepMountedMode:l,...u}=d(`AccordionPanel`,null,e),{value:f}=$e(),p=Ze();return(0,X.jsx)(o,{...p.getStyles(`panel`,{className:n,classNames:t,style:r,styles:i}),expanded:p.isItemActive(f),transitionDuration:p.transitionDuration??200,role:`region`,id:p.getRegionId(f),"aria-labelledby":p.getControlId(f),keepMounted:c??p.keepMounted,keepMountedMode:l??p.keepMountedMode,...u,children:(0,X.jsx)(`div`,{...p.getStyles(`content`,{classNames:t,styles:i}),children:s})})});rt.displayName=`@mantine/core/AccordionPanel`,rt.classes=et;var it={multiple:!1,loop:!0,disableChevronRotation:!1,disableCollapse:!1,chevronPosition:`right`,variant:`default`,chevronSize:`auto`,chevronIconSize:16,keepMountedMode:`activity`},at=w((e,{transitionDuration:t,chevronSize:n,radius:r})=>({root:{"--accordion-transition-duration":t===void 0?void 0:`${t}ms`,"--accordion-chevron-size":n===void 0?void 0:E(n),"--accordion-radius":r===void 0?void 0:D(r)}})),ot=v(e=>{let t=d(`Accordion`,it,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,children:c,multiple:l,value:u,defaultValue:f,onChange:p,id:h,loop:_,transitionDuration:v,disableChevronRotation:y,disableCollapse:b,chevronPosition:x,chevronSize:C,order:w,chevron:T,variant:E,radius:D,chevronIconSize:O,attributes:k,keepMounted:A,keepMountedMode:j,...N}=t,P=M(h),[F,I]=ee({value:u,defaultValue:f,finalValue:l?[]:null,onChange:p}),L=e=>Array.isArray(F)?F.includes(e):e===F,R=e=>{if(!Array.isArray(F)&&b&&e===F)return;let t=Array.isArray(F)?F.includes(e)?F.filter(t=>t!==e):[...F,e]:e===F?null:e;I(t)},te=g({name:`Accordion`,classes:et,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:k,vars:s,varsResolver:at});return(0,X.jsx)(Xe,{value:{isItemActive:L,onChange:R,getControlId:G(`${P}-control`,`Accordion.Item component was rendered with invalid value or without value`),getRegionId:G(`${P}-panel`,`Accordion.Item component was rendered with invalid value or without value`),chevron:T===null?null:T||(0,X.jsx)(m,{size:O}),transitionDuration:v,disableChevronRotation:y,chevronPosition:x,order:w,loop:_,getStyles:te,variant:E,unstyled:o,keepMounted:A,keepMountedMode:j},children:(0,X.jsx)(S,{...te(`root`),id:P,...N,variant:E,"data-accordion":!0,children:c})})});ot.classes=et,ot.varsResolver=at,ot.displayName=`@mantine/core/Accordion`,ot.Item=nt,ot.Panel=rt,ot.Control=tt,ot.Chevron=m;function st(e,t,n,r){if(t===n||r===`before`&&n===t+1||r===`after`&&n===t-1)return e;let i=e.slice(),[a]=i.splice(t,1),o=t{let t=e.lastElementChild;return t?t instanceof HTMLInputElement?t:t.querySelector(`input`):null},lt=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n{let e=i.current;e&&(i.current=null,lt(o.current,e.expectedValue)&&e.container?.querySelector(`[data-mantine-pill-index="${e.index}"]`)?.focus())});let s=(0,Z.useCallback)(e=>{a.current=e},[]);return{getPillProps:e=>{if(n)return{draggable:!0,tabIndex:-1,"data-mantine-pill-index":e,"aria-keyshortcuts":`Alt+ArrowLeft Alt+ArrowRight`,onMouseDown:e=>{e.button===0&&e.stopPropagation()},onDragStart:t=>{t.stopPropagation(),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,String(e)),r.current.draggedIndex=e;let n=t.currentTarget,i=n.getBoundingClientRect(),a=n.cloneNode(!0);a.removeAttribute(`data-dragging`),a.removeAttribute(`data-drag-over`),a.style.position=`fixed`,a.style.top=`-9999px`,a.style.left=`-9999px`,a.style.width=`${i.width}px`,a.style.height=`${i.height}px`,a.style.pointerEvents=`none`,document.body.appendChild(a),t.dataTransfer.setDragImage(a,t.clientX-i.left,t.clientY-i.top),setTimeout(()=>a.parentNode?.removeChild(a),0),requestAnimationFrame(()=>{n.setAttribute(`data-dragging`,`true`)})},onDragOver:t=>{let{draggedIndex:n}=r.current;if(n===null||n===e)return;let i=t.currentTarget,a=i.getBoundingClientRect(),o=t.clientX-a.left,s=(getComputedStyle(i).direction===`rtl`?o>a.width/2:o{let t=e.currentTarget,n=e.relatedTarget;n&&t.contains(n)||(t.removeAttribute(`data-drag-over`),r.current.currentDropTarget===t&&(r.current.currentDropTarget=null))},onDrop:n=>{n.preventDefault(),n.stopPropagation();let i=n.currentTarget,a=i.getAttribute(`data-drag-over`);i.removeAttribute(`data-drag-over`);let{draggedIndex:s}=r.current;if(s!==null&&a&&s!==e){let n=st(o.current,s,e,a);n!==o.current&&t(n)}r.current.draggedIndex=null,r.current.currentDropTarget=null},onDragEnd:e=>{e.currentTarget.removeAttribute(`data-dragging`);let t=r.current.currentDropTarget;t&&t.removeAttribute(`data-drag-over`),r.current.draggedIndex=null,r.current.currentDropTarget=null},onKeyDown:n=>{if(n.key!==`ArrowLeft`&&n.key!==`ArrowRight`)return;let r=n.currentTarget,a=getComputedStyle(r).direction===`rtl`?n.key===`ArrowLeft`:n.key===`ArrowRight`,s=a?e+1:e-1;if(n.altKey){if(s<0||s>=o.current.length)return;n.preventDefault(),n.stopPropagation();let c=a?`after`:`before`,l=st(o.current,e,s,c);if(l===o.current)return;i.current={container:r.parentElement,index:s,expectedValue:l},t(l);return}if(s<0)return;let c=r.parentElement;if(c){if(n.preventDefault(),n.stopPropagation(),s>=o.current.length){ct(c)?.focus();return}c.querySelector(`[data-mantine-pill-index="${s}"]`)?.focus()}}}},getListProps:()=>n?{ref:s}:{},handleInputKeyDown:e=>{if(!n||e.key!==`ArrowLeft`)return;let t=e.currentTarget;if(!(t.value.length===0||t.selectionStart===0&&t.selectionEnd===0))return;let r=a.current;if(!r)return;let i=r.querySelectorAll(`[data-mantine-pill-index]`);i.length!==0&&(e.preventDefault(),i[i.length-1].focus())}}}var Q=(0,Z.createContext)(null),dt={root:`m_7cda1cd6`,"root--default":`m_44da308b`,"root--contrast":`m_e3a01f8`,label:`m_1e0e6180`,remove:`m_ae386778`,group:`m_1dcfd90b`},ft=(0,Z.createContext)(null),pt=w((e,{gap:t},{size:n})=>({group:{"--pg-gap":t===void 0?R(n,`pg-gap`):R(t)}})),mt=c(e=>{let t=d(`PillGroup`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,size:c,disabled:l,attributes:u,...f}=t,p=(0,Z.use)(Q)?.size||c||void 0,m=g({name:`PillGroup`,classes:dt,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:u,vars:s,varsResolver:pt,stylesCtx:{size:p},rootSelector:`group`});return(0,X.jsx)(ft,{value:{size:p,disabled:l},children:(0,X.jsx)(S,{size:p,...m(`group`),...f})})});mt.classes=dt,mt.varsResolver=pt,mt.displayName=`@mantine/core/PillGroup`;var ht={variant:`default`},gt=w((e,{radius:t},{size:n})=>({root:{"--pill-fz":R(n,`pill-fz`),"--pill-height":R(n,`pill-height`),"--pill-radius":t===void 0?void 0:D(t)}})),_t=c(e=>{let t=d(`Pill`,ht,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,variant:c,children:l,withRemoveButton:u,onRemove:f,removeButtonProps:m,radius:h,size:_,disabled:v,mod:y,attributes:b,...x}=t,C=(0,Z.use)(ft),w=(0,Z.use)(Q),T=_||C?.size||void 0,E=w?.variant===`filled`?`contrast`:c||`default`,D=g({name:`Pill`,classes:dt,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:b,vars:s,varsResolver:gt,stylesCtx:{size:T}});return(0,X.jsxs)(S,{component:`span`,variant:E,size:T,...D(`root`,{variant:E}),mod:[{"with-remove":u&&!v,disabled:v||C?.disabled},y],...x,children:[(0,X.jsx)(`span`,{...D(`label`),children:l}),u&&(0,X.jsx)(p,{variant:`transparent`,radius:h,tabIndex:-1,"aria-hidden":!0,unstyled:o,...m,...D(`remove`,{className:m?.className,style:m?.style}),onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m?.onMouseDown?.(e)},onClick:e=>{e.stopPropagation(),f?.(),m?.onClick?.(e)}})]})});_t.classes=dt,_t.varsResolver=gt,_t.displayName=`@mantine/core/Pill`,_t.Group=mt;var vt={field:`m_45c4369d`},yt={type:`visible`},bt=c(e=>{let t=d(`PillsInputField`,yt,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,type:c,disabled:l,id:f,pointer:p,mod:m,attributes:h,ref:_,...v}=t,y=(0,Z.use)(Q),b=(0,Z.use)(u),x=g({name:`PillsInputField`,classes:vt,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:h,rootSelector:`field`}),C=l||y?.disabled;return(0,X.jsx)(S,{component:`input`,ref:I(_,y?.fieldRef),"data-type":c,disabled:C,mod:[{disabled:C,pointer:p},m],...x(`field`),...v,id:b?.inputId||f,"aria-invalid":y?.hasError,"aria-describedby":b?.describedBy,type:`text`,onMouseDown:e=>!p&&e.stopPropagation()})});bt.classes=vt,bt.displayName=`@mantine/core/PillsInputField`;var xt={size:`sm`},St=c(e=>{let{children:t,onMouseDown:n,onClick:r,size:i,disabled:a,__staticSelector:o,error:s,variant:c,...l}=d([`Input`,`InputWrapper`,`PillsInput`],xt,e),u=(0,Z.useRef)(null);return(0,X.jsx)(Q,{value:{fieldRef:u,size:i,disabled:a,hasError:!!s,variant:c},children:(0,X.jsx)(h,{size:i,error:s,variant:c,component:`div`,"data-no-overflow":!0,onMouseDown:e=>{e.preventDefault(),n?.(e),u.current?.focus()},onClick:e=>{e.preventDefault(),e.currentTarget.closest(`fieldset`)?.disabled||(u.current?.focus(),r?.(e))},...l,multiline:!0,disabled:a,__staticSelector:o||`PillsInput`,withAria:!1,children:t})})});St.displayName=`@mantine/core/PillsInput`,St.classes=h.classes,St.Field=bt;function Ct(e){return typeof e==`string`?e.trim().toLowerCase():e}function wt({data:e,value:t}){let n=t.map(Ct);return e.reduce((e,t)=>(Oe(t)?e.push({group:t.group,items:t.items.filter(e=>n.indexOf(Ct(e.value))===-1)}):n.indexOf(Ct(t.value))===-1&&e.push(t),e),[])}var Tt={xs:41,sm:50,md:60,lg:72,xl:89},Et={maxValues:1/0,withCheckIcon:!0,checkIconPosition:`left`,hiddenInputValuesDivider:`,`,clearSearchOnChange:!0,openOnFocus:!0,size:`sm`},Dt=v(e=>{let t=d([`Input`,`InputWrapper`,`MultiSelect`],Et,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,size:c,value:l,defaultValue:u,onChange:f,onKeyDown:p,variant:m,data:h,dropdownOpened:_,defaultDropdownOpened:v,onDropdownOpen:b,onDropdownClose:x,selectFirstOptionOnChange:S,selectFirstOptionOnDropdownOpen:C,onOptionSubmit:w,comboboxProps:T,filter:E,limit:D,withScrollArea:O,maxDropdownHeight:k,floatingHeight:A,searchValue:j,defaultSearchValue:N,onSearchChange:F,readOnly:I,disabled:L,onFocus:R,onBlur:te,radius:ne,rightSection:re,rightSectionWidth:ie,rightSectionPointerEvents:z,rightSectionProps:ae,leftSection:oe,leftSectionWidth:ce,leftSectionPointerEvents:B,leftSectionProps:le,inputContainer:V,inputWrapperOrder:ue,withAsterisk:de,labelProps:fe,descriptionProps:H,errorProps:U,successProps:pe,wrapperProps:G,description:K,label:q,error:J,success:me,maxValues:he,searchable:Y,nothingFoundMessage:ge,withCheckIcon:_e,withAlignedLabels:ve,checkIconPosition:ye,hidePickedOptions:be,withErrorStyles:xe,withSuccessStyles:Se,name:Ce,form:we,id:Te,clearable:Ee,clearSectionMode:De,clearButtonProps:Oe,hiddenInputProps:Me,placeholder:Ie,hiddenInputValuesDivider:Le,required:Re,mod:ze,renderOption:Be,renderPill:Ve,onRemove:He,onClear:Ue,onMaxValues:We,scrollAreaProps:Ge,chevronColor:Ke,attributes:qe,clearSearchOnChange:Je,openOnFocus:Ye,loading:Xe,loadingPosition:Ze,withPillsReorder:Qe,...$e}=t,et=M(Te),tt=Pe({id:et,label:q,labelProps:fe,inputWrapperOrder:ue}),nt=je(h),rt=ke(nt),it=(0,Z.useRef)({}),at=Fe({opened:_,defaultOpened:v,onDropdownOpen:()=>{b?.(),C&&at.selectFirstOption()},onDropdownClose:()=>{x?.(),at.resetSelectedOption()}}),{styleProps:ot,rest:{type:st,autoComplete:ct,...lt}}=P($e),[Q,dt]=ee({value:l,defaultValue:u,finalValue:[],onChange:f}),{getPillProps:ft,getListProps:pt,handleInputKeyDown:mt}=ut({value:Q,onChange:dt,enabled:Qe&&!L&&!I}),[ht,gt]=ee({value:j,defaultValue:N,finalValue:``,onChange:F}),vt=e=>{gt(e),at.resetSelectedOption()},yt=g({name:`MultiSelect`,classes:{},props:t,classNames:n,styles:a,unstyled:o,attributes:qe}),{resolvedClassNames:bt,resolvedStyles:xt}=y({props:t,styles:a,classNames:n}),Ct=e=>{p?.(e),!e.defaultPrevented&&(e.key===` `&&!Y&&(e.preventDefault(),at.toggleDropdown()),e.key===`Backspace`&&ht.length===0&&Q.length>0&&!I&&(He?.(Q[Q.length-1]),dt(Q.slice(0,Q.length-1))),mt(e))},Dt=Q.map((e,t)=>{let n=rt[`${e}`]||it.current[`${e}`],r=ft(t);return Ve?(0,X.jsx)(Z.Fragment,{children:Ve({option:n,value:e,onRemove:()=>{dt(Q.filter(t=>e!==t)),He?.(e)},disabled:L,reorderProps:r})},`${e}-${t}`):(0,X.jsx)(_t,{withRemoveButton:!I&&!rt[`${e}`]?.disabled,onRemove:()=>{dt(Q.filter(t=>e!==t)),He?.(e)},unstyled:o,disabled:L,...yt(`pill`),...r,children:n?.label||e},`${e}-${t}`)});(0,Z.useEffect)(()=>{S&&at.selectFirstOption()},[S,ht]),(0,Z.useEffect)(()=>{Q.forEach(e=>{`${e}`in rt&&(it.current[`${e}`]=rt[`${e}`])})},[rt,Q]);let Ot=(0,X.jsx)(Ne.ClearButton,{...Oe,onClear:()=>{Ue?.(),dt([]),vt(``)}}),kt=wt({data:nt,value:Q}),At=Ee&&Q.length>0&&!L&&!I,jt=At?{paddingInlineEnd:Tt[c]??Tt.sm}:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ne,{store:at,classNames:bt,styles:xt,unstyled:o,size:c,readOnly:I,__staticSelector:`MultiSelect`,attributes:qe,floatingHeight:A,onOptionSubmit:e=>{w?.(e),Je&&vt(``),at.updateSelectedOptionIndex(`selected`),Q.includes(rt[`${e}`].value)?(dt(Q.filter(t=>t!==rt[`${e}`].value)),He?.(rt[`${e}`].value)):Q.lengthY?at.openDropdown():at.toggleDropdown(),"data-expanded":at.dropdownOpened||void 0,id:et,required:Re,mod:ze,attributes:qe,children:(0,X.jsxs)(_t.Group,{attributes:qe,disabled:L,unstyled:o,...yt(`pillsList`,{style:jt}),...pt(),children:[Dt,(0,X.jsx)(Ne.EventsTarget,{autoComplete:ct,withExpandedAttribute:!0,children:(0,X.jsx)(St.Field,{...lt,id:et,placeholder:Ie,type:!Y&&!Ie?`hidden`:`visible`,...yt(`inputField`),unstyled:o,onFocus:e=>{R?.(e),Ye&&Y&&at.openDropdown()},onBlur:e=>{te?.(e),at.closeDropdown(),vt(``)},onKeyDown:Ct,value:ht,onChange:e=>{if(W(e)){if(!I){let t=se(rt,e.currentTarget.value);t&&!Q.includes(t.value)&&Q.lengthe*40+(e-1)*12,jt={s:3,m:6,l:10},Mt={stat:4},Nt=e=>Math.max(Mt[e.viz]??0,jt[e.height??(e.viz===`service_map`?`l`:e.viz===`stat`?`s`:`m`)]);function Pt(){return(0,X.jsxs)(x,{gap:`md`,"data-dashboard-skeleton":!0,children:[(0,X.jsxs)(x,{gap:`sm`,"data-dashboard-header-skeleton":!0,children:[(0,X.jsxs)(f,{justify:`space-between`,children:[(0,X.jsx)(l,{height:28,width:`32%`}),(0,X.jsx)(l,{height:28,width:28})]}),(0,X.jsx)(l,{height:12,width:`52%`}),(0,X.jsxs)(f,{justify:`space-between`,children:[(0,X.jsx)(l,{height:32,width:180}),(0,X.jsx)(l,{height:32,width:120})]})]}),(0,X.jsx)(S,{style:{containerType:`inline-size`},children:(0,X.jsx)(S,{className:`dashboard-loading-grid`,style:{display:`grid`,gridTemplateColumns:`repeat(12, minmax(0, 1fr))`,gap:12},children:[`stat`,`stat`,`stat`,`timeseries`,`table`].map((e,t)=>(0,X.jsxs)(i,{withBorder:!0,p:`md`,className:`dashboard-loading-panel`,"data-skeleton-columns":e===`stat`?4:6,style:{display:`flex`,flexDirection:`column`,minHeight:At(e===`stat`?4:6)},children:[(0,X.jsx)(l,{height:14,width:`44%`,mb:`xl`}),(0,X.jsx)(Je,{viz:e,rows:4})]},t))})})]})}function Ft(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function It(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function Lt(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=Ft(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=It(r,u,s[0]),f=It(i,l,s[1])),a?(p=Math.round(a.top),m=Math.round(a.left)):o?(p=Math.round(o.top),m=Math.round(o.left)):(p=Math.round((l+s[1])*n+c[1]),m=Math.round((u+s[0])*t+c[0])),!a&&!o){if(Number.isFinite(r)){let e=Math.round((u+s[0])*(t+r)+c[0])-m-d;e!==s[0]&&(d+=e-s[0])}if(Number.isFinite(i)){let e=Math.round((l+s[1])*(n+i)+c[1])-p-f;e!==s[1]&&(f+=e-s[1])}}return{top:p,left:m,width:d,height:f}}function Rt(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=Ft(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=Vt(d,0,s-r),f=Vt(f,0,l-i),{x:d,y:f}}function zt(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=Ft(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function Bt(e,t,n){let{margin:r,rowHeight:i}=e,a=Ft(e);return{w:Math.max(1,Math.round((t+r[0])/(a+r[0]))),h:Math.max(1,Math.round((n+r[1])/(i+r[1])))}}function Vt(e,t,n){return Math.max(Math.min(e,n),t)}function Ht(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function Ut(e,t){for(let n=0;nHt(e,t))}function Gt(e,t){return t===`horizontal`?qt(e):t===`vertical`||t===`wrap`?Kt(e):[...e]}function Kt(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function qt(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function Jt(e){let t=0;for(let n=0;nt&&(t=e)}}return t}function Yt(e,t){for(let n=0;ne.static===!0)}function Zt(e){return{i:e.i,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,constraints:e.constraints,isBounded:e.isBounded}}function Qt(e){let t=Array(e.length);for(let n=0;nt.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),i.y===1/0&&(i.y=Jt(n)),!i.static)n.push(i);else for(;Ut(n,i);)i.y++}}return e}function nn(e,t,n,r,i,a,o,s,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return[...e];let l=t.x,u=t.y;typeof n==`number`&&(t.x=n),typeof r==`number`&&(t.y=r),t.moved=!0;let d=Gt(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=Wt(d,t),p=f.length>0;if(p&&c)return Qt(e);if(p&&a)return t.x=l,t.y=u,t.moved=!1,e;let m=[...e];for(let e=0;et.y,d=l!==void 0&&t.x+t.w>l.x;if(!l)return nn(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return nn(e,n,void 0,n.y+1,r,c,i);if(u&&i===null){let r=n.y;return t.y=r,n.y=r+t.h,[...e]}if(d&&o)return nn(e,t,n.x,void 0,r,c,i)}let l=o?n.x+1:void 0,u=s?n.y+1:void 0;return l===void 0&&u===void 0?[...e]:nn(e,n,l,u,r,c,i)}function an(e,t,n){return Math.max(t,Math.min(n,e))}var on=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:an(t,0,Math.max(0,r-e.w)),y:an(n,0,Math.max(0,i-e.h))}},constrainSize(e,t,n,r,{cols:i,maxRows:a}){let o=r===`w`||r===`nw`||r===`sw`?e.x+e.w:i-e.x,s=r===`n`||r===`nw`||r===`ne`?e.y+e.h:a-e.y;return{w:an(t,1,Math.max(1,o)),h:an(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:an(t,e.minW??1,e.maxW??1/0),h:an(n,e.minH??1,e.maxH??1/0)}}}];function sn(e,t,n,r,i){let a={x:n,y:r};for(let n of e)n.constrainPosition&&(a=n.constrainPosition(t,a.x,a.y,i));if(t.constraints)for(let e of t.constraints)e.constrainPosition&&(a=e.constrainPosition(t,a.x,a.y,i));return a}function cn(e,t,n,r,i,a){let o={w:n,h:r};for(let n of e)n.constrainSize&&(o=n.constrainSize(t,o.w,o.h,i,a));if(t.constraints)for(let e of t.constraints)e.constrainSize&&(o=e.constrainSize(t,o.w,o.h,i,a));return o}function ln({top:e,left:t,width:n,height:r}){let i=`translate(${t}px,${e}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${n}px`,height:`${r}px`,position:`absolute`}}function un({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function dn(e){return e*100+`%`}function fn(e,t,n,r){return e+n>r?t:n}function pn(e,t,n){return e<0?t:n}function mn(e){return Math.max(0,e)}function hn(e){return Math.max(0,e)}var gn=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:pn(o,e.height,i),top:hn(o)}},_n=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:fn(e.left,e.width,o,n),left:mn(i)}},vn=(e,t,n)=>{let{top:r,height:i,width:a}=t,o=e.left+e.width-a;return o<0?{height:i,width:e.left+e.width,top:hn(r),left:0}:{height:i,width:a,top:hn(r),left:o}},yn=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:pn(r,e.height,a),top:hn(r)}},bn={n:gn,ne:(e,t,n)=>gn(e,_n(e,t,n)),e:_n,se:(e,t,n)=>yn(e,_n(e,t,n)),s:yn,sw:(e,t,n)=>yn(e,vn(e,t)),w:vn,nw:(e,t,n)=>gn(e,vn(e,t))};function xn(e,t,n,r){let i=bn[e];return i?i(t,{...t,...n},r):n}var Sn={type:`transform`,scale:1,calcStyle(e){return ln(e)}},Cn={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},wn={enabled:!0,bounded:!1,threshold:3},Tn={enabled:!0,handles:[`se`]},En={enabled:!1,defaultItem:{w:1,h:1},touchEnabled:!0,touchDragSource:`[data-rgl-draggable]`};function Dn(e,t,n,r,i){let a=r===`x`?`w`:`h`;t[r]+=1;let o=e.findIndex(e=>e.i===t.i),s=i??Xt(e).length>0;for(let i=o+1;it.y+t.h)break;Ht(t,o)&&Dn(e,o,n+t[a],r,s)}}t[r]=n}function On(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0),t.y=Math.min(r,t.y);t.y>0&&!Ut(e,t);)t.y--;let i;for(;(i=Ut(e,t))!==void 0;)Dn(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function kn(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!Ut(e,t);)t.x--;let i;for(;(i=Ut(e,t))!==void 0;)if(Dn(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!Ut(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var An={type:`vertical`,allowOverlap:!1,compact(e,t){let n=Xt(e),r=Jt(n),i=Kt(e),a=Array(e.length);for(let t=0;te[t]-e[n])}function Rn(e,t){let n=Ln(e),r=n[0];if(r===void 0)throw Error(`No breakpoints defined`);for(let i=1;ie[a]&&(r=a)}return r}function zn(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function Bn(e,t,n,r,i,a){let o=e[n];if(o)return Qt(o);let s=e[r],c=Ln(t),l=c.slice(c.indexOf(n));for(let t=0;t{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n[`fast-equals`]={}))})(e,(function(e){function t(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function n(e){return function(t,n,r,i){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r,i);var a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);var s=e(t,n,r,i);return i.delete(t),i.delete(n),s}}function r(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e){return e.constructor===Object||e.constructor==null}function a(e){return typeof e.then==`function`}function o(e,t){return e===t||e!==e&&t!==t}var s=Object.prototype.toString;function c(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,c=e.areObjectsEqual,l=e.areRegExpsEqual,u=e.areSetsEqual,d=e.createIsNestedEqual,f=d(p);function p(e,d,p){if(e===d)return!0;if(!e||!d||typeof e!=`object`||typeof d!=`object`)return e!==e&&d!==d;if(i(e)&&i(d))return c(e,d,f,p);var m=Array.isArray(e),h=Array.isArray(d);if(m||h)return m===h&&t(e,d,f,p);var g=s.call(e);return g===s.call(d)?g===`[object Date]`?n(e,d,f,p):g===`[object RegExp]`?l(e,d,f,p):g===`[object Map]`?r(e,d,f,p):g===`[object Set]`?u(e,d,f,p):g===`[object Object]`||g===`[object Arguments]`?a(e)||a(d)?!1:c(e,d,f,p):g===`[object Boolean]`||g===`[object Number]`||g===`[object String]`?o(e.valueOf(),d.valueOf()):!1:!1}return p}function l(e,t,n,r){var i=e.length;if(t.length!==i)return!1;for(;i-->0;)if(!n(e[i],t[i],i,i,e,t,r))return!1;return!0}var u=n(l);function d(e,t){return o(e.valueOf(),t.valueOf())}function f(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={},o=0;return e.forEach(function(s,c){if(i){var l=!1,u=0;t.forEach(function(i,d){!l&&!a[u]&&(l=n(c,d,o,u,e,t,r)&&n(s,i,c,d,e,t,r))&&(a[u]=!0),u++}),o++,i=l}}),i}var p=n(f),m=`_owner`,h=Object.prototype.hasOwnProperty;function g(e,t,n,r){var i=Object.keys(e),a=i.length;if(Object.keys(t).length!==a)return!1;for(var o;a-->0;){if(o=i[a],o===m){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!h.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var _=n(g);function v(e,t){return e.source===t.source&&e.flags===t.flags}function y(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={};return e.forEach(function(o,s){if(i){var c=!1,l=0;t.forEach(function(i,u){!c&&!a[l]&&(c=n(o,i,s,u,e,t,r))&&(a[l]=!0),l++}),i=c}}),i}var b=n(y),x=Object.freeze({areArraysEqual:l,areDatesEqual:d,areMapsEqual:f,areObjectsEqual:g,areRegExpsEqual:v,areSetsEqual:y,createIsNestedEqual:t}),S=Object.freeze({areArraysEqual:u,areDatesEqual:d,areMapsEqual:p,areObjectsEqual:_,areRegExpsEqual:v,areSetsEqual:b,createIsNestedEqual:t}),C=c(x);function w(e,t){return C(e,t,void 0)}var T=c(r(x,{createIsNestedEqual:function(){return o}}));function E(e,t){return T(e,t,void 0)}var D=c(S);function ee(e,t){return D(e,t,new WeakMap)}var O=c(r(S,{createIsNestedEqual:function(){return o}}));function k(e,t){return O(e,t,new WeakMap)}function A(e){return c(r(x,e(x)))}function j(e){var t=c(r(S,e(S)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=ee,e.circularShallowEqual=k,e.createCustomCircularEqual=j,e.createCustomEqual=A,e.deepEqual=w,e.sameValueZeroEqual=o,e.shallowEqual=E,Object.defineProperty(e,"__esModule",{value:!0})}))})),Un=e(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Wn=e(((e,t)=>{var n=Un();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Gn=e(((e,t)=>{t.exports=Wn()()})),$=r(Gn(),1);function Kn(e,t){for(let n=0,r=e.length;n`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;nt===e.identifier)||e.changedTouches&&Kn(e.changedTouches,e=>t===e.identifier)}function gr(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function _r(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function vr(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??_r();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;} `,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;} `,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&xr(e.body,`react-draggable-transparent-selection`)}function yr(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{br(e)}):br(e)}function br(e){if(e)try{e.body&&Sr(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function xr(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function Sr(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function Cr(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:Ar(r);let i=jr(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+Yn(s.paddingLeft)+Yn(o.marginLeft),top:-i.offsetTop+Yn(s.paddingTop)+Yn(o.marginTop),right:ur(a)-cr(i)-i.offsetLeft+Yn(s.paddingRight)-Yn(o.marginRight),bottom:lr(a)-sr(i)-i.offsetTop+Yn(s.paddingBottom)-Yn(o.marginBottom)}}return Jn(r.right)&&(t=Math.min(t,r.right)),Jn(r.bottom)&&(n=Math.min(n,r.bottom)),Jn(r.left)&&(t=Math.max(t,r.left)),Jn(r.top)&&(n=Math.max(n,r.top)),[t,n]}function wr(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function Tr(e){return e.props.axis===`both`||e.props.axis===`x`}function Er(e){return e.props.axis===`both`||e.props.axis===`y`}function Dr(e,t,n){let r=typeof t==`number`?hr(e,t):null;if(typeof t==`number`&&!r)return null;let i=jr(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return dr(r||e,a,n.props.scale)}function Or(e,t,n){let r=!Jn(e.lastX),i=jr(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function kr(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function Ar(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function jr(e){let t=e.findDOMNode();if(!t)throw Error(`: Unmounted during event!`);return t}var Mr=typeof process<`u`&&{}.DRAGGABLE_DEBUG?console.log.bind(console):function(){},Nr={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},Pr=Nr.mouse,Fr=class extends Z.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(` not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!ir(e.target,this.props.handle,t)||this.props.cancel&&ir(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=gr(e);this.touchIdentifier=r;let i=Dr(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=Or(this,a,o);Mr(`DraggableCore: handleDragStart: %j`,s),Mr(`calling`,this.props.onStart),this.props.onStart(e,s)!==!1&&this.mounted!==!1&&(this.props.enableUserSelectHack&&vr(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,ar(n,Pr.move,this.handleDrag),ar(n,Pr.stop,this.handleDragStop))},this.handleDrag=e=>{let t=Dr(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=wr(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=Or(this,n,r);if(Mr(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}return}this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=Dr(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=wr(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=Or(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&yr(a.ownerDocument),Mr(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(Mr(`DraggableCore: Removing handlers`),or(a.ownerDocument,Pr.move,this.handleDrag),or(a.ownerDocument,Pr.stop,this.handleDragStop))},this.onMouseDown=e=>(Pr=Nr.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(Pr=Nr.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(Pr=Nr.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(Pr=Nr.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&ar(e,Nr.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;or(t,Nr.mouse.move,this.handleDrag),or(t,Nr.touch.move,this.handleDrag),or(t,Nr.mouse.stop,this.handleDragStop),or(t,Nr.touch.stop,this.handleDragStop),or(e,Nr.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&yr(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=Ot.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(Mr(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return Z.cloneElement(Z.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};Fr.displayName=`DraggableCore`,Fr.propTypes={allowAnyClick:$.default.bool,allowMobileScroll:$.default.bool,children:$.default.node.isRequired,disabled:$.default.bool,enableUserSelectHack:$.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:$.default.arrayOf($.default.number),handle:$.default.string,cancel:$.default.string,nodeRef:$.default.object,nonce:$.default.string,onStart:$.default.func,onDrag:$.default.func,onStop:$.default.func,onMouseDown:$.default.func,scale:$.default.number,className:Xn,style:Xn,transform:Xn},Fr.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var Ir=class extends Z.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(Mr(`Draggable: onDragStart: %j`,t),this.props.onStart(e,kr(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;Mr(`Draggable: onDrag: %j`,t);let n=kr(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=Cr(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,kr(this,t))===!1)return!1;Mr(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(Mr(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=Ot.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,h={x:Tr(this)&&p?this.state.x:m.x,y:Er(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=pr(h,c):d=fr(h,c);let g=Z.Children.only(n),_=C(g.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return Z.createElement(Fr,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},Z.cloneElement(g,{className:_,style:{...g.props.style,...d},transform:f}))}};Ir.displayName=`Draggable`,Ir.propTypes={...Fr.propTypes,axis:$.default.oneOf([`both`,`x`,`y`,`none`]),bounds:$.default.oneOfType([$.default.shape({left:$.default.number,right:$.default.number,top:$.default.number,bottom:$.default.number}),$.default.string,$.default.oneOf([!1])]),defaultClassName:$.default.string,defaultClassNameDragging:$.default.string,defaultClassNameDragged:$.default.string,defaultPosition:$.default.shape({x:$.default.number,y:$.default.number}),positionOffset:$.default.shape({x:$.default.oneOfType([$.default.number,$.default.string]),y:$.default.oneOfType([$.default.number,$.default.string])}),position:$.default.shape({x:$.default.number,y:$.default.number}),className:Xn,style:Xn,transform:Xn},Ir.defaultProps={...Fr.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1};var Lr=e(((e,t)=>{function n(e){var t,r,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`){if(Array.isArray(e)){var a=e.length;for(t=0;t{var r=Object.create,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let a of s(t))!l.call(e,a)&&a!==n&&i(e,a,{get:()=>t[a],enumerable:!(r=o(t,a))||r.enumerable});return e},f=(e,t,n)=>(n=e==null?{}:r(c(e)),d(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)),p=e=>d(i({},`__esModule`,{value:!0}),e),m={};u(m,{DraggableCore:()=>Y,default:()=>ge}),n.exports=p(m);var h=f(t()),g=f(Gn()),_=f(a()),v=Lr();function y(e,t){for(let n=0,r=e.length;n`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;nt===e.identifier)||e.changedTouches&&y(e.changedTouches,e=>t===e.identifier)}function ie(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function z(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function ae(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??z();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;} `,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;} -`,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&ce(e.body,`react-draggable-transparent-selection`)}function oe(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{se(e)}):se(e)}function se(e){if(e)try{e.body&&B(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function ce(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function B(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function le(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:pe(r);let i=W(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+S(s.paddingLeft)+S(o.marginLeft),top:-i.offsetTop+S(s.paddingTop)+S(o.marginTop),right:I(a)-P(i)-i.offsetLeft+S(s.paddingRight)-S(o.marginRight),bottom:F(a)-N(i)-i.offsetTop+S(s.paddingBottom)-S(o.marginBottom)}}return x(r.right)&&(t=Math.min(t,r.right)),x(r.bottom)&&(n=Math.min(n,r.bottom)),x(r.left)&&(t=Math.max(t,r.left)),x(r.top)&&(n=Math.max(n,r.top)),[t,n]}function V(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function ue(e){return e.props.axis===`both`||e.props.axis===`x`}function de(e){return e.props.axis===`both`||e.props.axis===`y`}function fe(e,t,n){let r=typeof t==`number`?re(e,t):null;if(typeof t==`number`&&!r)return null;let i=W(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return L(r||e,a,n.props.scale)}function H(e,t,n){let r=!x(e.lastX),i=W(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function U(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function pe(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function W(e){let t=e.findDOMNode();if(!t)throw Error(`: Unmounted during event!`);return t}var G=f(t()),K=f(Gn()),q=f(a()),J=typeof process<`u`&&{}.DRAGGABLE_DEBUG?console.log.bind(console):function(){},me={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},he=me.mouse,Y=class extends G.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(` not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!A(e.target,this.props.handle,t)||this.props.cancel&&A(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=ie(e);this.touchIdentifier=r;let i=fe(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=H(this,a,o);J(`DraggableCore: handleDragStart: %j`,s),J(`calling`,this.props.onStart),this.props.onStart(e,s)!==!1&&this.mounted!==!1&&(this.props.enableUserSelectHack&&ae(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,j(n,he.move,this.handleDrag),j(n,he.stop,this.handleDragStop))},this.handleDrag=e=>{let t=fe(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=V(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=H(this,n,r);if(J(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}return}this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=fe(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=V(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=H(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&oe(a.ownerDocument),J(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(J(`DraggableCore: Removing handlers`),M(a.ownerDocument,he.move,this.handleDrag),M(a.ownerDocument,he.stop,this.handleDragStop))},this.onMouseDown=e=>(he=me.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(he=me.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(he=me.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(he=me.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&j(e,me.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;M(t,me.mouse.move,this.handleDrag),M(t,me.touch.move,this.handleDrag),M(t,me.mouse.stop,this.handleDragStop),M(t,me.touch.stop,this.handleDragStop),M(e,me.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&oe(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=q.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(J(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return G.cloneElement(G.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};Y.displayName=`DraggableCore`,Y.propTypes={allowAnyClick:K.default.bool,allowMobileScroll:K.default.bool,children:K.default.node.isRequired,disabled:K.default.bool,enableUserSelectHack:K.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:K.default.arrayOf(K.default.number),handle:K.default.string,cancel:K.default.string,nodeRef:K.default.object,nonce:K.default.string,onStart:K.default.func,onDrag:K.default.func,onStop:K.default.func,onMouseDown:K.default.func,scale:K.default.number,className:C,style:C,transform:C},Y.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var ge=class extends h.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(J(`Draggable: onDragStart: %j`,t),this.props.onStart(e,U(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;J(`Draggable: onDrag: %j`,t);let n=U(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=le(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,U(this,t))===!1)return!1;J(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(J(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=_.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,g={x:ue(this)&&p?this.state.x:m.x,y:de(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=te(g,c):d=R(g,c);let _=h.Children.only(n),y=(0,v.clsx)(_.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return h.createElement(Y,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},h.cloneElement(_,{className:y,style:{..._.props.style,...d},transform:f}))}};ge.displayName=`Draggable`,ge.propTypes={...Y.propTypes,axis:g.default.oneOf([`both`,`x`,`y`,`none`]),bounds:g.default.oneOfType([g.default.shape({left:g.default.number,right:g.default.number,top:g.default.number,bottom:g.default.number}),g.default.string,g.default.oneOf([!1])]),defaultClassName:g.default.string,defaultClassNameDragging:g.default.string,defaultClassNameDragged:g.default.string,defaultPosition:g.default.shape({x:g.default.number,y:g.default.number}),positionOffset:g.default.shape({x:g.default.oneOfType([g.default.number,g.default.string]),y:g.default.oneOfType([g.default.number,g.default.string])}),position:g.default.shape({x:g.default.number,y:g.default.number}),className:C,style:C,transform:C},ge.defaultProps={...Y.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1},0&&(n.exports={DraggableCore:Y})})),zr=e(((e,t)=>{var n=Rr(),r=n.DraggableCore,i=n.default||n;t.exports=i,t.exports.default=i,t.exports.DraggableCore=r})),Br=e((e=>{e.__esModule=!0,e.cloneElement=l;var n=r(t());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t{e.__esModule=!0,e.resizableProps=void 0;var t=n(Gn());zr();function n(e){return e&&e.__esModule?e:{default:e}}e.resizableProps={axis:t.default.oneOf([`both`,`x`,`y`,`none`]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:typeof Element<`u`?t.default.instanceOf(Element):t.default.any,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`y`?t.default.number.isRequired(...e):t.default.number(...e)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf([`s`,`w`,`e`,`n`,`sw`,`nw`,`se`,`ne`])),transformScale:t.default.number,width:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),Hr=e((e=>{e.__esModule=!0,e.default=void 0;var n=s(t()),r=zr(),i=Br(),a=Vr(),o=[`children`,`className`,`draggableOpts`,`width`,`height`,`handle`,`handleSize`,`lockAspectRatio`,`axis`,`minConstraints`,`maxConstraints`,`onResize`,`onResizeStop`,`onResizeStart`,`resizeHandles`,`transformScale`];function s(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(s=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;tMath.abs(i*n)?t=e/n:e=t*n}let o=e,s=t,c=this.slack||[0,0],l=c[0],u=c[1];return e+=l,t+=u,r&&(e=Math.max(r[0],e),t=Math.max(r[1],t)),i&&(e=Math.min(i[0],e),t=Math.min(i[1],t)),this.slack=[l+(o-e),u+(s-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let i=r.node,a=r.deltaX,o=r.deltaY;e===`onResizeStart`&&this.resetData();let s=(this.props.axis===`both`||this.props.axis===`x`)&&t!==`n`&&t!==`s`,c=(this.props.axis===`both`||this.props.axis===`y`)&&t!==`e`&&t!==`w`;if(!s&&!c)return;let l=t[0],u=t[t.length-1],d=i.getBoundingClientRect();if(this.lastHandleRect!=null){if(u===`w`){let e=d.left-this.lastHandleRect.left;a+=e}if(l===`n`){let e=d.top-this.lastHandleRect.top;o+=e}}this.lastHandleRect=d,u===`w`&&(a=-a),l===`n`&&(o=-o);let f=this.lastSize?.width??this.props.width,p=this.lastSize?.height??this.props.height,m=f+(s?a/this.props.transformScale:0),h=p+(c?o/this.props.transformScale:0);var g=this.runConstraints(m,h);if(m=g[0],h=g[1],e===`onResizeStop`&&this.lastSize){var _=this.lastSize;m=_.width,h=_.height}let v=m!==f||h!==p;e!==`onResizeStop`&&(this.lastSize={width:m,height:h});let y=typeof this.props[e]==`function`?this.props[e]:null;y&&(e!==`onResize`||v)&&(n.persist==null||n.persist(),y(n,{node:i,size:{width:m,height:h},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,t){let r=this.props.handle;if(!r)return n.createElement(`span`,{className:`react-resizable-handle react-resizable-handle-`+e,ref:t});if(typeof r==`function`)return r(e,t);let i=typeof r.type==`string`,a=d({ref:t},i?{}:{handleAxis:e});return n.cloneElement(r,a)}render(){let e=this.props,t=e.children,a=e.className,s=e.draggableOpts;e.width,e.height,e.handle,e.handleSize,e.lockAspectRatio,e.axis,e.minConstraints,e.maxConstraints,e.onResize,e.onResizeStop,e.onResizeStart;let u=e.resizeHandles;e.transformScale;let f=l(e,o);return(0,i.cloneElement)(t,d(d({},f),{},{className:(a?a+` `:``)+`react-resizable`,children:[...n.Children.toArray(t.props.children),...u.map(e=>{let t=this.handleRefs[e]??(this.handleRefs[e]=n.createRef());return n.createElement(r.DraggableCore,c({},s,{nodeRef:t,key:`resizableHandle-`+e,onStop:this.resizeHandler(`onResizeStop`,e),onStart:this.resizeHandler(`onResizeStart`,e),onDrag:this.resizeHandler(`onResize`,e)}),this.renderResizeHandle(e,t))})]}))}};e.default=h,h.propTypes=a.resizableProps,h.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),Ur=e((e=>{e.__esModule=!0,e.default=void 0;var n=c(t()),r=s(Gn()),i=s(Hr()),a=Vr(),o=[`handle`,`handleSize`,`onResize`,`onResizeStart`,`onResizeStop`,`draggableOpts`,`minConstraints`,`maxConstraints`,`lockAspectRatio`,`axis`,`width`,`height`,`resizeHandles`,`style`,`transformScale`];function s(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(c=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let n=t.size;this.props.onResize?(e.persist==null||e.persist(),this.setState(n,()=>this.props.onResize&&this.props.onResize(e,t))):this.setState(n)}}static getDerivedStateFromProps(e,t){return t.propsWidth!==e.width||t.propsHeight!==e.height?{width:e.width,height:e.height,propsWidth:e.width,propsHeight:e.height}:null}render(){let e=this.props,t=e.handle,r=e.handleSize;e.onResize;let a=e.onResizeStart,s=e.onResizeStop,c=e.draggableOpts,u=e.minConstraints,f=e.maxConstraints,p=e.lockAspectRatio,m=e.axis;e.width,e.height;let g=e.resizeHandles,_=e.style,v=e.transformScale,y=h(e,o);return n.createElement(i.default,{axis:m,draggableOpts:c,handle:t,handleSize:r,height:this.state.height,lockAspectRatio:p,maxConstraints:f,minConstraints:u,onResizeStart:a,onResize:this.onResize,onResizeStop:s,resizeHandles:g,transformScale:v,width:this.state.width},n.createElement(`div`,l({},y,{style:d(d({},_),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=g,g.propTypes=d(d({},a.resizableProps),{},{children:r.default.element})})),Wr=e(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=Hr().default,t.exports.ResizableBox=Ur().default}))(),Gr=Hn(),Kr=50,qr=12;function Jr(e){let t=e;for(;t;){let e=window.getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function Yr(e){let t=Jr(e),n=null,r=0,i=0,a=!1;function o(){let e=t;if(!e)return;let s=e.getBoundingClientRect(),{clientHeight:c,scrollTop:l,scrollHeight:u}=e,{scrollLeft:d,scrollWidth:f,clientWidth:p}=e,m=0,h=0;i0?m=-qr:i>s.bottom-Kr&&l+c0?h=-qr:r>s.right-Kr&&d+p({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),K=(0,Z.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),q=(0,Z.useCallback)(e=>({...K,containerHeight:e??K.containerHeight,layout:ue.current}),[K]),J=(0,Z.useMemo)(()=>F??{i:j,x:w,y:T,w:E,h:D,minW:ee,maxW:O,minH:k,maxH:A},[F,j,w,T,E,D,ee,O,k,A]),me=(0,Z.useCallback)(e=>{if(g?.calcStyle)return g.calcStyle(e);if(p)return ln(e);let t=un(e);return m?{...t,left:dn(e.left/r),width:dn(e.width/r)}:t},[g,p,m,r]),he=(0,Z.useCallback)((e,{node:t})=>{if(!L)return;let{offsetParent:n}=t;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=i.left/h,o=r.left/h,s=i.top/h,c=r.top/h,l;if(g?.calcDragPosition){let t=e;l=g.calcDragPosition(t.clientX,t.clientY,t.clientX-i.left,t.clientY-i.top)}else l={left:a-o+n.scrollLeft,top:s-c+n.scrollTop};if(B.current=l,W.current||=Yr(t instanceof HTMLElement?t:null),_>0){let t=e;U.current={x:t.clientX,y:t.clientY},H.current=!0,pe.current=!1,ae(!0);return}ae(!0);let u=zt(G,l.top,l.left),{x:d,y:f}=sn(P,J,u.x,u.y,q());L(j,d,f,{e,node:t,newPosition:l})},[L,h,G,g,_,P,J,q,j]),Y=(0,Z.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!R||!z)return;let s=e;if(H.current&&!pe.current){let n=s.clientX-U.current.x,r=s.clientY-U.current.y;if(Math.hypot(n,r)<_)return;if(pe.current=!0,H.current=!1,L){let n=zt(G,B.current.top,B.current.left),{x:r,y:i}=sn(P,J,n.x,n.y,q());L(j,r,i,{e,node:t,newPosition:B.current})}}W.current?.feed(s.clientX,s.clientY);let c=B.current.top+a,l=B.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-It(D,o,i[1]);c=Vt(c,0,t);let n=Ft(G),a=r-It(E,n,i[0]);l=Vt(l,0,a)}}let d={top:c,left:l};B.current=d;let f=zt(G,c,l),{x:p,y:m}=sn(P,J,f.x,f.y,q());R(j,p,m,{e,node:t,newPosition:d})},[R,L,z,_,u,D,o,i,G,r,E,j,P,J,q]),ge=(0,Z.useCallback)((e,{node:t})=>{if(!te||!z)return;W.current?.stop(),W.current=null;let n=H.current;if(H.current=!1,pe.current=!1,U.current={x:0,y:0},n){ae(!1),B.current={left:0,top:0};return}let{left:r,top:i}=B.current,a={top:i,left:r};ae(!1),B.current={left:0,top:0};let o=zt(G,i,r),{x:s,y:c}=sn(P,J,o.x,o.y,q());te(j,s,c,{e,node:t,newPosition:a})},[te,z,G,P,J,q,j]);de.current=he,fe.current=Y;let _e=(0,Z.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?ne:o===`onResize`?re:ie;if(!s)return;let c;c=t?xn(i,a,n,r):{...n,top:a.top,left:a.left},le.current=c;let l=t?.offsetParent?.clientHeight??0,u=Bt(G,c.width,c.height),{w:d,h:f}=cn(P,J,u.w,u.h,i,q(l));s(j,d,f,{e:e.nativeEvent??e,node:t,size:c,handle:i})},[ne,re,ie,r,G,j,P,J,q]),ve=(0,Z.useCallback)((e,t)=>{se(!0);let n=Lt(G,w,T,E,D),r={...t,handle:t.handle};_e(e,r,n,`onResizeStart`)},[_e,G,w,T,E,D]),ye=(0,Z.useCallback)((e,t)=>{let n=Lt(G,w,T,E,D),r={...t,handle:t.handle};_e(e,r,n,`onResize`)},[_e,G,w,T,E,D]),be=(0,Z.useCallback)((e,t)=>{se(!1),le.current={top:0,left:0,width:0,height:0};let n=Lt(G,w,T,E,D),r={...t,handle:t.handle};_e(e,r,n,`onResizeStop`)},[_e,G,w,T,E,D]);(0,Z.useEffect)(()=>{if(!v)return;let e=ce.current;if(!e)return;let t=V.current||{left:0,top:0},n=z&&(v.left!==t.left||v.top!==t.top);if(!z){let t={node:e,deltaX:v.left,deltaY:v.top,lastX:0,lastY:0,x:v.left,y:v.top};de.current?.(v.e,t)}else if(n){let t={node:e,deltaX:v.left-B.current.left,deltaY:v.top-B.current.top,lastX:B.current.left,lastY:B.current.top,x:v.left,y:v.top};fe.current?.(v.e,t)}V.current=v},[v,z,j]);let xe=Lt(G,w,T,E,D,z?B.current:null,oe?le.current:null),Se=Z.Children.only(t),Ce=Ft(G),we=[It(ee,Ce,i[0]),It(k,o,i[1])],Te=[It(O,Ce,i[0]),It(A,o,i[1])],Ee=Se.props,De=Ee.className,Oe=Ee.style,ke=Z.cloneElement(Se,{ref:ce,className:C(`react-grid-item`,De,y,{static:f,resizing:oe,"react-draggable":c,"react-draggable-dragging":z,dropping:!!v,cssTransforms:p}),style:{...b,...Oe,...me(xe)}}),Ae=N;return ke=(0,X.jsx)(Wr.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:xe.width,height:xe.height,minConstraints:we,maxConstraints:Te,onResizeStart:ve,onResize:ye,onResizeStop:be,transformScale:h,resizeHandles:M,handle:Ae,children:ke}),ke=(0,X.jsx)(Fr,{disabled:!c,onStart:he,onDrag:Y,onStop:ge,handle:x,cancel:`.react-resizable-handle`+(S?`,`+S:``),scale:h,allowMobileScroll:d,nodeRef:ce,children:ke}),ke}var Zr=Z.memo(Xr,(e,t)=>e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h&&e.minW===t.minW&&e.maxW===t.maxW&&e.minH===t.minH&&e.maxH===t.maxH&&e.cols===t.cols&&e.containerWidth===t.containerWidth&&e.rowHeight===t.rowHeight&&e.maxRows===t.maxRows&&e.margin===t.margin&&e.containerPadding===t.containerPadding&&e.transformScale===t.transformScale&&e.isDraggable===t.isDraggable&&e.isResizable===t.isResizable&&e.isBounded===t.isBounded&&e.allowMobileScroll===t.allowMobileScroll&&e.useCSSTransforms===t.useCSSTransforms&&e.usePercentages===t.usePercentages&&e.children===t.children&&e.onDrag===t.onDrag&&e.onDragStop===t.onDragStop&&e.onResize===t.onResize&&e.onResizeStop===t.onResizeStop&&e.droppingPosition===t.droppingPosition);Zr.displayName=`GridItem`;function Qr(e){let{clientX:t,clientY:n,gridElement:r,droppingItem:i,event:a,dragOffsetX:o=0,dragOffsetY:s=0,transformScale:c,cols:l,margin:u,maxRows:d,rowHeight:f,width:p,containerPadding:m}=e,h=r.getBoundingClientRect(),g={cols:l,margin:u,maxRows:d,rowHeight:f,containerWidth:p,containerPadding:m},_=Ft(g),v=It(i.w,_,u[0]),y=It(i.h,f,u[1]),b=v/2,x=y/2,S=r.scrollLeft??0,C=r.scrollTop??0,w=t-h.left+S+o-b,T=n-h.top+C+s-x,E=Math.max(0,w),D=Math.max(0,T);return{newDroppingPosition:{left:E/c,top:D/c,e:a},calculatedXY:Rt(g,D,E,i.w,i.h)}}var $r=()=>{},ei=`react-grid-layout`,ti=!1;try{ti=/firefox/i.test(navigator.userAgent)}catch{}function ni(e,t){let n=Z.Children.toArray(e),r=Z.Children.toArray(t);if(n.length!==r.length)return!1;for(let e=0;e{if(!Z.isValidElement(t)||t.key===null)return;let n=String(t.key);a.add(n);let r=e.find(e=>e.i===n);if(r)i.push(Zt(r));else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Jt(i),w:1,h:1})}});let o=tn(i,{cols:n});return r.compact(o,n)}function ii(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=Sn,compactor:c,constraints:l=on,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=$r,onDragStart:_=$r,onDrag:v=$r,onDragStop:y=$r,onResizeStart:b=$r,onResize:x=$r,onResizeStop:S=$r,onDrop:w=$r,onDropDragOver:T=$r}=e,E=(0,Z.useMemo)(()=>({...Cn,...r}),[r]),D=(0,Z.useMemo)(()=>({...wn,...i}),[i]),ee=(0,Z.useMemo)(()=>({...Tn,...a}),[a]),O=(0,Z.useMemo)(()=>({...En,...o}),[o]),{cols:k,rowHeight:A,maxRows:j,margin:M,containerPadding:N}=E,{enabled:P,bounded:F,handle:I,cancel:L,threshold:R,allowMobileScroll:te}=D,{enabled:ne,handles:re,handleComponent:ie}=ee,{enabled:z,defaultItem:ae,onDragOver:oe,touchEnabled:se=!0,touchDragSource:ce=`[data-rgl-draggable]`}=O,B=c??In(`vertical`),le=B.type,V=B.allowOverlap,ue=B.preventCollision??!1,de=(0,Z.useMemo)(()=>d??{i:`__dropping-elem__`,...ae},[d,ae]),fe=s.type===`transform`,H=s.scale,U=N??M,[pe,W]=(0,Z.useState)(!1),[G,K]=(0,Z.useState)(()=>ri(u,t,k,B)),[q,J]=(0,Z.useState)(null),[me,he]=(0,Z.useState)(!1),[Y,ge]=(0,Z.useState)(null),[_e,ve]=(0,Z.useState)(),ye=(0,Z.useRef)(void 0);ye.current=_e;let be=(0,Z.useRef)(null),xe=(0,Z.useRef)(null),Se=(0,Z.useRef)(null),Ce=(0,Z.useRef)(0),we=(0,Z.useRef)(G),Te=(0,Z.useRef)(u),Ee=(0,Z.useRef)(t),De=(0,Z.useRef)(le),Oe=(0,Z.useRef)(null),ke=(0,Z.useRef)(!1),Ae=(0,Z.useRef)(null),je=(0,Z.useRef)(null);je.current=Y;let Me=(0,Z.useRef)(w);(0,Z.useLayoutEffect)(()=>{Me.current=w});let Ne=(0,Z.useRef)(G);Ne.current=G,(0,Z.useEffect)(()=>{W(!0),(0,Gr.deepEqual)(G,u)||g(G)},[]),(0,Z.useEffect)(()=>{if(q||Y)return;let e=!(0,Gr.deepEqual)(u,Te.current),n=!ni(t,Ee.current),r=le!==De.current;if(e||n||r){let n=ri(e?u:G,t,k,B);(0,Gr.deepEqual)(n,G)||K(n)}Te.current=u,Ee.current=t,De.current=le},[u,t,k,le,B,q,Y,G]),(0,Z.useEffect)(()=>{if(!q&&!Y&&!(0,Gr.deepEqual)(G,we.current)){we.current=G;let e=G.filter(e=>e.i!==de.i);g(e)}},[G,q,Y,g,de.i]);let Pe=(0,Z.useMemo)(()=>{if(!f)return;let e=Jt(G),t=U[1];return e*A+(e-1)*M[1]+t*2+`px`},[f,G,A,M,U]),Fe=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=Yt(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};be.current=Zt(a),Se.current=i,J(o),_(i,a,a,null,r.e,r.node)},[_]),Ie=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=be.current,o=Yt(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=nn(i,o,t,n,!0,ue,le,k,V);v(c,a,o,s,r.e,r.node),K(B.compact(c,k)),J(s)},[ue,le,k,V,B,v]),Le=(0,Z.useCallback)((e,t,n,r)=>{if(!be.current)return;let i=Ne.current,a=be.current,o=Yt(i,e);if(!o)return;let s=nn(i,o,t,n,!0,ue,le,k,V),c=B.compact(s,k);y(c,a,o,null,r.e,r.node);let l=Se.current;be.current=null,Se.current=null,J(null),K(c),l&&!(0,Gr.deepEqual)(l,c)&&g(c)},[ue,le,k,V,B,y,g]),Re=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=Yt(i,e);a&&(xe.current=Zt(a),Se.current=i,he(!0),b(i,a,a,null,r.e,r.node))},[b]),ze=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=xe.current,{handle:o}=r,s=!1,c,l,[u,d]=en(i,e,e=>(c=e.x,l=e.y,[`sw`,`w`,`nw`,`n`,`ne`].includes(o)&&([`sw`,`nw`,`w`].includes(o)&&(c=e.x+(e.w-t),t=e.x!==c&&c<0?e.w:t,c=c<0?0:c),[`ne`,`n`,`nw`].includes(o)&&(l=e.y+(e.h-n),n=e.y!==l&&l<0?e.h:n,l=l<0?0:l),s=!0),ue&&!V&&Wt(i,{...e,w:t,h:n,x:c??e.x,y:l??e.y}).filter(t=>t.i!==e.i).length>0&&(l=e.y,n=e.h,c=e.x,t=e.w,s=!1),e.w=t,e.h=n,(o===`n`||o===`nw`||o===`ne`)&&(e.y=l??e.y),e));if(!d)return;let f=u;s&&c!==void 0&&l!==void 0&&(f=nn(u,d,c,l,!0,ue,le,k,V));let p={w:d.w,h:d.h,x:d.x,y:d.y,i:e,static:!0};x(f,a,d,p,r.e,r.node);let m=B.compact(f,k);if(o===`n`||o===`nw`||o===`ne`){let t=m.find(t=>t.i===e);t&&(t.y=d.y)}K(m),J(p)},[ue,le,k,V,B,x]),Be=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=xe.current,o=Yt(i,e),s=B.compact(i,k);S(s,a,o??null,null,r.e,r.node);let c=Se.current;xe.current=null,Se.current=null,J(null),he(!1),K(s),c&&!(0,Gr.deepEqual)(c,s)&&g(s)},[k,B,S,g]),Ve=(0,Z.useCallback)((e,t,n,r)=>{if(r)ye.current&&(ye.current.left!==t.left||ye.current.top!==t.top)&&(ve(t),K(t=>t.map(t=>t.i===e.i&&(t.x!==n.x||t.y!==n.y)?{...t,x:n.x,y:n.y}:t)));else{ge((0,X.jsx)(`div`,{},e.i)),ve(t);let r=Ne.current.filter(t=>t.i!==e.i);K([...r,{...e,x:n.x,y:n.y,static:!1,isDraggable:!0}])}},[]),He=(0,Z.useCallback)((e,t,r)=>{let i=Oe.current;if(!i)return;let{newDroppingPosition:a,calculatedXY:o}=Qr({clientX:e,clientY:t,gridElement:i,droppingItem:de,event:r,transformScale:H,cols:k,margin:M,maxRows:j,rowHeight:A,width:n,containerPadding:U});Ve(de,a,o,!!je.current)},[de,H,k,M,j,A,n,U,Ve]),Ue=(0,Z.useCallback)(()=>{let e=Ne.current;if(!e.some(e=>e.i===de.i)){ge(null),J(null),ve(void 0);return}let t=B.compact(e.filter(e=>e.i!==de.i),k);K(t),ge(null),J(null),ve(void 0)},[de.i,k,B]),We=(0,Z.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),ti&&!e.nativeEvent.target?.classList.contains(ei))return!1;let t=oe?oe(e.nativeEvent):T(e);if(t===!1)return Y&&Ue(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...de,...a},{newDroppingPosition:s,calculatedXY:c}=Qr({clientX:e.clientX,clientY:e.clientY,gridElement:e.currentTarget,droppingItem:o,event:e.nativeEvent,dragOffsetX:r,dragOffsetY:i,transformScale:H,cols:k,margin:M,maxRows:j,rowHeight:A,width:n,containerPadding:U});Ve(o,s,c,!!Y)},[Y,de,oe,T,Ue,Ve,H,k,M,j,A,n,U]),Ge=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ce.current--,Ce.current<0&&(Ce.current=0),Ce.current===0&&Ue()},[Ue]),Ke=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ce.current++},[]),qe=(0,Z.useCallback)(e=>{let t=Ne.current,n=t.find(e=>e.i===de.i);Ue(),Me.current(t,n,e)},[de.i,Ue]),Je=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ce.current=0,qe(e.nativeEvent)},[qe]);(0,Z.useEffect)(()=>{if(!z||!se)return;let e=Oe.current;if(!e)return;let t=(t,n)=>{let r=document.elementFromPoint(t,n);return r?e.contains(r):!1},n=e=>e instanceof HTMLElement&&e.closest(ce)!==null,r=e=>{let t=e.changedTouches;if(!t||t.length===0)return;let n=Ae.current;if(n===null)return t[0];for(let e=0;e{if(!n(e.target)||Ae.current!==null)return;e.preventDefault();let t=e.changedTouches?.[0];t&&(Ae.current=t.identifier,ke.current=!0)},a=e=>{if(!ke.current)return;e.preventDefault();let n=r(e);if(n){if(!t(n.clientX,n.clientY)){je.current&&Ue();return}He(n.clientX,n.clientY,e)}},o=e=>{if(!ke.current)return;e.preventDefault();let n=r(e);if(ke.current=!1,Ae.current=null,n){if(!t(n.clientX,n.clientY)){Ue();return}qe(e)}},s=()=>{ke.current&&(ke.current=!1,Ae.current=null,Ue())},c={passive:!1};return document.addEventListener(`touchstart`,i,c),document.addEventListener(`touchmove`,a,c),document.addEventListener(`touchend`,o,c),document.addEventListener(`touchcancel`,s,c),()=>{document.removeEventListener(`touchstart`,i,c),document.removeEventListener(`touchmove`,a,c),document.removeEventListener(`touchend`,o,c),document.removeEventListener(`touchcancel`,s,c)}},[z,se,ce,He,Ue,qe,de.i]);let Ye=(0,Z.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=Yt(G,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&P,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&ne,o=r.resizeHandles||[...re],c=i&&F&&r.isBounded!==!1,u=ie;return(0,X.jsx)(Zr,{containerWidth:n,cols:k,margin:M,containerPadding:U,maxRows:j,rowHeight:A,cancel:L,handle:I,onDragStart:Fe,onDrag:Ie,onDragStop:Le,onResizeStart:Re,onResize:ze,onResizeStop:Be,isDraggable:i,isResizable:a,isBounded:c,allowMobileScroll:te,useCSSTransforms:fe&&pe,usePercentages:!pe,transformScale:H,positionStrategy:s,dragThreshold:R,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:t?_e:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:G,children:e},r.i)},[G,n,k,M,U,j,A,L,I,Fe,Ie,Le,Re,ze,Be,P,ne,F,fe,pe,H,s,R,_e,re,ie,l]),Xe=()=>q?(0,X.jsx)(Zr,{w:q.w,h:q.h,x:q.x,y:q.y,i:q.i,className:`react-grid-placeholder ${me?`placeholder-resizing`:``}`,containerWidth:n,cols:k,margin:M,containerPadding:U,maxRows:j,rowHeight:A,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:fe,transformScale:H,constraints:l,layout:G,children:(0,X.jsx)(`div`,{})}):null,Ze=(0,Z.useCallback)(e=>{Oe.current=e,typeof h==`function`?h(e):h&&`current`in h&&(h.current=e)},[h]),Qe=C(ei,p),$e={height:Pe,...m};return(0,X.jsxs)(`div`,{ref:Ze,className:Qe,style:$e,onDrop:z?Je:void 0,onDragLeave:z?Ge:void 0,onDragEnter:z?Ke:void 0,onDragOver:z?We:void 0,children:[Z.Children.map(t,e=>Z.isValidElement(e)?Ye(e):null),z&&Y&&Ye(Y,!0),Xe()]})}var ai={lg:1200,md:996,sm:768,xs:480,xxs:0},oi={lg:12,md:10,sm:6,xs:4,xxs:2},si=()=>{};function ci(e,t,n,r,i=!1){let a=[];Z.Children.forEach(t,t=>{if(!Z.isValidElement(t)||t.key===null)return;let n=String(t.key),r=t.props[`data-grid`],o=e.find(e=>e.i===n);o?i&&r?a.push({...o,i:n,w:r.w??o.w,h:r.h??o.h,minW:r.minW??o.minW,maxW:r.maxW??o.maxW,minH:r.minH??o.minH,maxH:r.maxH??o.maxH}):a.push({...o,i:n}):r?a.push({i:n,x:r.x??0,y:r.y??0,w:r.w??1,h:r.h??1,minW:r.minW,maxW:r.maxW,minH:r.minH,maxH:r.maxH,static:r.static,isDraggable:r.isDraggable,isResizable:r.isResizable,resizeHandles:r.resizeHandles,isBounded:r.isBounded}):a.push({i:n,x:0,y:Jt(a),w:1,h:1})});let o=tn(a,{cols:n});return r.compact(o,n)}function li(e){let{children:t,width:n,breakpoint:r,breakpoints:i=ai,cols:a=oi,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=si,onLayoutChange:p=si,onWidthChange:m=si,...h}=e,g=d??In(`vertical`),_=g.type,v=g.allowOverlap,y=(0,Z.useMemo)(()=>r??Rn(i,n),[]),b=(0,Z.useMemo)(()=>zn(y,a),[y,a]),x=(0,Z.useMemo)(()=>Bn(o,i,y,y,b,_),[]),[S,C]=(0,Z.useState)(y),[w,T]=(0,Z.useState)(b),[E,D]=(0,Z.useState)(x),[ee,O]=(0,Z.useState)(o),k=(0,Z.useRef)(n),A=(0,Z.useRef)(r),j=(0,Z.useRef)(i),M=(0,Z.useRef)(a),N=(0,Z.useRef)(o),P=(0,Z.useRef)(_),F=(0,Z.useRef)(ee);(0,Z.useEffect)(()=>{F.current=ee},[ee]);let I=(0,Z.useMemo)(()=>(0,Gr.deepEqual)(o,N.current)?null:Bn(o,i,S,S,w,g),[o,i,S,w,g]),L=I??E;(0,Z.useEffect)(()=>{I!==null&&(D(I),O(o),F.current=o,N.current=o)},[I,o]),(0,Z.useEffect)(()=>{if(_!==P.current){let e=g.compact(Qt(L),w),t={...F.current,[S]:e};D(e),O(t),F.current=t,p(e,t),P.current=_}},[_,g,L,w,v,S,p]),(0,Z.useEffect)(()=>{let e=n!==k.current,o=r!==A.current,s=!(0,Gr.deepEqual)(i,j.current),c=!(0,Gr.deepEqual)(a,M.current);if(e||o||s||c){let e=r??Rn(i,n),o=zn(e,a),d=S;if(d!==e||s||c){let n={...F.current};n[d]||(n[d]=Qt(E));let r=Bn(n,i,e,d,o,g),a=!n[e];r=ci(r,t,o,g,a),n[e]=r,C(e),T(o),D(r),O(n),F.current=n,f(e,o),p(r,n)}let h=Vn(l,e),_=u?Vn(u,e):null;m(n,h,o,_),k.current=n,A.current=r,j.current=i,M.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let R=(0,Z.useCallback)(e=>{let t={...F.current,[S]:e};D(e),O(t),F.current=t,p(e,t)},[S,p]),te=(0,Z.useMemo)(()=>Vn(l,S),[l,S]),ne=(0,Z.useMemo)(()=>u===null?null:Vn(u,S),[u,S]),re=(0,Z.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:te,containerPadding:ne}),[w,s,c,te,ne]);return(0,X.jsx)(ii,{...h,width:n,gridConfig:re,compactor:g,onLayoutChange:R,layout:L,children:t})}var ui=Z.forwardRef(function(e,t){let{innerRef:n,...r}=e,i=n??t;return(0,X.jsx)(li,{...r,innerRef:i})});ui.displayName=`ResponsiveGridLayout`;function di(e,t,n){if(e.kind===`constant`)return e.value??``;let r=e.kind===`custom`?e.options?.map(e=>({value:e}))??[]:n===null?[]:n,i=t[e.name],a=!e.multi&&Array.isArray(i)&&i.length===0?void 0:i;if(a===`$__all`){if(e.include_all)return kt}else if(a!==void 0){if(e.kind===`text`||r===void 0)return a;let t=new Set(r.map(e=>e.value));if(Array.isArray(a)){if(a.length===0&&e.multi)return[];let n=a.filter(e=>t.has(e));if(n.length>0)return n}else if(t.has(a))return a}return e.default?e.default:e.include_all?kt:r?.[0]?.value??``}var fi=(e,t)=>e.replace(/\$([a-z][a-z0-9_]*)/g,(e,n)=>{let r=t[n];return r===void 0?e:r===`$__all`?`all`:Array.isArray(r)?r.join(`, `):r});function pi(e,t,n){let r={};for(let i of e??[]){let e=di(i,t,n?.[i.name]);(i.kind!==`query`||e!==``)&&(r[i.name]=e)}return r}function mi(e){return`Explain the panel “${e.title}”`}function hi(e){return`Fix the panel “${e.title}”`}function gi(e){return[{description:`Observed panel diagnostics`,value:JSON.stringify(e)}]}var _i=(0,Z.lazy)(()=>ae(()=>import(`./panel-editor-BVRFoShZ.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]))),vi=0;function yi(e){let t;do t=`p_${Date.now().toString(36)}_${(++vi).toString(36)}_${Math.random().toString(36).slice(2,10)}`;while(e.some(e=>e.id===t));return t}function bi({dashboardId:e,version:t,spec:n,vars:r,results:i,fetching:a,annotations:o,fetchingIds:c=[],staleAt:l=new Map,time:u=n.time,onEditExit:d,editing:p,view:m,agentAvailable:h,canManage:g=!1,onOpenChat:_,onVariable:v,onRetry:y,onPoint:b,onZoom:x,onZoomReset:C,onWiden:w,zoomed:E,onView:D,onVisible:ee,onRangePending:O,shortcutScope:k,onShortcuts:A,overlayOpen:j,returnViewFocus:M}){let P=Be(),[I,L]=(0,Z.useState)(),[R,te]=(0,Z.useState)(()=>n.panels.map(e=>({i:e.id,x:e.grid?.x??0,y:e.grid?.y??0,w:e.grid?.w??6,h:e.grid?.h??Nt(e)})));(0,Z.useEffect)(()=>{te(n.panels.map(e=>({i:e.id,x:e.grid?.x??0,y:e.grid?.y??0,w:e.grid?.w??6,h:e.grid?.h??Nt(e)})))},[n]);let[ne,ie]=(0,Z.useState)(()=>window.innerHeight),[z,ae]=(0,Z.useState)();(0,Z.useEffect)(()=>{let e=()=>ie(window.innerHeight);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let oe=(0,Z.useRef)(null),se=(0,Z.useRef)(new Map),B=(0,Z.useRef)(null),le=(0,Z.useRef)(null),V=()=>{let e=I?.panel?.id;L(void 0),requestAnimationFrame(()=>(le.current?.isConnected?le.current:se.current.get(e??``))?.focus())},de=(0,Z.useRef)(m);m&&(de.current=m);let[H,U]=(0,Z.useState)(0),pe=H>0,W=p&&(H>=1100?`lg`:H>=800?`md`:`sm`)==`lg`;(0,Z.useLayoutEffect)(()=>{if(!oe.current)return;U(Math.max(0,Math.round(oe.current.getBoundingClientRect().width)));let e=new ResizeObserver(([e])=>{e&&U(Math.max(0,Math.round(e.contentRect.width)))});return e.observe(oe.current),()=>e.disconnect()},[]);let G=(0,Z.useRef)(ee);G.current=ee,(0,Z.useEffect)(()=>{if(!pe||!oe.current||typeof IntersectionObserver>`u`)return;let e=new Set(n.panels.map(e=>e.id)),t=new IntersectionObserver(t=>{for(let n of t){let t=n.target.dataset.panel;t&&(n.isIntersecting?e.add(t):e.delete(t))}m&&n.panels.some(e=>e.id===m)&&e.add(m),G.current([...e])},{rootMargin:`200px`});return oe.current.querySelectorAll(`.react-grid-item[data-panel]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[n,m,pe]);let K=(0,Z.useMemo)(()=>n.panels.some(e=>{let t=R.find(t=>t.i===e.id);return t&&(t.x!==e.grid?.x||t.y!==e.grid?.y||t.w!==e.grid?.w||t.h!==e.grid?.h)}),[R,n]),q=e=>({...n,panels:e.map(e=>{let t=R.find(t=>t.i===e.id);return t?{...e,grid:{x:t.x,y:t.y,w:t.w,h:t.h}}:e})}),J=He({mutationFn:()=>Y(e,q(n.panels),t,`Edited layout`),onSuccess:t=>{P.setQueryData([`dashboard`,e],t)}}),me=He({mutationFn:r=>K?Y(e,q(n.panels.filter(e=>e.id!==r)),t,`Removed a panel and saved layout`):Te(e,[{op:`remove_panel`,id:r}],t,`Removed a panel`),onSuccess:t=>{P.setQueryData([`dashboard`,e],t)}}),he=He({mutationFn:r=>{let i={...r,id:yi(n.panels),title:`${Array.from(r.title).slice(0,73).join(``)} (copy)`,grid:void 0};if(K){let a=[...n.panels];return a.splice(a.findIndex(e=>e.id===r.id)+1,0,i),Y(e,q(a),t,`Duplicated a panel and saved layout`)}return Te(e,[{op:`add_panel`,after:r.id,panel:i}],t,`Duplicated a panel`)},onSuccess:t=>{P.setQueryData([`dashboard`,e],t)}});(0,Z.useEffect)(()=>{p||(J.reset(),me.reset(),he.reset())},[p]);let ge=()=>{J.reset(),me.reset(),he.reset(),d?.(),P.invalidateQueries({queryKey:[`dashboard`,e]})},_e=async e=>{let t=new URL(window.location.href);t.searchParams.set(`view`,e),t.searchParams.delete(`edit`);try{await navigator.clipboard.writeText(t.toString()),ae(`Link copied`)}catch{ae(`Copy this URL: ${t.toString()}`)}},ve=`dashboard-${e}`,ye=n=>({dashboard_id:e,version:t,panel_id:n.id,title:fi(n.title,r),from_ms:i.get(n.id)?.from_ms,to_ms:i.get(n.id)?.to_ms,vars:r,error:i.get(n.id)?.error,status:i.get(n.id)?.status,diagnosis:i.get(n.id)?.diagnosis,stale_since:l.get(n.id),truncated:i.has(n.id)?!!(i.get(n.id)?.frame?.truncated||i.get(n.id)?.previous?.truncated):void 0,note:i.get(n.id)?.frame?.note,spec:{...n,dashboard_time:u}}),be=(s,d,f=!1)=>(0,X.jsx)(ce,{panel:s,title:fi(s.title,r),result:i.get(s.id),loading:a&&c.includes(s.id),height:d,group:ve,editing:W&&!f,agentAvailable:h,suspended:!f&&s.id===m,menuRef:f?B:e=>{e?se.current.set(s.id,e):se.current.delete(s.id)},compare:u.compare===`previous_period`,range:s.time?.range??u.range,annotations:o,vars:r,onVariable:v,...ue(s,i.get(s.id),v,b?e=>b(s,e):void 0),onRangePending:e=>O?.(s.id,e),onZoom:x,zoomed:E,onZoomReset:C,onWiden:w,onRetry:y?()=>y(s.id):void 0,onView:()=>D(s.id),onCopyLink:()=>{_e(s.id)},onEdit:g&&e&&(s.query||typeof s.sql==`string`)?()=>{le.current=f?B.current:se.current.get(s.id)??null,L({panel:s,spec:n,version:t})}:void 0,onExplain:h&&e?()=>_(mi(ye(s)),{answer_only:!0,context:gi(ye(s))}):void 0,onFix:h&&e&&g?()=>_(hi(ye(s)),{context:gi(ye(s))}):void 0,staleAt:l.get(s.id),onDuplicate:W&&!f?()=>he.mutate(s):void 0,onRemove:W&&!f?()=>me.mutate(s.id):void 0}),xe=n.panels.find(e=>e.id===m),Se=p?J.error??me.error??he.error:null,Ce=Se instanceof ze&&Se.code===`dashboard_version_conflict`,we=e=>{W&&te(e.map(({i:e,x:t,y:n,w:r,h:i})=>({i:e,x:t,y:n,w:r,h:i})))};return(0,X.jsxs)(`div`,{ref:oe,style:{minWidth:0},children:[p&&(0,X.jsxs)(f,{justify:`space-between`,mb:`sm`,p:`xs`,style:{border:`1px dashed var(--mantine-color-default-border)`,borderRadius:8},children:[(0,X.jsx)(N,{size:`sm`,c:`dimmed`,children:W?`Drag a panel by its title and resize it from the corner. Changes are saved as a new version.`:`The layout can be edited only on a wider screen.`}),(0,X.jsxs)(f,{gap:`xs`,children:[g&&e&&(0,X.jsx)(F,{size:`compact-sm`,variant:`default`,onClick:e=>{le.current=e.currentTarget,L({spec:n,version:t})},children:`Add panel`}),(0,X.jsx)(F,{size:`compact-sm`,disabled:!K||!W,loading:J.isPending,onClick:()=>J.mutate(),children:`Save layout`})]})]}),Ce&&(0,X.jsx)(S,{mb:`sm`,children:(0,X.jsxs)(re,{tone:`warning`,children:[`Someone saved this dashboard since you opened it. Load the latest version, then redo your change. `,(0,X.jsx)(F,{size:`compact-sm`,onClick:ge,children:`Load latest`})]})}),Se&&!Ce&&(0,X.jsx)(S,{mb:`sm`,children:(0,X.jsx)(re,{tone:`danger`,children:Se.message})}),z&&(0,X.jsx)(S,{mb:`sm`,children:(0,X.jsx)(re,{tone:`info`,children:z})}),!pe&&(0,X.jsx)(`div`,{"data-grid-placeholder":!0,style:{height:At(Math.max(1,...R.map(e=>e.y+e.h)))}}),pe&&(0,X.jsx)(ui,{width:H,className:`dashboard-grid${W?` dashboard-grid-editing`:``}`,layouts:{lg:R,md:R,sm:R.map(e=>({...e,x:0,w:12}))},breakpoints:{lg:1100,md:800,sm:0},cols:{lg:12,md:12,sm:12},rowHeight:40,margin:[12,12],containerPadding:[0,0],compactor:An,dragConfig:{enabled:W,handle:`.panel-drag`,cancel:`button`},resizeConfig:{enabled:W},onDragStop:we,onResizeStop:we,children:n.panels.map(e=>{let t=R.find(t=>t.i===e.id);return(0,X.jsx)(`div`,{"data-panel":e.id,children:be(e,At(t?.h??6))},e.id)})}),(0,X.jsx)(fe,{shortcutScope:k,onShortcuts:A,escapeEnabled:!j&&!I,opened:!!m,onClose:()=>D(void 0),title:xe?fi(xe.title,r):`Missing panel`,returnFocusTo:()=>M?.(de.current)??se.current.get(de.current??``)??se.current.values().next().value,children:xe?(0,X.jsx)(`div`,{style:{height:`calc(100vh - 120px)`},children:be(xe,Math.max(40,ne-140),!0)}):(0,X.jsx)(S,{children:(0,X.jsx)(re,{tone:`warning`,children:`This panel is missing from the dashboard. The shared link may be out of date.`})})}),I&&e&&(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(s,{opened:!0,onClose:V,title:`Loading the panel editor`,children:(0,X.jsx)(T,{state:`loading`,loadingLabel:`Loading the panel editor`,rows:3})}),children:(0,X.jsx)(_i,{dashboardId:e,version:I.version,spec:q(I.spec.panels),layoutChanged:W&&K,panel:I.panel,time:u,vars:r,onClose:V})})]})}function xi({spec:e,onClose:t,onCreated:n}){let r=Be(),[i,a]=(0,Z.useState)(`${e.name} copy`),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(),d=async()=>{c(!0),u(void 0);try{let t=await ye({...e,name:i.trim()});r.invalidateQueries({queryKey:Se}),n(t.id)}catch(e){u(e instanceof Error?e.message:`Duplicate failed`)}finally{c(!1)}};return(0,X.jsx)(s,{opened:!0,onClose:()=>{o||t()},title:`Duplicate dashboard`,children:(0,X.jsxs)(x,{gap:`md`,children:[(0,X.jsx)(z,{label:`New dashboard name`,value:i,onChange:e=>a(e.currentTarget.value),"data-autofocus":!0}),l&&(0,X.jsx)(S,{children:(0,X.jsx)(re,{tone:`danger`,children:l})}),(0,X.jsxs)(f,{justify:`flex-end`,gap:`xs`,children:[(0,X.jsx)(F,{variant:`default`,disabled:o,onClick:t,children:`Cancel`}),(0,X.jsx)(F,{loading:o,disabled:!i.trim()||i.trim()===e.name,onClick:()=>void d(),children:`Duplicate`})]})]})})}var Si=(e,t)=>!(t instanceof ze&&t.status<500)&&e<2,Ci=(e,t)=>!(t instanceof ze&&t.code===`timeout`)&&Si(e,t),wi=e=>({panels:e.panels.map(({grid:e,...t})=>t),variables:e.variables,time:e.time,annotations:e.annotations});function Ti(e,t,n,r,i){return[`panels`,JSON.stringify([e,wi(t),n,r,i])]}function Ei(e,t,n,r){return[`variables`,e,wi(t),n,r]}var Di=2;async function Oi(e,t,n,r=[],i=!1){let a=r.filter(t=>e.panels?.includes(t)),o=e.panels?.filter(e=>!a.includes(e)),s=a.length&&!o?.length?[]:await we(a.length?{...e,panels:o}:e,t,n,i);for(let r=0;re.reason===`busy`))break}let c=new Set(e.dashboard.panels.filter(e=>[`timeseries`,`heatmap`,`state_timeline`].includes(e.viz)).map(e=>e.id)),l=s.filter(e=>c.has(e.id)&&e.from_ms!==void 0&&e.to_ms!==void 0&&e.from_mse.from_ms)),d=Math.max(...l.map(e=>e.to_ms));try{let e=await he({from:new Date(u).toISOString(),to:new Date(d).toISOString()},t);return{results:s,annotations:e}}catch(e){if(t?.aborted)throw e;return{results:s,annotation_error:e instanceof Error?e.message:`Annotations unavailable`}}}var ki={off:!1,"10s":1e4,"30s":3e4,"1m":6e4,"5m":3e5},Ai=0;function ji(e,t){let[n,r]=e.queryKey;if(n!==`panels`||typeof r!=`string`)return!1;try{return JSON.parse(r)[0]===t}catch{return!1}}function Mi({dashboardId:e,spec:t,time:n,vars:r,compare:i,widths:a,visible:o,refresh:s,enabled:c=!0}){let l=(0,Z.useMemo)(()=>Object.fromEntries(Object.entries(a).map(([e,t])=>[e,Math.max(100,Math.round(t/100)*100)])),[a]),u=Ti(e,t,n,r,i),d=u[1],f=o.filter(e=>t.panels.some(t=>t.id===e)),p=(0,Z.useRef)([]),m=(0,Z.useRef)(new Set),h=(0,Z.useRef)(void 0),g=(0,Z.useRef)(null),_=(0,Z.useRef)(!1),v=(0,Z.useRef)(!1),y=(0,Z.useRef)(null),b=(0,Z.useRef)({key:d,ids:new Set}),[x,S]=(0,Z.useState)({key:d}),[C,w]=(0,Z.useState)({key:d,results:new Map,updated:new Map,stale:new Set,receivedAt:0}),T=f.length===0&&C.key===d&&C.receivedAt>0,E=c&&t.panels.some(e=>e.viz!==`text`),D=Ve({queryKey:u,queryFn:({signal:e})=>{if(T&&g.current?.key!==d)return p.current=[],Promise.resolve({results:[],hasTimePanels:!1,batch:++Ai});let a=g.current?.key===d?g.current.ids:f;p.current=(a.length?[...a]:t.panels.map(e=>e.id)).sort(),b.current.key!==d&&(b.current={key:d,ids:new Set});for(let e of p.current)b.current.ids.add(e);let o=[...p.current],s=v.current;v.current=!1;let c=m.current=new Set,u=t=>{if(e.aborted)return;c.add(t.id);let n=Date.now(),r=++Ai;w(e=>Ni(e,d,[H(t,o)],n,r))},_=C.key===d?o.filter(e=>C.results.get(e)?.reason===`busy`):[];return Oi({dashboard:t,panels:o,time:n,vars:r,widths:l,compare:i},e,u,_,s).then(e=>{let n=new Set(e.results.map(e=>e.id)),r=o.filter(e=>!n.has(e)&&!_.includes(e)&&t.panels.find(t=>t.id===e)?.viz!==`text`).map(e=>({id:e,status:`error`,elapsed_ms:0,error:`No result was returned for this panel; refresh to retry.`,request_error:o}));return{...e,batch:++Ai,results:[...e.results.map(e=>H(e,o)),...r],hasTimePanels:t.panels.some(e=>o.includes(e.id)&&[`timeseries`,`heatmap`,`state_timeline`].includes(e.viz))}}).catch(n=>{throw e.aborted||(h.current={key:d,ids:o.filter(e=>!c.has(e)&&t.panels.find(t=>t.id===e)?.viz!==`text`),error:n instanceof Error?n.message:String(n),retryable:!(n instanceof ze)||n.status===408||n.status===429||n.status>=500}),n})},retry:Ci,enabled:E,refetchInterval:T?!1:ki[s]??3e4,staleTime:5e3,placeholderData:e=>e}),ee=D.error&&h.current?.key===d?h.current:void 0,O=(0,Z.useMemo)(()=>Ni(C,d,D.isPlaceholderData?void 0:D.data?.results,D.dataUpdatedAt,D.data?.batch,ee),[C,d,D.data,D.dataUpdatedAt,D.isPlaceholderData,D.error,D.errorUpdatedAt]),k=O.results,A=D.isPlaceholderData?void 0:D.data?.hasTimePanels?D.data:x.key===d?x:void 0;(0,Z.useEffect)(()=>{!D.isPlaceholderData&&D.data?.hasTimePanels&&S({key:d,annotations:D.data.annotations,annotation_error:D.data.annotation_error})},[d,D.data,D.isPlaceholderData]),(0,Z.useEffect)(()=>{D.isPlaceholderData||w(e=>Ni(e,d,D.data?.results,D.dataUpdatedAt,D.data?.batch,ee))},[d,D.data,D.dataUpdatedAt,D.isPlaceholderData,D.error,D.errorUpdatedAt]);let j=new Map([...O.stale].flatMap(e=>{let t=O.updated.get(e);return t?[[e,t]]:[]})),M=(D.data?.results??[]).find(e=>e.status===`error`&&e.reason!==`busy`&&O.stale.has(e.id)),N=(D.data?.results??[]).flatMap(e=>e.reason===`busy`&&O.stale.has(e.id)?[O.updated.get(e.id)??0]:[]),P=Math.max(0,...[...O.updated].filter(([e])=>{let t=O.results.get(e);return t?.reason!==`busy`||t.frame!==void 0}).map(([,e])=>e));(0,Z.useEffect)(()=>{if(b.current.key===d)for(let e of b.current.ids)k.get(e)?.reason===`busy`&&!f.includes(e)&&b.current.ids.delete(e)},[o,d,k]),(0,Z.useEffect)(()=>{if(!E||D.isFetching||_.current||y.current?.key===d||g.current?.key===d)return;let e=b.current.key===d?b.current.ids:new Set,n=[...new Set(f.filter(n=>(!k.has(n)||k.get(n)?.reason===`busy`)&&!e.has(n)&&t.panels.find(e=>e.id===n)?.viz!==`text`))].sort();if(!n.length)return;let r={key:d,ids:n};g.current=r,D.refetch({cancelRefetch:!1}).finally(()=>{g.current===r&&(g.current=null)})},[o,E,d,D.isFetching,D.error,D.refetch,k,t.panels]),(0,Z.useEffect)(()=>{!D.isFetching&&y.current?.key!==d&&_.current&&(_.current=!1,g.current=null,E&&!T&&(v.current=!0,D.refetch({cancelRefetch:!1})))},[D.isFetching,d,E,T,D.refetch]);let F=e=>{let t={key:d,ids:e};g.current=t,D.refetch({cancelRefetch:!1}).finally(()=>{g.current===t&&(g.current=null)})};return(0,Z.useEffect)(()=>{if(D.isFetching||!y.current)return;let e=y.current;if(y.current=null,e.key!==d||!E)return;let n=[...e.ids].filter(e=>t.panels.some(t=>t.id===e&&t.viz!==`text`)&&k.get(e)?.request_error).sort();n.length&&F(n)},[D.isFetching,d,E,k,t.panels]),{retry:e=>{if(E&&t.panels.some(t=>t.id===e&&t.viz!==`text`)&&k.get(e)?.request_error){if(D.isFetching){y.current?.key!==d&&(y.current={key:d,ids:new Set}),y.current.ids.add(e);return}F([e])}},results:k,staleAt:j,annotations:A?.annotations,annotationError:A?.annotation_error,fetchingIds:D.isFetching?p.current.filter(e=>!m.current.has(e)):[],fetching:D.isFetching,error:D.error??(M?Error(M.error??`Panel refresh failed`):null),updatedAt:P||null,skippedAt:N.length?Math.min(...N):null,refetch:()=>{if(E&&!T){if(D.isFetching){g.current?.key===d&&(_.current=!0);return}v.current=!0,D.refetch({cancelRefetch:!1})}}}}function Ni(e,t,n,r,i,a){let o=e.key===t?{key:t,results:new Map(e.results),updated:new Map(e.updated),stale:new Set(e.stale),receivedAt:e.receivedAt,receivedBatch:e.receivedBatch}:{key:t,results:new Map,updated:new Map,stale:new Set,receivedAt:0},s=n&&i!==void 0&&(o.receivedBatch===void 0||i>o.receivedBatch);for(let e of s?n:[])e.status===`error`&&o.results.get(e.id)?.frame?(o.stale.add(e.id),o.results.set(e.id,{...o.results.get(e.id),error:e.error,reason:e.reason,request_error:e.request_error})):(o.results.set(e.id,e),o.updated.set(e.id,r),o.stale.delete(e.id));s&&(o.receivedAt=r,o.receivedBatch=i);for(let e of a?.ids??[]){let t=o.results.get(e);t?.frame?(o.stale.add(e),o.results.set(e,{...t,error:a.error,reason:void 0,request_error:a.retryable?a.ids:void 0})):o.results.set(e,{id:e,status:`error`,elapsed_ms:0,error:a.error,request_error:a.retryable?a.ids:void 0})}return o}function Pi(e,t){return e.queryKey[0]===`variables`&&e.queryKey[1]===t}function Fi(e,t,n,r,i,a=!1){let o=!!t.variables?.some(e=>e.kind===`query`),s=Ve({queryKey:Ei(e,t,n,r),queryFn:async({signal:e})=>{let a=await i({dashboard:t,time:n,vars:r},e);return Object.fromEntries((t.variables??[]).map(e=>[e.name,a[e.name]??(e.kind===`custom`?e.options?.map(e=>({value:e})):void 0)??[]]))},enabled:o,retry:a,staleTime:6e4,placeholderData:e=>e}),c=s.isPlaceholderData?void 0:s.data,l=s.isError||(t.variables??[]).every(e=>e.kind!==`query`||r[e.name]!==void 0&&r[e.name]!==`$__all`&&(e.multi||!Array.isArray(r[e.name])||r[e.name].length>0)||!!e.default||e.include_all||c?.[e.name]!==void 0);return{...s,currentData:c,ready:l}}function Ii(e){return t=>ji(t,e)||Pi(t,`dashboard-${e}`)}function Li({id:e,currentVersion:t,currentSpec:n,opened:r,onClose:i,onRestored:a}){let o=Be(),[s,c]=(0,Z.useState)(),[l,u]=(0,Z.useState)(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(r),h=(0,Z.useRef)(0),g=(0,Z.useRef)(r);g.current=r;let _=(0,Z.useRef)(!1),v=(0,Z.useRef)(!1),y=(0,Z.useRef)(a);y.current=a,(0,Z.useEffect)(()=>(v.current=!0,()=>{v.current=!1}),[]);let b=He({mutationFn:({version:t})=>me(e,t),retry:!1,onSuccess:(t,{version:n,generation:r})=>{o.cancelQueries({queryKey:[`dashboard`,e],exact:!0}),o.cancelQueries({predicate:Ii(e)}),o.cancelQueries({queryKey:[`exemplars`]}),o.cancelQueries({queryKey:[`drill-trace`]}),o.setQueryData([`dashboard`,e],t),o.invalidateQueries({predicate:Ii(e),refetchType:`none`}),v.current&&(g.current&&r===h.current&&u({text:`Restored v${n} as v${t.version}`}),y.current(t)),o.invalidateQueries({queryKey:Se}),o.invalidateQueries({queryKey:[`dashboard-versions`,e]},{cancelRefetch:!1}),o.invalidateQueries({queryKey:[`exemplars`],refetchType:`none`}),o.invalidateQueries({queryKey:[`drill-trace`],refetchType:`none`})},onError:t=>{t instanceof ze&&t.code===`dashboard_version_not_found`&&o.invalidateQueries({queryKey:[`dashboard-versions`,e]})},onSettled:()=>{_.current=!1,v.current&&f(!1)}}),x=()=>{h.current++,b.reset(),u(void 0)};(0,Z.useEffect)(()=>{if(r){m(!0);return}h.current++,b.reset(),u(void 0),o.cancelQueries({queryKey:[`dashboard-versions`,e]}),o.cancelQueries({queryKey:[`dashboard-version`,e]})},[r,e,o,b.reset]);let S=(0,Z.useRef)(t);return(0,Z.useEffect)(()=>{S.current!==t&&(S.current=t,o.invalidateQueries({queryKey:[`dashboard-versions`,e]},{cancelRefetch:!1}))},[t,e,o]),(0,X.jsx)(oe,{opened:r,onClose:()=>{x(),i()},onExitTransitionEnd:()=>m(!1),title:`Version history`,position:`right`,size:`xl`,children:(r||p)&&(0,X.jsx)(Ri,{id:e,opened:r,currentVersion:t,currentSpec:n,selected:s,onSelect:e=>{x(),c(e)},pending:d,error:b.error,failedVersion:b.variables?.version,success:l,onRestore:e=>{_.current||(_.current=!0,f(!0),u(void 0),b.mutate({version:e,generation:h.current}))}})})}function Ri({id:e,opened:t,currentVersion:n,currentSpec:r,selected:a,onSelect:o,pending:s,error:c,failedVersion:l,success:u,onRestore:d}){let p=Ve({queryKey:[`dashboard-versions`,e],queryFn:({signal:t})=>_e(e,t),enabled:t,retry:!1}),m=a??p.data?.[0]?.version,h=Ve({queryKey:[`dashboard-version`,e,m],queryFn:({signal:t})=>Ce(e,m,t),enabled:t&&m!==void 0,retry:!1}),g=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{u&&g.current?.focus()},[u]),(0,X.jsxs)(x,{gap:`md`,"data-version-history":!0,children:[(0,X.jsx)(N,{size:`sm`,c:`dimmed`,children:`Inspect saved specs and changes. Restoring adds a new version.`}),u&&(0,X.jsx)(S,{ref:g,tabIndex:-1,role:`note`,children:(0,X.jsx)(re,{live:!1,tone:`success`,children:u.text})}),c&&l===m&&(0,X.jsx)(Hi,{error:c,version:m}),(0,X.jsxs)(S,{mih:160,children:[p.isPending&&(0,X.jsx)(T,{state:`loading`,loadingLabel:`Loading history…`,rows:3}),p.error&&(0,X.jsx)(S,{children:(0,X.jsxs)(re,{tone:`danger`,title:`History unavailable`,children:[p.error.message,(0,X.jsx)(F,{mt:`xs`,variant:`default`,size:`xs`,onClick:()=>void p.refetch(),children:`Retry history`})]})}),p.data?.length===0&&(0,X.jsx)(T,{state:`empty`,empty:{title:`No versions available.`,description:`Version history appears after a dashboard is saved.`,action:(0,X.jsx)(F,{variant:`default`,onClick:()=>void p.refetch(),children:`Retry history`})}}),!!p.data?.length&&(0,X.jsx)(L,{h:200,type:`auto`,children:(0,X.jsx)(x,{gap:`xs`,pr:`sm`,role:`list`,"aria-label":`Saved versions`,children:p.data.map(e=>(0,X.jsxs)(i,{role:`listitem`,withBorder:!0,p:`xs`,radius:`sm`,style:{borderColor:m===e.version?`var(--mantine-color-accent-filled)`:void 0},children:[(0,X.jsxs)(f,{justify:`space-between`,gap:`xs`,children:[(0,X.jsxs)(F,{color:`accent`,variant:m===e.version?`light`:`subtle`,size:`compact-sm`,"aria-pressed":m===e.version,onClick:()=>o(e.version),children:[`Version `,e.version]}),e.version===n&&(0,X.jsx)(k,{tone:`neutral`,children:`Current`}),(0,X.jsx)(Bi,{at:e.created_at})]}),(0,X.jsxs)(N,{size:`xs`,c:`dimmed`,mt:4,children:[zi(e),` · `,e.message||`No edit message`]})]},e.version))})})]}),(0,X.jsx)(O,{role:`status`,"aria-live":`polite`,children:m===void 0?`Select a version.`:h.isFetching?`Loading version ${m}…`:h.error?`Version ${m} unavailable.`:`Version ${m} ready.`}),(0,X.jsxs)(S,{mih:280,"aria-busy":h.isFetching,children:[m!==void 0&&h.isPending&&(0,X.jsx)(T,{state:`loading`,loadingLabel:`Loading version…`,rows:3}),h.error&&(0,X.jsx)(S,{children:(0,X.jsxs)(re,{tone:`danger`,title:h.error instanceof ze&&h.error.code===`dashboard_version_not_found`?`This version is no longer available`:`Version unavailable`,children:[h.error.message,(0,X.jsx)(F,{mt:`xs`,variant:`default`,size:`xs`,onClick:()=>void h.refetch(),children:`Retry version`})]})}),h.data&&!h.error&&(0,X.jsx)(Vi,{record:h.data,currentVersion:n,current:JSON.stringify(h.data.dashboard.spec)===JSON.stringify(r),pending:s,onRestore:()=>d(h.data.dashboard.version)})]})]})}function zi(e){return e.author_kind===`agent`?`Agent`:e.author_kind===`user`?`You`:`System`}function Bi({at:e}){let t=(Date.parse(e)-Date.now())/1e3,[n,r]=Math.abs(t)<60?[1,`second`]:Math.abs(t)<3600?[60,`minute`]:Math.abs(t)<86400?[3600,`hour`]:[86400,`day`];return(0,X.jsx)(N,{component:`time`,dateTime:e,title:De(e),size:`xs`,c:`dimmed`,children:new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(t/n),r)})}function Vi({record:e,currentVersion:t,current:n,pending:r,onRestore:i}){let{dashboard:a}=e,o=Ue(e);return(0,X.jsxs)(x,{gap:`sm`,"data-history-version":a.version,children:[(0,X.jsxs)(f,{justify:`space-between`,align:`flex-start`,children:[(0,X.jsxs)(S,{miw:0,children:[(0,X.jsxs)(b,{order:2,fz:`lg`,children:[a.name,` · v`,a.version]}),(0,X.jsxs)(N,{size:`sm`,c:`dimmed`,children:[zi(e),` · `,e.message||`No edit message`]}),(0,X.jsx)(Bi,{at:e.created_at})]}),a.version===t?(0,X.jsx)(F,{size:`sm`,variant:`default`,disabled:!0,children:`Current version`}):n?(0,X.jsx)(F,{size:`sm`,variant:`default`,disabled:!0,children:`Same as current`}):(0,X.jsxs)(F,{size:`sm`,disabled:r,loading:r,onClick:i,children:[`Restore version `,a.version]})]}),a.description&&(0,X.jsx)(N,{size:`sm`,children:a.description}),e.changes_available?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ye,{labels:o}),!o.length&&!e.layout_changed&&(0,X.jsx)(T,{state:`empty`,empty:{title:`No authored changes.`}})]}):(0,X.jsx)(S,{children:(0,X.jsx)(re,{tone:`warning`,title:`Changes unavailable`,children:`The preceding version is no longer retained. This saved spec is still available.`})}),(0,X.jsxs)(N,{size:`sm`,c:`dimmed`,children:[`Read-only · `,a.spec.panels.length,` panels. Historical data is not queried.`]}),(0,X.jsxs)(ot,{variant:`contained`,children:[(0,X.jsxs)(ot.Item,{value:`spec`,children:[(0,X.jsx)(ot.Control,{children:`Spec`}),(0,X.jsx)(ot.Panel,{children:(0,X.jsx)(Le,{block:!0,tabIndex:0,style:{maxHeight:320,overflow:`auto`},children:JSON.stringify(a.spec,null,2)})})]}),(0,X.jsxs)(ot.Item,{value:`data`,children:[(0,X.jsx)(ot.Control,{children:`Data`}),(0,X.jsx)(ot.Panel,{children:(0,X.jsx)(x,{gap:`xs`,children:a.spec.panels.map(e=>(0,X.jsxs)(S,{children:[(0,X.jsxs)(N,{size:`sm`,fw:500,children:[e.title,` · `,e.viz]}),(0,X.jsx)(Le,{block:!0,tabIndex:0,children:e.content??e.sql??JSON.stringify(e.query??{},null,2)})]},e.id))})})]})]})]})}function Hi({error:e,version:t}){let n=e instanceof ze?e.code:void 0,r=!(e instanceof ze)||e.status>=500?`Try again with the restore button.`:n===`invalid_spec`?`This saved spec is invalid. Review the fields below and choose another version.`:n===`dashboard_version_not_found`?`Reload history and choose a retained version.`:n===`already_current`?`The dashboard already has this version's contents, so there is nothing to restore.`:[`dashboard_version_conflict`,`conflict`].includes(n??``)?`This dashboard changed or its name conflicts. Reload history and choose another version.`:`Check your access and reload history.`;return(0,X.jsx)(S,{children:(0,X.jsxs)(re,{tone:`danger`,title:`Restore of version ${t} failed`,children:[(0,X.jsx)(N,{size:`sm`,children:e.message}),e instanceof ze&&e.problems.length>0&&(0,X.jsx)(`ul`,{children:e.problems.map((e,t)=>(0,X.jsxs)(`li`,{children:[e.path,`: `,e.message,e.hint?` (${e.hint})`:``]},t))}),(0,X.jsx)(N,{size:`sm`,mt:`xs`,children:r})]})})}function Ui(e,t){let n=JSON.stringify([e.range,e.from,e.to]),r=(0,Z.useRef)({search:e,onSearch:t,scope:n}),i=(0,Z.useRef)(``),a=(0,Z.useRef)(void 0),[o,s]=(0,Z.useState)(!1);r.current.scope!==n&&(i.current!==`${e.from}/${e.to}`&&(a.current=void 0,o&&s(!1)),i.current=``),r.current={search:e,onSearch:t,scope:n};let c=(0,Z.useCallback)(()=>{i.current=``,a.current=void 0,s(!1)},[]),l=(0,Z.useCallback)(()=>{if(!a.current)return;let e=a.current;c(),r.current.onSearch({...r.current.search,...e},!1)},[c]);return{zoom:(0,Z.useCallback)((e,t)=>{let n=U(e,t);if(!n)return;let o=r.current,c=`${n.from}/${n.to}`;o.search.from===n.from&&o.search.to===n.to||i.current===c||(a.current??={range:o.search.range,from:o.search.from,to:o.search.to},s(!0),i.current=c,o.onSearch({...o.search,range:void 0,...n},!1))},[]),reset:c,resetZoom:l,zoomed:o}}function Wi({variables:e,vars:t,options:n,onChange:r}){return e.length===0?null:(0,X.jsx)(f,{gap:`sm`,wrap:`wrap`,role:`group`,"aria-label":`Dashboard variables`,children:e.map(e=>{let i=di(e,t,n[e.name]),a=[...e.include_all?[{value:kt,label:`All`}]:[],...(n[e.name]??e.options?.map(e=>({value:e}))??[]).map(e=>({value:e.value,label:e.value}))],o=(0,X.jsxs)(N,{size:`sm`,c:`dimmed`,ff:`monospace`,children:[`$`,e.name]});return e.kind===`constant`?(0,X.jsx)(z,{label:o,size:`sm`,value:e.value,readOnly:!0,w:160},e.name):e.kind===`text`?(0,X.jsx)(z,{label:o,size:`sm`,w:200,defaultValue:typeof i==`string`?i:``,onBlur:t=>r(e.name,t.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}},`${e.name}:${JSON.stringify(i)}`):e.multi?(0,X.jsx)(Dt,{label:o,size:`sm`,w:260,searchable:!0,clearable:!0,data:a.filter(e=>e.value!==kt),value:Array.isArray(i)?i:i&&i!==`$__all`?[i]:[],placeholder:e.include_all?`All`:`None`,onChange:t=>r(e.name,t.length?t:e.include_all?kt:[])},e.name):(0,X.jsx)(le,{label:o,size:`sm`,w:220,searchable:!0,allowDeselect:!1,data:a,value:Array.isArray(i)?i[0]??null:i||null,onChange:t=>t!==null&&r(e.name,t)},e.name)})})}function Gi(e,t,n=!1){let r=e.target;return t||e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey&&e.key!==`?`||r instanceof Element&&r.closest(`input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="menu"]`)||r instanceof Element&&r.closest(`[role="dialog"]`)&&!(n&&r.closest(`[data-panel-fullscreen]`))?null:[`r`,`e`,`h`,`f`,`?`].includes(e.key)?e.key:null}function Ki(e,t,n={}){let r=(0,Z.useRef)({actions:t,options:n});r.current={actions:t,options:n},(0,Z.useEffect)(()=>{let t=t=>{let n=e.current,i=t.target,{actions:a,options:o}=r.current;if(!n||!(i instanceof Element)||o.enabled===!1)return;let s=o.fullscreenScope?[...document.querySelectorAll(`[data-shortcut-scope]`)].find(e=>e.dataset.shortcutScope===o.fullscreenScope&&e.hasAttribute(`data-panel-fullscreen`)):void 0,c=n.contains(i)&&n.contains(document.activeElement),l=i===document.body&&document.activeElement===document.body,u=s?.contains(i)&&s.contains(document.activeElement);if(!c&&!l&&!u)return;let d=Gi(t,!!(o.modalOpen||[...document.querySelectorAll(`[role="dialog"]`)].some(e=>e!==s)),!!s);if(!d||s&&![`r`,`f`,`?`].includes(d))return;let f=a[d];f&&(t.preventDefault(),f(i))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e])}function qi({opened:e,onClose:t,fullscreen:n=!1,enabled:r,onEnabled:i}){let a=[[`r`,`Refresh now`],...n?[]:[[`e`,`Toggle layout mode`],[`h`,`Open history`]],[`f`,n?`Exit full-screen`:`Open the focused panel in full-screen`],[`?`,`Open keyboard shortcuts`],[`Escape`,`Cancel a range, then leave the chart or close full-screen`]];return(0,X.jsx)(s,{opened:e,onClose:t,title:`Keyboard shortcuts`,trapFocus:!0,returnFocus:!0,closeOnEscape:!0,children:(0,X.jsxs)(x,{gap:`xs`,children:[(0,X.jsx)(Me,{label:`Single-key shortcuts`,checked:r,onChange:e=>i(e.currentTarget.checked)}),a.map(([e,t])=>(0,X.jsxs)(f,{gap:`sm`,children:[(0,X.jsx)(Ke,{children:e}),(0,X.jsx)(N,{size:`sm`,children:t})]},e)),!n&&(0,X.jsx)(N,{size:`sm`,children:`Focus a chart or a panel control before pressing f. Without a focused panel, f does nothing.`}),(0,X.jsx)(N,{size:`sm`,children:`Tab directly to a chart. Left/Right moves between points; Up/Down changes series at the same time or category. Home/End jumps to the first/last point. Enter drills or applies the panel filter. Comparison and Other values can be read even when selection is unavailable.`}),(0,X.jsx)(N,{size:`sm`,children:`On time charts, Shift+Left/Right extends a range and pauses auto-refresh. Review the shaded range and compact UTC label, then choose Zoom to range. Use the time picker after zooming for precise edits. Escape or Cancel cancels it and resumes refresh. The next Escape leaves the chart or closes full-screen. Reset zoom, Zoom out and browser Back preserve comparison and filters.`}),(0,X.jsxs)(N,{size:`sm`,children:[n?`In full-screen, r refreshes, f exits and ? opens help; e and h are inactive.`:`Shortcuts work in the dashboard.`,` Typing, menus and other dialogs or drawers pause shortcuts. Modifier shortcuts keep their browser behavior. Turning off single-key shortcuts keeps chart navigation and visible controls available.`]}),(0,X.jsx)(N,{size:`sm`,children:`The global / shortcut focuses the chat composer.`})]})})}function Ji(e){let t=`fanout:single-key-shortcuts:`+e,n=()=>{try{return localStorage.getItem(t)!==`off`}catch{return!0}},[r,i]=(0,Z.useState)(n);return(0,Z.useEffect)(()=>{i(n())},[t]),(0,Z.useEffect)(()=>{let e=e=>{e.key===t&&i(n())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[t]),{enabled:r,change:e=>{i(e);try{localStorage.setItem(t,e?`on`:`off`)}catch{}}}}function Yi(e){let t=(0,Z.useRef)(void 0),n=t=>[...e.current?.querySelectorAll(`[data-panel]`)??[]].find(e=>e.dataset.panel===t&&!e.closest(`[data-panel-fullscreen],[data-fragment-fullscreen]`));return(0,Z.useEffect)(()=>{t.current&&!n(t.current.panel)&&(t.current=void 0)}),{remember(n){t.current=void 0;let r=document.activeElement;if(!(r instanceof HTMLElement)||!e.current?.contains(r)||r.closest(`[data-panel]`)?.dataset.panel!==n)return;let i=r.getAttribute(`data-panel-view`),a=r.getAttribute(`aria-label`),o=r.hasAttribute(`data-chart-plot`)?`[data-chart-plot]`:i?`[data-panel-view=${JSON.stringify(i)}]`:a?`[aria-label=${JSON.stringify(a)}]`:void 0;t.current={element:r,panel:n,selector:o}},restore(e){let r=t.current;if(t.current=void 0,r&&(e===void 0||r.panel===e)&&n(r.panel))return r.element.isConnected&&!r.element.closest(`[hidden]`)?r.element:r.selector?n(r.panel)?.querySelector(r.selector)??void 0:void 0}}}var Xi=(0,Z.lazy)(()=>ae(()=>import(`./new-dashboard-D58ui2mw.js`).then(e=>({default:e.NewDashboard})),__vite__mapDeps([25,1,2,3,4,5,6,7,8,22,10,11,12,13,14,15,16,17,18,19,20,21,23,9,24]))),Zi={exemplars:K,trace:ge,span:V},Qi={"5m":`15m`,"15m":`1h`,"1h":`3h`,"3h":`6h`,"6h":`12h`,"12h":`24h`,"24h":`2d`,"2d":`7d`,"7d":`30d`,"30d":`30d`};function $i({dashboardId:e,search:t,onSearch:n,onOpen:r}){let{agentAvailable:i,openChat:a}=qe(),[o,s]=(0,Z.useState)(!1),c=Ve({queryKey:Se,queryFn:Ee,staleTime:15e3});(0,Z.useEffect)(()=>{!e&&c.data?.length&&r((c.data.find(e=>e.is_default)??c.data[0]).id,!0)},[e,c.data]);let l=Ve({queryKey:[`dashboard`,e],queryFn:({signal:t})=>be(e,t),enabled:!!e,retry:(e,t)=>!(t instanceof ze&&t.code===`not_found`)&&e<2});return!e&&c.error?(0,X.jsxs)(x,{p:`lg`,children:[(0,X.jsx)(A,{title:`Dashboards`,description:`Monitor your services and investigate changes.`}),(0,X.jsx)(T,{state:`error`,error:{title:`Dashboards could not be loaded`,message:c.error.message,onRetry:()=>void c.refetch()}})]}):!e&&c.data?.length===0?(0,X.jsx)(_,{mih:`50vh`,children:(0,X.jsxs)(x,{align:`center`,gap:`xs`,children:[(0,X.jsx)(A,{title:`Dashboards`,description:`Create a dashboard to explore your services.`}),(0,X.jsx)(T,{state:`empty`,empty:{title:(0,X.jsx)(b,{order:2,fz:`lg`,children:`No dashboards yet`}),description:`Create a dashboard to see your telemetry.`,action:(0,X.jsx)(F,{size:`sm`,onClick:()=>s(!0),children:`New dashboard`})}}),(0,X.jsx)(f,{mt:`sm`,gap:`xs`,children:i&&(0,X.jsx)(F,{size:`sm`,variant:`default`,onClick:()=>a(`Build me a dashboard for my services, showing request volume, latency, and errors. Ask me which services to monitor first.`),children:`Create with AI`})}),o&&(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(Xi,{onClose:()=>s(!1),onCreated:e=>{s(!1),r(e)}})})]})}):!e||l.isLoading?(0,X.jsx)(S,{component:`section`,"aria-label":`Dashboard`,maw:1600,mx:`auto`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,children:(0,X.jsx)(T,{state:`loading`,loadingLabel:`Loading dashboard`,skeleton:(0,X.jsx)(Pt,{})})}):l.error instanceof ze&&l.error.code===`not_found`?(0,X.jsx)(_,{mih:`50vh`,children:(0,X.jsxs)(x,{align:`center`,gap:`xs`,children:[(0,X.jsx)(A,{title:`Dashboard`,description:`Monitor your services and investigate changes.`}),(0,X.jsx)(T,{state:`empty`,empty:{title:(0,X.jsx)(b,{order:2,fz:`lg`,children:`This dashboard isn't here`}),description:`The link may be out of date, or the dashboard may have been deleted.`,action:c.data?.length?(0,X.jsx)(F,{variant:`default`,size:`sm`,onClick:()=>r((c.data.find(e=>e.is_default)??c.data[0]).id,!0),children:`Open your default dashboard`}):void 0}})]})}):l.error||!l.data?(0,X.jsxs)(x,{p:`lg`,children:[(0,X.jsx)(A,{title:`Dashboard`,description:`Monitor your services and investigate changes.`}),(0,X.jsx)(T,{state:`error`,error:{message:`Your dashboard is unavailable.`,onRetry:()=>void l.refetch()}})]}):(0,X.jsx)(ea,{id:l.data.id,version:l.data.version,spec:l.data.spec,search:t,onSearch:n,onOpen:r,agentAvailable:i,openChat:a},l.data.id)}function ea({id:e,version:t,spec:n,search:r,onSearch:i,onOpen:a,agentAvailable:o,openChat:s}){let[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1);Ge((0,Z.useCallback)(()=>m(!0),[]));let h=(0,Z.useRef)(null),g=(0,Z.useId)(),_=Ji(Re().id),v=Yi(h),[y,b]=(0,Z.useState)(()=>new Set),C=(0,Z.useCallback)((e,t)=>b(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r}),[]),w=Be(),[E,D]=(0,Z.useState)(),{zoom:ee,reset:O,resetZoom:k,zoomed:j}=Ui(r,i),M=xe(n,r),[N,P]=(0,Z.useState)(M.refresh??`30s`),I=()=>{if(M.from&&M.to){let e=Date.parse(M.from),t=Date.parse(M.to),n=(t-e)/2;i({...r,range:void 0,from:new Date(e-n).toISOString(),to:new Date(t+n).toISOString()})}else i({...r,range:Qi[M.range??`1h`]??`1h`,from:void 0,to:void 0})},L=r.compare?r.compare===`1`:n.time.compare===`previous_period`,R=r.vars??{},ie=Fi(`dashboard-${e}`,n,M,R,q,Si),z=(0,Z.useMemo)(()=>pi(n.variables,R,ie.currentData),[n.variables,R,ie.currentData]),[ae,oe]=(0,Z.useState)(()=>window.innerWidth);(0,Z.useEffect)(()=>{let e=0,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>oe(window.innerWidth),300)};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),window.clearTimeout(e)}},[]);let se=(0,Z.useMemo)(()=>{let e=Math.max(320,Math.min(ae-64,1600));return Object.fromEntries(n.panels.map(t=>[t.id,e/12*(t.grid?.w??t.width??6)]))},[ae,n]),[ce,le]=(0,Z.useState)(()=>n.panels.map(e=>e.id)),V=Mi({dashboardId:e,version:t,spec:n,time:M,vars:z,compare:L,widths:se,visible:(0,Z.useMemo)(()=>ce.filter(e=>n.panels.some(t=>t.id===e)),[ce,n.panels]),refresh:y.size?`off`:N,enabled:ie.ready});(0,Z.useEffect)(()=>{E===t&&w.refetchQueries({predicate:Ii(e),type:`active`,stale:!0},{cancelRefetch:!1})},[E,t,e,w]);let ue=(0,Z.useMemo)(()=>V.annotations?{...V.annotations,deploys:n.annotations?.deploys===!1?[]:V.annotations.deploys,anomalies:n.annotations?.anomalies===!1?[]:V.annotations.anomalies}:void 0,[V.annotations,n.annotations?.deploys,n.annotations?.anomalies]),fe=ie.error??V.error,H=(e,t)=>{let n={...R};t===void 0?delete n[e]:n[e]=t,i({...r,vars:n},!0)},U=()=>i({...r,edit:r.edit===`1`?void 0:`1`}),W=e=>{e&&v.remember(e),i({...r,view:e},e===void 0)};return Ki(h,{r:()=>V.refetch(),e:U,h:()=>d(!0),"?":()=>m(!0),f:e=>{if(r.view){W();return}let t=e.closest(`[data-panel]`)?.dataset.panel;t&&n.panels.some(e=>e.id===t)&&W(t)}},{modalOpen:u||p||!!r.drill,fullscreenScope:r.view?g:void 0,enabled:_.enabled}),(0,X.jsxs)(S,{component:`section`,ref:h,"aria-label":`Dashboard`,maw:1600,mx:`auto`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,children:[(0,X.jsxs)(x,{gap:`sm`,mb:`md`,children:[(0,X.jsx)(A,{title:n.name,description:n.description||`Monitor your services and investigate changes.`,meta:(0,X.jsx)(Ie,{time:M,updatedAt:V.updatedAt}),actions:(0,X.jsx)(f,{gap:`xs`,children:(0,X.jsx)(We,{label:`Duplicate dashboard`,children:(0,X.jsx)(te,{variant:`subtle`,color:`gray`,"aria-label":`Duplicate dashboard`,onClick:()=>l(!0),children:(0,X.jsx)(ne,{size:16})})})})}),(0,X.jsx)(de,{selecting:y.size>0,time:M,refresh:N,compare:L,editing:r.edit===`1`,fetching:V.fetching,updatedAt:V.updatedAt,onRange:e=>{O(),i({...r,range:e,from:void 0,to:void 0})},onAbsolute:(e,t)=>{O(),i({...r,range:void 0,from:e,to:t})},onZoomOut:I,onRefresh:P,onRefreshNow:V.refetch,onCompare:e=>i({...r,compare:e?`1`:`0`},!0),onEdit:U,onHistory:()=>d(!0)}),(0,X.jsx)(Wi,{variables:n.variables??[],vars:R,options:ie.data??{},onChange:H}),Object.entries(R).filter(([,e])=>e!==`$__all`).length>0&&(0,X.jsx)(f,{gap:6,children:Object.entries(R).filter(([,e])=>e!==`$__all`).map(([e,t])=>(0,X.jsxs)(F,{color:`accent`,size:`compact-xs`,variant:`light`,"aria-label":`$${e} = ${Array.isArray(t)?t.join(`, `):t} ×: remove filter`,onClick:()=>H(e,void 0),children:[`$`,e,` = `,Array.isArray(t)?t.join(`, `):t,` ×`]},e))}),V.annotationError&&(0,X.jsx)(re,{tone:`warning`,title:`Annotations unavailable`,children:V.annotationError}),V.annotations?.truncated&&(0,X.jsx)(re,{tone:`warning`,children:`Annotation history is limited.`})]}),!fe&&V.skippedAt!==null&&(0,X.jsx)(S,{"data-refresh-skipped":!0,children:(0,X.jsxs)(re,{tone:`info`,children:[`The server was busy, so the latest refresh was skipped. Marked panels show data from `,new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`,second:`2-digit`}).format(V.skippedAt),`.`]})}),fe&&(0,X.jsxs)(re,{tone:`danger`,title:ie.error?`Variables could not be loaded`:`Panels could not be loaded`,children:[fe.message,fe instanceof ze&&(0,X.jsx)(`ul`,{children:fe.problems.map((e,t)=>(0,X.jsxs)(`li`,{children:[e.path,`: `,e.message,e.hint?` (${e.hint})`:``]},t))})]}),n.panels.length===0&&(0,X.jsx)(T,{state:`empty`,empty:{title:`No panels yet`,description:`Add a panel to see telemetry on this dashboard.`,action:(0,X.jsx)(F,{onClick:()=>i({...r,edit:`1`}),children:`Add panel`})}}),(0,X.jsx)(bi,{dashboardId:e,version:t,spec:n,vars:z,results:V.results,annotations:ue,fetching:V.fetching,fetchingIds:V.fetchingIds,staleAt:V.staleAt,time:{...M,compare:L?`previous_period`:void 0},onEditExit:()=>i({...r,edit:void 0}),editing:r.edit===`1`,view:r.view,canManage:!0,agentAvailable:o,onOpenChat:s,onRetry:V.retry,onVariable:H,onZoom:ee,zoomed:j,onZoomReset:k,onWiden:I,onView:W,onRangePending:C,shortcutScope:g,onShortcuts:()=>m(!0),overlayOpen:u||p||!!r.drill,returnViewFocus:v.restore,onVisible:le,onPoint:(e,t)=>{let n=B(e,V.results.get(e.id),t,R);n&&i({...r,vars:n.vars,drill:JSON.stringify(n.target)},!1)}}),(0,X.jsx)(pe,{client:Zi,spec:n,time:M,vars:z,target:ve(r.drill),onChange:e=>i({...r,drill:e?JSON.stringify(e):void 0},!1)}),c&&(0,X.jsx)(xi,{spec:n,onClose:()=>l(!1),onCreated:e=>{l(!1),a(e)}}),(0,X.jsx)(Li,{id:e,currentVersion:t,currentSpec:n,opened:u,onClose:()=>d(!1),onRestored:e=>{D(e.version);let t=new Set(e.spec.panels.map(e=>e.id)),n=ve(r.drill),a=r.view&&!t.has(r.view)?void 0:r.view,o=n&&!t.has(n.panel_id)?void 0:r.drill;(a!==r.view||o!==r.drill)&&i({...r,view:a,drill:o},!0)}}),(0,X.jsx)(qi,{opened:p,onClose:()=>m(!1),fullscreen:!!r.view,enabled:_.enabled,onEnabled:_.change})]})}export{kt as n,$i as t}; \ No newline at end of file +`,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&ce(e.body,`react-draggable-transparent-selection`)}function oe(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{se(e)}):se(e)}function se(e){if(e)try{e.body&&B(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function ce(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function B(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function le(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:pe(r);let i=W(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+S(s.paddingLeft)+S(o.marginLeft),top:-i.offsetTop+S(s.paddingTop)+S(o.marginTop),right:I(a)-P(i)-i.offsetLeft+S(s.paddingRight)-S(o.marginRight),bottom:F(a)-N(i)-i.offsetTop+S(s.paddingBottom)-S(o.marginBottom)}}return x(r.right)&&(t=Math.min(t,r.right)),x(r.bottom)&&(n=Math.min(n,r.bottom)),x(r.left)&&(t=Math.max(t,r.left)),x(r.top)&&(n=Math.max(n,r.top)),[t,n]}function V(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function ue(e){return e.props.axis===`both`||e.props.axis===`x`}function de(e){return e.props.axis===`both`||e.props.axis===`y`}function fe(e,t,n){let r=typeof t==`number`?re(e,t):null;if(typeof t==`number`&&!r)return null;let i=W(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return L(r||e,a,n.props.scale)}function H(e,t,n){let r=!x(e.lastX),i=W(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function U(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function pe(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function W(e){let t=e.findDOMNode();if(!t)throw Error(`: Unmounted during event!`);return t}var G=f(t()),K=f(Gn()),q=f(a()),J=typeof process<`u`&&{}.DRAGGABLE_DEBUG?console.log.bind(console):function(){},me={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},he=me.mouse,Y=class extends G.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(` not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!A(e.target,this.props.handle,t)||this.props.cancel&&A(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=ie(e);this.touchIdentifier=r;let i=fe(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=H(this,a,o);J(`DraggableCore: handleDragStart: %j`,s),J(`calling`,this.props.onStart),this.props.onStart(e,s)!==!1&&this.mounted!==!1&&(this.props.enableUserSelectHack&&ae(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,j(n,he.move,this.handleDrag),j(n,he.stop,this.handleDragStop))},this.handleDrag=e=>{let t=fe(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=V(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=H(this,n,r);if(J(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}return}this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=fe(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=V(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=H(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&oe(a.ownerDocument),J(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(J(`DraggableCore: Removing handlers`),M(a.ownerDocument,he.move,this.handleDrag),M(a.ownerDocument,he.stop,this.handleDragStop))},this.onMouseDown=e=>(he=me.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(he=me.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(he=me.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(he=me.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&j(e,me.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;M(t,me.mouse.move,this.handleDrag),M(t,me.touch.move,this.handleDrag),M(t,me.mouse.stop,this.handleDragStop),M(t,me.touch.stop,this.handleDragStop),M(e,me.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&oe(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=q.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(J(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return G.cloneElement(G.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};Y.displayName=`DraggableCore`,Y.propTypes={allowAnyClick:K.default.bool,allowMobileScroll:K.default.bool,children:K.default.node.isRequired,disabled:K.default.bool,enableUserSelectHack:K.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:K.default.arrayOf(K.default.number),handle:K.default.string,cancel:K.default.string,nodeRef:K.default.object,nonce:K.default.string,onStart:K.default.func,onDrag:K.default.func,onStop:K.default.func,onMouseDown:K.default.func,scale:K.default.number,className:C,style:C,transform:C},Y.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var ge=class extends h.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(J(`Draggable: onDragStart: %j`,t),this.props.onStart(e,U(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;J(`Draggable: onDrag: %j`,t);let n=U(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=le(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,U(this,t))===!1)return!1;J(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(J(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=_.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,g={x:ue(this)&&p?this.state.x:m.x,y:de(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=te(g,c):d=R(g,c);let _=h.Children.only(n),y=(0,v.clsx)(_.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return h.createElement(Y,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},h.cloneElement(_,{className:y,style:{..._.props.style,...d},transform:f}))}};ge.displayName=`Draggable`,ge.propTypes={...Y.propTypes,axis:g.default.oneOf([`both`,`x`,`y`,`none`]),bounds:g.default.oneOfType([g.default.shape({left:g.default.number,right:g.default.number,top:g.default.number,bottom:g.default.number}),g.default.string,g.default.oneOf([!1])]),defaultClassName:g.default.string,defaultClassNameDragging:g.default.string,defaultClassNameDragged:g.default.string,defaultPosition:g.default.shape({x:g.default.number,y:g.default.number}),positionOffset:g.default.shape({x:g.default.oneOfType([g.default.number,g.default.string]),y:g.default.oneOfType([g.default.number,g.default.string])}),position:g.default.shape({x:g.default.number,y:g.default.number}),className:C,style:C,transform:C},ge.defaultProps={...Y.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1},0&&(n.exports={DraggableCore:Y})})),zr=e(((e,t)=>{var n=Rr(),r=n.DraggableCore,i=n.default||n;t.exports=i,t.exports.default=i,t.exports.DraggableCore=r})),Br=e((e=>{e.__esModule=!0,e.cloneElement=l;var n=r(t());function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t{e.__esModule=!0,e.resizableProps=void 0;var t=n(Gn());zr();function n(e){return e&&e.__esModule?e:{default:e}}e.resizableProps={axis:t.default.oneOf([`both`,`x`,`y`,`none`]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:typeof Element<`u`?t.default.instanceOf(Element):t.default.any,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`y`?t.default.number.isRequired(...e):t.default.number(...e)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf([`s`,`w`,`e`,`n`,`sw`,`nw`,`se`,`ne`])),transformScale:t.default.number,width:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),Hr=e((e=>{e.__esModule=!0,e.default=void 0;var n=s(t()),r=zr(),i=Br(),a=Vr(),o=[`children`,`className`,`draggableOpts`,`width`,`height`,`handle`,`handleSize`,`lockAspectRatio`,`axis`,`minConstraints`,`maxConstraints`,`onResize`,`onResizeStop`,`onResizeStart`,`resizeHandles`,`transformScale`];function s(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(s=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;tMath.abs(i*n)?t=e/n:e=t*n}let o=e,s=t,c=this.slack||[0,0],l=c[0],u=c[1];return e+=l,t+=u,r&&(e=Math.max(r[0],e),t=Math.max(r[1],t)),i&&(e=Math.min(i[0],e),t=Math.min(i[1],t)),this.slack=[l+(o-e),u+(s-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let i=r.node,a=r.deltaX,o=r.deltaY;e===`onResizeStart`&&this.resetData();let s=(this.props.axis===`both`||this.props.axis===`x`)&&t!==`n`&&t!==`s`,c=(this.props.axis===`both`||this.props.axis===`y`)&&t!==`e`&&t!==`w`;if(!s&&!c)return;let l=t[0],u=t[t.length-1],d=i.getBoundingClientRect();if(this.lastHandleRect!=null){if(u===`w`){let e=d.left-this.lastHandleRect.left;a+=e}if(l===`n`){let e=d.top-this.lastHandleRect.top;o+=e}}this.lastHandleRect=d,u===`w`&&(a=-a),l===`n`&&(o=-o);let f=this.lastSize?.width??this.props.width,p=this.lastSize?.height??this.props.height,m=f+(s?a/this.props.transformScale:0),h=p+(c?o/this.props.transformScale:0);var g=this.runConstraints(m,h);if(m=g[0],h=g[1],e===`onResizeStop`&&this.lastSize){var _=this.lastSize;m=_.width,h=_.height}let v=m!==f||h!==p;e!==`onResizeStop`&&(this.lastSize={width:m,height:h});let y=typeof this.props[e]==`function`?this.props[e]:null;y&&(e!==`onResize`||v)&&(n.persist==null||n.persist(),y(n,{node:i,size:{width:m,height:h},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,t){let r=this.props.handle;if(!r)return n.createElement(`span`,{className:`react-resizable-handle react-resizable-handle-`+e,ref:t});if(typeof r==`function`)return r(e,t);let i=typeof r.type==`string`,a=d({ref:t},i?{}:{handleAxis:e});return n.cloneElement(r,a)}render(){let e=this.props,t=e.children,a=e.className,s=e.draggableOpts;e.width,e.height,e.handle,e.handleSize,e.lockAspectRatio,e.axis,e.minConstraints,e.maxConstraints,e.onResize,e.onResizeStop,e.onResizeStart;let u=e.resizeHandles;e.transformScale;let f=l(e,o);return(0,i.cloneElement)(t,d(d({},f),{},{className:(a?a+` `:``)+`react-resizable`,children:[...n.Children.toArray(t.props.children),...u.map(e=>{let t=this.handleRefs[e]??(this.handleRefs[e]=n.createRef());return n.createElement(r.DraggableCore,c({},s,{nodeRef:t,key:`resizableHandle-`+e,onStop:this.resizeHandler(`onResizeStop`,e),onStart:this.resizeHandler(`onResizeStart`,e),onDrag:this.resizeHandler(`onResize`,e)}),this.renderResizeHandle(e,t))})]}))}};e.default=h,h.propTypes=a.resizableProps,h.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),Ur=e((e=>{e.__esModule=!0,e.default=void 0;var n=c(t()),r=s(Gn()),i=s(Hr()),a=Vr(),o=[`handle`,`handleSize`,`onResize`,`onResizeStart`,`onResizeStop`,`draggableOpts`,`minConstraints`,`maxConstraints`,`lockAspectRatio`,`axis`,`width`,`height`,`resizeHandles`,`style`,`transformScale`];function s(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(c=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let n=t.size;this.props.onResize?(e.persist==null||e.persist(),this.setState(n,()=>this.props.onResize&&this.props.onResize(e,t))):this.setState(n)}}static getDerivedStateFromProps(e,t){return t.propsWidth!==e.width||t.propsHeight!==e.height?{width:e.width,height:e.height,propsWidth:e.width,propsHeight:e.height}:null}render(){let e=this.props,t=e.handle,r=e.handleSize;e.onResize;let a=e.onResizeStart,s=e.onResizeStop,c=e.draggableOpts,u=e.minConstraints,f=e.maxConstraints,p=e.lockAspectRatio,m=e.axis;e.width,e.height;let g=e.resizeHandles,_=e.style,v=e.transformScale,y=h(e,o);return n.createElement(i.default,{axis:m,draggableOpts:c,handle:t,handleSize:r,height:this.state.height,lockAspectRatio:p,maxConstraints:f,minConstraints:u,onResizeStart:a,onResize:this.onResize,onResizeStop:s,resizeHandles:g,transformScale:v,width:this.state.width},n.createElement(`div`,l({},y,{style:d(d({},_),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=g,g.propTypes=d(d({},a.resizableProps),{},{children:r.default.element})})),Wr=e(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=Hr().default,t.exports.ResizableBox=Ur().default}))(),Gr=Hn(),Kr=50,qr=12;function Jr(e){let t=e;for(;t;){let e=window.getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function Yr(e){let t=Jr(e),n=null,r=0,i=0,a=!1;function o(){let e=t;if(!e)return;let s=e.getBoundingClientRect(),{clientHeight:c,scrollTop:l,scrollHeight:u}=e,{scrollLeft:d,scrollWidth:f,clientWidth:p}=e,m=0,h=0;i0?m=-qr:i>s.bottom-Kr&&l+c0?h=-qr:r>s.right-Kr&&d+p({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),K=(0,Z.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),q=(0,Z.useCallback)(e=>({...K,containerHeight:e??K.containerHeight,layout:ue.current}),[K]),J=(0,Z.useMemo)(()=>F??{i:j,x:w,y:T,w:E,h:D,minW:ee,maxW:O,minH:k,maxH:A},[F,j,w,T,E,D,ee,O,k,A]),me=(0,Z.useCallback)(e=>{if(g?.calcStyle)return g.calcStyle(e);if(p)return ln(e);let t=un(e);return m?{...t,left:dn(e.left/r),width:dn(e.width/r)}:t},[g,p,m,r]),he=(0,Z.useCallback)((e,{node:t})=>{if(!L)return;let{offsetParent:n}=t;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=i.left/h,o=r.left/h,s=i.top/h,c=r.top/h,l;if(g?.calcDragPosition){let t=e;l=g.calcDragPosition(t.clientX,t.clientY,t.clientX-i.left,t.clientY-i.top)}else l={left:a-o+n.scrollLeft,top:s-c+n.scrollTop};if(B.current=l,W.current||=Yr(t instanceof HTMLElement?t:null),_>0){let t=e;U.current={x:t.clientX,y:t.clientY},H.current=!0,pe.current=!1,ae(!0);return}ae(!0);let u=zt(G,l.top,l.left),{x:d,y:f}=sn(P,J,u.x,u.y,q());L(j,d,f,{e,node:t,newPosition:l})},[L,h,G,g,_,P,J,q,j]),Y=(0,Z.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!R||!z)return;let s=e;if(H.current&&!pe.current){let n=s.clientX-U.current.x,r=s.clientY-U.current.y;if(Math.hypot(n,r)<_)return;if(pe.current=!0,H.current=!1,L){let n=zt(G,B.current.top,B.current.left),{x:r,y:i}=sn(P,J,n.x,n.y,q());L(j,r,i,{e,node:t,newPosition:B.current})}}W.current?.feed(s.clientX,s.clientY);let c=B.current.top+a,l=B.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-It(D,o,i[1]);c=Vt(c,0,t);let n=Ft(G),a=r-It(E,n,i[0]);l=Vt(l,0,a)}}let d={top:c,left:l};B.current=d;let f=zt(G,c,l),{x:p,y:m}=sn(P,J,f.x,f.y,q());R(j,p,m,{e,node:t,newPosition:d})},[R,L,z,_,u,D,o,i,G,r,E,j,P,J,q]),ge=(0,Z.useCallback)((e,{node:t})=>{if(!te||!z)return;W.current?.stop(),W.current=null;let n=H.current;if(H.current=!1,pe.current=!1,U.current={x:0,y:0},n){ae(!1),B.current={left:0,top:0};return}let{left:r,top:i}=B.current,a={top:i,left:r};ae(!1),B.current={left:0,top:0};let o=zt(G,i,r),{x:s,y:c}=sn(P,J,o.x,o.y,q());te(j,s,c,{e,node:t,newPosition:a})},[te,z,G,P,J,q,j]);de.current=he,fe.current=Y;let _e=(0,Z.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?ne:o===`onResize`?re:ie;if(!s)return;let c;c=t?xn(i,a,n,r):{...n,top:a.top,left:a.left},le.current=c;let l=t?.offsetParent?.clientHeight??0,u=Bt(G,c.width,c.height),{w:d,h:f}=cn(P,J,u.w,u.h,i,q(l));s(j,d,f,{e:e.nativeEvent??e,node:t,size:c,handle:i})},[ne,re,ie,r,G,j,P,J,q]),ve=(0,Z.useCallback)((e,t)=>{se(!0);let n=Lt(G,w,T,E,D),r={...t,handle:t.handle};_e(e,r,n,`onResizeStart`)},[_e,G,w,T,E,D]),ye=(0,Z.useCallback)((e,t)=>{let n=Lt(G,w,T,E,D),r={...t,handle:t.handle};_e(e,r,n,`onResize`)},[_e,G,w,T,E,D]),be=(0,Z.useCallback)((e,t)=>{se(!1),le.current={top:0,left:0,width:0,height:0};let n=Lt(G,w,T,E,D),r={...t,handle:t.handle};_e(e,r,n,`onResizeStop`)},[_e,G,w,T,E,D]);(0,Z.useEffect)(()=>{if(!v)return;let e=ce.current;if(!e)return;let t=V.current||{left:0,top:0},n=z&&(v.left!==t.left||v.top!==t.top);if(!z){let t={node:e,deltaX:v.left,deltaY:v.top,lastX:0,lastY:0,x:v.left,y:v.top};de.current?.(v.e,t)}else if(n){let t={node:e,deltaX:v.left-B.current.left,deltaY:v.top-B.current.top,lastX:B.current.left,lastY:B.current.top,x:v.left,y:v.top};fe.current?.(v.e,t)}V.current=v},[v,z,j]);let xe=Lt(G,w,T,E,D,z?B.current:null,oe?le.current:null),Se=Z.Children.only(t),Ce=Ft(G),we=[It(ee,Ce,i[0]),It(k,o,i[1])],Te=[It(O,Ce,i[0]),It(A,o,i[1])],Ee=Se.props,De=Ee.className,Oe=Ee.style,ke=Z.cloneElement(Se,{ref:ce,className:C(`react-grid-item`,De,y,{static:f,resizing:oe,"react-draggable":c,"react-draggable-dragging":z,dropping:!!v,cssTransforms:p}),style:{...b,...Oe,...me(xe)}}),Ae=N;return ke=(0,X.jsx)(Wr.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:xe.width,height:xe.height,minConstraints:we,maxConstraints:Te,onResizeStart:ve,onResize:ye,onResizeStop:be,transformScale:h,resizeHandles:M,handle:Ae,children:ke}),ke=(0,X.jsx)(Fr,{disabled:!c,onStart:he,onDrag:Y,onStop:ge,handle:x,cancel:`.react-resizable-handle`+(S?`,`+S:``),scale:h,allowMobileScroll:d,nodeRef:ce,children:ke}),ke}var Zr=Z.memo(Xr,(e,t)=>e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h&&e.minW===t.minW&&e.maxW===t.maxW&&e.minH===t.minH&&e.maxH===t.maxH&&e.cols===t.cols&&e.containerWidth===t.containerWidth&&e.rowHeight===t.rowHeight&&e.maxRows===t.maxRows&&e.margin===t.margin&&e.containerPadding===t.containerPadding&&e.transformScale===t.transformScale&&e.isDraggable===t.isDraggable&&e.isResizable===t.isResizable&&e.isBounded===t.isBounded&&e.allowMobileScroll===t.allowMobileScroll&&e.useCSSTransforms===t.useCSSTransforms&&e.usePercentages===t.usePercentages&&e.children===t.children&&e.onDrag===t.onDrag&&e.onDragStop===t.onDragStop&&e.onResize===t.onResize&&e.onResizeStop===t.onResizeStop&&e.droppingPosition===t.droppingPosition);Zr.displayName=`GridItem`;function Qr(e){let{clientX:t,clientY:n,gridElement:r,droppingItem:i,event:a,dragOffsetX:o=0,dragOffsetY:s=0,transformScale:c,cols:l,margin:u,maxRows:d,rowHeight:f,width:p,containerPadding:m}=e,h=r.getBoundingClientRect(),g={cols:l,margin:u,maxRows:d,rowHeight:f,containerWidth:p,containerPadding:m},_=Ft(g),v=It(i.w,_,u[0]),y=It(i.h,f,u[1]),b=v/2,x=y/2,S=r.scrollLeft??0,C=r.scrollTop??0,w=t-h.left+S+o-b,T=n-h.top+C+s-x,E=Math.max(0,w),D=Math.max(0,T);return{newDroppingPosition:{left:E/c,top:D/c,e:a},calculatedXY:Rt(g,D,E,i.w,i.h)}}var $r=()=>{},ei=`react-grid-layout`,ti=!1;try{ti=/firefox/i.test(navigator.userAgent)}catch{}function ni(e,t){let n=Z.Children.toArray(e),r=Z.Children.toArray(t);if(n.length!==r.length)return!1;for(let e=0;e{if(!Z.isValidElement(t)||t.key===null)return;let n=String(t.key);a.add(n);let r=e.find(e=>e.i===n);if(r)i.push(Zt(r));else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Jt(i),w:1,h:1})}});let o=tn(i,{cols:n});return r.compact(o,n)}function ii(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=Sn,compactor:c,constraints:l=on,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=$r,onDragStart:_=$r,onDrag:v=$r,onDragStop:y=$r,onResizeStart:b=$r,onResize:x=$r,onResizeStop:S=$r,onDrop:w=$r,onDropDragOver:T=$r}=e,E=(0,Z.useMemo)(()=>({...Cn,...r}),[r]),D=(0,Z.useMemo)(()=>({...wn,...i}),[i]),ee=(0,Z.useMemo)(()=>({...Tn,...a}),[a]),O=(0,Z.useMemo)(()=>({...En,...o}),[o]),{cols:k,rowHeight:A,maxRows:j,margin:M,containerPadding:N}=E,{enabled:P,bounded:F,handle:I,cancel:L,threshold:R,allowMobileScroll:te}=D,{enabled:ne,handles:re,handleComponent:ie}=ee,{enabled:z,defaultItem:ae,onDragOver:oe,touchEnabled:se=!0,touchDragSource:ce=`[data-rgl-draggable]`}=O,B=c??In(`vertical`),le=B.type,V=B.allowOverlap,ue=B.preventCollision??!1,de=(0,Z.useMemo)(()=>d??{i:`__dropping-elem__`,...ae},[d,ae]),fe=s.type===`transform`,H=s.scale,U=N??M,[pe,W]=(0,Z.useState)(!1),[G,K]=(0,Z.useState)(()=>ri(u,t,k,B)),[q,J]=(0,Z.useState)(null),[me,he]=(0,Z.useState)(!1),[Y,ge]=(0,Z.useState)(null),[_e,ve]=(0,Z.useState)(),ye=(0,Z.useRef)(void 0);ye.current=_e;let be=(0,Z.useRef)(null),xe=(0,Z.useRef)(null),Se=(0,Z.useRef)(null),Ce=(0,Z.useRef)(0),we=(0,Z.useRef)(G),Te=(0,Z.useRef)(u),Ee=(0,Z.useRef)(t),De=(0,Z.useRef)(le),Oe=(0,Z.useRef)(null),ke=(0,Z.useRef)(!1),Ae=(0,Z.useRef)(null),je=(0,Z.useRef)(null);je.current=Y;let Me=(0,Z.useRef)(w);(0,Z.useLayoutEffect)(()=>{Me.current=w});let Ne=(0,Z.useRef)(G);Ne.current=G,(0,Z.useEffect)(()=>{W(!0),(0,Gr.deepEqual)(G,u)||g(G)},[]),(0,Z.useEffect)(()=>{if(q||Y)return;let e=!(0,Gr.deepEqual)(u,Te.current),n=!ni(t,Ee.current),r=le!==De.current;if(e||n||r){let n=ri(e?u:G,t,k,B);(0,Gr.deepEqual)(n,G)||K(n)}Te.current=u,Ee.current=t,De.current=le},[u,t,k,le,B,q,Y,G]),(0,Z.useEffect)(()=>{if(!q&&!Y&&!(0,Gr.deepEqual)(G,we.current)){we.current=G;let e=G.filter(e=>e.i!==de.i);g(e)}},[G,q,Y,g,de.i]);let Pe=(0,Z.useMemo)(()=>{if(!f)return;let e=Jt(G),t=U[1];return e*A+(e-1)*M[1]+t*2+`px`},[f,G,A,M,U]),Fe=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=Yt(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};be.current=Zt(a),Se.current=i,J(o),_(i,a,a,null,r.e,r.node)},[_]),Ie=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=be.current,o=Yt(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=nn(i,o,t,n,!0,ue,le,k,V);v(c,a,o,s,r.e,r.node),K(B.compact(c,k)),J(s)},[ue,le,k,V,B,v]),Le=(0,Z.useCallback)((e,t,n,r)=>{if(!be.current)return;let i=Ne.current,a=be.current,o=Yt(i,e);if(!o)return;let s=nn(i,o,t,n,!0,ue,le,k,V),c=B.compact(s,k);y(c,a,o,null,r.e,r.node);let l=Se.current;be.current=null,Se.current=null,J(null),K(c),l&&!(0,Gr.deepEqual)(l,c)&&g(c)},[ue,le,k,V,B,y,g]),Re=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=Yt(i,e);a&&(xe.current=Zt(a),Se.current=i,he(!0),b(i,a,a,null,r.e,r.node))},[b]),ze=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=xe.current,{handle:o}=r,s=!1,c,l,[u,d]=en(i,e,e=>(c=e.x,l=e.y,[`sw`,`w`,`nw`,`n`,`ne`].includes(o)&&([`sw`,`nw`,`w`].includes(o)&&(c=e.x+(e.w-t),t=e.x!==c&&c<0?e.w:t,c=c<0?0:c),[`ne`,`n`,`nw`].includes(o)&&(l=e.y+(e.h-n),n=e.y!==l&&l<0?e.h:n,l=l<0?0:l),s=!0),ue&&!V&&Wt(i,{...e,w:t,h:n,x:c??e.x,y:l??e.y}).filter(t=>t.i!==e.i).length>0&&(l=e.y,n=e.h,c=e.x,t=e.w,s=!1),e.w=t,e.h=n,(o===`n`||o===`nw`||o===`ne`)&&(e.y=l??e.y),e));if(!d)return;let f=u;s&&c!==void 0&&l!==void 0&&(f=nn(u,d,c,l,!0,ue,le,k,V));let p={w:d.w,h:d.h,x:d.x,y:d.y,i:e,static:!0};x(f,a,d,p,r.e,r.node);let m=B.compact(f,k);if(o===`n`||o===`nw`||o===`ne`){let t=m.find(t=>t.i===e);t&&(t.y=d.y)}K(m),J(p)},[ue,le,k,V,B,x]),Be=(0,Z.useCallback)((e,t,n,r)=>{let i=Ne.current,a=xe.current,o=Yt(i,e),s=B.compact(i,k);S(s,a,o??null,null,r.e,r.node);let c=Se.current;xe.current=null,Se.current=null,J(null),he(!1),K(s),c&&!(0,Gr.deepEqual)(c,s)&&g(s)},[k,B,S,g]),Ve=(0,Z.useCallback)((e,t,n,r)=>{if(r)ye.current&&(ye.current.left!==t.left||ye.current.top!==t.top)&&(ve(t),K(t=>t.map(t=>t.i===e.i&&(t.x!==n.x||t.y!==n.y)?{...t,x:n.x,y:n.y}:t)));else{ge((0,X.jsx)(`div`,{},e.i)),ve(t);let r=Ne.current.filter(t=>t.i!==e.i);K([...r,{...e,x:n.x,y:n.y,static:!1,isDraggable:!0}])}},[]),He=(0,Z.useCallback)((e,t,r)=>{let i=Oe.current;if(!i)return;let{newDroppingPosition:a,calculatedXY:o}=Qr({clientX:e,clientY:t,gridElement:i,droppingItem:de,event:r,transformScale:H,cols:k,margin:M,maxRows:j,rowHeight:A,width:n,containerPadding:U});Ve(de,a,o,!!je.current)},[de,H,k,M,j,A,n,U,Ve]),Ue=(0,Z.useCallback)(()=>{let e=Ne.current;if(!e.some(e=>e.i===de.i)){ge(null),J(null),ve(void 0);return}let t=B.compact(e.filter(e=>e.i!==de.i),k);K(t),ge(null),J(null),ve(void 0)},[de.i,k,B]),We=(0,Z.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),ti&&!e.nativeEvent.target?.classList.contains(ei))return!1;let t=oe?oe(e.nativeEvent):T(e);if(t===!1)return Y&&Ue(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...de,...a},{newDroppingPosition:s,calculatedXY:c}=Qr({clientX:e.clientX,clientY:e.clientY,gridElement:e.currentTarget,droppingItem:o,event:e.nativeEvent,dragOffsetX:r,dragOffsetY:i,transformScale:H,cols:k,margin:M,maxRows:j,rowHeight:A,width:n,containerPadding:U});Ve(o,s,c,!!Y)},[Y,de,oe,T,Ue,Ve,H,k,M,j,A,n,U]),Ge=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ce.current--,Ce.current<0&&(Ce.current=0),Ce.current===0&&Ue()},[Ue]),Ke=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ce.current++},[]),qe=(0,Z.useCallback)(e=>{let t=Ne.current,n=t.find(e=>e.i===de.i);Ue(),Me.current(t,n,e)},[de.i,Ue]),Je=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ce.current=0,qe(e.nativeEvent)},[qe]);(0,Z.useEffect)(()=>{if(!z||!se)return;let e=Oe.current;if(!e)return;let t=(t,n)=>{let r=document.elementFromPoint(t,n);return r?e.contains(r):!1},n=e=>e instanceof HTMLElement&&e.closest(ce)!==null,r=e=>{let t=e.changedTouches;if(!t||t.length===0)return;let n=Ae.current;if(n===null)return t[0];for(let e=0;e{if(!n(e.target)||Ae.current!==null)return;e.preventDefault();let t=e.changedTouches?.[0];t&&(Ae.current=t.identifier,ke.current=!0)},a=e=>{if(!ke.current)return;e.preventDefault();let n=r(e);if(n){if(!t(n.clientX,n.clientY)){je.current&&Ue();return}He(n.clientX,n.clientY,e)}},o=e=>{if(!ke.current)return;e.preventDefault();let n=r(e);if(ke.current=!1,Ae.current=null,n){if(!t(n.clientX,n.clientY)){Ue();return}qe(e)}},s=()=>{ke.current&&(ke.current=!1,Ae.current=null,Ue())},c={passive:!1};return document.addEventListener(`touchstart`,i,c),document.addEventListener(`touchmove`,a,c),document.addEventListener(`touchend`,o,c),document.addEventListener(`touchcancel`,s,c),()=>{document.removeEventListener(`touchstart`,i,c),document.removeEventListener(`touchmove`,a,c),document.removeEventListener(`touchend`,o,c),document.removeEventListener(`touchcancel`,s,c)}},[z,se,ce,He,Ue,qe,de.i]);let Ye=(0,Z.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=Yt(G,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&P,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&ne,o=r.resizeHandles||[...re],c=i&&F&&r.isBounded!==!1,u=ie;return(0,X.jsx)(Zr,{containerWidth:n,cols:k,margin:M,containerPadding:U,maxRows:j,rowHeight:A,cancel:L,handle:I,onDragStart:Fe,onDrag:Ie,onDragStop:Le,onResizeStart:Re,onResize:ze,onResizeStop:Be,isDraggable:i,isResizable:a,isBounded:c,allowMobileScroll:te,useCSSTransforms:fe&&pe,usePercentages:!pe,transformScale:H,positionStrategy:s,dragThreshold:R,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:t?_e:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:G,children:e},r.i)},[G,n,k,M,U,j,A,L,I,Fe,Ie,Le,Re,ze,Be,P,ne,F,fe,pe,H,s,R,_e,re,ie,l]),Xe=()=>q?(0,X.jsx)(Zr,{w:q.w,h:q.h,x:q.x,y:q.y,i:q.i,className:`react-grid-placeholder ${me?`placeholder-resizing`:``}`,containerWidth:n,cols:k,margin:M,containerPadding:U,maxRows:j,rowHeight:A,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:fe,transformScale:H,constraints:l,layout:G,children:(0,X.jsx)(`div`,{})}):null,Ze=(0,Z.useCallback)(e=>{Oe.current=e,typeof h==`function`?h(e):h&&`current`in h&&(h.current=e)},[h]),Qe=C(ei,p),$e={height:Pe,...m};return(0,X.jsxs)(`div`,{ref:Ze,className:Qe,style:$e,onDrop:z?Je:void 0,onDragLeave:z?Ge:void 0,onDragEnter:z?Ke:void 0,onDragOver:z?We:void 0,children:[Z.Children.map(t,e=>Z.isValidElement(e)?Ye(e):null),z&&Y&&Ye(Y,!0),Xe()]})}var ai={lg:1200,md:996,sm:768,xs:480,xxs:0},oi={lg:12,md:10,sm:6,xs:4,xxs:2},si=()=>{};function ci(e,t,n,r,i=!1){let a=[];Z.Children.forEach(t,t=>{if(!Z.isValidElement(t)||t.key===null)return;let n=String(t.key),r=t.props[`data-grid`],o=e.find(e=>e.i===n);o?i&&r?a.push({...o,i:n,w:r.w??o.w,h:r.h??o.h,minW:r.minW??o.minW,maxW:r.maxW??o.maxW,minH:r.minH??o.minH,maxH:r.maxH??o.maxH}):a.push({...o,i:n}):r?a.push({i:n,x:r.x??0,y:r.y??0,w:r.w??1,h:r.h??1,minW:r.minW,maxW:r.maxW,minH:r.minH,maxH:r.maxH,static:r.static,isDraggable:r.isDraggable,isResizable:r.isResizable,resizeHandles:r.resizeHandles,isBounded:r.isBounded}):a.push({i:n,x:0,y:Jt(a),w:1,h:1})});let o=tn(a,{cols:n});return r.compact(o,n)}function li(e){let{children:t,width:n,breakpoint:r,breakpoints:i=ai,cols:a=oi,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=si,onLayoutChange:p=si,onWidthChange:m=si,...h}=e,g=d??In(`vertical`),_=g.type,v=g.allowOverlap,y=(0,Z.useMemo)(()=>r??Rn(i,n),[]),b=(0,Z.useMemo)(()=>zn(y,a),[y,a]),x=(0,Z.useMemo)(()=>Bn(o,i,y,y,b,_),[]),[S,C]=(0,Z.useState)(y),[w,T]=(0,Z.useState)(b),[E,D]=(0,Z.useState)(x),[ee,O]=(0,Z.useState)(o),k=(0,Z.useRef)(n),A=(0,Z.useRef)(r),j=(0,Z.useRef)(i),M=(0,Z.useRef)(a),N=(0,Z.useRef)(o),P=(0,Z.useRef)(_),F=(0,Z.useRef)(ee);(0,Z.useEffect)(()=>{F.current=ee},[ee]);let I=(0,Z.useMemo)(()=>(0,Gr.deepEqual)(o,N.current)?null:Bn(o,i,S,S,w,g),[o,i,S,w,g]),L=I??E;(0,Z.useEffect)(()=>{I!==null&&(D(I),O(o),F.current=o,N.current=o)},[I,o]),(0,Z.useEffect)(()=>{if(_!==P.current){let e=g.compact(Qt(L),w),t={...F.current,[S]:e};D(e),O(t),F.current=t,p(e,t),P.current=_}},[_,g,L,w,v,S,p]),(0,Z.useEffect)(()=>{let e=n!==k.current,o=r!==A.current,s=!(0,Gr.deepEqual)(i,j.current),c=!(0,Gr.deepEqual)(a,M.current);if(e||o||s||c){let e=r??Rn(i,n),o=zn(e,a),d=S;if(d!==e||s||c){let n={...F.current};n[d]||(n[d]=Qt(E));let r=Bn(n,i,e,d,o,g),a=!n[e];r=ci(r,t,o,g,a),n[e]=r,C(e),T(o),D(r),O(n),F.current=n,f(e,o),p(r,n)}let h=Vn(l,e),_=u?Vn(u,e):null;m(n,h,o,_),k.current=n,A.current=r,j.current=i,M.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let R=(0,Z.useCallback)(e=>{let t={...F.current,[S]:e};D(e),O(t),F.current=t,p(e,t)},[S,p]),te=(0,Z.useMemo)(()=>Vn(l,S),[l,S]),ne=(0,Z.useMemo)(()=>u===null?null:Vn(u,S),[u,S]),re=(0,Z.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:te,containerPadding:ne}),[w,s,c,te,ne]);return(0,X.jsx)(ii,{...h,width:n,gridConfig:re,compactor:g,onLayoutChange:R,layout:L,children:t})}var ui=Z.forwardRef(function(e,t){let{innerRef:n,...r}=e,i=n??t;return(0,X.jsx)(li,{...r,innerRef:i})});ui.displayName=`ResponsiveGridLayout`;function di(e,t,n){if(e.kind===`constant`)return e.value??``;let r=e.kind===`custom`?e.options?.map(e=>({value:e}))??[]:n===null?[]:n,i=t[e.name],a=!e.multi&&Array.isArray(i)&&i.length===0?void 0:i;if(a===`$__all`){if(e.include_all)return kt}else if(a!==void 0){if(e.kind===`text`||r===void 0)return a;let t=new Set(r.map(e=>e.value));if(Array.isArray(a)){if(a.length===0&&e.multi)return[];let n=a.filter(e=>t.has(e));if(n.length>0)return n}else if(t.has(a))return a}return e.default?e.default:e.include_all?kt:r?.[0]?.value??``}var fi=(e,t)=>e.replace(/\$([a-z][a-z0-9_]*)/g,(e,n)=>{let r=t[n];return r===void 0?e:r===`$__all`?`all`:Array.isArray(r)?r.join(`, `):r});function pi(e,t,n){let r={};for(let i of e??[]){let e=di(i,t,n?.[i.name]);(i.kind!==`query`||e!==``)&&(r[i.name]=e)}return r}function mi(e){return`Explain the panel “${e.title}”`}function hi(e){return`Fix the panel “${e.title}”`}function gi(e){return[{description:`Observed panel diagnostics`,value:JSON.stringify(e)}]}var _i=(0,Z.lazy)(()=>ae(()=>import(`./panel-editor-DrACmBUu.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]))),vi=0;function yi(e){let t;do t=`p_${Date.now().toString(36)}_${(++vi).toString(36)}_${Math.random().toString(36).slice(2,10)}`;while(e.some(e=>e.id===t));return t}function bi({dashboardId:e,version:t,spec:n,vars:r,results:i,fetching:a,annotations:o,fetchingIds:c=[],staleAt:l=new Map,time:u=n.time,onEditExit:d,editing:p,view:m,agentAvailable:h,canManage:g=!1,onOpenChat:_,onVariable:v,onRetry:y,onPoint:b,onZoom:x,onZoomReset:C,onWiden:w,zoomed:E,onView:D,onVisible:ee,onRangePending:O,shortcutScope:k,onShortcuts:A,overlayOpen:j,returnViewFocus:M}){let P=Be(),[I,L]=(0,Z.useState)(),[R,te]=(0,Z.useState)(()=>n.panels.map(e=>({i:e.id,x:e.grid?.x??0,y:e.grid?.y??0,w:e.grid?.w??6,h:e.grid?.h??Nt(e)})));(0,Z.useEffect)(()=>{te(n.panels.map(e=>({i:e.id,x:e.grid?.x??0,y:e.grid?.y??0,w:e.grid?.w??6,h:e.grid?.h??Nt(e)})))},[n]);let[ne,ie]=(0,Z.useState)(()=>window.innerHeight),[z,ae]=(0,Z.useState)();(0,Z.useEffect)(()=>{let e=()=>ie(window.innerHeight);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let oe=(0,Z.useRef)(null),se=(0,Z.useRef)(new Map),B=(0,Z.useRef)(null),le=(0,Z.useRef)(null),V=()=>{let e=I?.panel?.id;L(void 0),requestAnimationFrame(()=>(le.current?.isConnected?le.current:se.current.get(e??``))?.focus())},de=(0,Z.useRef)(m);m&&(de.current=m);let[H,U]=(0,Z.useState)(0),pe=H>0,W=p&&(H>=1100?`lg`:H>=800?`md`:`sm`)==`lg`;(0,Z.useLayoutEffect)(()=>{if(!oe.current)return;U(Math.max(0,Math.round(oe.current.getBoundingClientRect().width)));let e=new ResizeObserver(([e])=>{e&&U(Math.max(0,Math.round(e.contentRect.width)))});return e.observe(oe.current),()=>e.disconnect()},[]);let G=(0,Z.useRef)(ee);G.current=ee,(0,Z.useEffect)(()=>{if(!pe||!oe.current||typeof IntersectionObserver>`u`)return;let e=new Set(n.panels.map(e=>e.id)),t=new IntersectionObserver(t=>{for(let n of t){let t=n.target.dataset.panel;t&&(n.isIntersecting?e.add(t):e.delete(t))}m&&n.panels.some(e=>e.id===m)&&e.add(m),G.current([...e])},{rootMargin:`200px`});return oe.current.querySelectorAll(`.react-grid-item[data-panel]`).forEach(e=>t.observe(e)),()=>t.disconnect()},[n,m,pe]);let K=(0,Z.useMemo)(()=>n.panels.some(e=>{let t=R.find(t=>t.i===e.id);return t&&(t.x!==e.grid?.x||t.y!==e.grid?.y||t.w!==e.grid?.w||t.h!==e.grid?.h)}),[R,n]),q=e=>({...n,panels:e.map(e=>{let t=R.find(t=>t.i===e.id);return t?{...e,grid:{x:t.x,y:t.y,w:t.w,h:t.h}}:e})}),J=He({mutationFn:()=>Y(e,q(n.panels),t,`Edited layout`),onSuccess:t=>{P.setQueryData([`dashboard`,e],t)}}),me=He({mutationFn:r=>K?Y(e,q(n.panels.filter(e=>e.id!==r)),t,`Removed a panel and saved layout`):Te(e,[{op:`remove_panel`,id:r}],t,`Removed a panel`),onSuccess:t=>{P.setQueryData([`dashboard`,e],t)}}),he=He({mutationFn:r=>{let i={...r,id:yi(n.panels),title:`${Array.from(r.title).slice(0,73).join(``)} (copy)`,grid:void 0};if(K){let a=[...n.panels];return a.splice(a.findIndex(e=>e.id===r.id)+1,0,i),Y(e,q(a),t,`Duplicated a panel and saved layout`)}return Te(e,[{op:`add_panel`,after:r.id,panel:i}],t,`Duplicated a panel`)},onSuccess:t=>{P.setQueryData([`dashboard`,e],t)}});(0,Z.useEffect)(()=>{p||(J.reset(),me.reset(),he.reset())},[p]);let ge=()=>{J.reset(),me.reset(),he.reset(),d?.(),P.invalidateQueries({queryKey:[`dashboard`,e]})},_e=async e=>{let t=new URL(window.location.href);t.searchParams.set(`view`,e),t.searchParams.delete(`edit`);try{await navigator.clipboard.writeText(t.toString()),ae(`Link copied`)}catch{ae(`Copy this URL: ${t.toString()}`)}},ve=`dashboard-${e}`,ye=n=>({dashboard_id:e,version:t,panel_id:n.id,title:fi(n.title,r),from_ms:i.get(n.id)?.from_ms,to_ms:i.get(n.id)?.to_ms,vars:r,error:i.get(n.id)?.error,status:i.get(n.id)?.status,diagnosis:i.get(n.id)?.diagnosis,stale_since:l.get(n.id),truncated:i.has(n.id)?!!(i.get(n.id)?.frame?.truncated||i.get(n.id)?.previous?.truncated):void 0,note:i.get(n.id)?.frame?.note,spec:{...n,dashboard_time:u}}),be=(s,d,f=!1)=>(0,X.jsx)(ce,{panel:s,title:fi(s.title,r),result:i.get(s.id),loading:a&&c.includes(s.id),height:d,group:ve,editing:W&&!f,agentAvailable:h,suspended:!f&&s.id===m,menuRef:f?B:e=>{e?se.current.set(s.id,e):se.current.delete(s.id)},compare:u.compare===`previous_period`,range:s.time?.range??u.range,annotations:o,vars:r,onVariable:v,...ue(s,i.get(s.id),v,b?e=>b(s,e):void 0),onRangePending:e=>O?.(s.id,e),onZoom:x,zoomed:E,onZoomReset:C,onWiden:w,onRetry:y?()=>y(s.id):void 0,onView:()=>D(s.id),onCopyLink:()=>{_e(s.id)},onEdit:g&&e&&(s.query||typeof s.sql==`string`)?()=>{le.current=f?B.current:se.current.get(s.id)??null,L({panel:s,spec:n,version:t})}:void 0,onExplain:h&&e?()=>_(mi(ye(s)),{answer_only:!0,context:gi(ye(s))}):void 0,onFix:h&&e&&g?()=>_(hi(ye(s)),{context:gi(ye(s))}):void 0,staleAt:l.get(s.id),onDuplicate:W&&!f?()=>he.mutate(s):void 0,onRemove:W&&!f?()=>me.mutate(s.id):void 0}),xe=n.panels.find(e=>e.id===m),Se=p?J.error??me.error??he.error:null,Ce=Se instanceof ze&&Se.code===`dashboard_version_conflict`,we=e=>{W&&te(e.map(({i:e,x:t,y:n,w:r,h:i})=>({i:e,x:t,y:n,w:r,h:i})))};return(0,X.jsxs)(`div`,{ref:oe,style:{minWidth:0},children:[p&&(0,X.jsxs)(f,{justify:`space-between`,mb:`sm`,p:`xs`,style:{border:`1px dashed var(--mantine-color-default-border)`,borderRadius:8},children:[(0,X.jsx)(N,{size:`sm`,c:`dimmed`,children:W?`Drag a panel by its title and resize it from the corner. Changes are saved as a new version.`:`The layout can be edited only on a wider screen.`}),(0,X.jsxs)(f,{gap:`xs`,children:[g&&e&&(0,X.jsx)(F,{size:`compact-sm`,variant:`default`,onClick:e=>{le.current=e.currentTarget,L({spec:n,version:t})},children:`Add panel`}),(0,X.jsx)(F,{size:`compact-sm`,disabled:!K||!W,loading:J.isPending,onClick:()=>J.mutate(),children:`Save layout`})]})]}),Ce&&(0,X.jsx)(S,{mb:`sm`,children:(0,X.jsxs)(re,{tone:`warning`,children:[`Someone saved this dashboard since you opened it. Load the latest version, then redo your change. `,(0,X.jsx)(F,{size:`compact-sm`,onClick:ge,children:`Load latest`})]})}),Se&&!Ce&&(0,X.jsx)(S,{mb:`sm`,children:(0,X.jsx)(re,{tone:`danger`,children:Se.message})}),z&&(0,X.jsx)(S,{mb:`sm`,children:(0,X.jsx)(re,{tone:`info`,children:z})}),!pe&&(0,X.jsx)(`div`,{"data-grid-placeholder":!0,style:{height:At(Math.max(1,...R.map(e=>e.y+e.h)))}}),pe&&(0,X.jsx)(ui,{width:H,className:`dashboard-grid${W?` dashboard-grid-editing`:``}`,layouts:{lg:R,md:R,sm:R.map(e=>({...e,x:0,w:12}))},breakpoints:{lg:1100,md:800,sm:0},cols:{lg:12,md:12,sm:12},rowHeight:40,margin:[12,12],containerPadding:[0,0],compactor:An,dragConfig:{enabled:W,handle:`.panel-drag`,cancel:`button`},resizeConfig:{enabled:W},onDragStop:we,onResizeStop:we,children:n.panels.map(e=>{let t=R.find(t=>t.i===e.id);return(0,X.jsx)(`div`,{"data-panel":e.id,children:be(e,At(t?.h??6))},e.id)})}),(0,X.jsx)(fe,{shortcutScope:k,onShortcuts:A,escapeEnabled:!j&&!I,opened:!!m,onClose:()=>D(void 0),title:xe?fi(xe.title,r):`Missing panel`,returnFocusTo:()=>M?.(de.current)??se.current.get(de.current??``)??se.current.values().next().value,children:xe?(0,X.jsx)(`div`,{style:{height:`calc(100vh - 120px)`},children:be(xe,Math.max(40,ne-140),!0)}):(0,X.jsx)(S,{children:(0,X.jsx)(re,{tone:`warning`,children:`This panel is missing from the dashboard. The shared link may be out of date.`})})}),I&&e&&(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(s,{opened:!0,onClose:V,title:`Loading the panel editor`,children:(0,X.jsx)(T,{state:`loading`,loadingLabel:`Loading the panel editor`,rows:3})}),children:(0,X.jsx)(_i,{dashboardId:e,version:I.version,spec:q(I.spec.panels),layoutChanged:W&&K,panel:I.panel,time:u,vars:r,onClose:V})})]})}function xi({spec:e,onClose:t,onCreated:n}){let r=Be(),[i,a]=(0,Z.useState)(`${e.name} copy`),[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(),d=async()=>{c(!0),u(void 0);try{let t=await ye({...e,name:i.trim()});r.invalidateQueries({queryKey:Se}),n(t.id)}catch(e){u(e instanceof Error?e.message:`Duplicate failed`)}finally{c(!1)}};return(0,X.jsx)(s,{opened:!0,onClose:()=>{o||t()},title:`Duplicate dashboard`,children:(0,X.jsxs)(x,{gap:`md`,children:[(0,X.jsx)(z,{label:`New dashboard name`,value:i,onChange:e=>a(e.currentTarget.value),"data-autofocus":!0}),l&&(0,X.jsx)(S,{children:(0,X.jsx)(re,{tone:`danger`,children:l})}),(0,X.jsxs)(f,{justify:`flex-end`,gap:`xs`,children:[(0,X.jsx)(F,{variant:`default`,disabled:o,onClick:t,children:`Cancel`}),(0,X.jsx)(F,{loading:o,disabled:!i.trim()||i.trim()===e.name,onClick:()=>void d(),children:`Duplicate`})]})]})})}var Si=(e,t)=>!(t instanceof ze&&t.status<500)&&e<2,Ci=(e,t)=>!(t instanceof ze&&t.code===`timeout`)&&Si(e,t),wi=e=>({panels:e.panels.map(({grid:e,...t})=>t),variables:e.variables,time:e.time,annotations:e.annotations});function Ti(e,t,n,r,i){return[`panels`,JSON.stringify([e,wi(t),n,r,i])]}function Ei(e,t,n,r){return[`variables`,e,wi(t),n,r]}var Di=2;async function Oi(e,t,n,r=[],i=!1){let a=r.filter(t=>e.panels?.includes(t)),o=e.panels?.filter(e=>!a.includes(e)),s=a.length&&!o?.length?[]:await we(a.length?{...e,panels:o}:e,t,n,i);for(let r=0;re.reason===`busy`))break}let c=new Set(e.dashboard.panels.filter(e=>[`timeseries`,`heatmap`,`state_timeline`].includes(e.viz)).map(e=>e.id)),l=s.filter(e=>c.has(e.id)&&e.from_ms!==void 0&&e.to_ms!==void 0&&e.from_mse.from_ms)),d=Math.max(...l.map(e=>e.to_ms));try{let e=await he({from:new Date(u).toISOString(),to:new Date(d).toISOString()},t);return{results:s,annotations:e}}catch(e){if(t?.aborted)throw e;return{results:s,annotation_error:e instanceof Error?e.message:`Annotations unavailable`}}}var ki={off:!1,"10s":1e4,"30s":3e4,"1m":6e4,"5m":3e5},Ai=0;function ji(e,t){let[n,r]=e.queryKey;if(n!==`panels`||typeof r!=`string`)return!1;try{return JSON.parse(r)[0]===t}catch{return!1}}function Mi({dashboardId:e,spec:t,time:n,vars:r,compare:i,widths:a,visible:o,refresh:s,enabled:c=!0}){let l=(0,Z.useMemo)(()=>Object.fromEntries(Object.entries(a).map(([e,t])=>[e,Math.max(100,Math.round(t/100)*100)])),[a]),u=Ti(e,t,n,r,i),d=u[1],f=o.filter(e=>t.panels.some(t=>t.id===e)),p=(0,Z.useRef)([]),m=(0,Z.useRef)(new Set),h=(0,Z.useRef)(void 0),g=(0,Z.useRef)(null),_=(0,Z.useRef)(!1),v=(0,Z.useRef)(!1),y=(0,Z.useRef)(null),b=(0,Z.useRef)({key:d,ids:new Set}),[x,S]=(0,Z.useState)({key:d}),[C,w]=(0,Z.useState)({key:d,results:new Map,updated:new Map,stale:new Set,receivedAt:0}),T=f.length===0&&C.key===d&&C.receivedAt>0,E=c&&t.panels.some(e=>e.viz!==`text`),D=Ve({queryKey:u,queryFn:({signal:e})=>{if(T&&g.current?.key!==d)return p.current=[],Promise.resolve({results:[],hasTimePanels:!1,batch:++Ai});let a=g.current?.key===d?g.current.ids:f;p.current=(a.length?[...a]:t.panels.map(e=>e.id)).sort(),b.current.key!==d&&(b.current={key:d,ids:new Set});for(let e of p.current)b.current.ids.add(e);let o=[...p.current],s=v.current;v.current=!1;let c=m.current=new Set,u=t=>{if(e.aborted)return;c.add(t.id);let n=Date.now(),r=++Ai;w(e=>Ni(e,d,[H(t,o)],n,r))},_=C.key===d?o.filter(e=>C.results.get(e)?.reason===`busy`):[];return Oi({dashboard:t,panels:o,time:n,vars:r,widths:l,compare:i},e,u,_,s).then(e=>{let n=new Set(e.results.map(e=>e.id)),r=o.filter(e=>!n.has(e)&&!_.includes(e)&&t.panels.find(t=>t.id===e)?.viz!==`text`).map(e=>({id:e,status:`error`,elapsed_ms:0,error:`No result was returned for this panel; refresh to retry.`,request_error:o}));return{...e,batch:++Ai,results:[...e.results.map(e=>H(e,o)),...r],hasTimePanels:t.panels.some(e=>o.includes(e.id)&&[`timeseries`,`heatmap`,`state_timeline`].includes(e.viz))}}).catch(n=>{throw e.aborted||(h.current={key:d,ids:o.filter(e=>!c.has(e)&&t.panels.find(t=>t.id===e)?.viz!==`text`),error:n instanceof Error?n.message:String(n),retryable:!(n instanceof ze)||n.status===408||n.status===429||n.status>=500}),n})},retry:Ci,enabled:E,refetchInterval:T?!1:ki[s]??3e4,staleTime:5e3,placeholderData:e=>e}),ee=D.error&&h.current?.key===d?h.current:void 0,O=(0,Z.useMemo)(()=>Ni(C,d,D.isPlaceholderData?void 0:D.data?.results,D.dataUpdatedAt,D.data?.batch,ee),[C,d,D.data,D.dataUpdatedAt,D.isPlaceholderData,D.error,D.errorUpdatedAt]),k=O.results,A=D.isPlaceholderData?void 0:D.data?.hasTimePanels?D.data:x.key===d?x:void 0;(0,Z.useEffect)(()=>{!D.isPlaceholderData&&D.data?.hasTimePanels&&S({key:d,annotations:D.data.annotations,annotation_error:D.data.annotation_error})},[d,D.data,D.isPlaceholderData]),(0,Z.useEffect)(()=>{D.isPlaceholderData||w(e=>Ni(e,d,D.data?.results,D.dataUpdatedAt,D.data?.batch,ee))},[d,D.data,D.dataUpdatedAt,D.isPlaceholderData,D.error,D.errorUpdatedAt]);let j=new Map([...O.stale].flatMap(e=>{let t=O.updated.get(e);return t?[[e,t]]:[]})),M=(D.data?.results??[]).find(e=>e.status===`error`&&e.reason!==`busy`&&O.stale.has(e.id)),N=(D.data?.results??[]).flatMap(e=>e.reason===`busy`&&O.stale.has(e.id)?[O.updated.get(e.id)??0]:[]),P=Math.max(0,...[...O.updated].filter(([e])=>{let t=O.results.get(e);return t?.reason!==`busy`||t.frame!==void 0}).map(([,e])=>e));(0,Z.useEffect)(()=>{if(b.current.key===d)for(let e of b.current.ids)k.get(e)?.reason===`busy`&&!f.includes(e)&&b.current.ids.delete(e)},[o,d,k]),(0,Z.useEffect)(()=>{if(!E||D.isFetching||_.current||y.current?.key===d||g.current?.key===d)return;let e=b.current.key===d?b.current.ids:new Set,n=[...new Set(f.filter(n=>(!k.has(n)||k.get(n)?.reason===`busy`)&&!e.has(n)&&t.panels.find(e=>e.id===n)?.viz!==`text`))].sort();if(!n.length)return;let r={key:d,ids:n};g.current=r,D.refetch({cancelRefetch:!1}).finally(()=>{g.current===r&&(g.current=null)})},[o,E,d,D.isFetching,D.error,D.refetch,k,t.panels]),(0,Z.useEffect)(()=>{!D.isFetching&&y.current?.key!==d&&_.current&&(_.current=!1,g.current=null,E&&!T&&(v.current=!0,D.refetch({cancelRefetch:!1})))},[D.isFetching,d,E,T,D.refetch]);let F=e=>{let t={key:d,ids:e};g.current=t,D.refetch({cancelRefetch:!1}).finally(()=>{g.current===t&&(g.current=null)})};return(0,Z.useEffect)(()=>{if(D.isFetching||!y.current)return;let e=y.current;if(y.current=null,e.key!==d||!E)return;let n=[...e.ids].filter(e=>t.panels.some(t=>t.id===e&&t.viz!==`text`)&&k.get(e)?.request_error).sort();n.length&&F(n)},[D.isFetching,d,E,k,t.panels]),{retry:e=>{if(E&&t.panels.some(t=>t.id===e&&t.viz!==`text`)&&k.get(e)?.request_error){if(D.isFetching){y.current?.key!==d&&(y.current={key:d,ids:new Set}),y.current.ids.add(e);return}F([e])}},results:k,staleAt:j,annotations:A?.annotations,annotationError:A?.annotation_error,fetchingIds:D.isFetching?p.current.filter(e=>!m.current.has(e)):[],fetching:D.isFetching,error:D.error??(M?Error(M.error??`Panel refresh failed`):null),updatedAt:P||null,skippedAt:N.length?Math.min(...N):null,refetch:()=>{if(E&&!T){if(D.isFetching){g.current?.key===d&&(_.current=!0);return}v.current=!0,D.refetch({cancelRefetch:!1})}}}}function Ni(e,t,n,r,i,a){let o=e.key===t?{key:t,results:new Map(e.results),updated:new Map(e.updated),stale:new Set(e.stale),receivedAt:e.receivedAt,receivedBatch:e.receivedBatch}:{key:t,results:new Map,updated:new Map,stale:new Set,receivedAt:0},s=n&&i!==void 0&&(o.receivedBatch===void 0||i>o.receivedBatch);for(let e of s?n:[])e.status===`error`&&o.results.get(e.id)?.frame?(o.stale.add(e.id),o.results.set(e.id,{...o.results.get(e.id),error:e.error,reason:e.reason,request_error:e.request_error})):(o.results.set(e.id,e),o.updated.set(e.id,r),o.stale.delete(e.id));s&&(o.receivedAt=r,o.receivedBatch=i);for(let e of a?.ids??[]){let t=o.results.get(e);t?.frame?(o.stale.add(e),o.results.set(e,{...t,error:a.error,reason:void 0,request_error:a.retryable?a.ids:void 0})):o.results.set(e,{id:e,status:`error`,elapsed_ms:0,error:a.error,request_error:a.retryable?a.ids:void 0})}return o}function Pi(e,t){return e.queryKey[0]===`variables`&&e.queryKey[1]===t}function Fi(e,t,n,r,i,a=!1){let o=!!t.variables?.some(e=>e.kind===`query`),s=Ve({queryKey:Ei(e,t,n,r),queryFn:async({signal:e})=>{let a=await i({dashboard:t,time:n,vars:r},e);return Object.fromEntries((t.variables??[]).map(e=>[e.name,a[e.name]??(e.kind===`custom`?e.options?.map(e=>({value:e})):void 0)??[]]))},enabled:o,retry:a,staleTime:6e4,placeholderData:e=>e}),c=s.isPlaceholderData?void 0:s.data,l=s.isError||(t.variables??[]).every(e=>e.kind!==`query`||r[e.name]!==void 0&&r[e.name]!==`$__all`&&(e.multi||!Array.isArray(r[e.name])||r[e.name].length>0)||!!e.default||e.include_all||c?.[e.name]!==void 0);return{...s,currentData:c,ready:l}}function Ii(e){return t=>ji(t,e)||Pi(t,`dashboard-${e}`)}function Li({id:e,currentVersion:t,currentSpec:n,opened:r,onClose:i,onRestored:a}){let o=Be(),[s,c]=(0,Z.useState)(),[l,u]=(0,Z.useState)(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(r),h=(0,Z.useRef)(0),g=(0,Z.useRef)(r);g.current=r;let _=(0,Z.useRef)(!1),v=(0,Z.useRef)(!1),y=(0,Z.useRef)(a);y.current=a,(0,Z.useEffect)(()=>(v.current=!0,()=>{v.current=!1}),[]);let b=He({mutationFn:({version:t})=>me(e,t),retry:!1,onSuccess:(t,{version:n,generation:r})=>{o.cancelQueries({queryKey:[`dashboard`,e],exact:!0}),o.cancelQueries({predicate:Ii(e)}),o.cancelQueries({queryKey:[`exemplars`]}),o.cancelQueries({queryKey:[`drill-trace`]}),o.setQueryData([`dashboard`,e],t),o.invalidateQueries({predicate:Ii(e),refetchType:`none`}),v.current&&(g.current&&r===h.current&&u({text:`Restored v${n} as v${t.version}`}),y.current(t)),o.invalidateQueries({queryKey:Se}),o.invalidateQueries({queryKey:[`dashboard-versions`,e]},{cancelRefetch:!1}),o.invalidateQueries({queryKey:[`exemplars`],refetchType:`none`}),o.invalidateQueries({queryKey:[`drill-trace`],refetchType:`none`})},onError:t=>{t instanceof ze&&t.code===`dashboard_version_not_found`&&o.invalidateQueries({queryKey:[`dashboard-versions`,e]})},onSettled:()=>{_.current=!1,v.current&&f(!1)}}),x=()=>{h.current++,b.reset(),u(void 0)};(0,Z.useEffect)(()=>{if(r){m(!0);return}h.current++,b.reset(),u(void 0),o.cancelQueries({queryKey:[`dashboard-versions`,e]}),o.cancelQueries({queryKey:[`dashboard-version`,e]})},[r,e,o,b.reset]);let S=(0,Z.useRef)(t);return(0,Z.useEffect)(()=>{S.current!==t&&(S.current=t,o.invalidateQueries({queryKey:[`dashboard-versions`,e]},{cancelRefetch:!1}))},[t,e,o]),(0,X.jsx)(oe,{opened:r,onClose:()=>{x(),i()},onExitTransitionEnd:()=>m(!1),title:`Version history`,position:`right`,size:`xl`,children:(r||p)&&(0,X.jsx)(Ri,{id:e,opened:r,currentVersion:t,currentSpec:n,selected:s,onSelect:e=>{x(),c(e)},pending:d,error:b.error,failedVersion:b.variables?.version,success:l,onRestore:e=>{_.current||(_.current=!0,f(!0),u(void 0),b.mutate({version:e,generation:h.current}))}})})}function Ri({id:e,opened:t,currentVersion:n,currentSpec:r,selected:a,onSelect:o,pending:s,error:c,failedVersion:l,success:u,onRestore:d}){let p=Ve({queryKey:[`dashboard-versions`,e],queryFn:({signal:t})=>_e(e,t),enabled:t,retry:!1}),m=a??p.data?.[0]?.version,h=Ve({queryKey:[`dashboard-version`,e,m],queryFn:({signal:t})=>Ce(e,m,t),enabled:t&&m!==void 0,retry:!1}),g=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{u&&g.current?.focus()},[u]),(0,X.jsxs)(x,{gap:`md`,"data-version-history":!0,children:[(0,X.jsx)(N,{size:`sm`,c:`dimmed`,children:`Inspect saved specs and changes. Restoring adds a new version.`}),u&&(0,X.jsx)(S,{ref:g,tabIndex:-1,role:`note`,children:(0,X.jsx)(re,{live:!1,tone:`success`,children:u.text})}),c&&l===m&&(0,X.jsx)(Hi,{error:c,version:m}),(0,X.jsxs)(S,{mih:160,children:[p.isPending&&(0,X.jsx)(T,{state:`loading`,loadingLabel:`Loading history…`,rows:3}),p.error&&(0,X.jsx)(S,{children:(0,X.jsxs)(re,{tone:`danger`,title:`History unavailable`,children:[p.error.message,(0,X.jsx)(F,{mt:`xs`,variant:`default`,size:`xs`,onClick:()=>void p.refetch(),children:`Retry history`})]})}),p.data?.length===0&&(0,X.jsx)(T,{state:`empty`,empty:{title:`No versions available.`,description:`Version history appears after a dashboard is saved.`,action:(0,X.jsx)(F,{variant:`default`,onClick:()=>void p.refetch(),children:`Retry history`})}}),!!p.data?.length&&(0,X.jsx)(L,{h:200,type:`auto`,children:(0,X.jsx)(x,{gap:`xs`,pr:`sm`,role:`list`,"aria-label":`Saved versions`,children:p.data.map(e=>(0,X.jsxs)(i,{role:`listitem`,withBorder:!0,p:`xs`,radius:`sm`,style:{borderColor:m===e.version?`var(--mantine-color-accent-filled)`:void 0},children:[(0,X.jsxs)(f,{justify:`space-between`,gap:`xs`,children:[(0,X.jsxs)(F,{color:`accent`,variant:m===e.version?`light`:`subtle`,size:`compact-sm`,"aria-pressed":m===e.version,onClick:()=>o(e.version),children:[`Version `,e.version]}),e.version===n&&(0,X.jsx)(k,{tone:`neutral`,children:`Current`}),(0,X.jsx)(Bi,{at:e.created_at})]}),(0,X.jsxs)(N,{size:`xs`,c:`dimmed`,mt:4,children:[zi(e),` · `,e.message||`No edit message`]})]},e.version))})})]}),(0,X.jsx)(O,{role:`status`,"aria-live":`polite`,children:m===void 0?`Select a version.`:h.isFetching?`Loading version ${m}…`:h.error?`Version ${m} unavailable.`:`Version ${m} ready.`}),(0,X.jsxs)(S,{mih:280,"aria-busy":h.isFetching,children:[m!==void 0&&h.isPending&&(0,X.jsx)(T,{state:`loading`,loadingLabel:`Loading version…`,rows:3}),h.error&&(0,X.jsx)(S,{children:(0,X.jsxs)(re,{tone:`danger`,title:h.error instanceof ze&&h.error.code===`dashboard_version_not_found`?`This version is no longer available`:`Version unavailable`,children:[h.error.message,(0,X.jsx)(F,{mt:`xs`,variant:`default`,size:`xs`,onClick:()=>void h.refetch(),children:`Retry version`})]})}),h.data&&!h.error&&(0,X.jsx)(Vi,{record:h.data,currentVersion:n,current:JSON.stringify(h.data.dashboard.spec)===JSON.stringify(r),pending:s,onRestore:()=>d(h.data.dashboard.version)})]})]})}function zi(e){return e.author_kind===`agent`?`Agent`:e.author_kind===`user`?`You`:`System`}function Bi({at:e}){let t=(Date.parse(e)-Date.now())/1e3,[n,r]=Math.abs(t)<60?[1,`second`]:Math.abs(t)<3600?[60,`minute`]:Math.abs(t)<86400?[3600,`hour`]:[86400,`day`];return(0,X.jsx)(N,{component:`time`,dateTime:e,title:De(e),size:`xs`,c:`dimmed`,children:new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(t/n),r)})}function Vi({record:e,currentVersion:t,current:n,pending:r,onRestore:i}){let{dashboard:a}=e,o=Ue(e);return(0,X.jsxs)(x,{gap:`sm`,"data-history-version":a.version,children:[(0,X.jsxs)(f,{justify:`space-between`,align:`flex-start`,children:[(0,X.jsxs)(S,{miw:0,children:[(0,X.jsxs)(b,{order:2,fz:`lg`,children:[a.name,` · v`,a.version]}),(0,X.jsxs)(N,{size:`sm`,c:`dimmed`,children:[zi(e),` · `,e.message||`No edit message`]}),(0,X.jsx)(Bi,{at:e.created_at})]}),a.version===t?(0,X.jsx)(F,{size:`sm`,variant:`default`,disabled:!0,children:`Current version`}):n?(0,X.jsx)(F,{size:`sm`,variant:`default`,disabled:!0,children:`Same as current`}):(0,X.jsxs)(F,{size:`sm`,disabled:r,loading:r,onClick:i,children:[`Restore version `,a.version]})]}),a.description&&(0,X.jsx)(N,{size:`sm`,children:a.description}),e.changes_available?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ye,{labels:o}),!o.length&&!e.layout_changed&&(0,X.jsx)(T,{state:`empty`,empty:{title:`No authored changes.`}})]}):(0,X.jsx)(S,{children:(0,X.jsx)(re,{tone:`warning`,title:`Changes unavailable`,children:`The preceding version is no longer retained. This saved spec is still available.`})}),(0,X.jsxs)(N,{size:`sm`,c:`dimmed`,children:[`Read-only · `,a.spec.panels.length,` panels. Historical data is not queried.`]}),(0,X.jsxs)(ot,{variant:`contained`,children:[(0,X.jsxs)(ot.Item,{value:`spec`,children:[(0,X.jsx)(ot.Control,{children:`Spec`}),(0,X.jsx)(ot.Panel,{children:(0,X.jsx)(Le,{block:!0,tabIndex:0,style:{maxHeight:320,overflow:`auto`},children:JSON.stringify(a.spec,null,2)})})]}),(0,X.jsxs)(ot.Item,{value:`data`,children:[(0,X.jsx)(ot.Control,{children:`Data`}),(0,X.jsx)(ot.Panel,{children:(0,X.jsx)(x,{gap:`xs`,children:a.spec.panels.map(e=>(0,X.jsxs)(S,{children:[(0,X.jsxs)(N,{size:`sm`,fw:500,children:[e.title,` · `,e.viz]}),(0,X.jsx)(Le,{block:!0,tabIndex:0,children:e.content??e.sql??JSON.stringify(e.query??{},null,2)})]},e.id))})})]})]})]})}function Hi({error:e,version:t}){let n=e instanceof ze?e.code:void 0,r=!(e instanceof ze)||e.status>=500?`Try again with the restore button.`:n===`invalid_spec`?`This saved spec is invalid. Review the fields below and choose another version.`:n===`dashboard_version_not_found`?`Reload history and choose a retained version.`:n===`already_current`?`The dashboard already has this version's contents, so there is nothing to restore.`:[`dashboard_version_conflict`,`conflict`].includes(n??``)?`This dashboard changed or its name conflicts. Reload history and choose another version.`:`Check your access and reload history.`;return(0,X.jsx)(S,{children:(0,X.jsxs)(re,{tone:`danger`,title:`Restore of version ${t} failed`,children:[(0,X.jsx)(N,{size:`sm`,children:e.message}),e instanceof ze&&e.problems.length>0&&(0,X.jsx)(`ul`,{children:e.problems.map((e,t)=>(0,X.jsxs)(`li`,{children:[e.path,`: `,e.message,e.hint?` (${e.hint})`:``]},t))}),(0,X.jsx)(N,{size:`sm`,mt:`xs`,children:r})]})})}function Ui(e,t){let n=JSON.stringify([e.range,e.from,e.to]),r=(0,Z.useRef)({search:e,onSearch:t,scope:n}),i=(0,Z.useRef)(``),a=(0,Z.useRef)(void 0),[o,s]=(0,Z.useState)(!1);r.current.scope!==n&&(i.current!==`${e.from}/${e.to}`&&(a.current=void 0,o&&s(!1)),i.current=``),r.current={search:e,onSearch:t,scope:n};let c=(0,Z.useCallback)(()=>{i.current=``,a.current=void 0,s(!1)},[]),l=(0,Z.useCallback)(()=>{if(!a.current)return;let e=a.current;c(),r.current.onSearch({...r.current.search,...e},!1)},[c]);return{zoom:(0,Z.useCallback)((e,t)=>{let n=U(e,t);if(!n)return;let o=r.current,c=`${n.from}/${n.to}`;o.search.from===n.from&&o.search.to===n.to||i.current===c||(a.current??={range:o.search.range,from:o.search.from,to:o.search.to},s(!0),i.current=c,o.onSearch({...o.search,range:void 0,...n},!1))},[]),reset:c,resetZoom:l,zoomed:o}}function Wi({variables:e,vars:t,options:n,onChange:r}){return e.length===0?null:(0,X.jsx)(f,{gap:`sm`,wrap:`wrap`,role:`group`,"aria-label":`Dashboard variables`,children:e.map(e=>{let i=di(e,t,n[e.name]),a=[...e.include_all?[{value:kt,label:`All`}]:[],...(n[e.name]??e.options?.map(e=>({value:e}))??[]).map(e=>({value:e.value,label:e.value}))],o=(0,X.jsxs)(N,{size:`sm`,c:`dimmed`,ff:`monospace`,children:[`$`,e.name]});return e.kind===`constant`?(0,X.jsx)(z,{label:o,size:`sm`,value:e.value,readOnly:!0,w:160},e.name):e.kind===`text`?(0,X.jsx)(z,{label:o,size:`sm`,w:200,defaultValue:typeof i==`string`?i:``,onBlur:t=>r(e.name,t.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}},`${e.name}:${JSON.stringify(i)}`):e.multi?(0,X.jsx)(Dt,{label:o,size:`sm`,w:260,searchable:!0,clearable:!0,data:a.filter(e=>e.value!==kt),value:Array.isArray(i)?i:i&&i!==`$__all`?[i]:[],placeholder:e.include_all?`All`:`None`,onChange:t=>r(e.name,t.length?t:e.include_all?kt:[])},e.name):(0,X.jsx)(le,{label:o,size:`sm`,w:220,searchable:!0,allowDeselect:!1,data:a,value:Array.isArray(i)?i[0]??null:i||null,onChange:t=>t!==null&&r(e.name,t)},e.name)})})}function Gi(e,t,n=!1){let r=e.target;return t||e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey&&e.key!==`?`||r instanceof Element&&r.closest(`input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="menu"]`)||r instanceof Element&&r.closest(`[role="dialog"]`)&&!(n&&r.closest(`[data-panel-fullscreen]`))?null:[`r`,`e`,`h`,`f`,`?`].includes(e.key)?e.key:null}function Ki(e,t,n={}){let r=(0,Z.useRef)({actions:t,options:n});r.current={actions:t,options:n},(0,Z.useEffect)(()=>{let t=t=>{let n=e.current,i=t.target,{actions:a,options:o}=r.current;if(!n||!(i instanceof Element)||o.enabled===!1)return;let s=o.fullscreenScope?[...document.querySelectorAll(`[data-shortcut-scope]`)].find(e=>e.dataset.shortcutScope===o.fullscreenScope&&e.hasAttribute(`data-panel-fullscreen`)):void 0,c=n.contains(i)&&n.contains(document.activeElement),l=i===document.body&&document.activeElement===document.body,u=s?.contains(i)&&s.contains(document.activeElement);if(!c&&!l&&!u)return;let d=Gi(t,!!(o.modalOpen||[...document.querySelectorAll(`[role="dialog"]`)].some(e=>e!==s)),!!s);if(!d||s&&![`r`,`f`,`?`].includes(d))return;let f=a[d];f&&(t.preventDefault(),f(i))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e])}function qi({opened:e,onClose:t,fullscreen:n=!1,enabled:r,onEnabled:i}){let a=[[`r`,`Refresh now`],...n?[]:[[`e`,`Toggle layout mode`],[`h`,`Open history`]],[`f`,n?`Exit full-screen`:`Open the focused panel in full-screen`],[`?`,`Open keyboard shortcuts`],[`Escape`,`Cancel a range, then leave the chart or close full-screen`]];return(0,X.jsx)(s,{opened:e,onClose:t,title:`Keyboard shortcuts`,trapFocus:!0,returnFocus:!0,closeOnEscape:!0,children:(0,X.jsxs)(x,{gap:`xs`,children:[(0,X.jsx)(Me,{label:`Single-key shortcuts`,checked:r,onChange:e=>i(e.currentTarget.checked)}),a.map(([e,t])=>(0,X.jsxs)(f,{gap:`sm`,children:[(0,X.jsx)(Ke,{children:e}),(0,X.jsx)(N,{size:`sm`,children:t})]},e)),!n&&(0,X.jsx)(N,{size:`sm`,children:`Focus a chart or a panel control before pressing f. Without a focused panel, f does nothing.`}),(0,X.jsx)(N,{size:`sm`,children:`Tab directly to a chart. Left/Right moves between points; Up/Down changes series at the same time or category. Home/End jumps to the first/last point. Enter drills or applies the panel filter. Comparison and Other values can be read even when selection is unavailable.`}),(0,X.jsx)(N,{size:`sm`,children:`On time charts, Shift+Left/Right extends a range and pauses auto-refresh. Review the shaded range and compact UTC label, then choose Zoom to range. Use the time picker after zooming for precise edits. Escape or Cancel cancels it and resumes refresh. The next Escape leaves the chart or closes full-screen. Reset zoom, Zoom out and browser Back preserve comparison and filters.`}),(0,X.jsxs)(N,{size:`sm`,children:[n?`In full-screen, r refreshes, f exits and ? opens help; e and h are inactive.`:`Shortcuts work in the dashboard.`,` Typing, menus and other dialogs or drawers pause shortcuts. Modifier shortcuts keep their browser behavior. Turning off single-key shortcuts keeps chart navigation and visible controls available.`]}),(0,X.jsx)(N,{size:`sm`,children:`The global / shortcut focuses the chat composer.`})]})})}function Ji(e){let t=`pitot:single-key-shortcuts:`+e,n=()=>{try{return localStorage.getItem(t)!==`off`}catch{return!0}},[r,i]=(0,Z.useState)(n);return(0,Z.useEffect)(()=>{i(n())},[t]),(0,Z.useEffect)(()=>{let e=e=>{e.key===t&&i(n())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[t]),{enabled:r,change:e=>{i(e);try{localStorage.setItem(t,e?`on`:`off`)}catch{}}}}function Yi(e){let t=(0,Z.useRef)(void 0),n=t=>[...e.current?.querySelectorAll(`[data-panel]`)??[]].find(e=>e.dataset.panel===t&&!e.closest(`[data-panel-fullscreen],[data-fragment-fullscreen]`));return(0,Z.useEffect)(()=>{t.current&&!n(t.current.panel)&&(t.current=void 0)}),{remember(n){t.current=void 0;let r=document.activeElement;if(!(r instanceof HTMLElement)||!e.current?.contains(r)||r.closest(`[data-panel]`)?.dataset.panel!==n)return;let i=r.getAttribute(`data-panel-view`),a=r.getAttribute(`aria-label`),o=r.hasAttribute(`data-chart-plot`)?`[data-chart-plot]`:i?`[data-panel-view=${JSON.stringify(i)}]`:a?`[aria-label=${JSON.stringify(a)}]`:void 0;t.current={element:r,panel:n,selector:o}},restore(e){let r=t.current;if(t.current=void 0,r&&(e===void 0||r.panel===e)&&n(r.panel))return r.element.isConnected&&!r.element.closest(`[hidden]`)?r.element:r.selector?n(r.panel)?.querySelector(r.selector)??void 0:void 0}}}var Xi=(0,Z.lazy)(()=>ae(()=>import(`./new-dashboard-nl-y_vRO.js`).then(e=>({default:e.NewDashboard})),__vite__mapDeps([25,1,2,3,4,5,6,7,8,22,10,11,12,13,14,15,16,17,18,19,20,21,23,9,24]))),Zi={exemplars:K,trace:ge,span:V},Qi={"5m":`15m`,"15m":`1h`,"1h":`3h`,"3h":`6h`,"6h":`12h`,"12h":`24h`,"24h":`2d`,"2d":`7d`,"7d":`30d`,"30d":`30d`};function $i({dashboardId:e,search:t,onSearch:n,onOpen:r}){let{agentAvailable:i,openChat:a}=qe(),[o,s]=(0,Z.useState)(!1),c=Ve({queryKey:Se,queryFn:Ee,staleTime:15e3});(0,Z.useEffect)(()=>{!e&&c.data?.length&&r((c.data.find(e=>e.is_default)??c.data[0]).id,!0)},[e,c.data]);let l=Ve({queryKey:[`dashboard`,e],queryFn:({signal:t})=>be(e,t),enabled:!!e,retry:(e,t)=>!(t instanceof ze&&t.code===`not_found`)&&e<2});return!e&&c.error?(0,X.jsxs)(x,{p:`lg`,children:[(0,X.jsx)(A,{title:`Dashboards`,description:`Monitor your services and investigate changes.`}),(0,X.jsx)(T,{state:`error`,error:{title:`Dashboards could not be loaded`,message:c.error.message,onRetry:()=>void c.refetch()}})]}):!e&&c.data?.length===0?(0,X.jsx)(_,{mih:`50vh`,children:(0,X.jsxs)(x,{align:`center`,gap:`xs`,children:[(0,X.jsx)(A,{title:`Dashboards`,description:`Create a dashboard to explore your services.`}),(0,X.jsx)(T,{state:`empty`,empty:{title:(0,X.jsx)(b,{order:2,fz:`lg`,children:`No dashboards yet`}),description:`Create a dashboard to see your telemetry.`,action:(0,X.jsx)(F,{size:`sm`,onClick:()=>s(!0),children:`New dashboard`})}}),(0,X.jsx)(f,{mt:`sm`,gap:`xs`,children:i&&(0,X.jsx)(F,{size:`sm`,variant:`default`,onClick:()=>a(`Build me a dashboard for my services, showing request volume, latency, and errors. Ask me which services to monitor first.`),children:`Create with AI`})}),o&&(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(Xi,{onClose:()=>s(!1),onCreated:e=>{s(!1),r(e)}})})]})}):!e||l.isLoading?(0,X.jsx)(S,{component:`section`,"aria-label":`Dashboard`,maw:1600,mx:`auto`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,children:(0,X.jsx)(T,{state:`loading`,loadingLabel:`Loading dashboard`,skeleton:(0,X.jsx)(Pt,{})})}):l.error instanceof ze&&l.error.code===`not_found`?(0,X.jsx)(_,{mih:`50vh`,children:(0,X.jsxs)(x,{align:`center`,gap:`xs`,children:[(0,X.jsx)(A,{title:`Dashboard`,description:`Monitor your services and investigate changes.`}),(0,X.jsx)(T,{state:`empty`,empty:{title:(0,X.jsx)(b,{order:2,fz:`lg`,children:`This dashboard isn't here`}),description:`The link may be out of date, or the dashboard may have been deleted.`,action:c.data?.length?(0,X.jsx)(F,{variant:`default`,size:`sm`,onClick:()=>r((c.data.find(e=>e.is_default)??c.data[0]).id,!0),children:`Open your default dashboard`}):void 0}})]})}):l.error||!l.data?(0,X.jsxs)(x,{p:`lg`,children:[(0,X.jsx)(A,{title:`Dashboard`,description:`Monitor your services and investigate changes.`}),(0,X.jsx)(T,{state:`error`,error:{message:`Your dashboard is unavailable.`,onRetry:()=>void l.refetch()}})]}):(0,X.jsx)(ea,{id:l.data.id,version:l.data.version,spec:l.data.spec,search:t,onSearch:n,onOpen:r,agentAvailable:i,openChat:a},l.data.id)}function ea({id:e,version:t,spec:n,search:r,onSearch:i,onOpen:a,agentAvailable:o,openChat:s}){let[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1);Ge((0,Z.useCallback)(()=>m(!0),[]));let h=(0,Z.useRef)(null),g=(0,Z.useId)(),_=Ji(Re().id),v=Yi(h),[y,b]=(0,Z.useState)(()=>new Set),C=(0,Z.useCallback)((e,t)=>b(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r}),[]),w=Be(),[E,D]=(0,Z.useState)(),{zoom:ee,reset:O,resetZoom:k,zoomed:j}=Ui(r,i),M=xe(n,r),[N,P]=(0,Z.useState)(M.refresh??`30s`),I=()=>{if(M.from&&M.to){let e=Date.parse(M.from),t=Date.parse(M.to),n=(t-e)/2;i({...r,range:void 0,from:new Date(e-n).toISOString(),to:new Date(t+n).toISOString()})}else i({...r,range:Qi[M.range??`1h`]??`1h`,from:void 0,to:void 0})},L=r.compare?r.compare===`1`:n.time.compare===`previous_period`,R=r.vars??{},ie=Fi(`dashboard-${e}`,n,M,R,q,Si),z=(0,Z.useMemo)(()=>pi(n.variables,R,ie.currentData),[n.variables,R,ie.currentData]),[ae,oe]=(0,Z.useState)(()=>window.innerWidth);(0,Z.useEffect)(()=>{let e=0,t=()=>{window.clearTimeout(e),e=window.setTimeout(()=>oe(window.innerWidth),300)};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),window.clearTimeout(e)}},[]);let se=(0,Z.useMemo)(()=>{let e=Math.max(320,Math.min(ae-64,1600));return Object.fromEntries(n.panels.map(t=>[t.id,e/12*(t.grid?.w??t.width??6)]))},[ae,n]),[ce,le]=(0,Z.useState)(()=>n.panels.map(e=>e.id)),V=Mi({dashboardId:e,version:t,spec:n,time:M,vars:z,compare:L,widths:se,visible:(0,Z.useMemo)(()=>ce.filter(e=>n.panels.some(t=>t.id===e)),[ce,n.panels]),refresh:y.size?`off`:N,enabled:ie.ready});(0,Z.useEffect)(()=>{E===t&&w.refetchQueries({predicate:Ii(e),type:`active`,stale:!0},{cancelRefetch:!1})},[E,t,e,w]);let ue=(0,Z.useMemo)(()=>V.annotations?{...V.annotations,deploys:n.annotations?.deploys===!1?[]:V.annotations.deploys,anomalies:n.annotations?.anomalies===!1?[]:V.annotations.anomalies}:void 0,[V.annotations,n.annotations?.deploys,n.annotations?.anomalies]),fe=ie.error??V.error,H=(e,t)=>{let n={...R};t===void 0?delete n[e]:n[e]=t,i({...r,vars:n},!0)},U=()=>i({...r,edit:r.edit===`1`?void 0:`1`}),W=e=>{e&&v.remember(e),i({...r,view:e},e===void 0)};return Ki(h,{r:()=>V.refetch(),e:U,h:()=>d(!0),"?":()=>m(!0),f:e=>{if(r.view){W();return}let t=e.closest(`[data-panel]`)?.dataset.panel;t&&n.panels.some(e=>e.id===t)&&W(t)}},{modalOpen:u||p||!!r.drill,fullscreenScope:r.view?g:void 0,enabled:_.enabled}),(0,X.jsxs)(S,{component:`section`,ref:h,"aria-label":`Dashboard`,maw:1600,mx:`auto`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,children:[(0,X.jsxs)(x,{gap:`sm`,mb:`md`,children:[(0,X.jsx)(A,{title:n.name,description:n.description||`Monitor your services and investigate changes.`,meta:(0,X.jsx)(Ie,{time:M,updatedAt:V.updatedAt}),actions:(0,X.jsx)(f,{gap:`xs`,children:(0,X.jsx)(We,{label:`Duplicate dashboard`,children:(0,X.jsx)(te,{variant:`subtle`,color:`gray`,"aria-label":`Duplicate dashboard`,onClick:()=>l(!0),children:(0,X.jsx)(ne,{size:16})})})})}),(0,X.jsx)(de,{selecting:y.size>0,time:M,refresh:N,compare:L,editing:r.edit===`1`,fetching:V.fetching,updatedAt:V.updatedAt,onRange:e=>{O(),i({...r,range:e,from:void 0,to:void 0})},onAbsolute:(e,t)=>{O(),i({...r,range:void 0,from:e,to:t})},onZoomOut:I,onRefresh:P,onRefreshNow:V.refetch,onCompare:e=>i({...r,compare:e?`1`:`0`},!0),onEdit:U,onHistory:()=>d(!0)}),(0,X.jsx)(Wi,{variables:n.variables??[],vars:R,options:ie.data??{},onChange:H}),Object.entries(R).filter(([,e])=>e!==`$__all`).length>0&&(0,X.jsx)(f,{gap:6,children:Object.entries(R).filter(([,e])=>e!==`$__all`).map(([e,t])=>(0,X.jsxs)(F,{color:`accent`,size:`compact-xs`,variant:`light`,"aria-label":`$${e} = ${Array.isArray(t)?t.join(`, `):t} ×: remove filter`,onClick:()=>H(e,void 0),children:[`$`,e,` = `,Array.isArray(t)?t.join(`, `):t,` ×`]},e))}),V.annotationError&&(0,X.jsx)(re,{tone:`warning`,title:`Annotations unavailable`,children:V.annotationError}),V.annotations?.truncated&&(0,X.jsx)(re,{tone:`warning`,children:`Annotation history is limited.`})]}),!fe&&V.skippedAt!==null&&(0,X.jsx)(S,{"data-refresh-skipped":!0,children:(0,X.jsxs)(re,{tone:`info`,children:[`The server was busy, so the latest refresh was skipped. Marked panels show data from `,new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`,second:`2-digit`}).format(V.skippedAt),`.`]})}),fe&&(0,X.jsxs)(re,{tone:`danger`,title:ie.error?`Variables could not be loaded`:`Panels could not be loaded`,children:[fe.message,fe instanceof ze&&(0,X.jsx)(`ul`,{children:fe.problems.map((e,t)=>(0,X.jsxs)(`li`,{children:[e.path,`: `,e.message,e.hint?` (${e.hint})`:``]},t))})]}),n.panels.length===0&&(0,X.jsx)(T,{state:`empty`,empty:{title:`No panels yet`,description:`Add a panel to see telemetry on this dashboard.`,action:(0,X.jsx)(F,{onClick:()=>i({...r,edit:`1`}),children:`Add panel`})}}),(0,X.jsx)(bi,{dashboardId:e,version:t,spec:n,vars:z,results:V.results,annotations:ue,fetching:V.fetching,fetchingIds:V.fetchingIds,staleAt:V.staleAt,time:{...M,compare:L?`previous_period`:void 0},onEditExit:()=>i({...r,edit:void 0}),editing:r.edit===`1`,view:r.view,canManage:!0,agentAvailable:o,onOpenChat:s,onRetry:V.retry,onVariable:H,onZoom:ee,zoomed:j,onZoomReset:k,onWiden:I,onView:W,onRangePending:C,shortcutScope:g,onShortcuts:()=>m(!0),overlayOpen:u||p||!!r.drill,returnViewFocus:v.restore,onVisible:le,onPoint:(e,t)=>{let n=B(e,V.results.get(e.id),t,R);n&&i({...r,vars:n.vars,drill:JSON.stringify(n.target)},!1)}}),(0,X.jsx)(pe,{client:Zi,spec:n,time:M,vars:z,target:ve(r.drill),onChange:e=>i({...r,drill:e?JSON.stringify(e):void 0},!1)}),c&&(0,X.jsx)(xi,{spec:n,onClose:()=>l(!1),onCreated:e=>{l(!1),a(e)}}),(0,X.jsx)(Li,{id:e,currentVersion:t,currentSpec:n,opened:u,onClose:()=>d(!1),onRestored:e=>{D(e.version);let t=new Set(e.spec.panels.map(e=>e.id)),n=ve(r.drill),a=r.view&&!t.has(r.view)?void 0:r.view,o=n&&!t.has(n.panel_id)?void 0:r.drill;(a!==r.view||o!==r.drill)&&i({...r,view:a,drill:o},!0)}}),(0,X.jsx)(qi,{opened:p,onClose:()=>m(!1),fullscreen:!!r.view,enabled:_.enabled,onEnabled:_.change})]})}export{kt as n,$i as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/page-1Rod7OFH.js b/internal/ui/dist/assets/page-DSor7wHc.js similarity index 90% rename from internal/ui/dist/assets/page-1Rod7OFH.js rename to internal/ui/dist/assets/page-DSor7wHc.js index 8652b2450..fcf940eca 100644 --- a/internal/ui/dist/assets/page-1Rod7OFH.js +++ b/internal/ui/dist/assets/page-DSor7wHc.js @@ -1,2 +1,2 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{A as r,G as i,T as a,Tt as o,g as s,j as c,k as l,q as u,s as d,w as f,y as p}from"./brand-D6fP-cLS.js";import{a as m,c as ee,g as te,h,m as g,r as _,t as v,u as y}from"./toolbar-DV46cPGs.js";import{d as ne,g as b,w as re}from"./search-D_K9J6yO.js";import{t as ie}from"./NumberInput-CixyOph4.js";import{t as x}from"./live-data-meta-CUyw2snU.js";import{s as ae}from"./auth-DWqIkMZS.js";import{t as oe}from"./useQuery-BLTYSIvG.js";import{i as se,r as ce,t as le}from"./search-CDra9nG2.js";import{ct as ue,k as de}from"./index-C1Pd14SU.js";import{A as fe,B as S,C as pe,D as me,E as C,F as w,H as he,I as T,L as ge,M as E,N as _e,O as D,P as ve,R as ye,S as be,T as O,U as xe,V as k,W as Se,_ as Ce,a as we,b as A,c as Te,d as Ee,f as De,g as Oe,h as ke,i as Ae,j as je,k as Me,l as j,m as M,n as Ne,o as Pe,p as N,s as Fe,t as Ie,u as Le,v as Re,w as ze,x as Be,y as Ve,z as He}from"./save-dialog-Chbkq2Xp.js";var P=n(e(),1),F=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new Ue(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizeo;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.reducePos=this.pos=n+e.length;this.pushState(t,n),this.buffer.push(r,n,i,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new We(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;rt&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}},Ue=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},We=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},Ge=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function I(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var Ke=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},qe=new Ke,Je=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=qe,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;in.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t=this.chunk2Pos&&nt.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=qe,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},L=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;z(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};L.prototype.contextual=L.prototype.fallback=L.prototype.extend=!1;var R=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?I(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(z(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};R.prototype.contextual=L.prototype.fallback=L.prototype.extend=!1;var Ye=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function z(e,t,n,r,i,a){let o=0,s=1<0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||Xe(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function B(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function Xe(e,t,n,r){let i=B(n,r,t);return i<0||B(n,r,e)t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var Qe=class{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Ze(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Ze(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=a,null;if(i instanceof w){let n=a>this.lastRepeatPos&&i.type.id>=this.minRepeat;if(a==e||n){let t=a+i.length,r;if(a>=this.safeFrom&&t<=this.safeTo&&(!(r=i.prop(je.lookAhead))||t+r=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},$e=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new Ke)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;rl.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new Ke,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ke,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;te.bufferLength*4?new Qe(n,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&tt(r);if(e)return V&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw V&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return V&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e-1&&n.length&&(!i||(n.prop(je.contextHash)||0)==a))return e.useNode(n,o,t),n;if(n.children.length==0||n.positions[0]>0)break;let s=n.children[0];if(s instanceof w&&(!r||s.type.id>=this.parser.minRepeatTerm))n=s;else break}return null}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=V?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.reducePos0)return e.reduce(o),V&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;or?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return W(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),V&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(V&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)V&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))V&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),V&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),W(o,n)):(!r||r.scoree.topRules[t][1]),r=[];for(let e=0;e=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new E(t.map((t,i)=>_e.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Me;let a=I(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;etypeof e==`number`?new L(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new U(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=K(this.data,n+2);else break}r=t(K(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=K(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=q(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;ee)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scoree.external(n,r)<<1|t}return e.get}var nt=36,rt=1,it=2,J=3,Y=4,at=5,X=6,ot=7,st=8,ct=9,lt=10,ut=11,Z=12,dt=13,ft=14,pt=15,mt=16,ht=17,gt=18,_t=19,vt=20,yt=21,bt=22,xt=23,St=24;function Ct(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function wt(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Q(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function Tt(e,t){scan:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n)`.charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function Dt(e,t){for(;e.next==95||Ct(e.next);)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function Ot(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),Q(e,t,!1)}else Dt(e)}function kt(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function At(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function jt(e){for(;!(e.next<0||e.next==10);)e.advance()}function Mt(e,t){for(let n=0;n!=&|~^/`,specialVar:`?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!1,words:Pt(It,Ft)};function Rt(e,t,n,r){let i={};for(let t in Lt)i[t]=(e.hasOwnProperty(t)?e:Lt)[t];return t&&(i.words=Pt(t,n||``,r)),i}function zt(e){return new Ye(t=>{let{next:n}=t;if(t.advance(),Mt(n,Nt)){for(;Mt(t.next,Nt);)t.advance();t.acceptToken(nt)}else if(n==36&&e.doubleDollarQuotedStrings){let e=Dt(t,``);t.next==36&&(t.advance(),Tt(t,e),t.acceptToken(J))}else if(n==39||n==34&&e.doubleQuotedStrings)Q(t,n,e.backslashEscapes),t.acceptToken(J);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)jt(t),t.acceptToken(rt);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))jt(t),t.acceptToken(rt);else if(n==47&&t.next==42){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),n==42&&t.next==47){if(e--,t.advance(),!e)break}else n==47&&t.next==42&&(e++,t.advance())}t.acceptToken(it)}else if((n==101||n==69)&&t.next==39)t.advance(),Q(t,39,!0),t.acceptToken(J);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),Q(t,39,e.backslashEscapes),t.acceptToken(J);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),Q(t,39,e.backslashEscapes),t.acceptToken(J);break}if(!Ct(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!Mt(t.peek(1),Nt)){let e=t.peek(1);t.advance(2),Et(t,e),t.acceptToken(J)}else if(Mt(n,e.identifierQuotes))Q(t,n==91?93:n,!1),t.acceptToken(_t);else if(n==40)t.acceptToken(ot);else if(n==41)t.acceptToken(st);else if(n==123)t.acceptToken(ct);else if(n==125)t.acceptToken(lt);else if(n==91)t.acceptToken(ut);else if(n==93)t.acceptToken(Z);else if(n==59)t.acceptToken(dt);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),kt(t),t.acceptToken(bt);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(Q(t,n,e.backslashEscapes),t.acceptToken(xt)):(kt(t,n),t.acceptToken(bt))}else if(n==48&&(t.next==120||t.next==88)||(n==120||n==88)&&t.next==39){let e=t.next==39;for(t.advance();wt(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(Y)}else if(n==46&&t.next>=48&&t.next<=57)At(t,!0),t.acceptToken(Y);else if(n==46)t.acceptToken(ft);else if(n>=48&&n<=57)At(t,!1),t.acceptToken(Y);else if(Mt(n,e.operatorChars)){for(;Mt(t.next,e.operatorChars);)t.advance();t.acceptToken(pt)}else if(Mt(n,e.specialVar))t.next==n&&t.advance(),Ot(t),t.acceptToken(ht);else if(n==58||n==44)t.acceptToken(mt);else if(Ct(n)){let r=Dt(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?gt:e.words[r.toLowerCase()]??gt)}})}var Bt=zt(Lt),Vt=et.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:`⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement`,maxTerm:38,nodeProps:[[`isolate`,-4,1,2,3,19,``]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:`RORO`,tokenizers:[0,Bt],topRules:{Script:[0,25]},tokenPrec:0});function Ht(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function Ut(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function Wt(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function Gt(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)Wt(r)&&n.push(Ut(e,r));return n}return[Ut(e,t)]}function Kt(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=Ht(t);if(!Wt(r))return n;n.unshift(Ut(e,r)),t=Ht(r)}}function qt(e,t){let n=C(e).resolveInner(t,-1),r=Yt(e.doc,n);return n.name==`Identifier`||n.name==`QuotedIdentifier`||n.name==`Keyword`?{from:n.from,quoted:n.name==`QuotedIdentifier`?e.doc.sliceString(n.from,n.from+1):null,parents:Kt(e.doc,Ht(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:Kt(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var Jt=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function Yt(e,t){let n;for(let e=t;!n;e=e.parent){if(!e)return null;e.name==`Statement`&&(n=e)}let r=null;for(let t=n.firstChild,i=!1,a=null;t;t=t.nextSibling){let n=t.name==`Keyword`?e.sliceString(t.from,t.to).toLowerCase():null,o=null;if(!i)i=n==`from`;else if(n==`as`&&a&&Wt(t.nextSibling))o=Ut(e,t.nextSibling);else if(n&&Jt.has(n))break;else a&&Wt(t)&&(o=Ut(e,t));o&&(r||=Object.create(null),r[o]=Gt(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function Xt(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var Zt=/^\w*$/,Qt=/^[`'"\[]?\w*[`'"\]]?$/;function $t(e){return e.self&&typeof e.self.label==`string`}var en=class e{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(t){let n=this.children||=Object.create(null);return n[t]||(t&&!this.list.some(e=>e.label==t)&&this.list.push(tn(t,`type`,this.idQuote,this.idCaseInsensitive)),n[t]=new e(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t==`string`?tn(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):$t(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],r=null,i=t.replace(/\\?\./g,e=>e==`.`?`\0`:e).split(`\0`),a=this;$t(n)&&(r=n.self,n=n.children);for(let e=0;e{let{parents:t,from:n,quoted:i,empty:a,aliases:c}=qt(e.state,e.pos);if(a&&!e.explicit)return null;c&&t.length==1&&(t=c[t[0]]||t);let l=o;for(let e of t){for(;!l.children||!l.children[e];)if(l==o&&s)l=s;else if(l==s&&r)l=l.child(r);else return null;let t=l.maybeChild(e);if(!t)return null;l=t}let u=l.list;if(l==o&&c&&(u=u.concat(Object.keys(c).map(e=>({label:e,type:`constant`})))),i){let t=i[0],r=nn(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:Xt(t,r,u),validFor:Qt}}return{from:n,options:u,validFor:Zt}}}function an(e){return e==yt?`type`:e==vt?`keyword`:`variable`}function on(e,t,n){let r=Object.keys(e).map(r=>n(t?r.toUpperCase():r,an(e[r])));return M([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],De(r))}var sn=Vt.configure({props:[pe.add({Statement:Be()}),be.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),me({Keyword:D.keyword,Type:D.typeName,Builtin:D.standard(D.name),Bits:D.number,Bytes:D.string,Bool:D.bool,Null:D.null,Number:D.number,String:D.string,Identifier:D.name,QuotedIdentifier:D.special(D.string),SpecialVar:D.special(D.name),LineComment:D.lineComment,BlockComment:D.blockComment,Operator:D.operator,"Semi Punctuation":D.punctuation,"( )":D.paren,"{ }":D.brace,"[ ]":D.squareBracket})]}),cn=class e{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(t,n){return new e(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=Rt(t,t.keywords,t.types,t.builtin),r=Re.define({name:`sql`,parser:sn.configure({tokenizers:[{from:Bt,to:zt(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}});return new e(n,r,t)}};function ln(e,t){return{label:e,type:t,boost:-1}}function un(e,t=!1,n){return on(e.dialect.words,t,n||ln)}function dn(e){return e.schema?rn(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||mn):()=>null}function fn(e){return e.schema?(e.dialect||mn).language.data.of({autocomplete:dn(e)}):[]}function pn(e={}){let t=e.dialect||mn;return new Ve(t.language,[fn(e),t.language.data.of({autocomplete:un(t,e.upperCaseKeywords,e.keywordCompletion)})])}var mn=cn.define({}),hn=cn.define({charSetCasts:!0,doubleDollarQuotedStrings:!0,operatorChars:"+-*/<>=~!@#%^&|`?",specialVar:``,keywords:It+`abort abs absent access according ada admin aggregate alias also always analyse analyze array_agg array_max_cardinality asensitive assert assignment asymmetric atomic attach attribute attributes avg backward base64 begin_frame begin_partition bernoulli bit_length blocked bom cache called cardinality catalog_name ceil ceiling chain char_length character_length character_set_catalog character_set_name character_set_schema characteristics characters checkpoint class class_origin cluster coalesce cobol collation_catalog collation_name collation_schema collect column_name columns command_function command_function_code comment comments committed concurrently condition_number configuration conflict connection_name constant constraint_catalog constraint_name constraint_schema contains content control conversion convert copy corr cost covar_pop covar_samp csv cume_dist current_catalog current_row current_schema cursor_name database datalink datatype datetime_interval_code datetime_interval_precision db debug defaults defined definer degree delimiter delimiters dense_rank depends derived detach detail dictionary disable discard dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue document dump dynamic_function dynamic_function_code element elsif empty enable encoding encrypted end_frame end_partition endexec enforced enum errcode error event every exclude excluding exclusive exp explain expression extension extract family file filter final first_value flag floor following force foreach fortran forward frame_row freeze fs functions fusion generated granted greatest groups handler header hex hierarchy hint id ignore ilike immediately immutable implementation implicit import include including increment indent index indexes info inherit inherits inline insensitive instance instantiable instead integrity intersection invoker isnull key_member key_type label lag last_value lead leakproof least length library like_regex link listen ln load location lock locked log logged lower mapping matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text min minvalue mod mode more move multiset mumps name namespace nfc nfd nfkc nfkd nil normalize normalized nothing notice notify notnull nowait nth_value ntile nullable nullif nulls number occurrences_regex octet_length octets off offset oids operator options ordering others over overlay overriding owned owner parallel parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partition pascal passing passthrough password percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding prepared print_strict_params procedural procedures program publication query quote raise range rank reassign recheck recovery refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex rename repeatable replace replica requiring reset respect restart restore result_oid returned_cardinality returned_length returned_octet_length returned_sqlstate returning reverse routine_catalog routine_name routine_schema routines row_count row_number rowtype rule scale schema_name schemas scope scope_catalog scope_name scope_schema security selective self sensitive sequence sequences serializable server server_name setof share show simple skip slice snapshot source specific_name sqlcode sqlerror sqrt stable stacked standalone statement statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time table_name tables tablesample tablespace temp template ties token top_level_count transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex trigger_catalog trigger_name trigger_schema trim trim_array truncate trusted type types uescape unbounded uncommitted unencrypted unlink unlisten unlogged unnamed untyped upper uri use_column use_variable user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema vacuum valid validate validator value_of var_pop var_samp varbinary variable_conflict variadic verbose version versioning views volatile warning whitespace width_bucket window within wrapper xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate yes`,types:Ft+`bigint int8 bigserial serial8 varbit bool box bytea cidr circle precision float8 inet int4 json jsonb line lseg macaddr macaddr8 money numeric pg_lsn point polygon float4 int2 smallserial serial2 serial serial4 text timetz timestamptz tsquery tsvector txid_snapshot uuid xml`}),gn=`accessible algorithm analyze asensitive authors auto_increment autocommit avg avg_row_length binlog btree cache catalog_name chain change changed checkpoint checksum class_origin client_statistics coalesce code collations columns comment committed completion concurrent consistent contains contributors convert database databases day_hour day_microsecond day_minute day_second delay_key_write delayed delimiter des_key_file dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile enable enclosed ends engine engines enum errors escaped even event events every explain extended fast field fields flush force found_rows fulltext grants handler hash high_priority hosts hour_microsecond hour_minute hour_second ignore ignore_server_ids import index index_statistics infile innodb insensitive insert_method install invoker iterate keys kill linear lines list load lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modify mutex mysql_errno no_write_to_binlog offline offset one online optimize optionally outfile pack_keys parser partition partitions password phase plugin plugins prev processlist profile profiles purge query quick range read_write rebuild recover regexp relaylog remove rename reorganize repair repeatable replace require resume rlike row_format rtree schedule schema_name schemas second_microsecond security sensitive separator serializable server share show slave slow snapshot soname spatial sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result ssl starting starts std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace terminated triggers truncate uncommitted uninstall unlock upgrade use use_frm user_resources user_statistics utc_date utc_time utc_timestamp variables views warnings xa xor year_month zerofill`;Ft+``,It+``+gn,It+``+gn,It+``,Ft+``,It+``,Ft+``,Ft+``,It+``,Ft+``;var _n=cn.define({...hn.spec,keywords:`${hn.spec.keywords} qualify exclude replace pivot unpivot summarize asof positional semi anti union by name columns sample using key`,types:`${hn.spec.types} variant timestamp_ns timestamptz_ns hugeint uhugeint ubigint uinteger`,builtin:`${hn.spec.builtin??``} time_bucket epoch_ns epoch_ms make_timestamp_ns try_cast count_if arg_max arg_min any_value quantile_cont quantile_disc approx_quantile histogram first last list list_extract list_value list_distinct list_sort unnest struct_pack struct_extract map map_keys map_extract map_extract_value json_extract json_extract_string json_keys json_type to_json regexp_matches regexp_full_match regexp_replace regexp_extract starts_with contains greatest least isfinite isinf isnan date_diff date_sub`,specialVar:`$?`}),vn=De([{label:`$__window`,type:`function`,detail:`Time filter`,info:`Use $__window(time_column) to apply the dashboard time range.`},{label:`$__bucket`,type:`function`,detail:`Time bucket`,info:`Use $__bucket(time_column) to group by the panel interval.`}]);function yn(e){return Object.fromEntries(Object.entries({...e.signals,...e.sql_relations}).map(([e,t])=>[e,t.columns.map(e=>({label:e.name,type:`property`,detail:e.sql_type??e.type,info:e.description}))]))}function bn(e,t){let n=e.line(Math.max(1,Math.min(e.lines,t.line+1)));return n.from+Math.max(0,Math.min(n.length,t.character))}function xn(e,t){return t.map(t=>{let n=t.range?bn(e,t.range.start):0;return{from:n,to:t.range?Math.max(n,bn(e,t.range.end)):e.length,severity:`error`,message:t.message+(t.hint?` (${t.hint})`:``)}})}var $=t(),Sn=[];function Cn(e){let{value:t,schema:n,problems:r=Sn,label:i=`Panel SQL`,describedBy:a,disabled:o=!1}=e,s=(0,P.useRef)(null),c=(0,P.useRef)(null),l=(0,P.useRef)(e);l.current=e;let u=(0,P.useRef)({language:new k,editable:new k,attributes:new k});return(0,P.useEffect)(()=>{let{language:e,editable:t,attributes:n}=u.current,r=new T({parent:s.current,state:he.create({doc:l.current.value,extensions:[S(),Oe(),ge(),ye(),A(),ze(),j,O(Te),T.lineWrapping,e.of(pn({dialect:_n})),_n.language.data.of({autocomplete:vn}),t.of([]),n.of([]),xe.highest(He.of([{key:`Mod-Enter`,run:()=>(l.current.disabled||l.current.onRun(),!0),stopPropagation:!0},{key:`Escape`,run:()=>(r.contentDOM.blur(),l.current.onEscape(),!0),stopPropagation:!0}])),Ee(),He.of([...N.filter(e=>e.key!==`Escape`),...ke,...Ce]),T.updateListener.of(e=>{e.docChanged&&l.current.onChange(e.state.doc.toString())})]})});return c.current=r,()=>{c.current=null,r.destroy()}},[]),(0,P.useEffect)(()=>{let e=c.current;e.state.doc.toString()!==t&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t}})},[t]),(0,P.useEffect)(()=>{c.current.dispatch({effects:u.current.language.reconfigure(pn({dialect:_n,schema:n?yn(n):void 0}))})},[n]),(0,P.useEffect)(()=>{c.current.dispatch({effects:u.current.editable.reconfigure([he.readOnly.of(o),T.editable.of(!o)])})},[o]),(0,P.useEffect)(()=>{c.current.dispatch({effects:u.current.attributes.reconfigure(T.contentAttributes.of({role:`textbox`,"aria-label":i,"aria-multiline":`true`,"aria-describedby":a??``,"aria-invalid":r.length?`true`:`false`,spellcheck:`false`}))})},[i,a,r.length]),(0,P.useEffect)(()=>{let e=c.current;e.dispatch(Le(e.state,xn(e.state.doc,r)))},[t,r]),(0,$.jsx)(`div`,{ref:s,"data-sql-editor":!0})}var wn=[`=`,`!=`,`>`,`>=`,`<`,`<=`],Tn=String.raw`[a-z_][a-z0-9_]*|(?:attributes|resource)\['(?:[^']|'')+'\]`,En=String.raw`'(?:[^']|'')*'|-?\d+(?:\.\d+)?|\$[a-z][a-z0-9_]*`,Dn=new RegExp(String.raw`^(${Tn})\s*(!=|>=|<=|=|>|<)\s*(${En})$`),On=/^-?\d+(?:\.\d+)?$/,kn=/^\$[a-z][a-z0-9_]*$/;function An(e){let t=Dn.exec(e.trim());if(!t)return;let[,n,r,i]=t,a=i.startsWith(`'`);return{field:n,op:r,value:a?i.slice(1,-1).replaceAll(`''`,`'`):i,quoted:a}}function jn(e,t=[]){let n=e.value.trim();if(kn.test(n)&&t.includes(n.slice(1)))return`${e.field} ${e.op} ${n}`;let r=e.quoted||!On.test(n)?`'${e.value.replaceAll(`'`,`''`)}'`:e.value.trim();return`${e.field} ${e.op} ${r}`}var Mn={h:36e5,m:6e4,s:1e3,ms:1,us:.001},Nn=/^(\d+(?:\.\d+)?)\s*(h|m|s|ms|us)$/i,Pn=e=>Number(e.toPrecision(12));function Fn(e){let t=e.trim();if(On.test(t))return Number(t);let n=Nn.exec(t);return n?Pn(Number(n[1])*Mn[n[2].toLowerCase()]):void 0}function In(e){for(let[t,n]of Object.entries(Mn))if(e>=n&&Pn(Pn(e/n)*n)===e)return`${Pn(e/n)}${t}`;return`${e}ms`}var Ln=[`spans`,`logs`,`metrics`],Rn=new Set([`count`,`rate`,`error_rate`,`share`]),zn=new Set([`quantile`]),Bn=new RegExp(String.raw`^([a-z_][a-z0-9_]*)\((|${Tn})\)$`);function Vn(e,t){let n=Bn.exec(e.trim());if(n&&!zn.has(n[1])&&t.includes(n[1])&&Rn.has(n[1])===(n[2]===``))return{fn:n[1],field:n[2]}}var Hn=e=>`${e.fn}(${Rn.has(e.fn)?``:e.field})`,Un=`duration_ms`,Wn=/^\$[a-z][a-z0-9_]*$/;function Gn(e,t){if(e===Un){let e=Fn(t);return e===void 0?void 0:String(e)}return/^-?\d+(?:\.\d+)?$/.test(t)?t:void 0}function Kn(e){let t=new Set,n=new Set,r=new Set([`count`]);for(let i of e.measures??[]){let e=Bn.exec(i.trim());e&&(r.add(e[1]),e[2]&&(e[1]===`count_distinct`?n:t).add(e[2]))}for(let r of e.where??[]){let e=An(r);e&&(e.quoted?n:t).add(e.field)}for(let t of e.by??[])n.add(t);n.add(`service`);let i=e=>({name:e,type:t.has(e)?`number`:`string`});return{signals:{[e.from]:{columns:[...new Set([...t,...n])].map(i)}},sql_relations:{},measures:[...r],buckets:[`auto`,...e.bucket&&e.bucket!==`auto`?[e.bucket]:[]]}}function qn(e,t){let n=e.signals[t],r=(n?.columns??[]).filter(e=>e.type!==`map`&&e.type!==`time`),i=(n?.attributes??[]).map(e=>({name:`${e.scope===`resource`?`resource`:`attributes`}['${e.key.replaceAll(`'`,`''`)}']`,type:e.type}));return[...r,...i]}function Jn({text:e,onRemove:t}){return(0,$.jsx)(r,{variant:`light`,color:`gray`,size:`lg`,tt:`none`,rightSection:(0,$.jsx)(u,{size:`xs`,variant:`subtle`,color:`gray`,"aria-label":`Remove ${e}`,onClick:t,children:(0,$.jsx)(p,{size:10})}),children:(0,$.jsx)(`code`,{children:e})})}function Yn({query:e,schema:t,variables:n=[],labels:r={},onChange:o,onInvalid:s}){let d=qn(t,e.from),m=new Set(d.map(e=>e.name)),ee=new Set(d.filter(e=>e.type===`number`||e.type===`int`||e.type===`float`).map(e=>e.name)),te=d.map(e=>e.name),g=t.measures??[],_=e.where??[],v=e.measures??[],y=e.by??[],ne=t.buckets??[],[b,re]=(0,P.useState)(),x=e=>{re(e),s?.(e!==void 0&&e.condition.value.trim()!==``)},ae=(0,P.useRef)(s);ae.current=s,(0,P.useEffect)(()=>()=>ae.current?.(!1),[]);let[oe,se]=(0,P.useState)(),ce=b!==void 0&&b.condition.value.trim()!==``,le=e=>r[e]??e,[ue,fe]=(0,P.useState)(),S=t=>{fe(void 0),o({...e,...t})},pe=n=>{let r=new Set(qn(t,n).map(e=>e.name)),i=e=>r.has(e)||e.startsWith(`attributes[`)||e.startsWith(`resource[`),a={where:_.filter(e=>{let t=An(e);return!t||i(t.field)}),measures:v.filter(e=>{let t=Vn(e,g);return!t||!t.field||i(t.field)}),by:y.filter(i)},s=[...v.filter(e=>!a.measures.includes(e)),..._.filter(e=>!a.where.includes(e)),...y.filter(e=>!a.by.includes(e))];a.measures.length===0&&v.length>0&&(a.measures=[`count()`]),x(void 0),fe(s.length>0?`Removed what ${n} does not have: ${s.map(le).join(`, `)}.`:void 0),o({...e,from:n,...a})},me=(e,t,n)=>e.map((e,r)=>r===t?n:e),C=(e,t)=>e.filter((e,n)=>n!==t),w=e=>m.has(e)?te:[e,...te];return(0,$.jsxs)(a,{gap:`sm`,"data-builder":!0,children:[(0,$.jsx)(h,{label:`Source`,w:200,allowDeselect:!1,value:e.from,data:[...Ln],onChange:t=>t&&t!==e.from&&pe(t)}),ue&&(0,$.jsx)(c,{size:`xs`,c:`dimmed`,role:`status`,"data-builder-removed":!0,children:ue}),(0,$.jsxs)(a,{gap:6,children:[(0,$.jsx)(c,{size:`sm`,fw:500,children:`Measures`}),v.map((e,n)=>{let r=Vn(e,g);return r?(0,$.jsxs)(i,{gap:`xs`,wrap:`nowrap`,children:[(0,$.jsx)(h,{"aria-label":`Measure ${n+1} function`,w:160,allowDeselect:!1,searchable:!0,value:r.fn,data:(t.measures??[]).filter(e=>!zn.has(e)),onChange:e=>e&&S({measures:me(v,n,Hn({fn:e,field:Rn.has(e)?``:r.field||(ee.values().next().value??``)}))})}),!Rn.has(r.fn)&&(0,$.jsx)(h,{"aria-label":`Measure ${n+1} field`,w:260,searchable:!0,value:r.field||null,data:Xn(r.fn,te,ee,w(r.field)),onChange:e=>e&&S({measures:me(v,n,Hn({...r,field:e}))})}),(0,$.jsx)(u,{variant:`subtle`,color:`gray`,"aria-label":`Remove measure ${n+1}`,onClick:()=>S({measures:C(v,n)}),children:(0,$.jsx)(p,{size:14})})]},n):(0,$.jsx)(i,{children:(0,$.jsx)(Jn,{text:le(e),onRemove:()=>S({measures:C(v,n)})})},n)}),(0,$.jsx)(i,{children:(0,$.jsx)(l,{size:`compact-sm`,variant:`subtle`,leftSection:(0,$.jsx)(de,{size:12}),onClick:()=>S({measures:[...v,`count()`]}),children:`Add measure`})})]}),(0,$.jsxs)(a,{gap:6,children:[(0,$.jsx)(c,{size:`sm`,fw:500,children:`Filters`}),(b?[..._.slice(0,b.at),b.condition,..._.slice(b.at)]:_).map((e,r)=>{let a=b?.at===r,o=b&&r>b.at?r-1:r,s=()=>{b&&o{let t={...c,...e};m.has(t.field)&&(t.quoted=!ee.has(t.field));let r=t.value.trim(),i=Wn.test(r)&&n.includes(r.slice(1)),s=ee.has(t.field)&&!i?Gn(t.field,r):r;if(!s){x({at:o,condition:t}),a||S({where:C(_,o)});return}a&&x(void 0);let l=jn({...t,value:s},n);S({where:a?[..._.slice(0,o),l,..._.slice(o)]:me(_,o,l)})},d=a&&ce?c.field===Un?`Enter a duration such as 100ms or 1.5s`:`Enter a number`:void 0,te=oe?.row===r?oe.text:c.field===Un&&!c.quoted&&Fn(c.value)!==void 0&&!a?In(Number(c.value)):c.value;return(0,$.jsxs)(i,{gap:`xs`,wrap:`nowrap`,align:`flex-start`,children:[(0,$.jsx)(h,{"aria-label":`Filter ${r+1} field`,w:260,searchable:!0,allowDeselect:!1,value:c.field,data:w(c.field),onChange:e=>e&&l({field:e})}),(0,$.jsx)(h,{"aria-label":`Filter ${r+1} operator`,w:90,style:{flexShrink:0},allowDeselect:!1,value:c.op,data:[...wn],onChange:e=>e&&l({op:e})}),c.field===`service`&&t.services?.length?(0,$.jsx)(h,{"aria-label":`Filter ${r+1} value`,w:220,searchable:!0,value:c.value||null,data:[...n.map(e=>`$${e}`),...t.services.map(e=>e.value)],onChange:e=>l({value:e??``})}):(0,$.jsx)(f,{"aria-label":`Filter ${r+1} value`,w:220,placeholder:a?`Value`:void 0,value:te,error:d,onBlur:()=>se(void 0),onChange:e=>{let t=e.currentTarget.value;se({row:r,text:t}),l({value:t})}}),(0,$.jsx)(u,{variant:`subtle`,color:`gray`,"aria-label":`Remove filter ${r+1}`,onClick:()=>a?x(void 0):s(),children:(0,$.jsx)(p,{size:14})})]},r)}),(0,$.jsx)(i,{children:(0,$.jsx)(l,{size:`compact-sm`,variant:`subtle`,leftSection:(0,$.jsx)(de,{size:12}),disabled:b!==void 0,onClick:()=>x({at:_.length,condition:{field:`service`,op:`=`,value:``,quoted:!0}}),children:`Add filter`})})]}),(0,$.jsxs)(i,{gap:`md`,align:`flex-end`,children:[(0,$.jsxs)(a,{gap:6,children:[(0,$.jsx)(c,{size:`sm`,fw:500,children:`Group by`}),(0,$.jsxs)(i,{gap:`xs`,children:[y.map((e,t)=>(0,$.jsx)(Jn,{text:e,onRemove:()=>S({by:C(y,t)})},e)),(0,$.jsx)(h,{"aria-label":`Add group by field`,placeholder:`Add field`,w:220,searchable:!0,value:null,data:te.filter(e=>!y.includes(e)),onChange:e=>e&&S({by:[...y,e]})})]})]}),(0,$.jsx)(h,{label:`Every`,w:170,clearable:!0,placeholder:`No time buckets`,value:e.bucket??null,data:e.bucket&&!ne.includes(e.bucket)?[...ne,e.bucket]:ne,onChange:e=>S({bucket:e??void 0})}),(0,$.jsx)(ie,{label:`Limit`,w:120,min:1,max:1e3,value:e.limit??``,onChange:e=>S({limit:typeof e==`number`?e:void 0})})]})]})}function Xn(e,t,n,r){let i=e===`count_distinct`?t:t.filter(e=>n.has(e));return[...new Set([...r.filter(e=>!t.includes(e)),...i])]}var Zn=`explore`,Qn=420,$n={stat:`Stat`,gauge:`Gauge`,timeseries:`Time series`,bar:`Bar`,table:`Table`,text:`Text`,heatmap:`Heatmap`,histogram:`Histogram`,scatter:`Scatter`,state_timeline:`State timeline`,logs:`Logs`,log_patterns:`Log patterns`,traces:`Traces`,service_map:`Service map`,health:`Health`},er={min_max:`a minimum and maximum`,thresholds:`thresholds`},tr=e=>e===`sql`?`sql`:`query`,nr={from:`spans`,measures:[`count()`],by:[`service`]};function rr(e,t){if(e.from===`logs`)return`logs`;if(e.from===`spans`&&t!==`health`&&t!==`service_map`)return`traces`}function ir(e,t){let n=(e,t)=>(e??[]).flatMap((e,n)=>n0||e.result.frame?.totals!==void 0)}function or({search:e,onSearch:t,onSaved:n,context:r}){let u=r?.spec.variables,f=r?.panel,p=e=>e.requires.every(e=>e===`min_max`?f?.min!==void 0&&f?.max!==void 0:(f?.thresholds?.length??0)>0),h=e=>r?.compose?r.compose(e):e,ie=r?.vars??{},[de,fe]=(0,P.useState)(),[S,pe]=(0,P.useState)(),[me,C]=(0,P.useState)(!1),[w,he]=(0,P.useState)(),[T,ge]=(0,P.useState)(e.q),[E,_e]=(0,P.useState)(e.sql??``),D=(0,P.useRef)({text:e.q,sql:e.sql??``}),ve=T!==D.current.text||E!==D.current.sql,ye=r?.onDirtyChange;(0,P.useEffect)(()=>{ye?.(ve)},[ve,ye]);let be=(0,P.useRef)(null),[O,xe]=(0,P.useState)(),[k,Ce]=(0,P.useState)(r?.initial?.query),[A,Te]=(0,P.useState)(r?.initial?.formatted),[Ee,De]=(0,P.useState)([]),[Oe,ke]=(0,P.useState)(()=>r?.initial?ir(r.initial.query,r.initial.formatted):{}),[je,Me]=(0,P.useState)(!1),j=(0,P.useRef)({}),[M,N]=(0,P.useState)([]),[Le,Re]=(0,P.useState)([]),[ze,Be]=(0,P.useState)(),[Ve,He]=(0,P.useState)(0),[F,Ue]=(0,P.useState)(),[We,Ge]=(0,P.useState)(),[I,Ke]=(0,P.useState)(!1),qe=(0,P.useRef)(void 0),Je=(0,P.useRef)(null),L=(0,P.useId)(),R=le(e),Ye=R.from&&R.to?void 0:R.range,z=(0,P.useRef)(e);z.current=e;let B=(0,P.useRef)({q:e.q,sql:e.sql??``,viz:e.viz}),Xe=e=>{let n=z.current;B.current={q:e.q,sql:e.sql??``,viz:e.viz},t(e,e.q===n.q&&e.sql===n.sql&&(n.viz===void 0||e.viz===n.viz))},V=e=>`${e.range}|${e.from??``}|${e.to??``}`,H=V(e),Ze=(0,P.useRef)(void 0),Qe=e=>{let n=V(ce(se(e)));n!==H&&(Ze.current=n),t(e)},$e=(0,P.useRef)(void 0),U=(0,P.useRef)({text:T,sql:E});U.current={text:T,sql:E};let W=oe({queryKey:[`telemetry-schema`],queryFn:({signal:e})=>b(e),staleTime:6e4,retry:!1,enabled:e.tab!==`query`});(0,P.useEffect)(()=>()=>{qe.current?.abort(),j.current.abort?.abort(),clearTimeout(j.current.timer),$e.current=void 0},[]);let G=async(e,t,n,i)=>{if(!t.trim())return;qe.current?.abort();let a=new AbortController;qe.current=a,Ke(!0),Be(void 0),N([]),Re([]),Ge(void 0);try{let o,s;if(e===`query`&&i)xe(void 0),o=h({id:Zn,title:Ne(t),viz:n??`table`,query:i,drill:rr(i,n??`table`)}),s=t,Xe({...z.current,q:t,viz:o.viz});else if(e===`query`){let e=await Pe({text:t,variables:u,window:Ye},a.signal);if(a.signal.aborted)return;xe({...e,text:t}),U.current.text===t&&Re(e.notices),z.current.tab===`builder`&&Ce(e.query);let r=n&&e.viz.compatible.some(e=>e.viz===n&&p(e))?n:e.viz.compatible.find(p)?.viz??`table`;o=h({id:Zn,title:Ne(e.canonical),viz:r,query:e.query,drill:rr(e.query,r)}),s=e.canonical,Xe({...z.current,q:t,viz:r,...t===z.current.q?{}:{drill:void 0}})}else o=h({id:Zn,title:`SQL`,viz:f?.viz??`table`,sql:t}),Xe({...z.current,sql:t});let c={version:1,name:r?.spec.name??`Explore`,time:R,variables:u,panels:[o]},l=Je.current?.clientWidth||960,d=await re({dashboard:c,panels:[Zn],time:R,vars:ie,widths:{[Zn]:l}},a.signal);if(a.signal.aborted)return;let m=d.find(e=>e.id===Zn);if(!m)throw Error(`The query returned no result.`);if(m.status===`invalid`){Ge({kind:e,source:t,window:H}),U.current[e===`query`?`text`:`sql`]===t&&N(m.problems??[]);return}fe(Date.now()),Ue({kind:e,source:t,window:H,panel:o,result:_(m,[Zn]),canonical:s}),e===`sql`&&m.status===`error`&&!m.retryable&&U.current.sql===t&&N([{path:`sql`,message:m.error??`Query failed`}])}catch(n){if(a.signal.aborted)return;Ge({kind:e,source:t,window:H}),n instanceof ae&&n.problems.length>0?U.current[e===`query`?`text`:`sql`]===t&&N(n.problems):Be(n instanceof Error?n.message:`Request failed`)}finally{qe.current===a&&Ke(!1)}},et=(0,P.useRef)({kind:tr(e.tab),viz:F?.panel.viz??e.viz,direct:void 0});et.current={kind:tr(e.tab),viz:F?.panel.viz??e.viz,direct:A?.editable===!1?k:void 0};let K=(0,P.useRef)(()=>void 0),tt=()=>{clearTimeout(j.current.timer),j.current.timer=void 0,j.current.abort?.abort()},q=async(e,t=!0)=>{tt();let n=new AbortController;j.current.abort=n;try{let r=await we({query:e},n.signal);return n.signal.aborted?void 0:(Te(r),De([]),ke(t=>({...t,...ir(e,r)})),t&&(Re(r.notices),N([]),ge(r.text)),r)}catch(e){if(n.signal.aborted)return;De(e instanceof ae&&e.problems.length>0?e.problems:[{path:`query`,message:e instanceof Error?e.message:`The query could not be printed`}]);return}},nt=e=>{Ce(e),clearTimeout(j.current.timer),j.current.timer=setTimeout(()=>{j.current.timer=void 0,q(e)},250)},rt=async t=>{if(!k)return;let n=await q(k);n&&z.current.tab===`builder`&&G(`query`,n.text,t??F?.panel.viz??e.viz,n.editable?void 0:k)},it=async n=>{if(n!==`builder`){e.tab===`builder`&&k&&j.current.timer&&q(k),t({...e,tab:n});return}let r=()=>{z.current.tab!==n&&t({...z.current,tab:n})};if(A?.editable===!1&&k){r();return}if(O&&O.text===T){Ce(O.query),r(),q(O.query,!1);return}if(!T.trim()){Ce(nr),r(),q(nr,!1);return}try{let e=await Pe({text:T,variables:u,window:Ye});xe({...e,text:T}),Ce(e.query),r(),q(e.query,!1)}catch(e){e instanceof ae&&e.problems.length>0?N(e.problems):Be(e instanceof Error?e.message:`Request failed`)}};K.current=()=>{let{kind:e,viz:t,direct:n}=et.current;z.current.tab===`builder`&&k?rt(t):G(e,U.current[e===`query`?`text`:`sql`],t,n)},(0,P.useEffect)(()=>{let t={q:e.q,sql:e.sql??``,viz:e.viz},n=t.q===B.current.q&&t.sql===B.current.sql&&t.viz===B.current.viz,r=$e.current===void 0,i=$e.current!==H,a=Ze.current===H;if($e.current=H,Ze.current=void 0,n&&(r||i&&a)){K.current();return}if(n&&!i)return;B.current=t,tt(),Te(void 0),N([]),ge(t.q),_e(t.sql);let o=tr(e.tab);G(o,o===`query`?t.q:t.sql,t.viz)},[e.q,e.sql,e.viz,H]),(0,P.useEffect)(()=>{e.tab===`builder`&&it(`builder`)},[]);let J=tr(e.tab),Y=J===`query`?T:E,at=Ve>0&&!T.trim(),X=A?.editable===!1,ot=F!==void 0&&(F.kind!==J||F.source!==Y||F.window!==H),st=O?.viz.compatible??[],ct=r?.panel!==void 0,lt=f!==void 0&&!ve&&(e.viz??f.viz)===f.viz,ut=!ot&&!I&&ar(F,ct),Z=ut||lt,dt=We===void 0?!ot&&F?.result.status===`error`:We.kind===J&&We.source===Y&&We.window===H,ft=I?`Wait for the run to finish`:dt?`The last run failed; saving needs a run that works`:ot?`Run the query as it is now first`:ct?`Run the query first`:`Run a query that returns rows first`,pt=(0,P.useId)(),mt=F!==void 0&&(F.panel.drill!==void 0||F.panel.viz===`service_map`||(F.result.frame?.columns.some(e=>e.name===`trace_id`)??!1));return(0,$.jsxs)(a,{gap:`md`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,maw:1600,mx:`auto`,"data-explore":!0,children:[!r&&(0,$.jsx)(s,{title:`Explore`,description:`Ask a question of your telemetry.`,meta:(0,$.jsx)(x,{time:R,updatedAt:F?de:null})}),(0,$.jsx)(v,{inHeader:!r,time:R,onRange:t=>Qe({...e,range:t,from:void 0,to:void 0}),onAbsolute:(t,n)=>Qe({...e,from:t,to:n})}),(0,$.jsxs)(g,{value:e.tab,onChange:e=>void it(e===`sql`||e===`builder`?e:`query`),keepMounted:!1,children:[(0,$.jsxs)(g.List,{children:[(0,$.jsx)(g.Tab,{value:`query`,children:`Query`}),(0,$.jsx)(g.Tab,{value:`builder`,children:`Builder`}),(0,$.jsx)(g.Tab,{value:`sql`,children:`SQL`})]}),(0,$.jsx)(g.Panel,{value:`query`,pt:`sm`,children:(0,$.jsxs)(a,{gap:`xs`,children:[(0,$.jsxs)(c,{id:L,size:`xs`,c:`dimmed`,children:[`Press Enter to run. For example `,(0,$.jsx)(`code`,{children:`spans | p95(duration) by service every 5m`}),`.`]}),X&&(0,$.jsxs)(c,{size:`xs`,c:`dimmed`,"data-fanql-readonly":!0,children:[`This query is edited in the Builder: `,A?.reason??`it is too large for the text editor`,`.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fe,{value:T,readOnly:X,placeholder:`spans | count() by service`,onChange:(e,t)=>{tt(),ge(e),N(t?.problems??[]),Re(t?.notices??[]),Te(void 0)},onRun:()=>{T.trim()||He(e=>e+1),G(`query`,T,e.viz,X?k:void 0)},problems:M,notices:Le,describedBy:L,complete:(e,t,n)=>Ae({text:e,cursor:t,...R.from&&R.to?{from:R.from,to:R.to}:{window:R.range}},n)}),(0,$.jsx)(c,{size:`xs`,c:`dimmed`,mt:at?4:0,"aria-live":`polite`,"data-fanql-empty":!0,children:at&&(0,$.jsxs)(`span`,{children:[`Type a query to run, for example `,(0,$.jsx)(`code`,{children:`spans | count() by service`}),`.`]},Ve)})]})]})}),(0,$.jsx)(g.Panel,{value:`builder`,pt:`sm`,children:(0,$.jsxs)(a,{gap:`xs`,children:[!k&&(M.length>0||ze)?(0,$.jsx)(o,{"data-builder-blocked":!0,children:(0,$.jsxs)(d,{tone:`danger`,title:`This query cannot open in the Builder`,children:[M.length>0?(0,$.jsx)(a,{gap:2,mb:`xs`,children:M.map((e,t)=>(0,$.jsxs)(c,{size:`sm`,children:[e.message,e.hint?` (${e.hint})`:``]},t))}):(0,$.jsx)(c,{size:`sm`,mb:`xs`,children:ze}),(0,$.jsx)(l,{size:`compact-sm`,variant:`default`,onClick:()=>void it(`query`),children:`Fix it in the Query tab`})]})}):(0,$.jsxs)($.Fragment,{children:[W.error&&(0,$.jsxs)(d,{tone:`warning`,title:`Fields could not be loaded`,children:[k?`Only the fields this query uses are offered until the field list loads. `:``,W.error.message,(0,$.jsx)(l,{size:`compact-xs`,variant:`default`,ml:`xs`,loading:W.isFetching,onClick:()=>void W.refetch(),children:`Retry`})]}),k&&(W.data??W.error)?(0,$.jsx)(Yn,{query:k,schema:W.data??Kn(k),variables:(u??[]).map(e=>e.name),labels:Oe,onChange:nt,onInvalid:Me}):!W.error&&(0,$.jsx)(c,{size:`sm`,c:`dimmed`,children:`Loading fields…`})]}),Ee.length>0&&(0,$.jsx)(a,{gap:2,role:`alert`,"data-builder-problems":!0,children:Ee.map((e,t)=>(0,$.jsxs)(c,{size:`sm`,c:`bad`,children:[e.message,e.hint?` (${e.hint})`:``]},t))}),A&&Ee.length===0&&(0,$.jsxs)(c,{size:`xs`,c:`dimmed`,"data-builder-text":!0,children:[`As FanQL: `,(0,$.jsx)(`code`,{children:A.text})]})]})}),(0,$.jsxs)(g.Panel,{value:`sql`,pt:`sm`,children:[!E.trim()&&(0,$.jsxs)(c,{size:`xs`,c:`dimmed`,mb:`xs`,"data-sql-hint":!0,children:[T.trim()?`SQL runs on its own; the FanQL query is not converted. `:``,`Write one SELECT over spans, logs or metrics that filters time with `,(0,$.jsx)(`code`,{children:`$__window(time_column)`}),`, for example `,(0,$.jsx)(`code`,{children:`SELECT service, count(*) AS spans FROM spans WHERE $__window(start_time) GROUP BY service`}),`.`]}),(0,$.jsx)(Cn,{value:E,onChange:e=>{_e(e),N([])},onRun:()=>void G(`sql`,E),onEscape:()=>be.current?.focus(),schema:W.data,problems:e.tab===`sql`?M:[],label:r?`Panel SQL`:`Explore SQL`}),e.tab===`sql`&&M.length>0&&(0,$.jsx)(d,{tone:`danger`,title:`The SQL has problems`,children:(0,$.jsx)(`ul`,{children:M.map((e,t)=>(0,$.jsxs)(`li`,{className:`sql-problem`,children:[e.message,e.hint?` (${e.hint})`:``]},t))})})]})]}),(0,$.jsxs)(i,{justify:`space-between`,children:[(0,$.jsxs)(i,{gap:`xs`,children:[(0,$.jsx)(l,{ref:be,loading:I,disabled:e.tab===`builder`?!k||Ee.length>0||je:!Y.trim(),onClick:()=>void(e.tab===`builder`?rt(e.viz):G(J,Y,e.viz,X?k:void 0)),children:`Run`}),J===`query`&&st.length>0&&(0,$.jsx)(te,{size:`xs`,"aria-label":`Visualization`,value:F?.panel.viz??e.viz??``,onChange:t=>void(e.tab===`builder`?rt(t):G(`query`,T,t,X?k:void 0)),data:st.map(e=>({value:e.viz,disabled:!p(e),label:p(e)?$n[e.viz]:(0,$.jsx)(ue,{label:`Needs ${e.requires.map(e=>er[e]).join(` and `)}; set them after saving`,children:(0,$.jsx)(`span`,{children:$n[e.viz]})})}))}),J===`query`&&!ot&&!X&&O?.viz.edits.map(e=>(0,$.jsx)(ue,{label:(0,$.jsxs)($.Fragment,{children:[`Rewrites the query as `,(0,$.jsx)(`code`,{children:e.text})]}),multiline:!0,maw:420,children:(0,$.jsxs)(l,{size:`compact-sm`,variant:`subtle`,onClick:()=>{ge(e.text),G(`query`,e.text,e.viz)},children:[$n[e.viz],`…`]})},e.viz))]}),(0,$.jsxs)(i,{gap:`xs`,children:[r?.cancel&&(0,$.jsx)(l,{variant:`default`,disabled:me,onClick:r.cancel,children:`Cancel`}),(0,$.jsx)(ue,{label:ft,disabled:Z,events:{hover:!0,focus:!0,touch:!0},children:r?(0,$.jsx)(l,{"data-disabled":!Z||void 0,"aria-disabled":!Z,"aria-describedby":Z?void 0:pt,loading:me,onClick:()=>{let e=ut?F?.panel:f;e&&Z&&(C(!0),pe(void 0),r.save.run(e).catch(e=>pe(e instanceof Error?e.message:`Save failed`)).finally(()=>C(!1)))},children:r.save.label}):(0,$.jsx)(l,{variant:`default`,"data-disabled":!Z||void 0,"aria-disabled":!Z,"aria-describedby":Z?void 0:pt,onClick:()=>F&&Z&&he(F.panel),children:`Save to dashboard`})}),!Z&&(0,$.jsx)(`span`,{id:pt,hidden:!0,children:ft})]})]}),ze&&(0,$.jsx)(d,{tone:`danger`,title:`The query could not run`,children:ze}),S&&(0,$.jsx)(d,{tone:`danger`,title:`Not saved`,children:S}),(0,$.jsx)(o,{ref:Je,children:F?(0,$.jsxs)(a,{gap:`xs`,children:[(0,$.jsx)(c,{size:`sm`,fw:600,role:`status`,children:I?`Running the query…`:F.kind===J?F.source===Y?F.window===H?F.canonical?(0,$.jsxs)($.Fragment,{children:[`Ran as `,(0,$.jsx)(`code`,{children:F.canonical})]}):`Result`:`Result of the last run · time range has changed`:`Result of the last run · query has changed`:`Result of the last ${F.kind===`sql`?`SQL`:`FanQL`} run`}),(0,$.jsx)(o,{h:Qn,children:(0,$.jsx)(m,{panel:F.panel,title:F.panel.title,result:F.result,loading:I,height:Qn,group:`explore`,editing:!1,agentAvailable:!1,range:R.range,onRetry:()=>void G(F.kind,F.source,F.panel.viz,X?k:void 0),traceLinks:`button`,onPoint:mt?n=>{let r=ee(F.panel,F.result,n,ie);r&&t({...e,drill:JSON.stringify(r.target)})}:void 0})})]}):I?(0,$.jsx)(c,{c:`dimmed`,size:`sm`,role:`status`,"data-explore-running":!0,children:`Running the query…`}):(0,$.jsx)(c,{c:`dimmed`,size:`sm`,"data-explore-empty":!0,children:e.tab===`builder`?`Build a query above and press Run.`:e.tab===`sql`?`Write a query above and press Run.`:`Type a query above and press Enter.`})}),F&&(0,$.jsx)(y,{client:Se,spec:{version:1,name:r?.spec.name??`Explore`,time:R,variables:u,panels:[F.panel]},time:R,vars:ie,target:ne(e.drill),onChange:n=>t({...e,drill:n?JSON.stringify(n):void 0})}),w&&n&&(0,$.jsx)(Ie,{panel:w,time:R,onClose:()=>he(void 0),onSaved:n})]})}export{or as t}; \ No newline at end of file +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{A as r,G as i,T as a,Tt as o,g as s,j as c,k as l,q as u,s as d,w as f,y as p}from"./brand-D6fP-cLS.js";import{a as m,c as ee,g as te,h,m as g,r as _,t as v,u as y}from"./toolbar-CLcpDIVT.js";import{d as ne,g as b,w as re}from"./search-P7VEnlsD.js";import{t as ie}from"./NumberInput-CixyOph4.js";import{t as x}from"./live-data-meta-CkxM9djV.js";import{s as ae}from"./auth-DcVParCH.js";import{t as oe}from"./useQuery-BLTYSIvG.js";import{i as se,r as ce,t as le}from"./search-pvW8SUhM.js";import{ct as ue,k as de}from"./index-D7FG-NN3.js";import{A as fe,B as S,C as pe,D as me,E as C,F as w,H as he,I as T,L as ge,M as E,N as _e,O as D,P as ve,R as ye,S as be,T as O,U as xe,V as k,W as Se,_ as Ce,a as we,b as A,c as Te,d as Ee,f as De,g as Oe,h as ke,i as Ae,j as je,k as Me,l as j,m as M,n as Ne,o as Pe,p as N,s as Fe,t as Ie,u as Le,v as Re,w as ze,x as Be,y as Ve,z as He}from"./save-dialog-DpwJ9nWF.js";var P=n(e(),1),F=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new Ue(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizeo;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.reducePos=this.pos=n+e.length;this.pushState(t,n),this.buffer.push(r,n,i,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new We(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;rt&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}},Ue=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},We=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},Ge=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function I(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var Ke=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},qe=new Ke,Je=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=qe,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;in.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t=this.chunk2Pos&&nt.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=qe,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},L=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;z(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};L.prototype.contextual=L.prototype.fallback=L.prototype.extend=!1;var R=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?I(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(z(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};R.prototype.contextual=L.prototype.fallback=L.prototype.extend=!1;var Ye=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function z(e,t,n,r,i,a){let o=0,s=1<0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||Xe(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function B(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function Xe(e,t,n,r){let i=B(n,r,t);return i<0||B(n,r,e)t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var Qe=class{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Ze(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Ze(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=a,null;if(i instanceof w){let n=a>this.lastRepeatPos&&i.type.id>=this.minRepeat;if(a==e||n){let t=a+i.length,r;if(a>=this.safeFrom&&t<=this.safeTo&&(!(r=i.prop(je.lookAhead))||t+r=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},$e=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new Ke)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;rl.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new Ke,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ke,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;te.bufferLength*4?new Qe(n,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&tt(r);if(e)return V&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw V&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return V&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e-1&&n.length&&(!i||(n.prop(je.contextHash)||0)==a))return e.useNode(n,o,t),n;if(n.children.length==0||n.positions[0]>0)break;let s=n.children[0];if(s instanceof w&&(!r||s.type.id>=this.parser.minRepeatTerm))n=s;else break}return null}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=V?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.reducePos0)return e.reduce(o),V&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;or?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return W(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),V&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(V&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)V&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))V&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),V&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),W(o,n)):(!r||r.scoree.topRules[t][1]),r=[];for(let e=0;e=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new E(t.map((t,i)=>_e.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Me;let a=I(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;etypeof e==`number`?new L(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new U(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=K(this.data,n+2);else break}r=t(K(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=K(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=q(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;ee)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scoree.external(n,r)<<1|t}return e.get}var nt=36,rt=1,it=2,J=3,Y=4,at=5,X=6,ot=7,st=8,ct=9,lt=10,ut=11,Z=12,dt=13,ft=14,pt=15,mt=16,ht=17,gt=18,_t=19,vt=20,yt=21,bt=22,xt=23,St=24;function Ct(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function wt(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Q(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function Tt(e,t){scan:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n)`.charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function Dt(e,t){for(;e.next==95||Ct(e.next);)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function Ot(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),Q(e,t,!1)}else Dt(e)}function kt(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function At(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function jt(e){for(;!(e.next<0||e.next==10);)e.advance()}function Mt(e,t){for(let n=0;n!=&|~^/`,specialVar:`?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!1,words:Pt(It,Ft)};function Rt(e,t,n,r){let i={};for(let t in Lt)i[t]=(e.hasOwnProperty(t)?e:Lt)[t];return t&&(i.words=Pt(t,n||``,r)),i}function zt(e){return new Ye(t=>{let{next:n}=t;if(t.advance(),Mt(n,Nt)){for(;Mt(t.next,Nt);)t.advance();t.acceptToken(nt)}else if(n==36&&e.doubleDollarQuotedStrings){let e=Dt(t,``);t.next==36&&(t.advance(),Tt(t,e),t.acceptToken(J))}else if(n==39||n==34&&e.doubleQuotedStrings)Q(t,n,e.backslashEscapes),t.acceptToken(J);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)jt(t),t.acceptToken(rt);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))jt(t),t.acceptToken(rt);else if(n==47&&t.next==42){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),n==42&&t.next==47){if(e--,t.advance(),!e)break}else n==47&&t.next==42&&(e++,t.advance())}t.acceptToken(it)}else if((n==101||n==69)&&t.next==39)t.advance(),Q(t,39,!0),t.acceptToken(J);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),Q(t,39,e.backslashEscapes),t.acceptToken(J);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),Q(t,39,e.backslashEscapes),t.acceptToken(J);break}if(!Ct(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!Mt(t.peek(1),Nt)){let e=t.peek(1);t.advance(2),Et(t,e),t.acceptToken(J)}else if(Mt(n,e.identifierQuotes))Q(t,n==91?93:n,!1),t.acceptToken(_t);else if(n==40)t.acceptToken(ot);else if(n==41)t.acceptToken(st);else if(n==123)t.acceptToken(ct);else if(n==125)t.acceptToken(lt);else if(n==91)t.acceptToken(ut);else if(n==93)t.acceptToken(Z);else if(n==59)t.acceptToken(dt);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),kt(t),t.acceptToken(bt);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(Q(t,n,e.backslashEscapes),t.acceptToken(xt)):(kt(t,n),t.acceptToken(bt))}else if(n==48&&(t.next==120||t.next==88)||(n==120||n==88)&&t.next==39){let e=t.next==39;for(t.advance();wt(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(Y)}else if(n==46&&t.next>=48&&t.next<=57)At(t,!0),t.acceptToken(Y);else if(n==46)t.acceptToken(ft);else if(n>=48&&n<=57)At(t,!1),t.acceptToken(Y);else if(Mt(n,e.operatorChars)){for(;Mt(t.next,e.operatorChars);)t.advance();t.acceptToken(pt)}else if(Mt(n,e.specialVar))t.next==n&&t.advance(),Ot(t),t.acceptToken(ht);else if(n==58||n==44)t.acceptToken(mt);else if(Ct(n)){let r=Dt(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?gt:e.words[r.toLowerCase()]??gt)}})}var Bt=zt(Lt),Vt=et.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:`⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement`,maxTerm:38,nodeProps:[[`isolate`,-4,1,2,3,19,``]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:`RORO`,tokenizers:[0,Bt],topRules:{Script:[0,25]},tokenPrec:0});function Ht(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function Ut(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function Wt(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function Gt(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)Wt(r)&&n.push(Ut(e,r));return n}return[Ut(e,t)]}function Kt(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=Ht(t);if(!Wt(r))return n;n.unshift(Ut(e,r)),t=Ht(r)}}function qt(e,t){let n=C(e).resolveInner(t,-1),r=Yt(e.doc,n);return n.name==`Identifier`||n.name==`QuotedIdentifier`||n.name==`Keyword`?{from:n.from,quoted:n.name==`QuotedIdentifier`?e.doc.sliceString(n.from,n.from+1):null,parents:Kt(e.doc,Ht(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:Kt(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var Jt=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function Yt(e,t){let n;for(let e=t;!n;e=e.parent){if(!e)return null;e.name==`Statement`&&(n=e)}let r=null;for(let t=n.firstChild,i=!1,a=null;t;t=t.nextSibling){let n=t.name==`Keyword`?e.sliceString(t.from,t.to).toLowerCase():null,o=null;if(!i)i=n==`from`;else if(n==`as`&&a&&Wt(t.nextSibling))o=Ut(e,t.nextSibling);else if(n&&Jt.has(n))break;else a&&Wt(t)&&(o=Ut(e,t));o&&(r||=Object.create(null),r[o]=Gt(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function Xt(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var Zt=/^\w*$/,Qt=/^[`'"\[]?\w*[`'"\]]?$/;function $t(e){return e.self&&typeof e.self.label==`string`}var en=class e{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(t){let n=this.children||=Object.create(null);return n[t]||(t&&!this.list.some(e=>e.label==t)&&this.list.push(tn(t,`type`,this.idQuote,this.idCaseInsensitive)),n[t]=new e(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t==`string`?tn(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):$t(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],r=null,i=t.replace(/\\?\./g,e=>e==`.`?`\0`:e).split(`\0`),a=this;$t(n)&&(r=n.self,n=n.children);for(let e=0;e{let{parents:t,from:n,quoted:i,empty:a,aliases:c}=qt(e.state,e.pos);if(a&&!e.explicit)return null;c&&t.length==1&&(t=c[t[0]]||t);let l=o;for(let e of t){for(;!l.children||!l.children[e];)if(l==o&&s)l=s;else if(l==s&&r)l=l.child(r);else return null;let t=l.maybeChild(e);if(!t)return null;l=t}let u=l.list;if(l==o&&c&&(u=u.concat(Object.keys(c).map(e=>({label:e,type:`constant`})))),i){let t=i[0],r=nn(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:Xt(t,r,u),validFor:Qt}}return{from:n,options:u,validFor:Zt}}}function an(e){return e==yt?`type`:e==vt?`keyword`:`variable`}function on(e,t,n){let r=Object.keys(e).map(r=>n(t?r.toUpperCase():r,an(e[r])));return M([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],De(r))}var sn=Vt.configure({props:[pe.add({Statement:Be()}),be.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),me({Keyword:D.keyword,Type:D.typeName,Builtin:D.standard(D.name),Bits:D.number,Bytes:D.string,Bool:D.bool,Null:D.null,Number:D.number,String:D.string,Identifier:D.name,QuotedIdentifier:D.special(D.string),SpecialVar:D.special(D.name),LineComment:D.lineComment,BlockComment:D.blockComment,Operator:D.operator,"Semi Punctuation":D.punctuation,"( )":D.paren,"{ }":D.brace,"[ ]":D.squareBracket})]}),cn=class e{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(t,n){return new e(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=Rt(t,t.keywords,t.types,t.builtin),r=Re.define({name:`sql`,parser:sn.configure({tokenizers:[{from:Bt,to:zt(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}});return new e(n,r,t)}};function ln(e,t){return{label:e,type:t,boost:-1}}function un(e,t=!1,n){return on(e.dialect.words,t,n||ln)}function dn(e){return e.schema?rn(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||mn):()=>null}function fn(e){return e.schema?(e.dialect||mn).language.data.of({autocomplete:dn(e)}):[]}function pn(e={}){let t=e.dialect||mn;return new Ve(t.language,[fn(e),t.language.data.of({autocomplete:un(t,e.upperCaseKeywords,e.keywordCompletion)})])}var mn=cn.define({}),hn=cn.define({charSetCasts:!0,doubleDollarQuotedStrings:!0,operatorChars:"+-*/<>=~!@#%^&|`?",specialVar:``,keywords:It+`abort abs absent access according ada admin aggregate alias also always analyse analyze array_agg array_max_cardinality asensitive assert assignment asymmetric atomic attach attribute attributes avg backward base64 begin_frame begin_partition bernoulli bit_length blocked bom cache called cardinality catalog_name ceil ceiling chain char_length character_length character_set_catalog character_set_name character_set_schema characteristics characters checkpoint class class_origin cluster coalesce cobol collation_catalog collation_name collation_schema collect column_name columns command_function command_function_code comment comments committed concurrently condition_number configuration conflict connection_name constant constraint_catalog constraint_name constraint_schema contains content control conversion convert copy corr cost covar_pop covar_samp csv cume_dist current_catalog current_row current_schema cursor_name database datalink datatype datetime_interval_code datetime_interval_precision db debug defaults defined definer degree delimiter delimiters dense_rank depends derived detach detail dictionary disable discard dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue document dump dynamic_function dynamic_function_code element elsif empty enable encoding encrypted end_frame end_partition endexec enforced enum errcode error event every exclude excluding exclusive exp explain expression extension extract family file filter final first_value flag floor following force foreach fortran forward frame_row freeze fs functions fusion generated granted greatest groups handler header hex hierarchy hint id ignore ilike immediately immutable implementation implicit import include including increment indent index indexes info inherit inherits inline insensitive instance instantiable instead integrity intersection invoker isnull key_member key_type label lag last_value lead leakproof least length library like_regex link listen ln load location lock locked log logged lower mapping matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text min minvalue mod mode more move multiset mumps name namespace nfc nfd nfkc nfkd nil normalize normalized nothing notice notify notnull nowait nth_value ntile nullable nullif nulls number occurrences_regex octet_length octets off offset oids operator options ordering others over overlay overriding owned owner parallel parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partition pascal passing passthrough password percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding prepared print_strict_params procedural procedures program publication query quote raise range rank reassign recheck recovery refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex rename repeatable replace replica requiring reset respect restart restore result_oid returned_cardinality returned_length returned_octet_length returned_sqlstate returning reverse routine_catalog routine_name routine_schema routines row_count row_number rowtype rule scale schema_name schemas scope scope_catalog scope_name scope_schema security selective self sensitive sequence sequences serializable server server_name setof share show simple skip slice snapshot source specific_name sqlcode sqlerror sqrt stable stacked standalone statement statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time table_name tables tablesample tablespace temp template ties token top_level_count transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex trigger_catalog trigger_name trigger_schema trim trim_array truncate trusted type types uescape unbounded uncommitted unencrypted unlink unlisten unlogged unnamed untyped upper uri use_column use_variable user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema vacuum valid validate validator value_of var_pop var_samp varbinary variable_conflict variadic verbose version versioning views volatile warning whitespace width_bucket window within wrapper xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate yes`,types:Ft+`bigint int8 bigserial serial8 varbit bool box bytea cidr circle precision float8 inet int4 json jsonb line lseg macaddr macaddr8 money numeric pg_lsn point polygon float4 int2 smallserial serial2 serial serial4 text timetz timestamptz tsquery tsvector txid_snapshot uuid xml`}),gn=`accessible algorithm analyze asensitive authors auto_increment autocommit avg avg_row_length binlog btree cache catalog_name chain change changed checkpoint checksum class_origin client_statistics coalesce code collations columns comment committed completion concurrent consistent contains contributors convert database databases day_hour day_microsecond day_minute day_second delay_key_write delayed delimiter des_key_file dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile enable enclosed ends engine engines enum errors escaped even event events every explain extended fast field fields flush force found_rows fulltext grants handler hash high_priority hosts hour_microsecond hour_minute hour_second ignore ignore_server_ids import index index_statistics infile innodb insensitive insert_method install invoker iterate keys kill linear lines list load lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modify mutex mysql_errno no_write_to_binlog offline offset one online optimize optionally outfile pack_keys parser partition partitions password phase plugin plugins prev processlist profile profiles purge query quick range read_write rebuild recover regexp relaylog remove rename reorganize repair repeatable replace require resume rlike row_format rtree schedule schema_name schemas second_microsecond security sensitive separator serializable server share show slave slow snapshot soname spatial sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result ssl starting starts std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace terminated triggers truncate uncommitted uninstall unlock upgrade use use_frm user_resources user_statistics utc_date utc_time utc_timestamp variables views warnings xa xor year_month zerofill`;Ft+``,It+``+gn,It+``+gn,It+``,Ft+``,It+``,Ft+``,Ft+``,It+``,Ft+``;var _n=cn.define({...hn.spec,keywords:`${hn.spec.keywords} qualify exclude replace pivot unpivot summarize asof positional semi anti union by name columns sample using key`,types:`${hn.spec.types} variant timestamp_ns timestamptz_ns hugeint uhugeint ubigint uinteger`,builtin:`${hn.spec.builtin??``} time_bucket epoch_ns epoch_ms make_timestamp_ns try_cast count_if arg_max arg_min any_value quantile_cont quantile_disc approx_quantile histogram first last list list_extract list_value list_distinct list_sort unnest struct_pack struct_extract map map_keys map_extract map_extract_value json_extract json_extract_string json_keys json_type to_json regexp_matches regexp_full_match regexp_replace regexp_extract starts_with contains greatest least isfinite isinf isnan date_diff date_sub`,specialVar:`$?`}),vn=De([{label:`$__window`,type:`function`,detail:`Time filter`,info:`Use $__window(time_column) to apply the dashboard time range.`},{label:`$__bucket`,type:`function`,detail:`Time bucket`,info:`Use $__bucket(time_column) to group by the panel interval.`}]);function yn(e){return Object.fromEntries(Object.entries({...e.signals,...e.sql_relations}).map(([e,t])=>[e,t.columns.map(e=>({label:e.name,type:`property`,detail:e.sql_type??e.type,info:e.description}))]))}function bn(e,t){let n=e.line(Math.max(1,Math.min(e.lines,t.line+1)));return n.from+Math.max(0,Math.min(n.length,t.character))}function xn(e,t){return t.map(t=>{let n=t.range?bn(e,t.range.start):0;return{from:n,to:t.range?Math.max(n,bn(e,t.range.end)):e.length,severity:`error`,message:t.message+(t.hint?` (${t.hint})`:``)}})}var $=t(),Sn=[];function Cn(e){let{value:t,schema:n,problems:r=Sn,label:i=`Panel SQL`,describedBy:a,disabled:o=!1}=e,s=(0,P.useRef)(null),c=(0,P.useRef)(null),l=(0,P.useRef)(e);l.current=e;let u=(0,P.useRef)({language:new k,editable:new k,attributes:new k});return(0,P.useEffect)(()=>{let{language:e,editable:t,attributes:n}=u.current,r=new T({parent:s.current,state:he.create({doc:l.current.value,extensions:[S(),Oe(),ge(),ye(),A(),ze(),j,O(Te),T.lineWrapping,e.of(pn({dialect:_n})),_n.language.data.of({autocomplete:vn}),t.of([]),n.of([]),xe.highest(He.of([{key:`Mod-Enter`,run:()=>(l.current.disabled||l.current.onRun(),!0),stopPropagation:!0},{key:`Escape`,run:()=>(r.contentDOM.blur(),l.current.onEscape(),!0),stopPropagation:!0}])),Ee(),He.of([...N.filter(e=>e.key!==`Escape`),...ke,...Ce]),T.updateListener.of(e=>{e.docChanged&&l.current.onChange(e.state.doc.toString())})]})});return c.current=r,()=>{c.current=null,r.destroy()}},[]),(0,P.useEffect)(()=>{let e=c.current;e.state.doc.toString()!==t&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t}})},[t]),(0,P.useEffect)(()=>{c.current.dispatch({effects:u.current.language.reconfigure(pn({dialect:_n,schema:n?yn(n):void 0}))})},[n]),(0,P.useEffect)(()=>{c.current.dispatch({effects:u.current.editable.reconfigure([he.readOnly.of(o),T.editable.of(!o)])})},[o]),(0,P.useEffect)(()=>{c.current.dispatch({effects:u.current.attributes.reconfigure(T.contentAttributes.of({role:`textbox`,"aria-label":i,"aria-multiline":`true`,"aria-describedby":a??``,"aria-invalid":r.length?`true`:`false`,spellcheck:`false`}))})},[i,a,r.length]),(0,P.useEffect)(()=>{let e=c.current;e.dispatch(Le(e.state,xn(e.state.doc,r)))},[t,r]),(0,$.jsx)(`div`,{ref:s,"data-sql-editor":!0})}var wn=[`=`,`!=`,`>`,`>=`,`<`,`<=`],Tn=String.raw`[a-z_][a-z0-9_]*|(?:attributes|resource)\['(?:[^']|'')+'\]`,En=String.raw`'(?:[^']|'')*'|-?\d+(?:\.\d+)?|\$[a-z][a-z0-9_]*`,Dn=new RegExp(String.raw`^(${Tn})\s*(!=|>=|<=|=|>|<)\s*(${En})$`),On=/^-?\d+(?:\.\d+)?$/,kn=/^\$[a-z][a-z0-9_]*$/;function An(e){let t=Dn.exec(e.trim());if(!t)return;let[,n,r,i]=t,a=i.startsWith(`'`);return{field:n,op:r,value:a?i.slice(1,-1).replaceAll(`''`,`'`):i,quoted:a}}function jn(e,t=[]){let n=e.value.trim();if(kn.test(n)&&t.includes(n.slice(1)))return`${e.field} ${e.op} ${n}`;let r=e.quoted||!On.test(n)?`'${e.value.replaceAll(`'`,`''`)}'`:e.value.trim();return`${e.field} ${e.op} ${r}`}var Mn={h:36e5,m:6e4,s:1e3,ms:1,us:.001},Nn=/^(\d+(?:\.\d+)?)\s*(h|m|s|ms|us)$/i,Pn=e=>Number(e.toPrecision(12));function Fn(e){let t=e.trim();if(On.test(t))return Number(t);let n=Nn.exec(t);return n?Pn(Number(n[1])*Mn[n[2].toLowerCase()]):void 0}function In(e){for(let[t,n]of Object.entries(Mn))if(e>=n&&Pn(Pn(e/n)*n)===e)return`${Pn(e/n)}${t}`;return`${e}ms`}var Ln=[`spans`,`logs`,`metrics`],Rn=new Set([`count`,`rate`,`error_rate`,`share`]),zn=new Set([`quantile`]),Bn=new RegExp(String.raw`^([a-z_][a-z0-9_]*)\((|${Tn})\)$`);function Vn(e,t){let n=Bn.exec(e.trim());if(n&&!zn.has(n[1])&&t.includes(n[1])&&Rn.has(n[1])===(n[2]===``))return{fn:n[1],field:n[2]}}var Hn=e=>`${e.fn}(${Rn.has(e.fn)?``:e.field})`,Un=`duration_ms`,Wn=/^\$[a-z][a-z0-9_]*$/;function Gn(e,t){if(e===Un){let e=Fn(t);return e===void 0?void 0:String(e)}return/^-?\d+(?:\.\d+)?$/.test(t)?t:void 0}function Kn(e){let t=new Set,n=new Set,r=new Set([`count`]);for(let i of e.measures??[]){let e=Bn.exec(i.trim());e&&(r.add(e[1]),e[2]&&(e[1]===`count_distinct`?n:t).add(e[2]))}for(let r of e.where??[]){let e=An(r);e&&(e.quoted?n:t).add(e.field)}for(let t of e.by??[])n.add(t);n.add(`service`);let i=e=>({name:e,type:t.has(e)?`number`:`string`});return{signals:{[e.from]:{columns:[...new Set([...t,...n])].map(i)}},sql_relations:{},measures:[...r],buckets:[`auto`,...e.bucket&&e.bucket!==`auto`?[e.bucket]:[]]}}function qn(e,t){let n=e.signals[t],r=(n?.columns??[]).filter(e=>e.type!==`map`&&e.type!==`time`),i=(n?.attributes??[]).map(e=>({name:`${e.scope===`resource`?`resource`:`attributes`}['${e.key.replaceAll(`'`,`''`)}']`,type:e.type}));return[...r,...i]}function Jn({text:e,onRemove:t}){return(0,$.jsx)(r,{variant:`light`,color:`gray`,size:`lg`,tt:`none`,rightSection:(0,$.jsx)(u,{size:`xs`,variant:`subtle`,color:`gray`,"aria-label":`Remove ${e}`,onClick:t,children:(0,$.jsx)(p,{size:10})}),children:(0,$.jsx)(`code`,{children:e})})}function Yn({query:e,schema:t,variables:n=[],labels:r={},onChange:o,onInvalid:s}){let d=qn(t,e.from),m=new Set(d.map(e=>e.name)),ee=new Set(d.filter(e=>e.type===`number`||e.type===`int`||e.type===`float`).map(e=>e.name)),te=d.map(e=>e.name),g=t.measures??[],_=e.where??[],v=e.measures??[],y=e.by??[],ne=t.buckets??[],[b,re]=(0,P.useState)(),x=e=>{re(e),s?.(e!==void 0&&e.condition.value.trim()!==``)},ae=(0,P.useRef)(s);ae.current=s,(0,P.useEffect)(()=>()=>ae.current?.(!1),[]);let[oe,se]=(0,P.useState)(),ce=b!==void 0&&b.condition.value.trim()!==``,le=e=>r[e]??e,[ue,fe]=(0,P.useState)(),S=t=>{fe(void 0),o({...e,...t})},pe=n=>{let r=new Set(qn(t,n).map(e=>e.name)),i=e=>r.has(e)||e.startsWith(`attributes[`)||e.startsWith(`resource[`),a={where:_.filter(e=>{let t=An(e);return!t||i(t.field)}),measures:v.filter(e=>{let t=Vn(e,g);return!t||!t.field||i(t.field)}),by:y.filter(i)},s=[...v.filter(e=>!a.measures.includes(e)),..._.filter(e=>!a.where.includes(e)),...y.filter(e=>!a.by.includes(e))];a.measures.length===0&&v.length>0&&(a.measures=[`count()`]),x(void 0),fe(s.length>0?`Removed what ${n} does not have: ${s.map(le).join(`, `)}.`:void 0),o({...e,from:n,...a})},me=(e,t,n)=>e.map((e,r)=>r===t?n:e),C=(e,t)=>e.filter((e,n)=>n!==t),w=e=>m.has(e)?te:[e,...te];return(0,$.jsxs)(a,{gap:`sm`,"data-builder":!0,children:[(0,$.jsx)(h,{label:`Source`,w:200,allowDeselect:!1,value:e.from,data:[...Ln],onChange:t=>t&&t!==e.from&&pe(t)}),ue&&(0,$.jsx)(c,{size:`xs`,c:`dimmed`,role:`status`,"data-builder-removed":!0,children:ue}),(0,$.jsxs)(a,{gap:6,children:[(0,$.jsx)(c,{size:`sm`,fw:500,children:`Measures`}),v.map((e,n)=>{let r=Vn(e,g);return r?(0,$.jsxs)(i,{gap:`xs`,wrap:`nowrap`,children:[(0,$.jsx)(h,{"aria-label":`Measure ${n+1} function`,w:160,allowDeselect:!1,searchable:!0,value:r.fn,data:(t.measures??[]).filter(e=>!zn.has(e)),onChange:e=>e&&S({measures:me(v,n,Hn({fn:e,field:Rn.has(e)?``:r.field||(ee.values().next().value??``)}))})}),!Rn.has(r.fn)&&(0,$.jsx)(h,{"aria-label":`Measure ${n+1} field`,w:260,searchable:!0,value:r.field||null,data:Xn(r.fn,te,ee,w(r.field)),onChange:e=>e&&S({measures:me(v,n,Hn({...r,field:e}))})}),(0,$.jsx)(u,{variant:`subtle`,color:`gray`,"aria-label":`Remove measure ${n+1}`,onClick:()=>S({measures:C(v,n)}),children:(0,$.jsx)(p,{size:14})})]},n):(0,$.jsx)(i,{children:(0,$.jsx)(Jn,{text:le(e),onRemove:()=>S({measures:C(v,n)})})},n)}),(0,$.jsx)(i,{children:(0,$.jsx)(l,{size:`compact-sm`,variant:`subtle`,leftSection:(0,$.jsx)(de,{size:12}),onClick:()=>S({measures:[...v,`count()`]}),children:`Add measure`})})]}),(0,$.jsxs)(a,{gap:6,children:[(0,$.jsx)(c,{size:`sm`,fw:500,children:`Filters`}),(b?[..._.slice(0,b.at),b.condition,..._.slice(b.at)]:_).map((e,r)=>{let a=b?.at===r,o=b&&r>b.at?r-1:r,s=()=>{b&&o{let t={...c,...e};m.has(t.field)&&(t.quoted=!ee.has(t.field));let r=t.value.trim(),i=Wn.test(r)&&n.includes(r.slice(1)),s=ee.has(t.field)&&!i?Gn(t.field,r):r;if(!s){x({at:o,condition:t}),a||S({where:C(_,o)});return}a&&x(void 0);let l=jn({...t,value:s},n);S({where:a?[..._.slice(0,o),l,..._.slice(o)]:me(_,o,l)})},d=a&&ce?c.field===Un?`Enter a duration such as 100ms or 1.5s`:`Enter a number`:void 0,te=oe?.row===r?oe.text:c.field===Un&&!c.quoted&&Fn(c.value)!==void 0&&!a?In(Number(c.value)):c.value;return(0,$.jsxs)(i,{gap:`xs`,wrap:`nowrap`,align:`flex-start`,children:[(0,$.jsx)(h,{"aria-label":`Filter ${r+1} field`,w:260,searchable:!0,allowDeselect:!1,value:c.field,data:w(c.field),onChange:e=>e&&l({field:e})}),(0,$.jsx)(h,{"aria-label":`Filter ${r+1} operator`,w:90,style:{flexShrink:0},allowDeselect:!1,value:c.op,data:[...wn],onChange:e=>e&&l({op:e})}),c.field===`service`&&t.services?.length?(0,$.jsx)(h,{"aria-label":`Filter ${r+1} value`,w:220,searchable:!0,value:c.value||null,data:[...n.map(e=>`$${e}`),...t.services.map(e=>e.value)],onChange:e=>l({value:e??``})}):(0,$.jsx)(f,{"aria-label":`Filter ${r+1} value`,w:220,placeholder:a?`Value`:void 0,value:te,error:d,onBlur:()=>se(void 0),onChange:e=>{let t=e.currentTarget.value;se({row:r,text:t}),l({value:t})}}),(0,$.jsx)(u,{variant:`subtle`,color:`gray`,"aria-label":`Remove filter ${r+1}`,onClick:()=>a?x(void 0):s(),children:(0,$.jsx)(p,{size:14})})]},r)}),(0,$.jsx)(i,{children:(0,$.jsx)(l,{size:`compact-sm`,variant:`subtle`,leftSection:(0,$.jsx)(de,{size:12}),disabled:b!==void 0,onClick:()=>x({at:_.length,condition:{field:`service`,op:`=`,value:``,quoted:!0}}),children:`Add filter`})})]}),(0,$.jsxs)(i,{gap:`md`,align:`flex-end`,children:[(0,$.jsxs)(a,{gap:6,children:[(0,$.jsx)(c,{size:`sm`,fw:500,children:`Group by`}),(0,$.jsxs)(i,{gap:`xs`,children:[y.map((e,t)=>(0,$.jsx)(Jn,{text:e,onRemove:()=>S({by:C(y,t)})},e)),(0,$.jsx)(h,{"aria-label":`Add group by field`,placeholder:`Add field`,w:220,searchable:!0,value:null,data:te.filter(e=>!y.includes(e)),onChange:e=>e&&S({by:[...y,e]})})]})]}),(0,$.jsx)(h,{label:`Every`,w:170,clearable:!0,placeholder:`No time buckets`,value:e.bucket??null,data:e.bucket&&!ne.includes(e.bucket)?[...ne,e.bucket]:ne,onChange:e=>S({bucket:e??void 0})}),(0,$.jsx)(ie,{label:`Limit`,w:120,min:1,max:1e3,value:e.limit??``,onChange:e=>S({limit:typeof e==`number`?e:void 0})})]})]})}function Xn(e,t,n,r){let i=e===`count_distinct`?t:t.filter(e=>n.has(e));return[...new Set([...r.filter(e=>!t.includes(e)),...i])]}var Zn=`explore`,Qn=420,$n={stat:`Stat`,gauge:`Gauge`,timeseries:`Time series`,bar:`Bar`,table:`Table`,text:`Text`,heatmap:`Heatmap`,histogram:`Histogram`,scatter:`Scatter`,state_timeline:`State timeline`,logs:`Logs`,log_patterns:`Log patterns`,traces:`Traces`,service_map:`Service map`,health:`Health`},er={min_max:`a minimum and maximum`,thresholds:`thresholds`},tr=e=>e===`sql`?`sql`:`query`,nr={from:`spans`,measures:[`count()`],by:[`service`]};function rr(e,t){if(e.from===`logs`)return`logs`;if(e.from===`spans`&&t!==`health`&&t!==`service_map`)return`traces`}function ir(e,t){let n=(e,t)=>(e??[]).flatMap((e,n)=>n0||e.result.frame?.totals!==void 0)}function or({search:e,onSearch:t,onSaved:n,context:r}){let u=r?.spec.variables,f=r?.panel,p=e=>e.requires.every(e=>e===`min_max`?f?.min!==void 0&&f?.max!==void 0:(f?.thresholds?.length??0)>0),h=e=>r?.compose?r.compose(e):e,ie=r?.vars??{},[de,fe]=(0,P.useState)(),[S,pe]=(0,P.useState)(),[me,C]=(0,P.useState)(!1),[w,he]=(0,P.useState)(),[T,ge]=(0,P.useState)(e.q),[E,_e]=(0,P.useState)(e.sql??``),D=(0,P.useRef)({text:e.q,sql:e.sql??``}),ve=T!==D.current.text||E!==D.current.sql,ye=r?.onDirtyChange;(0,P.useEffect)(()=>{ye?.(ve)},[ve,ye]);let be=(0,P.useRef)(null),[O,xe]=(0,P.useState)(),[k,Ce]=(0,P.useState)(r?.initial?.query),[A,Te]=(0,P.useState)(r?.initial?.formatted),[Ee,De]=(0,P.useState)([]),[Oe,ke]=(0,P.useState)(()=>r?.initial?ir(r.initial.query,r.initial.formatted):{}),[je,Me]=(0,P.useState)(!1),j=(0,P.useRef)({}),[M,N]=(0,P.useState)([]),[Le,Re]=(0,P.useState)([]),[ze,Be]=(0,P.useState)(),[Ve,He]=(0,P.useState)(0),[F,Ue]=(0,P.useState)(),[We,Ge]=(0,P.useState)(),[I,Ke]=(0,P.useState)(!1),qe=(0,P.useRef)(void 0),Je=(0,P.useRef)(null),L=(0,P.useId)(),R=le(e),Ye=R.from&&R.to?void 0:R.range,z=(0,P.useRef)(e);z.current=e;let B=(0,P.useRef)({q:e.q,sql:e.sql??``,viz:e.viz}),Xe=e=>{let n=z.current;B.current={q:e.q,sql:e.sql??``,viz:e.viz},t(e,e.q===n.q&&e.sql===n.sql&&(n.viz===void 0||e.viz===n.viz))},V=e=>`${e.range}|${e.from??``}|${e.to??``}`,H=V(e),Ze=(0,P.useRef)(void 0),Qe=e=>{let n=V(ce(se(e)));n!==H&&(Ze.current=n),t(e)},$e=(0,P.useRef)(void 0),U=(0,P.useRef)({text:T,sql:E});U.current={text:T,sql:E};let W=oe({queryKey:[`telemetry-schema`],queryFn:({signal:e})=>b(e),staleTime:6e4,retry:!1,enabled:e.tab!==`query`});(0,P.useEffect)(()=>()=>{qe.current?.abort(),j.current.abort?.abort(),clearTimeout(j.current.timer),$e.current=void 0},[]);let G=async(e,t,n,i)=>{if(!t.trim())return;qe.current?.abort();let a=new AbortController;qe.current=a,Ke(!0),Be(void 0),N([]),Re([]),Ge(void 0);try{let o,s;if(e===`query`&&i)xe(void 0),o=h({id:Zn,title:Ne(t),viz:n??`table`,query:i,drill:rr(i,n??`table`)}),s=t,Xe({...z.current,q:t,viz:o.viz});else if(e===`query`){let e=await Pe({text:t,variables:u,window:Ye},a.signal);if(a.signal.aborted)return;xe({...e,text:t}),U.current.text===t&&Re(e.notices),z.current.tab===`builder`&&Ce(e.query);let r=n&&e.viz.compatible.some(e=>e.viz===n&&p(e))?n:e.viz.compatible.find(p)?.viz??`table`;o=h({id:Zn,title:Ne(e.canonical),viz:r,query:e.query,drill:rr(e.query,r)}),s=e.canonical,Xe({...z.current,q:t,viz:r,...t===z.current.q?{}:{drill:void 0}})}else o=h({id:Zn,title:`SQL`,viz:f?.viz??`table`,sql:t}),Xe({...z.current,sql:t});let c={version:1,name:r?.spec.name??`Explore`,time:R,variables:u,panels:[o]},l=Je.current?.clientWidth||960,d=await re({dashboard:c,panels:[Zn],time:R,vars:ie,widths:{[Zn]:l}},a.signal);if(a.signal.aborted)return;let m=d.find(e=>e.id===Zn);if(!m)throw Error(`The query returned no result.`);if(m.status===`invalid`){Ge({kind:e,source:t,window:H}),U.current[e===`query`?`text`:`sql`]===t&&N(m.problems??[]);return}fe(Date.now()),Ue({kind:e,source:t,window:H,panel:o,result:_(m,[Zn]),canonical:s}),e===`sql`&&m.status===`error`&&!m.retryable&&U.current.sql===t&&N([{path:`sql`,message:m.error??`Query failed`}])}catch(n){if(a.signal.aborted)return;Ge({kind:e,source:t,window:H}),n instanceof ae&&n.problems.length>0?U.current[e===`query`?`text`:`sql`]===t&&N(n.problems):Be(n instanceof Error?n.message:`Request failed`)}finally{qe.current===a&&Ke(!1)}},et=(0,P.useRef)({kind:tr(e.tab),viz:F?.panel.viz??e.viz,direct:void 0});et.current={kind:tr(e.tab),viz:F?.panel.viz??e.viz,direct:A?.editable===!1?k:void 0};let K=(0,P.useRef)(()=>void 0),tt=()=>{clearTimeout(j.current.timer),j.current.timer=void 0,j.current.abort?.abort()},q=async(e,t=!0)=>{tt();let n=new AbortController;j.current.abort=n;try{let r=await we({query:e},n.signal);return n.signal.aborted?void 0:(Te(r),De([]),ke(t=>({...t,...ir(e,r)})),t&&(Re(r.notices),N([]),ge(r.text)),r)}catch(e){if(n.signal.aborted)return;De(e instanceof ae&&e.problems.length>0?e.problems:[{path:`query`,message:e instanceof Error?e.message:`The query could not be printed`}]);return}},nt=e=>{Ce(e),clearTimeout(j.current.timer),j.current.timer=setTimeout(()=>{j.current.timer=void 0,q(e)},250)},rt=async t=>{if(!k)return;let n=await q(k);n&&z.current.tab===`builder`&&G(`query`,n.text,t??F?.panel.viz??e.viz,n.editable?void 0:k)},it=async n=>{if(n!==`builder`){e.tab===`builder`&&k&&j.current.timer&&q(k),t({...e,tab:n});return}let r=()=>{z.current.tab!==n&&t({...z.current,tab:n})};if(A?.editable===!1&&k){r();return}if(O&&O.text===T){Ce(O.query),r(),q(O.query,!1);return}if(!T.trim()){Ce(nr),r(),q(nr,!1);return}try{let e=await Pe({text:T,variables:u,window:Ye});xe({...e,text:T}),Ce(e.query),r(),q(e.query,!1)}catch(e){e instanceof ae&&e.problems.length>0?N(e.problems):Be(e instanceof Error?e.message:`Request failed`)}};K.current=()=>{let{kind:e,viz:t,direct:n}=et.current;z.current.tab===`builder`&&k?rt(t):G(e,U.current[e===`query`?`text`:`sql`],t,n)},(0,P.useEffect)(()=>{let t={q:e.q,sql:e.sql??``,viz:e.viz},n=t.q===B.current.q&&t.sql===B.current.sql&&t.viz===B.current.viz,r=$e.current===void 0,i=$e.current!==H,a=Ze.current===H;if($e.current=H,Ze.current=void 0,n&&(r||i&&a)){K.current();return}if(n&&!i)return;B.current=t,tt(),Te(void 0),N([]),ge(t.q),_e(t.sql);let o=tr(e.tab);G(o,o===`query`?t.q:t.sql,t.viz)},[e.q,e.sql,e.viz,H]),(0,P.useEffect)(()=>{e.tab===`builder`&&it(`builder`)},[]);let J=tr(e.tab),Y=J===`query`?T:E,at=Ve>0&&!T.trim(),X=A?.editable===!1,ot=F!==void 0&&(F.kind!==J||F.source!==Y||F.window!==H),st=O?.viz.compatible??[],ct=r?.panel!==void 0,lt=f!==void 0&&!ve&&(e.viz??f.viz)===f.viz,ut=!ot&&!I&&ar(F,ct),Z=ut||lt,dt=We===void 0?!ot&&F?.result.status===`error`:We.kind===J&&We.source===Y&&We.window===H,ft=I?`Wait for the run to finish`:dt?`The last run failed; saving needs a run that works`:ot?`Run the query as it is now first`:ct?`Run the query first`:`Run a query that returns rows first`,pt=(0,P.useId)(),mt=F!==void 0&&(F.panel.drill!==void 0||F.panel.viz===`service_map`||(F.result.frame?.columns.some(e=>e.name===`trace_id`)??!1));return(0,$.jsxs)(a,{gap:`md`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,maw:1600,mx:`auto`,"data-explore":!0,children:[!r&&(0,$.jsx)(s,{title:`Explore`,description:`Ask a question of your telemetry.`,meta:(0,$.jsx)(x,{time:R,updatedAt:F?de:null})}),(0,$.jsx)(v,{inHeader:!r,time:R,onRange:t=>Qe({...e,range:t,from:void 0,to:void 0}),onAbsolute:(t,n)=>Qe({...e,from:t,to:n})}),(0,$.jsxs)(g,{value:e.tab,onChange:e=>void it(e===`sql`||e===`builder`?e:`query`),keepMounted:!1,children:[(0,$.jsxs)(g.List,{children:[(0,$.jsx)(g.Tab,{value:`query`,children:`Query`}),(0,$.jsx)(g.Tab,{value:`builder`,children:`Builder`}),(0,$.jsx)(g.Tab,{value:`sql`,children:`SQL`})]}),(0,$.jsx)(g.Panel,{value:`query`,pt:`sm`,children:(0,$.jsxs)(a,{gap:`xs`,children:[(0,$.jsxs)(c,{id:L,size:`xs`,c:`dimmed`,children:[`Press Enter to run. For example `,(0,$.jsx)(`code`,{children:`spans | p95(duration) by service every 5m`}),`.`]}),X&&(0,$.jsxs)(c,{size:`xs`,c:`dimmed`,"data-pitotql-readonly":!0,children:[`This query is edited in the Builder: `,A?.reason??`it is too large for the text editor`,`.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Fe,{value:T,readOnly:X,placeholder:`spans | count() by service`,onChange:(e,t)=>{tt(),ge(e),N(t?.problems??[]),Re(t?.notices??[]),Te(void 0)},onRun:()=>{T.trim()||He(e=>e+1),G(`query`,T,e.viz,X?k:void 0)},problems:M,notices:Le,describedBy:L,complete:(e,t,n)=>Ae({text:e,cursor:t,...R.from&&R.to?{from:R.from,to:R.to}:{window:R.range}},n)}),(0,$.jsx)(c,{size:`xs`,c:`dimmed`,mt:at?4:0,"aria-live":`polite`,"data-pitotql-empty":!0,children:at&&(0,$.jsxs)(`span`,{children:[`Type a query to run, for example `,(0,$.jsx)(`code`,{children:`spans | count() by service`}),`.`]},Ve)})]})]})}),(0,$.jsx)(g.Panel,{value:`builder`,pt:`sm`,children:(0,$.jsxs)(a,{gap:`xs`,children:[!k&&(M.length>0||ze)?(0,$.jsx)(o,{"data-builder-blocked":!0,children:(0,$.jsxs)(d,{tone:`danger`,title:`This query cannot open in the Builder`,children:[M.length>0?(0,$.jsx)(a,{gap:2,mb:`xs`,children:M.map((e,t)=>(0,$.jsxs)(c,{size:`sm`,children:[e.message,e.hint?` (${e.hint})`:``]},t))}):(0,$.jsx)(c,{size:`sm`,mb:`xs`,children:ze}),(0,$.jsx)(l,{size:`compact-sm`,variant:`default`,onClick:()=>void it(`query`),children:`Fix it in the Query tab`})]})}):(0,$.jsxs)($.Fragment,{children:[W.error&&(0,$.jsxs)(d,{tone:`warning`,title:`Fields could not be loaded`,children:[k?`Only the fields this query uses are offered until the field list loads. `:``,W.error.message,(0,$.jsx)(l,{size:`compact-xs`,variant:`default`,ml:`xs`,loading:W.isFetching,onClick:()=>void W.refetch(),children:`Retry`})]}),k&&(W.data??W.error)?(0,$.jsx)(Yn,{query:k,schema:W.data??Kn(k),variables:(u??[]).map(e=>e.name),labels:Oe,onChange:nt,onInvalid:Me}):!W.error&&(0,$.jsx)(c,{size:`sm`,c:`dimmed`,children:`Loading fields…`})]}),Ee.length>0&&(0,$.jsx)(a,{gap:2,role:`alert`,"data-builder-problems":!0,children:Ee.map((e,t)=>(0,$.jsxs)(c,{size:`sm`,c:`bad`,children:[e.message,e.hint?` (${e.hint})`:``]},t))}),A&&Ee.length===0&&(0,$.jsxs)(c,{size:`xs`,c:`dimmed`,"data-builder-text":!0,children:[`As PitotQL: `,(0,$.jsx)(`code`,{children:A.text})]})]})}),(0,$.jsxs)(g.Panel,{value:`sql`,pt:`sm`,children:[!E.trim()&&(0,$.jsxs)(c,{size:`xs`,c:`dimmed`,mb:`xs`,"data-sql-hint":!0,children:[T.trim()?`SQL runs on its own; the PitotQL query is not converted. `:``,`Write one SELECT over spans, logs or metrics that filters time with `,(0,$.jsx)(`code`,{children:`$__window(time_column)`}),`, for example `,(0,$.jsx)(`code`,{children:`SELECT service, count(*) AS spans FROM spans WHERE $__window(start_time) GROUP BY service`}),`.`]}),(0,$.jsx)(Cn,{value:E,onChange:e=>{_e(e),N([])},onRun:()=>void G(`sql`,E),onEscape:()=>be.current?.focus(),schema:W.data,problems:e.tab===`sql`?M:[],label:r?`Panel SQL`:`Explore SQL`}),e.tab===`sql`&&M.length>0&&(0,$.jsx)(d,{tone:`danger`,title:`The SQL has problems`,children:(0,$.jsx)(`ul`,{children:M.map((e,t)=>(0,$.jsxs)(`li`,{className:`sql-problem`,children:[e.message,e.hint?` (${e.hint})`:``]},t))})})]})]}),(0,$.jsxs)(i,{justify:`space-between`,children:[(0,$.jsxs)(i,{gap:`xs`,children:[(0,$.jsx)(l,{ref:be,loading:I,disabled:e.tab===`builder`?!k||Ee.length>0||je:!Y.trim(),onClick:()=>void(e.tab===`builder`?rt(e.viz):G(J,Y,e.viz,X?k:void 0)),children:`Run`}),J===`query`&&st.length>0&&(0,$.jsx)(te,{size:`xs`,"aria-label":`Visualization`,value:F?.panel.viz??e.viz??``,onChange:t=>void(e.tab===`builder`?rt(t):G(`query`,T,t,X?k:void 0)),data:st.map(e=>({value:e.viz,disabled:!p(e),label:p(e)?$n[e.viz]:(0,$.jsx)(ue,{label:`Needs ${e.requires.map(e=>er[e]).join(` and `)}; set them after saving`,children:(0,$.jsx)(`span`,{children:$n[e.viz]})})}))}),J===`query`&&!ot&&!X&&O?.viz.edits.map(e=>(0,$.jsx)(ue,{label:(0,$.jsxs)($.Fragment,{children:[`Rewrites the query as `,(0,$.jsx)(`code`,{children:e.text})]}),multiline:!0,maw:420,children:(0,$.jsxs)(l,{size:`compact-sm`,variant:`subtle`,onClick:()=>{ge(e.text),G(`query`,e.text,e.viz)},children:[$n[e.viz],`…`]})},e.viz))]}),(0,$.jsxs)(i,{gap:`xs`,children:[r?.cancel&&(0,$.jsx)(l,{variant:`default`,disabled:me,onClick:r.cancel,children:`Cancel`}),(0,$.jsx)(ue,{label:ft,disabled:Z,events:{hover:!0,focus:!0,touch:!0},children:r?(0,$.jsx)(l,{"data-disabled":!Z||void 0,"aria-disabled":!Z,"aria-describedby":Z?void 0:pt,loading:me,onClick:()=>{let e=ut?F?.panel:f;e&&Z&&(C(!0),pe(void 0),r.save.run(e).catch(e=>pe(e instanceof Error?e.message:`Save failed`)).finally(()=>C(!1)))},children:r.save.label}):(0,$.jsx)(l,{variant:`default`,"data-disabled":!Z||void 0,"aria-disabled":!Z,"aria-describedby":Z?void 0:pt,onClick:()=>F&&Z&&he(F.panel),children:`Save to dashboard`})}),!Z&&(0,$.jsx)(`span`,{id:pt,hidden:!0,children:ft})]})]}),ze&&(0,$.jsx)(d,{tone:`danger`,title:`The query could not run`,children:ze}),S&&(0,$.jsx)(d,{tone:`danger`,title:`Not saved`,children:S}),(0,$.jsx)(o,{ref:Je,children:F?(0,$.jsxs)(a,{gap:`xs`,children:[(0,$.jsx)(c,{size:`sm`,fw:600,role:`status`,children:I?`Running the query…`:F.kind===J?F.source===Y?F.window===H?F.canonical?(0,$.jsxs)($.Fragment,{children:[`Ran as `,(0,$.jsx)(`code`,{children:F.canonical})]}):`Result`:`Result of the last run · time range has changed`:`Result of the last run · query has changed`:`Result of the last ${F.kind===`sql`?`SQL`:`PitotQL`} run`}),(0,$.jsx)(o,{h:Qn,children:(0,$.jsx)(m,{panel:F.panel,title:F.panel.title,result:F.result,loading:I,height:Qn,group:`explore`,editing:!1,agentAvailable:!1,range:R.range,onRetry:()=>void G(F.kind,F.source,F.panel.viz,X?k:void 0),traceLinks:`button`,onPoint:mt?n=>{let r=ee(F.panel,F.result,n,ie);r&&t({...e,drill:JSON.stringify(r.target)})}:void 0})})]}):I?(0,$.jsx)(c,{c:`dimmed`,size:`sm`,role:`status`,"data-explore-running":!0,children:`Running the query…`}):(0,$.jsx)(c,{c:`dimmed`,size:`sm`,"data-explore-empty":!0,children:e.tab===`builder`?`Build a query above and press Run.`:e.tab===`sql`?`Write a query above and press Run.`:`Type a query above and press Enter.`})}),F&&(0,$.jsx)(y,{client:Se,spec:{version:1,name:r?.spec.name??`Explore`,time:R,variables:u,panels:[F.panel]},time:R,vars:ie,target:ne(e.drill),onChange:n=>t({...e,drill:n?JSON.stringify(n):void 0})}),w&&n&&(0,$.jsx)(Ie,{panel:w,time:R,onClose:()=>he(void 0),onSaved:n})]})}export{or as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/panel-editor-BVRFoShZ.js b/internal/ui/dist/assets/panel-editor-DrACmBUu.js similarity index 93% rename from internal/ui/dist/assets/panel-editor-BVRFoShZ.js rename to internal/ui/dist/assets/panel-editor-DrACmBUu.js index 65fea574b..b2f1404db 100644 --- a/internal/ui/dist/assets/panel-editor-BVRFoShZ.js +++ b/internal/ui/dist/assets/panel-editor-DrACmBUu.js @@ -1 +1 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,Tt as i,a,j as o,k as s,s as c,w as l}from"./brand-D6fP-cLS.js";import{T as u,h as d,p as f,x as p}from"./search-D_K9J6yO.js";import"./page-BABqeqdg.js";import{s as m}from"./auth-DWqIkMZS.js";import{T as h,t as g}from"./useQuery-BLTYSIvG.js";import{a as _,r as v}from"./save-dialog-Chbkq2Xp.js";import{t as y}from"./page-1Rod7OFH.js";import{t as ee}from"./discard-NZfxCIcK.js";var b=n(e(),1),x=t();function S(e,t,n){let r=e.from&&e.to?{range:`1h`,from:e.from,to:e.to}:{range:t?.time?.range??e.range??`1h`};return t?.sql===void 0?!t||!n?{q:``,tab:`query`,...r}:{q:n.text,viz:t.viz,tab:n.editable?`query`:`builder`,...r}:{q:``,sql:t.sql,viz:t.viz,tab:`sql`,...r}}var C=(e,t)=>JSON.stringify(e??null)===JSON.stringify(t??null),w={gauge:`stat`,state_timeline:`timeseries`};function T(e,t){let{query:n,sql:r,viz:i,reduce:a,options:o,drill:s,click:c,unit:l,thresholds:u,better:d,min:f,max:p,...m}=e,h={...m,id:t.id,title:t.title,viz:t.viz,...t.sql===void 0?{query:t.query}:{sql:t.sql}},g=t.sql!==void 0||C(t.query?.measures,n?.measures),_=t.sql===void 0?g&&C(t.query?.by,n?.by):t.sql===r;g?Object.assign(h,{unit:l,thresholds:u,better:d,min:f,max:p}):h.viz in w&&(h.viz=w[h.viz]);let v=h.viz===i;return v&&a&&(h.reduce=a),v&&_&&o&&(h.options=o),s&&t.query&&t.query.from===n?.from&&(h.drill=s),c&&t.query&&C(t.query.by,n?.by)&&(h.click=c),h}function E(e,t){let n={};for(let r of new Set([...Object.keys(e),...Object.keys(t)])){if(r===`id`||r===`grid`)continue;let i=e[r],a=t[r];C(i,a)||(n[r]=a??null)}return n}var D=e=>e===void 0?`not set`:e===`$__all`?`All`:Array.isArray(e)?e.join(`, `):e;function O({dashboardId:e,version:t,spec:n,layoutChanged:C=!1,time:w,vars:O,panel:k,onClose:A}){let j=h(),[M,N]=(0,b.useState)(),{version:P,spec:F,panel:I}=M??{version:t,spec:n,panel:k},[L,R]=(0,b.useState)(),z=(0,b.useRef)(null);(0,b.useEffect)(()=>{L===`stale`&&z.current?.focus()},[L]);let B=g({queryKey:[`panel-editor-format`,e,k?.id,t],queryFn:({signal:e})=>_({query:k.query,viz:k.viz},e),enabled:!!k?.query,staleTime:1/0,retry:!1}),V=!k?.query||B.isSuccess,[H,U]=(0,b.useState)(),W=H??(V?S(w,k,B.data):void 0),[G,K]=(0,b.useState)(k?.title??``),[q,J]=(0,b.useState)(!1),Y=q||G.trim()!==(k?.title??``)||k!==void 0&&W?.viz!==void 0&&W.viz!==k.viz,X=ee(Y,A,`this panel`),Z=(0,b.useRef)(!1),Q=async()=>{R(`loading`);try{let t=await d(e);j.setQueryData([`dashboard`,e],t),Z.current=!0,N({version:t.version,spec:t.spec,panel:k&&t.spec.panels.find(e=>e.id===k.id)}),R(void 0)}catch(e){R(e instanceof Error?e.message:`The latest version could not be loaded.`)}},te=async t=>{let n=G.trim()||t.title,r=I?void 0:{...t,title:n,id:v(`panel`,F.panels.map(e=>e.id))},i=I?`Edited ${n}`:`Added ${n}`,a=C&&!Z.current;try{let o=a?await u(e,{...F,panels:r?[...F.panels,r]:F.panels.map(e=>e.id===I.id?{...t,id:e.id,title:n,grid:e.grid}:e)},P,`${i} and saved layout`):await p(e,[r?{op:`add_panel`,panel:r}:{op:`update_panel`,id:I.id,set:E(I,{...t,id:I.id,title:n})}],P,i);await j.cancelQueries({queryKey:[`dashboard`,e],exact:!0}),j.setQueryData([`dashboard`,e],o),j.invalidateQueries({queryKey:f}),j.invalidateQueries({queryKey:[`dashboard-versions`,e]}),A()}catch(e){if(e instanceof m&&e.code===`dashboard_version_conflict`){R(`stale`);return}throw e instanceof m&&e.problems.length>0?Error(e.problems.map(e=>e.message).join(` `)):e}},$=F.variables??[];return(0,x.jsxs)(r,{opened:!0,onClose:X.request,closeOnEscape:!1,title:k?`Edit panel · ${k.title}`:`Add panel`,size:`min(1280px, 100vw - 32px)`,onKeyDown:X.onKeyDown,children:[X.prompt,L&&(0,x.jsx)(i,{mb:`sm`,children:(0,x.jsxs)(c,{tone:L===`stale`||L===`loading`?`warning`:`danger`,title:`Someone saved this dashboard since you opened it`,children:[(0,x.jsx)(o,{size:`sm`,children:L===`stale`||L===`loading`?`Load the latest version, then save again. Your draft stays as it is.`:L}),(0,x.jsx)(s,{ref:z,mt:`sm`,size:`compact-sm`,loading:L===`loading`,onClick:()=>void Q(),children:`Load latest`})]})}),(0,x.jsx)(l,{label:`Panel title`,px:`lg`,value:G,onChange:e=>K(e.currentTarget.value),placeholder:k?void 0:`Named after the query`}),$.length>0&&(0,x.jsxs)(o,{size:`xs`,c:`dimmed`,px:`lg`,pt:`xs`,"data-editor-variables":!0,children:[`Runs with the dashboard's variables: `,$.map((e,t)=>(0,x.jsxs)(`span`,{children:[t>0&&` · `,(0,x.jsxs)(`code`,{children:[`$`,e.name]}),` = `,D(O[e.name])]},e.name))]}),B.error?(0,x.jsx)(i,{children:(0,x.jsx)(c,{tone:`danger`,title:`This panel's query could not be opened`,children:B.error.message})}):W?(0,x.jsx)(y,{search:W,onSearch:U,context:{spec:F,vars:O,panel:I,compose:I?e=>T(I,e):void 0,onDirtyChange:J,cancel:X.request,save:{label:k?`Save panel`:`Add panel`,run:te},initial:k?.query&&B.data&&!B.data.editable?{query:k.query,formatted:B.data}:void 0}}):(0,x.jsx)(a,{state:`loading`,loadingLabel:`Loading the panel's query`,rows:3})]})}export{O as default}; \ No newline at end of file +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,Tt as i,a,j as o,k as s,s as c,w as l}from"./brand-D6fP-cLS.js";import{T as u,h as d,p as f,x as p}from"./search-P7VEnlsD.js";import"./page-DQgl1M0H.js";import{s as m}from"./auth-DcVParCH.js";import{T as h,t as g}from"./useQuery-BLTYSIvG.js";import{a as _,r as v}from"./save-dialog-DpwJ9nWF.js";import{t as y}from"./page-DSor7wHc.js";import{t as ee}from"./discard-NZfxCIcK.js";var b=n(e(),1),x=t();function S(e,t,n){let r=e.from&&e.to?{range:`1h`,from:e.from,to:e.to}:{range:t?.time?.range??e.range??`1h`};return t?.sql===void 0?!t||!n?{q:``,tab:`query`,...r}:{q:n.text,viz:t.viz,tab:n.editable?`query`:`builder`,...r}:{q:``,sql:t.sql,viz:t.viz,tab:`sql`,...r}}var C=(e,t)=>JSON.stringify(e??null)===JSON.stringify(t??null),w={gauge:`stat`,state_timeline:`timeseries`};function T(e,t){let{query:n,sql:r,viz:i,reduce:a,options:o,drill:s,click:c,unit:l,thresholds:u,better:d,min:f,max:p,...m}=e,h={...m,id:t.id,title:t.title,viz:t.viz,...t.sql===void 0?{query:t.query}:{sql:t.sql}},g=t.sql!==void 0||C(t.query?.measures,n?.measures),_=t.sql===void 0?g&&C(t.query?.by,n?.by):t.sql===r;g?Object.assign(h,{unit:l,thresholds:u,better:d,min:f,max:p}):h.viz in w&&(h.viz=w[h.viz]);let v=h.viz===i;return v&&a&&(h.reduce=a),v&&_&&o&&(h.options=o),s&&t.query&&t.query.from===n?.from&&(h.drill=s),c&&t.query&&C(t.query.by,n?.by)&&(h.click=c),h}function E(e,t){let n={};for(let r of new Set([...Object.keys(e),...Object.keys(t)])){if(r===`id`||r===`grid`)continue;let i=e[r],a=t[r];C(i,a)||(n[r]=a??null)}return n}var D=e=>e===void 0?`not set`:e===`$__all`?`All`:Array.isArray(e)?e.join(`, `):e;function O({dashboardId:e,version:t,spec:n,layoutChanged:C=!1,time:w,vars:O,panel:k,onClose:A}){let j=h(),[M,N]=(0,b.useState)(),{version:P,spec:F,panel:I}=M??{version:t,spec:n,panel:k},[L,R]=(0,b.useState)(),z=(0,b.useRef)(null);(0,b.useEffect)(()=>{L===`stale`&&z.current?.focus()},[L]);let B=g({queryKey:[`panel-editor-format`,e,k?.id,t],queryFn:({signal:e})=>_({query:k.query,viz:k.viz},e),enabled:!!k?.query,staleTime:1/0,retry:!1}),V=!k?.query||B.isSuccess,[H,U]=(0,b.useState)(),W=H??(V?S(w,k,B.data):void 0),[G,K]=(0,b.useState)(k?.title??``),[q,J]=(0,b.useState)(!1),Y=q||G.trim()!==(k?.title??``)||k!==void 0&&W?.viz!==void 0&&W.viz!==k.viz,X=ee(Y,A,`this panel`),Z=(0,b.useRef)(!1),Q=async()=>{R(`loading`);try{let t=await d(e);j.setQueryData([`dashboard`,e],t),Z.current=!0,N({version:t.version,spec:t.spec,panel:k&&t.spec.panels.find(e=>e.id===k.id)}),R(void 0)}catch(e){R(e instanceof Error?e.message:`The latest version could not be loaded.`)}},te=async t=>{let n=G.trim()||t.title,r=I?void 0:{...t,title:n,id:v(`panel`,F.panels.map(e=>e.id))},i=I?`Edited ${n}`:`Added ${n}`,a=C&&!Z.current;try{let o=a?await u(e,{...F,panels:r?[...F.panels,r]:F.panels.map(e=>e.id===I.id?{...t,id:e.id,title:n,grid:e.grid}:e)},P,`${i} and saved layout`):await p(e,[r?{op:`add_panel`,panel:r}:{op:`update_panel`,id:I.id,set:E(I,{...t,id:I.id,title:n})}],P,i);await j.cancelQueries({queryKey:[`dashboard`,e],exact:!0}),j.setQueryData([`dashboard`,e],o),j.invalidateQueries({queryKey:f}),j.invalidateQueries({queryKey:[`dashboard-versions`,e]}),A()}catch(e){if(e instanceof m&&e.code===`dashboard_version_conflict`){R(`stale`);return}throw e instanceof m&&e.problems.length>0?Error(e.problems.map(e=>e.message).join(` `)):e}},$=F.variables??[];return(0,x.jsxs)(r,{opened:!0,onClose:X.request,closeOnEscape:!1,title:k?`Edit panel · ${k.title}`:`Add panel`,size:`min(1280px, 100vw - 32px)`,onKeyDown:X.onKeyDown,children:[X.prompt,L&&(0,x.jsx)(i,{mb:`sm`,children:(0,x.jsxs)(c,{tone:L===`stale`||L===`loading`?`warning`:`danger`,title:`Someone saved this dashboard since you opened it`,children:[(0,x.jsx)(o,{size:`sm`,children:L===`stale`||L===`loading`?`Load the latest version, then save again. Your draft stays as it is.`:L}),(0,x.jsx)(s,{ref:z,mt:`sm`,size:`compact-sm`,loading:L===`loading`,onClick:()=>void Q(),children:`Load latest`})]})}),(0,x.jsx)(l,{label:`Panel title`,px:`lg`,value:G,onChange:e=>K(e.currentTarget.value),placeholder:k?void 0:`Named after the query`}),$.length>0&&(0,x.jsxs)(o,{size:`xs`,c:`dimmed`,px:`lg`,pt:`xs`,"data-editor-variables":!0,children:[`Runs with the dashboard's variables: `,$.map((e,t)=>(0,x.jsxs)(`span`,{children:[t>0&&` · `,(0,x.jsxs)(`code`,{children:[`$`,e.name]}),` = `,D(O[e.name])]},e.name))]}),B.error?(0,x.jsx)(i,{children:(0,x.jsx)(c,{tone:`danger`,title:`This panel's query could not be opened`,children:B.error.message})}):W?(0,x.jsx)(y,{search:W,onSearch:U,context:{spec:F,vars:O,panel:I,compose:I?e=>T(I,e):void 0,onDirtyChange:J,cancel:X.request,save:{label:k?`Save panel`:`Add panel`,run:te},initial:k?.query&&B.data&&!B.data.editable?{query:k.query,formatted:B.data}:void 0}}):(0,x.jsx)(a,{state:`loading`,loadingLabel:`Loading the panel's query`,rows:3})]})}export{O as default}; \ No newline at end of file diff --git a/internal/ui/dist/assets/save-dialog-Chbkq2Xp.js b/internal/ui/dist/assets/save-dialog-DpwJ9nWF.js similarity index 97% rename from internal/ui/dist/assets/save-dialog-Chbkq2Xp.js rename to internal/ui/dist/assets/save-dialog-DpwJ9nWF.js index ca6c5a620..4b0eb054e 100644 --- a/internal/ui/dist/assets/save-dialog-Chbkq2Xp.js +++ b/internal/ui/dist/assets/save-dialog-DpwJ9nWF.js @@ -1,4 +1,4 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,G as i,T as a,Tt as o,j as s,k as c,s as l,w as u}from"./brand-D6fP-cLS.js";import{g as d,h as f,i as p,p as m}from"./toolbar-DV46cPGs.js";import{C as h,E as g,_,f as v,h as y,p as ee,x as b,y as x}from"./search-D_K9J6yO.js";import{s as te}from"./auth-DWqIkMZS.js";import{T as ne,t as re}from"./useQuery-BLTYSIvG.js";var ie={exemplars:h,trace:_,span:p},S=n(e(),1),ae=[],oe=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t>1;if(e=oe[r])t=r+1;else return!0;if(t==n)return!1}}function ce(e){return e>=127462&&e<=127487}var le=8205;function ue(e,t,n=!0,r=!0){return(n?de:fe)(e,t,r)}function de(e,t,n){if(t==e.length)return t;t&&me(e.charCodeAt(t))&&he(e.charCodeAt(t-1))&&t--;let r=pe(e,t);for(t+=ge(r);t=0&&ce(pe(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function fe(e,t,n){for(;t>1;){let r=de(e,t-2,n);if(r=56320&&e<57344}function he(e){return e>=55296&&e<56320}function ge(e){return e<65536?1:2}var C=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Ee(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),ve.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ee(this,e,t);let n=[];return this.decompose(e,t,n,0),ve.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Se(this),i=new Se(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new Se(this,e)}iterRange(e,t=this.length){return new Ce(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new we(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new _e(t):ve.from(_e.split(t,[]))}},_e=class e extends C{constructor(e,t=ye(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Te(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(xe(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=be(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=Ee(this,t,n);let i=be(this.text,be(r.text,xe(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):ve.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=` +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,G as i,T as a,Tt as o,j as s,k as c,s as l,w as u}from"./brand-D6fP-cLS.js";import{g as d,h as f,i as p,p as m}from"./toolbar-CLcpDIVT.js";import{C as h,E as g,_,f as v,h as y,p as ee,x as b,y as x}from"./search-P7VEnlsD.js";import{s as te}from"./auth-DcVParCH.js";import{T as ne,t as re}from"./useQuery-BLTYSIvG.js";var ie={exemplars:h,trace:_,span:p},S=n(e(),1),ae=[],oe=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t>1;if(e=oe[r])t=r+1;else return!0;if(t==n)return!1}}function ce(e){return e>=127462&&e<=127487}var le=8205;function ue(e,t,n=!0,r=!0){return(n?de:fe)(e,t,r)}function de(e,t,n){if(t==e.length)return t;t&&me(e.charCodeAt(t))&&he(e.charCodeAt(t-1))&&t--;let r=pe(e,t);for(t+=ge(r);t=0&&ce(pe(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function fe(e,t,n){for(;t>1;){let r=de(e,t-2,n);if(r=56320&&e<57344}function he(e){return e>=55296&&e<56320}function ge(e){return e<65536?1:2}var C=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Ee(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),ve.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ee(this,e,t);let n=[];return this.decompose(e,t,n,0),ve.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Se(this),i=new Se(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new Se(this,e)}iterRange(e,t=this.length){return new Ce(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new we(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new _e(t):ve.from(_e.split(t,[]))}},_e=class e extends C{constructor(e,t=ye(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new Te(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(xe(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=be(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=Ee(this,t,n);let i=be(this.text,be(r.text,xe(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):ve.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=` `){[e,t]=Ee(this,e,t);let r=``;for(let i=0,a=0;i<=t&&ae&&a&&(r+=n),ei&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},ve=class e extends C{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=Ee(this,t,n),r.lines=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=` `){[e,t]=Ee(this,e,t);let r=``;for(let i=0,a=0;ie&&i&&(r+=n),ea&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new _e(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof _e&&c&&(n=u[u.length-1])instanceof _e&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new _e(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};C.empty=new _e([``],0);function ye(e){let t=-1;for(let n of e)t+=n.length+1;return t}function be(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a=n&&(c>r&&(s=s.slice(0,r-i)),i0?1:(e instanceof _e?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof _e?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(r instanceof _e){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof _e?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Ce=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new Se(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},we=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(C.prototype[Symbol.iterator]=function(){return this.iter()},Se.prototype[Symbol.iterator]=Ce.prototype[Symbol.iterator]=we.prototype[Symbol.iterator]=function(){return this});var Te=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function Ee(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function w(e,t,n=!0,r=!0){return ue(e,t,n,r)}function De(e){return e>=56320&&e<57344}function Oe(e){return e>=55296&&e<56320}function ke(e,t){let n=e.charCodeAt(t);if(!Oe(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return De(r)?(n-55296<<10)+(r-56320)+65536:n}function Ae(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function je(e){return e<65536?1:2}var Me=/\r\n?|\n/,T=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(T||={}),Ne=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return i+(e-r);i+=o}else{if(n!=T.Simple&&c>=e&&(n==T.TrackDel&&re||n==T.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&o>=e)return rt?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},Pe=class e extends Ne{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return Ie(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return Le(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length0&&Fe(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;os||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?C.of(l.split(r||Me)):l:C.empty,d=u.length;if(e==s&&d==0)return;eo&&E(i,e-o,-1),E(i,s-e,d),Fe(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;et&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Fe(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function Le(e,t,n,r=!1){let i=[],a=r?[]:null,o=new ze(e),s=new ze(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);E(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len=0&&e=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.lent||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var ze=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?C.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?C.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Be=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return D.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return D.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return D.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},D=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Be.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;ie.from-t.from),n=t.indexOf(r);for(let r=1;ri.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Ve(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var He=0,O=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=He++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Ue),!!t.static,t.enables)}of(e){return new We([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new We(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new We(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Ue(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var We=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=He++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Ke(e,c)){let r=t(e);if(a?!Ge(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=at(o,c);if(this.dependencies.every(t=>t instanceof O?o.facet(t)===e.facet(t):t instanceof Ye?o.field(t,!1)==e.field(t,!1):!0)||(a?Ge(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function Ge(e,t,n){if(e.length!=t.length)return!1;for(let r=0;re[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;te===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Je).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Je),i=n.facet(Je),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Je.of({field:this,create:e})]}get extension(){return this}},Xe={lowest:4,low:3,default:2,high:1,highest:0};function Ze(e){return t=>new $e(t,e)}var Qe={highest:Ze(Xe.highest),high:Ze(Xe.high),default:Ze(Xe.default),low:Ze(Xe.low),lowest:Ze(Xe.lowest)},$e=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},et=class e{of(e){return new tt(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},tt=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},nt=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of rt(t,n,o))e instanceof Ye?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,Ue(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>qe(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function rt(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof tt&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof tt){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof $e)a(e.inner,e.prec);else if(e instanceof Ye)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof We)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Xe.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Xe.default),r.reduce((e,t)=>e.concat(t))}function it(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function at(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var ot=O.define(),st=O.define({combine:e=>e.some(e=>e),static:!0}),ct=O.define({combine:e=>e.length?e[0]:void 0,static:!0}),lt=O.define(),ut=O.define(),dt=O.define(),ft=O.define({combine:e=>e.length?e[0]:!1}),pt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new mt}},mt=class{of(e){return new pt(this,e)}},ht=class{constructor(e){this.map=e}of(e){return new k(this,e)}},k=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new ht(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};k.reconfigure=k.define(),k.appendConfig=k.define();var A=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Ve(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};A.time=pt.define(),A.userEvent=pt.define(),A.addToHistory=pt.define(),A.remote=pt.define();function gt(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r=e[r]))a=e[r++],o=e[r++];else if(i=0;n--){let i=r[n](e);e=i instanceof A?i:Array.isArray(i)&&i.length==1&&i[0]instanceof A?i[0]:yt(t,Ct(i),!1)}return e}function xt(e){let t=e.startState,n=t.facet(dt),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=_t(r,vt(t,a,e.changes.newLength),!0))}return r==e?e:A.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var St=[];function Ct(e){return e==null?St:Array.isArray(e)?e:[e]}var wt=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(wt||={}),Tt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Et;try{Et=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function Dt(e){if(Et)return Et.test(e);for(let t=0;t`€`&&(n.toUpperCase()!=n.toLowerCase()||Tt.test(n)))return!0}return!1}function Ot(e){return t=>{if(!/\S/.test(t))return wt.Space;if(Dt(t))return wt.Word;for(let n=0;n-1)return wt.Word;return wt.Other}}var j=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;ei.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(k.reconfigure)?(n=null,r=e.value):e.is(k.appendConfig)&&(n=null,r=Ct(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=nt.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(st)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:D.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=Ct(n.effects);for(let n=1;nn.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:D.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=nt.resolve(t.extensions||[],new Map),r=t.doc instanceof C?t.doc:C.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||Me)),i=t.selection?t.selection instanceof D?t.selection:D.single(t.selection.anchor,t.selection.head):D.single(0);return Ve(i,r.length),n.staticFacet(st)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||` @@ -7,4 +7,4 @@ import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{D as r,G as i,T `;this.styleTag.textContent=e}let e=t.head||t;this.styleTag.parentNode!=e&&e.insertBefore(this.styleTag,e.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},rn={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},an={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},on=typeof navigator<`u`&&/Mac/.test(navigator.platform),sn=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),N=0;N<10;N++)rn[48+N]=rn[96+N]=String(N);for(var N=1;N<=24;N++)rn[N+111]=`F`+N;for(var N=65;N<=90;N++)rn[N]=String.fromCharCode(N+32),an[N]=String.fromCharCode(N);for(var cn in rn)an.hasOwnProperty(cn)||(an[cn]=rn[cn]);function ln(e){var t=!(on&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||sn&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?an:rn)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function un(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t2),F={mac:xn||/Mac/.test(P.platform),windows:/Win/.test(P.platform),linux:/Linux|X11/.test(P.platform),ie:gn,ie_version:mn?fn.documentMode||6:hn?+hn[1]:pn?+pn[1]:0,gecko:_n,gecko_version:_n?+(/Firefox\/(\d+)/.exec(P.userAgent)||[0,0])[1]:0,chrome:!!vn,chrome_version:vn?+vn[1]:0,ios:xn,android:/Android\b/.test(P.userAgent),webkit:yn,webkit_version:yn?+(/\bAppleWebKit\/(\d+)/.exec(P.userAgent)||[0,0])[1]:0,safari:bn,safari_version:bn?+(/\bVersion\/(\d+(\.\d+)?)/.exec(P.userAgent)||[0,0])[1]:0,tabSize:fn.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function Sn(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var Cn=Object.create(null);function wn(e,t,n){if(e==t)return!0;e||=Cn,t||=Cn;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function Tn(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function En(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function Dn(e){let t=Object.create(null);for(let n=0;n0?3e8:-4e8:t>0?1e8:-1e8,new jn(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=Mn(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new jn(e,n,r,t,e.widget||null,!0)}static line(e){return new An(e)}static set(e,t=!1){return M.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};L.none=M.empty;var kn=class e extends L{constructor(e){let{start:t,end:n}=Mn(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?Sn(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Cn}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&wn(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};kn.prototype.point=!1;var An=class e extends L{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&wn(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};An.prototype.mapMode=T.TrackBefore,An.prototype.point=!0;var jn=class e extends L{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?T.TrackBefore:T.TrackAfter:T.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?I.WidgetBefore:I.WidgetAfter:I.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&Nn(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};jn.prototype.point=!0;function Mn(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function Nn(e,t){return e==t||!!(e&&t&&e.compare(t))}function Pn(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var Fn=class e extends At{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&wn(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||Cn,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return M.of(e,t)}};Fn.prototype.startSide=Fn.prototype.endSide=-1;function In(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Ln(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function Rn(e,t){if(!t.anchorNode)return!1;try{return Ln(e,t.anchorNode)}catch{return!1}}function zn(e){return e.nodeType==3?nr(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function Bn(e,t,n,r){return n?Un(e,t,n,r,-1)||Un(e,t,n,r,1):!1}function Vn(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function Hn(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Un(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Wn(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=Vn(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?Wn(e):0}else return!1}}function Wn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Gn(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function Kn(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function qn(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function Jn(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=Kn(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=qn(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.lefte.bottom||t.lefte.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Yn(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var Xn=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Wn(t):0),n,Math.min(e.focusOffset,n?Wn(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function Zn(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function Qn(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}var $n=null;F.safari&&F.safari_version>=26&&($n=!1);function er(e){if(e.setActive)return e.setActive();if($n)return e.focus($n);let t=Zn(e);e.focus($n==null?{get preventScroll(){return $n={preventScroll:!0},!0}}:void 0),$n||($n=!1,Qn(t))}var tr;function nr(e,t,n=t){let r=tr||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function rr(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function ir(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function ar(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,Wn(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=Wn(n))}else if(n==e)return!0;else r=Vn(n),n=n.parentNode}function or(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function sr(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=Wn(n)}else if(n.parentNode&&!Hn(n))r=Vn(n),n=n.parentNode;else return null}function cr(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.fromt))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function br(e,t){if(e.length!=t.length)return!1;for(let n=0;n=0;e-=3)if(gr[e+1]==-r){let n=gr[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(z[t]=z[gr[e]]=r),s=e;break}}else if(gr.length==189)break;else gr[s++]=t,gr[s++]=n,gr[s++]=c}else if((o=z[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=gr[t+2];if(n&2)break;if(e)gr[t+2]|=2;else{if(n&4)break;gr[t+2]|=4}}}}}function Cr(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=ic;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),z[--t]=u;c=o}else a=o,c++}}}function wr(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;cc&&o.push(new yr(c,m.from,f)),Tr(e,m.direction==ur==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?z[p]!=s:z[p]==s))break;else p++;d?wr(e,c,p,r+1,i,d,o):ct;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=z[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(z[e-1]==s)break run;else break}d?d.push(m):(m.toz.length;)z[z.length]=256;let r=[],i=t==ur?0:1;return Tr(e,i,i,n,0,e.length,r),r}function Dr(e){return[new yr(0,e,0)]}var Or=``;function kr(e,t,n,r,i){if(!e.length)return null;let a=r.head-e.from,o;if(r.head==e.from&&r.assoc<0){if(!i)return null;a=t[o=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(i)return null;a=t[o=t.length-1].side(!0,n)}else o=yr.find(t,a,r.bidiLevel??-1,r.assoc);let s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=w(e.text,a,s.forward(i,n));(ls.to)&&(l=c),Or=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];if(l==c){if(!u)return i?D.cursor(e.to,1):D.cursor(e.from,-1);if(u.level+ +!ie.some(e=>e)}),Vr=O.define({combine:e=>e.some(e=>e)}),Hr=O.define(),Ur=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(D.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Wr=k.define({map:(e,t)=>e.map(t)}),Gr=k.define();function B(e,t,n){let r=e.facet(Pr);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var Kr=O.define({combine:e=>!e.length||e[0]}),qr=0,Jr=O.define({combine(e){return e.filter((t,n)=>{for(let r=0;r{let t=[];return o&&t.push($r.of(t=>{let n=t.plugin(e);return n?o(n):L.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},Xr=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){B(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(B(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){B(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},Zr=O.define(),Qr=O.define(),$r=O.define(),ei=O.define(),ti=O.define(),ni=O.define(),ri=O.define();function ii(e,t){let n=e.state.facet(ri);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return M.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=Ar(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var ai=O.define();function oi(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(ai)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var si=O.define(),ci=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAr.push(new ci(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},ui=[],V=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return ui}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&Tn(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=Vn(this.dom),r=this.length?e>0:t>0;return new lr(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof pi)return e;return null}static get(e){return e.cmTile}},di=class extends V{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=fi(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=fi(r);this.length=a}};function fi(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var pi=class extends di{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=V.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof mi)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(se||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},mi=class e extends di{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},hi=class e extends di{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0&&!(a.flags&32)||n&&_i(a,d)))&&(f>c||d.flags&32&&t<=1)?(a=d,o=c-u):(u=-1)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):gi(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new lr(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new lr(e.dom,0);e==n.tile&&(a=!0)}}return new lr(this.dom,0)}};function gi(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=zn(t);return n[n.length-1]||null}function _i(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.topr&&(e=r);let i=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?F.chrome||F.gecko||(e?(i--,o=1):a=0)?0:s.length-1];return F.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(s,e=>e.width)||c),n==null?c:Gn(c,(o?o>0:t<0)==n)}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},bi=class e extends V{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Gn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top0==n)}},Si=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite()){let t=r.length;if(i0?s.length<=e:s.length=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof vi&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(Pi(n.dom)),r=i;else{let{dom:e}=n;this.cache.reused.get(n)&&V.get(n.dom)&&(e=Pi(n.dom));let t=vi.of(n.mark,e);r.append(t),r=t}this.cache.reused.set(n,2)}let i=V.get(e.text);i&&this.cache.reused.set(i,2);let a=new yi(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=ji;let n=hi.start(e,t||this.cache.find(hi)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof vi&&a.mark.eq(i))n=a,t--;else{let e=vi.of(i,this.cache.find(vi,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ki(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(F.ios&&ki(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Ii,0,32)||new bi(Ii.toDOM(),0,Ii,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,n=new Ci(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.frome.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(xi,void 0,1);return n&&(n.flags=t),n||new xi(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Ti=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},Ei=[bi,hi,yi,vi,xi,mi,pi];for(let e=0;e[]),this.index=Ei.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=0;e{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=ar){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof vi&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof vi&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,a=M.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof jn){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?Fi.block:Fi.inline),c=Ai(a),l=this.cache.findWidget(i,t-e,c)||bi.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=Mi(n,a);t>e&&this.text.skip(t-e)},span:(e,t,a,o)=>{for(let i=e;i-1&&(this.openWidget=a>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=V.get(r);if(r==this.view.contentDOM)break;e instanceof vi?t.push(e):e?.isLine()?n=e:e instanceof mi||(r.nodeName==`DIV`&&!n?n=new hi(r,ji):n||t.push(vi.of(new kn({tagName:r.nodeName.toLowerCase(),attributes:Dn(r)}),r)))}return n?{line:n,marks:t}:null}};function ki(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function Ai(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var ji={class:`cm-line`};function Mi(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&Sn(n,e),r&&(e.class+=` `+r),e)}function Ni(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof vi&&t.push(r.mark)}return t}function Pi(e){let t=V.get(e);return t&&t.setDOM(e.cloneNode()),e}var Fi=class extends On{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Fi.inline=new Fi(`span`),Fi.block=new Fi(`div`);var Ii=new class extends On{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},Li=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=L.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new pi(e,e.contentDOM),this.updateInner([new ci(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>tthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!Ji(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Vi(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new ci(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(F.ie||F.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=Wi(i,this.decorations,e.changes);o.length&&(t=ci.extendWithRanges(t,o));let s=Ki(a,this.blockWrappers,e.changes);return s.length&&(t=ci.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new Oi(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&V.get(t.text)&&r.cache.reused.set(V.get(t.text),2),this.tile=r.run(e,t),Ri(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=F.chrome||F.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Rn(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),F.gecko&&s.empty&&!this.hasComposition&&zi(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new lr(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!Bn(c.node,c.offset,u.anchorNode,u.anchorOffset)||!Bn(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{F.android&&F.chrome&&n.contains(u.focusNode)&&qi(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=In(this.view.root);if(e){if(s.empty){if(F.gecko){let e=Hi(c.node,c.offset);if(e&&e!=3){let t=(e==1?sr:cr)(c.node,c.offset);t&&(c=new lr(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new lr(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new lr(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Bn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=In(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=Wn(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!V.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(r,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Yi?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==R.LTR,c=0,l=(e,u,d)=>{for(let f=0;fr);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof mi)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?zn(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?R.RTL:R.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=zn(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=zn(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(L.replace({widget:new Yi(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return L.set(e)}updateDeco(){let e=1,t=this.view.state.facet($r).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(ti).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(M.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(Hr))try{if(t(this.view,e.range,e))return!0}catch(e){B(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=oi(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(Jn(this.view.scrollDOM,a,t.head1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottome.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Ri(this.tile)}};function Ri(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)Ri(n,t)}}function zi(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function Bi(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=sr(n.focusNode,n.focusOffset),i=cr(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=V.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=V.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function Vi(e,t,n){let r=Bi(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new ci(c.mapPos(a),c.mapPos(o),a,o),text:i}}function Hi(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t{et.from&&(n=!0)}),n}var Yi=class extends On{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Xi(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return D.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=w(i.text,a,!1):s=w(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=w(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;se.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Yt(o,a,e.state.tabSize)}function Qi(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.tot)return i;(!e||i.type==I.Text&&(e.type!=i.type||(n<0?i.fromt)))&&(e=i)}}return e||r}return r}function $i(e,t,n,r){let i=Qi(e,t.head,t.assoc||-1),a=!r||i.type!=I.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==R.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return D.cursor(o,n?-1:1)}return D.cursor(n?i.to:i.from,n?-1:1)}function ea(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=kr(i,a,o,s,n),l=Or;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=` `,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=n?D.cursor(i.from,-1):D.cursor(i.to,1)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function ta(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==wt.Space&&(i=t),i==t}}function na(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return D.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=sa(e,{x:d,y:r},!1,a);if(n?r>c.bottom:rs:u{if(t>e&&tt(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:D.cursor(r,re.viewState.docHeight)return new oa(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==I.Text){if(r<0?l.toe.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==I.Text){let t=Zi(e,i,l,o,s);return new oa(t,t==l.from?1:-1)}}if(l.type!=I.Text)return c<(l.top+l.bottom)/2?new oa(l.from,1):new oa(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new ca(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var ca=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from>1;adjust:if(a.has(f)){for(let e=1;e=i&&(t-=n),!a.has(t)){f=t;break adjust}}break search}a.add(f);let p=t(f),m=0;if(p)for(let e=0;e1)){if(t.bottomthis.y)(!c||c.top>t.top)&&(c=t),m=-1;else{let e=t.left>this.x?this.x-t.left:t.right(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==R.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r{let i=n[r]-t,a=n[r+1]-t;return nr(e.dom,i,a).getClientRects()});return r.after?new oa(n[r.i+1],-1):new oa(n[r.i],1)}scanTile(e,t){if(!e.length)return new oa(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r{let n=e.children[t];return n.flags&48?null:(n.dom.nodeType==1?n.dom:nr(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new oa(n[r.i+1],-1):new oa(a,1)}},la=`￿`,ua=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(j.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=la}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=V.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=V.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:Hn(r))||Hn(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!fa(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=V.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(da(e,n.node,n.offset)?t:0))}};function da(e,t,n){for(;;){if(!t||n-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=ha(e.docView.tile,t,n,0))){let t=i||a?[]:ba(e),n=new ua(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=xa(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!Ln(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!Ln(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((F.ios||F.chrome)&&n!=r&&Math.min(n,r)<=o.main.from&&Math.max(n,r)>=o.main.to&&(s.from>0||s.to-1&&o.ranges.length>1)this.newSel=o.replaceRange(D.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=D.create([D.cursor(n,r)])}else this.newSel=D.single(r,n)}}};function ha(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;cn)return ha(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o=0?e.children[o].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function ga(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||F.android&&t.text.length=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:C.of(t.text.slice(a.from-e,u).split(la))}:(d=ya(l,t.text,s-e,c))&&(F.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==`￿￿`&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:C.of(t.text.slice(d.from,d.toB).split(la))})}else r&&(!e.hasFocus&&i.facet(Kr)||Sa(r,a))&&(r=null);if(!n&&!r)return!1;if((F.mac||F.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=D.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:C.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:F.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` `&&e.lineWrapping&&(r&&=D.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:C.of([` `])}),n)return _a(e,n,r,o);if(r&&!Sa(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=ia(i.facet(ni).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function _a(e,t,n,r=-1){if(F.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(F.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&rr(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.lengthi.head)&&rr(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&rr(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=va(e,t,n);return e.state.facet(Ir).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function va(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.froma.to){let n=t.fromt(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:D.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.fromt.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&Bi(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?D.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function ya(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function ba(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new pa(n,r)),(i!=n||a!=r)&&t.push(new pa(i,a))),t}function xa(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n<0||r<0?null:n==r?D.create([D.cursor(r+t,-1)]):D.single(n+t,r+t)}function Sa(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var Ca=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,F.safari&&e.contentDOM.addEventListener(`input`,()=>null),F.gecko&&ao(e.contentDOM.ownerDocument)}handleEvent(e){La(this.view,e)&&!this.ignoreDuringComposition(e)&&(e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e))))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Ea(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&ka.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),F.android&&F.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(F.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Da.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||Oa.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&F.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&wa(this.view.win)&&(t.shiftKey=!1);let n=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==n&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key==`Enter`&&e&&e.from0?!0:F.safari&&!F.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function wa(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function Ta(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){B(n.state,e)}}}function Ea(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(Ta(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(Ta(t.value,r))}}for(let e in Ra)n(e).handlers.push(Ra[e]);for(let e in H)n(e).observers.push(H[e]);return t}var Da=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],Oa=`dthko`,ka=[16,17,18,20,91,92,224,225],Aa=6;function ja(e){return Math.max(0,e)*.7+8}function Ma(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var Na=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Yn(e.contentDOM),this.atoms=e.state.facet(ni).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(j.allowMultipleSelections)&&Pa(e,t),this.dragging=Ia(e,t)&&Ja(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Ma(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=oi(this.view);e.clientX-s.left<=r+Aa?t=-ja(r-e.clientX):e.clientX+s.right>=a-Aa&&(t=ja(e.clientX-a)),e.clientY-s.top<=i+Aa?n=-ja(i-e.clientY):e.clientY+s.bottom>=o-Aa&&(n=ja(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=ia(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Pa(e,t){let n=e.state.facet(jr);return n.length?n[0](t):F.mac?t.metaKey:t.ctrlKey}function Fa(e,t){let n=e.state.facet(Mr);return n.length?n[0](t):F.mac?!t.altKey:!t.ctrlKey}function Ia(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=In(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function La(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=V.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var Ra=Object.create(null),H=Object.create(null),za=F.ie&&F.ie_version<15||F.ios&&F.webkit_version<604;function Ba(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),Ha(e,n.value)},50)}function Va(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Ha(e,t){t=Va(e.state,Rr,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(eo!=null&&n.selection.ranges.every(e=>e.empty)&&eo==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:D.cursor(r.from+c.length,-1)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:D.cursor(e.from+t.length,-1)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}H.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,F.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},H.wheel=H.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},Ra.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),H.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},H.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},H.touchend=(e,t)=>{e.inputState.touchActive=!1},Ra.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(Nr))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=Ya(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new Na(e,t,n,r)),r&&e.observer.ignore(()=>{er(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function Ua(e,t,n,r){if(r==1)return D.cursor(t,n);if(r==2)return Xi(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return oDate.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Ka+1)%3:1}function Ya(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Ja(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=Ua(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=Ua(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i1&&(c=Xa(i,s.pos))?c:o?i.addRange(l):D.create([l])}}}function Xa(e,t){for(let n=0;n=t)return D.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}Ra.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=D.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,Va(e.state,zr,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},Ra.dragend=e=>(e.inputState.draggedContent=null,!1);function Za(e,t,n,r){if(n=Va(e.state,Rr,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&Fa(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}Ra.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&Za(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData(`Text`);if(n)return Za(e,t,n,!0),!0}return!1},Ra.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=za?null:t.clipboardData;return n?(Ha(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(Ba(e),!1)};function Qa(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function $a(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:Va(e,zr,t.join(e.lineBreak)),ranges:n,linewise:r}}var eo=null;Ra.copy=Ra.cut=(e,t)=>{if(!Rn(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=$a(e.state);if(!n&&!i)return!1;eo=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=za?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(Qa(e,n),!1)};var to=pt.define();function no(e,t){let n=[];for(let r of e.facet(Lr)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:to.of(!0)}):null}function ro(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=no(e.state,t);n?e.dispatch(n):e.update([])}},10)}H.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),ro(e)},H.blur=e=>{e.observer.clearSelectionRange(),ro(e)},H.compositionstart=H.compositionupdate=e=>{if(!e.observer.editContext&&(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0)){let{main:t}=e.state.selection;!t.empty&&e.lineBlockAt(t.from).from!=e.lineBlockAt(t.to).from&&e.dispatch({changes:e.state.selection.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to})),userEvent:`input`}),e.inputState.composing=0}},H.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,F.chrome&&F.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},H.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Ra.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return _a(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(F.chrome&&F.android&&(n=Da.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return F.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),F.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>H.compositionend(e,t),20),!1};var io=new Set;function ao(e){io.has(e)||(io.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var oo=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],so=!1;function co(){so=!1}var lo=class{constructor(e){this.lineWrapping=e,this.doc=C.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return oo.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>po&&(so=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,U.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,U.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,sa*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break}else if(i=i&&a(this.lineAt(0,U.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},vo=class e extends _o{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new fo(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof yo&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof yo?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):mo.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},yo=class e extends mo{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return mo.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=po&&(s=-2);let c=new vo(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=mo.of(r);return(s<0||Math.abs(c.height-this.height)>=po||Math.abs(s-this.heightMetrics(t,n).perLine)>=po)&&(so=!0),ho(this,c)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}},bo=class extends mo{constructor(e,t,n){super(e.length+ +!!t+n.length,e.height+n.height,+!!t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return eo))return c;let l=t==U.ByPosNoHeight?U.ByPosNoHeight:U.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,U.ByPos,n,r,i);e=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(Math.max(e,c.to+1),t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&xo(i,a-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?mo.of(this.break?[e,null,t]:[e,t]):(this.left=ho(this.left,e),this.right=ho(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function xo(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof yo&&(r=e[t+1])instanceof yo&&e.splice(t-1,3,new yo(n.length+1+r.length))}var So=5,Co=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof vo?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new vo(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=So)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new vo(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new yo(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof vo)return e;let t=new vo(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof vo)&&!this.isCovered?this.nodes.push(new vo(0,-1,0)):(this.writtenTon.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function Do(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left0&&t.top0}function Oo(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var ko=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;ntypeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new lo(n),this.stateDeco=Ro(t),this.heightMap=mo.empty().applyChanges(this.stateDeco,C.empty,this.heightOracle.setDoc(t.doc),[new ci(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=L.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new Mo(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Lo:new zo(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Bo(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Ro(this.state);let r=e.changedRanges,i=ci.extendWithRanges(r,wo(n,this.stateDeco,e?e.changes:Pe.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);co(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||so)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heads.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Vr)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?R.RTL:R.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=qn(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=Yn(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=or(this.scrollParent||e.win);let m=(this.printing?Oo:Eo)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!Do(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),co();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?mo.empty().applyChanges(this.stateDeco,C.empty,this.heightOracle,[new ci(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new uo(n.from,i))}so&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new Mo(r.lineAt(a-n*1e3,U.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,U.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(es.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,U.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e=o+Math.max(10,Math.min(n,250)))&&r>a-2e3&&i>1,a=r<<1;if(this.defaultTextDirection!=R.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-rr&&ee.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)e.fromt));if(!f){if(ae.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(D.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new ko(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length2e6)for(let n of e)n.from>=t.from&&n.fromt.from&&s(t.from,c,t,i),le.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];M.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Bo(this.heightMap.lineAt(e,U.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Bo(this.heightMap.lineAt(this.scaler.fromDOM(e),U.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Bo(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Mo=class{constructor(e,t){this.from=e,this.to=t}};function No(e,t,n){let r=[],i=e,a=0;return M.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function Fo(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function Io(e,t){for(let n of e)if(t(n))return n}var Lo={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function Ro(e){let t=e.facet($r).filter(e=>typeof e!=`function`),n=e.facet(ti).filter(e=>typeof e!=`function`);return n.length&&t.push(M.join(n)),t}var zo=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,U.ByPos,e,0,0).top,o=t.lineAt(i,U.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=te.from==t.viewports[n].from&&e.to==t.viewports[n].to)}};function Bo(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new fo(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Bo(e,t)):e._content)}var Vo=O.define({combine:e=>e.join(` `)}),Ho=O.define({combine:e=>e.indexOf(!0)>-1}),Uo=en.newName(),Wo=en.newName(),Go=en.newName(),Ko={"&light":`.`+Wo,"&dark":`.`+Go};function qo(e,t,n){return new en(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var Jo=qo(`.`+Uo,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{userSelect:`none`,position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},".cm-panels-top":{top:`0`},".cm-panels-bottom":{bottom:`0`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`text-top`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{background:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat`,backgroundSize:`.4em`,backgroundPosition:`calc(min(50%, 0px)) center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},Ko),Yo={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Xo=F.ie&&F.ie_version<=11,Zo=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Xn,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(F.ie&&F.ie_version<=11||F.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&F.android&&e.constructor.EDIT_CONTEXT!==!1&&!(F.chrome&&F.chrome_version<126)&&(this.editContext=new ts(e),e.state.facet(Kr)&&(e.contentDOM.editContext=this.editContext.editContext)),Xo&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type!=`change`&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Kr)?n.root.activeElement!=this.dom:!Rn(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(F.ie&&F.ie_version<=11||F.android&&F.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Bn(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=In(e.root);if(!t)return!1;let n=F.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&es(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=Rn(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&rr(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&Rn(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new ma(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=ga(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Sa(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=Qo(t,e.previousSibling||e.target.previousSibling,-1),r=Qo(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return e.type==`characterData`?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Kr)!=e.state.facet(Kr)&&(e.view.contentDOM.editContext=e.state.facet(Kr)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Qo(e,t,n){for(;t;){let r=V.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function $o(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return Bn(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function es(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return $o(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?$o(e,n):null}var ts=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&ithis.to&&(s=i);let l=ya(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=D.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Sa(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:C.of(n.text.slice(l.from,l.toB).split(` -`))};if((F.mac||F.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:C.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);_a(e,u,D.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=In(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(ithis.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},W=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||ir(e.parent)||document,this.viewState=new jo(this,e.state||j.create(e)),e.scrollTo&&e.scrollTo.is(Wr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Jr).map(e=>new Xr(e));for(let e of this.plugins)e.update(this);this.observer=new Zo(this),this.inputState=new Ca(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Li(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof A?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(to))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=no(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(j.phrases)!=this.state.facet(j.phrases))return this.setState(a);i=li.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new Ur(t.empty?t:D.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(Wr)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=is.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(si)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(Vo)!=i.state.facet(Vo)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(Fr))try{e(i)}catch(e){B(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!ga(this,u)&&l.force&&rr(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new jo(this,e),this.plugins=e.facet(Jr).map(e=>new Xr(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Li(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Jr),n=e.state.facet(Jr);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Xr(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a,scaleY:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(or(n||this.win))i=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}o=this.viewState.scaleY}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let c=[];s&4||([this.measureRequests,c]=[c,this.measureRequests]);let l=c.map(e=>{try{return e.read(this)}catch(e){return B(this.state,e),rs}}),u=li.create(this,this.state,[]),d=!1;u.flags|=s,t?t.flags|=s:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let e=0;e1||e<-1)&&!(F.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(Fr))e(t)}get themeClasses(){return Uo+` `+(this.state.facet(Ho)?Go:Wo)+` `+this.state.facet(Vo)}updateAttrs(){let e=as(this,Zr,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Kr)?`true`:`false`,class:`cm-content`,style:`${F.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),as(this,Qr,t);let n=this.observer.ignore(()=>{let n=En(this.contentDOM,this.contentAttrs,t),r=En(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&=(this.announceDOM.textContent=``,this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=`\xA0`},200),!1);let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(si);let t=this.state.facet(e.cspNonce);en.mount(this.root,this.styleModules.concat(Jo).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tt.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return aa(this,e,ea(this,e,t,n))}moveByGroup(e,t){return aa(this,e,ea(this,e,t,t=>ta(this,e.head,t)))}visualLineSide(e,t){return t?D.cursor(e.to,1):D.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return $i(this,e,t,n)}moveVertically(e,t,n){return aa(this,e,na(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=sa(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),sa(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[yr.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&i.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+i.from,t=1):(e=n.from+i.to,t=-1)),this.docView.coordsAt(e,t,i.dir==R.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Br)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ns)return Dr(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||br(r.isolates,n=ii(this,e))))return r.order;n||=ii(this,e);let r=Er(e.text,t,n);return this.bidiCache.push(new is(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||F.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{er(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Wr.of(new Ur(typeof e==`number`?D.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Wr.of(new Ur(D.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Yr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Yr.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=en.newName(),r=[Vo.of(n),si.of(qo(`.${n}`,e))];return t&&t.dark&&r.push(Ho.of(!0)),r}static baseTheme(e){return Qe.lowest(si.of(qo(`.`+Uo,e,Ko)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&V.get(t)||V.get(e))?.root?.view||null}};W.styleModule=si,W.inputHandler=Ir,W.clipboardInputFilter=Rr,W.clipboardOutputFilter=zr,W.scrollHandler=Hr,W.focusChangeEffect=Lr,W.perLineTextDirection=Br,W.exceptionSink=Pr,W.updateListener=Fr,W.editable=Kr,W.mouseSelectionStyle=Nr,W.dragMovesSelection=Mr,W.clickAddsSelectionRange=jr,W.decorations=$r,W.blockWrappers=ei,W.outerDecorations=ti,W.atomicRanges=ni,W.bidiIsolatedRanges=ri,W.cursorScrollMargin=O.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),W.scrollMargins=ai,W.darkTheme=Ho,W.cspNonce=O.define({combine:e=>e.length?e[0]:``}),W.contentAttributes=Qr,W.editorAttributes=Zr,W.lineWrapping=W.contentAttributes.of({class:`cm-lineWrapping`}),W.announce=k.define();var ns=4096,rs={},is=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:R.LTR;for(let a=Math.max(0,t.length-10);a=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&Sn(a,n)}return n}var os=F.mac?`mac`:F.windows?`win`:F.linux?`linux`:`key`;function ss(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;ee.concat(t),[]))),n}var ps=null,ms=4e3;function hs(e,t=os){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>ss(e,t));for(let t=1;t{let r=ps={view:t,prefix:n,scope:e};return setTimeout(()=>{ps==r&&(ps=null)},ms),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,gs))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var gs=null;function _s(e,t,n,r){gs=t;let i=ln(t),a=je(ke(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;ps&&ps.view==n&&ps.scope==r&&(o=ps.prefix+` `,ka.indexOf(t.keyCode)<0&&(c=!0,ps=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+cs(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(F.windows&&t.ctrlKey&&t.altKey)&&!(F.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=rn[t.keyCode])&&p!=i?(d(f[o+cs(p,t,!0)])||t.shiftKey&&(m=an[t.keyCode])!=i&&m!=p&&d(f[o+cs(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+cs(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),gs=null,s}var vs=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=ys(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}return xs(t,n,r)}};function ys(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==R.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function bs(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function xs(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==R.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=ys(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=Qi(e,r,1),m=Qi(e,i,-1),h=p.type==I.Text?p:null,g=m.type==I.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=bs(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=bs(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):ee(p,!1),r=g?y(null,n.to,g):ee(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2l&&r.from=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function ee(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function Ss(e,t){return e.constructor==t.constructor&&e.eq(t)}var Cs=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(ws)!=e.state.facet(ws)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(ws);for(;t!Ss(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,F.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},ws=O.define();function Ts(e){return[Yr.define(t=>new Cs(t,e)),ws.of(e)]}var Es=O.define({combine(e){return kt(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Ds(e={}){return[Es.of(e),ks,js,Ns,Vr.of(!0)]}function Os(e){return e.startState.facet(Es)!=e.state.facet(Es)}var ks=Ts({above:!0,markers(e){let{state:t}=e,n=t.facet(Es),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&F.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:D.cursor(i.head,i.assoc);for(let i of vs.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=Os(e);return n&&As(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){As(t.state,e)},class:`cm-cursorLayer`});function As(e,t){t.style.animationDuration=e.facet(Es).cursorBlinkRate+`ms`}var js=Ts({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of vs.forRange(e,`cm-selectionBackground`,n))t.push(r);if(F.ios&&!n.empty&&e.state.facet(Es).iosSelectionHandles){for(let r of vs.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,D.cursor(n.from,1)))t.push(r);for(let r of vs.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,D.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Os(e)},class:`cm-selectionLayer`}),Ms=F.gecko&&F.gecko_version==153?`#ffffff01`:`transparent`,Ns=Qe.highest(W.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${Ms} !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}}));/x/.unicode;function Ps(){return Is}var Fs=L.line({class:`cm-activeLine`}),Is=Yr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Fs.range(i.from)),t=i.from)}return L.set(n)}},{decorations:e=>e.decorations}),Ls=class extends On{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?zn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Gn(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function Rs(e){let t=Yr.fromClass(class{constructor(t){this.view=t,this.placeholder=e?L.set([L.widget({widget:new Ls(e),side:1}).range(0)]):L.none}get decorations(){return this.view.state.doc.length?L.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,W.contentAttributes.of({"aria-placeholder":e})]:t}var zs=`-10000px`,Bs=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;nt[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function Vs(e={}){return Us.of(e)}function Hs(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var Us=O.define({combine:e=>({position:F.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||Hs})}),Ws=new WeakMap,Gs=Yr.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(Us);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Bs(e,Ys,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(Us);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=zs,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(F.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}let r=this.view.scrollDOM.getBoundingClientRect(),i=oi(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Us).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o=Math.min(t.bottom,n.bottom)||u.rightMath.min(t.right,n.right)+.1)){l.style.top=zs;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=Ws.get(c)??d.bottom-d.top,g=c.offset||Js,_=this.view.textDirection==R.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.yn.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let ee=(y?u.top-n.top:n.bottom-u.bottom)-p;if(eev&&e.topb&&(b=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(b-e.parent.top)/i+`px`,Ks(l,(v-e.parent.left)/r)):(l.style.top=b/i+`px`,Ks(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:b,right:x,bottom:b+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=zs}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ks(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var qs=W.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),Js={x:0,y:0},Ys=O.define({enables:[Gs,qs]}),Xs=O.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),Zs=class e{static create(t){return new e(t)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement(`div`),this.dom.classList.add(`cm-tooltip-hover`),this.manager=new Bs(e,Xs,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add(`cm-tooltip-section`),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)==null||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp(`offset`)}get getCoords(){return this.passProp(`getCoords`)}get overlap(){return this.passProp(`overlap`)}get resize(){return this.passProp(`resize`)}},Qs=Ys.compute([Xs],e=>{let t=e.facet(Xs);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:Zs.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),$s=O.define(),ec=class{constructor(e,t,n,r,i,a){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener(`mouseleave`,this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener(`mousemove`,this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;en.bottom||t.xn.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),o=a&&a.dir==R.RTL?-1:1;i=t.x{if(t&&(!Array.isArray(t)||t.length)){let n=Array.isArray(t)?t:[t];r&&this.locked.set(n,r),e.dispatch({effects:this.setHover.of(n)})}};if(i&&`then`in i){let n=this.pending={pos:t};i.then(e=>{this.pending==n&&(this.pending=null,a(e))},t=>B(e.state,t,`hover tooltip`))}else a(i)}get tooltip(){let e=this.view.plugin(Gs),t=e?e.manager.tooltips.findIndex(e=>e.create==Zs.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:t,tooltip:n}=this;if(t.length&&!this.locked.has(t)&&n&&!nc(n.dom,e)||this.pending){let{pos:n}=t[0]||this.pending,r=t[0]?.end??n;(n==r?this.view.posAtCoords(this.lastMove)!=n:!rc(this.view,n,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener(`mouseleave`,t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener(`mouseleave`,t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener(`mouseleave`,this.mouseleave),this.view.dom.removeEventListener(`mousemove`,this.mousemove)}},tc=4;function nc(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(`.cm-tooltip-arrow`)){let e=o.getBoundingClientRect();i=Math.min(e.top,i),a=Math.max(e.bottom,a)}return t.clientX>=n-tc&&t.clientX<=r+tc&&t.clientY>=i-tc&&t.clientY<=a+tc}function rc(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,s)=t&&c<=n}function ic(e,t={}){let n=k.define(),r=new WeakMap,i=Ye.define({create(){return[]},update(e,a){let o=r.get(e);if(e.length&&(t.hideOnChange&&(a.docChanged||a.selection)||o&&o(a)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(a,e)))),a.docChanged&&e.length){let t=[];for(let n of e){let e=a.changes.mapPos(n.pos,-1,T.TrackDel);if(e!=null){let r=Object.assign(Object.create(null),n);r.pos=e,r.end!=null&&(r.end=a.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of a.effects)t.is(n)&&(e=t.value,o=void 0),(t.is(oc)&&!t.value||t.value==i)&&(e=[]);return e.length&&o&&r.set(e,o),e},provide:e=>Xs.from(e)}),a=Yr.define(a=>new ec(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,a,$s.of(a),Qs]}}function ac(e,t){let n=e.plugin(Gs);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var oc=k.define(),sc=O.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}}),cc=Yr.fromClass(class{constructor(e){this.input=e.state.facet(dc),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(sc);this.top=new lc(e,!0,t.topContainer),this.bottom=new lc(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(sc);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new lc(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new lc(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(dc);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>W.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),lc=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=uc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=uc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function uc(e){let t=e.nextSibling;return e.remove(),t}var dc=O.define({enables:cc}),fc=class extends At{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};fc.prototype.elementClass=``,fc.prototype.toDOM=void 0,fc.prototype.mapMode=T.TrackBefore,fc.prototype.startSide=fc.prototype.endSide=-1,fc.prototype.point=!0;var pc=O.define(),mc=O.define(),hc=O.define(),gc=O.define({combine:e=>e.some(e=>e)});function _c(e){let t=[vc];return e&&e.fixed===!1&&t.push(gc.of(!0)),t}var vc=Yr.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(hc).map(t=>new Sc(e,t)),this.fixed=!e.state.facet(gc);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(gc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=M.iter(this.view.state.facet(pc),this.view.viewport.from),r=[],i=this.gutters.map(e=>new xc(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==I.Text&&t){bc(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==I.Text){bc(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(hc),n=e.state.facet(hc),r=e.docChanged||e.heightChanged||e.viewportChanged||!M.eq(e.startState.facet(pc),e.state.facet(pc),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Sc(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>W.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==R.LTR?{left:r,right:i}:{right:r,left:i}})});function yc(e){return Array.isArray(e)?e:[e]}function bc(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var xc=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=M.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Cc(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];bc(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;(r.length!=0||a.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(mc)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Sc=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=yc(t.markers(e)),t.initialSpacer&&(this.spacer=new Cc(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=yc(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!M.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Cc=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),wc(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=ir(e,t,n)||i(e,t,n):i}return n}})}}),Oc=class extends fc{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function kc(e,t){return e.state.facet(Dc).formatNumber(t,e.state)}var Ac=hc.compute([Dc],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Tc)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new Oc(kc(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Ec)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Dc)!=e.state.facet(Dc),initialSpacer(e){return new Oc(kc(e,Mc(e.state.doc.lines)))},updateSpacer(e,t){let n=kc(t.view,Mc(t.view.state.doc.lines));return n==e.number?e:new Oc(n)},domEventHandlers:e.facet(Dc).domEventHandlers,side:`before`}));function jc(e={}){return[Dc.of(e),_c(),Ac]}function Mc(e){let t=9;for(;t{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=Rc.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};G.closedBy=new G({deserialize:e=>e.split(` `)}),G.openedBy=new G({deserialize:e=>e.split(` `)}),G.group=new G({deserialize:e=>e.split(` `)}),G.isolate=new G({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),G.contextHash=new G({perNode:!0}),G.lookAhead=new G({perNode:!0}),G.mounted=new G({perNode:!0});var Ic=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[G.mounted.id]}},Lc=Object.create(null),Rc=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):Lc,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(G.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(G.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};Rc.none=new Rc(``,Object.create(null),0,8);var zc=class e{constructor(e){this.types=e;for(let t=0;t0;for(let e=this.cursor(a|K.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:ol(Rc.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(Rc.none,t,n,r)))}static build(e){return rl(e)}};q.empty=new q(Rc.none,[],[],0);var Hc=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},Uc=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Rc.none}toString(){let e=[];for(let t=0;t0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e=t&&nt;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Gc(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&K.EnterBracketed&&l instanceof q&&(d=Ic.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||Wc(i,r,u,u+l.length)){if(l instanceof Uc){if(a&K.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new Zc(new Xc(o,l,t,u),null,e)}else if(a&K.IncludeAnonymous||!l.type.isAnonymous||nl(l)){let s;if(!(a&K.IgnoreMounts)&&(s=Ic.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&K.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&K.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&K.IgnoreOverlays)&&(i=Ic.get(this._tree))&&i.overlay){let a=t-this.from,o=r&K.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Jc(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function Yc(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var Xc=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Zc=class e extends Kc{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&K.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new q(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Qc(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;rn.from||i.to=t){let o=new qc(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(Gc(o,t,n,!1))}}return i?Qc(i):r}var tl=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~K.EnterBracketed,e instanceof qc)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof qc?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&K.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&K.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&K.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&K.IncludeAnonymous||e instanceof Uc||!e.type.isAnonymous||nl(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e=0;i--){if(i<0)return Yc(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function nl(e){return e.children.some(e=>e instanceof Uc||!e.type.isAnonymous||nl(e))}function rl(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Nc,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new Hc(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,ee){let{id:b,start:x,end:te,size:ne}=o,re=l,ie=c;if(ne<0){if(o.next(),ne==-1){let t=i[b];_.push(t),v.push(x-e);return}if(ne==-3){c=b;return}if(ne==-4){l=b;return}throw RangeError(`Unrecognized record size: ${ne}`)}let S=s[b],ae,oe,se=x-e;if(te-x<=r&&(oe=h(o.pos-t,y))){let t=new Uint16Array(oe.size-oe.skip),r=o.pos-oe.size,i=t.length;for(;o.pos>r;)i=g(oe.start,t,i);ae=new Uc(t,te-oe.start,n),se=oe.start-e}else{let e=o.pos-ne;o.next();let t=[],n=[],i=b>=a?b:-1,s=0,c=te;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,x,s,o.end,c,i,re,ie),s=t.length,c=o.end),o.next()):ee>2500?d(x,e,t,n):u(x,e,t,n,i,ee+1);if(i>=0&&s>0&&s-1&&s>0){let e=f(S,ie);ae=ol(S,t,n,0,t.length,0,te-x,e,e)}else ae=m(S,t,n,te-x,re-te,ie)}_.push(ae),v.push(se)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new Uc(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof q){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(G.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[G.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[G.lookAhead,i];o=o?[e].concat(o):[e]}return new q(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new q(s[e.topID],_.reverse(),v.reverse(),y)}var il=new WeakMap;function al(e,t){if(!e.isAnonymous||t instanceof Uc||t.type!=e)return 1;let n=il.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof q)){n=1;break}n+=al(e,r)}il.set(t,n)}return n}function ol(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(ol(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var sl=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s=r)for(;o&&o.from=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=anew Fc(e.from,e.to)):[new Fc(0,0)]:[new Fc(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},ll=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new G({perNode:!0});var ul=0,dl=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=ul++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new pl(e);return e=>e.modified.indexOf(t)>-1?e:pl.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},fl=0,pl=class e{constructor(e){this.name=e,this.instances=[],this.id=fl++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&ml(n,e.modified));if(r)return r;let i=[],a=new dl(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=hl(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function ml(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function hl(e){let t=[[]];for(let n=0;nt.length-e.length)}function gl(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new vl(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return _l.add(t)}var _l=new G({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new vl(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),vl=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function bl(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function xl(e,t,n,r=0,i=e.length){let a=new Sl(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Sl=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Cl(e)||vl.empty,u=bl(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(G.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Cl(e){let t=e.type.prop(_l);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var J=dl.define,wl=J(),Tl=J(),El=J(Tl),Dl=J(Tl),Ol=J(),kl=J(Ol),Al=J(Ol),jl=J(),Ml=J(jl),Nl=J(),Pl=J(),Fl=J(),Il=J(Fl),Ll=J(),Y={comment:wl,lineComment:J(wl),blockComment:J(wl),docComment:J(wl),name:Tl,variableName:J(Tl),typeName:El,tagName:J(El),propertyName:Dl,attributeName:J(Dl),className:J(Tl),labelName:J(Tl),namespace:J(Tl),macroName:J(Tl),literal:Ol,string:kl,docString:J(kl),character:J(kl),attributeValue:J(kl),number:Al,integer:J(Al),float:J(Al),bool:J(Ol),regexp:J(Ol),escape:J(Ol),color:J(Ol),url:J(Ol),keyword:Nl,self:J(Nl),null:J(Nl),atom:J(Nl),unit:J(Nl),modifier:J(Nl),operatorKeyword:J(Nl),controlKeyword:J(Nl),definitionKeyword:J(Nl),moduleKeyword:J(Nl),operator:Pl,derefOperator:J(Pl),arithmeticOperator:J(Pl),logicOperator:J(Pl),bitwiseOperator:J(Pl),compareOperator:J(Pl),updateOperator:J(Pl),definitionOperator:J(Pl),typeOperator:J(Pl),controlOperator:J(Pl),punctuation:Fl,separator:J(Fl),bracket:Il,angleBracket:J(Il),squareBracket:J(Il),paren:J(Il),brace:J(Il),content:jl,heading:Ml,heading1:J(Ml),heading2:J(Ml),heading3:J(Ml),heading4:J(Ml),heading5:J(Ml),heading6:J(Ml),contentSeparator:J(jl),list:J(jl),quote:J(jl),emphasis:J(jl),strong:J(jl),link:J(jl),monospace:J(jl),strikethrough:J(jl),inserted:J(),deleted:J(),changed:J(),invalid:J(),meta:Ll,documentMeta:J(Ll),annotation:J(Ll),processingInstruction:J(Ll),definition:dl.defineModifier(`definition`),constant:dl.defineModifier(`constant`),function:dl.defineModifier(`function`),standard:dl.defineModifier(`standard`),local:dl.defineModifier(`local`),special:dl.defineModifier(`special`)};for(let e in Y){let t=Y[e];t instanceof dl&&(t.name=e)}yl([{tag:Y.link,class:`tok-link`},{tag:Y.heading,class:`tok-heading`},{tag:Y.emphasis,class:`tok-emphasis`},{tag:Y.strong,class:`tok-strong`},{tag:Y.keyword,class:`tok-keyword`},{tag:Y.atom,class:`tok-atom`},{tag:Y.bool,class:`tok-bool`},{tag:Y.url,class:`tok-url`},{tag:Y.labelName,class:`tok-labelName`},{tag:Y.inserted,class:`tok-inserted`},{tag:Y.deleted,class:`tok-deleted`},{tag:Y.literal,class:`tok-literal`},{tag:Y.string,class:`tok-string`},{tag:Y.number,class:`tok-number`},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:`tok-string2`},{tag:Y.variableName,class:`tok-variableName`},{tag:Y.local(Y.variableName),class:`tok-variableName tok-local`},{tag:Y.definition(Y.variableName),class:`tok-variableName tok-definition`},{tag:Y.special(Y.variableName),class:`tok-variableName2`},{tag:Y.definition(Y.propertyName),class:`tok-propertyName tok-definition`},{tag:Y.typeName,class:`tok-typeName`},{tag:Y.namespace,class:`tok-namespace`},{tag:Y.className,class:`tok-className`},{tag:Y.macroName,class:`tok-macroName`},{tag:Y.propertyName,class:`tok-propertyName`},{tag:Y.operator,class:`tok-operator`},{tag:Y.comment,class:`tok-comment`},{tag:Y.meta,class:`tok-meta`},{tag:Y.invalid,class:`tok-invalid`},{tag:Y.punctuation,class:`tok-punctuation`}]);var Rl=new G;function zl(e){return O.define({combine:e?t=>t.concat(e):void 0})}var Bl=new G,Vl=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,j.prototype.hasOwnProperty(`tree`)||Object.defineProperty(j.prototype,"tree",{get(){return Wl(this)}}),this.parser=t,this.extension=[$l.of(this),j.languageData.of((e,t,n)=>{let r=Hl(e,t,n),i=r.type.prop(Rl);if(!i)return[];let a=e.facet(i),o=r.type.prop(Bl);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return Hl(e,t,n).type.prop(Rl)==this.data}findRegions(e){let t=e.facet($l);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(Rl)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(G.mounted);if(i){if(i.tree.prop(Rl)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;ne.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Wl(e){let t=e.field(Vl.state,!1);return t?t.tree:q.empty}var Gl=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Kl=null,ql=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],q.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Gl(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=q.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(sl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Kl;Kl=this;try{return e()}finally{Kl=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Jl(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=sl.applyChanges(r,e),i=q.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);ne.from&&(this.fragments=Jl(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends cl{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=Kl;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new q(Rc.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Kl}};function Jl(e,t,n){return sl.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Yl=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=ql.create(t.facet($l).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};Vl.state=Ye.define({create:Yl.init,update(e,t){for(let e of t.effects)if(e.is(Vl.setState))return e.value;return t.startState.facet($l)==t.state.facet($l)?e.apply(t):Yl.init(t.state)}});var Xl=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Xl=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Zl=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,Ql=Yr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Vl.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Vl.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Xl(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,s=i.context.work(()=>Zl&&Zl()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Vl.setState.of(new Yl(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>B(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),$l=O.define({combine(e){return e.length?e[0]:null},enables:e=>[Vl.state,Ql,W.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),eu=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},tu=O.define(),nu=O.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function ru(e){let t=e.facet(nu);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function iu(e,t){let n=``,r=e.tabSize,i=e.facet(nu)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e=t?cu(e,n,t):null}var ou=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=ru(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Jt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},su=new G;function cu(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.fromr.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return lu(r,e,n)}function lu(e,t,n){for(let r=e;r;r=r.next){let e=du(r.node);if(e)return e(pu.create(t,n,r))}return 0}function uu(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function du(e){let t=e.type.prop(su);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(G.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>gu(e,!0,1,void 0,n&&!uu(e)?t.from:void 0)}return e.parent==null?fu:null}function fu(){return 0}var pu=class e extends ou{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(mu(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return lu(this.context.next,this.base,this.pos)}};function mu(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function hu(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function gu(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?hu(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function _u({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var vu=200;function yu(){return j.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+vu)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=au(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=iu(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var bu=new G,xu=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=en.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof Vl?e=>e.prop(Rl)==a.data:a?e=>e==a:void 0,this.style=yl(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new en(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},Su=O.define(),Cu=O.define({combine(e){return e.length?[e[0]]:null}});function wu(e){let t=e.facet(Su);return t.length?t:e.facet(Cu)}function Tu(e,t){let n=[Du],r;return e instanceof xu&&(e.module&&n.push(W.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Cu.of(e)):r?n.push(Su.computeN([W.darkTheme],t=>t.facet(W.darkTheme)==(r==`dark`)?[e]:[])):n.push(Su.of(e)),n}var Eu=class{constructor(e){this.markCache=Object.create(null),this.tree=Wl(e.state),this.decorations=this.buildDeco(e,wu(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Wl(e.state),n=wu(e.state),r=n!=wu(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return L.none;let n=new Lt;for(let{from:r,to:i}of e.visibleRanges)xl(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=L.mark({class:r})))},r,i);return n.finish()}},Du=Qe.high(Yr.fromClass(Eu,{decorations:e=>e.decorations}));Y.meta,Y.link,Y.heading,Y.emphasis,Y.strong,Y.strikethrough,Y.keyword,Y.atom,Y.bool,Y.url,Y.contentSeparator,Y.labelName,Y.literal,Y.inserted,Y.string,Y.deleted,Y.regexp,Y.escape,Y.string,Y.variableName,Y.variableName,Y.typeName,Y.namespace,Y.className,Y.variableName,Y.macroName,Y.propertyName,Y.comment,Y.invalid;var Ou=W.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),ku=1e4,Au=`()[]{}`,ju=O.define({combine(e){return kt(e,{afterCursor:!0,brackets:Au,maxScanDistance:ku,renderMatch:Pu})}}),Mu=L.mark({class:`cm-matchingBracket`}),Nu=L.mark({class:`cm-nonmatchingBracket`});function Pu(e){let t=[],n=e.matched?Mu:Nu;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function Fu(e){let t=[],n=e.facet(ju);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Vu(e,r.head,-1,n)||r.head>0&&Vu(e,r.head-1,1,n)||n.afterCursor&&(Vu(e,r.head,1,n)||r.heade.decorations}),Ou];function Lu(e={}){return[ju.of(e),Iu]}var Ru=new G;function zu(e,t,n){let r=e.prop(t<0?G.openedBy:G.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function Bu(e){let t=e.type.prop(Ru);return t?t(e.node):e}function Vu(e,t,n,r={}){let i=r.maxScanDistance||ku,a=r.brackets||Au,o=Wl(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=zu(r.type,n,a);if(i&&r.from0?t>=o.from&&to.from&&t<=o.to))return Hu(e,t,n,r,o,i,a)}}return Uu(e,t,n,o,s.type,i,a)}function Hu(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var Wu=Object.create(null),Gu=[Rc.none],Ku=[],qu=Object.create(null),Ju=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])Ju[e]=Xu(Wu,t);function Yu(e,t){Ku.indexOf(e)>-1||(Ku.push(e),console.warn(t))}function Xu(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Y[n];r?typeof r==`function`?t.length?t=t.map(r):Yu(n,`Modifier ${n} used at start of tag`):t.length?Yu(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Yu(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=qu[i];if(a)return a.id;let o=qu[i]=Rc.define({id:Gu.length,name:r,props:[gl({[r]:n})]});return Gu.push(o),o.id}R.RTL,R.LTR;var Zu=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=nd(e.state,n.from);return r.line?$u(e):r.block?td(e):!1};function Qu(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var $u=Qu(sd,0),ed=Qu(od,0),td=Qu((e,t)=>od(e,t,ad(t)),0);function nd(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var rd=50;function id(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-rd,r),o=e.sliceDoc(i,i+rd),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+rd),d=e.sliceDoc(i-rd,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function ad(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function od(e,t,n=t.selection.ranges){let r=n.map(e=>nd(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>id(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;ti&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var cd=pt.define(),ld=pt.define(),ud=O.define(),dd=O.define({combine(e){return kt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),fd=Ye.define({create(){return jd.empty},update(e,t){let n=t.state.facet(dd),r=t.annotation(cd);if(r){let i=yd.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?bd(o,o.length,n.minDepth,i):Ed(o,t.startState.selection),new jd(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(ld);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(A.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=yd.fromTransaction(t),o=t.annotation(A.time),s=t.annotation(A.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new jd(e.done.map(yd.fromJSON),e.undone.map(yd.fromJSON))}});function pd(e={}){return[fd,dd.of(e),W.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?hd:e.inputType==`historyRedo`?gd:null;return n?(e.preventDefault(),n(t)):!1}})]}function md(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(fd,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var hd=md(0,!1),gd=md(1,!1),_d=md(0,!0),vd=md(1,!0),yd=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&Pe.fromJSON(t.changes),[],t.mapped&&Ne.fromJSON(t.mapped),t.startSelection&&D.fromJSON(t.startSelection),t.selectionsAfter.map(D.fromJSON))}static fromTransaction(t,n){let r=wd;for(let e of t.startState.facet(ud)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,wd)}static selection(t){return new e(void 0,wd,void 0,void 0,t)}};function bd(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function xd(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e=t&&i<=o&&(r=!0)}}),r}function Sd(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function Cd(e,t){return e.length?t.length?e.concat(t):e:t}var wd=[],Td=200;function Ed(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Td));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),bd(e,e.length-1,1e9,n.setSelAfter(r)))}return[yd.selection([t])]}function Dd(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Od(e,t){if(!e.length)return e;let n=e.length,r=wd;for(;n;){let i=kd(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[yd.selection(r)]:wd}function kd(e,t,n){let r=Cd(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):wd,n);if(!e.changes)return yd.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new yd(i,k.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Ad=/^(input\.type|delete)($|\.)/,jd=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Ad.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):Id(n,t))}function X(e){return e.textDirectionAt(e.state.selection.main.head)==R.LTR}var Rd=e=>Ld(e,!X(e)),zd=e=>Ld(e,X(e));function Bd(e,t){return Fd(e,n=>n.empty?e.moveByGroup(n,t):Id(n,t))}var Vd=e=>Bd(e,!X(e)),Hd=e=>Bd(e,X(e));typeof Intl<`u`&&Intl.Segmenter;function Ud(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Wd(e,t,n){let r=Wl(e).resolveInner(t.head),i=n?G.closedBy:G.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Ud(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?Vu(e,r.from,1):Vu(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,D.cursor(s,n?-1:1)}var Gd=e=>Fd(e,t=>Wd(e.state,t,!X(e))),Kd=e=>Fd(e,t=>Wd(e.state,t,X(e)));function qd(e,t){return Fd(e,n=>{if(!n.empty)return Id(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Jd=e=>qd(e,!1),Yd=e=>qd(e,!0);function Xd(e){let t=e.scrollDOM.clientHeightr.empty?e.moveVertically(r,t,n.height):Id(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottomZd(e,!1),$d=e=>Zd(e,!0);function ef(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=D.cursor(r.from+n))}return i}var tf=e=>Fd(e,t=>ef(e,t,!0)),nf=e=>Fd(e,t=>ef(e,t,!1)),rf=e=>Fd(e,t=>ef(e,t,!X(e))),af=e=>Fd(e,t=>ef(e,t,X(e))),of=e=>Fd(e,t=>e.moveToLineBoundary(t,!1,!1)),sf=e=>Fd(e,t=>e.moveToLineBoundary(t,!0,!1));function cf(e,t,n){let r=!1,i=Nd(e.selection,t=>{let i=Vu(e,t.head,-1)||Vu(e,t.head,1)||t.head>0&&Vu(e,t.head-1,1)||t.headcf(e,t,!1);function uf(e,t,n){let r=Nd(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=D.range(e.head,e.anchor));let r=n(e);return D.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(Pd(e.state,r)),!0)}function df(e,t){return uf(e,t,n=>e.moveByChar(n,t))}var ff=e=>df(e,!X(e)),pf=e=>df(e,X(e));function mf(e,t){return uf(e,t,n=>e.moveByGroup(n,t))}var hf=e=>mf(e,!X(e)),gf=e=>mf(e,X(e)),_f=e=>{let t=!X(e);return uf(e,t,n=>Wd(e.state,n,t))},vf=e=>{let t=X(e);return uf(e,t,n=>Wd(e.state,n,t))};function yf(e,t){return uf(e,t,n=>e.moveVertically(n,t))}var bf=e=>yf(e,!1),xf=e=>yf(e,!0);function Sf(e,t){return uf(e,t,n=>e.moveVertically(n,t,Xd(e).height))}var Cf=e=>Sf(e,!1),wf=e=>Sf(e,!0),Tf=e=>uf(e,!0,t=>ef(e,t,!0)),Ef=e=>uf(e,!1,t=>ef(e,t,!1)),Df=e=>{let t=!X(e);return uf(e,t,n=>ef(e,n,t))},Of=e=>{let t=X(e);return uf(e,t,n=>ef(e,n,t))},kf=e=>uf(e,!1,t=>D.cursor(e.lineBlockAt(t.head).from)),Af=e=>uf(e,!0,t=>D.cursor(e.lineBlockAt(t.head).to)),jf=({state:e,dispatch:t})=>(t(Pd(e,{anchor:0})),!0),Mf=({state:e,dispatch:t})=>(t(Pd(e,{anchor:e.doc.length})),!0),Nf=({state:e,dispatch:t})=>(t(Pd(e,{anchor:e.selection.main.anchor,head:0})),!0),Pf=({state:e,dispatch:t})=>(t(Pd(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Ff=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),If=({state:e,dispatch:t})=>{let n=tp(e).map(({from:t,to:n})=>D.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:D.create(n),userEvent:`select`})),!0},Lf=({state:e,dispatch:t})=>{let n=Nd(e.selection,t=>{let n=Wl(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return D.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(Pd(e,n)),!0)};function Rf(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.heada.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(Pd(n,D.create(i,i.length-1))),!0)}var zf=e=>Rf(e,!1),Bf=e=>Rf(e,!0),Vf=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=D.create([n.main]):n.main.empty||(r=D.create([D.cursor(n.main.head)])),r?(t(Pd(e,r)),!0):!1};function Hf(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);oi&&(n=`delete.forward`,o=Uf(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Uf(e,i,!1),a=Uf(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:D.cursor(i,it(e)))r.between(t,t,(e,r)=>{et&&(t=n?r:e)});return t}var Wf=(e,t,n)=>Hf(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&iWf(e,!1,!0),Kf=e=>Wf(e,!0,!1),qf=(e,t)=>Hf(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=w(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Jf=e=>qf(e,!1),Yf=e=>qf(e,!0),Xf=e=>Hf(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headHf(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Qf=e=>Hf(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:C.of([``,``])},range:D.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},ep=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:w(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:w(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:D.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function tp(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function np(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of tp(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(D.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(D.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:D.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var rp=({state:e,dispatch:t})=>np(e,t,!1),ip=({state:e,dispatch:t})=>np(e,t,!0);function ap(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of tp(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var op=({state:e,dispatch:t})=>ap(e,t,!1),sp=({state:e,dispatch:t})=>ap(e,t,!0),cp=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(tp(t).map(({from:e,to:n})=>(e>0?e--:n{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function lp(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Wl(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(G.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var up=fp(!1),dp=fp(!0);function fp(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&lp(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new ou(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=au(s,r);for(c??=Jt(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);ia.from&&r{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:D.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var mp=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new ou(e,{overrideIndentation:e=>n[e]??-1}),i=pp(e,(t,i,a)=>{let o=au(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=iu(e,o);(s!=c||a.from!e.readOnly&&(t(e.update(pp(e,(t,n)=>{n.push({from:t.from,insert:e.facet(nu)})}),{userEvent:`input.indent`})),!0),gp=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(pp(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Jt(r,e.tabSize),a=0,o=iu(e,Math.max(0,i-ru(e)));for(;a(e.setTabFocusMode(),!0),vp=[{key:`Ctrl-b`,run:Rd,shift:ff,preventDefault:!0},{key:`Ctrl-f`,run:zd,shift:pf},{key:`Ctrl-p`,run:Jd,shift:bf},{key:`Ctrl-n`,run:Yd,shift:xf},{key:`Ctrl-a`,run:of,shift:kf},{key:`Ctrl-e`,run:sf,shift:Af},{key:`Ctrl-d`,run:Kf},{key:`Ctrl-h`,run:Gf},{key:`Ctrl-k`,run:Xf},{key:`Ctrl-Alt-h`,run:Jf},{key:`Ctrl-o`,run:$f},{key:`Ctrl-t`,run:ep},{key:`Ctrl-v`,run:$d}],yp=[{key:`ArrowLeft`,run:Rd,shift:ff,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Vd,shift:hf,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:rf,shift:Df,preventDefault:!0},{key:`ArrowRight`,run:zd,shift:pf,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Hd,shift:gf,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:af,shift:Of,preventDefault:!0},{key:`ArrowUp`,run:Jd,shift:bf,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:jf,shift:Nf},{mac:`Ctrl-ArrowUp`,run:Qd,shift:Cf},{key:`ArrowDown`,run:Yd,shift:xf,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Mf,shift:Pf},{mac:`Ctrl-ArrowDown`,run:$d,shift:wf},{key:`PageUp`,run:Qd,shift:Cf},{key:`PageDown`,run:$d,shift:wf},{key:`Home`,run:nf,shift:Ef,preventDefault:!0},{key:`Mod-Home`,run:jf,shift:Nf},{key:`End`,run:tf,shift:Tf,preventDefault:!0},{key:`Mod-End`,run:Mf,shift:Pf},{key:`Enter`,run:up,shift:up},{key:`Mod-a`,run:Ff},{key:`Backspace`,run:Gf,shift:Gf,preventDefault:!0},{key:`Delete`,run:Kf,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Jf,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Yf,preventDefault:!0},{mac:`Mod-Backspace`,run:Zf,preventDefault:!0},{mac:`Mod-Delete`,run:Qf,preventDefault:!0}].concat(vp.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),bp=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Gd,shift:_f},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Kd,shift:vf},{key:`Alt-ArrowUp`,run:rp},{key:`Shift-Alt-ArrowUp`,run:op},{key:`Alt-ArrowDown`,run:ip},{key:`Shift-Alt-ArrowDown`,run:sp},{key:`Mod-Alt-ArrowUp`,run:zf},{key:`Mod-Alt-ArrowDown`,run:Bf},{key:`Escape`,run:Vf},{key:`Mod-Enter`,run:dp},{key:`Alt-l`,mac:`Ctrl-l`,run:If},{key:`Mod-i`,run:Lf,preventDefault:!0},{key:`Mod-[`,run:gp},{key:`Mod-]`,run:hp},{key:`Mod-Alt-\\`,run:mp},{key:`Shift-Mod-k`,run:cp},{key:`Shift-Mod-\\`,run:lf},{key:`Mod-/`,run:Zu},{key:`Alt-A`,mac:`Ctrl-A`,run:ed},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:_p}].concat(yp),xp=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Wl(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(Op(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function Sp(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function Cp(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;etypeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:Cp(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Tp(e,t){return n=>{for(let t=Wl(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var Ep=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Dp(e){return e.selection.main.from}function Op(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var kp=pt.define();function Ap(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:D.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var jp=new WeakMap;function Mp(e){if(!Array.isArray(e))return e;let t=jp.get(e);return t||jp.set(e,t=wp(e)),t}var Np=k.define(),Pp=k.define(),Fp=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=Ae(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=je(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?je(ke(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},Ip=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Rp,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Lp(e(n),t(n)),optionClass:(e,t)=>n=>Lp(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Lp(e,t){return e?t?e+` `+t:e:t}function Rp(e,t,n,r,i,a){let o=e.textDirection==R.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var zp=k.define();function Bp(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;eo&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return oe.position-t.position).map(e=>e.render)}function Vp(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var Hp=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(Z);this.optionContent=Bp(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Vp(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:zp.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(Z).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Pp.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=Vp(r.length,i,e.state.facet(Z).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=Vp(t.options.length,t.selected,this.view.state.facet(Z).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>B(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Wp(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;an.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.tonew Hp(n,e,t)}function Wp(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.topn.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function Gp(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Kp(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(Z);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Ep(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Ip(n):new Fp(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Ep(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.namet.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):Gp(e.completion)>Gp(c)&&(s[s.length-1]=e),c=e.completion}return s}var qp=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,Qp(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=Kp(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(Z).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;tt.hasResult()?Math.min(e,t.from):e,1e8),create:om,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Jp=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e($p,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Z),i=(r.override||n.languageDataAt(`autocomplete`,Dp(n)).map(Mp)).map(e=>(this.active.find(t=>t.source==e)||new tm(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(im));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Yp(i,this.active)||o?a=qp.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new tm(e.source,0):e));for(let e of t.effects)e.is(zp)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Xp:Zp}};function Yp(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var $p=[];function em(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(kp);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var tm=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=em(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(Np))i=new e(i.source,1,n.value);else if(n.is(Pp))i=new e(i.source,0);else if(n.is(im))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Dp(e.state))}},nm=class e extends tm{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Dp(t.state);if(o>a||!r||n&2&&(Dp(t.startState)==this.from||oe.map(t))}}),Q=Ye.define({create(){return Jp.start()},update(e,t){return e.update(t)},provide:e=>[Ys.from(e,e=>e.tooltip),W.contentAttributes.from(e,e=>e.attrs)]});function am(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(Q).active.find(e=>e.source==t.source);return r instanceof nm&&(typeof n==`string`?e.dispatch({...Ap(e.state,n,r.from,r.to),annotations:kp.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var om=Up(Q,am);function sm(e,t=`option`){return n=>{let r=n.state.field(Q,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:zp.of(s)}),!0}}var cm=e=>{let t=e.state.field(Q,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.state.field(Q,!1)?(e.dispatch({effects:Np.of(!0)}),!0):!1,um=e=>{let t=e.state.field(Q,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:Pp.of(null)}),!0)},dm=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},fm=50,pm=1e3,mm=Yr.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Q).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Q),n=e.state.facet(Z);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Q)==t)return;let r=e.transactions.some(e=>{let t=em(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;tfm&&Date.now()-n.time>pm){for(let e of n.context.abortListeners)try{e()}catch(e){B(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(Np)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Q);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Z).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new xp(t,Dp(t),e.explicit,this.view),r=new dm(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Pp.of(null)}),B(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Z).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Z),n=this.view.state.field(Q);for(let r=0;re.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new tm(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:im.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Q,!1);if(t&&t.tooltip&&this.view.state.facet(Z).closeOnBlur){let n=t.open&&ac(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Pp.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Np.of(!1)}),20),this.composing=0}}}),hm=typeof navigator==`object`&&/Win/.test(navigator.platform),gm=Qe.highest(W.domEventHandlers({keydown(e,t){let n=t.state.field(Q,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(hm&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&am(t,r),!1}})),_m=W.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),vm=new class extends At{};vm.startSide=1,vm.endSide=-1,typeof navigator==`object`&&navigator.userAgent;function ym(e={}){return[gm,Q,Z.of(e),mm,xm,_m]}var bm=[{key:`Ctrl-Space`,run:lm},{mac:"Alt-`",run:lm},{mac:`Alt-i`,run:lm},{key:`Escape`,run:um},{key:`ArrowDown`,run:sm(!0)},{key:`ArrowUp`,run:sm(!1)},{key:`PageDown`,run:sm(!0,`page`)},{key:`PageUp`,run:sm(!1,`page`)},{key:`Enter`,run:cm}],xm=Qe.highest(us.computeN([Z],e=>e.facet(Z).defaultKeymap?[bm]:[]));function Sm(e){let t=e.field(Q,!1);return t&&t.active.some(e=>e.isPending)?`pending`:t&&t.active.some(e=>e.state!=0)?`active`:null}var Cm=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},wm=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Lm).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Lt,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;et.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Jm(s);if(i)o.add(n,n,L.widget({widget:new Vm(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,L.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new Cm(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Cm(r.from,n,r.diagnostic)}}),r}function Em(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Lm).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(km))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Dm(e,t){return e.field(Mm,!1)?t:t.concat(k.appendConfig.of(Xm))}function Om(e,t){return{effects:Dm(e,[km.of(t)])}}var km=k.define(),Am=k.define(),jm=k.define(),Mm=Ye.define({create(){return new wm(L.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Tm(n,e.selected.diagnostic,i)||Tm(n,null,i)}!n.size&&i&&t.state.facet(Lm).autoPanel&&(i=null),e=new wm(n,i,r)}for(let n of t.effects)if(n.is(km)){let r=t.state.facet(Lm).autoPanel?n.value.length?Um.open:null:e.panel;e=wm.init(n.value,r,t.state)}else n.is(Am)?e=new wm(e.diagnostics,n.value?Um.open:null,e.selected):n.is(jm)&&(e=new wm(e.diagnostics,e.panel,n.value));return e},provide:e=>[dc.from(e,e=>e.panel),W.decorations.from(e,e=>e.diagnostics)]}),Nm=L.mark({class:`cm-lintRange cm-lintRange-active`});function Pm(e,t,n){let{diagnostics:r}=e.state.field(Mm),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(tBm(e,t,!1)))}var Im=e=>{let t=e.state.field(Mm,!1);return!t||!t.panel?!1:(e.dispatch({effects:Am.of(!1)}),!0)},Lm=O.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...kt(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Rm,tooltipFilter:Rm,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Rm(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function zm(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;ee.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Bm(e,t,n){let r=n?zm(t.actions):[];return un(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},un(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Tm(e.state.field(Mm).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),un(`u`,s.slice(c,c+1)),s.slice(c+1)];return un(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&un(`div`,{class:`cm-diagnosticSource`},t.source))}var Vm=class extends On{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return un(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Hm=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Bm(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Um=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Im(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=zm(n.actions);for(let i=0;i{for(let t=0;tIm(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Mm).selected;if(!e)return-1;for(let t=0;t{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;tn&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.topt.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Tm(this.view.state.field(Mm).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:jm.of(t)})}static open(t){return new e(t)}};function Wm(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,${encodeURIComponent(e)}')`}function Gm(e){return Wm(``,`width="6" height="3"`)}var Km=W.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Gm(`#f11`)},".cm-lintRange-warning":{backgroundImage:Gm(`orange`)},".cm-lintRange-info":{backgroundImage:Gm(`#999`)},".cm-lintRange-hint":{backgroundImage:Gm(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function qm(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Jm(e){let t=`hint`,n=1;for(let r of e){let e=qm(r.severity);e>n&&(n=e,t=r.severity)}return t}var Ym=ic(Pm,{hideOn:Em}),Xm=[Mm,W.decorations.compute([Mm],e=>{let{selected:t,panel:n}=e.field(Mm);return!t||!n||t.from==t.to?L.none:L.set([Nm.range(t.from,t.to)])}),Ym,Km],Zm=W.theme({"&":{color:`var(--mantine-color-text)`,backgroundColor:`var(--labstack-inset)`,border:`1px solid var(--mantine-color-default-border)`,borderRadius:`var(--mantine-radius-sm)`},"&.cm-focused":{outline:`2px solid var(--mantine-color-accent-filled)`,outlineOffset:`2px`},".cm-scroller":{fontFamily:m.display,fontSize:`13px`,lineHeight:`1.6`,minHeight:`160px`,maxHeight:`40vh`,overflow:`auto`},".cm-content":{padding:`10px 0`,caretColor:`var(--labstack-focus)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--labstack-focus)`},".cm-gutters":{backgroundColor:`var(--mantine-color-default)`,color:`var(--mantine-color-dimmed)`,borderColor:`var(--mantine-color-default-border)`,borderRadius:`var(--mantine-radius-sm) 0 0 var(--mantine-radius-sm)`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`var(--mantine-color-accent-light-hover)`},".cm-activeLine":{backgroundColor:`var(--mantine-color-accent-light)`},".cm-placeholder":{color:`var(--mantine-color-dimmed)`,fontStyle:`italic`},".cm-tooltip":{color:`var(--mantine-color-text)`,backgroundColor:`var(--mantine-color-body)`,border:`1px solid var(--mantine-color-default-border)`,borderRadius:`var(--mantine-radius-sm)`},".cm-tooltip-autocomplete > ul > li[aria-selected]":{color:`var(--mantine-color-accent-light-color)`,backgroundColor:`var(--mantine-color-accent-light-hover)`},".cm-diagnostic-error":{borderLeftColor:`var(--mantine-color-bad-text)`},".cm-lintRange-error":{backgroundImage:`none`,textDecoration:`underline wavy var(--mantine-color-bad-text)`,textUnderlineOffset:`3px`}}),Qm=xu.define([{tag:Y.keyword,color:`var(--mantine-color-text)`,fontWeight:`600`},{tag:[Y.string,Y.number,Y.bool],color:`var(--mantine-color-info-light-color)`},{tag:Y.comment,color:`var(--mantine-color-gray-text)`,fontStyle:`italic`},{tag:[Y.typeName,Y.standard(Y.name)],color:`var(--mantine-color-text)`}]);function $m(e,t){let n=0;for(let r of e){if(t--<=0)break;n+=r.length}return n}function eh(e,t){return Array.from(e.slice(0,t)).length}function th(e,t){let n=$m(e,t.start);return{from:n,to:Math.max(n,$m(e,t.end))}}var $=t(),nh=[],rh=[],ih=W.theme({".cm-scroller":{minHeight:`0`,maxHeight:`none`,overflow:`hidden`,fontSize:`13px`},".cm-content":{padding:`8px 4px`},".cm-tooltip.cm-tooltip-autocomplete > ul":{maxWidth:`min(700px, calc(100vw - 40px))`},".cm-tooltip:has(.cm-tooltip-lint)":{display:`none`},"@media (max-width: 600px)":{".cm-tooltip.cm-tooltip-autocomplete > ul > li":{whiteSpace:`normal`,paddingLeft:`calc(3px + 1.4em)`,textIndent:`-1.4em`},".cm-tooltip.cm-tooltip-autocomplete > ul > li .cm-completionIcon":{fontSize:`inherit`,width:`1em`,paddingRight:`0.4em`,textIndent:`0`}}}),ah=pt.define(),oh=pt.define(),sh=e=>e.message+(`hint`in e&&e.hint?` (${e.hint})`:``);function ch(e,t,n){let{start:r,end:i}=e.span,a=Array.from(e.text).length-(i-r),o=e=>e.start<=i&&r<=e.end,s=e=>e.start>=i?{start:e.start+a,end:e.end+a}:e,c=e=>e.flatMap(e=>e.span&&o(e.span)||e.fix_its?.some(e=>o(e.span))?[]:[{...e,...e.span&&{span:s(e.span)},...e.fix_its&&{fix_its:e.fix_its.map(e=>({...e,span:s(e.span)}))}}]);return{problems:c(t.filter(e=>e.span)),notices:c(n)}}function lh(e,t,n,r){let{from:i,to:a}=th(e.state.doc.toString(),t.span);e.dispatch({changes:{from:i,to:a,insert:t.text},selection:{anchor:i+t.text.length},annotations:oh.of(ch(t,n,r))}),e.focus()}function uh(e,t,n){let r=(r,i)=>{let{from:a,to:o}=r.span?th(e,r.span):{from:0,to:e.length};return{from:a,to:o,severity:i,message:sh(r),actions:(r.fix_its??[]).map(e=>({name:`Replace with ${e.label||e.text}`,apply:r=>lh(r,e,t,n)}))}};return[...t.map(e=>r(e,`error`)),...n.filter(e=>e.span).map(e=>r(e,`info`))]}function dh(e){let{value:t,problems:n=nh,notices:r=rh,readOnly:o=!1,label:l=`FanQL query`,describedBy:u}=e,d=(0,S.useRef)(null),f=(0,S.useRef)(null),p=(0,S.useRef)(e);p.current=e;let m=(0,S.useRef)(void 0),[h,g]=(0,S.useState)(),_=(0,S.useRef)(0),[v,y]=(0,S.useState)(!1),ee=(0,S.useRef)(!1),b=(0,S.useRef)(!1),x=(0,S.useRef)([]),te=(0,S.useId)(),ne=(0,S.useRef)({editable:new et,attributes:new et});(0,S.useEffect)(()=>{let{editable:e,attributes:t}=ne.current,n=async e=>{let t=p.current.complete;if(!t)return null;m.current?.abort();let n=new AbortController;m.current=n,e.addEventListener(`abort`,()=>n.abort());let r=e.state.doc.toString();g(void 0);try{let i=await t(r,eh(r,e.pos),n.signal);if(n.signal.aborted||(_.current=i.schema.error?_.current+1:0,g(_.current>=2?`Field suggestions are unavailable: the telemetry schema could not be read.`:i.schema.notice),i.items.length===0))return null;let{from:a,to:o}=th(r,i.replace);return{from:a,to:o,filter:!1,options:i.items.map(e=>({label:e.label,apply:e.insert,detail:e.detail,type:e.kind}))}}catch{return null}},r=new W({parent:d.current,state:j.create({doc:p.current.value,extensions:[pd(),Ds(),Zm,Qe.highest(ih),W.lineWrapping,j.transactionFilter.of(e=>{if(!e.docChanged||!/[\r\n]/.test(e.newDoc.toString()))return e;let t=[];return e.changes.iterChanges((e,n,r,i,a)=>t.push({from:e,to:n,insert:a.toString().replace(/\r?\n|\r/g,` `)})),[{changes:t,selection:e.selection,scrollIntoView:e.scrollIntoView}]}),e.of([]),t.of([]),Qe.highest(us.of([{key:`Mod-Enter`,run:()=>(p.current.onRun(),!0),stopPropagation:!0},{key:`Tab`,run:cm},{key:`Enter`,run:e=>b.current&&Sm(e.state)===`active`?cm(e):(um(e),p.current.onRun(),!0)},...[`ArrowDown`,`ArrowUp`,`PageDown`,`PageUp`].map(e=>({key:e,run:e=>(Sm(e.state)===`active`&&(b.current=!0),!1)}))])),ym({override:[n],activateOnTypingDelay:120}),Vs({tooltipSpace:e=>{let t=e.dom.ownerDocument.defaultView??window;return{top:0,left:16,bottom:t.innerHeight,right:t.innerWidth-16}}}),us.of([...bp.filter(e=>e.key!==`Enter`),...Md]),W.updateListener.of(e=>{if((e.docChanged||Sm(e.state)===null)&&(b.current=!1),e.docChanged&&!e.transactions.some(e=>e.annotation(ah))){let t=e.state.doc.toString();x.current.push(t);let n=e.transactions.find(e=>e.annotation(oh))?.annotation(oh);n?p.current.onChange(t,n):p.current.onChange(t)}let t=Sm(e.state)!==null;t!==ee.current&&(ee.current=t,y(t))})]})});return f.current=r,()=>{m.current?.abort(),f.current=null,r.destroy()}},[]),(0,S.useEffect)(()=>{let e=f.current,n=x.current.indexOf(t);if(n>=0){x.current.splice(0,n+1);return}x.current=[],e.state.doc.toString()!==t&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t},annotations:ah.of(!0)})},[t]),(0,S.useEffect)(()=>{f.current.dispatch({effects:ne.current.editable.reconfigure([j.readOnly.of(o),W.editable.of(!o)])})},[o]),(0,S.useEffect)(()=>{f.current.dispatch({effects:ne.current.attributes.reconfigure([W.contentAttributes.of({role:`textbox`,"aria-label":l,"aria-multiline":`false`,"aria-describedby":u??``,"aria-invalid":n.length?`true`:`false`,spellcheck:`false`}),e.placeholder?Rs(e.placeholder):[]])})},[l,u,n.length,e.placeholder]),(0,S.useEffect)(()=>{let e=f.current;e.dispatch(Om(e.state,uh(e.state.doc.toString(),n,r)))},[n,r]);let re=(e,t)=>!o&&e.fix_its?.map((e,i)=>(0,$.jsx)(c,{size:`compact-xs`,variant:`default`,fw:400,"aria-describedby":t,onClick:()=>lh(f.current,e,n,r),"data-fix-it":!0,children:(0,$.jsxs)(`span`,{children:[`Replace with `,(0,$.jsx)(`code`,{children:e.label||e.text})]})},i));return(0,$.jsxs)(`div`,{"data-fanql-editor":!0,children:[(0,$.jsx)(`div`,{ref:d}),h&&v&&(0,$.jsxs)(s,{size:`xs`,c:`dimmed`,mt:4,"data-completion-note":!0,children:[`Suggestions: `,h]}),n.length>0&&(0,$.jsx)(a,{gap:4,mt:`xs`,"data-fanql-problems":!0,children:n.map((e,t)=>(0,$.jsxs)(i,{gap:6,wrap:`wrap`,children:[(0,$.jsx)(s,{id:`${te}p${t}`,role:`alert`,size:`sm`,c:`bad`,children:sh(e)}),re(e,`${te}p${t}`)]},t))}),r.length>0&&(0,$.jsx)(a,{gap:4,mt:`xs`,"data-fanql-notices":!0,children:r.map((e,t)=>(0,$.jsxs)(i,{gap:6,wrap:`wrap`,children:[(0,$.jsx)(s,{id:`${te}n${t}`,size:`xs`,c:`dimmed`,children:e.message}),re(e,`${te}n${t}`)]},t))})]})}var fh=(e,t)=>g(`/api/fanql/parse`,{method:`POST`,json:e,signal:t}),ph=(e,t)=>g(`/api/fanql/complete`,{method:`POST`,json:e,signal:t}),mh=(e,t)=>g(`/api/fanql/format`,{method:`POST`,json:e,signal:t}),hh=80;function gh(e){let t=Array.from(e);return t.length<=hh?e:`${t.slice(0,79).join(``)}…`}function _h(e,t){if(!t.includes(e))return e;for(let n=2;;n++)if(!t.includes(`${e}_${n}`))return`${e}_${n}`}function vh({panel:e,time:t,onClose:n,onSaved:s}){let p=ne(),m=re({queryKey:ee,queryFn:x}),[h,g]=(0,S.useState)(`existing`),[_,ie]=(0,S.useState)(null),[ae,oe]=(0,S.useState)(``),[se,ce]=(0,S.useState)(gh(e.title)),[le,ue]=(0,S.useState)(!1),[de,fe]=(0,S.useState)(),pe=m.data?.length===0?`new`:h,me=se.trim()!==``&&(pe===`new`?ae.trim()!==``:_!==null),he=async()=>{if(me&&!le){ue(!0),fe(void 0);try{let n;if(pe===`new`)n=(await v({version:1,name:ae.trim(),time:t.from&&t.to?{from:t.from,to:t.to}:{range:t.range??`1h`},panels:[{...e,id:`explore`,title:se.trim()}]})).id;else{let t=await y(_),r={...e,id:_h(`explore`,t.spec.panels.map(e=>e.id)),title:se.trim()};await b(t.id,[{op:`add_panel`,panel:r}],t.version,`Added ${r.title} from Explore`),n=t.id}p.invalidateQueries({queryKey:ee}),p.invalidateQueries({queryKey:[`dashboard`,n]}),s(n)}catch(e){e instanceof te&&e.code===`dashboard_version_conflict`?fe(`Someone saved that dashboard a moment ago. Save again to add the panel to the latest version.`):e instanceof te&&e.problems.length>0?fe(e.problems.map(e=>e.message).join(` `)):fe(e instanceof Error?e.message:`Save failed`)}finally{ue(!1)}}};return(0,$.jsx)(r,{opened:!0,onClose:()=>{le||n()},title:`Save to dashboard`,children:(0,$.jsxs)(a,{gap:`md`,children:[m.data&&m.data.length>0&&(0,$.jsx)(d,{fullWidth:!0,value:pe,onChange:e=>g(e===`new`?`new`:`existing`),data:[{value:`existing`,label:`Existing dashboard`},{value:`new`,label:`New dashboard`}]}),pe===`existing`?(0,$.jsx)(f,{label:`Dashboard`,placeholder:`Choose a dashboard`,searchable:!0,value:_,onChange:ie,data:(m.data??[]).map(e=>({value:e.id,label:e.name}))}):(0,$.jsx)(u,{label:`Dashboard name`,value:ae,onChange:e=>oe(e.currentTarget.value),"data-autofocus":!0}),(0,$.jsx)(u,{label:`Panel title`,value:se,onChange:e=>ce(e.currentTarget.value)}),m.error&&(0,$.jsx)(o,{children:(0,$.jsx)(l,{tone:`danger`,children:`Dashboards could not be loaded.`})}),de&&(0,$.jsx)(o,{children:(0,$.jsx)(l,{tone:`danger`,title:`Not saved`,children:de})}),(0,$.jsxs)(i,{justify:`flex-end`,gap:`xs`,children:[(0,$.jsx)(c,{variant:`default`,disabled:le,onClick:n,children:`Cancel`}),(0,$.jsx)(c,{loading:le,disabled:!me,onClick:()=>void he(),children:`Save`})]})]})})}export{K as A,jc as B,su as C,gl as D,Wl as E,q as F,j as H,W as I,Ds as L,zc as M,Rc as N,Y as O,cl as P,Ps as R,bu as S,Tu as T,Qe as U,et as V,ie as W,Md as _,mh as a,Lu as b,Qm as c,ym as d,wp as f,pd as g,bp as h,ph as i,G as j,Nc as k,Zm as l,Tp as m,gh as n,fh as o,bm as p,_h as r,dh as s,vh as t,Om as u,Ul as v,yu as w,_u as x,eu as y,us as z}; \ No newline at end of file +`))};if((F.mac||F.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:C.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);_a(e,u,D.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=In(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(ithis.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},W=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||ir(e.parent)||document,this.viewState=new jo(this,e.state||j.create(e)),e.scrollTo&&e.scrollTo.is(Wr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Jr).map(e=>new Xr(e));for(let e of this.plugins)e.update(this);this.observer=new Zo(this),this.inputState=new Ca(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Li(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof A?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(to))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=no(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(j.phrases)!=this.state.facet(j.phrases))return this.setState(a);i=li.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new Ur(t.empty?t:D.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(Wr)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=is.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(si)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(Vo)!=i.state.facet(Vo)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(Fr))try{e(i)}catch(e){B(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!ga(this,u)&&l.force&&rr(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new jo(this,e),this.plugins=e.facet(Jr).map(e=>new Xr(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Li(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Jr),n=e.state.facet(Jr);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Xr(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a,scaleY:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(or(n||this.win))i=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}o=this.viewState.scaleY}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let c=[];s&4||([this.measureRequests,c]=[c,this.measureRequests]);let l=c.map(e=>{try{return e.read(this)}catch(e){return B(this.state,e),rs}}),u=li.create(this,this.state,[]),d=!1;u.flags|=s,t?t.flags|=s:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let e=0;e1||e<-1)&&!(F.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(Fr))e(t)}get themeClasses(){return Uo+` `+(this.state.facet(Ho)?Go:Wo)+` `+this.state.facet(Vo)}updateAttrs(){let e=as(this,Zr,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Kr)?`true`:`false`,class:`cm-content`,style:`${F.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),as(this,Qr,t);let n=this.observer.ignore(()=>{let n=En(this.contentDOM,this.contentAttrs,t),r=En(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&=(this.announceDOM.textContent=``,this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=`\xA0`},200),!1);let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(si);let t=this.state.facet(e.cspNonce);en.mount(this.root,this.styleModules.concat(Jo).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tt.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return aa(this,e,ea(this,e,t,n))}moveByGroup(e,t){return aa(this,e,ea(this,e,t,t=>ta(this,e.head,t)))}visualLineSide(e,t){return t?D.cursor(e.to,1):D.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return $i(this,e,t,n)}moveVertically(e,t,n){return aa(this,e,na(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=sa(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),sa(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[yr.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&i.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+i.from,t=1):(e=n.from+i.to,t=-1)),this.docView.coordsAt(e,t,i.dir==R.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Br)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ns)return Dr(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||br(r.isolates,n=ii(this,e))))return r.order;n||=ii(this,e);let r=Er(e.text,t,n);return this.bidiCache.push(new is(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||F.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{er(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Wr.of(new Ur(typeof e==`number`?D.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Wr.of(new Ur(D.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Yr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Yr.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=en.newName(),r=[Vo.of(n),si.of(qo(`.${n}`,e))];return t&&t.dark&&r.push(Ho.of(!0)),r}static baseTheme(e){return Qe.lowest(si.of(qo(`.`+Uo,e,Ko)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&V.get(t)||V.get(e))?.root?.view||null}};W.styleModule=si,W.inputHandler=Ir,W.clipboardInputFilter=Rr,W.clipboardOutputFilter=zr,W.scrollHandler=Hr,W.focusChangeEffect=Lr,W.perLineTextDirection=Br,W.exceptionSink=Pr,W.updateListener=Fr,W.editable=Kr,W.mouseSelectionStyle=Nr,W.dragMovesSelection=Mr,W.clickAddsSelectionRange=jr,W.decorations=$r,W.blockWrappers=ei,W.outerDecorations=ti,W.atomicRanges=ni,W.bidiIsolatedRanges=ri,W.cursorScrollMargin=O.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),W.scrollMargins=ai,W.darkTheme=Ho,W.cspNonce=O.define({combine:e=>e.length?e[0]:``}),W.contentAttributes=Qr,W.editorAttributes=Zr,W.lineWrapping=W.contentAttributes.of({class:`cm-lineWrapping`}),W.announce=k.define();var ns=4096,rs={},is=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:R.LTR;for(let a=Math.max(0,t.length-10);a=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&Sn(a,n)}return n}var os=F.mac?`mac`:F.windows?`win`:F.linux?`linux`:`key`;function ss(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;ee.concat(t),[]))),n}var ps=null,ms=4e3;function hs(e,t=os){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>ss(e,t));for(let t=1;t{let r=ps={view:t,prefix:n,scope:e};return setTimeout(()=>{ps==r&&(ps=null)},ms),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,gs))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var gs=null;function _s(e,t,n,r){gs=t;let i=ln(t),a=je(ke(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;ps&&ps.view==n&&ps.scope==r&&(o=ps.prefix+` `,ka.indexOf(t.keyCode)<0&&(c=!0,ps=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+cs(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(F.windows&&t.ctrlKey&&t.altKey)&&!(F.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=rn[t.keyCode])&&p!=i?(d(f[o+cs(p,t,!0)])||t.shiftKey&&(m=an[t.keyCode])!=i&&m!=p&&d(f[o+cs(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+cs(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),gs=null,s}var vs=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=ys(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}return xs(t,n,r)}};function ys(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==R.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function bs(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function xs(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==R.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=ys(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=Qi(e,r,1),m=Qi(e,i,-1),h=p.type==I.Text?p:null,g=m.type==I.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=bs(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=bs(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):ee(p,!1),r=g?y(null,n.to,g):ee(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2l&&r.from=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function ee(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function Ss(e,t){return e.constructor==t.constructor&&e.eq(t)}var Cs=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(ws)!=e.state.facet(ws)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(ws);for(;t!Ss(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,F.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},ws=O.define();function Ts(e){return[Yr.define(t=>new Cs(t,e)),ws.of(e)]}var Es=O.define({combine(e){return kt(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Ds(e={}){return[Es.of(e),ks,js,Ns,Vr.of(!0)]}function Os(e){return e.startState.facet(Es)!=e.state.facet(Es)}var ks=Ts({above:!0,markers(e){let{state:t}=e,n=t.facet(Es),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&F.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:D.cursor(i.head,i.assoc);for(let i of vs.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=Os(e);return n&&As(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){As(t.state,e)},class:`cm-cursorLayer`});function As(e,t){t.style.animationDuration=e.facet(Es).cursorBlinkRate+`ms`}var js=Ts({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of vs.forRange(e,`cm-selectionBackground`,n))t.push(r);if(F.ios&&!n.empty&&e.state.facet(Es).iosSelectionHandles){for(let r of vs.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,D.cursor(n.from,1)))t.push(r);for(let r of vs.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,D.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Os(e)},class:`cm-selectionLayer`}),Ms=F.gecko&&F.gecko_version==153?`#ffffff01`:`transparent`,Ns=Qe.highest(W.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${Ms} !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}}));/x/.unicode;function Ps(){return Is}var Fs=L.line({class:`cm-activeLine`}),Is=Yr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Fs.range(i.from)),t=i.from)}return L.set(n)}},{decorations:e=>e.decorations}),Ls=class extends On{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?zn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Gn(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function Rs(e){let t=Yr.fromClass(class{constructor(t){this.view=t,this.placeholder=e?L.set([L.widget({widget:new Ls(e),side:1}).range(0)]):L.none}get decorations(){return this.view.state.doc.length?L.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,W.contentAttributes.of({"aria-placeholder":e})]:t}var zs=`-10000px`,Bs=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;nt[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function Vs(e={}){return Us.of(e)}function Hs(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var Us=O.define({combine:e=>({position:F.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||Hs})}),Ws=new WeakMap,Gs=Yr.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(Us);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Bs(e,Ys,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(Us);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=zs,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(F.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}let r=this.view.scrollDOM.getBoundingClientRect(),i=oi(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Us).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o=Math.min(t.bottom,n.bottom)||u.rightMath.min(t.right,n.right)+.1)){l.style.top=zs;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=Ws.get(c)??d.bottom-d.top,g=c.offset||Js,_=this.view.textDirection==R.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.yn.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let ee=(y?u.top-n.top:n.bottom-u.bottom)-p;if(eev&&e.topb&&(b=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(b-e.parent.top)/i+`px`,Ks(l,(v-e.parent.left)/r)):(l.style.top=b/i+`px`,Ks(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:b,right:x,bottom:b+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=zs}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ks(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var qs=W.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),Js={x:0,y:0},Ys=O.define({enables:[Gs,qs]}),Xs=O.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),Zs=class e{static create(t){return new e(t)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement(`div`),this.dom.classList.add(`cm-tooltip-hover`),this.manager=new Bs(e,Xs,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add(`cm-tooltip-section`),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)==null||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp(`offset`)}get getCoords(){return this.passProp(`getCoords`)}get overlap(){return this.passProp(`overlap`)}get resize(){return this.passProp(`resize`)}},Qs=Ys.compute([Xs],e=>{let t=e.facet(Xs);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:Zs.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),$s=O.define(),ec=class{constructor(e,t,n,r,i,a){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener(`mouseleave`,this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener(`mousemove`,this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;en.bottom||t.xn.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),o=a&&a.dir==R.RTL?-1:1;i=t.x{if(t&&(!Array.isArray(t)||t.length)){let n=Array.isArray(t)?t:[t];r&&this.locked.set(n,r),e.dispatch({effects:this.setHover.of(n)})}};if(i&&`then`in i){let n=this.pending={pos:t};i.then(e=>{this.pending==n&&(this.pending=null,a(e))},t=>B(e.state,t,`hover tooltip`))}else a(i)}get tooltip(){let e=this.view.plugin(Gs),t=e?e.manager.tooltips.findIndex(e=>e.create==Zs.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:t,tooltip:n}=this;if(t.length&&!this.locked.has(t)&&n&&!nc(n.dom,e)||this.pending){let{pos:n}=t[0]||this.pending,r=t[0]?.end??n;(n==r?this.view.posAtCoords(this.lastMove)!=n:!rc(this.view,n,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener(`mouseleave`,t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener(`mouseleave`,t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener(`mouseleave`,this.mouseleave),this.view.dom.removeEventListener(`mousemove`,this.mousemove)}},tc=4;function nc(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(`.cm-tooltip-arrow`)){let e=o.getBoundingClientRect();i=Math.min(e.top,i),a=Math.max(e.bottom,a)}return t.clientX>=n-tc&&t.clientX<=r+tc&&t.clientY>=i-tc&&t.clientY<=a+tc}function rc(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,s)=t&&c<=n}function ic(e,t={}){let n=k.define(),r=new WeakMap,i=Ye.define({create(){return[]},update(e,a){let o=r.get(e);if(e.length&&(t.hideOnChange&&(a.docChanged||a.selection)||o&&o(a)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(a,e)))),a.docChanged&&e.length){let t=[];for(let n of e){let e=a.changes.mapPos(n.pos,-1,T.TrackDel);if(e!=null){let r=Object.assign(Object.create(null),n);r.pos=e,r.end!=null&&(r.end=a.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of a.effects)t.is(n)&&(e=t.value,o=void 0),(t.is(oc)&&!t.value||t.value==i)&&(e=[]);return e.length&&o&&r.set(e,o),e},provide:e=>Xs.from(e)}),a=Yr.define(a=>new ec(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,a,$s.of(a),Qs]}}function ac(e,t){let n=e.plugin(Gs);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var oc=k.define(),sc=O.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}}),cc=Yr.fromClass(class{constructor(e){this.input=e.state.facet(dc),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(sc);this.top=new lc(e,!0,t.topContainer),this.bottom=new lc(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(sc);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new lc(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new lc(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(dc);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>W.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),lc=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=uc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=uc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function uc(e){let t=e.nextSibling;return e.remove(),t}var dc=O.define({enables:cc}),fc=class extends At{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};fc.prototype.elementClass=``,fc.prototype.toDOM=void 0,fc.prototype.mapMode=T.TrackBefore,fc.prototype.startSide=fc.prototype.endSide=-1,fc.prototype.point=!0;var pc=O.define(),mc=O.define(),hc=O.define(),gc=O.define({combine:e=>e.some(e=>e)});function _c(e){let t=[vc];return e&&e.fixed===!1&&t.push(gc.of(!0)),t}var vc=Yr.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(hc).map(t=>new Sc(e,t)),this.fixed=!e.state.facet(gc);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(gc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=M.iter(this.view.state.facet(pc),this.view.viewport.from),r=[],i=this.gutters.map(e=>new xc(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==I.Text&&t){bc(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==I.Text){bc(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(hc),n=e.state.facet(hc),r=e.docChanged||e.heightChanged||e.viewportChanged||!M.eq(e.startState.facet(pc),e.state.facet(pc),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Sc(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>W.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==R.LTR?{left:r,right:i}:{right:r,left:i}})});function yc(e){return Array.isArray(e)?e:[e]}function bc(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var xc=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=M.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Cc(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];bc(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;(r.length!=0||a.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(mc)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Sc=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=yc(t.markers(e)),t.initialSpacer&&(this.spacer=new Cc(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=yc(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!M.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Cc=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),wc(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=ir(e,t,n)||i(e,t,n):i}return n}})}}),Oc=class extends fc{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function kc(e,t){return e.state.facet(Dc).formatNumber(t,e.state)}var Ac=hc.compute([Dc],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Tc)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new Oc(kc(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Ec)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Dc)!=e.state.facet(Dc),initialSpacer(e){return new Oc(kc(e,Mc(e.state.doc.lines)))},updateSpacer(e,t){let n=kc(t.view,Mc(t.view.state.doc.lines));return n==e.number?e:new Oc(n)},domEventHandlers:e.facet(Dc).domEventHandlers,side:`before`}));function jc(e={}){return[Dc.of(e),_c(),Ac]}function Mc(e){let t=9;for(;t{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=Rc.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};G.closedBy=new G({deserialize:e=>e.split(` `)}),G.openedBy=new G({deserialize:e=>e.split(` `)}),G.group=new G({deserialize:e=>e.split(` `)}),G.isolate=new G({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),G.contextHash=new G({perNode:!0}),G.lookAhead=new G({perNode:!0}),G.mounted=new G({perNode:!0});var Ic=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[G.mounted.id]}},Lc=Object.create(null),Rc=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):Lc,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(G.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(G.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};Rc.none=new Rc(``,Object.create(null),0,8);var zc=class e{constructor(e){this.types=e;for(let t=0;t0;for(let e=this.cursor(a|K.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:ol(Rc.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(Rc.none,t,n,r)))}static build(e){return rl(e)}};q.empty=new q(Rc.none,[],[],0);var Hc=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},Uc=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Rc.none}toString(){let e=[];for(let t=0;t0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e=t&&nt;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Gc(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&K.EnterBracketed&&l instanceof q&&(d=Ic.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||Wc(i,r,u,u+l.length)){if(l instanceof Uc){if(a&K.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new Zc(new Xc(o,l,t,u),null,e)}else if(a&K.IncludeAnonymous||!l.type.isAnonymous||nl(l)){let s;if(!(a&K.IgnoreMounts)&&(s=Ic.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&K.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&K.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&K.IgnoreOverlays)&&(i=Ic.get(this._tree))&&i.overlay){let a=t-this.from,o=r&K.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Jc(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function Yc(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var Xc=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Zc=class e extends Kc{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&K.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new q(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Qc(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;rn.from||i.to=t){let o=new qc(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(Gc(o,t,n,!1))}}return i?Qc(i):r}var tl=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~K.EnterBracketed,e instanceof qc)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof qc?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&K.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&K.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&K.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&K.IncludeAnonymous||e instanceof Uc||!e.type.isAnonymous||nl(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e=0;i--){if(i<0)return Yc(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function nl(e){return e.children.some(e=>e instanceof Uc||!e.type.isAnonymous||nl(e))}function rl(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Nc,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new Hc(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,ee){let{id:b,start:x,end:te,size:ne}=o,re=l,ie=c;if(ne<0){if(o.next(),ne==-1){let t=i[b];_.push(t),v.push(x-e);return}if(ne==-3){c=b;return}if(ne==-4){l=b;return}throw RangeError(`Unrecognized record size: ${ne}`)}let S=s[b],ae,oe,se=x-e;if(te-x<=r&&(oe=h(o.pos-t,y))){let t=new Uint16Array(oe.size-oe.skip),r=o.pos-oe.size,i=t.length;for(;o.pos>r;)i=g(oe.start,t,i);ae=new Uc(t,te-oe.start,n),se=oe.start-e}else{let e=o.pos-ne;o.next();let t=[],n=[],i=b>=a?b:-1,s=0,c=te;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,x,s,o.end,c,i,re,ie),s=t.length,c=o.end),o.next()):ee>2500?d(x,e,t,n):u(x,e,t,n,i,ee+1);if(i>=0&&s>0&&s-1&&s>0){let e=f(S,ie);ae=ol(S,t,n,0,t.length,0,te-x,e,e)}else ae=m(S,t,n,te-x,re-te,ie)}_.push(ae),v.push(se)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new Uc(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof q){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(G.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[G.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[G.lookAhead,i];o=o?[e].concat(o):[e]}return new q(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new q(s[e.topID],_.reverse(),v.reverse(),y)}var il=new WeakMap;function al(e,t){if(!e.isAnonymous||t instanceof Uc||t.type!=e)return 1;let n=il.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof q)){n=1;break}n+=al(e,r)}il.set(t,n)}return n}function ol(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(ol(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var sl=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s=r)for(;o&&o.from=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=anew Fc(e.from,e.to)):[new Fc(0,0)]:[new Fc(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},ll=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new G({perNode:!0});var ul=0,dl=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=ul++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new pl(e);return e=>e.modified.indexOf(t)>-1?e:pl.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},fl=0,pl=class e{constructor(e){this.name=e,this.instances=[],this.id=fl++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&ml(n,e.modified));if(r)return r;let i=[],a=new dl(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=hl(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function ml(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function hl(e){let t=[[]];for(let n=0;nt.length-e.length)}function gl(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new vl(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return _l.add(t)}var _l=new G({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new vl(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),vl=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function bl(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function xl(e,t,n,r=0,i=e.length){let a=new Sl(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Sl=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Cl(e)||vl.empty,u=bl(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(G.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Cl(e){let t=e.type.prop(_l);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var J=dl.define,wl=J(),Tl=J(),El=J(Tl),Dl=J(Tl),Ol=J(),kl=J(Ol),Al=J(Ol),jl=J(),Ml=J(jl),Nl=J(),Pl=J(),Fl=J(),Il=J(Fl),Ll=J(),Y={comment:wl,lineComment:J(wl),blockComment:J(wl),docComment:J(wl),name:Tl,variableName:J(Tl),typeName:El,tagName:J(El),propertyName:Dl,attributeName:J(Dl),className:J(Tl),labelName:J(Tl),namespace:J(Tl),macroName:J(Tl),literal:Ol,string:kl,docString:J(kl),character:J(kl),attributeValue:J(kl),number:Al,integer:J(Al),float:J(Al),bool:J(Ol),regexp:J(Ol),escape:J(Ol),color:J(Ol),url:J(Ol),keyword:Nl,self:J(Nl),null:J(Nl),atom:J(Nl),unit:J(Nl),modifier:J(Nl),operatorKeyword:J(Nl),controlKeyword:J(Nl),definitionKeyword:J(Nl),moduleKeyword:J(Nl),operator:Pl,derefOperator:J(Pl),arithmeticOperator:J(Pl),logicOperator:J(Pl),bitwiseOperator:J(Pl),compareOperator:J(Pl),updateOperator:J(Pl),definitionOperator:J(Pl),typeOperator:J(Pl),controlOperator:J(Pl),punctuation:Fl,separator:J(Fl),bracket:Il,angleBracket:J(Il),squareBracket:J(Il),paren:J(Il),brace:J(Il),content:jl,heading:Ml,heading1:J(Ml),heading2:J(Ml),heading3:J(Ml),heading4:J(Ml),heading5:J(Ml),heading6:J(Ml),contentSeparator:J(jl),list:J(jl),quote:J(jl),emphasis:J(jl),strong:J(jl),link:J(jl),monospace:J(jl),strikethrough:J(jl),inserted:J(),deleted:J(),changed:J(),invalid:J(),meta:Ll,documentMeta:J(Ll),annotation:J(Ll),processingInstruction:J(Ll),definition:dl.defineModifier(`definition`),constant:dl.defineModifier(`constant`),function:dl.defineModifier(`function`),standard:dl.defineModifier(`standard`),local:dl.defineModifier(`local`),special:dl.defineModifier(`special`)};for(let e in Y){let t=Y[e];t instanceof dl&&(t.name=e)}yl([{tag:Y.link,class:`tok-link`},{tag:Y.heading,class:`tok-heading`},{tag:Y.emphasis,class:`tok-emphasis`},{tag:Y.strong,class:`tok-strong`},{tag:Y.keyword,class:`tok-keyword`},{tag:Y.atom,class:`tok-atom`},{tag:Y.bool,class:`tok-bool`},{tag:Y.url,class:`tok-url`},{tag:Y.labelName,class:`tok-labelName`},{tag:Y.inserted,class:`tok-inserted`},{tag:Y.deleted,class:`tok-deleted`},{tag:Y.literal,class:`tok-literal`},{tag:Y.string,class:`tok-string`},{tag:Y.number,class:`tok-number`},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:`tok-string2`},{tag:Y.variableName,class:`tok-variableName`},{tag:Y.local(Y.variableName),class:`tok-variableName tok-local`},{tag:Y.definition(Y.variableName),class:`tok-variableName tok-definition`},{tag:Y.special(Y.variableName),class:`tok-variableName2`},{tag:Y.definition(Y.propertyName),class:`tok-propertyName tok-definition`},{tag:Y.typeName,class:`tok-typeName`},{tag:Y.namespace,class:`tok-namespace`},{tag:Y.className,class:`tok-className`},{tag:Y.macroName,class:`tok-macroName`},{tag:Y.propertyName,class:`tok-propertyName`},{tag:Y.operator,class:`tok-operator`},{tag:Y.comment,class:`tok-comment`},{tag:Y.meta,class:`tok-meta`},{tag:Y.invalid,class:`tok-invalid`},{tag:Y.punctuation,class:`tok-punctuation`}]);var Rl=new G;function zl(e){return O.define({combine:e?t=>t.concat(e):void 0})}var Bl=new G,Vl=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,j.prototype.hasOwnProperty(`tree`)||Object.defineProperty(j.prototype,"tree",{get(){return Wl(this)}}),this.parser=t,this.extension=[$l.of(this),j.languageData.of((e,t,n)=>{let r=Hl(e,t,n),i=r.type.prop(Rl);if(!i)return[];let a=e.facet(i),o=r.type.prop(Bl);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return Hl(e,t,n).type.prop(Rl)==this.data}findRegions(e){let t=e.facet($l);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(Rl)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(G.mounted);if(i){if(i.tree.prop(Rl)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;ne.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Wl(e){let t=e.field(Vl.state,!1);return t?t.tree:q.empty}var Gl=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Kl=null,ql=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],q.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Gl(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=q.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(sl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Kl;Kl=this;try{return e()}finally{Kl=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Jl(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=sl.applyChanges(r,e),i=q.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);ne.from&&(this.fragments=Jl(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends cl{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=Kl;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new q(Rc.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Kl}};function Jl(e,t,n){return sl.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Yl=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=ql.create(t.facet($l).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};Vl.state=Ye.define({create:Yl.init,update(e,t){for(let e of t.effects)if(e.is(Vl.setState))return e.value;return t.startState.facet($l)==t.state.facet($l)?e.apply(t):Yl.init(t.state)}});var Xl=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Xl=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Zl=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,Ql=Yr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Vl.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Vl.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Xl(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,s=i.context.work(()=>Zl&&Zl()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Vl.setState.of(new Yl(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>B(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),$l=O.define({combine(e){return e.length?e[0]:null},enables:e=>[Vl.state,Ql,W.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),eu=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},tu=O.define(),nu=O.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function ru(e){let t=e.facet(nu);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function iu(e,t){let n=``,r=e.tabSize,i=e.facet(nu)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e=t?cu(e,n,t):null}var ou=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=ru(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Jt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},su=new G;function cu(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.fromr.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return lu(r,e,n)}function lu(e,t,n){for(let r=e;r;r=r.next){let e=du(r.node);if(e)return e(pu.create(t,n,r))}return 0}function uu(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function du(e){let t=e.type.prop(su);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(G.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>gu(e,!0,1,void 0,n&&!uu(e)?t.from:void 0)}return e.parent==null?fu:null}function fu(){return 0}var pu=class e extends ou{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(mu(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return lu(this.context.next,this.base,this.pos)}};function mu(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function hu(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function gu(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?hu(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function _u({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var vu=200;function yu(){return j.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+vu)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=au(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=iu(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var bu=new G,xu=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=en.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof Vl?e=>e.prop(Rl)==a.data:a?e=>e==a:void 0,this.style=yl(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new en(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},Su=O.define(),Cu=O.define({combine(e){return e.length?[e[0]]:null}});function wu(e){let t=e.facet(Su);return t.length?t:e.facet(Cu)}function Tu(e,t){let n=[Du],r;return e instanceof xu&&(e.module&&n.push(W.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Cu.of(e)):r?n.push(Su.computeN([W.darkTheme],t=>t.facet(W.darkTheme)==(r==`dark`)?[e]:[])):n.push(Su.of(e)),n}var Eu=class{constructor(e){this.markCache=Object.create(null),this.tree=Wl(e.state),this.decorations=this.buildDeco(e,wu(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Wl(e.state),n=wu(e.state),r=n!=wu(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return L.none;let n=new Lt;for(let{from:r,to:i}of e.visibleRanges)xl(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=L.mark({class:r})))},r,i);return n.finish()}},Du=Qe.high(Yr.fromClass(Eu,{decorations:e=>e.decorations}));Y.meta,Y.link,Y.heading,Y.emphasis,Y.strong,Y.strikethrough,Y.keyword,Y.atom,Y.bool,Y.url,Y.contentSeparator,Y.labelName,Y.literal,Y.inserted,Y.string,Y.deleted,Y.regexp,Y.escape,Y.string,Y.variableName,Y.variableName,Y.typeName,Y.namespace,Y.className,Y.variableName,Y.macroName,Y.propertyName,Y.comment,Y.invalid;var Ou=W.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),ku=1e4,Au=`()[]{}`,ju=O.define({combine(e){return kt(e,{afterCursor:!0,brackets:Au,maxScanDistance:ku,renderMatch:Pu})}}),Mu=L.mark({class:`cm-matchingBracket`}),Nu=L.mark({class:`cm-nonmatchingBracket`});function Pu(e){let t=[],n=e.matched?Mu:Nu;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function Fu(e){let t=[],n=e.facet(ju);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Vu(e,r.head,-1,n)||r.head>0&&Vu(e,r.head-1,1,n)||n.afterCursor&&(Vu(e,r.head,1,n)||r.heade.decorations}),Ou];function Lu(e={}){return[ju.of(e),Iu]}var Ru=new G;function zu(e,t,n){let r=e.prop(t<0?G.openedBy:G.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function Bu(e){let t=e.type.prop(Ru);return t?t(e.node):e}function Vu(e,t,n,r={}){let i=r.maxScanDistance||ku,a=r.brackets||Au,o=Wl(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=zu(r.type,n,a);if(i&&r.from0?t>=o.from&&to.from&&t<=o.to))return Hu(e,t,n,r,o,i,a)}}return Uu(e,t,n,o,s.type,i,a)}function Hu(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var Wu=Object.create(null),Gu=[Rc.none],Ku=[],qu=Object.create(null),Ju=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])Ju[e]=Xu(Wu,t);function Yu(e,t){Ku.indexOf(e)>-1||(Ku.push(e),console.warn(t))}function Xu(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Y[n];r?typeof r==`function`?t.length?t=t.map(r):Yu(n,`Modifier ${n} used at start of tag`):t.length?Yu(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Yu(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=qu[i];if(a)return a.id;let o=qu[i]=Rc.define({id:Gu.length,name:r,props:[gl({[r]:n})]});return Gu.push(o),o.id}R.RTL,R.LTR;var Zu=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=nd(e.state,n.from);return r.line?$u(e):r.block?td(e):!1};function Qu(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var $u=Qu(sd,0),ed=Qu(od,0),td=Qu((e,t)=>od(e,t,ad(t)),0);function nd(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var rd=50;function id(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-rd,r),o=e.sliceDoc(i,i+rd),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+rd),d=e.sliceDoc(i-rd,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function ad(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function od(e,t,n=t.selection.ranges){let r=n.map(e=>nd(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>id(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;ti&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var cd=pt.define(),ld=pt.define(),ud=O.define(),dd=O.define({combine(e){return kt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),fd=Ye.define({create(){return jd.empty},update(e,t){let n=t.state.facet(dd),r=t.annotation(cd);if(r){let i=yd.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?bd(o,o.length,n.minDepth,i):Ed(o,t.startState.selection),new jd(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(ld);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(A.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=yd.fromTransaction(t),o=t.annotation(A.time),s=t.annotation(A.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new jd(e.done.map(yd.fromJSON),e.undone.map(yd.fromJSON))}});function pd(e={}){return[fd,dd.of(e),W.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?hd:e.inputType==`historyRedo`?gd:null;return n?(e.preventDefault(),n(t)):!1}})]}function md(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(fd,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var hd=md(0,!1),gd=md(1,!1),_d=md(0,!0),vd=md(1,!0),yd=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&Pe.fromJSON(t.changes),[],t.mapped&&Ne.fromJSON(t.mapped),t.startSelection&&D.fromJSON(t.startSelection),t.selectionsAfter.map(D.fromJSON))}static fromTransaction(t,n){let r=wd;for(let e of t.startState.facet(ud)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,wd)}static selection(t){return new e(void 0,wd,void 0,void 0,t)}};function bd(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function xd(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e=t&&i<=o&&(r=!0)}}),r}function Sd(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function Cd(e,t){return e.length?t.length?e.concat(t):e:t}var wd=[],Td=200;function Ed(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Td));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),bd(e,e.length-1,1e9,n.setSelAfter(r)))}return[yd.selection([t])]}function Dd(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Od(e,t){if(!e.length)return e;let n=e.length,r=wd;for(;n;){let i=kd(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[yd.selection(r)]:wd}function kd(e,t,n){let r=Cd(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):wd,n);if(!e.changes)return yd.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new yd(i,k.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Ad=/^(input\.type|delete)($|\.)/,jd=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Ad.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):Id(n,t))}function X(e){return e.textDirectionAt(e.state.selection.main.head)==R.LTR}var Rd=e=>Ld(e,!X(e)),zd=e=>Ld(e,X(e));function Bd(e,t){return Fd(e,n=>n.empty?e.moveByGroup(n,t):Id(n,t))}var Vd=e=>Bd(e,!X(e)),Hd=e=>Bd(e,X(e));typeof Intl<`u`&&Intl.Segmenter;function Ud(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Wd(e,t,n){let r=Wl(e).resolveInner(t.head),i=n?G.closedBy:G.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Ud(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?Vu(e,r.from,1):Vu(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,D.cursor(s,n?-1:1)}var Gd=e=>Fd(e,t=>Wd(e.state,t,!X(e))),Kd=e=>Fd(e,t=>Wd(e.state,t,X(e)));function qd(e,t){return Fd(e,n=>{if(!n.empty)return Id(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Jd=e=>qd(e,!1),Yd=e=>qd(e,!0);function Xd(e){let t=e.scrollDOM.clientHeightr.empty?e.moveVertically(r,t,n.height):Id(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottomZd(e,!1),$d=e=>Zd(e,!0);function ef(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=D.cursor(r.from+n))}return i}var tf=e=>Fd(e,t=>ef(e,t,!0)),nf=e=>Fd(e,t=>ef(e,t,!1)),rf=e=>Fd(e,t=>ef(e,t,!X(e))),af=e=>Fd(e,t=>ef(e,t,X(e))),of=e=>Fd(e,t=>e.moveToLineBoundary(t,!1,!1)),sf=e=>Fd(e,t=>e.moveToLineBoundary(t,!0,!1));function cf(e,t,n){let r=!1,i=Nd(e.selection,t=>{let i=Vu(e,t.head,-1)||Vu(e,t.head,1)||t.head>0&&Vu(e,t.head-1,1)||t.headcf(e,t,!1);function uf(e,t,n){let r=Nd(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=D.range(e.head,e.anchor));let r=n(e);return D.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(Pd(e.state,r)),!0)}function df(e,t){return uf(e,t,n=>e.moveByChar(n,t))}var ff=e=>df(e,!X(e)),pf=e=>df(e,X(e));function mf(e,t){return uf(e,t,n=>e.moveByGroup(n,t))}var hf=e=>mf(e,!X(e)),gf=e=>mf(e,X(e)),_f=e=>{let t=!X(e);return uf(e,t,n=>Wd(e.state,n,t))},vf=e=>{let t=X(e);return uf(e,t,n=>Wd(e.state,n,t))};function yf(e,t){return uf(e,t,n=>e.moveVertically(n,t))}var bf=e=>yf(e,!1),xf=e=>yf(e,!0);function Sf(e,t){return uf(e,t,n=>e.moveVertically(n,t,Xd(e).height))}var Cf=e=>Sf(e,!1),wf=e=>Sf(e,!0),Tf=e=>uf(e,!0,t=>ef(e,t,!0)),Ef=e=>uf(e,!1,t=>ef(e,t,!1)),Df=e=>{let t=!X(e);return uf(e,t,n=>ef(e,n,t))},Of=e=>{let t=X(e);return uf(e,t,n=>ef(e,n,t))},kf=e=>uf(e,!1,t=>D.cursor(e.lineBlockAt(t.head).from)),Af=e=>uf(e,!0,t=>D.cursor(e.lineBlockAt(t.head).to)),jf=({state:e,dispatch:t})=>(t(Pd(e,{anchor:0})),!0),Mf=({state:e,dispatch:t})=>(t(Pd(e,{anchor:e.doc.length})),!0),Nf=({state:e,dispatch:t})=>(t(Pd(e,{anchor:e.selection.main.anchor,head:0})),!0),Pf=({state:e,dispatch:t})=>(t(Pd(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Ff=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),If=({state:e,dispatch:t})=>{let n=tp(e).map(({from:t,to:n})=>D.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:D.create(n),userEvent:`select`})),!0},Lf=({state:e,dispatch:t})=>{let n=Nd(e.selection,t=>{let n=Wl(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return D.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(Pd(e,n)),!0)};function Rf(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.heada.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(Pd(n,D.create(i,i.length-1))),!0)}var zf=e=>Rf(e,!1),Bf=e=>Rf(e,!0),Vf=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=D.create([n.main]):n.main.empty||(r=D.create([D.cursor(n.main.head)])),r?(t(Pd(e,r)),!0):!1};function Hf(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);oi&&(n=`delete.forward`,o=Uf(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Uf(e,i,!1),a=Uf(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:D.cursor(i,it(e)))r.between(t,t,(e,r)=>{et&&(t=n?r:e)});return t}var Wf=(e,t,n)=>Hf(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&iWf(e,!1,!0),Kf=e=>Wf(e,!0,!1),qf=(e,t)=>Hf(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=w(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Jf=e=>qf(e,!1),Yf=e=>qf(e,!0),Xf=e=>Hf(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headHf(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Qf=e=>Hf(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:C.of([``,``])},range:D.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},ep=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:w(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:w(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:D.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function tp(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function np(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of tp(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(D.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(D.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:D.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var rp=({state:e,dispatch:t})=>np(e,t,!1),ip=({state:e,dispatch:t})=>np(e,t,!0);function ap(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of tp(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var op=({state:e,dispatch:t})=>ap(e,t,!1),sp=({state:e,dispatch:t})=>ap(e,t,!0),cp=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(tp(t).map(({from:e,to:n})=>(e>0?e--:n{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function lp(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Wl(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(G.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var up=fp(!1),dp=fp(!0);function fp(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&lp(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new ou(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=au(s,r);for(c??=Jt(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);ia.from&&r{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:D.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var mp=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new ou(e,{overrideIndentation:e=>n[e]??-1}),i=pp(e,(t,i,a)=>{let o=au(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=iu(e,o);(s!=c||a.from!e.readOnly&&(t(e.update(pp(e,(t,n)=>{n.push({from:t.from,insert:e.facet(nu)})}),{userEvent:`input.indent`})),!0),gp=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(pp(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Jt(r,e.tabSize),a=0,o=iu(e,Math.max(0,i-ru(e)));for(;a(e.setTabFocusMode(),!0),vp=[{key:`Ctrl-b`,run:Rd,shift:ff,preventDefault:!0},{key:`Ctrl-f`,run:zd,shift:pf},{key:`Ctrl-p`,run:Jd,shift:bf},{key:`Ctrl-n`,run:Yd,shift:xf},{key:`Ctrl-a`,run:of,shift:kf},{key:`Ctrl-e`,run:sf,shift:Af},{key:`Ctrl-d`,run:Kf},{key:`Ctrl-h`,run:Gf},{key:`Ctrl-k`,run:Xf},{key:`Ctrl-Alt-h`,run:Jf},{key:`Ctrl-o`,run:$f},{key:`Ctrl-t`,run:ep},{key:`Ctrl-v`,run:$d}],yp=[{key:`ArrowLeft`,run:Rd,shift:ff,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Vd,shift:hf,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:rf,shift:Df,preventDefault:!0},{key:`ArrowRight`,run:zd,shift:pf,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Hd,shift:gf,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:af,shift:Of,preventDefault:!0},{key:`ArrowUp`,run:Jd,shift:bf,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:jf,shift:Nf},{mac:`Ctrl-ArrowUp`,run:Qd,shift:Cf},{key:`ArrowDown`,run:Yd,shift:xf,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Mf,shift:Pf},{mac:`Ctrl-ArrowDown`,run:$d,shift:wf},{key:`PageUp`,run:Qd,shift:Cf},{key:`PageDown`,run:$d,shift:wf},{key:`Home`,run:nf,shift:Ef,preventDefault:!0},{key:`Mod-Home`,run:jf,shift:Nf},{key:`End`,run:tf,shift:Tf,preventDefault:!0},{key:`Mod-End`,run:Mf,shift:Pf},{key:`Enter`,run:up,shift:up},{key:`Mod-a`,run:Ff},{key:`Backspace`,run:Gf,shift:Gf,preventDefault:!0},{key:`Delete`,run:Kf,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Jf,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Yf,preventDefault:!0},{mac:`Mod-Backspace`,run:Zf,preventDefault:!0},{mac:`Mod-Delete`,run:Qf,preventDefault:!0}].concat(vp.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),bp=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Gd,shift:_f},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Kd,shift:vf},{key:`Alt-ArrowUp`,run:rp},{key:`Shift-Alt-ArrowUp`,run:op},{key:`Alt-ArrowDown`,run:ip},{key:`Shift-Alt-ArrowDown`,run:sp},{key:`Mod-Alt-ArrowUp`,run:zf},{key:`Mod-Alt-ArrowDown`,run:Bf},{key:`Escape`,run:Vf},{key:`Mod-Enter`,run:dp},{key:`Alt-l`,mac:`Ctrl-l`,run:If},{key:`Mod-i`,run:Lf,preventDefault:!0},{key:`Mod-[`,run:gp},{key:`Mod-]`,run:hp},{key:`Mod-Alt-\\`,run:mp},{key:`Shift-Mod-k`,run:cp},{key:`Shift-Mod-\\`,run:lf},{key:`Mod-/`,run:Zu},{key:`Alt-A`,mac:`Ctrl-A`,run:ed},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:_p}].concat(yp),xp=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Wl(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(Op(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function Sp(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function Cp(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;etypeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:Cp(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Tp(e,t){return n=>{for(let t=Wl(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var Ep=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Dp(e){return e.selection.main.from}function Op(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var kp=pt.define();function Ap(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:D.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var jp=new WeakMap;function Mp(e){if(!Array.isArray(e))return e;let t=jp.get(e);return t||jp.set(e,t=wp(e)),t}var Np=k.define(),Pp=k.define(),Fp=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=Ae(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=je(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?je(ke(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},Ip=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Rp,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Lp(e(n),t(n)),optionClass:(e,t)=>n=>Lp(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Lp(e,t){return e?t?e+` `+t:e:t}function Rp(e,t,n,r,i,a){let o=e.textDirection==R.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var zp=k.define();function Bp(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;eo&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return oe.position-t.position).map(e=>e.render)}function Vp(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var Hp=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(Z);this.optionContent=Bp(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Vp(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:zp.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(Z).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Pp.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=Vp(r.length,i,e.state.facet(Z).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=Vp(t.options.length,t.selected,this.view.state.facet(Z).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>B(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Wp(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;an.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.tonew Hp(n,e,t)}function Wp(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.topn.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function Gp(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Kp(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(Z);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Ep(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Ip(n):new Fp(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Ep(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.namet.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):Gp(e.completion)>Gp(c)&&(s[s.length-1]=e),c=e.completion}return s}var qp=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,Qp(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=Kp(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(Z).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;tt.hasResult()?Math.min(e,t.from):e,1e8),create:om,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Jp=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e($p,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Z),i=(r.override||n.languageDataAt(`autocomplete`,Dp(n)).map(Mp)).map(e=>(this.active.find(t=>t.source==e)||new tm(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(im));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Yp(i,this.active)||o?a=qp.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new tm(e.source,0):e));for(let e of t.effects)e.is(zp)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Xp:Zp}};function Yp(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var $p=[];function em(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(kp);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var tm=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=em(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(Np))i=new e(i.source,1,n.value);else if(n.is(Pp))i=new e(i.source,0);else if(n.is(im))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Dp(e.state))}},nm=class e extends tm{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Dp(t.state);if(o>a||!r||n&2&&(Dp(t.startState)==this.from||oe.map(t))}}),Q=Ye.define({create(){return Jp.start()},update(e,t){return e.update(t)},provide:e=>[Ys.from(e,e=>e.tooltip),W.contentAttributes.from(e,e=>e.attrs)]});function am(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(Q).active.find(e=>e.source==t.source);return r instanceof nm&&(typeof n==`string`?e.dispatch({...Ap(e.state,n,r.from,r.to),annotations:kp.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var om=Up(Q,am);function sm(e,t=`option`){return n=>{let r=n.state.field(Q,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:zp.of(s)}),!0}}var cm=e=>{let t=e.state.field(Q,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestampe.state.field(Q,!1)?(e.dispatch({effects:Np.of(!0)}),!0):!1,um=e=>{let t=e.state.field(Q,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:Pp.of(null)}),!0)},dm=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},fm=50,pm=1e3,mm=Yr.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Q).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Q),n=e.state.facet(Z);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Q)==t)return;let r=e.transactions.some(e=>{let t=em(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;tfm&&Date.now()-n.time>pm){for(let e of n.context.abortListeners)try{e()}catch(e){B(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(Np)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Q);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Z).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new xp(t,Dp(t),e.explicit,this.view),r=new dm(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Pp.of(null)}),B(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Z).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Z),n=this.view.state.field(Q);for(let r=0;re.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new tm(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:im.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Q,!1);if(t&&t.tooltip&&this.view.state.facet(Z).closeOnBlur){let n=t.open&&ac(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Pp.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Np.of(!1)}),20),this.composing=0}}}),hm=typeof navigator==`object`&&/Win/.test(navigator.platform),gm=Qe.highest(W.domEventHandlers({keydown(e,t){let n=t.state.field(Q,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(hm&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&am(t,r),!1}})),_m=W.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),vm=new class extends At{};vm.startSide=1,vm.endSide=-1,typeof navigator==`object`&&navigator.userAgent;function ym(e={}){return[gm,Q,Z.of(e),mm,xm,_m]}var bm=[{key:`Ctrl-Space`,run:lm},{mac:"Alt-`",run:lm},{mac:`Alt-i`,run:lm},{key:`Escape`,run:um},{key:`ArrowDown`,run:sm(!0)},{key:`ArrowUp`,run:sm(!1)},{key:`PageDown`,run:sm(!0,`page`)},{key:`PageUp`,run:sm(!1,`page`)},{key:`Enter`,run:cm}],xm=Qe.highest(us.computeN([Z],e=>e.facet(Z).defaultKeymap?[bm]:[]));function Sm(e){let t=e.field(Q,!1);return t&&t.active.some(e=>e.isPending)?`pending`:t&&t.active.some(e=>e.state!=0)?`active`:null}var Cm=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},wm=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Lm).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Lt,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;et.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Jm(s);if(i)o.add(n,n,L.widget({widget:new Vm(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,L.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new Cm(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Cm(r.from,n,r.diagnostic)}}),r}function Em(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Lm).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(km))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Dm(e,t){return e.field(Mm,!1)?t:t.concat(k.appendConfig.of(Xm))}function Om(e,t){return{effects:Dm(e,[km.of(t)])}}var km=k.define(),Am=k.define(),jm=k.define(),Mm=Ye.define({create(){return new wm(L.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Tm(n,e.selected.diagnostic,i)||Tm(n,null,i)}!n.size&&i&&t.state.facet(Lm).autoPanel&&(i=null),e=new wm(n,i,r)}for(let n of t.effects)if(n.is(km)){let r=t.state.facet(Lm).autoPanel?n.value.length?Um.open:null:e.panel;e=wm.init(n.value,r,t.state)}else n.is(Am)?e=new wm(e.diagnostics,n.value?Um.open:null,e.selected):n.is(jm)&&(e=new wm(e.diagnostics,e.panel,n.value));return e},provide:e=>[dc.from(e,e=>e.panel),W.decorations.from(e,e=>e.diagnostics)]}),Nm=L.mark({class:`cm-lintRange cm-lintRange-active`});function Pm(e,t,n){let{diagnostics:r}=e.state.field(Mm),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(tBm(e,t,!1)))}var Im=e=>{let t=e.state.field(Mm,!1);return!t||!t.panel?!1:(e.dispatch({effects:Am.of(!1)}),!0)},Lm=O.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...kt(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Rm,tooltipFilter:Rm,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Rm(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function zm(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;ee.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Bm(e,t,n){let r=n?zm(t.actions):[];return un(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},un(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Tm(e.state.field(Mm).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),un(`u`,s.slice(c,c+1)),s.slice(c+1)];return un(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&un(`div`,{class:`cm-diagnosticSource`},t.source))}var Vm=class extends On{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return un(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Hm=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Bm(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},Um=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Im(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=zm(n.actions);for(let i=0;i{for(let t=0;tIm(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Mm).selected;if(!e)return-1;for(let t=0;t{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;tn&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.topt.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Tm(this.view.state.field(Mm).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:jm.of(t)})}static open(t){return new e(t)}};function Wm(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,${encodeURIComponent(e)}')`}function Gm(e){return Wm(``,`width="6" height="3"`)}var Km=W.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Gm(`#f11`)},".cm-lintRange-warning":{backgroundImage:Gm(`orange`)},".cm-lintRange-info":{backgroundImage:Gm(`#999`)},".cm-lintRange-hint":{backgroundImage:Gm(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function qm(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Jm(e){let t=`hint`,n=1;for(let r of e){let e=qm(r.severity);e>n&&(n=e,t=r.severity)}return t}var Ym=ic(Pm,{hideOn:Em}),Xm=[Mm,W.decorations.compute([Mm],e=>{let{selected:t,panel:n}=e.field(Mm);return!t||!n||t.from==t.to?L.none:L.set([Nm.range(t.from,t.to)])}),Ym,Km],Zm=W.theme({"&":{color:`var(--mantine-color-text)`,backgroundColor:`var(--labstack-inset)`,border:`1px solid var(--mantine-color-default-border)`,borderRadius:`var(--mantine-radius-sm)`},"&.cm-focused":{outline:`2px solid var(--mantine-color-accent-filled)`,outlineOffset:`2px`},".cm-scroller":{fontFamily:m.display,fontSize:`13px`,lineHeight:`1.6`,minHeight:`160px`,maxHeight:`40vh`,overflow:`auto`},".cm-content":{padding:`10px 0`,caretColor:`var(--labstack-focus)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--labstack-focus)`},".cm-gutters":{backgroundColor:`var(--mantine-color-default)`,color:`var(--mantine-color-dimmed)`,borderColor:`var(--mantine-color-default-border)`,borderRadius:`var(--mantine-radius-sm) 0 0 var(--mantine-radius-sm)`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:`var(--mantine-color-accent-light-hover)`},".cm-activeLine":{backgroundColor:`var(--mantine-color-accent-light)`},".cm-placeholder":{color:`var(--mantine-color-dimmed)`,fontStyle:`italic`},".cm-tooltip":{color:`var(--mantine-color-text)`,backgroundColor:`var(--mantine-color-body)`,border:`1px solid var(--mantine-color-default-border)`,borderRadius:`var(--mantine-radius-sm)`},".cm-tooltip-autocomplete > ul > li[aria-selected]":{color:`var(--mantine-color-accent-light-color)`,backgroundColor:`var(--mantine-color-accent-light-hover)`},".cm-diagnostic-error":{borderLeftColor:`var(--mantine-color-bad-text)`},".cm-lintRange-error":{backgroundImage:`none`,textDecoration:`underline wavy var(--mantine-color-bad-text)`,textUnderlineOffset:`3px`}}),Qm=xu.define([{tag:Y.keyword,color:`var(--mantine-color-text)`,fontWeight:`600`},{tag:[Y.string,Y.number,Y.bool],color:`var(--mantine-color-info-light-color)`},{tag:Y.comment,color:`var(--mantine-color-gray-text)`,fontStyle:`italic`},{tag:[Y.typeName,Y.standard(Y.name)],color:`var(--mantine-color-text)`}]);function $m(e,t){let n=0;for(let r of e){if(t--<=0)break;n+=r.length}return n}function eh(e,t){return Array.from(e.slice(0,t)).length}function th(e,t){let n=$m(e,t.start);return{from:n,to:Math.max(n,$m(e,t.end))}}var $=t(),nh=[],rh=[],ih=W.theme({".cm-scroller":{minHeight:`0`,maxHeight:`none`,overflow:`hidden`,fontSize:`13px`},".cm-content":{padding:`8px 4px`},".cm-tooltip.cm-tooltip-autocomplete > ul":{maxWidth:`min(700px, calc(100vw - 40px))`},".cm-tooltip:has(.cm-tooltip-lint)":{display:`none`},"@media (max-width: 600px)":{".cm-tooltip.cm-tooltip-autocomplete > ul > li":{whiteSpace:`normal`,paddingLeft:`calc(3px + 1.4em)`,textIndent:`-1.4em`},".cm-tooltip.cm-tooltip-autocomplete > ul > li .cm-completionIcon":{fontSize:`inherit`,width:`1em`,paddingRight:`0.4em`,textIndent:`0`}}}),ah=pt.define(),oh=pt.define(),sh=e=>e.message+(`hint`in e&&e.hint?` (${e.hint})`:``);function ch(e,t,n){let{start:r,end:i}=e.span,a=Array.from(e.text).length-(i-r),o=e=>e.start<=i&&r<=e.end,s=e=>e.start>=i?{start:e.start+a,end:e.end+a}:e,c=e=>e.flatMap(e=>e.span&&o(e.span)||e.fix_its?.some(e=>o(e.span))?[]:[{...e,...e.span&&{span:s(e.span)},...e.fix_its&&{fix_its:e.fix_its.map(e=>({...e,span:s(e.span)}))}}]);return{problems:c(t.filter(e=>e.span)),notices:c(n)}}function lh(e,t,n,r){let{from:i,to:a}=th(e.state.doc.toString(),t.span);e.dispatch({changes:{from:i,to:a,insert:t.text},selection:{anchor:i+t.text.length},annotations:oh.of(ch(t,n,r))}),e.focus()}function uh(e,t,n){let r=(r,i)=>{let{from:a,to:o}=r.span?th(e,r.span):{from:0,to:e.length};return{from:a,to:o,severity:i,message:sh(r),actions:(r.fix_its??[]).map(e=>({name:`Replace with ${e.label||e.text}`,apply:r=>lh(r,e,t,n)}))}};return[...t.map(e=>r(e,`error`)),...n.filter(e=>e.span).map(e=>r(e,`info`))]}function dh(e){let{value:t,problems:n=nh,notices:r=rh,readOnly:o=!1,label:l=`PitotQL query`,describedBy:u}=e,d=(0,S.useRef)(null),f=(0,S.useRef)(null),p=(0,S.useRef)(e);p.current=e;let m=(0,S.useRef)(void 0),[h,g]=(0,S.useState)(),_=(0,S.useRef)(0),[v,y]=(0,S.useState)(!1),ee=(0,S.useRef)(!1),b=(0,S.useRef)(!1),x=(0,S.useRef)([]),te=(0,S.useId)(),ne=(0,S.useRef)({editable:new et,attributes:new et});(0,S.useEffect)(()=>{let{editable:e,attributes:t}=ne.current,n=async e=>{let t=p.current.complete;if(!t)return null;m.current?.abort();let n=new AbortController;m.current=n,e.addEventListener(`abort`,()=>n.abort());let r=e.state.doc.toString();g(void 0);try{let i=await t(r,eh(r,e.pos),n.signal);if(n.signal.aborted||(_.current=i.schema.error?_.current+1:0,g(_.current>=2?`Field suggestions are unavailable: the telemetry schema could not be read.`:i.schema.notice),i.items.length===0))return null;let{from:a,to:o}=th(r,i.replace);return{from:a,to:o,filter:!1,options:i.items.map(e=>({label:e.label,apply:e.insert,detail:e.detail,type:e.kind}))}}catch{return null}},r=new W({parent:d.current,state:j.create({doc:p.current.value,extensions:[pd(),Ds(),Zm,Qe.highest(ih),W.lineWrapping,j.transactionFilter.of(e=>{if(!e.docChanged||!/[\r\n]/.test(e.newDoc.toString()))return e;let t=[];return e.changes.iterChanges((e,n,r,i,a)=>t.push({from:e,to:n,insert:a.toString().replace(/\r?\n|\r/g,` `)})),[{changes:t,selection:e.selection,scrollIntoView:e.scrollIntoView}]}),e.of([]),t.of([]),Qe.highest(us.of([{key:`Mod-Enter`,run:()=>(p.current.onRun(),!0),stopPropagation:!0},{key:`Tab`,run:cm},{key:`Enter`,run:e=>b.current&&Sm(e.state)===`active`?cm(e):(um(e),p.current.onRun(),!0)},...[`ArrowDown`,`ArrowUp`,`PageDown`,`PageUp`].map(e=>({key:e,run:e=>(Sm(e.state)===`active`&&(b.current=!0),!1)}))])),ym({override:[n],activateOnTypingDelay:120}),Vs({tooltipSpace:e=>{let t=e.dom.ownerDocument.defaultView??window;return{top:0,left:16,bottom:t.innerHeight,right:t.innerWidth-16}}}),us.of([...bp.filter(e=>e.key!==`Enter`),...Md]),W.updateListener.of(e=>{if((e.docChanged||Sm(e.state)===null)&&(b.current=!1),e.docChanged&&!e.transactions.some(e=>e.annotation(ah))){let t=e.state.doc.toString();x.current.push(t);let n=e.transactions.find(e=>e.annotation(oh))?.annotation(oh);n?p.current.onChange(t,n):p.current.onChange(t)}let t=Sm(e.state)!==null;t!==ee.current&&(ee.current=t,y(t))})]})});return f.current=r,()=>{m.current?.abort(),f.current=null,r.destroy()}},[]),(0,S.useEffect)(()=>{let e=f.current,n=x.current.indexOf(t);if(n>=0){x.current.splice(0,n+1);return}x.current=[],e.state.doc.toString()!==t&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t},annotations:ah.of(!0)})},[t]),(0,S.useEffect)(()=>{f.current.dispatch({effects:ne.current.editable.reconfigure([j.readOnly.of(o),W.editable.of(!o)])})},[o]),(0,S.useEffect)(()=>{f.current.dispatch({effects:ne.current.attributes.reconfigure([W.contentAttributes.of({role:`textbox`,"aria-label":l,"aria-multiline":`false`,"aria-describedby":u??``,"aria-invalid":n.length?`true`:`false`,spellcheck:`false`}),e.placeholder?Rs(e.placeholder):[]])})},[l,u,n.length,e.placeholder]),(0,S.useEffect)(()=>{let e=f.current;e.dispatch(Om(e.state,uh(e.state.doc.toString(),n,r)))},[n,r]);let re=(e,t)=>!o&&e.fix_its?.map((e,i)=>(0,$.jsx)(c,{size:`compact-xs`,variant:`default`,fw:400,"aria-describedby":t,onClick:()=>lh(f.current,e,n,r),"data-fix-it":!0,children:(0,$.jsxs)(`span`,{children:[`Replace with `,(0,$.jsx)(`code`,{children:e.label||e.text})]})},i));return(0,$.jsxs)(`div`,{"data-pitotql-editor":!0,children:[(0,$.jsx)(`div`,{ref:d}),h&&v&&(0,$.jsxs)(s,{size:`xs`,c:`dimmed`,mt:4,"data-completion-note":!0,children:[`Suggestions: `,h]}),n.length>0&&(0,$.jsx)(a,{gap:4,mt:`xs`,"data-pitotql-problems":!0,children:n.map((e,t)=>(0,$.jsxs)(i,{gap:6,wrap:`wrap`,children:[(0,$.jsx)(s,{id:`${te}p${t}`,role:`alert`,size:`sm`,c:`bad`,children:sh(e)}),re(e,`${te}p${t}`)]},t))}),r.length>0&&(0,$.jsx)(a,{gap:4,mt:`xs`,"data-pitotql-notices":!0,children:r.map((e,t)=>(0,$.jsxs)(i,{gap:6,wrap:`wrap`,children:[(0,$.jsx)(s,{id:`${te}n${t}`,size:`xs`,c:`dimmed`,children:e.message}),re(e,`${te}n${t}`)]},t))})]})}var fh=(e,t)=>g(`/api/pitotql/parse`,{method:`POST`,json:e,signal:t}),ph=(e,t)=>g(`/api/pitotql/complete`,{method:`POST`,json:e,signal:t}),mh=(e,t)=>g(`/api/pitotql/format`,{method:`POST`,json:e,signal:t}),hh=80;function gh(e){let t=Array.from(e);return t.length<=hh?e:`${t.slice(0,79).join(``)}…`}function _h(e,t){if(!t.includes(e))return e;for(let n=2;;n++)if(!t.includes(`${e}_${n}`))return`${e}_${n}`}function vh({panel:e,time:t,onClose:n,onSaved:s}){let p=ne(),m=re({queryKey:ee,queryFn:x}),[h,g]=(0,S.useState)(`existing`),[_,ie]=(0,S.useState)(null),[ae,oe]=(0,S.useState)(``),[se,ce]=(0,S.useState)(gh(e.title)),[le,ue]=(0,S.useState)(!1),[de,fe]=(0,S.useState)(),pe=m.data?.length===0?`new`:h,me=se.trim()!==``&&(pe===`new`?ae.trim()!==``:_!==null),he=async()=>{if(me&&!le){ue(!0),fe(void 0);try{let n;if(pe===`new`)n=(await v({version:1,name:ae.trim(),time:t.from&&t.to?{from:t.from,to:t.to}:{range:t.range??`1h`},panels:[{...e,id:`explore`,title:se.trim()}]})).id;else{let t=await y(_),r={...e,id:_h(`explore`,t.spec.panels.map(e=>e.id)),title:se.trim()};await b(t.id,[{op:`add_panel`,panel:r}],t.version,`Added ${r.title} from Explore`),n=t.id}p.invalidateQueries({queryKey:ee}),p.invalidateQueries({queryKey:[`dashboard`,n]}),s(n)}catch(e){e instanceof te&&e.code===`dashboard_version_conflict`?fe(`Someone saved that dashboard a moment ago. Save again to add the panel to the latest version.`):e instanceof te&&e.problems.length>0?fe(e.problems.map(e=>e.message).join(` `)):fe(e instanceof Error?e.message:`Save failed`)}finally{ue(!1)}}};return(0,$.jsx)(r,{opened:!0,onClose:()=>{le||n()},title:`Save to dashboard`,children:(0,$.jsxs)(a,{gap:`md`,children:[m.data&&m.data.length>0&&(0,$.jsx)(d,{fullWidth:!0,value:pe,onChange:e=>g(e===`new`?`new`:`existing`),data:[{value:`existing`,label:`Existing dashboard`},{value:`new`,label:`New dashboard`}]}),pe===`existing`?(0,$.jsx)(f,{label:`Dashboard`,placeholder:`Choose a dashboard`,searchable:!0,value:_,onChange:ie,data:(m.data??[]).map(e=>({value:e.id,label:e.name}))}):(0,$.jsx)(u,{label:`Dashboard name`,value:ae,onChange:e=>oe(e.currentTarget.value),"data-autofocus":!0}),(0,$.jsx)(u,{label:`Panel title`,value:se,onChange:e=>ce(e.currentTarget.value)}),m.error&&(0,$.jsx)(o,{children:(0,$.jsx)(l,{tone:`danger`,children:`Dashboards could not be loaded.`})}),de&&(0,$.jsx)(o,{children:(0,$.jsx)(l,{tone:`danger`,title:`Not saved`,children:de})}),(0,$.jsxs)(i,{justify:`flex-end`,gap:`xs`,children:[(0,$.jsx)(c,{variant:`default`,disabled:le,onClick:n,children:`Cancel`}),(0,$.jsx)(c,{loading:le,disabled:!me,onClick:()=>void he(),children:`Save`})]})]})})}export{K as A,jc as B,su as C,gl as D,Wl as E,q as F,j as H,W as I,Ds as L,zc as M,Rc as N,Y as O,cl as P,Ps as R,bu as S,Tu as T,Qe as U,et as V,ie as W,Md as _,mh as a,Lu as b,Qm as c,ym as d,wp as f,pd as g,bp as h,ph as i,G as j,Nc as k,Zm as l,Tp as m,gh as n,fh as o,bm as p,_h as r,dh as s,vh as t,Om as u,Ul as v,yu as w,_u as x,eu as y,us as z}; \ No newline at end of file diff --git a/internal/ui/dist/assets/search-D_K9J6yO.js b/internal/ui/dist/assets/search-P7VEnlsD.js similarity index 99% rename from internal/ui/dist/assets/search-D_K9J6yO.js rename to internal/ui/dist/assets/search-P7VEnlsD.js index 9220ff153..bbc89c598 100644 --- a/internal/ui/dist/assets/search-D_K9J6yO.js +++ b/internal/ui/dist/assets/search-P7VEnlsD.js @@ -1,2 +1,2 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{Dt as r,Et as i,Ft as a,Ht as o,Jt as s,Lt as c,M as l,Nt as u,P as d,Pt as f,Q as p,Qt as m,Tt as h,X as g,Xt as _,Y as v,Z as y,Zt as b,_n as x,_t as S,an as C,bn as w,bt as T,dn as E,en as D,fn as O,ft as k,gn as A,gt as ee,hn as te,ht as j,in as ne,it as re,lt as M,mt as N,nn as P,on as ie,pt as ae,sn as oe,st as F,tt as I,ut as L,vt as se,wt as R,x as ce,yt as le}from"./brand-D6fP-cLS.js";import{t as ue}from"./noop-mXPS5vjY.js";import{c as de,l as fe,o as pe,s as me}from"./format-BZjbsxwM.js";import{a as he,s as ge}from"./auth-DWqIkMZS.js";var z=n(e(),1);function B(e,t){let n=e;for(;(n=n.parentElement)&&!n.matches(t););return n}var V=t();function _e(e,t,n){for(let n=e-1;n>=0;--n)if(!t[n].disabled)return n;if(n){for(let e=t.length-1;e>-1;--e)if(!t[e].disabled)return e}return e}function ve(e,t,n){for(let n=e+1;n{n?.(s);let c=Array.from(B(s.currentTarget,e)?.querySelectorAll(t)||[]).filter(t=>ye(s.currentTarget,t,e)),l=c.findIndex(e=>s.currentTarget===e),u=ve(l,c,r),d=_e(l,c,r),f=a===`rtl`?d:u,p=a===`rtl`?u:d;switch(s.key){case`ArrowRight`:o===`horizontal`&&(s.stopPropagation(),s.preventDefault(),c[f].focus(),i&&c[f].click());break;case`ArrowLeft`:o===`horizontal`&&(s.stopPropagation(),s.preventDefault(),c[p].focus(),i&&c[p].click());break;case`ArrowUp`:o===`vertical`&&(s.stopPropagation(),s.preventDefault(),c[d].focus(),i&&c[d].click());break;case`ArrowDown`:o===`vertical`&&(s.stopPropagation(),s.preventDefault(),c[u].focus(),i&&c[u].click());break;case`Home`:s.stopPropagation(),s.preventDefault(),c[ve(-1,c,!1)]?.focus();break;case`End`:s.stopPropagation(),s.preventDefault(),c[_e(c.length,c,!1)]?.focus()}}}function be(e,t={active:!0}){return typeof e!=`function`||!t.active?t.onKeyDown||ue:n=>{n.key===`Escape`&&(e(n),t.onTrigger?.())}}function U(e,t){return n=>{e?.(n),t?.(n)}}function xe(e,t,n){return n?Array.from(B(n,t)?.querySelectorAll(e)||[]).findIndex(e=>e===n):null}var Se=[`mousedown`,`touchstart`];function Ce(e,t,n,r=!0,i=!1){let a=(0,z.useRef)(null),o=t||Se,s=(0,z.useEffectEvent)(t=>{let{target:r}=t??{};if(!document.body.contains(r)&&r?.tagName!==`HTML`)return;let i=t.composedPath();Array.isArray(n)?n.every(e=>!!e&&!i.includes(e))&&e(t):a.current&&!i.includes(a.current)&&e(t)}),c=o.join(`,`);return(0,z.useEffect)(()=>{if(!r)return;let e=c.split(`,`);return e.forEach(e=>document.addEventListener(e,s,i)),()=>{e.forEach(e=>document.removeEventListener(e,s,i))}},[c,r,i]),a}var we=[`mouse`,`touch`],Te=10;function Ee(e,t={}){let{threshold:n=400,events:r=we,cancelOnMove:i=!1,onStart:a,onFinish:o,onCancel:s}=t,c=(0,z.useRef)(!1),l=(0,z.useRef)(!1),u=(0,z.useRef)(-1),d=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>window.clearTimeout(u.current),[]);let f=r.join(`,`);return(0,z.useMemo)(()=>{if(typeof e!=`function`)return{};let t=i!==!1,f=i===!0?Te:i===!1?0:i,p=t=>{(ke(t)||Oe(t))&&(a&&a(t),d.current=De(t),l.current=!0,u.current=window.setTimeout(()=>{e(t),c.current=!0},n))},m=e=>{(ke(e)||Oe(e))&&(c.current?o&&o(e):l.current&&s&&s(e),c.current=!1,l.current=!1,d.current=null,u.current!==-1&&(window.clearTimeout(u.current),u.current=-1))},h=e=>{if(!t||!l.current||c.current)return;let n=De(e);if(!n||!d.current)return;let r=n.x-d.current.x,i=n.y-d.current.y;Math.sqrt(r*r+i*i)>f&&m(e)},g={};return r.includes(`mouse`)&&(g.onMouseDown=p,g.onMouseUp=m,g.onMouseLeave=m,t&&(g.onMouseMove=h)),r.includes(`touch`)&&(g.onTouchStart=p,g.onTouchEnd=m,g.onTouchCancel=m,t&&(g.onTouchMove=h)),g},[e,n,s,o,a,i,f])}function De(e){if(Oe(e)){let t=e.touches[0]??e.changedTouches[0];return t?{x:t.clientX,y:t.clientY}:null}return{x:e.clientX,y:e.clientY}}function Oe(e){return window.TouchEvent?e.nativeEvent instanceof TouchEvent:`touches`in e.nativeEvent}function ke(e){return e.nativeEvent instanceof MouseEvent}function W({open:e,close:t,openDelay:n,closeDelay:r}){let i=(0,z.useRef)(-1),a=(0,z.useRef)(-1),o=()=>{window.clearTimeout(i.current),window.clearTimeout(a.current)};return(0,z.useEffect)(()=>o,[]),{openDropdown:()=>{o(),n===0||n===void 0?e():i.current=window.setTimeout(e,n)},closeDropdown:()=>{o(),r===0||r===void 0?t():a.current=window.setTimeout(t,r)}}}var[Ae,G]=A(`Popover component was not found in the tree`);function je({childProps:e,disabled:t,opened:n,longPressDelay:r=500,setReference:i,open:a}){let o=(0,z.useRef)(!1),s=(0,z.useRef)(!1),c=(0,z.useRef)(null),l=(0,z.useRef)(t);l.current=t;let u=(e,t,n)=>{i({getBoundingClientRect:()=>({x:e,y:t,width:0,height:0,top:t,left:e,right:e,bottom:t,toJSON:()=>void 0}),contextElement:n}),a()},d=U(e.onMouseDown,e=>{t||e.button===2&&e.stopPropagation()}),f=U(e.onContextMenu,e=>{t||e.defaultPrevented||(e.preventDefault(),!s.current&&(u(e.clientX,e.clientY,e.currentTarget),o.current&&(s.current=!0)))}),p=Ee(e=>{if(l.current||s.current)return;let t=e,n=t.touches[0]??t.changedTouches[0];n&&(u(n.clientX,n.clientY,c.current),s.current=!0)},{threshold:r,events:[`touch`],cancelOnMove:!0,onStart:e=>{o.current=!0,s.current=!1,c.current=e.currentTarget},onFinish:e=>{o.current=!1,s.current=!1,l.current||e.preventDefault()},onCancel:()=>{o.current=!1,s.current=!1}});return{onContextMenu:f,onMouseDown:d,onTouchStart:U(e.onTouchStart,p.onTouchStart),onTouchEnd:U(e.onTouchEnd,p.onTouchEnd),onTouchCancel:U(e.onTouchCancel,p.onTouchCancel),onTouchMove:U(e.onTouchMove,p.onTouchMove),style:t?e.style:{...e.style,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},"data-expanded":n?!0:void 0}}function Me(e){let{children:t,disabled:n,longPressDelay:r}=a(`PopoverContextMenu`,null,e),i=m(t);if(!i)throw Error(`Popover.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let o=G(),s=je({childProps:i.props,disabled:n||o.disabled,opened:o.opened,longPressDelay:r,setReference:o.reference,open:()=>{o.opened||o.onToggle()}});return(0,z.cloneElement)(i,s)}Me.displayName=`@mantine/core/PopoverContextMenu`;var Ne={dropdown:`m_38a85659`,arrow:`m_a31dc6c1`,overlay:`m_3d7bc908`},Pe=r(e=>{let t=a(`PopoverDropdown`,null,e),{className:n,style:r,vars:i,children:o,onKeyDownCapture:s,variant:c,classNames:l,styles:u,ref:d,...f}=t,p=G(),{dir:m}=R(),_=p.arrowPosition===`merge`&&p.withArrow?de({position:p.placement,dir:m}):void 0,b=C({opened:p.opened,shouldReturnFocus:p.returnFocus}),x=p.withRoles?{"aria-labelledby":p.getTargetId(),id:p.getDropdownId(),role:`dialog`,tabIndex:-1}:{},S=P(d,p.floating);return p.disabled?null:(0,V.jsx)(y,{...p.portalProps,withinPortal:p.withinPortal,children:(0,V.jsx)(g,{mounted:p.opened,...p.transitionProps,transition:p.transitionProps?.transition||`fade`,duration:p.transitionProps?.duration??150,keepMounted:p.keepMounted,keepMountedMode:p.keepMountedMode,exitDuration:typeof p.transitionProps?.exitDuration==`number`?p.transitionProps.exitDuration:p.transitionProps?.duration,children:e=>(0,V.jsx)(v,{active:p.trapFocus&&p.opened,innerRef:S,children:(0,V.jsxs)(h,{...x,...f,variant:c,onKeyDownCapture:be(()=>{p.onClose?.(),p.onDismiss?.()},{active:p.closeOnEscape,onTrigger:b,onKeyDown:s}),"data-position":p.placement,"data-fixed":p.floatingStrategy===`fixed`||void 0,...p.getStyles(`dropdown`,{className:n,props:t,classNames:l,styles:u,style:[{...e,..._,zIndex:p.zIndex,top:p.y??0,left:p.x??0,width:p.width===`target`?void 0:w(p.width),...p.referenceHidden?{display:`none`}:null},p.resolvedStyles?.dropdown,u?.dropdown,r]}),children:[o,(0,V.jsx)(me,{ref:p.arrowRef,arrowX:p.arrowX,arrowY:p.arrowY,visible:p.withArrow,position:p.placement,arrowSize:p.arrowSize,arrowRadius:p.arrowRadius,arrowOffset:p.arrowOffset,arrowPosition:p.arrowPosition,...p.getStyles(`arrow`,{props:t,classNames:l,styles:u})})]})})})})});Pe.classes=Ne,Pe.displayName=`@mantine/core/PopoverDropdown`;var Fe={refProp:`ref`,popupType:`dialog`},Ie=r(e=>{let{children:t,refProp:n,popupType:r,ref:i,...o}=a(`PopoverTarget`,Fe,e),s=m(t);if(!s)throw Error(`Popover.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let c=o,l=G(),u=P(l.reference,fe(s),i),d=l.withRoles?{"aria-haspopup":r,"aria-expanded":l.opened,"aria-controls":l.opened?l.getDropdownId():void 0,id:l.getTargetId()}:{},f=s.props;return(0,z.cloneElement)(s,{...c,...d,...l.targetProps,className:_(l.targetProps.className,c.className,f.className),[n]:u,...l.controlled?null:{onClick:e=>{l.onToggle(),f.onClick?.(e)}}})});Ie.displayName=`@mantine/core/PopoverTarget`;function Le(e){if(e===void 0)return{shift:!0,flip:!0};let t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function Re(e,t,n,r){let i=Le(e.middlewares),a=[S(e.offset),N()];if(i.flip&&!n){let e=typeof i.flip==`boolean`?{}:i.flip,t=r?{fallbackStrategy:`initialPlacement`,...e}:e;a.push(ae(t))}if(i.shift){let t=typeof i.shift==`boolean`?{}:i.shift;a.push(se(n=>{let r=n.placement.startsWith(`top`)||n.placement.startsWith(`bottom`);return{limiter:ee(),padding:5,...e.width===`target`&&r?{mainAxis:!1}:null,...t}}))}return i.inline&&a.push(typeof i.inline==`boolean`?j():j(i.inline)),a.push(k({element:e.arrowRef,padding:e.arrowOffset})),(i.size||e.width===`target`)&&a.push(le({...typeof i.size==`boolean`?{}:i.size,apply({rects:n,availableWidth:r,availableHeight:a,...o}){let s=t().refs.floating.current?.style??{};i.size&&(typeof i.size==`object`&&i.size.apply?i.size.apply({rects:n,availableWidth:r,availableHeight:a,...o}):Object.assign(s,{maxWidth:`${r}px`,maxHeight:`${a}px`})),e.width===`target`&&Object.assign(s,{width:`${n.reference.width}px`})}})),a}function ze(e){let[t,n]=D({value:e.opened,defaultValue:e.defaultOpened,finalValue:!1,onChange:e.onChange}),r=(0,z.useRef)(t),i=(0,z.useRef)(!1),[a,o]=(0,z.useState)(null),s=e.preventPositionChangeWhenVisible!==!1,c=(0,z.useRef)(t);t!==c.current&&(c.current=t,t&&a!==null&&o(null));let l=(0,z.useRef)(e.position);e.position!==l.current&&(l.current=e.position,i.current=!1,a!==null&&o(null));let u=(0,z.useCallback)(()=>o(null),[]),d=()=>{t&&!e.disabled&&n(!1)},f=()=>{e.disabled||n(!t)},p=F({open:t,strategy:e.strategy,placement:s?a??e.position:e.position,middleware:Re(e,()=>p,s&&a!==null,s),whileElementsMounted:e.keepMounted?void 0:T});(0,z.useEffect)(()=>{if(!e.keepMounted)return;let n=p.refs.reference.current,r=p.refs.floating.current;if(t&&n&&r)return T(n,r,p.update)},[e.keepMounted,t,p.update,p.elements.reference,p.elements.floating]),oe(()=>{if(!t){i.current=!1;return}if(!s||a!==null)return;let e=p.refs.floating.current;if(e&&e.offsetHeight!==0&&e.offsetWidth!==0){if(!i.current){i.current=!0,p.update();return}p.isPositioned&&o(p.placement)}},[s,t,p.isPositioned,p.placement,a,p.update]);let m=(0,z.useRef)(p.placement);return oe(()=>{m.current!==p.placement&&(m.current=p.placement,e.onPositionChange?.(p.placement))},[p.placement]),ie(()=>{t!==r.current&&(t?e.onOpen?.():e.onClose?.()),r.current=t},[t,e.onClose,e.onOpen]),{floating:p,controlled:typeof e.opened==`boolean`,opened:t,onClose:d,onToggle:f,resetLockedPlacement:u}}var Be={position:`bottom`,offset:8,transitionProps:{transition:`fade`,duration:150},middlewares:{flip:!0,shift:!0,inline:!1},arrowSize:7,arrowOffset:5,arrowRadius:0,arrowPosition:`side`,closeOnClickOutside:!0,withinPortal:!0,closeOnEscape:!0,trapFocus:!1,withRoles:!0,returnFocus:!1,withOverlay:!1,hideDetached:!0,preventPositionChangeWhenVisible:!0,clickOutsideEvents:[`mousedown`,`touchstart`],clickOutsideCapture:!1,zIndex:te(`popover`),__staticSelector:`Popover`,width:`max-content`},Ve=b((e,{radius:t,shadow:n})=>({dropdown:{"--popover-radius":t===void 0?void 0:E(t),"--popover-shadow":O(n)}}));function K(e){let t=a(`Popover`,Be,e),{children:n,position:r,offset:i,onPositionChange:s,opened:c,transitionProps:l,onExitTransitionEnd:d,onEnterTransitionEnd:m,width:h,middlewares:_,withArrow:v,arrowSize:b,arrowOffset:x,arrowRadius:S,arrowPosition:C,unstyled:w,classNames:T,styles:E,closeOnClickOutside:D,withinPortal:O,portalProps:k,closeOnEscape:A,clickOutsideEvents:ee,clickOutsideCapture:te,trapFocus:j,onClose:re,onDismiss:M,onOpen:N,onChange:P,zIndex:ie,radius:ae,shadow:oe,id:F,defaultOpened:I,__staticSelector:L,withRoles:se,disabled:ce,returnFocus:le,variant:ue,keepMounted:de,keepMountedMode:fe,vars:me,floatingStrategy:he,withOverlay:ge,overlayProps:B,hideDetached:_e,attributes:ve,preventPositionChangeWhenVisible:ye,...H}=t,be=u({name:L,props:t,classes:Ne,classNames:T,styles:E,unstyled:w,attributes:ve,rootSelector:`dropdown`,vars:me,varsResolver:Ve}),{resolvedStyles:U}=f({classNames:T,styles:E,props:t}),xe=(0,z.useRef)(null),[Se,we]=(0,z.useState)(null),[Te,Ee]=(0,z.useState)(null),{dir:De}=R(),Oe=o(),ke=ne(F),W=ze({middlewares:_,width:h,position:pe(De,r),offset:typeof i==`number`?i+(v?b/2:0):i,arrowRef:xe,arrowOffset:x,onPositionChange:s,opened:c,defaultOpened:I,onChange:P,onOpen:N,onClose:re,onDismiss:M,strategy:he,disabled:ce,preventPositionChangeWhenVisible:ye,keepMounted:de});Ce(()=>{D&&(W.onClose(),M?.())},ee,[Se,Te],!0,te);let G=(0,z.useCallback)(e=>{we(e),W.floating.refs.setReference(e)},[W.floating.refs.setReference]),je=(0,z.useCallback)(e=>{Ee(e),W.floating.refs.setFloating(e)},[W.floating.refs.setFloating]),Me=(0,z.useCallback)(()=>{l?.onExited?.(),d?.(),W.resetLockedPlacement()},[l?.onExited,d,W.resetLockedPlacement]),Pe=(0,z.useCallback)(()=>{l?.onEntered?.(),m?.()},[l?.onEntered,m]);return(0,V.jsxs)(Ae,{value:{returnFocus:le,disabled:ce,controlled:W.controlled,reference:G,floating:je,x:W.floating.x,y:W.floating.y,arrowX:W.floating?.middlewareData?.arrow?.x,arrowY:W.floating?.middlewareData?.arrow?.y,opened:W.opened,arrowRef:xe,transitionProps:{...l,onExited:Me,onEntered:Pe},width:h,withArrow:v,arrowSize:b,arrowOffset:x,arrowRadius:S,arrowPosition:C,placement:W.floating.placement,trapFocus:j,withinPortal:O,portalProps:k,zIndex:ie,radius:ae,shadow:oe,closeOnEscape:A,onDismiss:M,onClose:W.onClose,onToggle:W.onToggle,getTargetId:()=>ke,getDropdownId:()=>`${ke}-dropdown`,withRoles:se,targetProps:H,__staticSelector:L,classNames:T,styles:E,unstyled:w,variant:ue,keepMounted:de,keepMountedMode:fe,getStyles:be,resolvedStyles:U,floatingStrategy:he,referenceHidden:_e&&Oe!==`test`?W.floating.middlewareData.hide?.referenceHidden:!1},children:[n,ge&&(0,V.jsx)(g,{transition:`fade`,mounted:W.opened,duration:l?.duration||250,exitDuration:l?.exitDuration||250,children:e=>(0,V.jsx)(y,{withinPortal:O,children:(0,V.jsx)(p,{...B,...be(`overlay`,{className:B?.className,style:[e,B?.style]})})})})]})}K.Target=Ie,K.Dropdown=Pe,K.ContextMenu=Me,K.varsResolver=Ve,K.displayName=`@mantine/core/Popover`,K.extend=e=>e,K.withProps=e=>{let t=t=>(0,V.jsx)(K,{...e,...t});return t.extend=K.extend,t.displayName=`WithProps(${K.displayName})`,t};function He({size:e,style:t,...n}){let r=e===void 0?t:{width:w(e),height:w(e),...t};return(0,V.jsx)(`svg`,{viewBox:`0 0 10 7`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:r,"aria-hidden":!0,...n,children:(0,V.jsx)(`path`,{d:`M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}var[Ue,q]=A(`Menu component was not found in the tree`),We=(0,z.createContext)(null);function Ge(e){let{value:t,defaultValue:n,onChange:r,children:i}=a(`MenuCheckboxGroup`,null,e),[o,s]=D({value:t,defaultValue:n,finalValue:[],onChange:r}),c=(0,z.useCallback)(e=>{s(o.includes(e)?o.filter(t=>t!==e):[...o,e])},[o,s]);return(0,V.jsx)(We,{value:{values:o,onChange:c},children:i})}Ge.displayName=`@mantine/core/MenuCheckboxGroup`;var J=(0,z.createContext)(null);function Ke({role:e,checked:t,indicator:n,onSelect:r,color:i,closeMenuOnClick:a,rightSection:o,children:l,disabled:u,dataDisabled:d,className:f,style:p,styles:m,classNames:h,buttonRef:g,others:_}){let v=q(),y=(0,z.use)(J),b=c(),{dir:x}=R(),S=(0,z.useRef)(null),C=U(_.onClick,()=>{d||(r(),a&&v.closeDropdownImmediately())}),w=U(_.onMouseMove,()=>{if(!v.hasSearch)return;let e=S.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==S.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),T=U(_.onKeyDown,e=>{e.key===`ArrowLeft`&&y&&(y.close(),y.focusParentItem())}),E=i?b.variantColorResolver({color:i,theme:b,variant:`light`}):void 0,D=i?s({color:i,theme:b}):null,O=v.alignItemsLabels!==`none`||t;return(0,V.jsxs)(I,{onMouseDown:e=>e.preventDefault(),..._,unstyled:v.unstyled,tabIndex:v.menuItemTabIndex,...v.getStyles(`item`,{className:f,style:p,styles:m,classNames:h}),ref:P(S,g),role:e,"aria-checked":t,disabled:u,"data-menu-item":!0,"data-checked":t||void 0,"data-disabled":u||d||void 0,"data-mantine-stop-propagation":!0,onClick:C,onMouseMove:w,onKeyDown:H({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:v.loop,dir:x,orientation:`vertical`,onKeyDown:T}),__vars:{"--menu-item-color":D?.isThemeColor&&D?.shade===void 0?`var(--mantine-color-${D.color}-6)`:E?.color,"--menu-item-hover":E?.hover},children:[O&&(0,V.jsx)(`div`,{...v.getStyles(`itemIndicator`,{styles:m,classNames:h}),"data-checked":t||void 0,children:t?n:null}),l&&(0,V.jsx)(`div`,{...v.getStyles(`itemLabel`,{styles:m,classNames:h}),"data-menu-item-label":!0,children:l}),o&&(0,V.jsx)(`div`,{...v.getStyles(`itemSection`,{styles:m,classNames:h}),"data-position":`right`,children:o})]})}var Y={dropdown:`m_dc9b7c9f`,label:`m_9bfac126`,divider:`m_efdf90cb`,item:`m_99ac2aa1`,search:`m_ef8769b6`,itemLabel:`m_5476e0d3`,itemIndicator:`m_8395186e`,itemSection:`m_8b75e504`,chevron:`m_b85b0bed`},qe=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,color:s,closeMenuOnClick:c,rightSection:l,children:u,disabled:d,"data-disabled":f,value:p,checked:m,defaultChecked:h,onChange:g,checkIcon:_,ref:v,...y}=a(`MenuCheckboxItem`,null,e),b=q(),x=(0,z.use)(We),S=x&&p!==void 0?x.values.includes(p):void 0,[C,w]=D({value:m??S,defaultValue:h,finalValue:!1,onChange:g}),T=_??b.checkIcon??(0,V.jsx)(He,{size:10});return(0,V.jsx)(Ke,{role:`menuitemcheckbox`,checked:C,indicator:T,onSelect:()=>{g?w(!C):x&&p!==void 0?x.onChange(p):w(!C)},color:s,closeMenuOnClick:c,rightSection:l,disabled:d,dataDisabled:f,className:n,style:r,styles:i,classNames:t,buttonRef:v,others:y,children:u})});qe.classes=Y,qe.displayName=`@mantine/core/MenuCheckboxItem`;function Je(e){let{children:t,disabled:n,longPressDelay:r}=a(`MenuContextMenu`,null,e),i=m(t);if(!i)throw Error(`Menu.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let o=q(),s=G(),c=je({childProps:i.props,disabled:n||s.disabled,opened:o.opened,longPressDelay:r,setReference:s.reference,open:()=>o.openDropdown()});return(0,z.cloneElement)(i,c)}Je.displayName=`@mantine/core/MenuContextMenu`;var Ye=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`MenuDivider`,null,e),c=q();return(0,V.jsx)(h,{...c.getStyles(`divider`,{className:n,style:r,styles:i,classNames:t}),...s})});Ye.classes=Y,Ye.displayName=`@mantine/core/MenuDivider`;var Xe=500;function Ze(e){return((e.querySelector(`[data-menu-item-label]`)??e).textContent??``).trim().toLowerCase()}function Qe(e){return e.length>1&&e.split(``).every(t=>t===e[0])}function $e({enabled:e,opened:t,getDropdown:n}){let r=(0,z.useRef)({buffer:``,timeoutId:null});return(0,z.useEffect)(()=>{if(t&&e)return;let n=r.current;n.timeoutId!==null&&(window.clearTimeout(n.timeoutId),n.timeoutId=null),n.buffer=``},[t,e]),(0,z.useEffect)(()=>()=>{let{timeoutId:e}=r.current;e!==null&&window.clearTimeout(e)},[]),t=>{if(!e||t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey||t.key.length!==1||t.key===` `)return;let i=t.target;if(i&&(i.tagName===`INPUT`||i.tagName===`TEXTAREA`||i.tagName===`SELECT`||i.isContentEditable))return;let a=n();if(!a)return;let o=Array.from(a.querySelectorAll(`[data-menu-item]:not([data-disabled])`)).filter(e=>e.closest(`[data-menu-dropdown]`)===a);if(o.length===0)return;let s=r.current;s.buffer=(s.buffer+t.key).toLowerCase(),s.timeoutId!==null&&window.clearTimeout(s.timeoutId),s.timeoutId=window.setTimeout(()=>{s.buffer=``,s.timeoutId=null},Xe);let c=document.activeElement,l=c?o.indexOf(c):-1,u=null;if(s.buffer.length===1||Qe(s.buffer)){let e=s.buffer[0],t=l+1;for(let n=0;n{let{classNames:t,className:n,style:r,styles:i,vars:o,onMouseEnter:s,onMouseLeave:c,onKeyDown:l,children:u,ref:d,...f}=a(`MenuDropdown`,null,e),p=(0,z.useRef)(null),m=q(),h=$e({enabled:!m.hasSearch,opened:m.opened,getDropdown:()=>p.current}),g=U(l,e=>{h(e),!(e.defaultPrevented||m.hasSearch)&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),p.current?.querySelectorAll(`[data-menu-item]:not(:disabled)`)[0]?.focus())}),_=U(s,()=>(m.trigger===`hover`||m.trigger===`click-hover`)&&m.openDropdown()),v=U(c,()=>(m.trigger===`hover`||m.trigger===`click-hover`)&&m.closeDropdown());return(0,V.jsxs)(K.Dropdown,{...f,onMouseEnter:_,onMouseLeave:v,role:`menu`,"aria-orientation":`vertical`,ref:P(d,p),...m.getStyles(`dropdown`,{className:n,style:r,styles:i,classNames:t,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:g,children:[m.withInitialFocusPlaceholder&&!m.hasSearch&&(0,V.jsx)(`div`,{role:`presentation`,tabIndex:-1,"data-autofocus":!0,"data-mantine-stop-propagation":!0,style:{outline:0}}),u]})});et.classes=Y,et.displayName=`@mantine/core/MenuDropdown`;var tt=i(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,color:l,closeMenuOnClick:u,leftSection:d,rightSection:f,children:p,disabled:m,"data-disabled":h,ref:g,..._}=a(`MenuItem`,null,e),v=q(),y=(0,z.use)(J),b=c(),{dir:x}=R(),S=(0,z.useRef)(null),C=_,w=U(C.onClick,()=>{h||(typeof u==`boolean`?u&&v.closeDropdownImmediately():v.closeOnItemClick&&v.closeDropdownImmediately())}),T=U(C.onMouseMove,()=>{if(!v.hasSearch)return;let e=S.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==S.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),E=l?b.variantColorResolver({color:l,theme:b,variant:`light`}):void 0,D=l?s({color:l,theme:b}):null,O=U(C.onKeyDown,e=>{e.key===`ArrowLeft`&&y&&(y.close(),y.focusParentItem())});return(0,V.jsxs)(I,{onMouseDown:e=>e.preventDefault(),..._,unstyled:v.unstyled,tabIndex:v.menuItemTabIndex,...v.getStyles(`item`,{className:n,style:r,styles:i,classNames:t}),ref:P(S,g),role:`menuitem`,disabled:m,"data-menu-item":!0,"data-disabled":m||h||void 0,"data-mantine-stop-propagation":!0,onClick:w,onMouseMove:T,onKeyDown:H({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:v.loop,dir:x,orientation:`vertical`,onKeyDown:O}),__vars:{"--menu-item-color":D?.isThemeColor&&D?.shade===void 0?`var(--mantine-color-${D.color}-6)`:E?.color,"--menu-item-hover":E?.hover},children:[v.alignItemsLabels===`all`&&(0,V.jsx)(`div`,{...v.getStyles(`itemIndicator`,{styles:i,classNames:t}),"data-placeholder":!0}),d&&(0,V.jsx)(`div`,{...v.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`left`,children:d}),p&&(0,V.jsx)(`div`,{...v.getStyles(`itemLabel`,{styles:i,classNames:t}),"data-menu-item-label":!0,children:p}),f&&(0,V.jsx)(`div`,{...v.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`right`,children:f})]})});tt.classes=Y,tt.displayName=`@mantine/core/MenuItem`;var nt=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`MenuLabel`,null,e),c=q();return(0,V.jsx)(h,{...c.getStyles(`label`,{className:n,style:r,styles:i,classNames:t}),...s})});nt.classes=Y,nt.displayName=`@mantine/core/MenuLabel`;var rt=(0,z.createContext)(null);function it(e){let{value:t,defaultValue:n,onChange:r,children:i}=a(`MenuRadioGroup`,null,e),[o,s]=D({value:t,defaultValue:n,finalValue:null,onChange:r});return(0,V.jsx)(rt,{value:{value:o,onChange:e=>s(e)},children:i})}it.displayName=`@mantine/core/MenuRadioGroup`;function at({size:e,style:t,...n}){return(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 5 5`,style:{width:w(e),height:w(e),...t},"aria-hidden":!0,...n,children:(0,V.jsx)(`circle`,{cx:`2.5`,cy:`2.5`,r:`2.5`,fill:`currentColor`})})}var ot=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,color:s,closeMenuOnClick:c,rightSection:l,children:u,disabled:d,"data-disabled":f,value:p,checked:m,onChange:h,checkIcon:g,ref:_,...v}=a(`MenuRadioItem`,null,e),y=q(),b=(0,z.use)(rt),x=m??(b?b.value===p:!1),S=g??y.checkIcon??(0,V.jsx)(at,{size:5});return(0,V.jsx)(Ke,{role:`menuitemradio`,checked:x,indicator:S,onSelect:()=>{x||(h?h(p):b&&b.onChange(p))},color:s,closeMenuOnClick:c,rightSection:l,disabled:d,dataDisabled:f,className:n,style:r,styles:i,classNames:t,buttonRef:_,others:v,children:u})});ot.classes=Y,ot.displayName=`@mantine/core/MenuRadioItem`;var st=`[data-menu-item]:not([data-disabled])`,ct=`[data-menu-active]`;function lt(e){return e?.closest(`[data-menu-dropdown]`)}function ut(e){return e?Array.from(e.querySelectorAll(st)).filter(t=>t.closest(`[data-menu-dropdown]`)===e):[]}function dt(e){e&&e.querySelectorAll(ct).forEach(t=>{t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}function ft(e,t){dt(t),e&&(e.setAttribute(`data-menu-active`,`true`),e.scrollIntoView({block:`nearest`}))}function pt(e){return e.findIndex(e=>e.hasAttribute(`data-menu-active`))}var mt={clearSearchOnClose:!0},ht=r(e=>{let{classNames:t,styles:n,onKeyDown:r,onChange:i,size:o,clearSearchOnClose:s,ref:c,...l}=a(`MenuSearch`,mt,e),u=q(),f=(0,z.useRef)(null),p=P(c,f),m=(0,z.useRef)(i);m.current=i,(0,z.useEffect)(()=>u.registerSearch(),[u.registerSearch]),(0,z.useEffect)(()=>{s?u.searchExitClearRef.current=()=>{m.current?.({currentTarget:{value:``}})}:u.searchExitClearRef.current=null},[s,u.searchExitClearRef]),(0,z.useEffect)(()=>{u.opened||dt(lt(f.current))},[u.opened]);let h=U(i,e=>{dt(lt(e.currentTarget))}),g=U(r,e=>{if(e.defaultPrevented)return;let t=lt(e.currentTarget),n=ut(t);if(e.key===`ArrowDown`){if(e.preventDefault(),n.length===0)return;let r=pt(n);ft(n[r>=n.length-1?u.loop?0:r:r+1]??null,t)}else if(e.key===`ArrowUp`){if(e.preventDefault(),n.length===0)return;let r=pt(n);ft(n[r<=0?r===-1||u.loop?n.length-1:0:r-1]??null,t)}else if(e.key===`Home`)e.preventDefault(),n.length>0&&ft(n[0],t);else if(e.key===`End`)e.preventDefault(),n.length>0&&ft(n[n.length-1],t);else if(e.key===`Enter`){if(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)return;let t=n[pt(n)];t&&(e.preventDefault(),t.hasAttribute(`data-sub-menu-item`)?(t.focus(),t.dispatchEvent(new KeyboardEvent(`keydown`,{key:`ArrowRight`,bubbles:!0}))):t.click())}}),_=u.getStyles(`search`);return(0,V.jsx)(d,{"data-autofocus":!0,"data-mantine-stop-propagation":!0,type:`search`,size:o,...l,ref:p,classNames:[{input:_.className},t],styles:[{input:_.style},n],onKeyDown:g,onChange:h,__staticSelector:`Menu`})});ht.classes=Y,ht.displayName=`@mantine/core/MenuSearch`;var gt=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,onMouseEnter:s,onMouseLeave:c,onPointerEnter:l,onPointerLeave:u,onKeyDown:d,children:f,ref:p,...m}=a(`MenuSubDropdown`,null,e),h=(0,z.useRef)(null),g=q(),_=(0,z.use)(J),v=$e({enabled:!g.hasSearch,opened:_?.opened??!1,getDropdown:()=>h.current}),y=U(d,e=>{v(e),!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1&&e.key!==` `&&e.stopPropagation()}),b=_?.getFloatingProps({onMouseEnter:s,onMouseLeave:c,onPointerEnter:l,onPointerLeave:u});return(0,V.jsx)(K.Dropdown,{...m,...b,role:`menu`,"aria-orientation":`vertical`,ref:P(p,h,_?.setFloating),...g.getStyles(`dropdown`,{className:n,style:r,styles:i,classNames:t,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:y,children:f})});gt.classes=Y,gt.displayName=`@mantine/core/MenuSubDropdown`;var _t=i(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,color:u,leftSection:d,rightSection:f,children:p,disabled:m,"data-disabled":h,closeMenuOnClick:g,ref:_,...v}=a(`MenuSubItem`,null,e),y=q(),b=(0,z.use)(J),x=c(),{dir:S}=R(),C=(0,z.useRef)(null),w=v,T=u?x.variantColorResolver({color:u,theme:x,variant:`light`}):void 0,E=u?s({color:u,theme:x}):null,D=U(w.onKeyDown,e=>{e.key===`ArrowRight`&&(b?.open(),b?.focusFirstItem()),e.key===`ArrowLeft`&&b?.parentContext&&(b.parentContext.close(),b.parentContext.focusParentItem())}),O=U(w.onClick,()=>{!h&&g&&y.closeDropdownImmediately()}),k=U(w.onMouseMove,()=>{if(!y.hasSearch)return;let e=C.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==C.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),A=b?.getReferenceProps({onMouseEnter:w.onMouseEnter,onMouseLeave:w.onMouseLeave,onPointerEnter:w.onPointerEnter,onPointerLeave:w.onPointerLeave});return(0,V.jsxs)(I,{onMouseDown:e=>e.preventDefault(),...v,...A,unstyled:y.unstyled,tabIndex:y.menuItemTabIndex,...y.getStyles(`item`,{className:n,style:r,styles:i,classNames:t}),ref:P(C,_,b?.setReference),role:`menuitem`,disabled:m,"data-menu-item":!0,"data-sub-menu-item":!0,"data-disabled":m||h||void 0,"data-mantine-stop-propagation":!0,onClick:O,onMouseMove:k,onKeyDown:H({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:y.loop,dir:S,orientation:`vertical`,onKeyDown:D}),__vars:{"--menu-item-color":E?.isThemeColor&&E?.shade===void 0?`var(--mantine-color-${E.color}-6)`:T?.color,"--menu-item-hover":T?.hover},children:[y.alignItemsLabels===`all`&&(0,V.jsx)(`div`,{...y.getStyles(`itemIndicator`,{styles:i,classNames:t}),"data-placeholder":!0}),d&&(0,V.jsx)(`div`,{...y.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`left`,children:d}),p&&(0,V.jsx)(`div`,{...y.getStyles(`itemLabel`,{styles:i,classNames:t}),"data-menu-item-label":!0,children:p}),(0,V.jsx)(`div`,{...y.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`right`,children:f||(0,V.jsx)(l,{...y.getStyles(`chevron`),size:14})})]})});_t.classes=Y,_t.displayName=`@mantine/core/MenuSubItem`;function vt({children:e,refProp:t}){if(!x(e))throw Error(`Menu.Sub.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);return q(),(0,V.jsx)(K.Target,{refProp:t,popupType:`menu`,children:e})}vt.displayName=`@mantine/core/MenuSubTarget`;var yt={offset:0,position:`right-start`,safeAreaPolygon:!0,transitionProps:{duration:0},openDelay:0,middlewares:{shift:{crossAxis:!0}}};function X(e){let{children:t,closeDelay:n,openDelay:r,position:i,safeAreaPolygon:o,opened:s,onChange:c,...l}=a(`MenuSub`,yt,e),u=ne(),[d,f]=D({value:s,finalValue:!1,onChange:c}),p=(0,z.use)(J),m=q(),{dir:h}=R(),g=pe(h,i),_=p?.registerOpenSub??m.registerOpenSub,v=(0,z.useRef)(null),y=(0,z.useCallback)(e=>{let t=v.current;return t&&t!==e&&t(),v.current=e,()=>{v.current===e&&(v.current=null)}},[]),b=(0,z.useRef)(f);b.current=f;let x=(0,z.useCallback)(()=>b.current(!0),[]),S=(0,z.useCallback)(()=>b.current(!1),[]);(0,z.useEffect)(()=>{if(d)return _(S)},[d,_,S]);let{context:C,refs:w}=F({placement:g,open:d,onOpenChange:e=>{e?x():S()}}),{getReferenceProps:T,getFloatingProps:E}=L([M(C,{handleClose:o?re(typeof o==`object`?o:void 0):void 0,delay:{open:r,close:n}})]);return(0,V.jsx)(J,{value:{opened:d,close:S,open:x,focusFirstItem:()=>window.setTimeout(()=>{document.getElementById(`${u}-dropdown`)?.querySelectorAll(`[data-menu-item]:not([data-disabled])`)[0]?.focus()},16),focusParentItem:()=>window.setTimeout(()=>{document.getElementById(`${u}-target`)?.focus()},16),parentContext:p,setReference:w.setReference,setFloating:w.setFloating,getReferenceProps:T,getFloatingProps:E,registerOpenSub:y},children:(0,V.jsx)(K,{opened:d,onChange:e=>e?x():S(),withArrow:!1,id:u,position:i,...l,withinPortal:!1,children:t})})}X.extend=e=>e,X.displayName=`@mantine/core/MenuSub`,X.Target=vt,X.Dropdown=gt,X.Item=_t;var bt={refProp:`ref`};function xt(e){let{children:t,refProp:n,...r}=a(`MenuTarget`,bt,e),i=m(t);if(!i)throw Error(`Menu.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let o=q(),s=i.props,c=U(s.onClick,()=>{o.trigger===`click`?o.toggleDropdown():o.trigger===`click-hover`&&(o.setOpenedViaClick(!0),o.opened||o.openDropdown())}),l=U(s.onMouseEnter,()=>(o.trigger===`hover`||o.trigger===`click-hover`)&&o.openDropdown()),u=U(s.onMouseLeave,()=>{(o.trigger===`hover`||o.trigger===`click-hover`&&!o.openedViaClick)&&o.closeDropdown()});return(0,V.jsx)(K.Target,{refProp:n,popupType:`menu`,...r,children:(0,z.cloneElement)(i,{onClick:c,onMouseEnter:l,onMouseLeave:u,"data-expanded":o.opened?!0:void 0})})}xt.displayName=`@mantine/core/MenuTarget`;var St={trapFocus:!0,closeOnItemClick:!0,withInitialFocusPlaceholder:!0,clickOutsideEvents:[`mousedown`,`touchstart`,`keydown`],loop:!0,trigger:`click`,openDelay:0,closeDelay:100,menuItemTabIndex:-1,alignItemsLabels:`with-indicators`},Z=r(e=>{let t=a(`Menu`,St,e),{children:n,onOpen:r,onClose:i,opened:o,defaultOpened:s,trapFocus:c,onChange:l,closeOnItemClick:d,loop:p,closeOnEscape:m,trigger:h,openDelay:g,closeDelay:_,classNames:v,styles:y,unstyled:b,variant:x,vars:S,menuItemTabIndex:C,keepMounted:w,withInitialFocusPlaceholder:T,attributes:E,onExitTransitionEnd:O,alignItemsLabels:k,checkIcon:A,...ee}=t,te=u({name:`Menu`,classes:Y,props:t,classNames:v,styles:y,unstyled:b,attributes:E}),[j,ne]=D({value:o,defaultValue:s,finalValue:!1,onChange:l}),[re,M]=(0,z.useState)(!1),N=()=>{ne(!1),M(!1),j&&i?.()},P=()=>{ne(!0),!j&&r?.()},ie=()=>{j?N():P()},{openDropdown:ae,closeDropdown:oe}=W({open:P,close:N,closeDelay:_,openDelay:g}),F=(0,z.useRef)(null),I=(0,z.useCallback)(e=>{let t=F.current;return t&&t!==e&&t(),F.current=e,()=>{F.current===e&&(F.current=null)}},[]),L=(0,z.useRef)(0),[se,R]=(0,z.useState)(!1),ce=(0,z.useCallback)(()=>(L.current+=1,L.current===1&&R(!0),()=>{--L.current,L.current===0&&R(!1)}),[]),le=(0,z.useRef)(null),ue=()=>{le.current?.(),O?.()},de=e=>xe(`[data-menu-item]`,`[data-menu-dropdown]`,e),{resolvedClassNames:fe,resolvedStyles:pe}=f({classNames:v,styles:y,props:t});return(0,V.jsx)(Ue,{value:{getStyles:te,opened:j,toggleDropdown:ie,getItemIndex:de,openedViaClick:re,setOpenedViaClick:M,closeOnItemClick:d,closeDropdown:h===`click`?N:oe,openDropdown:h===`click`?P:ae,closeDropdownImmediately:N,loop:p,trigger:h,unstyled:b,menuItemTabIndex:C,withInitialFocusPlaceholder:T,registerOpenSub:I,hasSearch:se,registerSearch:ce,searchExitClearRef:le,alignItemsLabels:k,checkIcon:A},children:(0,V.jsx)(K,{returnFocus:!0,...ee,opened:j,onChange:ie,defaultOpened:s,trapFocus:!w&&c,closeOnEscape:m,__staticSelector:`Menu`,classNames:fe,styles:pe,unstyled:b,variant:x,keepMounted:w,onExitTransitionEnd:ue,children:n})})});Z.displayName=`@mantine/core/Menu`,Z.classes=Y,Z.Item=tt,Z.Label=nt,Z.Dropdown=et,Z.Target=xt,Z.Divider=Ye,Z.Search=ht,Z.Sub=X,Z.CheckboxItem=qe,Z.CheckboxGroup=Ge,Z.RadioItem=ot,Z.RadioGroup=it,Z.ContextMenu=Je;var Ct=new Map([[`bold`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M144,128a16,16,0,1,1-16-16A16,16,0,0,1,144,128ZM60,112a16,16,0,1,0,16,16A16,16,0,0,0,60,112Zm136,0a16,16,0,1,0,16,16A16,16,0,0,0,196,112Z`}))],[`duotone`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M240,96v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V96A16,16,0,0,1,32,80H224A16,16,0,0,1,240,96Z`,opacity:`0.2`}),z.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z`}))],[`fill`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M224,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V96A16,16,0,0,0,224,80ZM60,140a12,12,0,1,1,12-12A12,12,0,0,1,60,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,196,140Z`}))],[`light`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM60,118a10,10,0,1,0,10,10A10,10,0,0,0,60,118Zm136,0a10,10,0,1,0,10,10A10,10,0,0,0,196,118Z`}))],[`regular`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z`}))],[`thin`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-76-8a8,8,0,1,0,8,8A8,8,0,0,0,60,120Zm136,0a8,8,0,1,0,8,8A8,8,0,0,0,196,120Z`}))]]),wt=z.forwardRef((e,t)=>z.createElement(ce,{ref:t,...e,weights:Ct}));wt.displayName=`DotsThreeIcon`;var Tt=wt,Et=[`dashboards`],Dt=3e4;async function Q(e,t){let{json:n,...r}=t??{},i=new Headers(r.headers),a=r.body;n!==void 0&&(i.set(`content-type`,`application/json`),a=JSON.stringify(n));let o=await he(e,{...r,headers:i,body:a}),s=await o.json().catch(()=>({}));if(!o.ok)throw Ot(o,s);return s}var Ot=(e,t)=>new ge(t.message??`Request failed (${e.status})`,e.status,t.problems??[],t.code??``),$=e=>`/api/dashboards/${encodeURIComponent(e)}`,kt=()=>Q(`/api/dashboards`).then(e=>e.dashboards),At=(e,t)=>Q($(e),{signal:t}),jt=(e,t)=>Q(`${$(e)}/versions`,{signal:t}).then(e=>e.versions),Mt=(e,t,n)=>Q(`${$(e)}/versions/${t}`,{signal:n}),Nt=(e,t)=>Q(`${$(e)}/versions/${t}/restore`,{method:`POST`}),Pt=(e,t,n,r)=>Q($(e),{method:`PUT`,json:{spec:t,base_version:n,message:r}}),Ft=(e,t,n,r)=>Q($(e),{method:`PATCH`,json:{operations:t,base_version:n,message:r}});async function It(e,t,n,r=!1){let i=r?{"cache-control":`no-cache`}:{};if(!n)return Q(`/api/queries/run`,{method:`POST`,headers:i,json:e,signal:t}).then(e=>e.results);let a=await he(`/api/queries/run`,{method:`POST`,headers:{...i,"content-type":`application/json`,accept:`application/x-ndjson`},body:JSON.stringify(e),signal:t});if(!a.ok)throw Ot(a,await a.json().catch(()=>({})));let o=[],s=a.body.pipeThrough(new TextDecoderStream).getReader(),c=``;try{for(;;){let{done:e,value:t}=await s.read();c+=t??``;let r;for(;(r=c.indexOf(` +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{Dt as r,Et as i,Ft as a,Ht as o,Jt as s,Lt as c,M as l,Nt as u,P as d,Pt as f,Q as p,Qt as m,Tt as h,X as g,Xt as _,Y as v,Z as y,Zt as b,_n as x,_t as S,an as C,bn as w,bt as T,dn as E,en as D,fn as O,ft as k,gn as A,gt as ee,hn as te,ht as j,in as ne,it as re,lt as M,mt as N,nn as P,on as ie,pt as ae,sn as oe,st as F,tt as I,ut as L,vt as se,wt as R,x as ce,yt as le}from"./brand-D6fP-cLS.js";import{t as ue}from"./noop-mXPS5vjY.js";import{c as de,l as fe,o as pe,s as me}from"./format-BZjbsxwM.js";import{a as he,s as ge}from"./auth-DcVParCH.js";var z=n(e(),1);function B(e,t){let n=e;for(;(n=n.parentElement)&&!n.matches(t););return n}var V=t();function _e(e,t,n){for(let n=e-1;n>=0;--n)if(!t[n].disabled)return n;if(n){for(let e=t.length-1;e>-1;--e)if(!t[e].disabled)return e}return e}function ve(e,t,n){for(let n=e+1;n{n?.(s);let c=Array.from(B(s.currentTarget,e)?.querySelectorAll(t)||[]).filter(t=>ye(s.currentTarget,t,e)),l=c.findIndex(e=>s.currentTarget===e),u=ve(l,c,r),d=_e(l,c,r),f=a===`rtl`?d:u,p=a===`rtl`?u:d;switch(s.key){case`ArrowRight`:o===`horizontal`&&(s.stopPropagation(),s.preventDefault(),c[f].focus(),i&&c[f].click());break;case`ArrowLeft`:o===`horizontal`&&(s.stopPropagation(),s.preventDefault(),c[p].focus(),i&&c[p].click());break;case`ArrowUp`:o===`vertical`&&(s.stopPropagation(),s.preventDefault(),c[d].focus(),i&&c[d].click());break;case`ArrowDown`:o===`vertical`&&(s.stopPropagation(),s.preventDefault(),c[u].focus(),i&&c[u].click());break;case`Home`:s.stopPropagation(),s.preventDefault(),c[ve(-1,c,!1)]?.focus();break;case`End`:s.stopPropagation(),s.preventDefault(),c[_e(c.length,c,!1)]?.focus()}}}function be(e,t={active:!0}){return typeof e!=`function`||!t.active?t.onKeyDown||ue:n=>{n.key===`Escape`&&(e(n),t.onTrigger?.())}}function U(e,t){return n=>{e?.(n),t?.(n)}}function xe(e,t,n){return n?Array.from(B(n,t)?.querySelectorAll(e)||[]).findIndex(e=>e===n):null}var Se=[`mousedown`,`touchstart`];function Ce(e,t,n,r=!0,i=!1){let a=(0,z.useRef)(null),o=t||Se,s=(0,z.useEffectEvent)(t=>{let{target:r}=t??{};if(!document.body.contains(r)&&r?.tagName!==`HTML`)return;let i=t.composedPath();Array.isArray(n)?n.every(e=>!!e&&!i.includes(e))&&e(t):a.current&&!i.includes(a.current)&&e(t)}),c=o.join(`,`);return(0,z.useEffect)(()=>{if(!r)return;let e=c.split(`,`);return e.forEach(e=>document.addEventListener(e,s,i)),()=>{e.forEach(e=>document.removeEventListener(e,s,i))}},[c,r,i]),a}var we=[`mouse`,`touch`],Te=10;function Ee(e,t={}){let{threshold:n=400,events:r=we,cancelOnMove:i=!1,onStart:a,onFinish:o,onCancel:s}=t,c=(0,z.useRef)(!1),l=(0,z.useRef)(!1),u=(0,z.useRef)(-1),d=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>window.clearTimeout(u.current),[]);let f=r.join(`,`);return(0,z.useMemo)(()=>{if(typeof e!=`function`)return{};let t=i!==!1,f=i===!0?Te:i===!1?0:i,p=t=>{(ke(t)||Oe(t))&&(a&&a(t),d.current=De(t),l.current=!0,u.current=window.setTimeout(()=>{e(t),c.current=!0},n))},m=e=>{(ke(e)||Oe(e))&&(c.current?o&&o(e):l.current&&s&&s(e),c.current=!1,l.current=!1,d.current=null,u.current!==-1&&(window.clearTimeout(u.current),u.current=-1))},h=e=>{if(!t||!l.current||c.current)return;let n=De(e);if(!n||!d.current)return;let r=n.x-d.current.x,i=n.y-d.current.y;Math.sqrt(r*r+i*i)>f&&m(e)},g={};return r.includes(`mouse`)&&(g.onMouseDown=p,g.onMouseUp=m,g.onMouseLeave=m,t&&(g.onMouseMove=h)),r.includes(`touch`)&&(g.onTouchStart=p,g.onTouchEnd=m,g.onTouchCancel=m,t&&(g.onTouchMove=h)),g},[e,n,s,o,a,i,f])}function De(e){if(Oe(e)){let t=e.touches[0]??e.changedTouches[0];return t?{x:t.clientX,y:t.clientY}:null}return{x:e.clientX,y:e.clientY}}function Oe(e){return window.TouchEvent?e.nativeEvent instanceof TouchEvent:`touches`in e.nativeEvent}function ke(e){return e.nativeEvent instanceof MouseEvent}function W({open:e,close:t,openDelay:n,closeDelay:r}){let i=(0,z.useRef)(-1),a=(0,z.useRef)(-1),o=()=>{window.clearTimeout(i.current),window.clearTimeout(a.current)};return(0,z.useEffect)(()=>o,[]),{openDropdown:()=>{o(),n===0||n===void 0?e():i.current=window.setTimeout(e,n)},closeDropdown:()=>{o(),r===0||r===void 0?t():a.current=window.setTimeout(t,r)}}}var[Ae,G]=A(`Popover component was not found in the tree`);function je({childProps:e,disabled:t,opened:n,longPressDelay:r=500,setReference:i,open:a}){let o=(0,z.useRef)(!1),s=(0,z.useRef)(!1),c=(0,z.useRef)(null),l=(0,z.useRef)(t);l.current=t;let u=(e,t,n)=>{i({getBoundingClientRect:()=>({x:e,y:t,width:0,height:0,top:t,left:e,right:e,bottom:t,toJSON:()=>void 0}),contextElement:n}),a()},d=U(e.onMouseDown,e=>{t||e.button===2&&e.stopPropagation()}),f=U(e.onContextMenu,e=>{t||e.defaultPrevented||(e.preventDefault(),!s.current&&(u(e.clientX,e.clientY,e.currentTarget),o.current&&(s.current=!0)))}),p=Ee(e=>{if(l.current||s.current)return;let t=e,n=t.touches[0]??t.changedTouches[0];n&&(u(n.clientX,n.clientY,c.current),s.current=!0)},{threshold:r,events:[`touch`],cancelOnMove:!0,onStart:e=>{o.current=!0,s.current=!1,c.current=e.currentTarget},onFinish:e=>{o.current=!1,s.current=!1,l.current||e.preventDefault()},onCancel:()=>{o.current=!1,s.current=!1}});return{onContextMenu:f,onMouseDown:d,onTouchStart:U(e.onTouchStart,p.onTouchStart),onTouchEnd:U(e.onTouchEnd,p.onTouchEnd),onTouchCancel:U(e.onTouchCancel,p.onTouchCancel),onTouchMove:U(e.onTouchMove,p.onTouchMove),style:t?e.style:{...e.style,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},"data-expanded":n?!0:void 0}}function Me(e){let{children:t,disabled:n,longPressDelay:r}=a(`PopoverContextMenu`,null,e),i=m(t);if(!i)throw Error(`Popover.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let o=G(),s=je({childProps:i.props,disabled:n||o.disabled,opened:o.opened,longPressDelay:r,setReference:o.reference,open:()=>{o.opened||o.onToggle()}});return(0,z.cloneElement)(i,s)}Me.displayName=`@mantine/core/PopoverContextMenu`;var Ne={dropdown:`m_38a85659`,arrow:`m_a31dc6c1`,overlay:`m_3d7bc908`},Pe=r(e=>{let t=a(`PopoverDropdown`,null,e),{className:n,style:r,vars:i,children:o,onKeyDownCapture:s,variant:c,classNames:l,styles:u,ref:d,...f}=t,p=G(),{dir:m}=R(),_=p.arrowPosition===`merge`&&p.withArrow?de({position:p.placement,dir:m}):void 0,b=C({opened:p.opened,shouldReturnFocus:p.returnFocus}),x=p.withRoles?{"aria-labelledby":p.getTargetId(),id:p.getDropdownId(),role:`dialog`,tabIndex:-1}:{},S=P(d,p.floating);return p.disabled?null:(0,V.jsx)(y,{...p.portalProps,withinPortal:p.withinPortal,children:(0,V.jsx)(g,{mounted:p.opened,...p.transitionProps,transition:p.transitionProps?.transition||`fade`,duration:p.transitionProps?.duration??150,keepMounted:p.keepMounted,keepMountedMode:p.keepMountedMode,exitDuration:typeof p.transitionProps?.exitDuration==`number`?p.transitionProps.exitDuration:p.transitionProps?.duration,children:e=>(0,V.jsx)(v,{active:p.trapFocus&&p.opened,innerRef:S,children:(0,V.jsxs)(h,{...x,...f,variant:c,onKeyDownCapture:be(()=>{p.onClose?.(),p.onDismiss?.()},{active:p.closeOnEscape,onTrigger:b,onKeyDown:s}),"data-position":p.placement,"data-fixed":p.floatingStrategy===`fixed`||void 0,...p.getStyles(`dropdown`,{className:n,props:t,classNames:l,styles:u,style:[{...e,..._,zIndex:p.zIndex,top:p.y??0,left:p.x??0,width:p.width===`target`?void 0:w(p.width),...p.referenceHidden?{display:`none`}:null},p.resolvedStyles?.dropdown,u?.dropdown,r]}),children:[o,(0,V.jsx)(me,{ref:p.arrowRef,arrowX:p.arrowX,arrowY:p.arrowY,visible:p.withArrow,position:p.placement,arrowSize:p.arrowSize,arrowRadius:p.arrowRadius,arrowOffset:p.arrowOffset,arrowPosition:p.arrowPosition,...p.getStyles(`arrow`,{props:t,classNames:l,styles:u})})]})})})})});Pe.classes=Ne,Pe.displayName=`@mantine/core/PopoverDropdown`;var Fe={refProp:`ref`,popupType:`dialog`},Ie=r(e=>{let{children:t,refProp:n,popupType:r,ref:i,...o}=a(`PopoverTarget`,Fe,e),s=m(t);if(!s)throw Error(`Popover.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let c=o,l=G(),u=P(l.reference,fe(s),i),d=l.withRoles?{"aria-haspopup":r,"aria-expanded":l.opened,"aria-controls":l.opened?l.getDropdownId():void 0,id:l.getTargetId()}:{},f=s.props;return(0,z.cloneElement)(s,{...c,...d,...l.targetProps,className:_(l.targetProps.className,c.className,f.className),[n]:u,...l.controlled?null:{onClick:e=>{l.onToggle(),f.onClick?.(e)}}})});Ie.displayName=`@mantine/core/PopoverTarget`;function Le(e){if(e===void 0)return{shift:!0,flip:!0};let t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function Re(e,t,n,r){let i=Le(e.middlewares),a=[S(e.offset),N()];if(i.flip&&!n){let e=typeof i.flip==`boolean`?{}:i.flip,t=r?{fallbackStrategy:`initialPlacement`,...e}:e;a.push(ae(t))}if(i.shift){let t=typeof i.shift==`boolean`?{}:i.shift;a.push(se(n=>{let r=n.placement.startsWith(`top`)||n.placement.startsWith(`bottom`);return{limiter:ee(),padding:5,...e.width===`target`&&r?{mainAxis:!1}:null,...t}}))}return i.inline&&a.push(typeof i.inline==`boolean`?j():j(i.inline)),a.push(k({element:e.arrowRef,padding:e.arrowOffset})),(i.size||e.width===`target`)&&a.push(le({...typeof i.size==`boolean`?{}:i.size,apply({rects:n,availableWidth:r,availableHeight:a,...o}){let s=t().refs.floating.current?.style??{};i.size&&(typeof i.size==`object`&&i.size.apply?i.size.apply({rects:n,availableWidth:r,availableHeight:a,...o}):Object.assign(s,{maxWidth:`${r}px`,maxHeight:`${a}px`})),e.width===`target`&&Object.assign(s,{width:`${n.reference.width}px`})}})),a}function ze(e){let[t,n]=D({value:e.opened,defaultValue:e.defaultOpened,finalValue:!1,onChange:e.onChange}),r=(0,z.useRef)(t),i=(0,z.useRef)(!1),[a,o]=(0,z.useState)(null),s=e.preventPositionChangeWhenVisible!==!1,c=(0,z.useRef)(t);t!==c.current&&(c.current=t,t&&a!==null&&o(null));let l=(0,z.useRef)(e.position);e.position!==l.current&&(l.current=e.position,i.current=!1,a!==null&&o(null));let u=(0,z.useCallback)(()=>o(null),[]),d=()=>{t&&!e.disabled&&n(!1)},f=()=>{e.disabled||n(!t)},p=F({open:t,strategy:e.strategy,placement:s?a??e.position:e.position,middleware:Re(e,()=>p,s&&a!==null,s),whileElementsMounted:e.keepMounted?void 0:T});(0,z.useEffect)(()=>{if(!e.keepMounted)return;let n=p.refs.reference.current,r=p.refs.floating.current;if(t&&n&&r)return T(n,r,p.update)},[e.keepMounted,t,p.update,p.elements.reference,p.elements.floating]),oe(()=>{if(!t){i.current=!1;return}if(!s||a!==null)return;let e=p.refs.floating.current;if(e&&e.offsetHeight!==0&&e.offsetWidth!==0){if(!i.current){i.current=!0,p.update();return}p.isPositioned&&o(p.placement)}},[s,t,p.isPositioned,p.placement,a,p.update]);let m=(0,z.useRef)(p.placement);return oe(()=>{m.current!==p.placement&&(m.current=p.placement,e.onPositionChange?.(p.placement))},[p.placement]),ie(()=>{t!==r.current&&(t?e.onOpen?.():e.onClose?.()),r.current=t},[t,e.onClose,e.onOpen]),{floating:p,controlled:typeof e.opened==`boolean`,opened:t,onClose:d,onToggle:f,resetLockedPlacement:u}}var Be={position:`bottom`,offset:8,transitionProps:{transition:`fade`,duration:150},middlewares:{flip:!0,shift:!0,inline:!1},arrowSize:7,arrowOffset:5,arrowRadius:0,arrowPosition:`side`,closeOnClickOutside:!0,withinPortal:!0,closeOnEscape:!0,trapFocus:!1,withRoles:!0,returnFocus:!1,withOverlay:!1,hideDetached:!0,preventPositionChangeWhenVisible:!0,clickOutsideEvents:[`mousedown`,`touchstart`],clickOutsideCapture:!1,zIndex:te(`popover`),__staticSelector:`Popover`,width:`max-content`},Ve=b((e,{radius:t,shadow:n})=>({dropdown:{"--popover-radius":t===void 0?void 0:E(t),"--popover-shadow":O(n)}}));function K(e){let t=a(`Popover`,Be,e),{children:n,position:r,offset:i,onPositionChange:s,opened:c,transitionProps:l,onExitTransitionEnd:d,onEnterTransitionEnd:m,width:h,middlewares:_,withArrow:v,arrowSize:b,arrowOffset:x,arrowRadius:S,arrowPosition:C,unstyled:w,classNames:T,styles:E,closeOnClickOutside:D,withinPortal:O,portalProps:k,closeOnEscape:A,clickOutsideEvents:ee,clickOutsideCapture:te,trapFocus:j,onClose:re,onDismiss:M,onOpen:N,onChange:P,zIndex:ie,radius:ae,shadow:oe,id:F,defaultOpened:I,__staticSelector:L,withRoles:se,disabled:ce,returnFocus:le,variant:ue,keepMounted:de,keepMountedMode:fe,vars:me,floatingStrategy:he,withOverlay:ge,overlayProps:B,hideDetached:_e,attributes:ve,preventPositionChangeWhenVisible:ye,...H}=t,be=u({name:L,props:t,classes:Ne,classNames:T,styles:E,unstyled:w,attributes:ve,rootSelector:`dropdown`,vars:me,varsResolver:Ve}),{resolvedStyles:U}=f({classNames:T,styles:E,props:t}),xe=(0,z.useRef)(null),[Se,we]=(0,z.useState)(null),[Te,Ee]=(0,z.useState)(null),{dir:De}=R(),Oe=o(),ke=ne(F),W=ze({middlewares:_,width:h,position:pe(De,r),offset:typeof i==`number`?i+(v?b/2:0):i,arrowRef:xe,arrowOffset:x,onPositionChange:s,opened:c,defaultOpened:I,onChange:P,onOpen:N,onClose:re,onDismiss:M,strategy:he,disabled:ce,preventPositionChangeWhenVisible:ye,keepMounted:de});Ce(()=>{D&&(W.onClose(),M?.())},ee,[Se,Te],!0,te);let G=(0,z.useCallback)(e=>{we(e),W.floating.refs.setReference(e)},[W.floating.refs.setReference]),je=(0,z.useCallback)(e=>{Ee(e),W.floating.refs.setFloating(e)},[W.floating.refs.setFloating]),Me=(0,z.useCallback)(()=>{l?.onExited?.(),d?.(),W.resetLockedPlacement()},[l?.onExited,d,W.resetLockedPlacement]),Pe=(0,z.useCallback)(()=>{l?.onEntered?.(),m?.()},[l?.onEntered,m]);return(0,V.jsxs)(Ae,{value:{returnFocus:le,disabled:ce,controlled:W.controlled,reference:G,floating:je,x:W.floating.x,y:W.floating.y,arrowX:W.floating?.middlewareData?.arrow?.x,arrowY:W.floating?.middlewareData?.arrow?.y,opened:W.opened,arrowRef:xe,transitionProps:{...l,onExited:Me,onEntered:Pe},width:h,withArrow:v,arrowSize:b,arrowOffset:x,arrowRadius:S,arrowPosition:C,placement:W.floating.placement,trapFocus:j,withinPortal:O,portalProps:k,zIndex:ie,radius:ae,shadow:oe,closeOnEscape:A,onDismiss:M,onClose:W.onClose,onToggle:W.onToggle,getTargetId:()=>ke,getDropdownId:()=>`${ke}-dropdown`,withRoles:se,targetProps:H,__staticSelector:L,classNames:T,styles:E,unstyled:w,variant:ue,keepMounted:de,keepMountedMode:fe,getStyles:be,resolvedStyles:U,floatingStrategy:he,referenceHidden:_e&&Oe!==`test`?W.floating.middlewareData.hide?.referenceHidden:!1},children:[n,ge&&(0,V.jsx)(g,{transition:`fade`,mounted:W.opened,duration:l?.duration||250,exitDuration:l?.exitDuration||250,children:e=>(0,V.jsx)(y,{withinPortal:O,children:(0,V.jsx)(p,{...B,...be(`overlay`,{className:B?.className,style:[e,B?.style]})})})})]})}K.Target=Ie,K.Dropdown=Pe,K.ContextMenu=Me,K.varsResolver=Ve,K.displayName=`@mantine/core/Popover`,K.extend=e=>e,K.withProps=e=>{let t=t=>(0,V.jsx)(K,{...e,...t});return t.extend=K.extend,t.displayName=`WithProps(${K.displayName})`,t};function He({size:e,style:t,...n}){let r=e===void 0?t:{width:w(e),height:w(e),...t};return(0,V.jsx)(`svg`,{viewBox:`0 0 10 7`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:r,"aria-hidden":!0,...n,children:(0,V.jsx)(`path`,{d:`M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z`,fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`})})}var[Ue,q]=A(`Menu component was not found in the tree`),We=(0,z.createContext)(null);function Ge(e){let{value:t,defaultValue:n,onChange:r,children:i}=a(`MenuCheckboxGroup`,null,e),[o,s]=D({value:t,defaultValue:n,finalValue:[],onChange:r}),c=(0,z.useCallback)(e=>{s(o.includes(e)?o.filter(t=>t!==e):[...o,e])},[o,s]);return(0,V.jsx)(We,{value:{values:o,onChange:c},children:i})}Ge.displayName=`@mantine/core/MenuCheckboxGroup`;var J=(0,z.createContext)(null);function Ke({role:e,checked:t,indicator:n,onSelect:r,color:i,closeMenuOnClick:a,rightSection:o,children:l,disabled:u,dataDisabled:d,className:f,style:p,styles:m,classNames:h,buttonRef:g,others:_}){let v=q(),y=(0,z.use)(J),b=c(),{dir:x}=R(),S=(0,z.useRef)(null),C=U(_.onClick,()=>{d||(r(),a&&v.closeDropdownImmediately())}),w=U(_.onMouseMove,()=>{if(!v.hasSearch)return;let e=S.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==S.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),T=U(_.onKeyDown,e=>{e.key===`ArrowLeft`&&y&&(y.close(),y.focusParentItem())}),E=i?b.variantColorResolver({color:i,theme:b,variant:`light`}):void 0,D=i?s({color:i,theme:b}):null,O=v.alignItemsLabels!==`none`||t;return(0,V.jsxs)(I,{onMouseDown:e=>e.preventDefault(),..._,unstyled:v.unstyled,tabIndex:v.menuItemTabIndex,...v.getStyles(`item`,{className:f,style:p,styles:m,classNames:h}),ref:P(S,g),role:e,"aria-checked":t,disabled:u,"data-menu-item":!0,"data-checked":t||void 0,"data-disabled":u||d||void 0,"data-mantine-stop-propagation":!0,onClick:C,onMouseMove:w,onKeyDown:H({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:v.loop,dir:x,orientation:`vertical`,onKeyDown:T}),__vars:{"--menu-item-color":D?.isThemeColor&&D?.shade===void 0?`var(--mantine-color-${D.color}-6)`:E?.color,"--menu-item-hover":E?.hover},children:[O&&(0,V.jsx)(`div`,{...v.getStyles(`itemIndicator`,{styles:m,classNames:h}),"data-checked":t||void 0,children:t?n:null}),l&&(0,V.jsx)(`div`,{...v.getStyles(`itemLabel`,{styles:m,classNames:h}),"data-menu-item-label":!0,children:l}),o&&(0,V.jsx)(`div`,{...v.getStyles(`itemSection`,{styles:m,classNames:h}),"data-position":`right`,children:o})]})}var Y={dropdown:`m_dc9b7c9f`,label:`m_9bfac126`,divider:`m_efdf90cb`,item:`m_99ac2aa1`,search:`m_ef8769b6`,itemLabel:`m_5476e0d3`,itemIndicator:`m_8395186e`,itemSection:`m_8b75e504`,chevron:`m_b85b0bed`},qe=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,color:s,closeMenuOnClick:c,rightSection:l,children:u,disabled:d,"data-disabled":f,value:p,checked:m,defaultChecked:h,onChange:g,checkIcon:_,ref:v,...y}=a(`MenuCheckboxItem`,null,e),b=q(),x=(0,z.use)(We),S=x&&p!==void 0?x.values.includes(p):void 0,[C,w]=D({value:m??S,defaultValue:h,finalValue:!1,onChange:g}),T=_??b.checkIcon??(0,V.jsx)(He,{size:10});return(0,V.jsx)(Ke,{role:`menuitemcheckbox`,checked:C,indicator:T,onSelect:()=>{g?w(!C):x&&p!==void 0?x.onChange(p):w(!C)},color:s,closeMenuOnClick:c,rightSection:l,disabled:d,dataDisabled:f,className:n,style:r,styles:i,classNames:t,buttonRef:v,others:y,children:u})});qe.classes=Y,qe.displayName=`@mantine/core/MenuCheckboxItem`;function Je(e){let{children:t,disabled:n,longPressDelay:r}=a(`MenuContextMenu`,null,e),i=m(t);if(!i)throw Error(`Menu.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let o=q(),s=G(),c=je({childProps:i.props,disabled:n||s.disabled,opened:o.opened,longPressDelay:r,setReference:s.reference,open:()=>o.openDropdown()});return(0,z.cloneElement)(i,c)}Je.displayName=`@mantine/core/MenuContextMenu`;var Ye=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`MenuDivider`,null,e),c=q();return(0,V.jsx)(h,{...c.getStyles(`divider`,{className:n,style:r,styles:i,classNames:t}),...s})});Ye.classes=Y,Ye.displayName=`@mantine/core/MenuDivider`;var Xe=500;function Ze(e){return((e.querySelector(`[data-menu-item-label]`)??e).textContent??``).trim().toLowerCase()}function Qe(e){return e.length>1&&e.split(``).every(t=>t===e[0])}function $e({enabled:e,opened:t,getDropdown:n}){let r=(0,z.useRef)({buffer:``,timeoutId:null});return(0,z.useEffect)(()=>{if(t&&e)return;let n=r.current;n.timeoutId!==null&&(window.clearTimeout(n.timeoutId),n.timeoutId=null),n.buffer=``},[t,e]),(0,z.useEffect)(()=>()=>{let{timeoutId:e}=r.current;e!==null&&window.clearTimeout(e)},[]),t=>{if(!e||t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey||t.key.length!==1||t.key===` `)return;let i=t.target;if(i&&(i.tagName===`INPUT`||i.tagName===`TEXTAREA`||i.tagName===`SELECT`||i.isContentEditable))return;let a=n();if(!a)return;let o=Array.from(a.querySelectorAll(`[data-menu-item]:not([data-disabled])`)).filter(e=>e.closest(`[data-menu-dropdown]`)===a);if(o.length===0)return;let s=r.current;s.buffer=(s.buffer+t.key).toLowerCase(),s.timeoutId!==null&&window.clearTimeout(s.timeoutId),s.timeoutId=window.setTimeout(()=>{s.buffer=``,s.timeoutId=null},Xe);let c=document.activeElement,l=c?o.indexOf(c):-1,u=null;if(s.buffer.length===1||Qe(s.buffer)){let e=s.buffer[0],t=l+1;for(let n=0;n{let{classNames:t,className:n,style:r,styles:i,vars:o,onMouseEnter:s,onMouseLeave:c,onKeyDown:l,children:u,ref:d,...f}=a(`MenuDropdown`,null,e),p=(0,z.useRef)(null),m=q(),h=$e({enabled:!m.hasSearch,opened:m.opened,getDropdown:()=>p.current}),g=U(l,e=>{h(e),!(e.defaultPrevented||m.hasSearch)&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),p.current?.querySelectorAll(`[data-menu-item]:not(:disabled)`)[0]?.focus())}),_=U(s,()=>(m.trigger===`hover`||m.trigger===`click-hover`)&&m.openDropdown()),v=U(c,()=>(m.trigger===`hover`||m.trigger===`click-hover`)&&m.closeDropdown());return(0,V.jsxs)(K.Dropdown,{...f,onMouseEnter:_,onMouseLeave:v,role:`menu`,"aria-orientation":`vertical`,ref:P(d,p),...m.getStyles(`dropdown`,{className:n,style:r,styles:i,classNames:t,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:g,children:[m.withInitialFocusPlaceholder&&!m.hasSearch&&(0,V.jsx)(`div`,{role:`presentation`,tabIndex:-1,"data-autofocus":!0,"data-mantine-stop-propagation":!0,style:{outline:0}}),u]})});et.classes=Y,et.displayName=`@mantine/core/MenuDropdown`;var tt=i(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,color:l,closeMenuOnClick:u,leftSection:d,rightSection:f,children:p,disabled:m,"data-disabled":h,ref:g,..._}=a(`MenuItem`,null,e),v=q(),y=(0,z.use)(J),b=c(),{dir:x}=R(),S=(0,z.useRef)(null),C=_,w=U(C.onClick,()=>{h||(typeof u==`boolean`?u&&v.closeDropdownImmediately():v.closeOnItemClick&&v.closeDropdownImmediately())}),T=U(C.onMouseMove,()=>{if(!v.hasSearch)return;let e=S.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==S.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),E=l?b.variantColorResolver({color:l,theme:b,variant:`light`}):void 0,D=l?s({color:l,theme:b}):null,O=U(C.onKeyDown,e=>{e.key===`ArrowLeft`&&y&&(y.close(),y.focusParentItem())});return(0,V.jsxs)(I,{onMouseDown:e=>e.preventDefault(),..._,unstyled:v.unstyled,tabIndex:v.menuItemTabIndex,...v.getStyles(`item`,{className:n,style:r,styles:i,classNames:t}),ref:P(S,g),role:`menuitem`,disabled:m,"data-menu-item":!0,"data-disabled":m||h||void 0,"data-mantine-stop-propagation":!0,onClick:w,onMouseMove:T,onKeyDown:H({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:v.loop,dir:x,orientation:`vertical`,onKeyDown:O}),__vars:{"--menu-item-color":D?.isThemeColor&&D?.shade===void 0?`var(--mantine-color-${D.color}-6)`:E?.color,"--menu-item-hover":E?.hover},children:[v.alignItemsLabels===`all`&&(0,V.jsx)(`div`,{...v.getStyles(`itemIndicator`,{styles:i,classNames:t}),"data-placeholder":!0}),d&&(0,V.jsx)(`div`,{...v.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`left`,children:d}),p&&(0,V.jsx)(`div`,{...v.getStyles(`itemLabel`,{styles:i,classNames:t}),"data-menu-item-label":!0,children:p}),f&&(0,V.jsx)(`div`,{...v.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`right`,children:f})]})});tt.classes=Y,tt.displayName=`@mantine/core/MenuItem`;var nt=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,...s}=a(`MenuLabel`,null,e),c=q();return(0,V.jsx)(h,{...c.getStyles(`label`,{className:n,style:r,styles:i,classNames:t}),...s})});nt.classes=Y,nt.displayName=`@mantine/core/MenuLabel`;var rt=(0,z.createContext)(null);function it(e){let{value:t,defaultValue:n,onChange:r,children:i}=a(`MenuRadioGroup`,null,e),[o,s]=D({value:t,defaultValue:n,finalValue:null,onChange:r});return(0,V.jsx)(rt,{value:{value:o,onChange:e=>s(e)},children:i})}it.displayName=`@mantine/core/MenuRadioGroup`;function at({size:e,style:t,...n}){return(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 5 5`,style:{width:w(e),height:w(e),...t},"aria-hidden":!0,...n,children:(0,V.jsx)(`circle`,{cx:`2.5`,cy:`2.5`,r:`2.5`,fill:`currentColor`})})}var ot=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,color:s,closeMenuOnClick:c,rightSection:l,children:u,disabled:d,"data-disabled":f,value:p,checked:m,onChange:h,checkIcon:g,ref:_,...v}=a(`MenuRadioItem`,null,e),y=q(),b=(0,z.use)(rt),x=m??(b?b.value===p:!1),S=g??y.checkIcon??(0,V.jsx)(at,{size:5});return(0,V.jsx)(Ke,{role:`menuitemradio`,checked:x,indicator:S,onSelect:()=>{x||(h?h(p):b&&b.onChange(p))},color:s,closeMenuOnClick:c,rightSection:l,disabled:d,dataDisabled:f,className:n,style:r,styles:i,classNames:t,buttonRef:_,others:v,children:u})});ot.classes=Y,ot.displayName=`@mantine/core/MenuRadioItem`;var st=`[data-menu-item]:not([data-disabled])`,ct=`[data-menu-active]`;function lt(e){return e?.closest(`[data-menu-dropdown]`)}function ut(e){return e?Array.from(e.querySelectorAll(st)).filter(t=>t.closest(`[data-menu-dropdown]`)===e):[]}function dt(e){e&&e.querySelectorAll(ct).forEach(t=>{t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}function ft(e,t){dt(t),e&&(e.setAttribute(`data-menu-active`,`true`),e.scrollIntoView({block:`nearest`}))}function pt(e){return e.findIndex(e=>e.hasAttribute(`data-menu-active`))}var mt={clearSearchOnClose:!0},ht=r(e=>{let{classNames:t,styles:n,onKeyDown:r,onChange:i,size:o,clearSearchOnClose:s,ref:c,...l}=a(`MenuSearch`,mt,e),u=q(),f=(0,z.useRef)(null),p=P(c,f),m=(0,z.useRef)(i);m.current=i,(0,z.useEffect)(()=>u.registerSearch(),[u.registerSearch]),(0,z.useEffect)(()=>{s?u.searchExitClearRef.current=()=>{m.current?.({currentTarget:{value:``}})}:u.searchExitClearRef.current=null},[s,u.searchExitClearRef]),(0,z.useEffect)(()=>{u.opened||dt(lt(f.current))},[u.opened]);let h=U(i,e=>{dt(lt(e.currentTarget))}),g=U(r,e=>{if(e.defaultPrevented)return;let t=lt(e.currentTarget),n=ut(t);if(e.key===`ArrowDown`){if(e.preventDefault(),n.length===0)return;let r=pt(n);ft(n[r>=n.length-1?u.loop?0:r:r+1]??null,t)}else if(e.key===`ArrowUp`){if(e.preventDefault(),n.length===0)return;let r=pt(n);ft(n[r<=0?r===-1||u.loop?n.length-1:0:r-1]??null,t)}else if(e.key===`Home`)e.preventDefault(),n.length>0&&ft(n[0],t);else if(e.key===`End`)e.preventDefault(),n.length>0&&ft(n[n.length-1],t);else if(e.key===`Enter`){if(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)return;let t=n[pt(n)];t&&(e.preventDefault(),t.hasAttribute(`data-sub-menu-item`)?(t.focus(),t.dispatchEvent(new KeyboardEvent(`keydown`,{key:`ArrowRight`,bubbles:!0}))):t.click())}}),_=u.getStyles(`search`);return(0,V.jsx)(d,{"data-autofocus":!0,"data-mantine-stop-propagation":!0,type:`search`,size:o,...l,ref:p,classNames:[{input:_.className},t],styles:[{input:_.style},n],onKeyDown:g,onChange:h,__staticSelector:`Menu`})});ht.classes=Y,ht.displayName=`@mantine/core/MenuSearch`;var gt=r(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,onMouseEnter:s,onMouseLeave:c,onPointerEnter:l,onPointerLeave:u,onKeyDown:d,children:f,ref:p,...m}=a(`MenuSubDropdown`,null,e),h=(0,z.useRef)(null),g=q(),_=(0,z.use)(J),v=$e({enabled:!g.hasSearch,opened:_?.opened??!1,getDropdown:()=>h.current}),y=U(d,e=>{v(e),!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1&&e.key!==` `&&e.stopPropagation()}),b=_?.getFloatingProps({onMouseEnter:s,onMouseLeave:c,onPointerEnter:l,onPointerLeave:u});return(0,V.jsx)(K.Dropdown,{...m,...b,role:`menu`,"aria-orientation":`vertical`,ref:P(p,h,_?.setFloating),...g.getStyles(`dropdown`,{className:n,style:r,styles:i,classNames:t,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:y,children:f})});gt.classes=Y,gt.displayName=`@mantine/core/MenuSubDropdown`;var _t=i(e=>{let{classNames:t,className:n,style:r,styles:i,vars:o,color:u,leftSection:d,rightSection:f,children:p,disabled:m,"data-disabled":h,closeMenuOnClick:g,ref:_,...v}=a(`MenuSubItem`,null,e),y=q(),b=(0,z.use)(J),x=c(),{dir:S}=R(),C=(0,z.useRef)(null),w=v,T=u?x.variantColorResolver({color:u,theme:x,variant:`light`}):void 0,E=u?s({color:u,theme:x}):null,D=U(w.onKeyDown,e=>{e.key===`ArrowRight`&&(b?.open(),b?.focusFirstItem()),e.key===`ArrowLeft`&&b?.parentContext&&(b.parentContext.close(),b.parentContext.focusParentItem())}),O=U(w.onClick,()=>{!h&&g&&y.closeDropdownImmediately()}),k=U(w.onMouseMove,()=>{if(!y.hasSearch)return;let e=C.current?.closest(`[data-menu-dropdown]`);e&&e.querySelectorAll(`[data-menu-active]`).forEach(t=>{t!==C.current&&t.closest(`[data-menu-dropdown]`)===e&&t.removeAttribute(`data-menu-active`)})}),A=b?.getReferenceProps({onMouseEnter:w.onMouseEnter,onMouseLeave:w.onMouseLeave,onPointerEnter:w.onPointerEnter,onPointerLeave:w.onPointerLeave});return(0,V.jsxs)(I,{onMouseDown:e=>e.preventDefault(),...v,...A,unstyled:y.unstyled,tabIndex:y.menuItemTabIndex,...y.getStyles(`item`,{className:n,style:r,styles:i,classNames:t}),ref:P(C,_,b?.setReference),role:`menuitem`,disabled:m,"data-menu-item":!0,"data-sub-menu-item":!0,"data-disabled":m||h||void 0,"data-mantine-stop-propagation":!0,onClick:O,onMouseMove:k,onKeyDown:H({siblingSelector:`[data-menu-item]:not([data-disabled])`,parentSelector:`[data-menu-dropdown]`,activateOnFocus:!1,loop:y.loop,dir:S,orientation:`vertical`,onKeyDown:D}),__vars:{"--menu-item-color":E?.isThemeColor&&E?.shade===void 0?`var(--mantine-color-${E.color}-6)`:T?.color,"--menu-item-hover":T?.hover},children:[y.alignItemsLabels===`all`&&(0,V.jsx)(`div`,{...y.getStyles(`itemIndicator`,{styles:i,classNames:t}),"data-placeholder":!0}),d&&(0,V.jsx)(`div`,{...y.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`left`,children:d}),p&&(0,V.jsx)(`div`,{...y.getStyles(`itemLabel`,{styles:i,classNames:t}),"data-menu-item-label":!0,children:p}),(0,V.jsx)(`div`,{...y.getStyles(`itemSection`,{styles:i,classNames:t}),"data-position":`right`,children:f||(0,V.jsx)(l,{...y.getStyles(`chevron`),size:14})})]})});_t.classes=Y,_t.displayName=`@mantine/core/MenuSubItem`;function vt({children:e,refProp:t}){if(!x(e))throw Error(`Menu.Sub.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);return q(),(0,V.jsx)(K.Target,{refProp:t,popupType:`menu`,children:e})}vt.displayName=`@mantine/core/MenuSubTarget`;var yt={offset:0,position:`right-start`,safeAreaPolygon:!0,transitionProps:{duration:0},openDelay:0,middlewares:{shift:{crossAxis:!0}}};function X(e){let{children:t,closeDelay:n,openDelay:r,position:i,safeAreaPolygon:o,opened:s,onChange:c,...l}=a(`MenuSub`,yt,e),u=ne(),[d,f]=D({value:s,finalValue:!1,onChange:c}),p=(0,z.use)(J),m=q(),{dir:h}=R(),g=pe(h,i),_=p?.registerOpenSub??m.registerOpenSub,v=(0,z.useRef)(null),y=(0,z.useCallback)(e=>{let t=v.current;return t&&t!==e&&t(),v.current=e,()=>{v.current===e&&(v.current=null)}},[]),b=(0,z.useRef)(f);b.current=f;let x=(0,z.useCallback)(()=>b.current(!0),[]),S=(0,z.useCallback)(()=>b.current(!1),[]);(0,z.useEffect)(()=>{if(d)return _(S)},[d,_,S]);let{context:C,refs:w}=F({placement:g,open:d,onOpenChange:e=>{e?x():S()}}),{getReferenceProps:T,getFloatingProps:E}=L([M(C,{handleClose:o?re(typeof o==`object`?o:void 0):void 0,delay:{open:r,close:n}})]);return(0,V.jsx)(J,{value:{opened:d,close:S,open:x,focusFirstItem:()=>window.setTimeout(()=>{document.getElementById(`${u}-dropdown`)?.querySelectorAll(`[data-menu-item]:not([data-disabled])`)[0]?.focus()},16),focusParentItem:()=>window.setTimeout(()=>{document.getElementById(`${u}-target`)?.focus()},16),parentContext:p,setReference:w.setReference,setFloating:w.setFloating,getReferenceProps:T,getFloatingProps:E,registerOpenSub:y},children:(0,V.jsx)(K,{opened:d,onChange:e=>e?x():S(),withArrow:!1,id:u,position:i,...l,withinPortal:!1,children:t})})}X.extend=e=>e,X.displayName=`@mantine/core/MenuSub`,X.Target=vt,X.Dropdown=gt,X.Item=_t;var bt={refProp:`ref`};function xt(e){let{children:t,refProp:n,...r}=a(`MenuTarget`,bt,e),i=m(t);if(!i)throw Error(`Menu.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported`);let o=q(),s=i.props,c=U(s.onClick,()=>{o.trigger===`click`?o.toggleDropdown():o.trigger===`click-hover`&&(o.setOpenedViaClick(!0),o.opened||o.openDropdown())}),l=U(s.onMouseEnter,()=>(o.trigger===`hover`||o.trigger===`click-hover`)&&o.openDropdown()),u=U(s.onMouseLeave,()=>{(o.trigger===`hover`||o.trigger===`click-hover`&&!o.openedViaClick)&&o.closeDropdown()});return(0,V.jsx)(K.Target,{refProp:n,popupType:`menu`,...r,children:(0,z.cloneElement)(i,{onClick:c,onMouseEnter:l,onMouseLeave:u,"data-expanded":o.opened?!0:void 0})})}xt.displayName=`@mantine/core/MenuTarget`;var St={trapFocus:!0,closeOnItemClick:!0,withInitialFocusPlaceholder:!0,clickOutsideEvents:[`mousedown`,`touchstart`,`keydown`],loop:!0,trigger:`click`,openDelay:0,closeDelay:100,menuItemTabIndex:-1,alignItemsLabels:`with-indicators`},Z=r(e=>{let t=a(`Menu`,St,e),{children:n,onOpen:r,onClose:i,opened:o,defaultOpened:s,trapFocus:c,onChange:l,closeOnItemClick:d,loop:p,closeOnEscape:m,trigger:h,openDelay:g,closeDelay:_,classNames:v,styles:y,unstyled:b,variant:x,vars:S,menuItemTabIndex:C,keepMounted:w,withInitialFocusPlaceholder:T,attributes:E,onExitTransitionEnd:O,alignItemsLabels:k,checkIcon:A,...ee}=t,te=u({name:`Menu`,classes:Y,props:t,classNames:v,styles:y,unstyled:b,attributes:E}),[j,ne]=D({value:o,defaultValue:s,finalValue:!1,onChange:l}),[re,M]=(0,z.useState)(!1),N=()=>{ne(!1),M(!1),j&&i?.()},P=()=>{ne(!0),!j&&r?.()},ie=()=>{j?N():P()},{openDropdown:ae,closeDropdown:oe}=W({open:P,close:N,closeDelay:_,openDelay:g}),F=(0,z.useRef)(null),I=(0,z.useCallback)(e=>{let t=F.current;return t&&t!==e&&t(),F.current=e,()=>{F.current===e&&(F.current=null)}},[]),L=(0,z.useRef)(0),[se,R]=(0,z.useState)(!1),ce=(0,z.useCallback)(()=>(L.current+=1,L.current===1&&R(!0),()=>{--L.current,L.current===0&&R(!1)}),[]),le=(0,z.useRef)(null),ue=()=>{le.current?.(),O?.()},de=e=>xe(`[data-menu-item]`,`[data-menu-dropdown]`,e),{resolvedClassNames:fe,resolvedStyles:pe}=f({classNames:v,styles:y,props:t});return(0,V.jsx)(Ue,{value:{getStyles:te,opened:j,toggleDropdown:ie,getItemIndex:de,openedViaClick:re,setOpenedViaClick:M,closeOnItemClick:d,closeDropdown:h===`click`?N:oe,openDropdown:h===`click`?P:ae,closeDropdownImmediately:N,loop:p,trigger:h,unstyled:b,menuItemTabIndex:C,withInitialFocusPlaceholder:T,registerOpenSub:I,hasSearch:se,registerSearch:ce,searchExitClearRef:le,alignItemsLabels:k,checkIcon:A},children:(0,V.jsx)(K,{returnFocus:!0,...ee,opened:j,onChange:ie,defaultOpened:s,trapFocus:!w&&c,closeOnEscape:m,__staticSelector:`Menu`,classNames:fe,styles:pe,unstyled:b,variant:x,keepMounted:w,onExitTransitionEnd:ue,children:n})})});Z.displayName=`@mantine/core/Menu`,Z.classes=Y,Z.Item=tt,Z.Label=nt,Z.Dropdown=et,Z.Target=xt,Z.Divider=Ye,Z.Search=ht,Z.Sub=X,Z.CheckboxItem=qe,Z.CheckboxGroup=Ge,Z.RadioItem=ot,Z.RadioGroup=it,Z.ContextMenu=Je;var Ct=new Map([[`bold`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M144,128a16,16,0,1,1-16-16A16,16,0,0,1,144,128ZM60,112a16,16,0,1,0,16,16A16,16,0,0,0,60,112Zm136,0a16,16,0,1,0,16,16A16,16,0,0,0,196,112Z`}))],[`duotone`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M240,96v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V96A16,16,0,0,1,32,80H224A16,16,0,0,1,240,96Z`,opacity:`0.2`}),z.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z`}))],[`fill`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M224,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V96A16,16,0,0,0,224,80ZM60,140a12,12,0,1,1,12-12A12,12,0,0,1,60,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm68,0a12,12,0,1,1,12-12A12,12,0,0,1,196,140Z`}))],[`light`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM60,118a10,10,0,1,0,10,10A10,10,0,0,0,60,118Zm136,0a10,10,0,1,0,10,10A10,10,0,0,0,196,118Z`}))],[`regular`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm56-12a12,12,0,1,0,12,12A12,12,0,0,0,196,116ZM60,116a12,12,0,1,0,12,12A12,12,0,0,0,60,116Z`}))],[`thin`,z.createElement(z.Fragment,null,z.createElement(`path`,{d:`M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-76-8a8,8,0,1,0,8,8A8,8,0,0,0,60,120Zm136,0a8,8,0,1,0,8,8A8,8,0,0,0,196,120Z`}))]]),wt=z.forwardRef((e,t)=>z.createElement(ce,{ref:t,...e,weights:Ct}));wt.displayName=`DotsThreeIcon`;var Tt=wt,Et=[`dashboards`],Dt=3e4;async function Q(e,t){let{json:n,...r}=t??{},i=new Headers(r.headers),a=r.body;n!==void 0&&(i.set(`content-type`,`application/json`),a=JSON.stringify(n));let o=await he(e,{...r,headers:i,body:a}),s=await o.json().catch(()=>({}));if(!o.ok)throw Ot(o,s);return s}var Ot=(e,t)=>new ge(t.message??`Request failed (${e.status})`,e.status,t.problems??[],t.code??``),$=e=>`/api/dashboards/${encodeURIComponent(e)}`,kt=()=>Q(`/api/dashboards`).then(e=>e.dashboards),At=(e,t)=>Q($(e),{signal:t}),jt=(e,t)=>Q(`${$(e)}/versions`,{signal:t}).then(e=>e.versions),Mt=(e,t,n)=>Q(`${$(e)}/versions/${t}`,{signal:n}),Nt=(e,t)=>Q(`${$(e)}/versions/${t}/restore`,{method:`POST`}),Pt=(e,t,n,r)=>Q($(e),{method:`PUT`,json:{spec:t,base_version:n,message:r}}),Ft=(e,t,n,r)=>Q($(e),{method:`PATCH`,json:{operations:t,base_version:n,message:r}});async function It(e,t,n,r=!1){let i=r?{"cache-control":`no-cache`}:{};if(!n)return Q(`/api/queries/run`,{method:`POST`,headers:i,json:e,signal:t}).then(e=>e.results);let a=await he(`/api/queries/run`,{method:`POST`,headers:{...i,"content-type":`application/json`,accept:`application/x-ndjson`},body:JSON.stringify(e),signal:t});if(!a.ok)throw Ot(a,await a.json().catch(()=>({})));let o=[],s=a.body.pipeThrough(new TextDecoderStream).getReader(),c=``;try{for(;;){let{done:e,value:t}=await s.read();c+=t??``;let r;for(;(r=c.indexOf(` `))>=0;){let e=c.slice(0,r);if(c=c.slice(r+1),!e.trim())continue;let t=JSON.parse(e);o.push(t),n(t)}if(e)return o}}catch(e){throw s.cancel().catch(()=>{}),e}}var Lt=e=>Q(`/api/dashboards`,{method:`POST`,json:{spec:e}}),Rt=e=>Q(`/api/telemetry/schema`,{signal:e}),zt=(e,t)=>Q(`/api/annotations/query`,{method:`POST`,json:e,signal:t}),Bt=(e,t)=>Q(`/api/queries/variables/resolve`,{method:`POST`,json:e,signal:t}).then(e=>e.options),Vt=(e,t)=>Q(`/api/queries/exemplars`,{method:`POST`,json:e,signal:t});function Ht(e,t){let n=new URLSearchParams({namespace:e.namespace??``,from:e.window_from,to:e.window_to,limit:`500`});return Q(`/api/traces/${encodeURIComponent(e.trace_id??``)}?${n}`,{signal:t})}function Ut(e){try{let t=typeof e==`string`?e:JSON.stringify(e);if(!t||t.length>4096)return;let n=typeof e==`string`?JSON.parse(e):e;if(!n||typeof n!=`object`)return;let r=n;return typeof r.panel_id!=`string`||!/^([a-z][a-z0-9_]{0,39})$/.test(r.panel_id)||r.kind!==`traces`&&r.kind!==`logs`||typeof r.from!=`string`||typeof r.to!=`string`||!Number.isFinite(Date.parse(r.from))||!Number.isFinite(Date.parse(r.to))||Date.parse(r.from)>=Date.parse(r.to)||Date.parse(r.to)-Date.parse(r.from)>2592e6||typeof r.window_from!=`string`||typeof r.window_to!=`string`||!Number.isFinite(Date.parse(r.window_from))||!Number.isFinite(Date.parse(r.window_to))||Date.parse(r.window_from)>=Date.parse(r.window_to)||Date.parse(r.window_to)-Date.parse(r.window_from)>2592e6||Date.parse(r.from)Date.parse(r.window_to)||!r.dimensions||Array.isArray(r.dimensions)||typeof r.dimensions!=`object`||Object.keys(r.dimensions).length>3||Object.values(r.dimensions).some(e=>typeof e!=`string`||e.length>500)||r.trace_id!==void 0&&(typeof r.trace_id!=`string`||r.trace_id.length>128)||r.namespace!==void 0&&(typeof r.namespace!=`string`||r.namespace.length>200)||r.bucket&&(!Number.isFinite(r.bucket.lower)||r.bucket.lower<0||r.bucket.upper!==void 0&&(!Number.isFinite(r.bucket.upper)||r.bucket.upper<=r.bucket.lower))?void 0:{panel_id:r.panel_id,kind:r.kind,from:r.from,to:r.to,window_from:r.window_from,window_to:r.window_to,dimensions:r.dimensions,trace_id:r.trace_id,namespace:r.namespace,bucket:r.bucket}}catch{return}}function Wt(e,t,n){if(!e.drill&&e.viz!==`service_map`&&!n.trace_id||t.from_ms===void 0||t.to_ms===void 0)return;let r=t.from_ms,i=t.to_ms;if(n.from!==void 0&&n.to!==void 0&&(r=Math.max(r,Date.parse(n.from)),i=Math.min(i,Date.parse(n.to))),n.time!==void 0&&!n.trace_id){let e=/^(\d+)(s|m|h|d)$/.exec(t.interval??``),a=e?Number(e[1])*{s:1e3,m:6e4,h:36e5,d:864e5}[e[2]]:6e4;r=Math.max(r,n.time),i=Math.min(i,n.time+a)}return Ut(JSON.stringify({panel_id:e.id,kind:n.trace_id||e.viz===`service_map`?`traces`:e.drill,from:n.from&&Date.parse(n.from)===r?n.from:new Date(r).toISOString(),to:n.to&&Date.parse(n.to)===i?n.to:new Date(i).toISOString(),window_from:new Date(t.from_ms).toISOString(),window_to:new Date(t.to_ms).toISOString(),dimensions:n.dimensions,trace_id:n.trace_id,namespace:n.namespace,bucket:n.bucket}))}function Gt(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))for(let e of Array.isArray(r)?r:[r]){if(e===void 0)continue;let r=typeof e==`string`&&/^[{"]/.test(e);t.append(n,r||typeof e==`object`&&e?JSON.stringify(e):String(e))}let n=t.toString();return n?`?${n}`:``}function Kt(e){let t=Object.create(null),n=e=>{if(e.startsWith(`{`)||e.startsWith(`"`))try{let t=JSON.parse(e);if(typeof t==`string`)return/^[{"]/.test(t)?t:e;if(typeof t==`object`&&t&&!Array.isArray(t))return t}catch{}return e},r=new URLSearchParams(e);for(let e of new Set(r.keys())){let i=r.getAll(e).map(n);t[e]=i.length===1?i[0]:i}return t}var qt=[`5m`,`15m`,`1h`,`3h`,`6h`,`12h`,`24h`,`2d`,`7d`,`30d`],Jt=[`off`,`10s`,`30s`,`1m`,`5m`],Yt=e=>{if(typeof e!=`string`||!/^\d{4}-\d{2}-\d{2}[Tt](?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:[Zz]|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(e)||Number.isNaN(Date.parse(e)))return!1;let[t,n,r]=e.slice(0,10).split(`-`).map(Number),i=new Date(0);return i.setUTCFullYear(t,n-1,r),i.setUTCHours(0,0,0,0),i.getUTCFullYear()===t&&i.getUTCMonth()===n-1&&i.getUTCDate()===r},Xt=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):void 0;function Zt(e){let t={};typeof e.range==`string`&&qt.includes(e.range)?t.range=e.range:Yt(e.from)&&Yt(e.to)&&Date.parse(e.from)typeof e==`string`)&&(i[e]=t)}}else{let t=Xt(n);t!==void 0&&(i[e]=t)}}}Object.keys(i).length>0&&(t.vars=i);let a=Ut(e.drill);return a&&(t.drill=JSON.stringify(a)),t}function Qt(e){let t={};e.drill&&(t.drill=JSON.parse(e.drill)),e.range&&(t.range=e.range),e.from&&e.to&&(t.from=e.from,t.to=e.to),e.compare&&(t.compare=e.compare),e.view&&(t.view=e.view),e.edit&&(t.edit=e.edit);for(let[n,r]of Object.entries(e.vars??{}))t[`var-${n}`]=Array.isArray(r)?{values:r}:r;return t}function $t(e,t){let n=new URL(e);return n.search=Gt(Qt({...Zt(Kt(n.search)),drill:JSON.stringify(t)})),n.href}function en(e,t){let n=e.time.refresh??`30s`;return t.from&&t.to?{from:t.from,to:t.to,refresh:n}:t.range?{range:t.range,refresh:n}:{...e.time,refresh:n}}export{Z as A,Vt as C,Bt as D,Q as E,K as M,H as N,Nt as O,zt as S,Pt as T,Ht as _,qt as a,jt as b,Kt as c,Ut as d,Lt as f,Rt as g,At as h,Zt as i,He as j,Tt as k,Gt as l,Dt as m,en as n,Jt as o,Et as p,Yt as r,Qt as s,$t as t,Wt as u,Mt as v,It as w,Ft as x,kt as y}; \ No newline at end of file diff --git a/internal/ui/dist/assets/search-page-uYBxylji.js b/internal/ui/dist/assets/search-page-ug63oRqo.js similarity index 68% rename from internal/ui/dist/assets/search-page-uYBxylji.js rename to internal/ui/dist/assets/search-page-ug63oRqo.js index 275d9f36e..d8070ec12 100644 --- a/internal/ui/dist/assets/search-page-uYBxylji.js +++ b/internal/ui/dist/assets/search-page-ug63oRqo.js @@ -1 +1 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{G as r,T as i,Tt as a,a as o,g as s,j as c,k as l,l as u,s as ee}from"./brand-D6fP-cLS.js";import{a as te,c as d,d as f,f as p,g as ne,h as m,r as re,t as ie,u as ae}from"./toolbar-DV46cPGs.js";import{d as oe,g as se,w as h}from"./search-D_K9J6yO.js";import{t as g}from"./NumberInput-CixyOph4.js";import{n as ce,t as le}from"./live-data-meta-CUyw2snU.js";import{l as _,s as ue}from"./auth-DWqIkMZS.js";import{t as v}from"./useQuery-BLTYSIvG.js";import{n as y,t as de}from"./search-CDra9nG2.js";import{ct as fe}from"./index-C1Pd14SU.js";import{t as b}from"./loading-skeleton-D1hXpfUI.js";import{W as pe,a as x,i as me,n as he,o as ge,s as _e,t as ve}from"./save-dialog-Chbkq2Xp.js";var S=n(e(),1),C=t(),w=e=>`'${e.replaceAll(`'`,`''`)}'`,T=e=>{let t=typeof e==`string`&&e?JSON.parse(e):null;return t&&typeof t==`object`&&!Array.isArray(t)?t:{}};async function E(e,t){let n=Number(e.time),r={from:new Date(n-1).toISOString(),to:new Date(n+1).toISOString(),refresh:`off`},i=Array.from(String(e.body??``)),a=i.length===2e3&&i[1999]===`…`?`starts_with(body, ${w(i.slice(0,1999).join(``))})`:`coalesce(body, '') = ${w(i.join(``))}`,o=`SELECT attributes, resource, coalesce(span_id, ''), coalesce(scope_name, '') FROM logs WHERE $__window(time) AND coalesce(service, '') = ${w(String(e.service??``))} AND coalesce(namespace, '') = ${w(String(e.namespace??``))} AND coalesce(trace_id, '') = ${w(String(e.trace_id??``))} AND ${a} LIMIT 1`,[s]=await h({dashboard:{version:1,name:`Log`,time:r,panels:[{id:`log`,title:`Log`,viz:`table`,sql:o}]},panels:[`log`],time:r},t);if(s?.status===`error`||s?.status===`invalid`)throw Error(s.error??`The log details could not load.`);let c=s?.frame?.values;if(!c||!s.frame?.rows)throw Error(`This log is no longer stored.`);return{attributes:T(c[0][0]),resource:T(c[1][0]),span_id:String(c[2][0]??``),scope:String(c[3][0]??``)}}function ye({row:e,onTrace:t}){let n=v({queryKey:[`log-extras`,e],queryFn:({signal:t})=>E(e,t),retry:!1,staleTime:1/0}),r=typeof e.trace_id==`string`?e.trace_id:``;return(0,C.jsxs)(i,{gap:`xs`,py:4,"data-log-details":!0,onClick:e=>e.stopPropagation(),style:{cursor:`auto`},children:[r&&(0,C.jsx)(a,{children:(0,C.jsx)(u,{label:`Log metadata`,items:[{label:`Trace`,value:t?(0,C.jsx)(_,{component:`button`,type:`button`,size:`sm`,ff:`monospace`,onClick:t,style:{overflowWrap:`anywhere`},children:r}):(0,C.jsx)(c,{span:!0,inherit:!0,ff:`monospace`,children:r})},...n.data?.span_id?[{label:`Span`,value:(0,C.jsx)(c,{span:!0,inherit:!0,ff:`monospace`,children:n.data.span_id})}]:[]]})}),n.isLoading&&(0,C.jsx)(o,{state:`loading`,loadingLabel:`Loading log details`,skeleton:(0,C.jsx)(b,{shape:`key_value`,rows:3})}),n.error&&(0,C.jsx)(a,{p:`xs`,children:(0,C.jsx)(o,{state:`error`,error:{message:n.error.message,onRetry:()=>void n.refetch()}})}),n.data&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p,{label:`Attributes`,values:n.data.attributes}),(0,C.jsx)(p,{label:`Resource`,values:n.data.resource}),n.data.scope&&(0,C.jsx)(a,{children:(0,C.jsx)(u,{items:[{label:`Instrumentation scope`,value:(0,C.jsx)(c,{span:!0,inherit:!0,ff:`monospace`,children:n.data.scope})}]})})]})]})}var D={name:`Logs`,source:`logs`,viz:`logs`,fields:[`service`,`severity`],sorts:[{value:`time`,label:`Newest`},{value:`+time`,label:`Oldest`}],example:`service:checkout severity>=warn`,matching:`Bare words match anywhere in the body; body:x matches the whole body and body~x any part of it.`},O={name:`Traces`,source:`spans`,viz:`traces`,fields:[`service`,`errors`,`slower`],sorts:[{value:`duration_ms`,label:`Slowest`},{value:`+start`,label:`Oldest`}],example:`status:error duration>500ms`,matching:`Bare words match anywhere in the operation; operation:x matches the whole operation and operation~x any part of it.`},k=`search`,be=[{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warn and above`},{value:`error`,label:`Error and above`},{value:`fatal`,label:`Fatal`}];function xe(e,t){let n=[];return e.fields.includes(`service`)&&t.service&&n.push(`service:"${t.service.replaceAll(`"`,`""`)}"`),e.fields.includes(`severity`)&&t.severity&&n.push(`severity>=${t.severity}`),e.fields.includes(`errors`)&&t.errors&&n.push(`status:error`),e.fields.includes(`slower`)&&t.slower&&n.push(`duration>${t.slower}ms`),n.join(` `)}var A=560,Se=100,Ce=e=>e.reason===`busy`?{...e,error:`Not run: other queries kept the server busy. Run the search again.`}:e,we=(e,t)=>e.trim()&&t?`(${e}) ${t}`:e.trim()?e:t,Te=e=>`"${e.replaceAll(`"`,`""`)}"`,j=e=>/\bstatus\b/i.test(e.replace(/'(?:[^']|'')*'|"(?:[^"]|"")*"/g,`''`));async function Ee(e){let t=e?.where??[],n=``;return t.length>0&&(n=(await x({query:{from:`spans`,where:t},viz:`traces`})).where.filter((e,n)=>!e.startsWith(`-`)&&!j(t[n]??``)).map(e=>/\bor\b/i.test(e)?`(${e})`:e).join(` `)),`spans${n?` where ${n}`:``} | count(), error_rate(), p95(duration) by service sort error_rate`}function M({preset:e,search:t,onSearch:n,onSaved:o,onExplore:u}){let[p,g]=(0,S.useState)(t.q),[y,b]=(0,S.useState)([]),[x,w]=(0,S.useState)({shift:0,length:0}),[T,E]=(0,S.useState)([]),[D,O]=(0,S.useState)(),[j,M]=(0,S.useState)(),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(),L=(0,S.useRef)(void 0),R=(0,S.useRef)(null),z=(0,S.useId)(),[Oe,ke]=(0,S.useState)(),B=de(t),V=`${t.range}|${t.from??``}|${t.to??``}`,H=t.sort&&e.sorts.some(e=>e.value===t.sort)?t.sort:e.sorts[0].value,U=(0,S.useRef)(p);U.current=p;let W=xe(e,t.picks??{}),G=(0,S.useRef)(W);G.current=W;let K=v({queryKey:[`telemetry-schema`],queryFn:({signal:e})=>se(e),staleTime:6e4,retry:!1,enabled:e.fields.includes(`service`)}),q=e=>n({...t,picks:{...t.picks,...e}}),J=(0,S.useRef)(t.q),Y=(0,S.useRef)(t);Y.current=t;let Ae=(0,S.useRef)(n);Ae.current=n;let je=(0,S.useRef)(H);je.current=H,(0,S.useEffect)(()=>()=>L.current?.abort(),[]);let X=async(t,r)=>{L.current?.abort();let i=new AbortController;L.current=i,P(!0),O(void 0),b([]),E([]);try{let a=G.current,o=we(t,a),s=t.trim()&&a?1:0;w({shift:s,length:Array.from(t).length});let c=await ge({text:o,source:e.source,viz:e.viz,window:B.from&&B.to?void 0:B.range},i.signal);if(i.signal.aborted)return;U.current===t&&E(c.notices);let l={id:k,title:he(`${e.name}: ${[t.trim(),a].filter(Boolean).join(` `)||`all`}`),viz:e.viz,query:{...c.query,sort:r}},u=t!==J.current;J.current=t,n({...Y.current,q:t,sort:r,...u?{drill:void 0}:{}},!u);let ee={version:1,name:e.name,time:B,panels:[l]},te=R.current?.clientWidth||960,d=await h({dashboard:ee,panels:[k],time:B,widths:{[k]:te}},i.signal);if(i.signal.aborted)return;let f=d.find(e=>e.id===k);if(!f)throw Error(`The search returned no result.`);if(f.status===`invalid`){U.current===t&&b(f.problems??[]);return}ke(Date.now()),M({text:t,terms:a,sort:r,window:V,panel:l,result:re(Ce(f),[k])})}catch(e){if(i.signal.aborted)return;e instanceof ue&&e.problems.length>0?U.current===t&&b(e.problems):O(e instanceof Error?e.message:`Request failed`)}finally{L.current===i&&P(!1)}},Me=(0,S.useRef)(X);Me.current=X;let Ne=(0,S.useRef)(()=>void 0);Ne.current=()=>void X(U.current,H),(0,S.useEffect)(()=>{Ne.current()},[V,H,W]),(0,S.useEffect)(()=>{t.q!==J.current&&(J.current=t.q,g(t.q),X(t.q,H))},[t.q]);let Pe=(0,S.useMemo)(()=>{let e=e=>e&&e.start>=x.shift&&e.end-x.shift<=x.length?{start:e.start-x.shift,end:e.end-x.shift}:void 0,t=t=>({...t,span:e(t.span),fix_its:t.fix_its?.flatMap(t=>{let n=e(t.span);return n?[{...t,span:n}]:[]})});return{problems:y.map(t),notices:T.map(t)}},[y,T,x]),Z=(0,S.useRef)(j);Z.current=j;let Fe=(0,S.useRef)(p);Fe.current=p;let Q=(0,S.useCallback)(e=>{let t=Z.current;if(!t)return;let n=d(t.panel,t.result,e,{});n&&Ae.current({...Y.current,drill:JSON.stringify(n.target)})},[]),Ie=(0,S.useMemo)(()=>({page:Se,details:e.viz===`logs`?e=>(0,C.jsx)(ye,{row:e,onTrace:()=>{let t=Z.current;t&&Q(f(t.panel,t.result).selection(e))}}):void 0,exclude:e.viz===`traces`?(e,t)=>{let n=Fe.current.trim(),r=[/\bor\b/i.test(n)?`(${n})`:n,`-${e}:${Te(t)}`].filter(Boolean).join(` `);g(r),Me.current(r,je.current)}:void 0}),[e.viz,Q]),Le=j!==void 0&&(j.text!==p||j.terms!==W||j.sort!==H||j.window!==V),$=j!==void 0&&!Le&&!N&&j.result.status===`ok`&&(j.result.frame?.rows??0)>0;return(0,C.jsxs)(i,{gap:`md`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,maw:1600,mx:`auto`,"data-search-page":e.viz,children:[(0,C.jsxs)(r,{justify:`space-between`,align:`flex-end`,children:[(0,C.jsx)(s,{title:e.name,description:e.name===`Logs`?`Search and inspect log events.`:`Find slow requests and inspect their traces.`,meta:(0,C.jsx)(le,{time:B,updatedAt:j?Oe:null})}),(0,C.jsx)(ie,{inHeader:!0,time:B,onRange:e=>n({...t,range:e,from:void 0,to:void 0}),onAbsolute:(e,r)=>n({...t,from:e,to:r})})]}),(0,C.jsxs)(i,{gap:`xs`,children:[(0,C.jsxs)(c,{id:z,size:`xs`,c:`dimmed`,children:[`Filter with FanQL, for example `,(0,C.jsx)(`code`,{children:e.example}),`. `,e.matching,` Press Enter to search.`]}),(0,C.jsx)(_e,{value:p,label:`Search ${e.name.toLowerCase()}`,describedBy:z,problems:Pe.problems,notices:Pe.notices,onChange:e=>{g(e),b([]),E([])},onRun:()=>void X(p,H),complete:(t,n,r)=>me({text:t,cursor:n,source:e.source,viz:e.viz,...B.from&&B.to?{from:B.from,to:B.to}:{window:B.range}},r)})]}),(0,C.jsxs)(r,{gap:`sm`,align:`flex-end`,"data-search-fields":!0,children:[e.fields.includes(`service`)&&(0,C.jsx)(m,{label:`Service`,placeholder:K.isPending?`Loading services…`:`All services`,w:220,clearable:!0,searchable:!0,value:t.picks?.service??null,error:K.isError&&(0,C.jsxs)(C.Fragment,{children:[`Services did not load. `,(0,C.jsx)(_,{component:`button`,type:`button`,fz:`xs`,onClick:()=>void K.refetch(),children:`Retry`})]}),data:[...new Set([...t.picks?.service?[t.picks.service]:[],...(K.data?.services??[]).map(e=>e.value)])],onChange:e=>q({service:e??void 0})}),e.fields.includes(`severity`)&&(0,C.jsx)(m,{label:`Severity`,placeholder:`Any severity`,w:180,clearable:!0,value:t.picks?.severity??null,data:be,onChange:e=>q({severity:e??void 0})}),e.fields.includes(`slower`)&&(0,C.jsx)(De,{value:t.picks?.slower,onCommit:e=>q({slower:e})}),e.fields.includes(`errors`)&&(0,C.jsx)(ce,{label:`Errors only`,mb:8,checked:t.picks?.errors===`1`,onChange:e=>q({errors:e.currentTarget.checked?`1`:void 0})})]}),(0,C.jsxs)(r,{justify:`space-between`,children:[(0,C.jsxs)(r,{gap:`xs`,children:[(0,C.jsx)(l,{loading:N,onClick:()=>void X(p,H),children:`Search`}),(0,C.jsx)(ne,{size:`sm`,"aria-label":`Order`,value:H,data:[...e.sorts],onChange:e=>n({...t,sort:e})}),e.viz===`traces`&&u&&(0,C.jsx)(fe,{label:`Error rate of the matching spans in each service, in Explore. Status and excluded terms are left out.`,children:(0,C.jsx)(l,{variant:`subtle`,size:`xs`,disabled:!j,onClick:()=>{j&&Ee(j.panel.query).then(u,e=>O(e instanceof Error?e.message:`Request failed`))},children:`Span error rates by service`})})]}),(0,C.jsx)(fe,{label:`Search for something that returns rows first`,disabled:$,children:(0,C.jsx)(`span`,{children:(0,C.jsx)(l,{variant:`default`,disabled:!$,onClick:()=>j&&I(j.panel),children:`Save to dashboard`})})})]}),D&&(0,C.jsx)(ee,{tone:`danger`,title:`The search could not run`,children:D}),(0,C.jsx)(a,{ref:R,children:j&&(0,C.jsxs)(i,{gap:`xs`,children:[Le&&(0,C.jsx)(c,{size:`sm`,fw:600,role:`status`,children:`Result of the last search · filters have changed`}),(0,C.jsx)(a,{h:A,children:(0,C.jsx)(te,{panel:j.panel,title:j.panel.title,result:j.result,loading:N,height:A,group:`search-${e.viz}`,editing:!1,agentAvailable:!1,range:B.range,onRetry:()=>void X(j.text,j.sort),traceLinks:`button`,controls:Ie,onPoint:Q})})]})}),j&&(0,C.jsx)(ae,{client:pe,spec:{version:1,name:e.name,time:B,panels:[{...j.panel,title:`this search`}]},time:B,vars:{},target:oe(t.drill),onChange:e=>n({...t,drill:e?JSON.stringify(e):void 0})}),F&&(0,C.jsx)(ve,{panel:F,time:B,onClose:()=>I(void 0),onSaved:o})]})}function De({value:e,onCommit:t}){let[n,r]=(0,S.useState)(e?Number(e):``);(0,S.useEffect)(()=>{r(e?Number(e):``)},[e]);let i=()=>{let r=typeof n==`number`&&n>=1?String(Math.min(y,Math.floor(n))):void 0;r!==e&&t(r)};return(0,C.jsx)(g,{label:`Slower than (ms)`,w:160,min:1,max:y,clampBehavior:`strict`,value:n,onChange:r,onBlur:i,onKeyDown:e=>{e.key===`Enter`&&i()}})}export{D as n,O as r,M as t}; \ No newline at end of file +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{G as r,T as i,Tt as a,a as o,g as s,j as c,k as l,l as u,s as ee}from"./brand-D6fP-cLS.js";import{a as te,c as d,d as f,f as p,g as ne,h as m,r as re,t as ie,u as ae}from"./toolbar-CLcpDIVT.js";import{d as oe,g as se,w as h}from"./search-P7VEnlsD.js";import{t as g}from"./NumberInput-CixyOph4.js";import{n as ce,t as le}from"./live-data-meta-CkxM9djV.js";import{l as _,s as ue}from"./auth-DcVParCH.js";import{t as v}from"./useQuery-BLTYSIvG.js";import{n as y,t as de}from"./search-pvW8SUhM.js";import{ct as fe}from"./index-D7FG-NN3.js";import{t as b}from"./loading-skeleton-D1hXpfUI.js";import{W as pe,a as x,i as me,n as he,o as ge,s as _e,t as ve}from"./save-dialog-DpwJ9nWF.js";var S=n(e(),1),C=t(),w=e=>`'${e.replaceAll(`'`,`''`)}'`,T=e=>{let t=typeof e==`string`&&e?JSON.parse(e):null;return t&&typeof t==`object`&&!Array.isArray(t)?t:{}};async function E(e,t){let n=Number(e.time),r={from:new Date(n-1).toISOString(),to:new Date(n+1).toISOString(),refresh:`off`},i=Array.from(String(e.body??``)),a=i.length===2e3&&i[1999]===`…`?`starts_with(body, ${w(i.slice(0,1999).join(``))})`:`coalesce(body, '') = ${w(i.join(``))}`,o=`SELECT attributes, resource, coalesce(span_id, ''), coalesce(scope_name, '') FROM logs WHERE $__window(time) AND coalesce(service, '') = ${w(String(e.service??``))} AND coalesce(namespace, '') = ${w(String(e.namespace??``))} AND coalesce(trace_id, '') = ${w(String(e.trace_id??``))} AND ${a} LIMIT 1`,[s]=await h({dashboard:{version:1,name:`Log`,time:r,panels:[{id:`log`,title:`Log`,viz:`table`,sql:o}]},panels:[`log`],time:r},t);if(s?.status===`error`||s?.status===`invalid`)throw Error(s.error??`The log details could not load.`);let c=s?.frame?.values;if(!c||!s.frame?.rows)throw Error(`This log is no longer stored.`);return{attributes:T(c[0][0]),resource:T(c[1][0]),span_id:String(c[2][0]??``),scope:String(c[3][0]??``)}}function ye({row:e,onTrace:t}){let n=v({queryKey:[`log-extras`,e],queryFn:({signal:t})=>E(e,t),retry:!1,staleTime:1/0}),r=typeof e.trace_id==`string`?e.trace_id:``;return(0,C.jsxs)(i,{gap:`xs`,py:4,"data-log-details":!0,onClick:e=>e.stopPropagation(),style:{cursor:`auto`},children:[r&&(0,C.jsx)(a,{children:(0,C.jsx)(u,{label:`Log metadata`,items:[{label:`Trace`,value:t?(0,C.jsx)(_,{component:`button`,type:`button`,size:`sm`,ff:`monospace`,onClick:t,style:{overflowWrap:`anywhere`},children:r}):(0,C.jsx)(c,{span:!0,inherit:!0,ff:`monospace`,children:r})},...n.data?.span_id?[{label:`Span`,value:(0,C.jsx)(c,{span:!0,inherit:!0,ff:`monospace`,children:n.data.span_id})}]:[]]})}),n.isLoading&&(0,C.jsx)(o,{state:`loading`,loadingLabel:`Loading log details`,skeleton:(0,C.jsx)(b,{shape:`key_value`,rows:3})}),n.error&&(0,C.jsx)(a,{p:`xs`,children:(0,C.jsx)(o,{state:`error`,error:{message:n.error.message,onRetry:()=>void n.refetch()}})}),n.data&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(p,{label:`Attributes`,values:n.data.attributes}),(0,C.jsx)(p,{label:`Resource`,values:n.data.resource}),n.data.scope&&(0,C.jsx)(a,{children:(0,C.jsx)(u,{items:[{label:`Instrumentation scope`,value:(0,C.jsx)(c,{span:!0,inherit:!0,ff:`monospace`,children:n.data.scope})}]})})]})]})}var D={name:`Logs`,source:`logs`,viz:`logs`,fields:[`service`,`severity`],sorts:[{value:`time`,label:`Newest`},{value:`+time`,label:`Oldest`}],example:`service:checkout severity>=warn`,matching:`Bare words match anywhere in the body; body:x matches the whole body and body~x any part of it.`},O={name:`Traces`,source:`spans`,viz:`traces`,fields:[`service`,`errors`,`slower`],sorts:[{value:`duration_ms`,label:`Slowest`},{value:`+start`,label:`Oldest`}],example:`status:error duration>500ms`,matching:`Bare words match anywhere in the operation; operation:x matches the whole operation and operation~x any part of it.`},k=`search`,be=[{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warn and above`},{value:`error`,label:`Error and above`},{value:`fatal`,label:`Fatal`}];function xe(e,t){let n=[];return e.fields.includes(`service`)&&t.service&&n.push(`service:"${t.service.replaceAll(`"`,`""`)}"`),e.fields.includes(`severity`)&&t.severity&&n.push(`severity>=${t.severity}`),e.fields.includes(`errors`)&&t.errors&&n.push(`status:error`),e.fields.includes(`slower`)&&t.slower&&n.push(`duration>${t.slower}ms`),n.join(` `)}var A=560,Se=100,Ce=e=>e.reason===`busy`?{...e,error:`Not run: other queries kept the server busy. Run the search again.`}:e,we=(e,t)=>e.trim()&&t?`(${e}) ${t}`:e.trim()?e:t,Te=e=>`"${e.replaceAll(`"`,`""`)}"`,j=e=>/\bstatus\b/i.test(e.replace(/'(?:[^']|'')*'|"(?:[^"]|"")*"/g,`''`));async function Ee(e){let t=e?.where??[],n=``;return t.length>0&&(n=(await x({query:{from:`spans`,where:t},viz:`traces`})).where.filter((e,n)=>!e.startsWith(`-`)&&!j(t[n]??``)).map(e=>/\bor\b/i.test(e)?`(${e})`:e).join(` `)),`spans${n?` where ${n}`:``} | count(), error_rate(), p95(duration) by service sort error_rate`}function M({preset:e,search:t,onSearch:n,onSaved:o,onExplore:u}){let[p,g]=(0,S.useState)(t.q),[y,b]=(0,S.useState)([]),[x,w]=(0,S.useState)({shift:0,length:0}),[T,E]=(0,S.useState)([]),[D,O]=(0,S.useState)(),[j,M]=(0,S.useState)(),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(),L=(0,S.useRef)(void 0),R=(0,S.useRef)(null),z=(0,S.useId)(),[Oe,ke]=(0,S.useState)(),B=de(t),V=`${t.range}|${t.from??``}|${t.to??``}`,H=t.sort&&e.sorts.some(e=>e.value===t.sort)?t.sort:e.sorts[0].value,U=(0,S.useRef)(p);U.current=p;let W=xe(e,t.picks??{}),G=(0,S.useRef)(W);G.current=W;let K=v({queryKey:[`telemetry-schema`],queryFn:({signal:e})=>se(e),staleTime:6e4,retry:!1,enabled:e.fields.includes(`service`)}),q=e=>n({...t,picks:{...t.picks,...e}}),J=(0,S.useRef)(t.q),Y=(0,S.useRef)(t);Y.current=t;let Ae=(0,S.useRef)(n);Ae.current=n;let je=(0,S.useRef)(H);je.current=H,(0,S.useEffect)(()=>()=>L.current?.abort(),[]);let X=async(t,r)=>{L.current?.abort();let i=new AbortController;L.current=i,P(!0),O(void 0),b([]),E([]);try{let a=G.current,o=we(t,a),s=t.trim()&&a?1:0;w({shift:s,length:Array.from(t).length});let c=await ge({text:o,source:e.source,viz:e.viz,window:B.from&&B.to?void 0:B.range},i.signal);if(i.signal.aborted)return;U.current===t&&E(c.notices);let l={id:k,title:he(`${e.name}: ${[t.trim(),a].filter(Boolean).join(` `)||`all`}`),viz:e.viz,query:{...c.query,sort:r}},u=t!==J.current;J.current=t,n({...Y.current,q:t,sort:r,...u?{drill:void 0}:{}},!u);let ee={version:1,name:e.name,time:B,panels:[l]},te=R.current?.clientWidth||960,d=await h({dashboard:ee,panels:[k],time:B,widths:{[k]:te}},i.signal);if(i.signal.aborted)return;let f=d.find(e=>e.id===k);if(!f)throw Error(`The search returned no result.`);if(f.status===`invalid`){U.current===t&&b(f.problems??[]);return}ke(Date.now()),M({text:t,terms:a,sort:r,window:V,panel:l,result:re(Ce(f),[k])})}catch(e){if(i.signal.aborted)return;e instanceof ue&&e.problems.length>0?U.current===t&&b(e.problems):O(e instanceof Error?e.message:`Request failed`)}finally{L.current===i&&P(!1)}},Me=(0,S.useRef)(X);Me.current=X;let Ne=(0,S.useRef)(()=>void 0);Ne.current=()=>void X(U.current,H),(0,S.useEffect)(()=>{Ne.current()},[V,H,W]),(0,S.useEffect)(()=>{t.q!==J.current&&(J.current=t.q,g(t.q),X(t.q,H))},[t.q]);let Pe=(0,S.useMemo)(()=>{let e=e=>e&&e.start>=x.shift&&e.end-x.shift<=x.length?{start:e.start-x.shift,end:e.end-x.shift}:void 0,t=t=>({...t,span:e(t.span),fix_its:t.fix_its?.flatMap(t=>{let n=e(t.span);return n?[{...t,span:n}]:[]})});return{problems:y.map(t),notices:T.map(t)}},[y,T,x]),Z=(0,S.useRef)(j);Z.current=j;let Fe=(0,S.useRef)(p);Fe.current=p;let Q=(0,S.useCallback)(e=>{let t=Z.current;if(!t)return;let n=d(t.panel,t.result,e,{});n&&Ae.current({...Y.current,drill:JSON.stringify(n.target)})},[]),Ie=(0,S.useMemo)(()=>({page:Se,details:e.viz===`logs`?e=>(0,C.jsx)(ye,{row:e,onTrace:()=>{let t=Z.current;t&&Q(f(t.panel,t.result).selection(e))}}):void 0,exclude:e.viz===`traces`?(e,t)=>{let n=Fe.current.trim(),r=[/\bor\b/i.test(n)?`(${n})`:n,`-${e}:${Te(t)}`].filter(Boolean).join(` `);g(r),Me.current(r,je.current)}:void 0}),[e.viz,Q]),Le=j!==void 0&&(j.text!==p||j.terms!==W||j.sort!==H||j.window!==V),$=j!==void 0&&!Le&&!N&&j.result.status===`ok`&&(j.result.frame?.rows??0)>0;return(0,C.jsxs)(i,{gap:`md`,px:{base:`md`,sm:`xl`},pt:`lg`,pb:`xl`,maw:1600,mx:`auto`,"data-search-page":e.viz,children:[(0,C.jsxs)(r,{justify:`space-between`,align:`flex-end`,children:[(0,C.jsx)(s,{title:e.name,description:e.name===`Logs`?`Search and inspect log events.`:`Find slow requests and inspect their traces.`,meta:(0,C.jsx)(le,{time:B,updatedAt:j?Oe:null})}),(0,C.jsx)(ie,{inHeader:!0,time:B,onRange:e=>n({...t,range:e,from:void 0,to:void 0}),onAbsolute:(e,r)=>n({...t,from:e,to:r})})]}),(0,C.jsxs)(i,{gap:`xs`,children:[(0,C.jsxs)(c,{id:z,size:`xs`,c:`dimmed`,children:[`Filter with PitotQL, for example `,(0,C.jsx)(`code`,{children:e.example}),`. `,e.matching,` Press Enter to search.`]}),(0,C.jsx)(_e,{value:p,label:`Search ${e.name.toLowerCase()}`,describedBy:z,problems:Pe.problems,notices:Pe.notices,onChange:e=>{g(e),b([]),E([])},onRun:()=>void X(p,H),complete:(t,n,r)=>me({text:t,cursor:n,source:e.source,viz:e.viz,...B.from&&B.to?{from:B.from,to:B.to}:{window:B.range}},r)})]}),(0,C.jsxs)(r,{gap:`sm`,align:`flex-end`,"data-search-fields":!0,children:[e.fields.includes(`service`)&&(0,C.jsx)(m,{label:`Service`,placeholder:K.isPending?`Loading services…`:`All services`,w:220,clearable:!0,searchable:!0,value:t.picks?.service??null,error:K.isError&&(0,C.jsxs)(C.Fragment,{children:[`Services did not load. `,(0,C.jsx)(_,{component:`button`,type:`button`,fz:`xs`,onClick:()=>void K.refetch(),children:`Retry`})]}),data:[...new Set([...t.picks?.service?[t.picks.service]:[],...(K.data?.services??[]).map(e=>e.value)])],onChange:e=>q({service:e??void 0})}),e.fields.includes(`severity`)&&(0,C.jsx)(m,{label:`Severity`,placeholder:`Any severity`,w:180,clearable:!0,value:t.picks?.severity??null,data:be,onChange:e=>q({severity:e??void 0})}),e.fields.includes(`slower`)&&(0,C.jsx)(De,{value:t.picks?.slower,onCommit:e=>q({slower:e})}),e.fields.includes(`errors`)&&(0,C.jsx)(ce,{label:`Errors only`,mb:8,checked:t.picks?.errors===`1`,onChange:e=>q({errors:e.currentTarget.checked?`1`:void 0})})]}),(0,C.jsxs)(r,{justify:`space-between`,children:[(0,C.jsxs)(r,{gap:`xs`,children:[(0,C.jsx)(l,{loading:N,onClick:()=>void X(p,H),children:`Search`}),(0,C.jsx)(ne,{size:`sm`,"aria-label":`Order`,value:H,data:[...e.sorts],onChange:e=>n({...t,sort:e})}),e.viz===`traces`&&u&&(0,C.jsx)(fe,{label:`Error rate of the matching spans in each service, in Explore. Status and excluded terms are left out.`,children:(0,C.jsx)(l,{variant:`subtle`,size:`xs`,disabled:!j,onClick:()=>{j&&Ee(j.panel.query).then(u,e=>O(e instanceof Error?e.message:`Request failed`))},children:`Span error rates by service`})})]}),(0,C.jsx)(fe,{label:`Search for something that returns rows first`,disabled:$,children:(0,C.jsx)(`span`,{children:(0,C.jsx)(l,{variant:`default`,disabled:!$,onClick:()=>j&&I(j.panel),children:`Save to dashboard`})})})]}),D&&(0,C.jsx)(ee,{tone:`danger`,title:`The search could not run`,children:D}),(0,C.jsx)(a,{ref:R,children:j&&(0,C.jsxs)(i,{gap:`xs`,children:[Le&&(0,C.jsx)(c,{size:`sm`,fw:600,role:`status`,children:`Result of the last search · filters have changed`}),(0,C.jsx)(a,{h:A,children:(0,C.jsx)(te,{panel:j.panel,title:j.panel.title,result:j.result,loading:N,height:A,group:`search-${e.viz}`,editing:!1,agentAvailable:!1,range:B.range,onRetry:()=>void X(j.text,j.sort),traceLinks:`button`,controls:Ie,onPoint:Q})})]})}),j&&(0,C.jsx)(ae,{client:pe,spec:{version:1,name:e.name,time:B,panels:[{...j.panel,title:`this search`}]},time:B,vars:{},target:oe(t.drill),onChange:e=>n({...t,drill:e?JSON.stringify(e):void 0})}),F&&(0,C.jsx)(ve,{panel:F,time:B,onClose:()=>I(void 0),onSaved:o})]})}function De({value:e,onCommit:t}){let[n,r]=(0,S.useState)(e?Number(e):``);(0,S.useEffect)(()=>{r(e?Number(e):``)},[e]);let i=()=>{let r=typeof n==`number`&&n>=1?String(Math.min(y,Math.floor(n))):void 0;r!==e&&t(r)};return(0,C.jsx)(g,{label:`Slower than (ms)`,w:160,min:1,max:y,clampBehavior:`strict`,value:n,onChange:r,onBlur:i,onKeyDown:e=>{e.key===`Enter`&&i()}})}export{D as n,O as r,M as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/search-CDra9nG2.js b/internal/ui/dist/assets/search-pvW8SUhM.js similarity index 95% rename from internal/ui/dist/assets/search-CDra9nG2.js rename to internal/ui/dist/assets/search-pvW8SUhM.js index 7a8915fe0..1e8a38635 100644 --- a/internal/ui/dist/assets/search-CDra9nG2.js +++ b/internal/ui/dist/assets/search-pvW8SUhM.js @@ -1 +1 @@ -import{a as e,d as t,r as n}from"./search-D_K9J6yO.js";var r=[`stat`,`gauge`,`timeseries`,`bar`,`table`,`heatmap`,`histogram`,`scatter`,`state_timeline`,`logs`,`log_patterns`,`traces`,`service_map`,`health`],i=9999999,a=[`trace`,`debug`,`info`,`warn`,`error`,`fatal`];function o(i){let o={q:``,range:`1h`,tab:`query`};if(i.v!==void 0&&String(i.v)!==`1`)return o;typeof i.q==`string`&&(o.q=i.q),typeof i.viz==`string`&&r.includes(i.viz)&&(o.viz=i.viz),typeof i.range==`string`&&e.includes(i.range)&&(o.range=i.range),n(i.from)&&n(i.to)&&Date.parse(i.from)0&&(o.picks=s);let c=t(i.drill);return c&&(o.drill=JSON.stringify(c)),typeof i.sort==`string`&&/^\+?[a-z_]{1,40}$/.test(i.sort)&&(o.sort=i.sort),o}function s(e){let t={v:`1`};e.q&&(t.q=e.q),e.viz&&(t.viz=e.viz),e.from&&e.to?(t.from=e.from,t.to=e.to):e.range!==`1h`&&(t.range=e.range),e.tab!==`query`&&(t.tab=e.tab),e.sql&&(t.sql=e.sql),e.sort&&(t.sort=e.sort),e.drill&&(t.drill=JSON.parse(e.drill));for(let[n,r]of Object.entries(e.picks??{}))r&&(t[n]=r);return t}function c(e){return e.from&&e.to?{from:e.from,to:e.to,refresh:`off`}:{range:e.range,refresh:`off`}}export{s as i,i as n,o as r,c as t}; \ No newline at end of file +import{a as e,d as t,r as n}from"./search-P7VEnlsD.js";var r=[`stat`,`gauge`,`timeseries`,`bar`,`table`,`heatmap`,`histogram`,`scatter`,`state_timeline`,`logs`,`log_patterns`,`traces`,`service_map`,`health`],i=9999999,a=[`trace`,`debug`,`info`,`warn`,`error`,`fatal`];function o(i){let o={q:``,range:`1h`,tab:`query`};if(i.v!==void 0&&String(i.v)!==`1`)return o;typeof i.q==`string`&&(o.q=i.q),typeof i.viz==`string`&&r.includes(i.viz)&&(o.viz=i.viz),typeof i.range==`string`&&e.includes(i.range)&&(o.range=i.range),n(i.from)&&n(i.to)&&Date.parse(i.from)0&&(o.picks=s);let c=t(i.drill);return c&&(o.drill=JSON.stringify(c)),typeof i.sort==`string`&&/^\+?[a-z_]{1,40}$/.test(i.sort)&&(o.sort=i.sort),o}function s(e){let t={v:`1`};e.q&&(t.q=e.q),e.viz&&(t.viz=e.viz),e.from&&e.to?(t.from=e.from,t.to=e.to):e.range!==`1h`&&(t.range=e.range),e.tab!==`query`&&(t.tab=e.tab),e.sql&&(t.sql=e.sql),e.sort&&(t.sort=e.sort),e.drill&&(t.drill=JSON.parse(e.drill));for(let[n,r]of Object.entries(e.picks??{}))r&&(t[n]=r);return t}function c(e){return e.from&&e.to?{from:e.from,to:e.to,refresh:`off`}:{range:e.range,refresh:`off`}}export{s as i,i as n,o as r,c as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/settings-BCyNZMl5.js b/internal/ui/dist/assets/settings-BCyNZMl5.js new file mode 100644 index 000000000..cf4d0abe9 --- /dev/null +++ b/internal/ui/dist/assets/settings-BCyNZMl5.js @@ -0,0 +1 @@ +import{n as e}from"./settings-Cgt_UVbR.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/settings-BhplbQY-.js b/internal/ui/dist/assets/settings-Cgt_UVbR.js similarity index 98% rename from internal/ui/dist/assets/settings-BhplbQY-.js rename to internal/ui/dist/assets/settings-Cgt_UVbR.js index 1fb4e4e69..d6c9866b4 100644 --- a/internal/ui/dist/assets/settings-BhplbQY-.js +++ b/internal/ui/dist/assets/settings-Cgt_UVbR.js @@ -1,4 +1,4 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{$ as r,G as i,S as a,T as o,Tt as s,a as c,g as l,i as u,j as d,k as f,l as p,r as m,s as h,u as g,w as _}from"./brand-D6fP-cLS.js";import{t as v}from"./CopyButton-BIdC6qm1.js";import{a as y,c as b,i as x,l as S,n as C,r as w}from"./auth-DWqIkMZS.js";import{T,t as E}from"./useQuery-BLTYSIvG.js";import{t as D}from"./useMutation-B1CTivyp.js";import{O,ct as k,d as A,k as j,x as M}from"./index-C1Pd14SU.js";import{t as N}from"./loading-skeleton-D1hXpfUI.js";var P=n(e(),1),F=t(),I=[`settings`,`ingest`],L=[`settings`,`ingest`,`tokens`];function R(e,t){let n=e.trim();return t||/^https:\/\//i.test(n)||/:443$/.test(n)}function z(e,t,n){if(/^https?:\/\//i.test(e.trim()))try{let t=new URL(e);e=`${t.protocol}//${t.hostname}:${t.port||(t.protocol===`https:`?`443`:`80`)}`}catch{}let r=R(e,n)?``:` +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{$ as r,G as i,S as a,T as o,Tt as s,a as c,g as l,i as u,j as d,k as f,l as p,r as m,s as h,u as g,w as _}from"./brand-D6fP-cLS.js";import{t as v}from"./CopyButton-BIdC6qm1.js";import{a as y,c as b,i as x,l as S,n as C,r as w}from"./auth-DcVParCH.js";import{T,t as E}from"./useQuery-BLTYSIvG.js";import{t as D}from"./useMutation-Diiy6DUC.js";import{O,ct as k,d as A,k as j,x as M}from"./index-D7FG-NN3.js";import{t as N}from"./loading-skeleton-D1hXpfUI.js";var P=n(e(),1),F=t(),I=[`settings`,`ingest`],L=[`settings`,`ingest`,`tokens`];function R(e,t){let n=e.trim();return t||/^https:\/\//i.test(n)||/:443$/.test(n)}function z(e,t,n){if(/^https?:\/\//i.test(e.trim()))try{let t=new URL(e);e=`${t.protocol}//${t.hostname}:${t.port||(t.protocol===`https:`?`443`:`80`)}`}catch{}let r=R(e,n)?``:` tls: insecure: true`;return`exporters: otlp/pitot: diff --git a/internal/ui/dist/assets/settings-_0QC4d6a.js b/internal/ui/dist/assets/settings-_0QC4d6a.js deleted file mode 100644 index ce38b128b..000000000 --- a/internal/ui/dist/assets/settings-_0QC4d6a.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./settings-BhplbQY-.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/settings_.ingest-7LDcHtKJ.js b/internal/ui/dist/assets/settings_.ingest-7LDcHtKJ.js deleted file mode 100644 index cd81c253a..000000000 --- a/internal/ui/dist/assets/settings_.ingest-7LDcHtKJ.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./settings-BhplbQY-.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/settings_.ingest-CRd3tDC4.js b/internal/ui/dist/assets/settings_.ingest-CRd3tDC4.js new file mode 100644 index 000000000..844f9b637 --- /dev/null +++ b/internal/ui/dist/assets/settings_.ingest-CRd3tDC4.js @@ -0,0 +1 @@ +import{t as e}from"./settings-Cgt_UVbR.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/toolbar-DV46cPGs.js b/internal/ui/dist/assets/toolbar-CLcpDIVT.js similarity index 99% rename from internal/ui/dist/assets/toolbar-DV46cPGs.js rename to internal/ui/dist/assets/toolbar-CLcpDIVT.js index 41d3050c7..0c54b7a67 100644 --- a/internal/ui/dist/assets/toolbar-DV46cPGs.js +++ b/internal/ui/dist/assets/toolbar-CLcpDIVT.js @@ -1,4 +1,4 @@ -import{i as e,o as t,r as n,s as r}from"./useRouter-ByJ6_rwb.js";import{$ as i,$t as a,A as o,At as s,Cn as c,D as l,Dt as u,Ft as d,G as f,Ht as p,J as m,K as h,Lt as g,Mt as _,N as v,Nt as y,Ot as b,Pt as x,Sn as S,St as C,T as w,Tt as T,Zt as E,_ as D,a as O,b as k,bn as A,c as j,cn as ee,d as M,dn as N,en as P,et as te,f as F,gn as ne,i as re,in as ie,j as I,k as ae,l as oe,ln as se,mn as ce,nn as le,pn as ue,q as de,qt as fe,r as pe,s as me,tt as he,un as ge,v as _e,vn as ve,w as ye,wt as be,x as xe}from"./brand-D6fP-cLS.js";import{_ as Se,a as Ce,c as we,f as Te,g as Ee,h as De,i as Oe,l as ke,m as Ae,o as je,s as Me,t as Ne}from"./theme-DXTVNXHm.js";import{A as Pe,N as Fe,a as Ie,k as Le,o as Re,t as ze,u as Be,w as Ve}from"./search-D_K9J6yO.js";import{t as He}from"./CopyButton-BIdC6qm1.js";import{n as Ue,t as We}from"./Table-D4ZwUno3.js";import{a as Ge,i as Ke,n as qe,r as Je,t as Ye}from"./format-BZjbsxwM.js";import{c as Xe,i as Ze,l as Qe,n as $e,o as et,r as tt,s as nt,u as rt}from"./live-data-meta-CUyw2snU.js";import{c as it,l as at}from"./auth-DWqIkMZS.js";import{t as ot}from"./useQuery-BLTYSIvG.js";import{n as st,r as ct,t as lt}from"./lib-BLIvzI-_.js";import{c as ut,ct as dt,d as ft,f as pt,h as mt,l as ht,m as gt,o as _t,p as vt,s as yt,u as bt,ut as xt}from"./index-C1Pd14SU.js";import{t as St}from"./loading-skeleton-D1hXpfUI.js";function Ct(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();let n=wt(e);if(n.length!==wt(t).length)return!1;for(let r=0;r{if(typeof n!=`string`||n.trim().length===0)throw Error(t);return`${e}-${n}`}}function Et(e){return typeof e==`object`&&e?`base`in e?e.base:void 0:e}function Dt(e,t){if(e===t||Number.isNaN(e)&&Number.isNaN(t))return!0;if(!(e instanceof Object)||!(t instanceof Object))return!1;let n=Object.keys(e),{length:r}=n;if(r!==Object.keys(t).length)return!1;for(let i=0;i(e+1)%1e6;function kt(){let[,e]=(0,L.useReducer)(Ot,0);return e}function At(e,t){if(!e||!t)return!1;if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n{r.current||=window.setTimeout(()=>{i(...e),r.current=null},t)},[t]),o=(0,L.useCallback)(()=>{r.current&&=(window.clearTimeout(r.current),null)},[]);return(0,L.useEffect)(()=>(n.autoInvoke&&a(),o),[o,a]),{start:a,clear:o}}function Pt(e){let t=(0,L.useRef)(void 0);return(0,L.useEffect)(()=>{t.current=e},[e]),t.current}function Ft(e,t,n){let r=(0,L.useRef)(null);(0,L.useEffect)(()=>{r.current&&=(r.current.disconnect(),null);let i=typeof n==`function`?n():n;return i&&(r.current=new MutationObserver(e),r.current.observe(i,t)),()=>{r.current&&=(r.current.disconnect(),null)}},[e,t,n])}function It(){let[e,t]=(0,L.useState)(!1);return(0,L.useEffect)(()=>t(!0),[]),e}function Lt(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`}function Rt(e,t){return typeof e==`boolean`?e:t.autoContrast}function zt(e,t){if(!t||!e)return!1;let n=t.parentNode;for(;n!=null;){if(n===e)return!0;n=n.parentNode}return!1}function Bt({target:e,parent:t,ref:n,displayAfterTransitionEnd:r,onTransitionStart:i,onTransitionEnd:a}){let o=(0,L.useRef)(-1),s=(0,L.useRef)(e),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(typeof r==`boolean`&&r),f=()=>{if(!e||!t||!n.current)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=t.offsetWidth===0?1:i.width/t.offsetWidth,o=t.offsetHeight===0?1:i.height/t.offsetHeight,s=window.getComputedStyle(e),c=window.getComputedStyle(t),l=C(s.borderTopWidth)+C(c.borderTopWidth),u=C(s.borderLeftWidth)+C(c.borderLeftWidth),d={top:(r.top-i.top)/o-l,left:(r.left-i.left)/a-u,width:r.width/a,height:r.height/o};n.current.style.transform=`translateY(${d.top}px) translateX(${d.left}px)`,n.current.style.width=`${d.width}px`,n.current.style.height=`${d.height}px`},p=()=>{window.clearTimeout(o.current),n.current&&(n.current.style.transitionDuration=`0ms`),f(),o.current=window.setTimeout(()=>{n.current&&(n.current.style.transitionDuration=``)},30)},m=(0,L.useRef)(null),h=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(c&&s.current!==e&&i&&i(),s.current=e,f(),e)return m.current=new ResizeObserver(p),m.current.observe(e),t&&(h.current=new ResizeObserver(p),h.current.observe(t)),()=>{m.current?.disconnect(),h.current?.disconnect()}},[t,e]),(0,L.useEffect)(()=>{if(t){let e=e=>{zt(e.target,t)&&(p(),d(!1))};return t.addEventListener(`transitionend`,e),()=>{t.removeEventListener(`transitionend`,e)}}},[t]),(0,L.useEffect)(()=>{if(n.current&&a){let e=e=>{e.propertyName===`transform`&&a()};return n.current.addEventListener(`transitionend`,e),()=>{n.current?.removeEventListener(`transitionend`,e)}}},[a]),Nt(()=>{Ue()!==`test`&&l(!0)},20,{autoInvoke:!0}),Ft(e=>{e.forEach(e=>{e.type===`attributes`&&e.attributeName===`dir`&&p()})},{attributes:!0,attributeFilter:[`dir`]},()=>document.documentElement),{initialized:c,hidden:u}}var Vt={root:`m_96b553a6`},Ht=E((e,{transitionDuration:t},{shouldReduceMotion:n})=>({root:{"--transition-duration":e.respectReducedMotion&&n?`0ms`:typeof t==`number`?`${t}ms`:t||`150ms`}})),Ut=u(e=>{let t=d(`FloatingIndicator`,null,e),{classNames:n,className:r,style:i,styles:o,unstyled:s,vars:c,target:l,parent:u,transitionDuration:f,mod:p,displayAfterTransitionEnd:m,onTransitionStart:h,onTransitionEnd:g,attributes:_,ref:v,...b}=t,x=a(),S=y({name:`FloatingIndicator`,classes:Vt,props:t,className:r,style:i,classNames:n,styles:o,unstyled:s,attributes:_,vars:c,varsResolver:Ht,stylesCtx:{shouldReduceMotion:x}}),C=(0,L.useRef)(null),{initialized:w,hidden:E}=Bt({target:l,parent:u,ref:C,displayAfterTransitionEnd:m,onTransitionStart:h,onTransitionEnd:g}),D=le(v,C);return!l||!u?null:(0,R.jsx)(T,{ref:D,mod:[{initialized:w,hidden:E},p],...S(`root`),...b})});Ut.displayName=`@mantine/core/FloatingIndicator`,Ut.classes=Vt,Ut.varsResolver=Ht;function Wt(e){let t=e.currentTarget;return rt(t).activeElement!==t}function Gt(e,t){let n=t.trim().toLowerCase();if(n===``)return;let r=Object.values(e).filter(e=>!e.disabled&&e.label.trim().toLowerCase()===n);return r.length===1?r[0]:void 0}var[Kt,qt]=ne(`Progress.Root component was not found in tree`),Jt={root:`m_db6d6462`,section:`m_2242eb65`,"stripes-animation":`m_81a374bd`,"stripes-animation-vertical":`m_e0fb7a86`,label:`m_91e40b74`},Yt=u(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,...o}=d(`ProgressLabel`,null,e),s=qt();return(0,R.jsx)(T,{...s.getStyles(`label`,{className:n,style:r,classNames:t,styles:i}),...o})});Yt.classes=Jt,Yt.displayName=`@mantine/core/ProgressLabel`;var Xt=E((e,{size:t,radius:n,transitionDuration:r})=>({root:{"--progress-size":ue(t,`progress-size`),"--progress-radius":n===void 0?void 0:N(n),"--progress-transition-duration":typeof r==`number`?`${r}ms`:void 0}})),Zt=u(e=>{let t=d(`ProgressRoot`,null,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,autoContrast:c,transitionDuration:l,orientation:u,attributes:f,mod:p,...m}=t,h=y({name:`Progress`,classes:Jt,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:f,vars:s,varsResolver:Xt});return(0,R.jsx)(Kt,{value:{getStyles:h,autoContrast:c},children:(0,R.jsx)(T,{mod:[{orientation:u},p],...h(`root`),...m})})});Zt.classes=Jt,Zt.varsResolver=Xt,Zt.displayName=`@mantine/core/ProgressRoot`;var Qt={withAria:!0},$t=u(e=>{let{classNames:t,className:n,style:r,styles:i,vars:a,value:o,withAria:s,color:c,striped:l,animated:u,mod:f,...p}=d(`ProgressSection`,Qt,e),m=qt(),h=g(),_=s?{role:`progressbar`,"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":o,"aria-valuetext":`${o}%`}:{};return(0,R.jsx)(T,{...m.getStyles(`section`,{className:n,classNames:t,styles:i,style:r}),...p,..._,mod:[{striped:l||u,animated:u},f],__vars:{"--progress-section-size":`${o}%`,"--progress-section-color":fe(c,h),"--progress-label-color":Rt(m.autoContrast,h)?ke({color:c,theme:h,autoContrast:m.autoContrast}):void 0}})});$t.classes=Jt,$t.displayName=`@mantine/core/ProgressSection`;var en=u(e=>{let t=d(`Progress`,null,e),{value:n,classNames:r,styles:i,vars:a,color:o,striped:s,animated:c,"aria-label":l,...u}=t,{resolvedClassNames:f,resolvedStyles:p}=x({classNames:r,styles:i,props:t});return(0,R.jsx)(Zt,{classNames:f,styles:p,vars:a,...u,children:(0,R.jsx)($t,{value:n,color:o,striped:s,animated:c,"aria-label":l})})});en.classes=Jt,en.displayName=`@mantine/core/Progress`,en.Section=$t,en.Root=Zt,en.Label=Yt;var tn={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},nn={withItemsBorders:!0},rn=E((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:N(t),"--sc-color":n?fe(n,e):void 0,"--sc-shadow":n?void 0:`var(--mantine-shadow-xs)`,"--sc-transition-duration":r===void 0?void 0:`${r}ms`,"--sc-transition-timing-function":a,"--sc-padding":ue(i,`sc-padding`),"--sc-font-size":ge(i)}})),an=b(e=>{let t=d(`SegmentedControl`,nn,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:s,data:c,value:l,defaultValue:u,onChange:f,size:p,name:m,disabled:h,readOnly:_,fullWidth:v,orientation:b,radius:x,color:S,transitionDuration:C,transitionTimingFunction:w,variant:E,autoContrast:D,withItemsBorders:O,mod:k,attributes:A,ref:j,...ee}=t,M=y({name:`SegmentedControl`,props:t,classes:tn,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:A,vars:s,varsResolver:rn}),N=g(),te=c.map(e=>Lt(e)?{label:`${e}`,value:e}:e),F=It(),[ne,re]=(0,L.useState)(0),[I,ae]=(0,L.useState)(null),[oe,se]=(0,L.useState)({}),ce=(e,t)=>{e!==null&&oe[t]!==e&&(oe[t]=e,se({...oe}))},[ue,de]=P({value:l,defaultValue:u,finalValue:Array.isArray(c)?te.find(e=>!e.disabled)?.value??c[0]?.value??null:null,onChange:f}),fe=ie(m),pe=te.map(e=>`${e.value}`),me=te.map(e=>(0,L.createElement)(T,{...M(`control`),mod:{active:ue===e.value,orientation:b},key:`${e.value}`},(0,L.createElement)(`input`,{...M(`input`),disabled:h||e.disabled,type:`radio`,name:fe,value:`${e.value}`,id:`${fe}-${e.value}`,checked:ue===e.value,onChange:()=>!_&&de(e.value),"data-focus-ring":N.focusRing,key:`${e.value}-input`}),(0,L.createElement)(T,{component:`label`,...M(`label`),mod:{active:ue===e.value&&!(h||e.disabled),disabled:h||e.disabled,"read-only":_},htmlFor:`${fe}-${e.value}`,ref:t=>ce(t,`${e.value}`),__vars:{"--sc-label-color":S===void 0?void 0:ke({color:S,theme:N,autoContrast:D})},key:`${e.value}-label`},(0,R.jsx)(`span`,{...M(`innerLabel`),children:e.label})))),he=le(j,ae);return Mt(()=>{re(e=>e+1)},[c.length]),Mt(()=>{se(e=>{let t={};return pe.forEach(n=>{n in e&&(t[n]=e[n])}),Object.keys(t).length===Object.keys(e).length?e:t})},[pe]),c.length===0?null:(0,R.jsxs)(T,{...M(`root`),variant:E,size:p,ref:he,mod:[{"full-width":v,orientation:b,initialized:F,"with-items-borders":O},k],...ee,role:`radiogroup`,"data-disabled":h,children:[ue!==void 0&&(0,R.jsx)(Ut,{target:oe[`${ue}`],parent:I,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...M(`indicator`)},ne),me]})});an.classes=tn,an.varsResolver=rn,an.displayName=`@mantine/core/SegmentedControl`;var on={size:`sm`,withCheckIcon:!0,allowDeselect:!0,checkIconPosition:`left`,openOnFocus:!0},sn=b(e=>{let t=d([`Input`,`InputWrapper`,`Select`],on,e),{classNames:n,styles:r,unstyled:i,vars:a,dropdownOpened:o,defaultDropdownOpened:s,onDropdownClose:c,onDropdownOpen:l,onFocus:u,onBlur:f,onClick:p,onChange:m,data:h,value:g,defaultValue:_,selectFirstOptionOnChange:y,selectFirstOptionOnDropdownOpen:b,onOptionSubmit:S,comboboxProps:C,readOnly:w,disabled:T,filter:E,limit:D,withScrollArea:O,maxDropdownHeight:k,floatingHeight:A,size:j,searchable:ee,rightSection:M,checkIconPosition:N,withCheckIcon:te,withAlignedLabels:F,nothingFoundMessage:ne,name:re,form:I,searchValue:ae,defaultSearchValue:oe,onSearchChange:se,allowDeselect:ce,error:le,rightSectionPointerEvents:ue,id:de,clearable:fe,clearSectionMode:pe,clearButtonProps:me,hiddenInputProps:he,renderOption:ge,onClear:_e,autoComplete:ve,scrollAreaProps:ye,__defaultRightSection:be,__clearSection:xe,__clearable:Se,chevronColor:Ce,autoSelectOnBlur:we,openOnFocus:Te,attributes:Ee,...De}=t,Oe=(0,L.useMemo)(()=>Qe(h),[h]),ke=(0,L.useRef)({}),Ae=(0,L.useMemo)(()=>Xe(Oe),[Oe]),je=ie(de),Me=tt({id:je,label:De.label,labelProps:De.labelProps,inputWrapperOrder:De.inputWrapperOrder}),[Ne,Pe,Fe]=P({value:g,defaultValue:_,finalValue:null,onChange:m}),Ie=Ne==null?void 0:`${Ne}`in Ae?Ae[`${Ne}`]:ke.current[`${Ne}`],Le=Pt(Ie),[Re,ze,Be]=P({value:ae,defaultValue:oe,finalValue:Ie?Ie.label:``,onChange:se}),Ve=nt({opened:o,defaultOpened:s,onDropdownOpen:()=>{l?.(),b?Ve.selectFirstOption():Ve.updateSelectedOptionIndex(`active`,{scrollIntoView:!0})},onDropdownClose:()=>{c?.(),setTimeout(Ve.resetSelectedOption,0)}}),He=e=>{ze(e),Ve.resetSelectedOption()},{resolvedClassNames:Ue,resolvedStyles:We}=x({props:t,styles:r,classNames:n});(0,L.useEffect)(()=>{y&&Ve.selectFirstOption()},[y,Re]),(0,L.useEffect)(()=>{g===null&&He(``),g!=null&&Ie&&(Le?.value!==Ie.value||Le?.label!==Ie.label)&&He(Ie.label)},[g,Ie]),(0,L.useEffect)(()=>{!Fe&&!Be&&He(Ne==null?``:`${Ne}`in Ae?Ae[`${Ne}`]?.label:ke.current[`${Ne}`]?.label||``)},[Ae,Ne]),(0,L.useEffect)(()=>{Ne&&`${Ne}`in Ae&&(ke.current[`${Ne}`]=Ae[`${Ne}`])},[Ae,Ne]);let Ge=(0,R.jsx)(et.ClearButton,{...me,onClear:()=>{Pe(null,null),He(``),_e?.()}}),Ke=fe&&Ne!=null&&!T&&!w;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(et,{store:Ve,__staticSelector:`Select`,classNames:Ue,styles:We,unstyled:i,readOnly:w,size:j,attributes:Ee,floatingHeight:A,keepMounted:we,onOptionSubmit:e=>{S?.(e);let t=ce&&`${Ae[e].value}`==`${Ne}`?null:Ae[e],n=t?t.value:null;n!==Ne&&Pe(n,t),!Fe&&He(n==null?``:t?.label||``),Ve.closeDropdown()},...C,children:[(0,R.jsx)(et.Target,{targetType:ee?`input`:`button`,autoComplete:ve,withExpandedAttribute:!0,children:(0,R.jsx)(v,{id:je,__defaultRightSection:(0,R.jsx)(et.Chevron,{size:j,error:le,unstyled:i,color:Ce}),__clearSection:Ge,__clearable:Ke,__clearSectionMode:pe,rightSection:M,rightSectionPointerEvents:ue||`none`,...De,size:j,__staticSelector:`Select`,disabled:T,readOnly:w||!ee,value:Re,onChange:e=>{if(Wt(e)){if(!w){let t=Gt(Ae,e.currentTarget.value);t&&`${t.value}`!=`${Ne}`&&(Pe(t.value,t),!Fe&&He(t.label))}return}He(e.currentTarget.value),Ve.openDropdown(),y&&Ve.selectFirstOption()},onFocus:e=>{Te&&ee&&Ve.openDropdown(),u?.(e)},onBlur:e=>{we&&Ve.clickSelectedOption(),Ve.closeDropdown();let t=Ne!=null&&(`${Ne}`in Ae?Ae[`${Ne}`]:ke.current[`${Ne}`]);He(t&&t.label||``),f?.(e)},onClick:e=>{ee?Ve.openDropdown():Ve.toggleDropdown(),p?.(e)},classNames:Ue,styles:We,unstyled:i,pointer:!ee,error:le,attributes:Ee})}),(0,R.jsx)(Ze,{data:Oe,hidden:w||T,filter:E,search:Re,limit:D,hiddenWhenEmpty:!ne,withScrollArea:O,maxDropdownHeight:k,filterOptions:!!ee&&Ie?.label!==Re,value:Ne,checkIconPosition:N,withCheckIcon:te,withAlignedLabels:F,nothingFoundMessage:ne,unstyled:i,labelId:Me,"aria-label":Me?void 0:De[`aria-label`],renderOption:ge,scrollAreaProps:ye})]}),(0,R.jsx)(et.HiddenInput,{value:Ne,name:re,form:I,disabled:T,...he})]})});sn.classes={...v.classes,...et.classes},sn.displayName=`@mantine/core/Select`;function cn(e){if(e!==void 0)return typeof e==`number`?A(e):e}function ln({spacing:e,verticalSpacing:t,cols:n,minColWidth:r,autoRows:i,selector:a}){let o=g(),s=t===void 0?e:t,c=r!==void 0,l=ve({"--sg-spacing-x":ce(Et(e)),"--sg-spacing-y":ce(Et(s)),"--sg-auto-rows":i,...c?{"--sg-min-col-width":cn(r)}:{"--sg-cols":Et(n)?.toString()}}),u=S(o.breakpoints).reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=ce(e[r])),typeof s==`object`&&s[r]!==void 0&&(t[r][`--sg-spacing-y`]=ce(s[r])),!c&&typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{}),d=Te(S(u),o.breakpoints).filter(e=>S(u[e.value]).length>0).map(e=>({query:`(min-width: ${o.breakpoints[e.value]})`,styles:u[e.value]}));return(0,R.jsx)(_,{styles:l,media:d,selector:a})}function un(e){return typeof e==`object`&&e?S(e):[]}function dn(e){return e.sort((e,t)=>Ae(e)-Ae(t))}function fn({spacing:e,verticalSpacing:t,cols:n,minColWidth:r}){return dn(Array.from(new Set([...un(e),...un(t),...r===void 0?un(n):[]])))}function pn({spacing:e,verticalSpacing:t,cols:n,minColWidth:r,autoRows:i,selector:a}){let o=t===void 0?e:t,s=r!==void 0,c=ve({"--sg-spacing-x":ce(Et(e)),"--sg-spacing-y":ce(Et(o)),"--sg-auto-rows":i,...s?{"--sg-min-col-width":cn(r)}:{"--sg-cols":Et(n)?.toString()}}),l=fn({spacing:e,verticalSpacing:t,cols:n,minColWidth:r}),u=l.reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=ce(e[r])),typeof o==`object`&&o[r]!==void 0&&(t[r][`--sg-spacing-y`]=ce(o[r])),!s&&typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{}),d=l.map(e=>({query:`simple-grid (min-width: ${e})`,styles:u[e]}));return(0,R.jsx)(_,{styles:c,container:d,selector:a})}var mn={container:`m_925c2d2c`,root:`m_2415a157`},hn={cols:1,spacing:`md`,type:`media`},gn=u(e=>{let t=d(`SimpleGrid`,hn,e),{classNames:n,className:r,style:i,styles:a,unstyled:o,vars:c,cols:l,verticalSpacing:u,spacing:f,type:p,minColWidth:m,autoFlow:h,autoRows:g,attributes:_,...v}=t,b=y({name:`SimpleGrid`,classes:mn,props:t,className:r,style:i,classNames:n,styles:a,unstyled:o,attributes:_,vars:c}),x=s(),S=m===void 0?void 0:h||`auto-fill`;return p===`container`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(pn,{...t,selector:`.${x}`}),(0,R.jsx)(`div`,{...b(`container`),children:(0,R.jsx)(T,{...b(`root`,{className:x}),...v,"data-auto-cols":S})})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ln,{...t,selector:`.${x}`}),(0,R.jsx)(T,{...b(`root`,{className:x}),...v,"data-auto-cols":S})]})});gn.classes=mn,gn.displayName=`@mantine/core/SimpleGrid`;var[_n,vn]=ne(`Tabs component was not found in the tree`),yn={root:`m_89d60db1`,"list--default":`m_576c9d4`,list:`m_89d33d6d`,tab:`m_4ec4dce6`,panel:`m_b0c91715`,tabSection:`m_fc420b1f`,tabLabel:`m_42bbd1ae`,"tab--default":`m_539e827b`,"list--outline":`m_6772fbd5`,"tab--outline":`m_b59ab47c`,"tab--pills":`m_c3381914`},bn=u(e=>{let t=d(`TabsList`,null,e),{children:n,className:r,grow:i,justify:a,classNames:o,styles:s,style:c,mod:l,...u}=t,f=vn();return(0,R.jsx)(T,{...f.getStyles(`list`,{className:r,style:c,classNames:o,styles:s,props:t,variant:f.variant}),role:`tablist`,variant:f.variant,mod:[{grow:i,orientation:f.orientation,placement:f.orientation===`vertical`&&f.placement,inverted:f.inverted},l],"aria-orientation":f.orientation,__vars:{"--tabs-justify":a},...u,children:n})});bn.classes=yn,bn.displayName=`@mantine/core/TabsList`;var xn=u(e=>{let t=d(`TabsPanel`,null,e),{children:n,className:r,value:i,classNames:a,styles:o,style:s,mod:c,keepMounted:l,...u}=t,f=p(),m=vn();(0,L.useEffect)(()=>(m.setMountedPanel(i,!0),()=>{m.setMountedPanel(i,!1)}),[i]);let h=m.value===i,g=m.keepMounted||l,_=m.keepMountedMode!==`display-none`,v=g&&_&&f!==`test`?(0,R.jsx)(L.Activity,{mode:h?`visible`:`hidden`,children:n}):g||h?n:null;return(0,R.jsx)(T,{...m.getStyles(`panel`,{className:r,classNames:a,styles:o,style:[s,h?void 0:{display:`none`}],props:t}),mod:[{orientation:m.orientation},c],role:`tabpanel`,id:m.getPanelId(i),"aria-labelledby":m.getTabId(i),...u,children:v})});xn.classes=yn,xn.displayName=`@mantine/core/TabsPanel`;var Sn=u(e=>{let t=d(`TabsTab`,null,e),{className:n,children:r,rightSection:i,leftSection:a,value:o,onClick:s,onKeyDown:c,disabled:l,color:u,style:f,classNames:p,styles:m,vars:h,mod:_,tabIndex:v,...y}=t,b=g(),{dir:x}=be(),S=vn(),C=o===S.value,w=e=>{S.onChange(S.allowTabDeactivation&&o===S.value?null:o),s?.(e)},T={classNames:p,styles:m,props:t};return(0,R.jsxs)(he,{...S.getStyles(`tab`,{className:n,style:f,variant:S.variant,...T}),disabled:l,unstyled:S.unstyled,variant:S.variant,mod:[{active:C,disabled:l,orientation:S.orientation,inverted:S.inverted,placement:S.orientation===`vertical`&&S.placement},_],role:`tab`,id:S.getTabId(o),"aria-selected":C,tabIndex:v===void 0?C||S.value===null?0:-1:v,"aria-controls":S.mountedPanels.current.has(o)?S.getPanelId(o):void 0,onClick:w,__vars:{"--tabs-color":u?fe(u,b):void 0},onKeyDown:Fe({siblingSelector:`[role="tab"]`,parentSelector:`[role="tablist"]`,activateOnFocus:S.activateTabWithKeyboard,loop:S.loop,orientation:S.orientation||`horizontal`,dir:x,onKeyDown:c}),...y,children:[a&&(0,R.jsx)(`span`,{...S.getStyles(`tabSection`,T),"data-position":`left`,children:a}),r&&(0,R.jsx)(`span`,{...S.getStyles(`tabLabel`,T),children:r}),i&&(0,R.jsx)(`span`,{...S.getStyles(`tabSection`,T),"data-position":`right`,children:i})]})});Sn.classes=yn,Sn.displayName=`@mantine/core/TabsTab`;var Cn=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,wn={keepMounted:!0,keepMountedMode:`activity`,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},Tn=E((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":N(t),"--tabs-color":fe(n,e),"--tabs-text-color":Rt(r,e)?ke({color:n,theme:e,autoContrast:r}):void 0}})),En=u(e=>{let t=d(`Tabs`,wn,e),{defaultValue:n,value:r,onChange:i,orientation:a,children:o,loop:s,id:c,activateTabWithKeyboard:l,allowTabDeactivation:u,variant:f,color:p,radius:m,inverted:h,placement:g,keepMounted:_,keepMountedMode:v,classNames:b,styles:x,unstyled:S,className:C,style:w,vars:E,autoContrast:D,mod:O,attributes:k,...A}=t,j=ie(c),ee=(0,L.useRef)(new Set),M=kt(),N=(0,L.useCallback)((e,t)=>{let n=ee.current;t&&!n.has(e)?(n.add(e),M()):!t&&n.has(e)&&(n.delete(e),M())},[]),[te,F]=P({value:r,defaultValue:n,finalValue:null,onChange:i}),ne=y({name:`Tabs`,props:t,classes:yn,className:C,style:w,classNames:b,styles:x,unstyled:S,attributes:k,vars:E,varsResolver:Tn});return(0,R.jsx)(_n,{value:{placement:g,value:te,orientation:a,id:j,loop:s,activateTabWithKeyboard:l,getTabId:Tt(`${j}-tab`,Cn),getPanelId:Tt(`${j}-panel`,Cn),onChange:F,allowTabDeactivation:u,variant:f,color:p,radius:m,inverted:h,keepMounted:_,keepMountedMode:v,unstyled:S,getStyles:ne,mountedPanels:ee,setMountedPanel:N},children:(0,R.jsx)(T,{id:j,variant:f,mod:[{orientation:a,inverted:a===`horizontal`&&h,placement:a===`vertical`&&g},O],...ne(`root`),...A,children:o})})});En.classes=yn,En.varsResolver=Tn,En.displayName=`@mantine/core/Tabs`,En.Tab=Sn,En.Panel=xn,En.List=bn;var Dn=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M208,160H48l80-80Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z`}))]]),On=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:Dn}));On.displayName=`CaretUpIcon`;var kn=On,An=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M244,56v48a12,12,0,0,1-12,12H184a12,12,0,1,1,0-24H201.1l-19-17.38c-.13-.12-.26-.24-.38-.37A76,76,0,1,0,127,204h1a75.53,75.53,0,0,0,52.15-20.72,12,12,0,0,1,16.49,17.45A99.45,99.45,0,0,1,128,228h-1.37A100,100,0,1,1,198.51,57.06L220,76.72V56a12,12,0,0,1,24,0Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M216,128a88,88,0,1,1-88-88A88,88,0,0,1,216,128Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1-5.66-13.66l17-17-10.55-9.65-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,1,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60l10.93,10L226.34,50.3A8,8,0,0,1,240,56Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M238,56v48a6,6,0,0,1-6,6H184a6,6,0,0,1,0-12h32.55l-30.38-27.8c-.06-.06-.12-.13-.19-.19a82,82,0,1,0-1.7,117.65,6,6,0,0,1,8.24,8.73A93.46,93.46,0,0,1,128,222h-1.28A94,94,0,1,1,194.37,61.4L226,90.35V56a6,6,0,1,1,12,0Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M236,56v48a4,4,0,0,1-4,4H184a4,4,0,0,1,0-8h37.7L187.53,68.69l-.13-.12a84,84,0,1,0-1.75,120.51,4,4,0,0,1,5.5,5.82A91.43,91.43,0,0,1,128,220h-1.26A92,92,0,1,1,193,62.84l35,32.05V56a4,4,0,1,1,8,0Z`}))]]),jn=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M220,48V96a12,12,0,0,1-24,0V77l-35.51,35.52a12,12,0,0,1-17-17L179,60H160a12,12,0,0,1,0-24h48A12,12,0,0,1,220,48ZM95.51,143.51,60,179V160a12,12,0,0,0-24,0v48a12,12,0,0,0,12,12H96a12,12,0,0,0,0-24H77l35.52-35.51a12,12,0,0,0-17-17ZM208,148a12,12,0,0,0-12,12v19l-35.51-35.52a12,12,0,0,0-17,17L179,196H160a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,208,148ZM77,60H96a12,12,0,0,0,0-24H48A12,12,0,0,0,36,48V96a12,12,0,0,0,24,0V77l35.51,35.52a12,12,0,0,0,17-17Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M208,48V208H48V48Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M216,48V96a8,8,0,0,1-16,0V67.31l-42.34,42.35a8,8,0,0,1-11.32-11.32L188.69,56H160a8,8,0,0,1,0-16h48A8,8,0,0,1,216,48ZM98.34,146.34,56,188.69V160a8,8,0,0,0-16,0v48a8,8,0,0,0,8,8H96a8,8,0,0,0,0-16H67.31l42.35-42.34a8,8,0,0,0-11.32-11.32ZM208,152a8,8,0,0,0-8,8v28.69l-42.34-42.35a8,8,0,0,0-11.32,11.32L188.69,200H160a8,8,0,0,0,0,16h48a8,8,0,0,0,8-8V160A8,8,0,0,0,208,152ZM67.31,56H96a8,8,0,0,0,0-16H48a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31l42.34,42.35a8,8,0,0,0,11.32-11.32Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M109.66,146.34a8,8,0,0,1,0,11.32L83.31,184l18.35,18.34A8,8,0,0,1,96,216H48a8,8,0,0,1-8-8V160a8,8,0,0,1,13.66-5.66L72,172.69l26.34-26.35A8,8,0,0,1,109.66,146.34ZM83.31,72l18.35-18.34A8,8,0,0,0,96,40H48a8,8,0,0,0-8,8V96a8,8,0,0,0,13.66,5.66L72,83.31l26.34,26.35a8,8,0,0,0,11.32-11.32ZM208,40H160a8,8,0,0,0-5.66,13.66L172.69,72,146.34,98.34a8,8,0,0,0,11.32,11.32L184,83.31l18.34,18.35A8,8,0,0,0,216,96V48A8,8,0,0,0,208,40Zm3.06,112.61a8,8,0,0,0-8.72,1.73L184,172.69l-26.34-26.35a8,8,0,0,0-11.32,11.32L172.69,184l-18.35,18.34A8,8,0,0,0,160,216h48a8,8,0,0,0,8-8V160A8,8,0,0,0,211.06,152.61Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M214,48V96a6,6,0,0,1-12,0V62.48l-45.76,45.76a6,6,0,0,1-8.48-8.48L193.52,54H160a6,6,0,0,1,0-12h48A6,6,0,0,1,214,48ZM99.76,147.76,54,193.52V160a6,6,0,0,0-12,0v48a6,6,0,0,0,6,6H96a6,6,0,0,0,0-12H62.48l45.76-45.76a6,6,0,0,0-8.48-8.48ZM208,154a6,6,0,0,0-6,6v33.52l-45.76-45.76a6,6,0,0,0-8.48,8.48L193.52,202H160a6,6,0,0,0,0,12h48a6,6,0,0,0,6-6V160A6,6,0,0,0,208,154ZM62.48,54H96a6,6,0,0,0,0-12H48a6,6,0,0,0-6,6V96a6,6,0,0,0,12,0V62.48l45.76,45.76a6,6,0,0,0,8.48-8.48Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M216,48V96a8,8,0,0,1-16,0V67.31l-42.34,42.35a8,8,0,0,1-11.32-11.32L188.69,56H160a8,8,0,0,1,0-16h48A8,8,0,0,1,216,48ZM98.34,146.34,56,188.69V160a8,8,0,0,0-16,0v48a8,8,0,0,0,8,8H96a8,8,0,0,0,0-16H67.31l42.35-42.34a8,8,0,0,0-11.32-11.32ZM208,152a8,8,0,0,0-8,8v28.69l-42.34-42.35a8,8,0,0,0-11.32,11.32L188.69,200H160a8,8,0,0,0,0,16h48a8,8,0,0,0,8-8V160A8,8,0,0,0,208,152ZM67.31,56H96a8,8,0,0,0,0-16H48a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31l42.34,42.35a8,8,0,0,0,11.32-11.32Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M212,48V96a4,4,0,0,1-8,0V57.66l-49.17,49.17a4,4,0,0,1-5.66-5.66L198.34,52H160a4,4,0,0,1,0-8h48A4,4,0,0,1,212,48ZM101.17,149.17,52,198.34V160a4,4,0,0,0-8,0v48a4,4,0,0,0,4,4H96a4,4,0,0,0,0-8H57.66l49.17-49.17a4,4,0,0,0-5.66-5.66ZM208,156a4,4,0,0,0-4,4v38.34l-49.17-49.17a4,4,0,0,0-5.66,5.66L198.34,204H160a4,4,0,0,0,0,8h48a4,4,0,0,0,4-4V160A4,4,0,0,0,208,156ZM57.66,52H96a4,4,0,0,0,0-8H48a4,4,0,0,0-4,4V96a4,4,0,0,0,8,0V57.66l49.17,49.17a4,4,0,0,0,5.66-5.66Z`}))]]),Mn=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M172,108a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,108Zm-12,28H96a12,12,0,0,0,0,24h64a12,12,0,0,0,0-24Zm76-8A108,108,0,0,1,78.77,224.15L46.34,235A20,20,0,0,1,21,209.66l10.81-32.43A108,108,0,1,1,236,128Zm-24,0A84,84,0,1,0,55.27,170.06a12,12,0,0,1,1,9.81l-9.93,29.79,29.79-9.93a12.1,12.1,0,0,1,3.8-.62,12,12,0,0,1,6,1.62A84,84,0,0,0,212,128Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M224,128A96,96,0,0,1,79.93,211.11h0L42.54,223.58a8,8,0,0,1-10.12-10.12l12.47-37.39h0A96,96,0,1,1,224,128Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-4-1.08,7.85,7.85,0,0,0-2.53.42L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Zm40-104a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,112Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,144Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm32,128H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M166,112a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,112Zm-6,26H96a6,6,0,0,0,0,12h64a6,6,0,0,0,0-12Zm70-10A102,102,0,0,1,79.31,217.65L44.44,229.27a14,14,0,0,1-17.71-17.71l11.62-34.87A102,102,0,1,1,230,128Zm-12,0A90,90,0,1,0,50.08,173.06a6,6,0,0,1,.5,4.91L38.12,215.35a2,2,0,0,0,2.53,2.53L78,205.42a6.2,6.2,0,0,1,1.9-.31,6.09,6.09,0,0,1,3,.81A90,90,0,0,0,218,128Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M168,112a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,112Zm-8,24H96a8,8,0,0,0,0,16h64a8,8,0,0,0,0-16Zm72-8A104,104,0,0,1,79.12,219.82L45.07,231.17a16,16,0,0,1-20.24-20.24l11.35-34.05A104,104,0,1,1,232,128Zm-16,0A88,88,0,1,0,51.81,172.06a8,8,0,0,1,.66,6.54L40,216,77.4,203.53a7.85,7.85,0,0,1,2.53-.42,8,8,0,0,1,4,1.08A88,88,0,0,0,216,128Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M164,112a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,112Zm-4,28H96a4,4,0,0,0,0,8h64a4,4,0,0,0,0-8Zm68-12A100,100,0,0,1,79.5,215.47l-35.69,11.9a12,12,0,0,1-15.18-15.18l11.9-35.69A100,100,0,1,1,228,128Zm-8,0A92,92,0,1,0,48.35,174.07a4,4,0,0,1,.33,3.27L36.22,214.72a4,4,0,0,0,5.06,5.06l37.38-12.46a3.93,3.93,0,0,1,1.27-.21,4.05,4.05,0,0,1,2,.54A92,92,0,0,0,220,128Z`}))]]),Nn=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm68-84a12,12,0,0,1-12,12H128a12,12,0,0,1-12-12V72a12,12,0,0,1,24,0v44h44A12,12,0,0,1,196,128Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm64-88a8,8,0,0,1-8,8H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48A8,8,0,0,1,192,128Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm56,112H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm62-90a6,6,0,0,1-6,6H128a6,6,0,0,1-6-6V72a6,6,0,0,1,12,0v50h50A6,6,0,0,1,190,128Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm64-88a8,8,0,0,1-8,8H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48A8,8,0,0,1,192,128Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm60-92a4,4,0,0,1-4,4H128a4,4,0,0,1-4-4V72a4,4,0,0,1,8,0v52h52A4,4,0,0,1,188,128Z`}))]]),Pn=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M140,80v41.21l34.17,20.5a12,12,0,1,1-12.34,20.58l-40-24A12,12,0,0,1,116,128V80a12,12,0,0,1,24,0ZM128,28A99.38,99.38,0,0,0,57.24,57.34c-4.69,4.74-9,9.37-13.24,14V64a12,12,0,0,0-24,0v40a12,12,0,0,0,12,12H72a12,12,0,0,0,0-24H57.77C63,86,68.37,80.22,74.26,74.26a76,76,0,1,1,1.58,109,12,12,0,0,0-16.48,17.46A100,100,0,1,0,128,28Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M216,128a88,88,0,1,1-88-88A88,88,0,0,1,216,128Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M136,80v43.47l36.12,21.67a8,8,0,0,1-8.24,13.72l-40-24A8,8,0,0,1,120,128V80a8,8,0,0,1,16,0Zm-8-48A95.44,95.44,0,0,0,60.08,60.15C52.81,67.51,46.35,74.59,40,82V64a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H72a8,8,0,0,0,0-16H49c7.15-8.42,14.27-16.35,22.39-24.57a80,80,0,1,1,1.66,114.75,8,8,0,1,0-11,11.64A96,96,0,1,0,128,32Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M224,128A96,96,0,0,1,62.11,197.82a8,8,0,1,1,11-11.64A80,80,0,1,0,71.43,71.43C67.9,75,64.58,78.51,61.35,82L77.66,98.34A8,8,0,0,1,72,112H32a8,8,0,0,1-8-8V64a8,8,0,0,1,13.66-5.66L50,70.7c3.22-3.49,6.54-7,10.06-10.55A96,96,0,0,1,224,128ZM128,72a8,8,0,0,0-8,8v48a8,8,0,0,0,3.88,6.86l40,24a8,8,0,1,0,8.24-13.72L136,123.47V80A8,8,0,0,0,128,72Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M134,80v44.6l37.09,22.25a6,6,0,0,1-6.18,10.3l-40-24A6,6,0,0,1,122,128V80a6,6,0,0,1,12,0Zm-6-46A93.4,93.4,0,0,0,61.51,61.56c-8.58,8.68-16,17-23.51,25.8V64a6,6,0,0,0-12,0v40a6,6,0,0,0,6,6H72a6,6,0,0,0,0-12H44.73C52.86,88.29,60.79,79.35,70,70a82,82,0,1,1,1.7,117.62,6,6,0,1,0-8.24,8.72A94,94,0,1,0,128,34Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M136,80v43.47l36.12,21.67a8,8,0,0,1-8.24,13.72l-40-24A8,8,0,0,1,120,128V80a8,8,0,0,1,16,0Zm-8-48A95.44,95.44,0,0,0,60.08,60.15C52.81,67.51,46.35,74.59,40,82V64a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H72a8,8,0,0,0,0-16H49c7.15-8.42,14.27-16.35,22.39-24.57a80,80,0,1,1,1.66,114.75,8,8,0,1,0-11,11.64A96,96,0,1,0,128,32Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M132,80v45.74l38.06,22.83a4,4,0,0,1-4.12,6.86l-40-24A4,4,0,0,1,124,128V80a4,4,0,0,1,8,0Zm-4-44A91.42,91.42,0,0,0,62.93,63C53.05,73,44.66,82.47,36,92.86V64a4,4,0,0,0-8,0v40a4,4,0,0,0,4,4H72a4,4,0,0,0,0-8H40.47C49.61,89,58.3,79,68.6,68.6a84,84,0,1,1,1.75,120.49,4,4,0,1,0-5.5,5.82A92,92,0,1,0,128,36Z`}))]]),Fn=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M76,64A12,12,0,0,1,88,52H216a12,12,0,0,1,0,24H88A12,12,0,0,1,76,64Zm140,52H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24Zm0,64H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24ZM44,112a16,16,0,1,0,16,16A16,16,0,0,0,44,112Zm0-64A16,16,0,1,0,60,64,16,16,0,0,0,44,48Zm0,128a16,16,0,1,0,16,16A16,16,0,0,0,44,176Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M216,64V192H88V64Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,1,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,1,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM68,188a12,12,0,1,1,12-12A12,12,0,0,1,68,188Zm0-48a12,12,0,1,1,12-12A12,12,0,0,1,68,140Zm0-48A12,12,0,1,1,80,80,12,12,0,0,1,68,92Zm124,92H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Zm0-48H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Zm0-48H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M82,64a6,6,0,0,1,6-6H216a6,6,0,0,1,0,12H88A6,6,0,0,1,82,64Zm134,58H88a6,6,0,0,0,0,12H216a6,6,0,0,0,0-12Zm0,64H88a6,6,0,0,0,0,12H216a6,6,0,0,0,0-12ZM44,54A10,10,0,1,0,54,64,10,10,0,0,0,44,54Zm0,128a10,10,0,1,0,10,10A10,10,0,0,0,44,182Zm0-64a10,10,0,1,0,10,10A10,10,0,0,0,44,118Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M84,64a4,4,0,0,1,4-4H216a4,4,0,0,1,0,8H88A4,4,0,0,1,84,64Zm132,60H88a4,4,0,0,0,0,8H216a4,4,0,0,0,0-8Zm0,64H88a4,4,0,0,0,0,8H216a4,4,0,0,0,0-8ZM44,120a8,8,0,1,0,8,8A8,8,0,0,0,44,120Zm0-64a8,8,0,1,0,8,8A8,8,0,0,0,44,56Zm0,128a8,8,0,1,0,8,8A8,8,0,0,0,44,184Z`}))]]),In=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M156,112a12,12,0,0,1-12,12H80a12,12,0,0,1,0-24h64A12,12,0,0,1,156,112Zm76.49,120.49a12,12,0,0,1-17,0L168,185a92.12,92.12,0,1,1,17-17l47.54,47.53A12,12,0,0,1,232.49,232.49ZM112,180a68,68,0,1,0-68-68A68.08,68.08,0,0,0,112,180Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Zm112,0a8,8,0,0,1-8,8H80a8,8,0,0,1,0-16h64A8,8,0,0,1,152,112Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM144,120H80a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M150,112a6,6,0,0,1-6,6H80a6,6,0,0,1,0-12h64A6,6,0,0,1,150,112Zm78.24,116.24a6,6,0,0,1-8.48,0l-51.38-51.38a86.15,86.15,0,1,1,8.48-8.48l51.38,51.38A6,6,0,0,1,228.24,228.24ZM112,186a74,74,0,1,0-74-74A74.09,74.09,0,0,0,112,186Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M152,112a8,8,0,0,1-8,8H80a8,8,0,0,1,0-16h64A8,8,0,0,1,152,112Zm77.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88.11,88.11,0,1,1,11.31-11.31l50.07,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M148,112a4,4,0,0,1-4,4H80a4,4,0,0,1,0-8h64A4,4,0,0,1,148,112Zm78.83,114.83a4,4,0,0,1-5.66,0l-52.7-52.7a84.1,84.1,0,1,1,5.66-5.66l52.7,52.7A4,4,0,0,1,226.83,226.83ZM112,188a76,76,0,1,0-76-76A76.08,76.08,0,0,0,112,188Z`}))]]),Ln=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M180,128a12,12,0,0,1-12,12H88a12,12,0,0,1,0-24h80A12,12,0,0,1,180,128Zm56,0A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M176,128a8,8,0,0,1-8,8H88a8,8,0,0,1,0-16h80A8,8,0,0,1,176,128Zm56,0A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm40,112H88a8,8,0,0,1,0-16h80a8,8,0,0,1,0,16Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M174,128a6,6,0,0,1-6,6H88a6,6,0,0,1,0-12h80A6,6,0,0,1,174,128Zm56,0A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M176,128a8,8,0,0,1-8,8H88a8,8,0,0,1,0-16h80A8,8,0,0,1,176,128Zm56,0A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M172,128a4,4,0,0,1-4,4H88a4,4,0,0,1,0-8h80A4,4,0,0,1,172,128Zm56,0A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),Rn=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:An}));Rn.displayName=`ArrowClockwiseIcon`;var zn=Rn,Bn=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:jn}));Bn.displayName=`ArrowsOutIcon`;var Vn=Bn,Hn=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:Mn}));Hn.displayName=`ChatCircleTextIcon`;var Un=Hn,Wn=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:Nn}));Wn.displayName=`ClockIcon`;var Gn=Wn,Kn=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:Pn}));Kn.displayName=`ClockCounterClockwiseIcon`;var qn=Kn,Jn=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:Fn}));Jn.displayName=`ListBulletsIcon`;var Yn=Jn,Xn=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:In}));Xn.displayName=`MagnifyingGlassMinusIcon`;var Zn=Xn,Qn=L.forwardRef((e,t)=>L.createElement(xe,{ref:t,...e,weights:Ln}));Qn.displayName=`MinusCircleIcon`;var $n=Qn,er=[`#F1F0FF`,`#E4E2FF`,`#CDC9FF`,`#B5B0FF`,`#A29CFF`,`#8F8CFF`,`#756DEB`,`#5A50D8`,`#463DAE`,`#332B81`],tr={dark:{ground:`#0B0B0C`,raised:`#121214`,inset:`#08080A`,hover:`#1A1A1D`,border:`#232327`,borderSoft:`#1A1A1E`,controlBorder:`#828288`,text:`#EDEDEF`,muted:`#A1A1A9`},light:{ground:`#F5F5F6`,raised:`#FFFFFF`,inset:`#EFEFF1`,hover:`#EDEDEF`,border:`#E3E3E6`,borderSoft:`#ECECEE`,controlBorder:`#6D6D73`,text:`#111113`,muted:`#53535B`}},nr=[`#eefbe6`,`#dcf7cc`,`#c2f0a6`,`#a5e880`,`#8fe06c`,`#7fd962`,`#66c04b`,`#4f9c3a`,`#3b7a2c`,`#2a5a1f`],rr=[`#fff5e6`,`#ffe9c9`,`#ffd79b`,`#ffc571`,`#ffbc62`,`#ffb454`,`#ef9c33`,`#c87d21`,`#9c5f16`,`#74460f`],ir=[`#fdecee`,`#fbd9dc`,`#f8b6bc`,`#f59099`,`#f37d87`,`#f26d78`,`#e04d5a`,`#c03642`,`#96262f`,`#6f1a21`],ar=[`#e8f6ff`,`#ccebff`,`#a3daff`,`#7dcbff`,`#66c5ff`,`#59c2ff`,`#33a7e6`,`#1e86bd`,`#146694`,`#0d4a6d`],or={micro:11,small:12,body:14,title:16,section:20,page:28},sr={display:`"Geist Mono Variable", "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,body:`"Geist Variable", "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`};function cr(e){return e===`healthy`?`ok`:e===`degraded`?`warn`:e===`unknown`?`gray`:`bad`}function lr(e){return Ne[e?`dark`:`light`]}function ur(e){let t=e?5:7;return{ok:nr[t],warn:rr[t],bad:ir[t],info:ar[t]}}function dr(e,t){return Oe[t?`dark`:`light`][e]??lr(t).muted}function fr(e){return e===`unhealthy`?`diamond`:e===`degraded`?`roundRect`:`circle`}function pr(e){return e===`unknown`?`dashed`:`solid`}function mr(e){let t=e.map(e=>{let t=e.start.match(/\.(\d+)(?=Z|[+-]\d{2}:\d{2}$)/),n=t?e.start.replace(t[0],``):e.start,r=Date.parse(n);if(Number.isFinite(r))return BigInt(r)*1000000n+BigInt((t?.[1]??``).slice(0,9).padEnd(9,`0`))}),n=t.filter(e=>e!==void 0),r=n.reduce((e,t)=>t[e,Number((t[n]??r)-r)/1e6]))}function hr(e){let t=mr(e),n=e.map(e=>{let n=t.get(e);return{span:e,start:n,end:n+Math.max(0,e.duration_ms),children:[]}}),r=new Map(n.map((e,t)=>[e.span.span_id,t])),i;for(let e=0;en[i].end-n[i].start)&&(i=e)}if(i===void 0)return[];for(let e of n)e.children.sort((t,r)=>Math.min(n[r].end,e.end)-Math.min(n[t].end,e.end)||n[r].start-n[t].start||t-r);let a=(e,t,n)=>({id:e,start:t,end:n,cursor:n,next:0}),o=[a(i,n[i].start,n[i].end)],s=[],c=(e,t,r)=>{r>t&&s.push({span_id:n[e].span.span_id,start:t,end:r})};for(;o.length;){let e=o[o.length-1],t=n[e.id].children[e.next++];if(t===void 0||e.cursor<=e.start){c(e.id,e.start,e.cursor),o.pop();continue}let r=n[t],i=Math.min(r.end,e.end);if(i>e.cursor)continue;let s=Math.max(r.start,e.start);i<=s||(c(e.id,i,e.cursor),e.cursor=s,o.push(a(t,s,i)))}return s}function gr(e,t){let n=new Set(e.map(e=>e.span_id)),r=(e,n)=>t.get(e)-t.get(n),i=new Map,a=[];for(let t of e){let e=t.parent_span_id;if(e&&e!==t.span_id&&n.has(e)){let n=i.get(e);n?n.push(t):i.set(e,[t])}else a.push(t)}let o=[],s=new Set,c=a.sort(r).reverse().map(e=>({span:e,depth:0})),l=()=>{for(;c.length;){let e=c.pop();if(!s.has(e.span)){s.add(e.span),o.push(e);for(let t of[...i.get(e.span.span_id)??[]].sort(r).reverse())c.push({span:t,depth:e.depth+1})}}};l();for(let t of e)s.has(t)||(c.push({span:t,depth:0}),l());return o}function _r({spans:e,dark:t,onSpan:n,selected:r,showCriticalPath:i=!0}){let a=(0,L.useMemo)(()=>{let t=new Map;for(let n of hr(e)){let e=t.get(n.span_id);e?e.push(n):t.set(n.span_id,[n])}return t},[e]),o=(0,L.useMemo)(()=>{let n=mr(e),r=e.reduce((e,t)=>Math.max(e,n.get(t)+t.duration_ms),1),i=[...new Set(e.map(e=>e.service))];return gr(e,n).map(({span:e,depth:a})=>{let o=n.get(e)/r*100,s=dr(i.indexOf(e.service),t);return{span:e,depth:a,offset:o,total:r,width:Math.min(Math.max(e.duration_ms/r*100,.6),100-o),color:s,failed:e.status===`STATUS_CODE_ERROR`}})},[e,t]);return(0,R.jsx)(T,{"data-waterfall":!0,style:{maxHeight:520,overflow:`auto`},children:(0,R.jsxs)(We,{highlightOnHover:!!n,verticalSpacing:6,layout:`fixed`,stickyHeader:!0,children:[(0,R.jsxs)(`colgroup`,{children:[(0,R.jsx)(`col`,{style:{width:`42%`}}),(0,R.jsx)(`col`,{}),(0,R.jsx)(`col`,{style:{width:76}})]}),(0,R.jsx)(We.Thead,{children:(0,R.jsxs)(We.Tr,{children:[(0,R.jsx)(We.Th,{children:`Operation`}),(0,R.jsx)(We.Th,{children:`Timeline`}),(0,R.jsx)(We.Th,{ta:`right`,children:`Duration`})]})}),(0,R.jsx)(We.Tbody,{children:o.map(({span:e,depth:t,offset:o,total:s,width:c,color:l,failed:u})=>{let d=i?a.get(e.span_id)??[]:[],f=d.reduce((e,t)=>e+t.end-t.start,0),p=d.length?` · on critical path · ${Ye(f)} (${(f/e.duration_ms*100).toFixed(1)}% of span)`:``,m=`${e.service} · ${e.operation} · ${Ye(e.duration_ms)}${p}`;return(0,R.jsxs)(We.Tr,{"data-depth":t,"data-selected":e.span_id===r||void 0,"aria-selected":n?e.span_id===r:void 0,tabIndex:n?0:void 0,onClick:n?()=>n(e):void 0,onKeyDown:n?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))}:void 0,style:{cursor:n?`pointer`:void 0},children:[(0,R.jsx)(We.Td,{title:m,children:(0,R.jsxs)(T,{style:{display:`flex`,alignItems:`center`,gap:6,paddingLeft:Math.min(t,16)*10,minWidth:0},children:[(0,R.jsx)(T,{w:8,h:8,bg:l,style:{borderRadius:`50%`,flex:`0 0 auto`}}),(0,R.jsxs)(T,{miw:0,children:[(0,R.jsxs)(I,{fw:600,size:`sm`,truncate:!0,children:[u&&(0,R.jsx)(D,{size:14,"aria-label":`Error`,color:`var(--mantine-color-bad-text)`}),e.operation]}),(0,R.jsx)(I,{c:`dimmed`,size:`xs`,truncate:!0,children:e.service})]})]})}),(0,R.jsx)(We.Td,{children:(0,R.jsxs)(T,{pos:`relative`,h:14,bg:`var(--mantine-color-default-hover)`,role:`img`,title:m,"aria-label":`${e.operation} on ${e.service} took ${Ye(e.duration_ms)}${p}`,style:{borderRadius:`var(--mantine-radius-sm)`},children:[(0,R.jsx)(T,{pos:`absolute`,left:`${o}%`,w:`${c}%`,h:`100%`,bg:u?`bad`:l,style:{borderRadius:`var(--mantine-radius-sm)`,minWidth:3}}),d.map((t,n)=>(0,R.jsx)(T,{"data-critical-path-segment":e.span_id,"aria-hidden":`true`,pos:`absolute`,left:`${t.start/s*100}%`,w:`${(t.end-t.start)/s*100}%`,top:`50%`,bg:`var(--mantine-color-text)`,style:{height:3,transform:`translateY(-50%)`,pointerEvents:`none`,boxShadow:`0 0 0 1px var(--mantine-color-body)`}},n))]})}),(0,R.jsx)(We.Td,{ta:`right`,children:(0,R.jsx)(I,{size:`sm`,ff:`monospace`,children:Ye(e.duration_ms)})})]},e.span_id)})})]})})}var vr={STATUS_CODE_ERROR:`Error`,STATUS_CODE_OK:`OK`,STATUS_CODE_UNSET:`Unset`},yr=e=>e==null?void 0:typeof e==`string`?e:JSON.stringify(e);function br({label:e,values:t}){let n=Object.keys(t).sort();return(0,R.jsxs)(T,{children:[(0,R.jsx)(I,{size:`xs`,fw:600,c:`dimmed`,mb:4,children:e}),n.length===0?(0,R.jsx)(I,{size:`xs`,c:`dimmed`,children:`None`}):(0,R.jsx)(oe,{label:e,items:n.map(e=>({label:(0,R.jsx)(I,{span:!0,inherit:!0,ff:`monospace`,children:e}),value:(0,R.jsx)(I,{span:!0,inherit:!0,ff:`monospace`,style:{whiteSpace:`pre-wrap`},children:typeof t[e]==`string`?String(t[e]):JSON.stringify(t[e])})}))})]})}function xr({traceId:e,span:t,load:n,onClose:r}){let a=(0,L.useRef)(null);(0,L.useEffect)(()=>{a.current?.scrollIntoView?.({block:`nearest`})},[t]);let o=ot({queryKey:[`span-extras`,e,t.span_id,t.start],queryFn:({signal:r})=>n(e,t,r),enabled:!!n,retry:!1,staleTime:1/0}),s=M(`danger`),c=t.status===`STATUS_CODE_ERROR`,l=o.data?.events.filter(e=>e.name===`exception`)??[];return(0,R.jsx)(i,{ref:a,withBorder:!0,p:`sm`,radius:`md`,"data-span-details":!0,"aria-label":`Span ${t.operation}`,role:`region`,children:(0,R.jsxs)(w,{gap:`sm`,children:[(0,R.jsxs)(f,{justify:`space-between`,wrap:`nowrap`,align:`flex-start`,children:[(0,R.jsxs)(T,{miw:0,children:[(0,R.jsx)(I,{fw:600,style:{overflowWrap:`anywhere`},children:t.operation}),(0,R.jsxs)(I,{size:`xs`,c:`dimmed`,children:[t.service,` · `,t.kind.replace(/^SPAN_KIND_/,``).toLowerCase(),` · `,Ye(t.duration_ms),` · `,(0,R.jsx)(I,{span:!0,ff:`monospace`,size:`xs`,children:ft(Date.parse(t.start))})]})]}),(0,R.jsx)(h,{"aria-label":`Close span details`,onClick:r})]}),(0,R.jsx)(T,{children:(0,R.jsx)(oe,{label:`Span metadata`,items:[{label:`Status`,value:(0,R.jsx)(F,{tone:c?`danger`:`neutral`,children:vr[t.status]??t.status})},{label:`Span`,value:(0,R.jsx)(I,{span:!0,inherit:!0,ff:`monospace`,children:t.span_id})},...t.parent_span_id?[{label:`Parent`,value:(0,R.jsx)(I,{span:!0,inherit:!0,ff:`monospace`,children:t.parent_span_id})}]:[]]})}),t.status_message&&(0,R.jsx)(I,{size:`sm`,c:c?s:void 0,style:{overflowWrap:`anywhere`},children:t.status_message}),o.isLoading&&(0,R.jsx)(O,{state:`loading`,loadingLabel:`Loading span details`,skeleton:(0,R.jsx)(St,{shape:`key_value`,rows:3})}),o.error&&(0,R.jsx)(T,{p:`xs`,children:(0,R.jsx)(O,{state:`error`,error:{message:o.error.message,onRetry:()=>void o.refetch()}})}),l.map((e,t)=>{let n=yr(e.attributes[`exception.message`]),r=yr(e.attributes[`exception.stacktrace`]);return(0,R.jsx)(T,{p:`xs`,children:(0,R.jsxs)(me,{tone:`danger`,title:yr(e.attributes[`exception.type`])??`Exception`,children:[n&&(0,R.jsx)(I,{size:`sm`,style:{overflowWrap:`anywhere`},children:n}),r&&(0,R.jsx)(it,{block:!0,mt:4,fz:12,style:{maxHeight:220,overflow:`auto`},children:r})]})},t)}),o.data&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(br,{label:`Attributes`,values:o.data.attributes}),o.data.events.length>0&&(0,R.jsxs)(T,{children:[(0,R.jsx)(I,{size:`xs`,fw:600,c:`dimmed`,mb:4,children:`Events`}),(0,R.jsx)(w,{gap:4,children:o.data.events.map((e,t)=>(0,R.jsxs)(T,{children:[(0,R.jsxs)(I,{size:`xs`,children:[(0,R.jsxs)(I,{span:!0,ff:`monospace`,c:`dimmed`,children:[`+`,Ye(e.offset_ns/1e6)]}),` `,e.name]}),e.name!==`exception`&&Object.keys(e.attributes).length>0&&(0,R.jsx)(T,{pl:`md`,children:(0,R.jsx)(br,{label:`Event attributes`,values:e.attributes})})]},t))})]}),(0,R.jsx)(br,{label:`Resource`,values:o.data.resource}),o.data.scope&&(0,R.jsx)(T,{children:(0,R.jsx)(oe,{items:[{label:`Instrumentation scope`,value:(0,R.jsx)(I,{span:!0,inherit:!0,ff:`monospace`,children:o.data.scope})}]})})]})]})})}function Sr({value:e,children:t}){return(0,R.jsxs)(f,{gap:4,wrap:`nowrap`,children:[(0,R.jsx)(T,{miw:0,flex:1,children:t}),(0,R.jsx)(He,{value:e,children:({copied:t,copy:n})=>(0,R.jsx)(de,{size:`xs`,variant:`subtle`,color:`gray`,"aria-label":t?`Trace ID copied`:`Copy trace ID`,title:e,onClick:e=>{e.stopPropagation(),n()},children:t?(0,R.jsx)(re,{size:12}):(0,R.jsx)(pe,{size:12})})})]})}function Cr(e){return e!==`OK`&&/^[A-Za-z]+$/.test(e)?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e}function wr(e){return Array.from({length:e.rows},(t,n)=>Object.fromEntries(e.columns.map((t,r)=>{let i=e.values[r]?.[n]??null;return[t.name,typeof i==`number`&&!Number.isFinite(i)?null:i]})))}function Tr(e,t){return e.viz!==`logs`||!t||t.rows<2?[]:t.columns.flatMap((e,n)=>{if(e.role!==`dimension`||e.type!==`string`||[`body`,`body_template`,`severity`,`status`].includes(e.name)||/(^id$|_id$)/.test(e.name))return[];let r=t.values[n][0];return typeof r==`string`&&r!==``&&t.values[n].slice(0,t.rows).every(e=>e===r)?[{name:e.name,value:r}]:[]})}function Er(e,t){let n=t.frame??{columns:[],values:[],rows:0};return{columns:n.columns.map(e=>e.name),rows:wr(n),selection:t=>{let n={};for(let r of e.query?.by??[]){let e=r.startsWith(`attributes[`)||r.startsWith(`resource[`)?r.slice(r.indexOf(`'`)+1,r.lastIndexOf(`'`)):r;t[e]!==void 0&&t[e]!==null&&(n[r]=String(t[e]))}return{time:typeof t.time==`number`?t.time:typeof t.start==`number`?t.start:void 0,dimensions:n,trace_id:typeof t.trace_id==`string`?t.trace_id:void 0,namespace:typeof t.namespace==`string`?t.namespace:void 0}}}}function Dr(e){return Or(e)||typeof e==`function`||kr(e)}function Or(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function kr(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function Ar(e,t){return e==null?null:Dr(e)?L.createElement(e,t):e}function jr(e){if(`cell`in e&&e.cell){let t=e.cell,n=t.column.columnDef,r=t,i=n;return r.getIsAggregated?.()?Ar(i.aggregatedCell??n.cell,t.getContext()):r.getIsPlaceholder?.()?null:Ar(n.cell,t.getContext())}return`header`in e&&e.header?Ar(e.header.column.columnDef.header,e.header.getContext()):`footer`in e&&e.footer?Ar(e.footer.column.columnDef.footer,e.footer.getContext()):null}function Mr(e){let t=De(e.source,e.selector,{compare:Ct});return typeof e.children==`function`?e.children(t):e.children}function Nr(e){let t=e;return Object.defineProperty(e,"state",{get(){return e.get()}}),`set`in e&&(t.setState=e.set.bind(e)),t}function Pr(e){let{createAtom:t,batch:n}=e,r=t(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:()=>{throw Error(`Feature not supported in current reactivity implementation`)},unmount:()=>{throw Error(`Feature not supported in current reactivity implementation`)},schedule:e.schedule??(e=>queueMicrotask(e)),batch:n,untrack:e=>e(),createReadonlyAtom:(e,n)=>{let i=n?.compare??Object.is,a=!1,o,s=()=>{let t=e();return(!a||!i(o,t))&&(o=t,a=!0),o},c=t(()=>(r.get(),s()),{compare:i});return{get:s,subscribe:c.subscribe.bind(c)}},createWritableAtom:(e,n)=>t(e,{compare:n?.compare}),commit:()=>{r.set(e=>e+1)}}}function Fr(e,t=Object.is){let n=!1,r;return{get:e.get,markCommitted:e=>{r=e,n=!0},subscribe:i=>e.subscribe(e=>{(!n||!t(r,e))&&i(e)})}}function Ir(){return Pr({createAtom:Se,batch:Ee})}function Lr(e,t){return typeof e==`function`?e(t):e}function Rr(e){if(Array.isArray(e))return e.map(Rr);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=t===null?Br():{},r=Object.keys(e);for(let t=0;t{(t.options.atoms?.[e]??t.baseAtoms[e]).set(e=>Lr(n,e))}}function Ur(e){if(typeof e!=`object`||!e)return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Wr(e){return Reflect.ownKeys(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}var Gr=3;function Kr(e,t){return qr(e,t,Gr)}function qr(e,t,n){if(Object.is(e,t))return!0;if(n<=0||!Ur(e)||!Ur(t)||(Array.isArray(e)||Array.isArray(t))&&(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length))return!1;let r=Wr(e),i=Wr(t);if(r.length!==i.length)return!1;let a=e,o=t;for(let e=0;e{let t=Lr(n,e);return r(e,t)?e:t})}function Yr(e){return e instanceof Function}function Xr(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i.length&&r(i)})};return r(e),n}var Zr=({fn:e,memoDeps:t,onAfterCompare:n,onAfterUpdate:r,onBeforeCompare:i,onBeforeUpdate:a})=>{let o=[],s;return c=>{i?.();let l=t?.(c),u=!l||l.length!==o?.length;if(!u&&l){for(let e=0;e{if(!t){t=!0;return}e()}}function $r({feature:e,fnName:t,objectId:n,onAfterUpdate:r,table:i,...a}){let o={onAfterUpdate:r?()=>{let{schedule:e,untrack:t}=i._reactivity;e(()=>t(()=>r()))}:void 0};return Zr({...a,...o})}function ei(e,t=`_`){let[n,r]=e.replace(t,` `).split(` `);return{fnKey:r,fnName:`${n}.${r}`,parentName:n}}function ti(e,t,n){for(let[r,{fn:i,memoDeps:a}]of Object.entries(n)){let{fnKey:n,fnName:o}=ei(r);t[n]=a?$r({memoDeps:a,fn:i,fnName:o,table:t,feature:e}):i}}function ni(e,t,n,r){for(let[i,{fn:a,memoDeps:o}]of Object.entries(r)){let{fnKey:r,fnName:s}=ei(i);if(o){let i=`_memo_${r}`;t[r]=function(...t){if(!this[i]){let t=this;this[i]=$r({memoDeps:e=>o(t,e),fn:(...e)=>a(t,...e),fnName:s,objectId:t.id,table:n,feature:e})}return this[i](...t)}}else t[r]=function(...e){return a(this,...e)}}}function ri(e){return e.row.getValue(e.column.id)}function ii(e){return e.getValue()??e.table.options.renderFallbackValue}function ai(e){return{table:e.table,column:e.column,row:e.row,cell:e,getValue:()=>e.getValue(),renderValue:()=>e.renderValue()}}var oi={assignCellPrototype:(e,t)=>{ni(`coreCellsFeature`,e,t,{cell_getValue:{fn:e=>ri(e)},cell_renderValue:{fn:e=>ii(e)},cell_getContext:{fn:e=>ai(e),memoDeps:e=>[e]}})}};function si(e){if(!e._columnPrototype){e._columnPrototype={table:e};let t=Object.values(e._features);for(let n=0;n{let n=t;for(let t=0;te[i.accessorKey]}if(!s)throw Error();let l=si(e),u=Object.create(l);u.accessorFn=c,u.columnDef=i,u.columns=[],u.depth=n,u.id=`${String(s)}`,u.parent=r;let d=e._columnInstanceInitFns;for(let e=0;ee.getFlatColumns())]}function yi(e){if(e.columns.length){let t=e.columns.flatMap(e=>e.getLeafColumns());return di(e.table,t)}return[e]}function bi(e){return{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>e.renderValue()?.toString?.()??null,...Object.values(e._features).reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef?.()),{}),...e.options.defaultColumn}}function xi(e,t,n,r=0){let i=Array(t.length);for(let a=0;ae.getFlatColumns())}function wi(e){let t=Br(),n=e.getAllFlatColumns();for(let e=0;ee.getLeafColumns()))}function Ei(e){let t=Br(),n=e.getAllLeafColumns();for(let e=0;e{ni(`coreColumnsFeature`,e,t,{column_getFlatColumns:{fn:e=>vi(e),memoDeps:e=>[e.table.options.columns]},column_getLeafColumns:{fn:e=>yi(e),memoDeps:e=>[e.table.atoms.columnOrder?.get(),e.table.atoms.grouping?.get(),e.table.options.columns,e.table.options.groupedColumnMode]}})},constructTableAPIs:e=>{ti(`coreColumnsFeature`,e,{table_getDefaultColumnDef:{fn:()=>bi(e),memoDeps:()=>[e.options.defaultColumn]},table_getAllColumns:{fn:()=>Si(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumns:{fn:()=>Ci(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumnsById:{fn:()=>wi(e),memoDeps:()=>[e.options.columns]},table_getAllLeafColumns:{fn:()=>Ti(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getAllLeafColumnsById:{fn:()=>Ei(e),memoDeps:()=>[e.getAllLeafColumns()]},table_getColumn:{fn:t=>Di(e,t)}})}};function ki(e){if(!e._headerPrototype){e._headerPrototype={table:e};let t=Object.values(e._features);for(let n=0;n0&&Fi(s,t-1,n,r,i,a)}function Ii(e){for(let t=0;te.id),e)}function Hi(e){return[...e.getHeaderGroups()].reverse()}function Ui(e){let t=e.getHeaderGroups(),n=[];for(let e=0;e{ni(`coreHeadersFeature`,e,t,{header_getLeafHeaders:{fn:e=>zi(e),memoDeps:e=>[e.column.table.options.columns]},header_getContext:{fn:e=>Bi(e),memoDeps:e=>[e.column.table.options.columns]}})},constructTableAPIs:e=>{ti(`coreHeadersFeature`,e,{table_getHeaderGroups:{fn:()=>Vi(e),memoDeps:()=>[e.options.columns,e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.options.groupedColumnMode]},table_getFooterGroups:{fn:()=>Hi(e),memoDeps:()=>[e.getHeaderGroups()]},table_getFlatHeaders:{fn:()=>Ui(e),memoDeps:()=>[e.getHeaderGroups()]},table_getLeafHeaders:{fn:()=>Wi(e),memoDeps:()=>[e.getHeaderGroups()]}})}};function Ki(e){if(!e._rowPrototype){e._rowPrototype={table:e};let t=Object.values(e._features);for(let n=0;n{let s=Ki(e),c=Object.create(s);c._displayIndexCache=-1,c._uniqueValuesCache=Br(),c._valuesCache=Br(),c.depth=i,c.id=t,c.index=r,c.original=n,c.parentId=o,c.subRows=a??[];let l=e._rowInstanceInitFns;for(let e=0;e$r({feature:`coreRowModelsFeature`,table:e,fnName:`table.getCoreRowModel`,memoDeps:()=>[e.options.data],fn:()=>Xi(e,e.options.data),onAfterUpdate:Qr(()=>{mi(e),hi(e),gi(e),_i(e)})})}function Yi(e,t,n,r=0,i){let a=[];for(let o=0;o{ti(`coreRowModelsFeature`,e,{table_getCoreRowModel:{fn:()=>Zi(e)},table_getPreFilteredRowModel:{fn:()=>Qi(e)},table_getFilteredRowModel:{fn:()=>$i(e)},table_getPreGroupedRowModel:{fn:()=>ea(e)},table_getGroupedRowModel:{fn:()=>ta(e)},table_getPreSortedRowModel:{fn:()=>na(e)},table_getSortedRowModel:{fn:()=>ra(e)},table_getPreExpandedRowModel:{fn:()=>ia(e)},table_getExpandedRowModel:{fn:()=>aa(e)},table_getPrePaginatedRowModel:{fn:()=>oa(e)},table_getPaginatedRowModel:{fn:()=>sa(e)},table_getRowModel:{fn:()=>ca(e)}})}};function ua(e){if(!e._cellPrototype){e._cellPrototype={table:e};let t=Object.values(e._features);for(let n=0;ne.subRows)}function va(e){let t=e.getCoreRowModel().flatRows,n=0;for(let e=0;e{ni(`coreRowsFeature`,e,t,{row_getDisplayIndex:{fn:e=>fa(e)},row_getAllCellsByColumnId:{fn:e=>Sa(e),memoDeps:e=>[e.getAllCells()]},row_getAllCells:{fn:e=>xa(e),memoDeps:e=>[e.table.getAllLeafColumns()]},row_getLeafRows:{fn:e=>_a(e),memoDeps:e=>[e.subRows]},row_getParentRow:{fn:e=>ya(e)},row_getParentRows:{fn:e=>ba(e)},row_getUniqueValues:{fn:(e,t)=>ha(e,t)},row_getValue:{fn:(e,t)=>ma(e,t)},row_renderValue:{fn:(e,t)=>ga(e,t)}})},constructTableAPIs:e=>{ti(`coreRowsFeature`,e,{table_getRowsInDisplayOrder:{fn:()=>pa(e),memoDeps:()=>[e.getPrePaginatedRowModel().rows,e.options.paginateExpandedRows,e.options.paginateExpandedRows===!1?e.atoms.expanded?.get():void 0]},table_getRowId:{fn:(t,n,r)=>Ca(t,e,n,r)},table_getRow:{fn:(t,n)=>wa(e,t,n)},table_getMaxSubRowDepth:{fn:()=>va(e),memoDeps:()=>[e.getCoreRowModel()]}})}};function Ea(e,t,n=(e,t)=>e===t){let r=t===void 0?e.options.state:t;e._reactivity.batch(()=>{if(r)for(let t in r){let i=e.baseAtoms[t];if(!i)continue;let a=r[t],o=a===void 0?e.initialState[t]:a;n(e._reactivity.untrack(()=>i.get()),o)||i.set(()=>o)}})}function Da(e,t,n=(e,t)=>e===t){e._reactivity.batch(()=>{Ea(e,t,n),e._reactivity.commit?.()})}function Oa(e){let t=Rr(e.initialState);e._reactivity.batch(()=>{let n=Object.keys(t);for(let r=0;rr):e.options=r,n?.syncExternalState!==!1&&Da(e,r.state??null)}var ja={coreCellsFeature:oi,coreColumnsFeature:Oi,coreHeadersFeature:Gi,coreRowModelsFeature:la,coreRowsFeature:Ta,coreTablesFeature:{constructTableAPIs:e=>{ti(`coreTablesFeature`,e,{table_reset:{fn:()=>Oa(e)},table_setOptions:{fn:t=>Aa(e,t)}})}}};function Ma(e){return e}function Na(e,t={}){return Object.values(e).forEach(e=>{t=e.getInitialState?.(t)??t}),Rr(t)}function Pa(e){let t=e.features.coreReactivityFeature,{aggregationFns:n,columnMeta:r,coreRowModel:i,expandedRowModel:a,facetedMinMaxValues:o,facetedRowModel:s,facetedUniqueValues:c,filterFns:l,filterMeta:u,filteredRowModel:d,groupedRowModel:f,paginatedRowModel:p,sortFns:m,sortedRowModel:h,tableMeta:g,..._}=e.features,v={_cellInstanceInitFns:[],_columnInstanceInitFns:[],_features:{...ja,..._},_headerGroupInstanceInitFns:[],_headerInstanceInitFns:[],_reactivity:t,_rowInstanceInitFns:[],_rowModelFns:{aggregationFns:n,filterFns:l,sortFns:m},_rowModels:{},atoms:{},baseAtoms:{}},y=Object.values(v._features),b={...y.reduce((e,t)=>Object.assign(e,t.getDefaultTableOptions?.(v)),{}),...e};if(t.wrapExternalAtoms&&b.atoms)for(let[e,n]of Object.entries(b.atoms)){let r=n,i=t.createWritableAtom(r.get(),{debugName:`externalAtom/${e}`});b.atoms[e]=i;let a=!1,o=r.subscribe(e=>{a||i.set(e)}),s=i.subscribe(e=>{a=!0,r.set(e),a=!1});t.addSubscription(o),t.addSubscription(s)}t.createOptionsStore?(v.optionsStore=t.createWritableAtom(b,{debugName:`table/optionsStore`}),Object.defineProperty(v,"options",{configurable:!0,enumerable:!0,get(){return v.optionsStore.get()},set(e){v.optionsStore.set(()=>e)}})):v.options=b,v.initialState=Na(v._features,v.options.initialState);let x=Object.keys(v.initialState);for(let e=0;e{let e=v.options,t=e.atoms?.[n],r=t?t.get():v.baseAtoms[n].get();if(t)return r;let i=e.state;if(i&&Vr(i,n)){let e=i[n];return e===void 0?v.initialState[n]:e}return r},{debugName:`table/atoms/${n}`})}Ea(v),v.store=Nr(t.createReadonlyAtom(()=>{let e={};for(let t=0;t{let i=e.getValue(r),a=n.getValue(r),o=t.resolveDataValue;return o&&(i=o(i),a=o(a)),t.sort(i,a,e,n,r)},e);return t}var La=Ia({resolveDataValue:e=>Ba(e).toLowerCase(),sort:(e,t)=>Va(e,t)}),Ra=Ia({sort:(e,t)=>za(e,t)});function za(e,t){return e===t?0:e>t?1:-1}function Ba(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function Va(e,t){let n=0,r=0,i=e.length,a=t.length;for(;n=48&&e<=57}function Ua(e,t,n){let r=t+1;for(;ro)return 1;if(o>a)return-1}return o>s?1:s>o?-1:0}function Ga(e,t,n,r,i,a){let o=t;for(;oi?1:i>t?-1:0}let u=parseInt(e.slice(t,n),10),d=parseInt(r.slice(i,a),10);return u>d?1:d>u?-1:0}function Ka(e,t,n){let r=0;for(let i=t;i1)){r=`alphanumeric`;break}}if(!r&&i&&(r=`text`),r){let e=t?.[r];if(e||r===`alphanumeric`&&(e=t?.text),e)return e}return Ra}function $a(e){let t=e.table.getFilteredRowModel().flatRows.slice(0,10);for(let n=0;n{let o=a.findIndex(t=>t.id===e.id),s=o===-1?void 0:a[o],c=[],l,u=i?t:r===`desc`,d=!!(a.length&&ao(e)&&n);return l=d?s?`toggle`:`add`:s?`toggle`:`replace`,l===`toggle`&&(i||r||(l=`remove`)),l===`add`?(c=[...a,{id:e.id,desc:u}],c.splice(0,c.length-(e.table.options.maxMultiSortColCount??2**53-1))):c=l===`toggle`?d?a.map(t=>t.id===e.id?{...t,desc:u}:t):[{id:e.id,desc:u}]:l===`remove`?d?a.filter(t=>t.id!==e.id):[]:[{id:e.id,desc:u}],c})}function no(e){return e.columnDef.sortDescFirst??e.table.options.sortDescFirst??$a(e)===`desc`?`desc`:`asc`}function ro(e,t){let n=no(e),r=oo(e);return r?r!==n&&(e.table.options.enableSortingRemoval??!0)&&(!t||(e.table.options.enableMultiRemove??!0))?!1:r===`desc`?`asc`:`desc`:n}function io(e){return(e.columnDef.enableSorting??!0)&&(e.table.options.enableSorting??!0)&&!!e.accessorFn}function ao(e){return e.columnDef.enableMultiSort??e.table.options.enableMultiSort??!!e.accessorFn}function oo(e){let t=e.table.atoms.sorting?.get()?.find(t=>t.id===e.id);return t?t.desc?`desc`:`asc`:!1}function so(e){return e.table.atoms.sorting?.get()?.findIndex(t=>t.id===e.id)??-1}function co(e){Ya(e.table,t=>t.length?t.filter(t=>t.id!==e.id):[])}function lo(e){let t=io(e);return n=>{t&&to(e,void 0,ao(e)?e.table.options.isMultiSortEvent?.(n):!1)}}var uo={getInitialState(e){return{sorting:Ja(),...e}},getDefaultColumnDef(){return{sortFn:`auto`,sortUndefined:1}},getDefaultTableOptions(e){return{autoResetSorting:!1,onSortingChange:Hr(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}},assignColumnPrototype(e,t){ni(`rowSortingFeature`,e,t,{column_getAutoSortFn:{fn:e=>Qa(e)},column_getAutoSortDir:{fn:e=>$a(e)},column_getSortFn:{fn:e=>eo(e)},column_toggleSorting:{fn:(e,t,n)=>to(e,t,n)},column_getFirstSortDir:{fn:e=>no(e)},column_getNextSortingOrder:{fn:(e,t)=>ro(e,t)},column_getCanSort:{fn:e=>io(e)},column_getCanMultiSort:{fn:e=>ao(e)},column_getIsSorted:{fn:e=>oo(e)},column_getSortIndex:{fn:e=>so(e)},column_clearSorting:{fn:e=>co(e)},column_getToggleSortingHandler:{fn:e=>lo(e)}})},constructTableAPIs(e){ti(`rowSortingFeature`,e,{table_autoResetSorting:{fn:()=>Za(e)},table_setSorting:{fn:t=>Ya(e,t)},table_resetSorting:{fn:t=>Xa(e,t)}})}};function fo(){return e=>{let t=e;return $r({feature:`rowSortingFeature`,table:t,fnName:`table.getSortedRowModel`,memoDeps:()=>[t.atoms.sorting?.get(),t.getPreSortedRowModel()],fn:()=>po(t),onAfterUpdate:Qr(()=>hi(t))})}}function po(e){let t=e.getPreSortedRowModel(),n=e.atoms.sorting?.get();if(!t.rows.length||!n?.length)return t;let r=[],i=n.filter(t=>{let n=e.getColumn(t.id);return n?io(n):!1});if(!i.length)return t;let a=[];for(let t=0;t{for(let n=0;n{let t=e.slice();t.sort(o);let n=!1;for(let i=0;i`u`?L.useEffect:L.useLayoutEffect;function ho(e,t){let[{table:n,rootSource:r}]=(0,L.useState)(()=>{let t=Pa({...e,features:{coreReactivityFeature:Ir(),...e.features}});return t.Subscribe=(e=>Mr({...e,source:e.source??t.store})),t.FlexRender=jr,{table:t,rootSource:Fr(t.store,Ct)}}),i=n;Aa(i,t=>({...t,...e}),{syncExternalState:!1});let a=i.options.state,o=r.get(),s=De(r,t,{compare:Ct});return mo(()=>{r.markCommitted(o),Da(i,a??null,Ct)}),(0,L.useMemo)(()=>({...n,options:e,state:s}),[n,e,s])}var go=new Set([`id`,`http`,`https`,`rpc`,`grpc`,`cpu`,`sql`,`url`,`uri`,`ip`,`io`,`db`,`gc`,`tls`,`api`]),_o={ms:`ms`,ns:`ns`,s:`s`,us:`µs`,bytes:`bytes`,percent:`%`,ratio:`ratio`,per_second:`/s`,per_minute:`/min`},vo={body_template:`message template`,calls:`requests`,spans:`requests`,parquet_index:`traces`};function yo(e,t,{withUnit:n=!0}={}){let r=typeof e==`string`?e:e.name,i=t?.options?.columns?.find(e=>e.field===r)?.unit??(typeof e==`string`?void 0:e.unit)??(typeof e!=`string`&&e.role===`measure`?t?.unit:void 0),a=vo[r]??r;/\b(?:duckdb|parquet|sqlite|variant|timestamptz_ns|timestamp_ns)\b|\btelemetry\./i.test(a)&&(a=`value`),a=a.replace(/^(\w+)\(([^()]*)\)$/,(e,t,n)=>[t,n].filter(Boolean).join(`_`));let o=a.match(/_(ms|ns|us|s|bytes|percent)$/i);o&&(a=a.slice(0,-o[0].length));let s=i??o?.[1]?.toLowerCase();return a=a.split(`_`).map((e,t)=>/^p\d+$/i.test(e)||go.has(e.toLowerCase())?/^p\d+$/i.test(e)?e.toLowerCase():e.toUpperCase():t===0?e.charAt(0).toUpperCase()+e.slice(1):e).join(` `),a+(n&&s&&s!==`none`&&s!==`count`?` (${_o[s]??s})`:``)}var bo={ok:0,warn:1,bad:2};function xo(e){if(!e?.length)return;let t=[...e].sort((e,t)=>bo[e.status]-bo[t.status]),n=t[0],r=t[t.length-1];return bo[r.status]>bo[n.status]&&r.value!==n.value?r.value>n.value?`lower`:`higher`:`lower`}function So(e,t,n){if(e===null||!t||t.length===0)return null;n??=xo(t);let r=`ok`;for(let i of t)(n===`lower`?e>=i.value:e<=i.value)&&bo[i.status]>bo[r]&&(r=i.status);return r}var Co=e=>String(e??``)||`(none)`,wo=e=>typeof e==`number`&&Number.isFinite(e)?e:null;function To(e){return e.columns.flatMap((e,t)=>e.role===`measure`?[t]:[])}function Eo(e){let t=e.columns.findIndex(e=>e.role===`time`);if(t<0)return[];let n=e.columns.findIndex(e=>e.role===`dimension`),r=To(e);if(n>=0&&r.length>0){let i=r[0],a=new Map;for(let r=0;r({name:e.columns[n].name,unit:e.columns[n].unit,points:e.values[t].map((t,r)=>[Number(t),wo(e.values[n][r])])}))}function Do(e){let t=e.columns.flatMap((e,t)=>e.role===`dimension`?[t]:[]),n=To(e);if(t.length===0||n.length===0)return{categories:[],series:[]};let r=t[0],i=[];for(let t=0;t1){let a=t[1],o=n[0],s=new Map;for(let t=0;tnull)),s.get(n)[i.indexOf(String(e.values[r][t]??``))]=wo(e.values[o][t])}return{categories:i,series:[...s.entries()].map(([t,n])=>({name:t,unit:e.columns[o].unit,values:n}))}}return{categories:i,series:n.map(t=>({name:e.columns[t].name,unit:e.columns[t].unit,values:e.values[t].map(wo)}))}}function Oo(e,t){let n=e.filter(e=>e!==null);if(n.length===0)return null;switch(t){case`last`:return n[n.length-1];case`min`:return Math.min(...n);case`max`:return Math.max(...n);case`sum`:return n.reduce((e,t)=>e+t,0);default:return n.reduce((e,t)=>e+t,0)/n.length}}function ko(e,t){let n=To(t)[0];return n===void 0?null:(e.reduce??`window`)===`window`?t.totals?wo(t.totals[n]):Oo(t.values[n].map(wo),`mean`):Oo(t.values[n].map(wo),e.reduce??`mean`)}function Ao(e){let t=To(e)[0];return t===void 0?[]:e.values[t].map(wo)}function jo(e,t){return!t.previous||(e.reduce??`window`)===`window`&&!t.previous.totals?null:ko(e,t.previous)}function Mo(e,t){return`rgba(${[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)).join(`, `)}, ${t})`}function No(e,t){return{color:e,...j(e,t.surface)<3?{borderColor:t.text,borderWidth:1}:{}}}function Po(e,t){return{color:e,...j(e,t.surface)<3?{shadowColor:t.text,shadowBlur:2}:{}}}function Fo(e,t){return{ok:nr,warn:rr,bad:ir}[e][t?5:8]}function Io({panel:e,result:t,dark:n=!1,compare:r=!0,range:i}){let a=t.frame,o=ko(e,a),s=a.columns.find(e=>e.role===`measure`)?.unit??e.unit,c=e.better??t.better??xo(e.thresholds),l=So(o,e.thresholds,c)??(a.health?.health===`healthy`?`ok`:a.health?.health===`degraded`?`warn`:a.health?.health===`unhealthy`?`bad`:null),u=jo(e,t),d=Ao(a),p=e.thresholds?.find(e=>e.status===l&&o!==null&&(c===`higher`?o<=e.value:o>=e.value))?.label;return(0,R.jsxs)(T,{h:`100%`,style:{display:`flex`,flexDirection:`column`,justifyContent:`space-between`,gap:4},children:[(0,R.jsxs)(f,{justify:`space-between`,align:`flex-start`,wrap:`nowrap`,gap:`xs`,children:[(0,R.jsx)(I,{"data-stat-value":!0,fz:24,fw:500,lh:1.1,lts:`-0.02em`,ff:`var(--mantine-font-family-monospace)`,children:pt(s,o)}),l&&(0,R.jsx)(T,{"data-stat-status":!0,children:(0,R.jsx)(F,{tone:l===`bad`?`danger`:l===`warn`?`warning`:`success`,children:p??(l===`bad`?`Unhealthy`:l===`warn`?`Degraded`:`Healthy`)})})]}),r&&u!==null&&o!==null&&(0,R.jsx)(Lo,{dark:n,value:o,previous:u,better:c,unit:s,period:Ro(i,t)}),(0,R.jsx)(zo,{points:d,area:!0,dark:n,height:40})]})}function Lo({value:e,previous:t,better:n,unit:r,period:i,dark:a}){let o=r===`percent`,s=o?e-t:t===0?e===0?0:1/0:(e-t)/Math.abs(t)*100,c=s>=0,l=s===0||!n?null:c?n===`higher`:n===`lower`,u=Number.isFinite(s)?o?`${c?`+`:`−`}${Math.abs(s).toFixed(1)} pts`:`${c?`+`:`−`}${Math.abs(s).toFixed(0)}%`:`new`;return(0,R.jsxs)(f,{gap:6,children:[(0,R.jsxs)(I,{"data-stat-delta":!0,fz:12,fw:600,style:{color:l===null?`var(--mantine-color-dimmed)`:Fo(l?`ok`:`bad`,a)},children:[c?`▲`:`▼`,` `,u]}),(0,R.jsxs)(I,{fz:12,c:`dimmed`,children:[`vs previous `,i]})]})}function Ro(e,t){let n=t.from_ms!==void 0&&t.to_ms!==void 0?t.to_ms-t.from_ms:t.shift_ms,r=/^(\d+)(s|m|h|d|w)$/.exec(e??``),i=r?Number(r[1])*{s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5}[r[2]]:n;if(!i)return`period`;let a=i>=6048e5?`week`:i>=864e5?`day`:i>=36e5?`hour`:i>=6e4?`minute`:`second`,o=i/{week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3}[a];return o===1?a:`${Number(o.toFixed(2))} ${a}s`}function zo({points:e,area:t=!1,dark:n=!1,height:r=32}){let i=e.filter(e=>e!==null&&Number.isFinite(e));if(i.length<2)return null;let a=Math.min(...i),o=Math.max(...i),s=r,c=t=>t/(e.length-1)*200,l=e=>s-2-(e-a)/(o-a||1)*(s-4),u=e.map((t,n)=>t===null||!Number.isFinite(t)?``:`${n===0||e[n-1]===null||!Number.isFinite(e[n-1])?`M`:`L`}${c(n).toFixed(1)},${l(t).toFixed(1)}`).join(``),d=[];return e.forEach((t,n)=>{if(t!==null&&Number.isFinite(t)){if(!n||e[n-1]===null||!Number.isFinite(e[n-1]))d.push({start:n,end:n,path:`M${c(n).toFixed(1)},${l(t).toFixed(1)}`});else{let e=d.at(-1);e.end=n,e.path+=`L${c(n).toFixed(1)},${l(t).toFixed(1)}`}}}),(0,R.jsxs)(`svg`,{viewBox:`0 0 200 ${s}`,preserveAspectRatio:`none`,width:`100%`,height:s,role:`img`,"aria-label":`Value over this panel's time range`,children:[t&&d.filter(e=>e.end>e.start).map(e=>(0,R.jsx)(`path`,{"data-sparkline-area":!0,d:`${e.path}L${c(e.end)},${s}L${c(e.start)},${s}Z`,fill:dr(0,n),opacity:.18},e.start)),(0,R.jsx)(`path`,{"data-sparkline-line":!0,d:u,fill:`none`,stroke:dr(0,n),strokeWidth:1.5,vectorEffect:`non-scaling-stroke`})]})}function Bo(e,t,n,r,i,a){e.format===`status`&&e.unit&&typeof t==`string`&&t.trim()!==``&&Number.isFinite(Number(t))&&(t=Number(t));let o=t===null?`—`:String(t),s={kind:e.format,text:o};if([`unit`,`bar`,`status`,`sparkline`].includes(e.format)&&(s.text=typeof t==`number`?pt(e.unit,t):o),e.format===`bar`&&(s.fraction=typeof t==`number`&&n>0?Math.max(0,Math.min(1,t/n)):0),e.format===`status`&&typeof t==`number`&&(s.status=So(Number.isFinite(t)?t:null,r?.thresholds,r?.better??i)),e.format===`service_link`&&(s.variable=e.variable),e.format===`sparkline`&&a)return s.points=a.slice(0,240),s;if(e.format===`sparkline`)try{let e=JSON.parse(o);Array.isArray(e)?s.points=e.slice(0,240).map(e=>typeof e==`number`&&Number.isFinite(e)?e:null):s.unsupported=`Sparkline requires an array column`}catch{s.unsupported=`Sparkline requires an array column`}return s}function Vo({text:e,template:t=!1,highlight:n=``}){let r=xt(`light`)===`dark`,i=er[r?5:7],a=[1,3,5].map(e=>parseInt(i.slice(e,e+2),16)).join(`, `),o=[];if(n){let t=e.toLowerCase(),r=n.toLowerCase();for(let e=t.indexOf(r);e!==-1;e=t.indexOf(r,e+r.length))o.push(e)}let s=(t,i)=>{let s=[],c=t;for(let l of o){let o=Math.max(t,l),u=Math.min(i,l+n.length);o>=u||(s.push(e.slice(c,o),(0,R.jsx)(`mark`,{"data-highlight-match":!0,style:{background:`rgba(${a}, ${r?.22:.3})`,color:`inherit`,borderRadius:3,padding:`0 2px`},children:e.slice(o,u)},o)),c=u)}return s.push(e.slice(c,i)),s},c=[],l=0;if(t)for(let t of e.matchAll(/<\*>||||