From 3fa26cfe3cb21c8004727deee078584e5fc52850 Mon Sep 17 00:00:00 2001 From: nfebe Date: Fri, 28 Aug 2026 21:34:14 +0100 Subject: [PATCH 01/27] feat: Keep the local index running and serve it The agent is the process that stays up on a developer's machine. It starts the indexer on a free port, waits for it to answer, and starts it again when it dies, backing off as failures repeat. Stopping the agent stops everything the indexer started, not only the process it launched directly. Its own surface reports whether the indexer is answering and how many times it has been started, and reads the repositories and graphs the indexer holds. Clients talk to the agent rather than to the indexer, because the agent is the half that is always up and the half that knows where the indexer landed. It never parses code. The grammars and the graph shape stay in one place. --- .gitignore | 3 + Makefile | 64 +++++ README.md | 37 +++ VERSION | 1 + cmd/agent/main.go | 80 ++++++ go.mod | 3 + internal/api/server.go | 156 ++++++++++ internal/api/server_test.go | 149 ++++++++++ internal/config/config.go | 54 ++++ internal/config/config_test.go | 55 ++++ internal/core/client.go | 186 ++++++++++++ internal/core/client_test.go | 158 +++++++++++ internal/core/testdata/graph.json | 1 + internal/core/testdata/repositories.json | 1 + .../core/testdata/unknown_repository.json | 1 + internal/supervise/process_other.go | 13 + internal/supervise/process_unix.go | 30 ++ internal/supervise/supervisor.go | 266 ++++++++++++++++++ internal/supervise/supervisor_test.go | 166 +++++++++++ 19 files changed, 1424 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 VERSION create mode 100644 cmd/agent/main.go create mode 100644 go.mod create mode 100644 internal/api/server.go create mode 100644 internal/api/server_test.go create mode 100644 internal/config/config.go create mode 100644 internal/config/config_test.go create mode 100644 internal/core/client.go create mode 100644 internal/core/client_test.go create mode 100644 internal/core/testdata/graph.json create mode 100644 internal/core/testdata/repositories.json create mode 100644 internal/core/testdata/unknown_repository.json create mode 100644 internal/supervise/process_other.go create mode 100644 internal/supervise/process_unix.go create mode 100644 internal/supervise/supervisor.go create mode 100644 internal/supervise/supervisor_test.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b8ba3ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +sourceant-agent +coverage.out +coverage.html diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..26105ca --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +.PHONY: help deps build test test-race test-coverage fmt fmt-check vet lint lint-install clean qa + +BINARY_NAME=sourceant-agent +VERSION?=$(shell cat VERSION 2>/dev/null || echo "dev") +BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S') +GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") +LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT)" + +help: + @echo "SourceAnt agent - build commands" + @echo "" + @echo "make deps - Download dependencies" + @echo "make build - Build the agent binary" + @echo "make test - Run unit tests" + @echo "make test-race - Run unit tests under the race detector" + @echo "make test-coverage - Run tests with a coverage report" + @echo "make fmt - Format code with gofmt" + @echo "make fmt-check - Check gofmt formatting" + @echo "make vet - Run go vet" + @echo "make lint - Run golangci-lint" + @echo "make qa - Run fmt-check, vet, lint, and tests" + @echo "make clean - Clean build artifacts" + +deps: + go mod download + go mod tidy + +build: + go build $(LDFLAGS) -o $(BINARY_NAME) ./cmd/agent + +test: + go test ./... + +test-race: + go test -race ./... + +test-coverage: + go test -coverprofile=coverage.out ./... + go tool cover -html=coverage.out -o coverage.html + @echo "Coverage report generated: coverage.html" + +fmt: + go fmt ./... + +fmt-check: + @test -z "$$(gofmt -l .)" || (echo "Run gofmt on:" && gofmt -l . && exit 1) + +vet: + go vet ./... + +lint: + @command -v golangci-lint > /dev/null 2>&1 && golangci-lint run ./... || \ + (test -x "$$(go env GOPATH)/bin/golangci-lint" && "$$(go env GOPATH)/bin/golangci-lint" run ./... || \ + (echo "golangci-lint not found. Run 'make lint-install' first." && exit 1)) + +lint-install: + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest + +qa: fmt-check vet lint test + +clean: + rm -f $(BINARY_NAME) + rm -f coverage.out coverage.html + go clean diff --git a/README.md b/README.md new file mode 100644 index 0000000..e59314d --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# SourceAnt agent + +The process that stays up on a developer's machine. It supervises the SourceAnt indexer, keeps the local code graph current, and serves it to the CLI and the local UI. + +It never parses code. The grammars and the graph shape live in the Python core, so that one index serves every client. + +## What it does + +Starts the core on a free port and waits for it to answer. Restarts it when it dies, backing off as failures repeat. Serves its own HTTP surface on `127.0.0.1:8930`, where `/health` reports whether the core is up and how many times it has been started, and `/api/repositories` and `/api/graph` read the index. + +Loopback is the default because the agent reads a working tree. The machine it runs on is the only audience it has. + +## Running it + +The core has to be on `PATH` as `sourceant`. See [sourceant/sourceant](https://github.com/sourceant/sourceant). + +```bash +make build +./sourceant-agent +``` + +| Variable | Default | Meaning | +|---|---|---| +| `SOURCEANT_AGENT_LISTEN` | `127.0.0.1:8930` | Where the agent answers | +| `SOURCEANT_CORE` | `sourceant` | The core executable to supervise | +| `SOURCEANT_CORE_PORT` | chosen at start | The port to start the core on | + +## Building + +```bash +make qa # fmt-check, vet, lint, test +make build +``` + +## Licence + +MIT. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/cmd/agent/main.go b/cmd/agent/main.go new file mode 100644 index 0000000..8097ccf --- /dev/null +++ b/cmd/agent/main.go @@ -0,0 +1,80 @@ +// Command sourceant-agent keeps the local index running and serves it. +package main + +import ( + "context" + "fmt" + "os" + "os/signal" + "strconv" + "syscall" + "time" + + "github.com/sourceant/agent/internal/api" + "github.com/sourceant/agent/internal/config" + "github.com/sourceant/agent/internal/core" + "github.com/sourceant/agent/internal/supervise" +) + +// Set at build time. See the Makefile. +var ( + Version = "dev" + BuildTime = "unknown" + GitCommit = "unknown" +) + +func main() { + if len(os.Args) > 1 && (os.Args[1] == "version" || os.Args[1] == "--version") { + fmt.Printf("sourceant-agent %s (%s, built %s)\n", Version, GitCommit, BuildTime) + return + } + if err := run(); err != nil { + fmt.Fprintln(os.Stderr, "sourceant-agent:", err) + os.Exit(1) + } +} + +func run() error { + cfg, err := config.FromEnvironment() + if err != nil { + return err + } + + port := cfg.CorePort + if port == 0 { + if port, err = supervise.FreePort(); err != nil { + return fmt.Errorf("finding a port for the core: %w", err) + } + } + coreURL := "http://127.0.0.1:" + strconv.Itoa(port) + client := core.New(coreURL, 30*time.Second) + + supervisor := supervise.New(supervise.Options{ + Name: cfg.Core, + Args: []string{"serve", "--host", "127.0.0.1", "--port", strconv.Itoa(port)}, + Ready: client.Healthy, + ReadyWithin: 60 * time.Second, + Output: os.Stderr, + }) + + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + supervised := make(chan error, 1) + go func() { supervised <- supervisor.Run(ctx) }() + + served := make(chan error, 1) + server := api.New(client, supervisor, Version, coreURL) + go func() { served <- server.Serve(ctx, cfg.Listen) }() + + fmt.Fprintf(os.Stderr, "sourceant-agent %s listening on %s, core on %s\n", Version, cfg.Listen, coreURL) + + // Whichever half stops first ends the agent: an agent serving without a + // core answers nothing, and a core nobody serves is not reachable. + select { + case err := <-supervised: + return err + case err := <-served: + return err + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..39a3490 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/sourceant/agent + +go 1.26.1 diff --git a/internal/api/server.go b/internal/api/server.go new file mode 100644 index 0000000..2bc6584 --- /dev/null +++ b/internal/api/server.go @@ -0,0 +1,156 @@ +// Package api is the agent's own HTTP surface. +// +// Everything else talks to the agent rather than to the Python core: the agent +// is the process that is always up, it knows which port the core landed on, and +// it is where a view across every registered repository will be assembled. A +// client that reached past it would have to learn all three. +package api + +import ( + "context" + "encoding/json" + "errors" + "net/http" + "strconv" + "time" + + "github.com/sourceant/agent/internal/core" +) + +// Reader is the part of the core client this server needs. +type Reader interface { + Healthy(ctx context.Context) bool + Repositories(ctx context.Context) ([]core.Repository, error) + Graph(ctx context.Context, repository string, opts core.GraphOptions) (core.Graph, error) +} + +// Supervision is the part of the supervisor this server reports on. +type Supervision interface { + Starts() int + LastExit() error +} + +// Status is what the agent says about itself. +type Status struct { + Version string `json:"version"` + // CoreURL is where the agent's core is listening. + CoreURL string `json:"core_url"` + // CoreUp is whether it answered just now. + CoreUp bool `json:"core_up"` + // CoreStarts counts launches, so a number that keeps climbing is a + // core that keeps dying. + CoreStarts int `json:"core_starts"` + LastExit string `json:"last_exit,omitempty"` +} + +// Server answers for the agent. +type Server struct { + reader Reader + supervisor Supervision + version string + coreURL string +} + +// New builds the agent's HTTP surface. +func New(reader Reader, supervisor Supervision, version, coreURL string) *Server { + return &Server{reader: reader, supervisor: supervisor, version: version, coreURL: coreURL} +} + +// Handler is the agent's routes. +func (s *Server) Handler() http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("GET /health", s.health) + mux.HandleFunc("GET /api/repositories", s.repositories) + mux.HandleFunc("GET /api/graph", s.graph) + return mux +} + +func (s *Server) health(w http.ResponseWriter, r *http.Request) { + status := Status{Version: s.version, CoreURL: s.coreURL} + if s.reader != nil { + status.CoreUp = s.reader.Healthy(r.Context()) + } + if s.supervisor != nil { + status.CoreStarts = s.supervisor.Starts() + if exit := s.supervisor.LastExit(); exit != nil { + status.LastExit = exit.Error() + } + } + write(w, http.StatusOK, status) +} + +func (s *Server) repositories(w http.ResponseWriter, r *http.Request) { + repositories, err := s.reader.Repositories(r.Context()) + if err != nil { + fail(w, err) + return + } + // An empty registry is an empty list, never a null, so a client can draw + // "nothing indexed yet" without special-casing the absent case. + if repositories == nil { + repositories = []core.Repository{} + } + write(w, http.StatusOK, repositories) +} + +func (s *Server) graph(w http.ResponseWriter, r *http.Request) { + repository := r.URL.Query().Get("repository") + if repository == "" { + write(w, http.StatusBadRequest, problem{Error: "name a repository"}) + return + } + limit, err := strconv.Atoi(r.URL.Query().Get("node_limit")) + if err != nil { + limit = 0 + } + graph, err := s.reader.Graph(r.Context(), repository, core.GraphOptions{ + PathPrefix: r.URL.Query().Get("path_prefix"), + IncludeTests: r.URL.Query().Get("include_tests") == "true", + NodeLimit: limit, + }) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, graph) +} + +type problem struct { + Error string `json:"error"` +} + +// fail answers with the core's own status where it gave one, so a repository +// nobody registered reads as 404 here too rather than as the agent breaking. +func fail(w http.ResponseWriter, err error) { + var coreError *core.Error + if errors.As(err, &coreError) { + write(w, coreError.StatusCode, problem{Error: coreError.Detail}) + return + } + write(w, http.StatusBadGateway, problem{Error: err.Error()}) +} + +func write(w http.ResponseWriter, status int, body any) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(body) +} + +// Serve runs the agent's HTTP surface until ctx is cancelled. +func (s *Server) Serve(ctx context.Context, address string) error { + server := &http.Server{ + Addr: address, + Handler: s.Handler(), + ReadHeaderTimeout: 10 * time.Second, + } + go func() { + <-ctx.Done() + shutdown, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) + defer cancel() + _ = server.Shutdown(shutdown) + }() + if err := server.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) { + return err + } + return nil +} diff --git a/internal/api/server_test.go b/internal/api/server_test.go new file mode 100644 index 0000000..b53fd03 --- /dev/null +++ b/internal/api/server_test.go @@ -0,0 +1,149 @@ +package api + +import ( + "context" + "encoding/json" + "errors" + "net/http" + "net/http/httptest" + "testing" + + "github.com/sourceant/agent/internal/core" +) + +type stubReader struct { + up bool + repositories []core.Repository + graph core.Graph + err error + askedFor string + askedOptions core.GraphOptions +} + +func (s *stubReader) Healthy(context.Context) bool { return s.up } + +func (s *stubReader) Repositories(context.Context) ([]core.Repository, error) { + return s.repositories, s.err +} + +func (s *stubReader) Graph(_ context.Context, repository string, opts core.GraphOptions) (core.Graph, error) { + s.askedFor = repository + s.askedOptions = opts + return s.graph, s.err +} + +type stubSupervisor struct { + starts int + exit error +} + +func (s stubSupervisor) Starts() int { return s.starts } +func (s stubSupervisor) LastExit() error { return s.exit } + +func call(t *testing.T, server *Server, target string) *httptest.ResponseRecorder { + t.Helper() + recorder := httptest.NewRecorder() + server.Handler().ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, target, nil)) + return recorder +} + +func TestHealthReportsWhetherTheCoreIsAnswering(t *testing.T) { + server := New(&stubReader{up: true}, stubSupervisor{starts: 2}, "1.2.3", "http://127.0.0.1:8931") + + response := call(t, server, "/health") + + var status Status + decode(t, response, &status) + if !status.CoreUp { + t.Error("reported a core that answered as down") + } + if status.CoreStarts != 2 { + t.Errorf("got %d starts, want 2", status.CoreStarts) + } + if status.Version != "1.2.3" || status.CoreURL != "http://127.0.0.1:8931" { + t.Errorf("got version %q at %q, want what the agent was built with", status.Version, status.CoreURL) + } +} + +func TestHealthCarriesWhyTheCoreLastDied(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{starts: 9, exit: errors.New("exit status 1")}, "dev", "") + + response := call(t, server, "/health") + + var status Status + decode(t, response, &status) + if status.LastExit != "exit status 1" { + t.Errorf("got last exit %q, want what the process said", status.LastExit) + } +} + +func TestAnEmptyRegistryIsAnEmptyListRatherThanNull(t *testing.T) { + server := New(&stubReader{repositories: nil}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/repositories") + + if got := response.Body.String(); got != "[]\n" { + t.Errorf("got %q, want an empty list", got) + } +} + +func TestGraphPassesOnWhatNarrowsADrawing(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + call(t, server, "/api/graph?repository=acme/billing&path_prefix=app/&include_tests=true&node_limit=200") + + if reader.askedFor != "acme/billing" { + t.Errorf("asked for %q, want acme/billing", reader.askedFor) + } + want := core.GraphOptions{PathPrefix: "app/", IncludeTests: true, NodeLimit: 200} + if reader.askedOptions != want { + t.Errorf("asked with %+v, want %+v", reader.askedOptions, want) + } +} + +func TestGraphRefusesToGuessWhichRepositoryIsMeant(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/graph") + + if response.Code != http.StatusBadRequest { + t.Errorf("got %d, want 400", response.Code) + } +} + +func TestAnUnregisteredRepositoryStaysA404(t *testing.T) { + reader := &stubReader{err: &core.Error{ + StatusCode: http.StatusNotFound, + Detail: "acme/nope is not registered on this machine", + }} + server := New(reader, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/graph?repository=acme/nope") + + if response.Code != http.StatusNotFound { + t.Errorf("got %d, want the core's own 404", response.Code) + } + var body problem + decode(t, response, &body) + if body.Error != "acme/nope is not registered on this machine" { + t.Errorf("got %q, want the reason the core gave", body.Error) + } +} + +func TestACoreThatCannotBeReachedIsNotTheAgentBreaking(t *testing.T) { + server := New(&stubReader{err: errors.New("connection refused")}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/repositories") + + if response.Code != http.StatusBadGateway { + t.Errorf("got %d, want 502", response.Code) + } +} + +func decode(t *testing.T, response *httptest.ResponseRecorder, into any) { + t.Helper() + if err := json.Unmarshal(response.Body.Bytes(), into); err != nil { + t.Fatalf("decoding %q: %v", response.Body.String(), err) + } +} diff --git a/internal/config/config.go b/internal/config/config.go new file mode 100644 index 0000000..1d1e1d7 --- /dev/null +++ b/internal/config/config.go @@ -0,0 +1,54 @@ +// Package config reads what the agent needs to know before it starts anything. +package config + +import ( + "fmt" + "os" + "strconv" +) + +const ( + EnvListen = "SOURCEANT_AGENT_LISTEN" + EnvCore = "SOURCEANT_CORE" + EnvPort = "SOURCEANT_CORE_PORT" +) + +// DefaultListen is loopback on purpose. The agent reads a person's working +// tree; the machine it runs on is the only audience it has. +const DefaultListen = "127.0.0.1:8930" + +// DefaultCore is the Python entry point, found on PATH. +const DefaultCore = "sourceant" + +// Config is everything the agent takes from its environment. +type Config struct { + // Listen is where the agent answers. + Listen string + // Core is the Python executable to supervise. + Core string + // CorePort is the port to start it on, zero to pick a free one. + CorePort int +} + +// FromEnvironment reads the configuration, filling in what was not set. +func FromEnvironment() (Config, error) { + cfg := Config{ + Listen: valueOr(EnvListen, DefaultListen), + Core: valueOr(EnvCore, DefaultCore), + } + if raw := os.Getenv(EnvPort); raw != "" { + port, err := strconv.Atoi(raw) + if err != nil || port < 1 || port > 65535 { + return cfg, fmt.Errorf("%s is %q, which is not a port", EnvPort, raw) + } + cfg.CorePort = port + } + return cfg, nil +} + +func valueOr(name, fallback string) string { + if value := os.Getenv(name); value != "" { + return value + } + return fallback +} diff --git a/internal/config/config_test.go b/internal/config/config_test.go new file mode 100644 index 0000000..38234e8 --- /dev/null +++ b/internal/config/config_test.go @@ -0,0 +1,55 @@ +package config + +import "testing" + +func TestItRunsWithNothingSet(t *testing.T) { + t.Setenv(EnvListen, "") + t.Setenv(EnvCore, "") + t.Setenv(EnvPort, "") + + cfg, err := FromEnvironment() + if err != nil { + t.Fatalf("reading configuration: %v", err) + } + + if cfg.Listen != DefaultListen { + t.Errorf("got %q, want %q", cfg.Listen, DefaultListen) + } + if cfg.Core != DefaultCore { + t.Errorf("got %q, want %q", cfg.Core, DefaultCore) + } + if cfg.CorePort != 0 { + t.Errorf("got port %d, want one chosen at start", cfg.CorePort) + } +} + +func TestItTakesWhatWasSet(t *testing.T) { + t.Setenv(EnvListen, "127.0.0.1:9999") + t.Setenv(EnvCore, "/opt/sourceant/bin/sourceant") + t.Setenv(EnvPort, "8123") + + cfg, err := FromEnvironment() + if err != nil { + t.Fatalf("reading configuration: %v", err) + } + + if cfg.Listen != "127.0.0.1:9999" || cfg.Core != "/opt/sourceant/bin/sourceant" || cfg.CorePort != 8123 { + t.Errorf("got %+v, want what the environment said", cfg) + } +} + +func TestAPortThatIsNotAPortIsRefusedAtStart(t *testing.T) { + t.Setenv(EnvPort, "eighty") + + if _, err := FromEnvironment(); err == nil { + t.Fatal("accepted a port that is not a number") + } +} + +func TestAPortOutsideTheRangeIsRefusedAtStart(t *testing.T) { + t.Setenv(EnvPort, "70000") + + if _, err := FromEnvironment(); err == nil { + t.Fatal("accepted a port no socket can bind") + } +} diff --git a/internal/core/client.go b/internal/core/client.go new file mode 100644 index 0000000..a36a150 --- /dev/null +++ b/internal/core/client.go @@ -0,0 +1,186 @@ +// Package core reads the Python indexer's HTTP surface. +// +// The agent never parses code. Everything it knows about a repository it got +// from here, so that one set of grammars and one graph shape serve every +// client. +package core + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// Envelope is the shape every core route answers in. +type envelope[T any] struct { + Status string `json:"status"` + Message string `json:"message"` + Data T `json:"data"` +} + +// Repository is one repository registered on this machine. +type Repository struct { + Name string `json:"name"` + Path string `json:"path"` +} + +// Node is one file, import or symbol in a repository's graph. +// +// Kind and Labels are not the same question. A Python file's kind is "python" +// and a Python function's kind is "function", so kind alone cannot tell them +// apart; labels can. A drawing colours by one and reads by the other. +type Node struct { + ID string `json:"id"` + Name string `json:"name"` + Kind string `json:"kind"` + Labels []string `json:"labels"` + Path string `json:"path"` +} + +// Link is a typed edge between two nodes. +type Link struct { + Source string `json:"source"` + Target string `json:"target"` + Type string `json:"type"` +} + +// Graph is a whole scope, as the index drew it. +// +// Truncated says the scope was larger than the cap asked for, so what came back +// is a part of the repository and not the repository. +type Graph struct { + Nodes []Node `json:"nodes"` + Links []Link `json:"links"` + Truncated bool `json:"truncated"` +} + +// Error is a non-2xx answer from the core, carrying what it said. +type Error struct { + StatusCode int + Detail string +} + +func (e *Error) Error() string { + if e.Detail == "" { + return fmt.Sprintf("sourceant core returned %d", e.StatusCode) + } + return fmt.Sprintf("sourceant core returned %d: %s", e.StatusCode, e.Detail) +} + +// NotFound reports whether the core had no such repository registered. +func (e *Error) NotFound() bool { return e.StatusCode == http.StatusNotFound } + +// Client talks to one core instance. +type Client struct { + baseURL string + http *http.Client +} + +// New builds a client for the core serving at baseURL. +func New(baseURL string, timeout time.Duration) *Client { + return &Client{ + baseURL: strings.TrimRight(baseURL, "/"), + http: &http.Client{Timeout: timeout}, + } +} + +// BaseURL is the core this client talks to. +func (c *Client) BaseURL() string { return c.baseURL } + +// Healthy reports whether the core is up and answering. +func (c *Client) Healthy(ctx context.Context) bool { + req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL+"/health", nil) + if err != nil { + return false + } + resp, err := c.http.Do(req) + if err != nil { + return false + } + defer func() { _ = resp.Body.Close() }() + _, _ = io.Copy(io.Discard, resp.Body) + return resp.StatusCode >= 200 && resp.StatusCode < 300 +} + +// Repositories lists what has been registered on this machine. +func (c *Client) Repositories(ctx context.Context) ([]Repository, error) { + return get[[]Repository](ctx, c, "/api/code/repositories", nil) +} + +// GraphOptions narrows what a drawing covers. +type GraphOptions struct { + PathPrefix string + IncludeTests bool + NodeLimit int +} + +// Graph reads one repository's whole scope. +func (c *Client) Graph(ctx context.Context, repository string, opts GraphOptions) (Graph, error) { + query := url.Values{"repository": {repository}} + if opts.PathPrefix != "" { + query.Set("path_prefix", opts.PathPrefix) + } + if opts.IncludeTests { + query.Set("include_tests", "true") + } + if opts.NodeLimit > 0 { + query.Set("node_limit", strconv.Itoa(opts.NodeLimit)) + } + return get[Graph](ctx, c, "/api/code/graph", query) +} + +func get[T any](ctx context.Context, c *Client, path string, query url.Values) (T, error) { + var zero T + target := c.baseURL + path + if len(query) > 0 { + target += "?" + query.Encode() + } + req, err := http.NewRequestWithContext(ctx, http.MethodGet, target, nil) + if err != nil { + return zero, err + } + req.Header.Set("Accept", "application/json") + + resp, err := c.http.Do(req) + if err != nil { + return zero, err + } + defer func() { _ = resp.Body.Close() }() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return zero, err + } + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return zero, &Error{StatusCode: resp.StatusCode, Detail: detail(body)} + } + + var parsed envelope[T] + if err := json.Unmarshal(body, &parsed); err != nil { + return zero, fmt.Errorf("sourceant core answered %s with something other than JSON: %w", path, err) + } + return parsed.Data, nil +} + +// detail pulls the reason out of an error body, falling back to the body itself. +func detail(body []byte) string { + var parsed struct { + Detail string `json:"detail"` + Error string `json:"error"` + } + if err := json.Unmarshal(body, &parsed); err == nil { + if parsed.Detail != "" { + return parsed.Detail + } + if parsed.Error != "" { + return parsed.Error + } + } + return strings.TrimSpace(string(body)) +} diff --git a/internal/core/client_test.go b/internal/core/client_test.go new file mode 100644 index 0000000..77cd4a4 --- /dev/null +++ b/internal/core/client_test.go @@ -0,0 +1,158 @@ +package core + +import ( + "context" + "errors" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "slices" + "strings" + "testing" + "time" +) + +// The fixtures are answers captured from a running core, not written here, so a +// change to what it serves fails these rather than passing against our guess. +func fixture(t *testing.T, name string) []byte { + t.Helper() + data, err := os.ReadFile(filepath.Join("testdata", name)) + if err != nil { + t.Fatalf("reading fixture: %v", err) + } + return data +} + +func serving(t *testing.T, routes map[string]func(http.ResponseWriter, *http.Request)) *Client { + t.Helper() + mux := http.NewServeMux() + for pattern, handler := range routes { + mux.HandleFunc(pattern, handler) + } + server := httptest.NewServer(mux) + t.Cleanup(server.Close) + return New(server.URL, 5*time.Second) +} + +func TestRepositoriesReadsWhatTheCoreRegistered(t *testing.T) { + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/repositories": func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write(fixture(t, "repositories.json")) + }, + }) + + repositories, err := client.Repositories(context.Background()) + if err != nil { + t.Fatalf("listing repositories: %v", err) + } + + if len(repositories) != 1 { + t.Fatalf("got %d repositories, want 1", len(repositories)) + } + if repositories[0].Name != "local/sourceant" { + t.Errorf("got name %q, want local/sourceant", repositories[0].Name) + } + if repositories[0].Path == "" { + t.Error("got an empty path, want the directory the core registered") + } +} + +func TestGraphKeepsWhatTellsAFileFromAFunction(t *testing.T) { + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/graph": func(w http.ResponseWriter, _ *http.Request) { + _, _ = w.Write(fixture(t, "graph.json")) + }, + }) + + graph, err := client.Graph(context.Background(), "local/sourceant", GraphOptions{}) + if err != nil { + t.Fatalf("reading graph: %v", err) + } + + if len(graph.Nodes) == 0 || len(graph.Links) == 0 { + t.Fatalf("got %d nodes and %d links, want both", len(graph.Nodes), len(graph.Links)) + } + if graph.Truncated { + t.Error("got a truncated graph, want the whole captured scope") + } + + var file, symbol *Node + for i := range graph.Nodes { + switch { + case file == nil && slices.Contains(graph.Nodes[i].Labels, "File"): + file = &graph.Nodes[i] + case symbol == nil && graph.Nodes[i].Kind == "function": + symbol = &graph.Nodes[i] + } + } + if file == nil || symbol == nil { + t.Fatal("the captured graph holds no file and function to tell apart") + } + if file.Kind != "python" { + t.Errorf("got file kind %q, want the language", file.Kind) + } + if file.Path == "" || symbol.Path == "" { + t.Error("got a node with no path, want where the code sits") + } +} + +func TestGraphPassesOnWhatNarrowsADrawing(t *testing.T) { + var asked string + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/graph": func(w http.ResponseWriter, r *http.Request) { + asked = r.URL.RawQuery + _, _ = w.Write(fixture(t, "graph.json")) + }, + }) + + _, err := client.Graph(context.Background(), "local/sourceant", GraphOptions{ + PathPrefix: "src/config/", + IncludeTests: true, + NodeLimit: 120, + }) + if err != nil { + t.Fatalf("reading graph: %v", err) + } + + for _, want := range []string{ + "repository=local%2Fsourceant", + "path_prefix=src%2Fconfig%2F", + "include_tests=true", + "node_limit=120", + } { + if !strings.Contains(asked, want) { + t.Errorf("query %q is missing %q", asked, want) + } + } +} + +func TestAnUnregisteredRepositoryIsReportedAsSuch(t *testing.T) { + client := serving(t, map[string]func(http.ResponseWriter, *http.Request){ + "/api/code/graph": func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusNotFound) + _, _ = w.Write(fixture(t, "unknown_repository.json")) + }, + }) + + _, err := client.Graph(context.Background(), "acme/nope", GraphOptions{}) + + var coreError *Error + if !errors.As(err, &coreError) { + t.Fatalf("got %v, want a core error", err) + } + if !coreError.NotFound() { + t.Errorf("got status %d, want 404", coreError.StatusCode) + } + if !strings.Contains(coreError.Error(), "not registered on this machine") { + t.Errorf("got %q, want the reason the core gave", coreError.Error()) + } +} + +func TestHealthyIsFalseWhenTheCoreIsNotThere(t *testing.T) { + client := New("http://127.0.0.1:1", 200*time.Millisecond) + + if client.Healthy(context.Background()) { + t.Error("reported a core that is not listening as healthy") + } +} diff --git a/internal/core/testdata/graph.json b/internal/core/testdata/graph.json new file mode 100644 index 0000000..7c70211 --- /dev/null +++ b/internal/core/testdata/graph.json @@ -0,0 +1 @@ +{"status":"success","message":"Request was successful","data":{"nodes":[{"id":"file:src/config/__init__.py","name":"__init__.py","kind":"python","labels":["File"],"path":"src/config/__init__.py"},{"id":"file:src/config/db.py","name":"db.py","kind":"python","labels":["File"],"path":"src/config/db.py"},{"id":"file:src/config/paths.py","name":"paths.py","kind":"python","labels":["File"],"path":"src/config/paths.py"},{"id":"file:src/config/settings.py","name":"settings.py","kind":"python","labels":["File"],"path":"src/config/settings.py"},{"id":"import:src/config/db.py:0","name":"from sqlmodel import create_engine, Session","kind":"import","labels":["Import"],"path":"src/config/db.py"},{"id":"import:src/config/db.py:1","name":"from src.utils.logger import logger","kind":"import","labels":["Import"],"path":"src/config/db.py"},{"id":"import:src/config/db.py:2","name":"from src.config.settings import DATABASE_URL, STATELESS_MODE, DEBUG_MODE","kind":"import","labels":["Import"],"path":"src/config/db.py"},{"id":"import:src/config/paths.py:0","name":"import os","kind":"import","labels":["Import"],"path":"src/config/paths.py"},{"id":"import:src/config/paths.py:1","name":"import secrets","kind":"import","labels":["Import"],"path":"src/config/paths.py"},{"id":"import:src/config/paths.py:2","name":"from pathlib import Path","kind":"import","labels":["Import"],"path":"src/config/paths.py"},{"id":"import:src/config/settings.py:0","name":"import os","kind":"import","labels":["Import"],"path":"src/config/settings.py"},{"id":"import:src/config/settings.py:1","name":"from dotenv import load_dotenv","kind":"import","labels":["Import"],"path":"src/config/settings.py"},{"id":"import:src/config/settings.py:2","name":"from src.config.paths import default_database_url","kind":"import","labels":["Import"],"path":"src/config/settings.py"},{"id":"symbol:src/config/db.py:get_engine:7:0","name":"get_engine","kind":"function","labels":["Function"],"path":"src/config/db.py"},{"id":"symbol:src/config/db.py:get_session:30:1","name":"get_session","kind":"function","labels":["Function"],"path":"src/config/db.py"},{"id":"symbol:src/config/paths.py:data_dir:10:0","name":"data_dir","kind":"function","labels":["Function"],"path":"src/config/paths.py"},{"id":"symbol:src/config/paths.py:default_database_url:26:2","name":"default_database_url","kind":"function","labels":["Function"],"path":"src/config/paths.py"},{"id":"symbol:src/config/paths.py:ensure_data_dir:20:1","name":"ensure_data_dir","kind":"function","labels":["Function"],"path":"src/config/paths.py"},{"id":"symbol:src/config/paths.py:local_jwt_secret:30:3","name":"local_jwt_secret","kind":"function","labels":["Function"],"path":"src/config/paths.py"}],"links":[{"source":"file:src/config/db.py","target":"symbol:src/config/db.py:get_engine:7:0","type":"defines"},{"source":"file:src/config/db.py","target":"symbol:src/config/db.py:get_session:30:1","type":"defines"},{"source":"file:src/config/paths.py","target":"symbol:src/config/paths.py:data_dir:10:0","type":"defines"},{"source":"file:src/config/paths.py","target":"symbol:src/config/paths.py:default_database_url:26:2","type":"defines"},{"source":"file:src/config/paths.py","target":"symbol:src/config/paths.py:ensure_data_dir:20:1","type":"defines"},{"source":"file:src/config/paths.py","target":"symbol:src/config/paths.py:local_jwt_secret:30:3","type":"defines"},{"source":"file:src/config/db.py","target":"import:src/config/db.py:0","type":"imports"},{"source":"file:src/config/db.py","target":"import:src/config/db.py:1","type":"imports"},{"source":"file:src/config/db.py","target":"import:src/config/db.py:2","type":"imports"},{"source":"file:src/config/paths.py","target":"import:src/config/paths.py:0","type":"imports"},{"source":"file:src/config/paths.py","target":"import:src/config/paths.py:1","type":"imports"},{"source":"file:src/config/paths.py","target":"import:src/config/paths.py:2","type":"imports"},{"source":"file:src/config/settings.py","target":"import:src/config/settings.py:0","type":"imports"},{"source":"file:src/config/settings.py","target":"import:src/config/settings.py:1","type":"imports"},{"source":"file:src/config/settings.py","target":"import:src/config/settings.py:2","type":"imports"}],"truncated":false}} \ No newline at end of file diff --git a/internal/core/testdata/repositories.json b/internal/core/testdata/repositories.json new file mode 100644 index 0000000..7d6fa53 --- /dev/null +++ b/internal/core/testdata/repositories.json @@ -0,0 +1 @@ +{"status":"success","message":"Request was successful","data":[{"name":"local/sourceant","path":"/app"}]} \ No newline at end of file diff --git a/internal/core/testdata/unknown_repository.json b/internal/core/testdata/unknown_repository.json new file mode 100644 index 0000000..5304dee --- /dev/null +++ b/internal/core/testdata/unknown_repository.json @@ -0,0 +1 @@ +{"detail":"acme/nope is not registered on this machine"} \ No newline at end of file diff --git a/internal/supervise/process_other.go b/internal/supervise/process_other.go new file mode 100644 index 0000000..9bcc377 --- /dev/null +++ b/internal/supervise/process_other.go @@ -0,0 +1,13 @@ +//go:build !unix + +package supervise + +import "os/exec" + +// Process groups are a Unix idea. Elsewhere the supervisor reaches the process +// it started and no further, which is what the standard library offers. +func isolate(*exec.Cmd) {} + +func askToStop(command *exec.Cmd) error { return command.Process.Kill() } + +func forceStop(command *exec.Cmd) error { return command.Process.Kill() } diff --git a/internal/supervise/process_unix.go b/internal/supervise/process_unix.go new file mode 100644 index 0000000..cc1b121 --- /dev/null +++ b/internal/supervise/process_unix.go @@ -0,0 +1,30 @@ +//go:build unix + +package supervise + +import ( + "os/exec" + "syscall" +) + +// isolate puts the process in a group of its own. +// +// Without it, stopping the core reaches only the process we started. Anything +// it started stays running, holding the port the next start wants. +func isolate(command *exec.Cmd) { + command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} +} + +// signal sends sig to the whole group, falling back to the process alone when +// there is no group to address. +func signal(command *exec.Cmd, sig syscall.Signal) error { + pid := command.Process.Pid + if group, err := syscall.Getpgid(pid); err == nil { + return syscall.Kill(-group, sig) + } + return syscall.Kill(pid, sig) +} + +func askToStop(command *exec.Cmd) error { return signal(command, syscall.SIGTERM) } + +func forceStop(command *exec.Cmd) error { return signal(command, syscall.SIGKILL) } diff --git a/internal/supervise/supervisor.go b/internal/supervise/supervisor.go new file mode 100644 index 0000000..6543ced --- /dev/null +++ b/internal/supervise/supervisor.go @@ -0,0 +1,266 @@ +// Package supervise keeps the Python core running. +// +// The core is a separate process because the grammars and the graph live there. +// The agent's job is to make that process something a person never has to think +// about: start it, notice when it dies, start it again. +package supervise + +import ( + "context" + "errors" + "fmt" + "io" + "net" + "os/exec" + "sync" + "time" +) + +// Backoff is how long to wait before restarting, and how far that grows. +type Backoff struct { + First time.Duration + Max time.Duration +} + +func (b Backoff) after(previous time.Duration) time.Duration { + if previous == 0 { + return b.First + } + doubled := previous * 2 + if doubled > b.Max { + return b.Max + } + return doubled +} + +// Options describe the process to keep alive. +type Options struct { + // Name and Args are the command. Name is looked up on PATH. + Name string + Args []string + // Dir is where it runs, empty for the agent's own directory. + Dir string + // Env is the whole environment, empty to inherit the agent's. + Env []string + // Ready reports whether the process is up and answering. It is polled + // after each start until it says yes or ReadyWithin passes. + Ready func(context.Context) bool + // ReadyWithin bounds that wait, and PollEvery is how often it is asked. + ReadyWithin time.Duration + PollEvery time.Duration + // StopWithin is how long a process gets to stop when asked, before it is + // killed. + StopWithin time.Duration + // Backoff paces restarts. + Backoff Backoff + // Output receives the process's stdout and stderr, nil to discard. + Output io.Writer +} + +func (o Options) withDefaults() Options { + if o.ReadyWithin == 0 { + o.ReadyWithin = 30 * time.Second + } + if o.PollEvery == 0 { + o.PollEvery = 100 * time.Millisecond + } + if o.StopWithin == 0 { + o.StopWithin = 5 * time.Second + } + if o.Backoff.First == 0 { + o.Backoff.First = 250 * time.Millisecond + } + if o.Backoff.Max == 0 { + o.Backoff.Max = 30 * time.Second + } + return o +} + +// ErrNotReady says the process started but never began answering. +var ErrNotReady = errors.New("the process started but never became ready") + +// process is one launch, and the single place its exit is waited for. +// +// exec.Cmd is not safe to Wait on from one goroutine while another reads +// ProcessState, so exactly one goroutine calls Wait and everybody else learns +// what happened by waiting on done. +type process struct { + cmd *exec.Cmd + err error + done chan struct{} +} + +// wait is the only caller of Wait. Writing err before closing done is what lets +// exit read it without a lock. +func (p *process) wait() { + p.err = p.cmd.Wait() + close(p.done) +} + +// exit blocks until the process has gone, and says why. +func (p *process) exit() error { + <-p.done + return p.err +} + +// Supervisor runs one process and restarts it for as long as it is asked to. +type Supervisor struct { + options Options + + mu sync.Mutex + starts int + lastExit error +} + +// New builds a supervisor for the process described by options. +func New(options Options) *Supervisor { + return &Supervisor{options: options.withDefaults()} +} + +// Starts is how many times the process has been launched, restarts included. +func (s *Supervisor) Starts() int { + s.mu.Lock() + defer s.mu.Unlock() + return s.starts +} + +// LastExit is why the process last stopped, nil if it never has. +func (s *Supervisor) LastExit() error { + s.mu.Lock() + defer s.mu.Unlock() + return s.lastExit +} + +// Run starts the process and keeps it running until ctx is cancelled. +// +// It returns once the process is stopped and no further restart is wanted, so a +// caller runs it in its own goroutine. A cancelled context is not an error: it +// is how a caller says stop. +func (s *Supervisor) Run(ctx context.Context) error { + var wait time.Duration + for { + if ctx.Err() != nil { + return nil + } + + started, err := s.start(ctx) + if err != nil { + return err + } + + if s.options.Ready != nil && !s.waitReady(ctx, started) { + s.terminate(started) + s.record(started.exit()) + if ctx.Err() != nil { + return nil + } + return fmt.Errorf("%w within %s", ErrNotReady, s.options.ReadyWithin) + } + + s.record(started.exit()) + if ctx.Err() != nil { + return nil + } + + wait = s.options.Backoff.after(wait) + select { + case <-ctx.Done(): + return nil + case <-time.After(wait): + } + } +} + +func (s *Supervisor) start(ctx context.Context) (*process, error) { + command := exec.Command(s.options.Name, s.options.Args...) + command.Dir = s.options.Dir + command.Env = s.options.Env + command.Stdout = s.options.Output + command.Stderr = s.options.Output + isolate(command) + + if err := command.Start(); err != nil { + return nil, fmt.Errorf("starting %s: %w", s.options.Name, err) + } + + started := &process{cmd: command, done: make(chan struct{})} + go started.wait() + + s.mu.Lock() + s.starts++ + s.mu.Unlock() + + // Stopping the process when the context ends is what makes the wait + // return, so a cancelled Run does not leave the core running behind it. + go func() { + select { + case <-ctx.Done(): + s.terminate(started) + case <-started.done: + } + }() + + return started, nil +} + +// waitReady polls until the process answers, it exits, or the deadline passes. +func (s *Supervisor) waitReady(ctx context.Context, started *process) bool { + deadline := time.Now().Add(s.options.ReadyWithin) + ticker := time.NewTicker(s.options.PollEvery) + defer ticker.Stop() + + for { + if s.options.Ready(ctx) { + return true + } + if time.Now().After(deadline) { + return false + } + select { + case <-started.done: + return false + case <-ctx.Done(): + return false + case <-ticker.C: + } + } +} + +// terminate asks the process to stop, then insists. +// +// A core killed outright loses whatever it was writing, so it is asked first +// and only killed if it does not go. Both signals address the process group, +// because a core that started a worker leaves it holding the port otherwise. +func (s *Supervisor) terminate(started *process) { + if started == nil || started.cmd.Process == nil { + return + } + if err := askToStop(started.cmd); err != nil { + return + } + select { + case <-started.done: + case <-time.After(s.options.StopWithin): + _ = forceStop(started.cmd) + } +} + +func (s *Supervisor) record(exit error) { + s.mu.Lock() + s.lastExit = exit + s.mu.Unlock() +} + +// FreePort asks the operating system for a port nobody is using. +// +// It is racy by nature: the port is free when asked and could be taken before +// it is bound. Nothing better exists without binding it here and handing the +// listener over, which a child process cannot accept. +func FreePort() (int, error) { + listener, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + return 0, err + } + defer func() { _ = listener.Close() }() + return listener.Addr().(*net.TCPAddr).Port, nil +} diff --git a/internal/supervise/supervisor_test.go b/internal/supervise/supervisor_test.go new file mode 100644 index 0000000..e46618a --- /dev/null +++ b/internal/supervise/supervisor_test.go @@ -0,0 +1,166 @@ +package supervise + +import ( + "context" + "errors" + "os" + "path/filepath" + "sync/atomic" + "testing" + "time" +) + +// script writes an executable shell script and returns the command to run it. +func script(t *testing.T, body string) (string, []string) { + t.Helper() + path := filepath.Join(t.TempDir(), "process.sh") + if err := os.WriteFile(path, []byte("#!/bin/sh\n"+body), 0o755); err != nil { + t.Fatalf("writing script: %v", err) + } + return "/bin/sh", []string{path} +} + +func TestItRestartsAProcessThatDies(t *testing.T) { + name, args := script(t, "exit 1\n") + supervisor := New(Options{ + Name: name, + Args: args, + Backoff: Backoff{First: time.Millisecond, Max: 2 * time.Millisecond}, + }) + + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + go func() { done <- supervisor.Run(ctx) }() + + waitFor(t, func() bool { return supervisor.Starts() >= 3 }) + cancel() + + if err := <-done; err != nil { + t.Fatalf("running: %v", err) + } + if supervisor.LastExit() == nil { + t.Error("a process that exited 1 was recorded as exiting cleanly") + } +} + +func TestItLeavesNothingRunningWhenItIsToldToStop(t *testing.T) { + marker := filepath.Join(t.TempDir(), "alive") + name, args := script(t, "touch "+marker+"\nwhile true; do sleep 0.05; done\n") + supervisor := New(Options{Name: name, Args: args}) + + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + go func() { done <- supervisor.Run(ctx) }() + + waitFor(t, func() bool { + _, err := os.Stat(marker) + return err == nil + }) + cancel() + + select { + case err := <-done: + if err != nil { + t.Fatalf("running: %v", err) + } + case <-time.After(5 * time.Second): + t.Fatal("cancelling left the process running") + } +} + +// A core that started a worker leaves it holding the port unless the whole +// group is stopped, so this drives a process that starts a child of its own. +func TestItLeavesNoGrandchildRunningEither(t *testing.T) { + dir := t.TempDir() + marker := filepath.Join(dir, "child-alive") + child := filepath.Join(dir, "child.sh") + if err := os.WriteFile(child, []byte( + "#!/bin/sh\nwhile true; do touch "+marker+"; sleep 0.02; done\n"), 0o755); err != nil { + t.Fatalf("writing child script: %v", err) + } + name, args := script(t, child+" &\nwhile true; do sleep 0.05; done\n") + supervisor := New(Options{Name: name, Args: args, StopWithin: 200 * time.Millisecond}) + + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + go func() { done <- supervisor.Run(ctx) }() + + waitFor(t, func() bool { + _, err := os.Stat(marker) + return err == nil + }) + cancel() + <-done + + // The child touches the marker every 20ms while it lives. Remove it, and if + // it comes back the child outlived the process that started it. + if err := os.Remove(marker); err != nil { + t.Fatalf("removing marker: %v", err) + } + time.Sleep(300 * time.Millisecond) + if _, err := os.Stat(marker); err == nil { + t.Error("a grandchild was still running after the supervisor stopped") + } +} + +func TestItWaitsForTheProcessToAnswerBeforeCallingItStarted(t *testing.T) { + name, args := script(t, "while true; do sleep 0.05; done\n") + var polls atomic.Int32 + supervisor := New(Options{ + Name: name, + Args: args, + Ready: func(context.Context) bool { + return polls.Add(1) >= 3 + }, + PollEvery: time.Millisecond, + ReadyWithin: 5 * time.Second, + }) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + go func() { _ = supervisor.Run(ctx) }() + + waitFor(t, func() bool { return polls.Load() >= 3 }) + if supervisor.Starts() != 1 { + t.Errorf("started %d times while waiting to be ready, want 1", supervisor.Starts()) + } +} + +func TestAProcessThatNeverAnswersIsReportedRatherThanRestartedForever(t *testing.T) { + name, args := script(t, "while true; do sleep 0.05; done\n") + supervisor := New(Options{ + Name: name, + Args: args, + Ready: func(context.Context) bool { return false }, + PollEvery: time.Millisecond, + ReadyWithin: 50 * time.Millisecond, + }) + + err := supervisor.Run(context.Background()) + + if !errors.Is(err, ErrNotReady) { + t.Fatalf("got %v, want ErrNotReady", err) + } +} + +func TestFreePortGivesAPortNobodyIsUsing(t *testing.T) { + port, err := FreePort() + if err != nil { + t.Fatalf("asking for a port: %v", err) + } + if port <= 0 || port > 65535 { + t.Errorf("got port %d, want a usable one", port) + } +} + +func waitFor(t *testing.T, condition func() bool) { + t.Helper() + deadline := time.Now().Add(5 * time.Second) + for time.Now().Before(deadline) { + if condition() { + return + } + time.Sleep(2 * time.Millisecond) + } + t.Fatal("condition never held") +} From 9699499adea9e8b5941c08be2baad69d35fe756c Mon Sep 17 00:00:00 2001 From: nfebe Date: Fri, 28 Aug 2026 21:49:04 +0100 Subject: [PATCH 02/27] feat: Draw the local graph in a browser The agent now serves a graph view alongside its API. Assets are embedded in the binary, so it works with nothing to download and cannot drift from the agent serving it. What opens is the repository's shape: its folders and its files, every one named. Symbols, imports and the test suite are there to be asked for, because a repository's every function is a texture rather than a picture. Four layouts, a search that dims everything it does not match, and a panel for whatever is clicked. The index stores no folders. Files hold their symbols and their imports and nothing holds the files, so drawing the index as stored scatters a repository into one island per file. The folders here are read out of the paths the index already carries, and are marked as this view's arrangement rather than as something that was found. Colours and tokens are the shared ones, so every surface reads as one product. --- README.md | 4 + internal/api/server.go | 2 + internal/ui/assets/app.js | 363 ++++++++++++++++++ internal/ui/assets/favicon.svg | 1 + internal/ui/assets/index.html | 71 ++++ internal/ui/assets/styles.css | 295 ++++++++++++++ internal/ui/assets/vendor/force-graph.LICENSE | 21 + internal/ui/assets/vendor/force-graph.min.js | 5 + internal/ui/ui.go | 33 ++ internal/ui/ui_test.go | 52 +++ 10 files changed, 847 insertions(+) create mode 100644 internal/ui/assets/app.js create mode 100644 internal/ui/assets/favicon.svg create mode 100644 internal/ui/assets/index.html create mode 100644 internal/ui/assets/styles.css create mode 100644 internal/ui/assets/vendor/force-graph.LICENSE create mode 100644 internal/ui/assets/vendor/force-graph.min.js create mode 100644 internal/ui/ui.go create mode 100644 internal/ui/ui_test.go diff --git a/README.md b/README.md index e59314d..a8e08e9 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ It never parses code. The grammars and the graph shape live in the Python core, Starts the core on a free port and waits for it to answer. Restarts it when it dies, backing off as failures repeat. Serves its own HTTP surface on `127.0.0.1:8930`, where `/health` reports whether the core is up and how many times it has been started, and `/api/repositories` and `/api/graph` read the index. +It also serves the graph view at `/`. The assets are embedded in the binary, so the view works with no network and cannot drift from the agent serving it. + +What opens is the repository's shape: folders and files. Symbols, imports and the test suite are there to be asked for, because a repository's every function is a texture rather than a picture. The folder nodes are this view's arrangement, read out of the paths the index already carries; the index stores no folders of its own. + Loopback is the default because the agent reads a working tree. The machine it runs on is the only audience it has. ## Running it diff --git a/internal/api/server.go b/internal/api/server.go index 2bc6584..92d56e6 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -15,6 +15,7 @@ import ( "time" "github.com/sourceant/agent/internal/core" + "github.com/sourceant/agent/internal/ui" ) // Reader is the part of the core client this server needs. @@ -62,6 +63,7 @@ func (s *Server) Handler() http.Handler { mux.HandleFunc("GET /health", s.health) mux.HandleFunc("GET /api/repositories", s.repositories) mux.HandleFunc("GET /api/graph", s.graph) + mux.Handle("GET /", ui.Handler()) return mux } diff --git a/internal/ui/assets/app.js b/internal/ui/assets/app.js new file mode 100644 index 0000000..8be461b --- /dev/null +++ b/internal/ui/assets/app.js @@ -0,0 +1,363 @@ +/* The local code graph. + * + * Colours are concrete hex rather than the CSS custom properties above, + * because the graph draws to a canvas and cannot resolve them. They are the + * dashboard's palette, mapped onto what a code graph holds. + */ +const COLOURS = { + repository: '#E20C18', + directory: '#9560f0', + file: '#3b82f6', + import: '#f59e0b', + function: '#4ade80', + method: '#2dd4bf', + class: '#c084fc', + struct: '#22d3ee', + interface: '#22d3ee', + enum: '#22d3ee', +} +const OTHER = '#a1a1aa' + +const LAYOUTS = [ + { id: 'force', label: 'Force', dag: null }, + { id: 'tree', label: 'Tree', dag: 'td' }, + { id: 'radial', label: 'Radial', dag: 'radialout' }, + { id: 'sideways', label: 'Sideways', dag: 'lr' }, +] + +/* A file's kind is its language and a symbol's kind is what the parser called + * it, so kind alone cannot tell a Python file from a Python function. The + * labels the index carries can, which is what this reads. */ +function groupOf(node) { + if (node.synthetic) return node.synthetic + const labels = node.labels || [] + if (labels.includes('File')) return 'file' + if (labels.includes('Import')) return 'import' + return (node.kind || '').toLowerCase() +} + +/* Files hold their symbols and their imports, and nothing holds the files, so + * drawing the index as it is stored scatters a repository into one island per + * file. The directories are already in every path; this reads them out and + * hangs the files off them, which is the difference between a repository and + * confetti. The nodes it adds are marked synthetic: they are how this view + * arranges what the index found, not something the index found. */ +function withFolders(data, repository) { + const root = { id: 'tree:', name: repository, kind: 'repository', synthetic: 'repository', path: '' } + const folders = new Map([['', root]]) + const links = [...data.links] + + const folderFor = (path) => { + if (folders.has(path)) return folders.get(path) + const cut = path.lastIndexOf('/', path.length - 2) + const parentPath = cut === -1 ? '' : path.slice(0, cut + 1) + const parent = folderFor(parentPath) + const folder = { + id: `tree:${path}`, + name: path.slice(parentPath.length).replace(/\/$/, ''), + kind: 'directory', + synthetic: 'directory', + path, + } + folders.set(path, folder) + links.push({ source: parent.id, target: folder.id, type: 'contains' }) + return folder + } + + for (const node of data.nodes) { + if (groupOf(node) !== 'file' || !node.path) continue + const cut = node.path.lastIndexOf('/') + const folder = folderFor(cut === -1 ? '' : node.path.slice(0, cut + 1)) + links.push({ source: folder.id, target: node.id, type: 'contains' }) + } + + return { nodes: [...folders.values(), ...data.nodes], links } +} + +function colourOf(node) { + return COLOURS[groupOf(node)] || OTHER +} + +function shortName(name) { + return name && name.length > 30 ? `${name.slice(0, 29)}…` : name +} + +const element = { + canvas: document.getElementById('canvas'), + overlay: document.getElementById('overlay'), + repository: document.getElementById('repository'), + layouts: document.getElementById('layouts'), + search: document.getElementById('search'), + tests: document.getElementById('tests'), + imports: document.getElementById('imports'), + folders: document.getElementById('folders'), + symbols: document.getElementById('symbols'), + legend: document.getElementById('legend'), + tally: document.getElementById('tally'), + truncated: document.getElementById('truncated'), + theme: document.getElementById('theme'), + details: document.getElementById('details'), + detailsName: document.getElementById('details-name'), + detailsKind: document.getElementById('details-kind'), + detailsPath: document.getElementById('details-path'), + detailsLinks: document.getElementById('details-links'), + closeDetails: document.getElementById('close-details'), +} + +const state = { + graph: null, + loaded: { nodes: [], links: [], truncated: false }, + layout: 'force', + matching: null, + selected: null, + labelled: false, +} + +function canvasColour(name) { + return getComputedStyle(document.documentElement).getPropertyValue(name).trim() +} + +function say(message) { + element.overlay.innerHTML = message + element.overlay.hidden = false +} + +async function read(path) { + const response = await fetch(path) + if (!response.ok) { + const body = await response.json().catch(() => ({})) + throw new Error(body.error || `the agent answered ${response.status}`) + } + return response.json() +} + +/* What is drawn, after the toggles and before the layout. Dropping a node has + * to drop the links that reach it, or the renderer is handed an edge with no + * end and stops drawing entirely. */ +/* A repository's every function is a texture rather than a picture, so what + * opens is its shape: folders and files. Symbols and imports are there to be + * asked for. */ +function wanted(node) { + const group = groupOf(node) + if (group === 'import') return element.imports.checked + if (group === 'file') return true + return element.symbols.checked +} + +function visible() { + const nodes = state.loaded.nodes.filter(wanted) + const kept = new Set(nodes.map((node) => node.id)) + const links = state.loaded.links + .filter((link) => kept.has(link.source.id || link.source) && kept.has(link.target.id || link.target)) + .map((link) => ({ source: link.source.id || link.source, target: link.target.id || link.target, type: link.type })) + + const data = { nodes: nodes.map((node) => ({ ...node })), links } + return element.folders.checked ? withFolders(data, element.repository.value) : data +} + +function draw() { + const data = visible() + const dag = LAYOUTS.find((layout) => layout.id === state.layout).dag + + if (!state.graph) { + state.graph = new ForceGraph(element.canvas) + state.graph + .backgroundColor('rgba(0,0,0,0)') + .nodeRelSize(4) + .nodeLabel((node) => `${node.name} · ${node.kind}`) + .nodeCanvasObject(paintNode) + .nodePointerAreaPaint((node, colour, ctx) => { + ctx.fillStyle = colour + ctx.beginPath() + ctx.arc(node.x, node.y, 7, 0, 2 * Math.PI) + ctx.fill() + }) + .linkColor(() => canvasColour('--canvas-link')) + .linkWidth(0.7) + .linkDirectionalArrowLength(3) + .linkDirectionalArrowRelPos(1) + .onNodeClick(select) + .onBackgroundClick(() => select(null)) + state.graph.onEngineStop(() => state.graph.zoomToFit(400, 40)) + } + + // A drawing small enough to read gets its names at any zoom. A large one + // would be soup, so there the names wait until something is zoomed into. + state.labelled = data.nodes.length <= 400 + + state.graph + .dagMode(dag) + .dagLevelDistance(dag ? 90 : 40) + .onDagError(() => undefined) + .width(element.canvas.clientWidth) + .height(element.canvas.clientHeight) + .graphData(data) + + element.tally.textContent = `${data.nodes.length.toLocaleString()} nodes · ${data.links.length.toLocaleString()} links` + element.overlay.hidden = data.nodes.length > 0 + if (data.nodes.length === 0) { + say('Nothing here yet. Index it with sourceant index.') + } + renderLegend(data.nodes) +} + +function paintNode(node, ctx, scale) { + const dimmed = state.matching !== null && !state.matching.has(node.id) + const colour = colourOf(node) + ctx.globalAlpha = dimmed ? 0.15 : 1 + + ctx.beginPath() + ctx.arc(node.x, node.y, node.id === state.selected ? 6 : 4, 0, 2 * Math.PI) + ctx.fillStyle = colour + ctx.fill() + if (node.id === state.selected) { + ctx.lineWidth = 1.5 / scale + ctx.strokeStyle = canvasColour('--canvas-label') + ctx.stroke() + } + + if (state.labelled || scale > 1.4 || state.matching !== null) { + const size = Math.max(11 / scale, 2) + ctx.font = `${groupOf(node) === 'file' ? '600 ' : ''}${size}px Inter, sans-serif` + ctx.fillStyle = colour + ctx.textAlign = 'left' + ctx.textBaseline = 'middle' + ctx.fillText(shortName(node.name), node.x + 6, node.y) + } + ctx.globalAlpha = 1 +} + +function renderLegend(nodes) { + const present = new Set(nodes.map(groupOf)) + const seen = [] + for (const group of present) { + seen.push({ group, colour: COLOURS[group] || OTHER }) + } + seen.sort((a, b) => a.group.localeCompare(b.group)) + element.legend.innerHTML = seen + .map(({ group, colour }) => + `${group || 'other'}`) + .join('') +} + +function select(node) { + state.selected = node ? node.id : null + element.details.hidden = !node + if (node) { + const degree = state.loaded.links.filter((link) => + (link.source.id || link.source) === node.id || (link.target.id || link.target) === node.id).length + element.detailsName.textContent = node.name + element.detailsKind.textContent = node.synthetic + ? `${node.kind} · this view's arrangement` + : (groupOf(node) === node.kind ? node.kind : `${groupOf(node)} · ${node.kind}`) + element.detailsPath.textContent = node.path || '—' + element.detailsLinks.textContent = node.synthetic ? '—' : degree + } + if (state.graph) state.graph.nodeCanvasObject(paintNode) +} + +function highlight(term) { + const needle = term.trim().toLowerCase() + state.matching = needle + ? new Set(state.loaded.nodes + .filter((node) => node.name.toLowerCase().includes(needle) || (node.path || '').toLowerCase().includes(needle)) + .map((node) => node.id)) + : null + if (state.graph) state.graph.nodeCanvasObject(paintNode) +} + +async function load() { + const repository = element.repository.value + if (!repository) return + say('Reading the index…') + try { + const query = new URLSearchParams({ repository }) + if (element.tests.checked) query.set('include_tests', 'true') + const graph = await read(`/api/graph?${query}`) + state.loaded = graph + state.selected = null + element.details.hidden = true + element.truncated.hidden = !graph.truncated + if (graph.truncated) { + element.truncated.textContent = + 'This repository is larger than the limit, so this is part of it, not all of it.' + } + draw() + } catch (error) { + say(`Could not read the graph: ${error.message}`) + } +} + +async function start() { + buildLayouts() + applyStoredTheme() + + try { + const repositories = await read('/api/repositories') + if (repositories.length === 0) { + element.repository.innerHTML = '' + say('No repository is registered on this machine. Add one with sourceant repo add <path>.') + return + } + element.repository.innerHTML = repositories + .map((repository) => ``) + .join('') + await load() + } catch (error) { + say(`Could not reach the agent: ${error.message}`) + } +} + +function buildLayouts() { + element.layouts.innerHTML = LAYOUTS + .map((layout) => + ``) + .join('') + element.layouts.addEventListener('click', (event) => { + const button = event.target.closest('button[data-layout]') + if (!button) return + state.layout = button.dataset.layout + for (const other of element.layouts.querySelectorAll('button')) { + other.setAttribute('aria-pressed', String(other === button)) + } + draw() + }) +} + +function applyStoredTheme() { + let stored = null + try { + stored = localStorage.getItem('sourceant-theme') + } catch { + stored = null + } + setTheme(stored === 'light' ? 'light' : 'dark') +} + +function setTheme(theme) { + document.documentElement.className = theme + element.theme.textContent = theme === 'dark' ? 'Light' : 'Dark' + try { + localStorage.setItem('sourceant-theme', theme) + } catch { + // A browser that refuses storage still gets the theme, just not the memory. + } + if (state.graph) state.graph.linkColor(() => canvasColour('--canvas-link')) +} + +element.repository.addEventListener('change', load) +element.tests.addEventListener('change', load) +element.imports.addEventListener('change', draw) +element.folders.addEventListener('change', draw) +element.symbols.addEventListener('change', draw) +element.search.addEventListener('input', (event) => highlight(event.target.value)) +element.closeDetails.addEventListener('click', () => select(null)) +element.theme.addEventListener('click', () => + setTheme(document.documentElement.className === 'dark' ? 'light' : 'dark')) +new ResizeObserver(() => { + if (state.graph) { + state.graph.width(element.canvas.clientWidth).height(element.canvas.clientHeight) + } +}).observe(element.canvas) + +start() diff --git a/internal/ui/assets/favicon.svg b/internal/ui/assets/favicon.svg new file mode 100644 index 0000000..ee39a57 --- /dev/null +++ b/internal/ui/assets/favicon.svg @@ -0,0 +1 @@ + diff --git a/internal/ui/assets/index.html b/internal/ui/assets/index.html new file mode 100644 index 0000000..d261c7c --- /dev/null +++ b/internal/ui/assets/index.html @@ -0,0 +1,71 @@ + + + + + +Code graph · SourceAnt + + + + +
+
+
+ +
+

Code graph

+

What the indexer found on this machine.

+
+
+
+ + +
+
+ +
+
+
+ + + + + +
+
+ +
+
+
Loading…
+ +
+ + + +
+
+
+
+
+ + + + + diff --git a/internal/ui/assets/styles.css b/internal/ui/assets/styles.css new file mode 100644 index 0000000..888fac1 --- /dev/null +++ b/internal/ui/assets/styles.css @@ -0,0 +1,295 @@ +/* The tokens are the dashboard's, so the local view and the hosted one read as + one product. Dark is the default there and here; .light is the override. */ +:root, +.light { + --background: 240 20% 98%; + --foreground: 240 10% 10%; + --card: 0 0% 100%; + --muted: 240 10% 94%; + --muted-foreground: 240 5% 45%; + --border: 240 10% 90%; + --primary: 357 89% 47%; + --primary-foreground: 0 0% 100%; + --accent: 357 60% 96%; + --radius: 0.25rem; + --canvas-link: #b4b4bd; + --canvas-label: #52525b; + color-scheme: light; +} + +.dark { + --background: 240 10% 3.9%; + --foreground: 0 0% 98%; + --card: 240 9% 7%; + --muted: 240 5% 14%; + --muted-foreground: 240 5% 64.9%; + --border: 240 6% 16%; + --primary: 357 89% 47%; + --primary-foreground: 0 0% 100%; + --accent: 240 4% 16%; + --canvas-link: #52525b; + --canvas-label: #9ca3af; + color-scheme: dark; +} + +* { + box-sizing: border-box; + border-color: hsl(var(--border)); +} + +body { + margin: 0; + padding: 2rem 1.5rem; + background: hsl(var(--background)); + color: hsl(var(--foreground)); + font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; + -webkit-font-smoothing: antialiased; +} + +main { + max-width: 1400px; + margin: 0 auto; +} + +header { + display: flex; + flex-wrap: wrap; + align-items: flex-start; + justify-content: space-between; + gap: 1rem; + margin-bottom: 1.5rem; +} + +.title { + display: flex; + align-items: center; + gap: 0.75rem; +} + +.mark { + width: 2.75rem; + height: 2.75rem; + display: grid; + place-items: center; + border-radius: calc(var(--radius) + 2px); + background: hsl(262 83% 66% / 0.15); + color: hsl(262 83% 66%); + flex: none; +} + +h1 { + font-size: 1.25rem; + font-weight: 600; + margin: 0; + line-height: 1.3; +} + +.subtitle { + margin: 0.15rem 0 0; + font-size: 0.875rem; + color: hsl(var(--muted-foreground)); +} + +select, +input[type="search"], +button { + font: inherit; + color: inherit; + background: hsl(var(--card)); + border: 1px solid hsl(var(--border)); + border-radius: calc(var(--radius) + 2px); + padding: 0.375rem 0.75rem; + font-size: 0.875rem; +} + +button { + cursor: pointer; +} + +.controls { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + margin-bottom: 0.75rem; +} + +.segmented { + display: inline-flex; + gap: 0.125rem; + padding: 0.125rem; + background: hsl(var(--card)); + border: 1px solid hsl(var(--border)); + border-radius: calc(var(--radius) + 2px); +} + +.segmented button { + border: 0; + background: none; + padding: 0.25rem 0.75rem; + font-size: 0.75rem; + font-weight: 500; + color: hsl(var(--muted-foreground)); + border-radius: var(--radius); + transition: background-color 0.15s, color 0.15s; +} + +.segmented button[aria-pressed="true"] { + background: hsl(var(--primary) / 0.15); + color: hsl(var(--primary)); +} + +.toggles { + display: flex; + align-items: center; + gap: 1rem; + font-size: 0.75rem; + color: hsl(var(--muted-foreground)); +} + +.toggles label { + display: inline-flex; + align-items: center; + gap: 0.375rem; + cursor: pointer; +} + +.stage { + position: relative; + border: 1px solid hsl(var(--border)); + border-radius: calc(var(--radius) + 4px); + background: hsl(var(--card)); + overflow: hidden; +} + +#canvas { + height: 62vh; + min-height: 420px; + width: 100%; +} + +.overlay { + position: absolute; + inset: 0; + display: grid; + place-items: center; + padding: 2rem; + text-align: center; + font-size: 0.875rem; + color: hsl(var(--muted-foreground)); + background: hsl(var(--card)); +} + +.overlay[hidden] { + display: none; +} + +.overlay code { + font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; + font-size: 0.8125rem; + background: hsl(var(--muted)); + padding: 0.15rem 0.4rem; + border-radius: var(--radius); +} + +.details { + position: absolute; + top: 0.75rem; + right: 0.75rem; + width: min(20rem, calc(100% - 1.5rem)); + padding: 0.875rem 1rem; + background: hsl(var(--background) / 0.92); + backdrop-filter: blur(12px); + border: 1px solid hsl(var(--border)); + border-radius: calc(var(--radius) + 2px); +} + +.details[hidden] { + display: none; +} + +.details h2 { + margin: 0 0 0.5rem; + font-size: 0.9375rem; + font-weight: 600; + overflow-wrap: anywhere; +} + +.details dl { + margin: 0; + display: grid; + grid-template-columns: auto 1fr; + gap: 0.25rem 0.75rem; + font-size: 0.75rem; +} + +.details dt { + color: hsl(var(--muted-foreground)); +} + +.details dd { + margin: 0; + font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; + overflow-wrap: anywhere; +} + +.details button { + position: absolute; + top: 0.5rem; + right: 0.5rem; + border: 0; + background: none; + padding: 0.25rem; + line-height: 1; + color: hsl(var(--muted-foreground)); +} + +footer { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 1rem; + margin-top: 1rem; +} + +.legend { + display: flex; + flex-wrap: wrap; + gap: 0.5rem 1rem; +} + +.legend span { + display: inline-flex; + align-items: center; + gap: 0.5rem; + font-size: 0.75rem; + color: hsl(var(--muted-foreground)); +} + +.swatch { + width: 0.625rem; + height: 0.625rem; + border-radius: 2px; + flex: none; +} + +.tally { + font-size: 0.75rem; + color: hsl(var(--muted-foreground)); + font-variant-numeric: tabular-nums; +} + +.warning { + margin-top: 0.75rem; + padding: 0.625rem 0.875rem; + font-size: 0.8125rem; + border: 1px solid hsl(38 92% 50% / 0.35); + background: hsl(38 92% 50% / 0.1); + border-radius: calc(var(--radius) + 2px); +} + +.warning[hidden] { + display: none; +} diff --git a/internal/ui/assets/vendor/force-graph.LICENSE b/internal/ui/assets/vendor/force-graph.LICENSE new file mode 100644 index 0000000..a36ddd4 --- /dev/null +++ b/internal/ui/assets/vendor/force-graph.LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Vasco Asturiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/internal/ui/assets/vendor/force-graph.min.js b/internal/ui/assets/vendor/force-graph.min.js new file mode 100644 index 0000000..a2ed925 --- /dev/null +++ b/internal/ui/assets/vendor/force-graph.min.js @@ -0,0 +1,5 @@ +// Version 1.51.4 force-graph - https://github.com/vasturiano/force-graph +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).ForceGraph=n()}(this,function(){"use strict";function n(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),f.hasOwnProperty(n)?{space:f[n],local:t}:t}function d(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===h&&n.documentElement.namespaceURI===h?n.createElement(t):n.createElementNS(e,t)}}function g(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function _(t){var n=p(t);return(n.local?g:d)(n)}function y(){}function v(t){return null==t?y:function(){return this.querySelector(t)}}function m(){return[]}function x(t){return null==t?m:function(){return this.querySelectorAll(t)}}function b(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function w(t){return function(){return this.matches(t)}}function k(t){return function(n){return n.matches(t)}}var M=Array.prototype.find;function A(){return this.firstElementChild}var z=Array.prototype.filter;function S(){return Array.from(this.children)}function C(t){return new Array(t.length)}function E(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function P(t,n,e,r,i,o){for(var a,u=0,s=n.length,l=o.length;un?1:t>=n?0:NaN}function R(t){return function(){this.removeAttribute(t)}}function D(t){return function(){this.removeAttributeNS(t.space,t.local)}}function I(t,n){return function(){this.setAttribute(t,n)}}function U(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function F(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function L(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function q(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function $(t){return function(){this.style.removeProperty(t)}}function B(t,n,e){return function(){this.style.setProperty(t,n,e)}}function H(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function V(t,n){return t.style.getPropertyValue(n)||q(t).getComputedStyle(t,null).getPropertyValue(n)}function X(t){return function(){delete this[t]}}function G(t,n){return function(){this[t]=n}}function Y(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function W(t){return t.trim().split(/^|\s+/)}function Z(t){return t.classList||new Q(t)}function Q(t){this._node=t,this._names=W(t.getAttribute("class")||"")}function K(t,n){for(var e=Z(t),r=-1,i=n.length;++r=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var xt=[null];function bt(t,n){this._groups=t,this._parents=n}function wt(){return new bt([[document.documentElement]],xt)}function kt(t){return"string"==typeof t?new bt([[document.querySelector(t)]],[document.documentElement]):new bt([[t]],xt)}function Mt(t,n){if(t=function(t){let n;for(;n=t.sourceEvent;)t=n;return t}(t),void 0===n&&(n=t.currentTarget),n){var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(n.getScreenCTM().inverse())).x,r.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}}return[t.pageX,t.pageY]}bt.prototype=wt.prototype={constructor:bt,select:function(t){"function"!=typeof t&&(t=v(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i=x&&(x=m+1);!(v=_[x])&&++x=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=T);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?$:"function"==typeof n?H:B)(t,n,null==e?"":e)):V(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?X:"function"==typeof n?Y:G)(t,n)):this.node()[t]},classed:function(t,n){var e=W(t+"");if(arguments.length<2){for(var r=Z(this.node()),i=-1,o=e.length;++i=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}(t+""),a=o.length;if(!(arguments.length<2)){for(u=n?_t:gt,r=0;r{}};function zt(){for(var t,n=0,e=arguments.length,r={};n=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})),a=-1,u=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++a0)for(var e,r,i=new Array(e),o=0;o()=>t;function It(t,{sourceEvent:n,subject:e,target:r,identifier:i,active:o,x:a,y:u,dx:s,dy:l,dispatch:c}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:s,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:c}})}function Ut(t){return!t.ctrlKey&&!t.button}function Ft(){return this.parentNode}function Lt(t,n){return null==n?{x:t.x,y:t.y}:n}function qt(){return navigator.maxTouchPoints||"ontouchstart"in this}function $t(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function Bt(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function Ht(){}It.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var Vt=.7,Xt=1/Vt,Gt="\\s*([+-]?\\d+)\\s*",Yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Zt=/^#([0-9a-f]{3,8})$/,Qt=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Kt=new RegExp(`^rgb\\(${Wt},${Wt},${Wt}\\)$`),Jt=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${Yt}\\)$`),tn=new RegExp(`^rgba\\(${Wt},${Wt},${Wt},${Yt}\\)$`),nn=new RegExp(`^hsl\\(${Yt},${Wt},${Wt}\\)$`),en=new RegExp(`^hsla\\(${Yt},${Wt},${Wt},${Yt}\\)$`),rn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function on(){return this.rgb().formatHex()}function an(){return this.rgb().formatRgb()}function un(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=Zt.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?sn(n):3===e?new hn(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?ln(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?ln(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=Qt.exec(t))?new hn(n[1],n[2],n[3],1):(n=Kt.exec(t))?new hn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=Jt.exec(t))?ln(n[1],n[2],n[3],n[4]):(n=tn.exec(t))?ln(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=nn.exec(t))?yn(n[1],n[2]/100,n[3]/100,1):(n=en.exec(t))?yn(n[1],n[2]/100,n[3]/100,n[4]):rn.hasOwnProperty(t)?sn(rn[t]):"transparent"===t?new hn(NaN,NaN,NaN,0):null}function sn(t){return new hn(t>>16&255,t>>8&255,255&t,1)}function ln(t,n,e,r){return r<=0&&(t=n=e=NaN),new hn(t,n,e,r)}function cn(t,n,e,r){return 1===arguments.length?function(t){return t instanceof Ht||(t=un(t)),t?new hn((t=t.rgb()).r,t.g,t.b,t.opacity):new hn}(t):new hn(t,n,e,null==r?1:r)}function hn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function fn(){return`#${_n(this.r)}${_n(this.g)}${_n(this.b)}`}function pn(){const t=dn(this.opacity);return`${1===t?"rgb(":"rgba("}${gn(this.r)}, ${gn(this.g)}, ${gn(this.b)}${1===t?")":`, ${t})`}`}function dn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function gn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function _n(t){return((t=gn(t))<16?"0":"")+t.toString(16)}function yn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new mn(t,n,e,r)}function vn(t){if(t instanceof mn)return new mn(t.h,t.s,t.l,t.opacity);if(t instanceof Ht||(t=un(t)),!t)return new mn;if(t instanceof mn)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,s=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e0&&s<1?0:a,new mn(a,u,s,t.opacity)}function mn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function xn(t){return(t=(t||0)%360)<0?t+360:t}function bn(t){return Math.max(0,Math.min(1,t||0))}function wn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}$t(Ht,un,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:on,formatHex:on,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return vn(this).formatHsl()},formatRgb:an,toString:an}),$t(hn,cn,Bt(Ht,{brighter(t){return t=null==t?Xt:Math.pow(Xt,t),new hn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Vt:Math.pow(Vt,t),new hn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new hn(gn(this.r),gn(this.g),gn(this.b),dn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:fn,formatHex:fn,formatHex8:function(){return`#${_n(this.r)}${_n(this.g)}${_n(this.b)}${_n(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:pn,toString:pn})),$t(mn,function(t,n,e,r){return 1===arguments.length?vn(t):new mn(t,n,e,null==r?1:r)},Bt(Ht,{brighter(t){return t=null==t?Xt:Math.pow(Xt,t),new mn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Vt:Math.pow(Vt,t),new mn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new hn(wn(t>=240?t-240:t+120,i,r),wn(t,i,r),wn(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new mn(xn(this.h),bn(this.s),bn(this.l),dn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=dn(this.opacity);return`${1===t?"hsl(":"hsla("}${xn(this.h)}, ${100*bn(this.s)}%, ${100*bn(this.l)}%${1===t?")":`, ${t})`}`}}));var kn=t=>()=>t;function Mn(t){return 1===(t=+t)?An:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):kn(isNaN(n)?e:n)}}function An(t,n){var e=n-t;return e?function(t,n){return function(e){return t+e*n}}(t,e):kn(isNaN(t)?n:t)}var zn=function t(n){var e=Mn(n);function r(t,n){var r=e((t=cn(t)).r,(n=cn(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=An(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function Sn(t,n){return t=+t,n=+n,function(e){return t*(1-e)+n*e}}var Cn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,En=new RegExp(Cn.source,"g");function Pn(t,n){var e,r,i,o=Cn.lastIndex=En.lastIndex=0,a=-1,u=[],s=[];for(t+="",n+="";(e=Cn.exec(t))&&(r=En.exec(n));)(i=r.index)>o&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,s.push({i:a,x:Sn(e,r)})),o=En.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Sn(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,s),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Sn(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,s),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:Sn(t,e)},{i:u-2,x:Sn(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,s),o=a=null,function(t){for(var n,e=-1,r=s.length;++e=0&&n._call.call(void 0,t),n=n._next;--$n}()}finally{$n=0,function(){var t,n,e=Fn,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Fn=n);Ln=t,ee(r)}(),Xn=0}}function ne(){var t=Yn.now(),n=t-Vn;n>1e3&&(Gn-=n,Vn=t)}function ee(t){$n||(Bn&&(Bn=clearTimeout(Bn)),t-Xn>24?(t<1/0&&(Bn=setTimeout(te,t-Yn.now()-Gn)),Hn&&(Hn=clearInterval(Hn))):(Hn||(Vn=Yn.now(),Hn=setInterval(ne,1e3)),$n=1,Wn(te)))}function re(t,n,e){var r=new Kn;return n=null==n?0:+n,r.restart(e=>{r.stop(),t(e+n)},n,e),r}Kn.prototype=Jn.prototype={constructor:Kn,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?Zn():+e)+(null==n?0:+n),this._next||Ln===this||(Ln?Ln._next=this:Fn=this,Ln=this),this._call=t,this._time=e,ee()},stop:function(){this._call&&(this._call=null,this._time=1/0,ee())}};var ie=zt("start","end","cancel","interrupt"),oe=[];function ae(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(t){e.state=1,e.timer.restart(a,e.delay,e.time),e.delay<=t&&a(t-e.delay)}function a(o){var l,c,h,f;if(1!==e.state)return s();for(l in i)if((f=i[l]).name===e.name){if(3===f.state)return re(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[l]):+l0)throw new Error("too late; already scheduled");return e}function se(t,n){var e=le(t,n);if(e.state>3)throw new Error("too late; already running");return e}function le(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function ce(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>2&&e.state<5,e.state=6,e.timer.stop(),e.on.call(r?"interrupt":"cancel",t,t.__data__,e.index,e.group),delete o[i]):a=!1;a&&delete t.__transition}}function he(t,n){var e,r;return function(){var i=se(this,t),o=i.tween;if(o!==e)for(var a=0,u=(r=e=o).length;a=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?ue:se;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var e=p(t),r="transform"===e?In:de;return this.attrTween(t,"function"==typeof n?(e.local?xe:me)(e,r,pe(this,"attr."+t,n)):null==n?(e.local?_e:ge)(e):(e.local?ve:ye)(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=p(t);return this.tween(e,(r.local?be:we)(r,n))},style:function(t,n,e){var r="transform"==(t+="")?Dn:de;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=V(this,t),a=(this.style.removeProperty(t),V(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,Ce(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=V(this,t),u=e(this),s=u+"";return null==u&&(this.style.removeProperty(t),s=u=V(this,t)),a===s?null:a===r&&s===i?o:(i=s,o=n(r=a,u))}}(t,r,pe(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var s=se(this,t),l=s.on,c=null==s.value[a]?o||(o=Ce(n)):void 0;l===e&&i===c||(r=(e=l).copy()).on(u,i=c),s.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=V(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(pe(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=le(this.node(),e).tween,o=0,a=i.length;o()=>t;function De(t,{sourceEvent:n,target:e,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ie(t,n,e){this.k=t,this.x=n,this.y=e}Ie.prototype={constructor:Ie,scale:function(t){return 1===t?this:new Ie(this.k*t,this.x,this.y)},translate:function(t,n){return 0===t&0===n?this:new Ie(this.k,this.x+this.k*t,this.y+this.k*n)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ue=new Ie(1,0,0);function Fe(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Ue;return t.__zoom}function Le(t){t.stopImmediatePropagation()}function qe(t){t.preventDefault(),t.stopImmediatePropagation()}function $e(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Be(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function He(){return this.__zoom||Ue}function Ve(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Xe(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ge(t,n,e){var r=t.invertX(n[0][0])-e[0][0],i=t.invertX(n[1][0])-e[1][0],o=t.invertY(n[0][1])-e[0][1],a=t.invertY(n[1][1])-e[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function Ye(){var t,n,e,r=$e,i=Be,o=Ge,a=Ve,u=Xe,s=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,h=qn,f=zt("start","zoom","end"),p=0,d=10;function g(t){t.property("__zoom",He).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",M).filter(u).on("touchstart.zoom",A).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",S).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(t,n){return(n=Math.max(s[0],Math.min(s[1],n)))===t.k?t:new Ie(n,t.x,t.y)}function y(t,n,e){var r=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return r===t.x&&i===t.y?t:new Ie(t.k,r,i)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function m(t,n,e,r){t.on("start.zoom",function(){x(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,o=arguments,a=x(t,o).event(r),u=i.apply(t,o),s=null==e?v(u):"function"==typeof e?e.apply(t,o):e,l=Math.max(u[1][0]-u[0][0],u[1][1]-u[0][1]),c=t.__zoom,f="function"==typeof n?n.apply(t,o):n,p=h(c.invert(s).concat(l/c.k),f.invert(s).concat(l/f.k));return function(t){if(1===t)t=f;else{var n=p(t),e=l/n[2];t=new Ie(e,s[0]-n[0]*e,s[1]-n[1]*e)}a.zoom(null,t)}})}function x(t,n,e){return!e&&t.__zooming||new b(t,n)}function b(t,n){this.that=t,this.args=n,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,n),this.taps=0}function w(t,...n){if(r.apply(this,arguments)){var e=x(this,n).event(t),i=this.__zoom,u=Math.max(s[0],Math.min(s[1],i.k*Math.pow(2,a.apply(this,arguments)))),c=Mt(t);if(e.wheel)e.mouse[0][0]===c[0]&&e.mouse[0][1]===c[1]||(e.mouse[1]=i.invert(e.mouse[0]=c)),clearTimeout(e.wheel);else{if(i.k===u)return;e.mouse=[c,i.invert(c)],ce(this),e.start()}qe(t),e.wheel=setTimeout(function(){e.wheel=null,e.end()},150),e.zoom("mouse",o(y(_(i,u),e.mouse[0],e.mouse[1]),e.extent,l))}}function k(t,...n){if(!e&&r.apply(this,arguments)){var i=t.currentTarget,a=x(this,n,!0).event(t),u=kt(t.view).on("mousemove.zoom",function(t){if(qe(t),!a.moved){var n=t.clientX-c,e=t.clientY-h;a.moved=n*n+e*e>p}a.event(t).zoom("mouse",o(y(a.that.__zoom,a.mouse[0]=Mt(t,i),a.mouse[1]),a.extent,l))},!0).on("mouseup.zoom",function(t){u.on("mousemove.zoom mouseup.zoom",null),Rt(t.view,a.moved),qe(t),a.event(t).end()},!0),s=Mt(t,i),c=t.clientX,h=t.clientY;Tt(t.view),Le(t),a.mouse=[s,this.__zoom.invert(s)],ce(this),a.start()}}function M(t,...n){if(r.apply(this,arguments)){var e=this.__zoom,a=Mt(t.changedTouches?t.changedTouches[0]:t,this),u=e.invert(a),s=e.k*(t.shiftKey?.5:2),h=o(y(_(e,s),a,u),i.apply(this,n),l);qe(t),c>0?kt(this).transition().duration(c).call(m,h,a,t):kt(this).call(g.transform,h,a,t)}}function A(e,...i){if(r.apply(this,arguments)){var o,a,u,s,l=e.touches,c=l.length,h=x(this,i,e.changedTouches.length===c).event(e);for(Le(e),a=0;a=n)&&(e=n);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(e=i)&&(e=i)}return e}function Je(t,n){let e;if(void 0===n)for(const n of t)null!=n&&(e>n||void 0===e&&n>=n)&&(e=n);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(e>i||void 0===e&&i>=i)&&(e=i)}return e}var tr="object"==typeof global&&global&&global.Object===Object&&global,nr="object"==typeof self&&self&&self.Object===Object&&self,er=tr||nr||Function("return this")(),rr=er.Symbol,ir=Object.prototype,or=ir.hasOwnProperty,ar=ir.toString,ur=rr?rr.toStringTag:void 0;var sr=Object.prototype.toString;var lr=rr?rr.toStringTag:void 0;function cr(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":lr&&lr in Object(t)?function(t){var n=or.call(t,ur),e=t[ur];try{t[ur]=void 0;var r=!0}catch(t){}var i=ar.call(t);return r&&(n?t[ur]=e:delete t[ur]),i}(t):function(t){return sr.call(t)}(t)}var hr=/\s/;var fr=/^\s+/;function pr(t){return t?t.slice(0,function(t){for(var n=t.length;n--&&hr.test(t.charAt(n)););return n}(t)+1).replace(fr,""):t}function dr(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}var gr=/^[-+]0x[0-9a-f]+$/i,_r=/^0b[01]+$/i,yr=/^0o[0-7]+$/i,vr=parseInt;function mr(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return null!=t&&"object"==typeof t}(t)&&"[object Symbol]"==cr(t)}(t))return NaN;if(dr(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=dr(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=pr(t);var e=_r.test(t);return e||yr.test(t)?vr(t.slice(2),e?2:8):gr.test(t)?NaN:+t}var xr=function(){return er.Date.now()},br=Math.max,wr=Math.min;function kr(t,n,e){var r,i,o,a,u,s,l=0,c=!1,h=!1,f=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(n){var e=r,o=i;return r=i=void 0,l=n,a=t.apply(o,e)}function d(t){var e=t-s;return void 0===s||e>=n||e<0||h&&t-l>=o}function g(){var t=xr();if(d(t))return _(t);u=setTimeout(g,function(t){var e=n-(t-s);return h?wr(e,o-(t-l)):e}(t))}function _(t){return u=void 0,f&&r?p(t):(r=i=void 0,a)}function y(){var t=xr(),e=d(t);if(r=arguments,i=this,s=t,e){if(void 0===u)return function(t){return l=t,u=setTimeout(g,n),c?p(t):a}(s);if(h)return clearTimeout(u),u=setTimeout(g,n),p(s)}return void 0===u&&(u=setTimeout(g,n)),a}return n=mr(n)||0,dr(e)&&(c=!!e.leading,o=(h="maxWait"in e)?br(mr(e.maxWait)||0,n):o,f="trailing"in e?!!e.trailing:f),y.cancel=function(){void 0!==u&&clearTimeout(u),l=0,r=s=i=u=void 0},y.flush=function(){return void 0===u?a:_(xr())},y}var Mr=Object.freeze({Linear:Object.freeze({None:function(t){return t},In:function(t){return t},Out:function(t){return t},InOut:function(t){return t}}),Quadratic:Object.freeze({In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}}),Cubic:Object.freeze({In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}}),Quartic:Object.freeze({In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}}),Quintic:Object.freeze({In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}}),Sinusoidal:Object.freeze({In:function(t){return 1-Math.sin((1-t)*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.sin(Math.PI*(.5-t)))}}),Exponential:Object.freeze({In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}}),Circular:Object.freeze({In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}}),Elastic:Object.freeze({In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(t){var n=1.70158;return 1===t?1:t*t*((n+1)*t-n)},Out:function(t){var n=1.70158;return 0===t?0:--t*t*((n+1)*t+n)+1},InOut:function(t){var n=2.5949095;return(t*=2)<1?t*t*((n+1)*t-n)*.5:.5*((t-=2)*t*((n+1)*t+n)+2)}}),Bounce:Object.freeze({In:function(t){return 1-Mr.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*Mr.Bounce.In(2*t):.5*Mr.Bounce.Out(2*t-1)+.5}}),generatePow:function(t){return void 0===t&&(t=4),t=(t=t1e4?1e4:t,{In:function(n){return Math.pow(n,t)},Out:function(n){return 1-Math.pow(1-n,t)},InOut:function(n){return n<.5?Math.pow(2*n,t)/2:(1-Math.pow(2-2*n,t))/2+.5}}}}),Ar=function(){return performance.now()},zr=function(){function t(){for(var t=[],n=0;n0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?o(t[e],t[e-1],e-r):o(t[i],t[i+1>e?e:i+1],r-i)},Utils:{Linear:function(t,n,e){return(n-t)*e+t}}},Cr=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),Er=new zr,Pr=function(){function t(t,n){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Mr.Linear.None,this._interpolationFunction=Sr.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Cr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=t,"object"==typeof n?(this._group=n,n.add(this)):!0===n&&(this._group=Er,Er.add(this))}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.getDuration=function(){return this._duration},t.prototype.to=function(t,n){if(void 0===n&&(n=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=n<0?0:n,this},t.prototype.duration=function(t){return void 0===t&&(t=1e3),this._duration=t<0?0:t,this},t.prototype.dynamic=function(t){return void 0===t&&(t=!1),this._isDynamic=t,this},t.prototype.start=function(t,n){if(void 0===t&&(t=Ar()),void 0===n&&(n=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||n){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var i in this._valuesEnd)r[i]=this._valuesEnd[i];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,n)}return this},t.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},t.prototype._setupProperties=function(t,n,e,r,i){for(var o in e){var a=t[o],u=Array.isArray(a),s=u?"array":typeof a,l=!u&&Array.isArray(e[o]);if("undefined"!==s&&"function"!==s){if(l){if(0===(_=e[o]).length)continue;for(var c=[a],h=0,f=_.length;hs)return 1;var t=Math.trunc(a/u),n=a-t*u,e=Math.min(n/o._duration,1);return 0===e&&a===o._duration?1:e}(),c=this._easingFunction(l);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,c),this._onUpdateCallback&&this._onUpdateCallback(this._object,l),0===this._duration||a>=this._duration){if(this._repeat>0){var h=Math.min(Math.trunc((a-this._duration)/u)+1,this._repeat);for(i in isFinite(this._repeat)&&(this._repeat-=h),this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[i]||(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*h,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var f=0,p=this._chainedTweens.length;ft.length)&&(n=t.length);for(var e=0,r=Array(n);e1&&(e-=1),e<1/6?t+6*(n-t)*e:e<.5?n:e<2/3?t+(n-t)*(2/3-e)*6:t}if(t=ui(t,360),n=ui(n,100),e=ui(e,100),0===n)r=i=o=e;else{var u=e<.5?e*(1+n):e+n-e*n,s=2*e-u;r=a(s,u,t+1/3),i=a(s,u,t),o=a(s,u,t-1/3)}return{r:255*r,g:255*i,b:255*o}}(t.h,r,o),a=!0,u="hsl"),t.hasOwnProperty("a")&&(e=t.a));return e=ai(e),{ok:a,format:t.format||u,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:e}}(t);this._originalInput=t,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=n.format||e.format,this._gradientType=n.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}function $r(t,n,e){t=ui(t,255),n=ui(n,255),e=ui(e,255);var r,i,o=Math.max(t,n,e),a=Math.min(t,n,e),u=(o+a)/2;if(o==a)r=i=0;else{var s=o-a;switch(i=u>.5?s/(2-o-a):s/(o+a),o){case t:r=(n-e)/s+(n>1)+720)%360;--n;)r.h=(r.h+i)%360,o.push(qr(r));return o}function ri(t,n){n=n||6;for(var e=qr(t).toHsv(),r=e.h,i=e.s,o=e.v,a=[],u=1/n;n--;)a.push(qr({h:r,s:i,v:o})),o=(o+u)%1;return a}qr.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,n,e,r=this.toRgb();return t=r.r/255,n=r.g/255,e=r.b/255,.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))},setAlpha:function(t){return this._a=ai(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=Br(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=Br(this._r,this._g,this._b),n=Math.round(360*t.h),e=Math.round(100*t.s),r=Math.round(100*t.v);return 1==this._a?"hsv("+n+", "+e+"%, "+r+"%)":"hsva("+n+", "+e+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=$r(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=$r(this._r,this._g,this._b),n=Math.round(360*t.h),e=Math.round(100*t.s),r=Math.round(100*t.l);return 1==this._a?"hsl("+n+", "+e+"%, "+r+"%)":"hsla("+n+", "+e+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return Hr(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,n,e,r,i){var o=[ci(Math.round(t).toString(16)),ci(Math.round(n).toString(16)),ci(Math.round(e).toString(16)),ci(fi(r))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*ui(this._r,255))+"%",g:Math.round(100*ui(this._g,255))+"%",b:Math.round(100*ui(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*ui(this._r,255))+"%, "+Math.round(100*ui(this._g,255))+"%, "+Math.round(100*ui(this._b,255))+"%)":"rgba("+Math.round(100*ui(this._r,255))+"%, "+Math.round(100*ui(this._g,255))+"%, "+Math.round(100*ui(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(oi[Hr(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var n="#"+Vr(this._r,this._g,this._b,this._a),e=n,r=this._gradientType?"GradientType = 1, ":"";if(t){var i=qr(t);e="#"+Vr(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+n+",endColorstr="+e+")"},toString:function(t){var n=!!t;t=t||this._format;var e=!1,r=this._a<1&&this._a>=0;return n||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(e=this.toRgbString()),"prgb"===t&&(e=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(e=this.toHexString()),"hex3"===t&&(e=this.toHexString(!0)),"hex4"===t&&(e=this.toHex8String(!0)),"hex8"===t&&(e=this.toHex8String()),"name"===t&&(e=this.toName()),"hsl"===t&&(e=this.toHslString()),"hsv"===t&&(e=this.toHsvString()),e||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return qr(this.toString())},_applyModification:function(t,n){var e=t.apply(null,[this].concat([].slice.call(n)));return this._r=e._r,this._g=e._g,this._b=e._b,this.setAlpha(e._a),this},lighten:function(){return this._applyModification(Wr,arguments)},brighten:function(){return this._applyModification(Zr,arguments)},darken:function(){return this._applyModification(Qr,arguments)},desaturate:function(){return this._applyModification(Xr,arguments)},saturate:function(){return this._applyModification(Gr,arguments)},greyscale:function(){return this._applyModification(Yr,arguments)},spin:function(){return this._applyModification(Kr,arguments)},_applyCombination:function(t,n){return t.apply(null,[this].concat([].slice.call(n)))},analogous:function(){return this._applyCombination(ei,arguments)},complement:function(){return this._applyCombination(Jr,arguments)},monochromatic:function(){return this._applyCombination(ri,arguments)},splitcomplement:function(){return this._applyCombination(ni,arguments)},triad:function(){return this._applyCombination(ti,[3])},tetrad:function(){return this._applyCombination(ti,[4])}},qr.fromRatio=function(t,n){if("object"==Ur(t)){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]="a"===r?t[r]:hi(t[r]));t=e}return qr(t,n)},qr.equals=function(t,n){return!(!t||!n)&&qr(t).toRgbString()==qr(n).toRgbString()},qr.random=function(){return qr.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},qr.mix=function(t,n,e){e=0===e?0:e||50;var r=qr(t).toRgb(),i=qr(n).toRgb(),o=e/100;return qr({r:(i.r-r.r)*o+r.r,g:(i.g-r.g)*o+r.g,b:(i.b-r.b)*o+r.b,a:(i.a-r.a)*o+r.a})}, +// =4.5;break;case"AAlarge":i=o>=3;break;case"AAAsmall":i=o>=7}return i},qr.mostReadable=function(t,n,e){var r,i,o,a,u=null,s=0;i=(e=e||{}).includeFallbackColors,o=e.level,a=e.size;for(var l=0;ls&&(s=r,u=qr(n[l]));return qr.isReadable(t,u,{level:o,size:a})||!i?u:(e.includeFallbackColors=!1,qr.mostReadable(t,["#fff","#000"],e))};var ii=qr.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},oi=qr.hexNames=function(t){var n={};for(var e in t)t.hasOwnProperty(e)&&(n[t[e]]=e);return n}(ii);function ai(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function ui(t,n){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var e=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=Math.min(n,Math.max(0,parseFloat(t))),e&&(t=parseInt(t*n,10)/100),Math.abs(t-n)<1e-6?1:t%n/parseFloat(n)}function si(t){return Math.min(1,Math.max(0,t))}function li(t){return parseInt(t,16)}function ci(t){return 1==t.length?"0"+t:""+t}function hi(t){return t<=1&&(t=100*t+"%"),t}function fi(t){return Math.round(255*parseFloat(t)).toString(16)}function pi(t){return li(t)/255}var di,gi,_i,yi=(gi="[\\s|\\(]+("+(di="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+di+")[,|\\s]+("+di+")\\s*\\)?",_i="[\\s|\\(]+("+di+")[,|\\s]+("+di+")[,|\\s]+("+di+")[,|\\s]+("+di+")\\s*\\)?",{CSS_UNIT:new RegExp(di),rgb:new RegExp("rgb"+gi),rgba:new RegExp("rgba"+_i),hsl:new RegExp("hsl"+gi),hsla:new RegExp("hsla"+_i),hsv:new RegExp("hsv"+gi),hsva:new RegExp("hsva"+_i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function vi(t){return!!yi.CSS_UNIT.exec(t)}function mi(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e0&&void 0!==arguments[0]?arguments[0]:6;!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),wi(this,Hi,void 0),wi(this,Vi,void 0),ki(Vi,this,n),this.reset()},[{key:"reset",value:function(){ki(Hi,this,["__reserved for background__"])}},{key:"register",value:function(t){if(bi(Hi,this).length>=Math.pow(2,24-bi(Vi,this)))return null;var n,e=bi(Hi,this).length,r=Bi(e,bi(Vi,this)),i=(n=e+(r<<24-bi(Vi,this)),"#".concat(Math.min(n,Math.pow(2,24)).toString(16).padStart(6,"0")));return bi(Hi,this).push(t),i}},{key:"lookup",value:function(t){if(!t)return null;var n="string"==typeof t?function(t){var n=qr(t).toRgb(),e=n.r,r=n.g,i=n.b;return $i(e,r,i)}(t):$i.apply(void 0,Ai(t));if(!n)return null;var e=n&Math.pow(2,24-bi(Vi,this))-1,r=n>>24-bi(Vi,this)&Math.pow(2,bi(Vi,this))-1;return Bi(e,bi(Vi,this))!==r||e>=bi(Hi,this).length?null:bi(Hi,this)[e]}}])}(),Gi={},Yi=[],Wi=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Zi=Array.isArray;function Qi(t,n){for(var e in n)t[e]=n[e];return t}function Ki(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Ji(t,n,e,r,i){var o={type:t,props:n,key:e,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++Ei:i,__i:-1,__u:0};return null==i&&null!=Ci.vnode&&Ci.vnode(o),o}function to(t){return t.children}function no(t,n){this.props=t,this.context=n}function eo(t,n){if(null==n)return t.__?eo(t.__,t.__i+1):null;for(var e;nn&&Oi.sort(Ti),t=Oi.shift(),n=Oi.length,ro(t)}finally{Oi.length=ao.__r=0}}function uo(t,n,e,r,i,o,a,u,s,l,c){var h,f,p,d,g,_,y,v=r&&r.__k||Yi,m=n.length;for(s=so(e,n,v,s,m),h=0;h0?a=t.__k[o]=Ji(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,s=o+f,a.__=t,a.__b=t.__b+1,u=null,-1!=(l=a.__i=co(a,e,s,h))&&(h--,(u=e[l])&&(u.__u|=2)),null==u||null==u.__v?(-1==l&&(i>c?f--:is?f--:f++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o(c?1:0))for(i=e-1,o=e+1;i>=0||o=0?i--:o++])&&!(2&l.__u)&&u==l.key&&s==l.type)return a;return-1}function ho(t,n,e){"-"==n[0]?t.setProperty(n,null==e?"":e):t[n]=null==e?"":"number"!=typeof e||Wi.test(n)?e:e+"px"}function fo(t,n,e,r,i){var o,a;t:if("style"==n)if("string"==typeof e)t.style.cssText=e;else{if("string"==typeof r&&(t.style.cssText=r=""),r)for(n in r)e&&n in e||ho(t.style,n,"");if(e)for(n in e)r&&e[n]==r[n]||ho(t.style,n,e[n])}else if("o"==n[0]&&"n"==n[1])o=n!=(n=n.replace(Ui,"$1")),a=n.toLowerCase(),n=a in t||"onFocusOut"==n||"onFocusIn"==n?a.slice(2):n.slice(2),t.l||(t.l={}),t.l[n+o]=e,e?r?e[Ii]=r[Ii]:(e[Ii]=Fi,t.addEventListener(n,o?qi:Li,o)):t.removeEventListener(n,o?qi:Li,o);else{if("http://www.w3.org/2000/svg"==i)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in t)try{t[n]=null==e?"":e;break t}catch(t){}"function"==typeof e||(null==e||!1===e&&"-"!=n[4]?t.removeAttribute(n):t.setAttribute(n,"popover"==n&&1==e?"":e))}}function po(t){return function(n){if(this.l){var e=this.l[n.type+t];if(null==n[Di])n[Di]=Fi++;else if(n[Di]0?t:Zi(t)?t.map(vo):Qi({},t)}function mo(t,n,e,r,i,o,a,u,s){var l,c,h,f,p,d,g,_=e.props||Gi,y=n.props,v=n.type;if("svg"==v?i="http://www.w3.org/2000/svg":"math"==v?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=o)for(l=0;l2&&(a.children=arguments.length>3?Si.call(arguments,2):e),"function"==typeof t&&null!=t.defaultProps)for(o in t.defaultProps)void 0===a[o]&&(a[o]=t.defaultProps[o]);return Ji(t,a,r,i,null)}(to,null,[t]),r||Gi,Gi,n.namespaceURI,r?null:n.firstChild?Si.call(n.childNodes):null,i,r?r.__e:n.firstChild,false,o),yo(i,t,o)}function Mo(t,n,e){var r,i,o,a,u=Qi({},t.props);for(o in t.type&&t.type.defaultProps&&(a=t.type.defaultProps),n)"key"==o?r=n[o]:"ref"==o?i=n[o]:u[o]=void 0===n[o]&&null!=a?a[o]:n[o];return arguments.length>2&&(u.children=arguments.length>3?Si.call(arguments,2):e),Ji(t.type,u,r||t.key,i||t.ref,null)}function Ao(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e2&&void 0!==arguments[2]?arguments[2]:{}).style,r=void 0===e?{}:e,i=kt(!!t&&"object"===Eo(t)&&!!t.node&&"function"==typeof t.node?t.node():t);"static"===i.style("position")&&i.style("position","relative"),n.tooltipEl=i.append("div").attr("class","float-tooltip-kap"),Object.entries(r).forEach(function(t){var e=Co(t,2),r=e[0],i=e[1];return n.tooltipEl.style(r,i)}),n.tooltipEl.style("left","-10000px").style("display","none");var o="tooltip-".concat(Math.round(1e12*Math.random()));n.mouseInside=!1,i.on("mousemove.".concat(o),function(t){n.mouseInside=!0;var e=Mt(t),r=i.node(),o=r.offsetWidth,a=r.offsetHeight,u=[null===n.offsetX||void 0===n.offsetX?"-".concat(e[0]/o*100,"%"):"number"==typeof n.offsetX?"calc(-50% + ".concat(n.offsetX,"px)"):n.offsetX,null===n.offsetY||void 0===n.offsetY?a>130&&a-e[1]<100?"calc(-100% - 6px)":"21px":"number"==typeof n.offsetY?n.offsetY<0?"calc(-100% - ".concat(Math.abs(n.offsetY),"px)"):"".concat(n.offsetY,"px"):n.offsetY];n.tooltipEl.style("left",e[0]+"px").style("top",e[1]+"px").style("transform","translate(".concat(u.join(","),")")),n.content&&n.tooltipEl.style("display","inline")}),i.on("mouseover.".concat(o),function(){n.mouseInside=!0,n.content&&n.tooltipEl.style("display","inline")}),i.on("mouseout.".concat(o),function(){n.mouseInside=!1,n.tooltipEl.style("display","none")})},update:function(t){var n,e;t.tooltipEl.style("display",t.content&&t.mouseInside?"inline":"none"),t.content?t.content instanceof HTMLElement?(t.tooltipEl.text(""),t.tooltipEl.append(function(){return t.content})):"string"==typeof t.content?t.tooltipEl.html(t.content):!function(t){return Pi(Mo(t))}(t.content)?(t.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",t.content,t.content.toString())):(t.tooltipEl.text(""),n=t.content,delete(e=t.tooltipEl.node()).__k,ko(Po(n),e)):t.tooltipEl.text("")}});function No(t,n,e){var r,i=1;function o(){var o,a,u=r.length,s=0,l=0,c=0;for(o=0;o=(i=(h+f)/2))?h=i:f=i,r=l,!(l=l[u=+a]))return r[u]=c,t;if(n===(o=+t._x.call(null,l.data)))return c.next=l,r?r[u]=c:t._root=c,t;do{r=r?r[u]=new Array(2):t._root=new Array(2),(a=n>=(i=(h+f)/2))?h=i:f=i}while((u=+a)===(s=+(o>=i)));return r[s]=l,r[u]=c,t}function To(t,n,e){this.node=t,this.x0=n,this.x1=e}function Ro(t){return t[0]}function Do(t,n){var e=new Io(null==n?Ro:n,NaN,NaN);return null==t?e:e.addAll(t)}function Io(t,n,e){this._x=t,this._x0=n,this._x1=e,this._root=void 0}function Uo(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var Fo=Do.prototype=Io.prototype;function Lo(t,n,e,r){if(isNaN(n)||isNaN(e))return t;var i,o,a,u,s,l,c,h,f,p=t._root,d={data:r},g=t._x0,_=t._y0,y=t._x1,v=t._y1;if(!p)return t._root=d,t;for(;p.length;)if((l=n>=(o=(g+y)/2))?g=o:y=o,(c=e>=(a=(_+v)/2))?_=a:v=a,i=p,!(p=p[h=c<<1|l]))return i[h]=d,t;if(u=+t._x.call(null,p.data),s=+t._y.call(null,p.data),n===u&&e===s)return d.next=p,i?i[h]=d:t._root=d,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(l=n>=(o=(g+y)/2))?g=o:y=o,(c=e>=(a=(_+v)/2))?_=a:v=a}while((h=c<<1|l)==(f=(s>=a)<<1|u>=o));return i[f]=p,i[h]=d,t}function qo(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function $o(t){return t[0]}function Bo(t){return t[1]}function Ho(t,n,e){var r=new Vo(null==n?$o:n,null==e?Bo:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Vo(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Xo(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}Fo.copy=function(){var t,n,e=new Io(this._x,this._x0,this._x1),r=this._root;if(!r)return e;if(!r.length)return e._root=Uo(r),e;for(t=[{source:r,target:e._root=new Array(2)}];r=t.pop();)for(var i=0;i<2;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(2)}):r.target[i]=Uo(n));return e},Fo.add=function(t){const n=+this._x.call(null,t);return jo(this.cover(n),n,t)},Fo.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,e=new Float64Array(n);let r=1/0,i=-1/0;for(let o,a=0;ai&&(i=o));if(r>i)return this;this.cover(r).cover(i);for(let r=0;rt||t>=e;)switch(i=+(ts||(i=o.x1)=h))&&(o=l[l.length-1],l[l.length-1]=l[l.length-1-a],l[l.length-1-a]=o)}else{var f=Math.abs(t-+this._x.call(null,c.data));f=(a=(h+f)/2))?h=a:f=a,n=c,!(c=c[s=+u]))return this;if(!c.length)break;n[s+1&1]&&(e=n,l=s)}for(;c.data!==t;)if(r=c,!(c=c.next))return this;return(i=c.next)&&delete c.next,r?(i?r.next=i:delete r.next,this):n?(i?n[s]=i:delete n[s],(c=n[0]||n[1])&&c===(n[1]||n[0])&&!c.length&&(e?e[l]=c:this._root=c),this):(this._root=i,this)},Fo.removeAll=function(t){for(var n=0,e=t.length;n=(a=(m+w)/2))?m=a:w=a,(p=e>=(u=(x+k)/2))?x=u:k=u,(d=r>=(s=(b+M)/2))?b=s:M=s,o=y,!(y=y[g=d<<2|p<<1|f]))return o[g]=v,t;if(l=+t._x.call(null,y.data),c=+t._y.call(null,y.data),h=+t._z.call(null,y.data),n===l&&e===c&&r===h)return v.next=y,o?o[g]=v:t._root=v,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(f=n>=(a=(m+w)/2))?m=a:w=a,(p=e>=(u=(x+k)/2))?x=u:k=u,(d=r>=(s=(b+M)/2))?b=s:M=s}while((g=d<<2|p<<1|f)==(_=(h>=s)<<2|(c>=u)<<1|l>=a));return o[_]=y,o[g]=v,t}function Wo(t,n,e,r,i,o,a){this.node=t,this.x0=n,this.y0=e,this.z0=r,this.x1=i,this.y1=o,this.z1=a}Go.copy=function(){var t,n,e=new Vo(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=Xo(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=Xo(n));return e},Go.add=function(t){const n=+this._x.call(null,t),e=+this._y.call(null,t);return Lo(this.cover(n,e),n,e,t)},Go.addAll=function(t){var n,e,r,i,o=t.length,a=new Array(o),u=new Array(o),s=1/0,l=1/0,c=-1/0,h=-1/0;for(e=0;ec&&(c=r),ih&&(h=i));if(s>c||l>h)return this;for(this.cover(s,l).cover(c,h),e=0;et||t>=i||r>n||n>=o;)switch(u=(nf||(o=s.y0)>p||(a=s.x1)=y)<<1|t>=_)&&(s=d[d.length-1],d[d.length-1]=d[d.length-1-l],d[d.length-1-l]=s)}else{var v=t-+this._x.call(null,g.data),m=n-+this._y.call(null,g.data),x=v*v+m*m;if(x=(u=(d+_)/2))?d=u:_=u,(c=a>=(s=(g+y)/2))?g=s:y=s,n=p,!(p=p[h=c<<1|l]))return this;if(!p.length)break;(n[h+1&3]||n[h+2&3]||n[h+3&3])&&(e=n,f=h)}for(;p.data!==t;)if(r=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,r?(i?r.next=i:delete r.next,this):n?(i?n[h]=i:delete n[h],(p=n[0]||n[1]||n[2]||n[3])&&p===(n[3]||n[2]||n[1]||n[0])&&!p.length&&(e?e[f]=p:this._root=p),this):(this._root=i,this)},Go.removeAll=function(t){for(var n=0,e=t.length;nMath.sqrt((t-r)**2+(n-i)**2+(e-o)**2);function Qo(t){return t[0]}function Ko(t){return t[1]}function Jo(t){return t[2]}function ta(t,n,e,r){var i=new na(null==n?Qo:n,null==e?Ko:e,null==r?Jo:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function na(t,n,e,r,i,o,a,u,s){this._x=t,this._y=n,this._z=e,this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=u,this._z1=s,this._root=void 0}function ea(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var ra=ta.prototype=na.prototype;function ia(t){return function(){return t}}function oa(t){return 1e-6*(t()-.5)}function aa(t){return t.index}function ua(t,n){var e=t.get(n);if(!e)throw new Error("node not found: "+n);return e}function sa(t){var n,e,r,i,o,a,u,s=aa,l=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},c=ia(30),h=1;function f(r){for(var o=0,s=t.length;o1&&(y=f.y+f.vy-c.y-c.vy||oa(u)),i>2&&(v=f.z+f.vz-c.z-c.vz||oa(u)),_*=p=((p=Math.sqrt(_*_+y*y+v*v))-e[g])/p*r*n[g],y*=p,v*=p,f.vx-=_*(d=a[g]),i>1&&(f.vy-=y*d),i>2&&(f.vz-=v*d),c.vx+=_*(d=1-d),i>1&&(c.vy+=y*d),i>2&&(c.vz+=v*d)}function p(){if(r){var i,u,l=r.length,c=t.length,h=new Map(r.map((t,n)=>[s(t,n,r),t]));for(i=0,o=new Array(l);i"function"==typeof t)||Math.random,i=n.find(t=>[1,2,3].includes(t))||2,p()},f.links=function(n){return arguments.length?(t=n,p(),f):t},f.id=function(t){return arguments.length?(s=t,f):s},f.iterations=function(t){return arguments.length?(h=+t,f):h},f.strength=function(t){return arguments.length?(l="function"==typeof t?t:ia(+t),d(),f):l},f.distance=function(t){return arguments.length?(c="function"==typeof t?t:ia(+t),g(),f):c},f}ra.copy=function(){var t,n,e=new na(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return e;if(!r.length)return e._root=ea(r),e;for(t=[{source:r,target:e._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(8)}):r.target[i]=ea(n));return e},ra.add=function(t){const n=+this._x.call(null,t),e=+this._y.call(null,t),r=+this._z.call(null,t);return Yo(this.cover(n,e,r),n,e,r,t)},ra.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,e=new Float64Array(n),r=new Float64Array(n),i=new Float64Array(n);let o=1/0,a=1/0,u=1/0,s=-1/0,l=-1/0,c=-1/0;for(let h,f,p,d,g=0;gs&&(s=f),pl&&(l=p),dc&&(c=d));if(o>s||a>l||u>c)return this;this.cover(o,a,u).cover(s,l,c);for(let o=0;ot||t>=a||i>n||n>=u||o>e||e>=s;)switch(c=(e_||(a=h.y0)>y||(u=h.z0)>v||(s=h.x1)=k)<<2|(n>=w)<<1|t>=b)&&(h=m[m.length-1],m[m.length-1]=m[m.length-1-f],m[m.length-1-f]=h)}else{var M=t-+this._x.call(null,x.data),A=n-+this._y.call(null,x.data),z=e-+this._z.call(null,x.data),S=M*M+A*A+z*z;if(S{if(!h.length)do{const o=h.data;Zo(t,n,e,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(h=h.next);return f>s||p>l||d>c||g=(s=(y+x)/2))?y=s:x=s,(f=a>=(l=(v+b)/2))?v=l:b=l,(p=u>=(c=(m+w)/2))?m=c:w=c,n=_,!(_=_[d=p<<2|f<<1|h]))return this;if(!_.length)break;(n[d+1&7]||n[d+2&7]||n[d+3&7]||n[d+4&7]||n[d+5&7]||n[d+6&7]||n[d+7&7])&&(e=n,g=d)}for(;_.data!==t;)if(r=_,!(_=_.next))return this;return(i=_.next)&&delete _.next,r?(i?r.next=i:delete r.next,this):n?(i?n[d]=i:delete n[d],(_=n[0]||n[1]||n[2]||n[3]||n[4]||n[5]||n[6]||n[7])&&_===(n[7]||n[6]||n[5]||n[4]||n[3]||n[2]||n[1]||n[0])&&!_.length&&(e?e[g]=_:this._root=_),this):(this._root=i,this)},ra.removeAll=function(t){for(var n=0,e=t.length;n(t=(1664525*t+1013904223)%la)/la}();function p(){d(),h.call("tick",e),i1&&(null==c.fy?c.y+=c.vy*=s:(c.y=c.fy,c.vy=0)),r>2&&(null==c.fz?c.z+=c.vz*=s:(c.z=c.fz,c.vz=0));return e}function g(){for(var n,e=0,i=t.length;e1&&isNaN(n.y)||r>2&&isNaN(n.z)){var o=10*(r>2?Math.cbrt(.5+e):r>1?Math.sqrt(.5+e):e),a=e*pa,u=e*da;1===r?n.x=o:2===r?(n.x=o*Math.cos(a),n.y=o*Math.sin(a)):(n.x=o*Math.sin(a)*Math.cos(u),n.y=o*Math.cos(a),n.z=o*Math.sin(a)*Math.sin(u))}(isNaN(n.vx)||r>1&&isNaN(n.vy)||r>2&&isNaN(n.vz))&&(n.vx=0,r>1&&(n.vy=0),r>2&&(n.vz=0))}}function _(n){return n.initialize&&n.initialize(t,f,r),n}return null==t&&(t=[]),g(),e={tick:d,restart:function(){return c.restart(p),e},stop:function(){return c.stop(),e},numDimensions:function(t){return arguments.length?(r=Math.min(3,Math.max(1,Math.round(t))),l.forEach(_),e):r},nodes:function(n){return arguments.length?(t=n,g(),l.forEach(_),e):t},alpha:function(t){return arguments.length?(i=+t,e):i},alphaMin:function(t){return arguments.length?(o=+t,e):o},alphaDecay:function(t){return arguments.length?(a=+t,e):+a},alphaTarget:function(t){return arguments.length?(u=+t,e):u},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(f=t,l.forEach(_),e):f},force:function(t,n){return arguments.length>1?(null==n?l.delete(t):l.set(t,_(n)),e):l.get(t)},find:function(){var n,e,i,o,a,u,s=Array.prototype.slice.call(arguments),l=s.shift()||0,c=(r>1?s.shift():null)||0,h=(r>2?s.shift():null)||0,f=s.shift()||1/0,p=0,d=t.length;for(f*=f,p=0;p1?(h.on(t,n),e):h.on(t)}}}function _a(){var t,n,e,r,i,o,a=ia(-30),u=1,s=1/0,l=.81;function c(r){var o,a=t.length,u=(1===n?Do(t,ca):2===n?Ho(t,ca,ha):3===n?ta(t,ca,ha,fa):null).visitAfter(f);for(i=r,o=0;o1&&(t.y=a/c),n>2&&(t.z=u/c)}else{(e=t).x=e.data.x,n>1&&(e.y=e.data.y),n>2&&(e.z=e.data.z);do{l+=o[e.data.index]}while(e=e.next)}t.value=l}function p(t,a,c,h,f){if(!t.value)return!0;var p=[c,h,f][n-1],d=t.x-e.x,g=n>1?t.y-e.y:0,_=n>2?t.z-e.z:0,y=p-a,v=d*d+g*g+_*_;if(y*y/l1&&0===g&&(v+=(g=oa(r))*g),n>2&&0===_&&(v+=(_=oa(r))*_),v1&&(e.vy+=g*t.value*i/v),n>2&&(e.vz+=_*t.value*i/v)),!0;if(!(t.length||v>=s)){(t.data!==e||t.next)&&(0===d&&(v+=(d=oa(r))*d),n>1&&0===g&&(v+=(g=oa(r))*g),n>2&&0===_&&(v+=(_=oa(r))*_),v1&&(e.vy+=g*y),n>2&&(e.vz+=_*y))}while(t=t.next)}}return c.initialize=function(e,...i){t=e,r=i.find(t=>"function"==typeof t)||Math.random,n=i.find(t=>[1,2,3].includes(t))||2,h()},c.strength=function(t){return arguments.length?(a="function"==typeof t?t:ia(+t),h(),c):a},c.distanceMin=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.theta=function(t){return arguments.length?(l=t*t,c):Math.sqrt(l)},c}const{abs:ya,cos:va,sin:ma,acos:xa,atan2:ba,sqrt:wa,pow:ka}=Math;function Ma(t){return t<0?-ka(-t,1/3):ka(t,1/3)}const Aa=Math.PI,za=2*Aa,Sa=Aa/2,Ca=Number.MAX_SAFE_INTEGER||9007199254740991,Ea=Number.MIN_SAFE_INTEGER||-9007199254740991,Pa={x:0,y:0,z:0},Oa={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,n){const e=n(t);let r=e.x*e.x+e.y*e.y;return void 0!==e.z&&(r+=e.z*e.z),wa(r)},compute:function(t,n,e){if(0===t)return n[0].t=0,n[0];const r=n.length-1;if(1===t)return n[r].t=1,n[r];const i=1-t;let o=n;if(0===r)return n[0].t=t,n[0];if(1===r){const n={x:i*o[0].x+t*o[1].x,y:i*o[0].y+t*o[1].y,t:t};return e&&(n.z=i*o[0].z+t*o[1].z),n}if(r<4){let n,a,u,s=i*i,l=t*t,c=0;2===r?(o=[o[0],o[1],o[2],Pa],n=s,a=i*t*2,u=l):3===r&&(n=s*i,a=s*t*3,u=i*l*3,c=t*l);const h={x:n*o[0].x+a*o[1].x+u*o[2].x+c*o[3].x,y:n*o[0].y+a*o[1].y+u*o[2].y+c*o[3].y,t:t};return e&&(h.z=n*o[0].z+a*o[1].z+u*o[2].z+c*o[3].z),h}const a=JSON.parse(JSON.stringify(n));for(;a.length>1;){for(let n=0;n1;i--,o--){const t=[];for(let e,i=0;io.x.min&&(n=o.x.min),e>o.y.min&&(e=o.y.min),r0&&(a.c1=n,a.c2=r,a.s1=t,a.s2=e,o.push(a))})}),o},makeshape:function(t,n,e){const r=n.points.length,i=t.points.length,o=Oa.makeline(n.points[r-1],t.points[0]),a=Oa.makeline(t.points[i-1],n.points[0]),u={startcap:o,forward:t,back:n,endcap:a,bbox:Oa.findbbox([o,t,n,a]),intersections:function(t){return Oa.shapeintersections(u,u.bbox,t,t.bbox,e)}};return u},getminmax:function(t,n,e){if(!e)return{min:0,max:0};let r,i,o=Ca,a=Ea;-1===e.indexOf(0)&&(e=[0].concat(e)),-1===e.indexOf(1)&&e.push(1);for(let u=0,s=e.length;ua&&(a=i[n]);return{min:o,mid:(o+a)/2,max:a,size:a-o}},align:function(t,n){const e=n.p1.x,r=n.p1.y,i=-ba(n.p2.y-r,n.p2.x-e);return t.map(function(t){return{x:(t.x-e)*va(i)-(t.y-r)*ma(i),y:(t.x-e)*ma(i)+(t.y-r)*va(i)}})},roots:function(t,n){n=n||{p1:{x:0,y:0},p2:{x:1,y:0}};const e=t.length-1,r=Oa.align(t,n),i=function(t){return 0<=t&&t<=1};if(2===e){const t=r[0].y,n=r[1].y,e=r[2].y,o=t-2*n+e;if(0!==o){const r=-wa(n*n-t*e),a=-t+n;return[-(r+a)/o,-(-r+a)/o].filter(i)}return n!==e&&0===o?[(2*n-e)/(2*n-2*e)].filter(i):[]}const o=r[0].y,a=r[1].y,u=r[2].y;let s=3*a-o-3*u+r[3].y,l=3*o-6*a+3*u,c=-3*o+3*a,h=o;if(Oa.approximately(s,0)){if(Oa.approximately(l,0))return Oa.approximately(c,0)?[]:[-h/c].filter(i);const t=wa(c*c-4*l*h),n=2*l;return[(t-c)/n,(-c-t)/n].filter(i)}l/=s,c/=s,h/=s;const f=(3*c-l*l)/3,p=f/3,d=(2*l*l*l-9*l*c+27*h)/27,g=d/2,_=g*g+p*p*p;let y,v,m,x,b;if(_<0){const t=-f/3,n=wa(t*t*t),e=-d/(2*n),r=xa(e<-1?-1:e>1?1:e),o=2*Ma(n);return m=o*va(r/3)-l/3,x=o*va((r+za)/3)-l/3,b=o*va((r+2*za)/3)-l/3,[m,x,b].filter(i)}if(0===_)return y=g<0?Ma(-g):-Ma(g),m=2*y-l/3,x=-y-l/3,[m,x].filter(i);{const t=wa(_);return y=Ma(-g+t),v=Ma(g+t),[y-v-l/3].filter(i)}},droots:function(t){if(3===t.length){const n=t[0],e=t[1],r=t[2],i=n-2*e+r;if(0!==i){const t=-wa(e*e-n*r),o=-n+e;return[-(t+o)/i,-(-t+o)/i]}return e!==r&&0===i?[(2*e-r)/(2*(e-r))]:[]}if(2===t.length){const n=t[0],e=t[1];return n!==e?[n/(n-e)]:[]}return[]},curvature:function(t,n,e,r,i){let o,a,u,s,l=0,c=0;const h=Oa.compute(t,n),f=Oa.compute(t,e),p=h.x*h.x+h.y*h.y;if(r?(o=wa(ka(h.y*f.z-f.y*h.z,2)+ka(h.z*f.x-f.z*h.x,2)+ka(h.x*f.y-f.x*h.y,2)),a=ka(p+h.z*h.z,1.5)):(o=h.x*f.y-h.y*f.x,a=ka(p,1.5)),0===o||0===a)return{k:0,r:0};if(l=o/a,c=a/o,!i){const i=Oa.curvature(t-.001,n,e,r,!0).k,o=Oa.curvature(t+.001,n,e,r,!0).k;s=(o-l+(l-i))/2,u=(ya(o-l)+ya(l-i))/2}return{k:l,r:c,dk:s,adk:u}},inflections:function(t){if(t.length<4)return[];const n=Oa.align(t,{p1:t[0],p2:t.slice(-1)[0]}),e=n[2].x*n[1].y,r=n[3].x*n[1].y,i=n[1].x*n[2].y,o=18*(-3*e+2*r+3*i-n[3].x*n[2].y),a=18*(3*e-r-3*i),u=18*(i-e);if(Oa.approximately(o,0)){if(!Oa.approximately(a,0)){let t=-u/a;if(0<=t&&t<=1)return[t]}return[]}const s=2*o;if(Oa.approximately(s,0))return[];const l=a*a-4*o*u;if(l<0)return[];const c=Math.sqrt(l);return[(c-a)/s,-(a+c)/s].filter(function(t){return 0<=t&&t<=1})},bboxoverlap:function(t,n){const e=["x","y"],r=e.length;for(let i,o,a,u,s=0;s=u)return!1;return!0},expandbox:function(t,n){n.x.mint.x.max&&(t.x.max=n.x.max),n.y.max>t.y.max&&(t.y.max=n.y.max),n.z&&n.z.max>t.z.max&&(t.z.max=n.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,n,e){const r=t.bbox(),i=n.bbox(),o=1e5,a=e||.5;if(r.x.size+r.y.sizek||k>M)&&(w+=za),w>M&&(b=M,M=w,w=b)):M4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");r=!0}}else if(6!==i&&8!==i&&9!==i&&12!==i&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const o=this._3d=!r&&(9===i||12===i)||t&&t[0]&&void 0!==t[0].z,a=this.points=[];for(let t=0,e=o?3:2;tt+ja(n.y),0)0}length(){return Oa.length(this.derivative.bind(this))}static getABC(t=2,n,e,r,i=.5){const o=Oa.projectionratio(i,t),a=1-o,u={x:o*n.x+a*r.x,y:o*n.y+a*r.y},s=Oa.abcratio(i,t);return{A:{x:e.x+(e.x-u.x)/s,y:e.y+(e.y-u.y)/s},B:e,C:u,S:n,E:r}}getABC(t,n){n=n||this.get(t);let e=this.points[0],r=this.points[this.order];return qa.getABC(this.order,e,n,r,t)}getLUT(t){if(this.verify(),t=t||100,this._lut.length===t+1)return this._lut;this._lut=[],t++,this._lut=[];for(let n,e,r=0;r1?1:h,s=this.compute(h),s.t=h,s.d=l,s}get(t){return this.compute(t)}point(t){return this.points[t]}compute(t){return this.ratios?Oa.computeWithRatios(t,this.points,this.ratios,this._3d):Oa.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,n=[t[0]],e=t.length;for(let r,i,o=1;o1;){e=[];for(let o,a=0,u=n.length-1;a=0&&t<=1}),n=n.concat(t[e].sort(Oa.numberSort))}.bind(this)),t.values=n.sort(Oa.numberSort).filter(function(t,e){return n.indexOf(t)===e}),t}bbox(){const t=this.extrema(),n={};return this.dims.forEach(function(e){n[e]=Oa.getminmax(this,e,t[e])}.bind(this)),n}overlaps(t){const n=this.bbox(),e=t.bbox();return Oa.bboxoverlap(n,e)}offset(t,n){if(void 0!==n){const e=this.get(t),r=this.normal(t),i={c:e,n:r,x:e.x+r.x*n,y:e.y+r.y*n};return this._3d&&(i.z=e.z+r.z*n),i}if(this._linear){const n=this.normal(0),e=this.points.map(function(e){const r={x:e.x+t*n.x,y:e.y+t*n.y};return e.z&&n.z&&(r.z=e.z+t*n.z),r});return[new qa(e)]}return this.reduce().map(function(n){return n._linear?n.offset(t)[0]:n.scale(t)})}simple(){if(3===this.order){const t=Oa.angle(this.points[0],this.points[3],this.points[1]),n=Oa.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&n<0||t<0&&n>0)return!1}const t=this.normal(0),n=this.normal(1);let e=t.x*n.x+t.y*n.y;return this._3d&&(e+=t.z*n.z),ja(Ua(e))(1-i/r)*n+i/r*e);return new qa(this.points.map((n,e)=>({x:n.x+t.x*i[e],y:n.y+t.y*i[e]})))}scale(t){const n=this.order;let e=!1;if("function"==typeof t&&(e=t),e&&2===n)return this.raise().scale(e);const r=this.clockwise,i=this.points;if(this._linear)return this.translate(this.normal(0),e?e(0):t,e?e(1):t);const o=e?e(0):t,a=e?e(1):t,u=[this.offset(0,10),this.offset(1,10)],s=[],l=Oa.lli4(u[0],u[0].c,u[1],u[1].c);if(!l)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(t){const e=s[t*n]=Oa.copy(i[t*n]);e.x+=(t?a:o)*u[t].n.x,e.y+=(t?a:o)*u[t].n.y}),e?([0,1].forEach(function(o){if(2!==n||!o){var a=i[o+1],u={x:a.x-l.x,y:a.y-l.y},c=e?e((o+1)/n):t;e&&!r&&(c=-c);var h=Fa(u.x*u.x+u.y*u.y);u.x/=h,u.y/=h,s[o+1]={x:a.x+c*u.x,y:a.y+c*u.y}}}),new qa(s)):([0,1].forEach(t=>{if(2===n&&t)return;const e=s[t*n],r=this.derivative(t),o={x:e.x+r.x,y:e.y+r.y};s[t+1]=Oa.lli4(e,o,l,i[t+1])}),new qa(s))}outline(t,n,e,r){if(n=void 0===n?t:n,this._linear){const i=this.normal(0),o=this.points[0],a=this.points[this.points.length-1];let u,s,l;void 0===e&&(e=t,r=n),u={x:o.x+i.x*t,y:o.y+i.y*t},l={x:a.x+i.x*e,y:a.y+i.y*e},s={x:(u.x+l.x)/2,y:(u.y+l.y)/2};const c=[u,s,l];u={x:o.x-i.x*n,y:o.y-i.y*n},l={x:a.x-i.x*r,y:a.y-i.y*r},s={x:(u.x+l.x)/2,y:(u.y+l.y)/2};const h=[l,s,u],f=Oa.makeline(h[2],c[0]),p=Oa.makeline(c[2],h[0]),d=[f,new qa(c),p,new qa(h)];return new Na(d)}const i=this.reduce(),o=i.length,a=[];let u,s=[],l=0,c=this.length();const h=void 0!==e&&void 0!==r;function f(t,n,e,r,i){return function(o){const a=r/e,u=(r+i)/e,s=n-t;return Oa.map(o,0,1,t+a*s,t+u*s)}}i.forEach(function(i){const o=i.length();h?(a.push(i.scale(f(t,e,c,l,o))),s.push(i.scale(f(-n,-r,c,l,o)))):(a.push(i.scale(t)),s.push(i.scale(-n))),l+=o}),s=s.map(function(t){return u=t.points,u[3]?t.points=[u[3],u[2],u[1],u[0]]:t.points=[u[2],u[1],u[0]],t}).reverse();const p=a[0].points[0],d=a[o-1].points[a[o-1].points.length-1],g=s[o-1].points[s[o-1].points.length-1],_=s[0].points[0],y=Oa.makeline(g,p),v=Oa.makeline(d,_),m=[y].concat(a).concat([v]).concat(s);return new Na(m)}outlineshapes(t,n,e){n=n||t;const r=this.outline(t,n).curves,i=[];for(let t=1,n=r.length;t1,o.endcap.virtual=t{var o=this.get(t);return Oa.between(o.x,n,r)&&Oa.between(o.y,e,i)})}selfintersects(t){const n=this.reduce(),e=n.length-2,r=[];for(let i,o,a,u=0;u0&&(i=i.concat(n))}),i}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,n,e,r){const i=(r-e)/4,o=this.get(e+i),a=this.get(r-i),u=Oa.dist(t,n),s=Oa.dist(t,o),l=Oa.dist(t,a);return ja(s-u)+ja(l-u)}_iterate(t,n){let e,r=0,i=1;do{e=0,i=1;let o,a,u,s,l,c=this.get(r),h=!1,f=!1,p=i,d=1;do{if(f=h,s=u,p=(r+i)/2,o=this.get(p),a=this.get(i),u=Oa.getccenter(c,o,a),u.interval={start:r,end:i},h=this._error(u,c,r,i)<=t,l=f&&!h,l||(d=i),h){if(i>=1){if(u.interval.end=d=1,s=u,i>1){let t={x:u.x+u.r*Da(u.e),y:u.y+u.r*Ia(u.e)};u.e+=Oa.angle({x:u.x,y:u.y},t,this.get(1))}break}i+=(i-r)/2}else i=p}while(!l&&e++<100);if(e>=100)break;s=s||u,n.push(s),r=d}while(i<1);return n}}function $a(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],e=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=(n instanceof Array?n.length?n:[void 0]:[n]).map(function(t){return{keyAccessor:t,isProp:!(t instanceof Function)}}),o=t.reduce(function(t,n){var r=t,o=n;return i.forEach(function(t,n){var a,u=t.keyAccessor;if(t.isProp){var s=o,l=s[u],c=function(t,n){if(null==t)return{};var e,r,i=function(t,n){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(n.includes(r))continue;e[r]=t[r]}return e}(t,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r1&&void 0!==arguments[1]?arguments[1]:1;r===i.length?Object.keys(n).forEach(function(t){return n[t]=e(n[t])}):Object.values(n).forEach(function(n){return t(n,r+1)})}(o);var a=o;return r&&(a=[],function t(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.length===i.length?a.push({keys:e,vals:n}):Object.entries(n).forEach(function(n){var r=Ba(n,2),i=r[0],o=r[1];return t(o,[].concat(Ha(e),[i]))})}(o),n instanceof Array&&0===n.length&&1===a.length&&(a[0].keys=[])),a};function Ya(t,n){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(n).domain(t)}return this}const Wa=Symbol("implicit");var Za=function(t){for(var n=t.length/6|0,e=new Array(n),r=0;rt.cooldownTicks||new Date-t.startTickTime>t.cooldownTime||t.d3AlphaMin>0&&t.forceLayout.alpha()0){var a=Math.atan2(r.y-e.y,r.x-e.x),u=i*n,s={x:(e.x+r.x)/2+u*Math.cos(a-Math.PI/2),y:(e.y+r.y)/2+u*Math.sin(a-Math.PI/2)};t.__controlPoints=[s.x,s.y]}else{var l=70*n;t.__controlPoints=[r.x,r.y-l,r.x+l,r.y]}});var f=[],p=[],d=h;if(t.linkCanvasObject){var g=[],_=[];h.forEach(function(t){return({before:f,after:p,replace:g}[a(t)]||_).push(t)}),d=[].concat(s(f),p,_),f=f.concat(g)}l.save(),f.forEach(function(n){return t.linkCanvasObject(n,l,t.globalScale)}),l.restore();var y=Ga(d,[e,r,i]);l.save(),Object.entries(y).forEach(function(n){var e=u(n,2),r=e[0],o=e[1],a=r&&"undefined"!==r?r:"rgba(0,0,0,0.15)";Object.entries(o).forEach(function(n){var e=u(n,2),r=e[0],o=e[1],h=(r||1)/t.globalScale+c;Object.entries(o).forEach(function(t){var n=u(t,2);n[0];var e=n[1],r=i(e[0]);l.beginPath(),e.forEach(function(t){var n=t.source,e=t.target;if(n&&e&&n.hasOwnProperty("x")&&e.hasOwnProperty("x")){l.moveTo(n.x,n.y);var r=t.__controlPoints;r?l[2===r.length?"quadraticCurveTo":"bezierCurveTo"].apply(l,s(r).concat([e.x,e.y])):l.lineTo(e.x,e.y)}}),l.strokeStyle=a,l.lineWidth=h,l.setLineDash(r||[]),l.stroke()})})}),l.restore(),l.save(),p.forEach(function(n){return t.linkCanvasObject(n,l,t.globalScale)}),l.restore()}(),!t.isShadow&&(n=Ir(t.linkDirectionalArrowLength),r=Ir(t.linkDirectionalArrowRelPos),i=Ir(t.linkVisibility),o=Ir(t.linkDirectionalArrowColor||t.linkColor),a=Ir(t.nodeVal),(l=t.ctx).save(),t.graphData.links.filter(i).forEach(function(i){var u=n(i);if(u&&!(u<0)){var c=i.source,h=i.target;if(c&&h&&c.hasOwnProperty("x")&&h.hasOwnProperty("x")){var f=Math.sqrt(Math.max(0,a(c)||1))*t.nodeRelSize,p=Math.sqrt(Math.max(0,a(h)||1))*t.nodeRelSize,d=Math.min(1,Math.max(0,r(i))),g=o(i)||"rgba(0,0,0,0.28)",_=u/1.6/2,y=i.__controlPoints&&e(qa,[c.x,c.y].concat(s(i.__controlPoints),[h.x,h.y])),v=y?function(t){return y.get(t)}:function(t){return{x:c.x+(h.x-c.x)*t||0,y:c.y+(h.y-c.y)*t||0}},m=y?y.length():Math.sqrt(Math.pow(h.x-c.x,2)+Math.pow(h.y-c.y,2)),x=f+u+(m-f-p-u)*d,b=v(x/m),w=v((x-u)/m),k=v((x-.8*u)/m),M=Math.atan2(b.y-w.y,b.x-w.x)-Math.PI/2;l.beginPath(),l.moveTo(b.x,b.y),l.lineTo(w.x+_*Math.cos(M),w.y+_*Math.sin(M)),l.lineTo(k.x,k.y),l.lineTo(w.x-_*Math.cos(M),w.y-_*Math.sin(M)),l.fillStyle=g,l.fill()}}}),l.restore()),!t.isShadow&&function(){var n=Ir(t.linkDirectionalParticles),r=Ir(t.linkDirectionalParticleSpeed),i=Ir(t.linkDirectionalParticleOffset),o=Ir(t.linkDirectionalParticleWidth),a=Ir(t.linkVisibility),u=Ir(t.linkDirectionalParticleColor||t.linkColor),l=t.ctx;l.save(),t.graphData.links.filter(a).forEach(function(a){var c=n(a);if(a.hasOwnProperty("__photons")&&a.__photons.length){var h=a.source,f=a.target;if(h&&f&&h.hasOwnProperty("x")&&f.hasOwnProperty("x")){var p=r(a),d=Math.abs(i(a)),g=a.__photons||[],_=Math.max(0,o(a)/2)/Math.sqrt(t.globalScale),y=u(a)||"rgba(0,0,0,0.28)";l.fillStyle=y;var v=a.__controlPoints?e(qa,[h.x,h.y].concat(s(a.__controlPoints),[f.x,f.y])):null,m=0,x=!1;g.forEach(function(n){var e=!!n.__singleHop;if(n.hasOwnProperty("__progressRatio")||(n.__progressRatio=e?p<0?1:0:(m+d)/c),!e&&m++,n.__progressRatio+=p,n.__progressRatio>=1||n.__progressRatio<0){if(e)return void(x=!0);n.__progressRatio=n.__progressRatio%1,n.__progressRatio<0&&n.__progressRatio++}var r=n.__progressRatio,i=v?v.get(r):{x:h.x+(f.x-h.x)*r||0,y:h.y+(f.y-h.y)*r||0};t.linkDirectionalParticleCanvasObject?t.linkDirectionalParticleCanvasObject(i.x,i.y,a,l,t.globalScale):(l.beginPath(),l.arc(i.x,i.y,_,0,2*Math.PI,!1),l.fill())}),x&&(a.__photons=a.__photons.filter(function(t){return!t.__singleHop||t.__progressRatio<=1&&t.__progressRatio>=0}))}}}),l.restore()}(),function(){var n=Ir(t.nodeVisibility),e=Ir(t.nodeVal),r=Ir(t.nodeColor),i=Ir(t.nodeCanvasObjectMode),o=t.ctx,a=t.isShadow/t.globalScale,u=t.graphData.nodes.filter(n);o.save(),u.forEach(function(n){var u=i(n);if(!t.nodeCanvasObject||"before"!==u&&"replace"!==u||(t.nodeCanvasObject(n,o,t.globalScale),"replace"!==u)){var s=Math.sqrt(Math.max(0,e(n)||1))*t.nodeRelSize+a;o.beginPath(),o.arc(n.x,n.y,s,0,2*Math.PI,!1),o.fillStyle=r(n)||"rgba(31, 120, 180, 0.92)",o.fill(),t.nodeCanvasObject&&"after"===u&&t.nodeCanvasObject(n,t.ctx,t.globalScale)}else o.restore()}),o.restore()}(),this},emitParticle:function(t,n){return n&&(!n.__photons&&(n.__photons=[]),n.__photons.push({__singleHop:!0})),this}},stateInit:function(){return{forceLayout:ga().force("link",sa()).force("charge",_a()).force("center",No()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(t,n){n.ctx=t},update:function(t,n){t.engineRunning=!1,t.onUpdate(),null!==t.nodeAutoColorBy&&Ka(t.graphData.nodes,Ir(t.nodeAutoColorBy),t.nodeColor),null!==t.linkAutoColorBy&&Ka(t.graphData.links,Ir(t.linkAutoColorBy),t.linkColor),t.graphData.links.forEach(function(n){n.source=n[t.linkSource],n.target=n[t.linkTarget]}),t.forceLayout.stop().alpha(1).nodes(t.graphData.nodes);var e=t.forceLayout.force("link");e&&e.id(function(n){return n[t.nodeId]}).links(t.graphData.links);var i=t.dagMode&&function(t,n){var e=t.nodes,i=t.links,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=o.nodeFilter,c=void 0===a?function(){return!0}:a,h=o.onLoopError,f=void 0===h?function(t){throw"Invalid DAG structure! Found cycle in node path: ".concat(t.join(" -> "),".")}:h,p={};e.forEach(function(t){return p[n(t)]={data:t,out:[],depth:-1,skip:!c(t)}}),i.forEach(function(t){var e=t.source,r=t.target,i=s(e),o=s(r);if(!p.hasOwnProperty(i))throw"Missing source node with id: ".concat(i);if(!p.hasOwnProperty(o))throw"Missing target node with id: ".concat(o);var a=p[i],u=p[o];function s(t){return"object"===l(t)?n(t):t}a.out.push(u)});var d=[];return function t(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=function(){var o=e[a];if(-1!==r.indexOf(o)){var u=[].concat(s(r.slice(r.indexOf(o))),[o]).map(function(t){return n(t.data)});return d.some(function(t){return t.length===u.length&&t.every(function(t,n){return t===u[n]})})||(d.push(u),f(u)),1}i>o.depth&&(o.depth=i,t(o.out,[].concat(s(r),[o]),i+(o.skip?0:1)))},a=0,u=e.length;a1&&(c.vy+=f*g),o>2&&(c.vz+=p*g)}}function c(){if(i){var n,e=i.length;for(a=new Array(e),u=new Array(e),n=0;n[1,2,3].includes(t))||2,c()},l.strength=function(t){return arguments.length?(s="function"==typeof t?t:ia(+t),c(),l):s},l.radius=function(n){return arguments.length?(t="function"==typeof n?n:ia(+n),c(),l):t},l.x=function(t){return arguments.length?(n=+t,l):n},l.y=function(t){return arguments.length?(e=+t,l):e},l.z=function(t){return arguments.length?(r=+t,l):r},l}(function(n){var e=i[n[t.nodeId]]||-1;return("radialin"===t.dagMode?o-e:e)*a}).strength(function(n){return t.dagNodeFilter(n)?1:0}):null);for(var p=0;p0&&t.forceLayout.alpha()1?r-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,r=arguments.length,i=new Array(r>3?r-3:0),o=3;o1&&void 0!==arguments[1]?arguments[1]:function(){return!0},e=Ir(t.nodeVal),r=function(n){return Math.sqrt(Math.max(0,e(n)||1))*t.nodeRelSize},i=t.graphData.nodes.filter(n).map(function(t){return{x:t.x,y:t.y,r:r(t)}});return i.length?{x:[Je(i,function(t){return t.x-t.r}),Ke(i,function(t){return t.x+t.r})],y:[Je(i,function(t){return t.y-t.r}),Ke(i,function(t){return t.y+t.r})]}:null},pauseAnimation:function(t){return t.animationFrameRequestId&&(cancelAnimationFrame(t.animationFrameRequestId),t.animationFrameRequestId=null),this},resumeAnimation:function(t){return t.animationFrameRequestId||this._animationCycle(),this},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},au),stateInit:function(){return{lastSetZoom:1,zoom:Ye(),forceGraph:new nu,shadowGraph:(new nu).cooldownTicks(0).nodeColor("__indexColor").linkColor("__indexColor").isShadow(!0),colorTracker:new Xi,tweenGroup:new zr}},init:function(t,n){var e=this;t.innerHTML="";var r=document.createElement("div");r.classList.add("force-graph-container"),r.style.position="relative",t.appendChild(r),n.canvas=document.createElement("canvas"),n.backgroundColor&&(n.canvas.style.background=n.backgroundColor),r.appendChild(n.canvas),n.shadowCanvas=document.createElement("canvas");var i=n.canvas.getContext("2d"),o=n.shadowCanvas.getContext("2d",{willReadFrequently:!0}),u={x:-1e12,y:-1e12},s=function(){var t=null,e=window.devicePixelRatio,r=u.x>0&&u.y>0?o.getImageData(u.x*e,u.y*e,1,1):null;return r&&(t=n.colorTracker.lookup(r.data)),t};kt(n.canvas).call(function(){var t,n,e,r,i=Ut,o=Ft,a=Lt,u=qt,s={},l=zt("start","drag","end"),c=0,h=0;function f(t){t.on("mousedown.drag",p).filter(u).on("touchstart.drag",_).on("touchmove.drag",y,Pt).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(a,u){if(!r&&i.call(this,a,u)){var s=m(this,o.call(this,a,u),a,u,"mouse");s&&(kt(a.view).on("mousemove.drag",d,Ot).on("mouseup.drag",g,Ot),Tt(a.view),Nt(a),e=!1,t=a.clientX,n=a.clientY,s("start",a))}}function d(r){if(jt(r),!e){var i=r.clientX-t,o=r.clientY-n;e=i*i+o*o>h}s.mouse("drag",r)}function g(t){kt(t.view).on("mousemove.drag mouseup.drag",null),Rt(t.view,e),jt(t),s.mouse("end",t)}function _(t,n){if(i.call(this,t,n)){var e,r,a=t.changedTouches,u=o.call(this,t,n),s=a.length;for(e=0;e=Math.sqrt(function(t){let n=0;for(let e of t)(e=+e)&&(n+=e);return n}(["x","y"].map(function(n){return Math.pow(t[n]-r[n],2)})))||(n.forceGraph.d3AlphaTarget(.3).resetCountdown(),n.isPointerDragging=!0,e.__dragged=!0,n.onNodeDrag(e,a))}).on("end",function(t){var e=t.subject,r=e.__initialDragPos,i={x:e.x-r.x,y:e.y-r.y};void 0===r.fx&&(e.fx=void 0),void 0===r.fy&&(e.fy=void 0),delete e.__initialDragPos,n.forceGraph.d3AlphaTarget()&&n.forceGraph.d3AlphaTarget(0).resetCountdown(),n.canvas.classList.remove("grabbable"),n.isPointerDragging=!1,e.__dragged&&(delete e.__dragged,n.onNodeDragEnd(e,i))})),n.zoom(n.zoom.__baseElem=kt(n.canvas)),n.zoom.__baseElem.on("dblclick.zoom",null),n.zoom.filter(function(t){return!t.button&&n.enableZoomPanInteraction&&("wheel"!==t.type||Ir(n.enableZoomInteraction)(t))&&("wheel"===t.type||Ir(n.enablePanInteraction)(t))}).on("zoom",function(t){var r=t.transform;[i,o].forEach(function(t){su(t),t.translate(r.x,r.y),t.scale(r.k,r.k)}),n.isPointerDragging=!0,n.onZoom&&n.onZoom(a(a({},r),e.centerAt())),n.needsRedraw=!0}).on("end",function(t){n.isPointerDragging=!1,n.onZoomEnd&&n.onZoomEnd(a(a({},t.transform),e.centerAt()))}),uu(n),n.forceGraph.onNeedsRedraw(function(){return n.needsRedraw=!0}).onFinishUpdate(function(){Fe(n.canvas).k===n.lastSetZoom&&n.graphData.nodes.length&&(n.zoom.scaleTo(n.zoom.__baseElem,n.lastSetZoom=4/Math.cbrt(n.graphData.nodes.length)),n.needsRedraw=!0)}),n.tooltip=new Oo(r),["pointermove","pointerdown"].forEach(function(t){return r.addEventListener(t,function(e){"pointerdown"===t&&(n.isPointerPressed=!0,n.pointerDownEvent=e),!n.isPointerDragging&&"pointermove"===e.type&&n.onBackgroundClick&&(e.pressure>0||n.isPointerPressed)&&("mouse"===e.pointerType||void 0===e.movementX||[e.movementX,e.movementY].some(function(t){return Math.abs(t)>1}))&&(n.isPointerDragging=!0);var i,o,a,s=(i=r.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,a=window.pageYOffset||document.documentElement.scrollTop,{top:i.top+a,left:i.left+o});u.x=e.pageX-s.left,u.y=e.pageY-s.top},{passive:!0})}),r.addEventListener("pointerup",function(t){if(n.isPointerPressed)if(n.isPointerPressed=!1,n.isPointerDragging)n.isPointerDragging=!1;else{var e=[t,n.pointerDownEvent];requestAnimationFrame(function(){if(0===t.button)if(n.hoverObj){var r=n["on".concat(n.hoverObj.type,"Click")];r&&r.apply(void 0,[n.hoverObj.d].concat(e))}else n.onBackgroundClick&&n.onBackgroundClick.apply(n,e);if(2===t.button)if(n.hoverObj){var i=n["on".concat(n.hoverObj.type,"RightClick")];i&&i.apply(void 0,[n.hoverObj.d].concat(e))}else n.onBackgroundRightClick&&n.onBackgroundRightClick.apply(n,e)})}},{passive:!0}),r.addEventListener("contextmenu",function(t){return!(n.onBackgroundRightClick||n.onNodeRightClick||n.onLinkRightClick)||(t.preventDefault(),!1)}),n.forceGraph(i),n.shadowGraph(o);var l=function(t,n,e){var r=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return dr(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),kr(t,n,{leading:r,maxWait:n,trailing:i})}(function(){lu(o,n.width,n.height),n.shadowGraph.linkWidth(function(t){return Ir(n.linkWidth)(t)+n.linkHoverPrecision});var t=Fe(n.canvas);n.shadowGraph.globalScale(t.k).tickFrame()},800);n.flushShadowCanvas=l.flush,(this._animationCycle=function t(){var e=!n.autoPauseRedraw||!!n.needsRedraw||n.forceGraph.isEngineRunning()||n.graphData.links.some(function(t){return t.__photons&&t.__photons.length});if(n.needsRedraw=!1,n.enablePointerInteraction){var r=n.isPointerDragging?null:s();if(r!==n.hoverObj){var o=n.hoverObj,a=o?o.type:null,u=r?r.type:null;if(a&&a!==u){var c=n["on".concat(a,"Hover")];c&&c(null,o.d)}if(u){var h=n["on".concat(u,"Hover")];h&&h(r.d,a===u?o.d:null)}n.tooltip.content(r&&Ir(n["".concat(r.type.toLowerCase(),"Label")])(r.d)||null),n.canvas.classList[(r&&n["on".concat(u,"Click")]||!r&&n.onBackgroundClick)&&Ir(n.showPointerCursor)(null==r?void 0:r.d)?"add":"remove"]("clickable"),n.hoverObj=r}e&&l()}if(e){lu(i,n.width,n.height);var f=Fe(n.canvas).k;n.onRenderFramePre&&n.onRenderFramePre(i,f),n.forceGraph.globalScale(f).tickFrame(),n.onRenderFramePost&&n.onRenderFramePost(i,f)}n.tweenGroup.update(),n.animationFrameRequestId=requestAnimationFrame(t)})()},update:function(t){}});return cu}); diff --git a/internal/ui/ui.go b/internal/ui/ui.go new file mode 100644 index 0000000..8c98688 --- /dev/null +++ b/internal/ui/ui.go @@ -0,0 +1,33 @@ +// Package ui serves the local graph view. +// +// The assets are embedded rather than fetched, so the view works on a laptop +// with no network and cannot drift from the binary serving it. +package ui + +import ( + "embed" + "io/fs" + "net/http" +) + +//go:embed assets +var assets embed.FS + +// Handler serves the graph view at the root of whatever it is mounted on. +func Handler() http.Handler { + files, err := fs.Sub(assets, "assets") + if err != nil { + // Only reachable if the embed directive and this path disagree, which + // is a build-time mistake rather than anything a run can recover from. + panic(err) + } + return noStore(http.FileServer(http.FS(files))) +} + +// noStore keeps a browser from holding on to a view the next agent replaces. +func noStore(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Cache-Control", "no-store") + next.ServeHTTP(w, r) + }) +} diff --git a/internal/ui/ui_test.go b/internal/ui/ui_test.go new file mode 100644 index 0000000..02d50fe --- /dev/null +++ b/internal/ui/ui_test.go @@ -0,0 +1,52 @@ +package ui + +import ( + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func fetch(t *testing.T, path string) *httptest.ResponseRecorder { + t.Helper() + recorder := httptest.NewRecorder() + Handler().ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, path, nil)) + return recorder +} + +// Everything the page pulls in has to be embedded, or the view is blank on a +// machine with no network and nobody finds out until it is opened. +func TestItServesEveryAssetThePageAsksFor(t *testing.T) { + page := fetch(t, "/") + if page.Code != http.StatusOK { + t.Fatalf("got %d for the page, want 200", page.Code) + } + body := page.Body.String() + + for _, asset := range []string{"styles.css", "app.js", "vendor/force-graph.min.js", "favicon.svg"} { + if !strings.Contains(body, asset) { + t.Errorf("the page does not ask for %s", asset) + continue + } + if response := fetch(t, "/"+asset); response.Code != http.StatusOK { + t.Errorf("got %d for %s, want 200", response.Code, asset) + } + } +} + +func TestTheGraphLibraryIsWholeRatherThanAStub(t *testing.T) { + response := fetch(t, "/vendor/force-graph.min.js") + + if response.Body.Len() < 100_000 { + t.Errorf("got %d bytes, want the whole library", response.Body.Len()) + } + if !strings.Contains(response.Body.String(), "ForceGraph") { + t.Error("the vendored file does not define ForceGraph") + } +} + +func TestABrowserIsNotToldToKeepAViewTheNextAgentReplaces(t *testing.T) { + if got := fetch(t, "/").Header().Get("Cache-Control"); got != "no-store" { + t.Errorf("got Cache-Control %q, want no-store", got) + } +} From 80370b93369525489ee309ecd263d9a93b09dbb4 Mon Sep 17 00:00:00 2001 From: nfebe Date: Fri, 28 Aug 2026 22:24:36 +0100 Subject: [PATCH 03/27] feat: Start whichever core was installed The agent now reads what the installer put on this machine and starts that, rather than expecting the core on PATH. A container and a program need different command lines for the same thing: a container binding loopback binds its own, which nothing can reach, so it binds every interface inside and is published to loopback outside. It also runs a container as whoever installed. The image has a user of its own, and where that id differs, everything the container writes into the mounted index belongs to somebody who does not exist on that machine. With nothing installed it still looks for the core on PATH, which is what somebody working on the core itself already has, and naming one explicitly still wins over both. --- README.md | 8 +- cmd/agent/main.go | 30 +++++- internal/config/config.go | 9 +- internal/runtime/runtime.go | 159 +++++++++++++++++++++++++++++++ internal/runtime/runtime_test.go | 123 ++++++++++++++++++++++++ 5 files changed, 321 insertions(+), 8 deletions(-) create mode 100644 internal/runtime/runtime.go create mode 100644 internal/runtime/runtime_test.go diff --git a/README.md b/README.md index a8e08e9..578f955 100644 --- a/README.md +++ b/README.md @@ -16,17 +16,19 @@ Loopback is the default because the agent reads a working tree. The machine it r ## Running it -The core has to be on `PATH` as `sourceant`. See [sourceant/sourceant](https://github.com/sourceant/sourceant). - ```bash make build ./sourceant-agent ``` +It starts whatever `sourceant install` put on this machine, reading `~/.sourceant/config.json`: a container, or the core as a program. A container binds every interface inside and is published to loopback outside, because one binding the container's own loopback could be reached by nothing. + +With nothing installed it looks for `sourceant` on `PATH`, which is what somebody working on the core itself already has. See [sourceant/cli](https://github.com/sourceant/cli) to install one, and [sourceant/sourceant](https://github.com/sourceant/sourceant) for the core. + | Variable | Default | Meaning | |---|---|---| | `SOURCEANT_AGENT_LISTEN` | `127.0.0.1:8930` | Where the agent answers | -| `SOURCEANT_CORE` | `sourceant` | The core executable to supervise | +| `SOURCEANT_CORE` | what was installed | A core to supervise instead, overriding the install | | `SOURCEANT_CORE_PORT` | chosen at start | The port to start the core on | ## Building diff --git a/cmd/agent/main.go b/cmd/agent/main.go index 8097ccf..46b98f5 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -13,6 +13,7 @@ import ( "github.com/sourceant/agent/internal/api" "github.com/sourceant/agent/internal/config" "github.com/sourceant/agent/internal/core" + "github.com/sourceant/agent/internal/runtime" "github.com/sourceant/agent/internal/supervise" ) @@ -49,9 +50,15 @@ func run() error { coreURL := "http://127.0.0.1:" + strconv.Itoa(port) client := core.New(coreURL, 30*time.Second) + installed := resolveCore(cfg) + name, args, err := installed.Serve(port) + if err != nil { + return err + } + supervisor := supervise.New(supervise.Options{ - Name: cfg.Core, - Args: []string{"serve", "--host", "127.0.0.1", "--port", strconv.Itoa(port)}, + Name: name, + Args: args, Ready: client.Healthy, ReadyWithin: 60 * time.Second, Output: os.Stderr, @@ -67,7 +74,8 @@ func run() error { server := api.New(client, supervisor, Version, coreURL) go func() { served <- server.Serve(ctx, cfg.Listen) }() - fmt.Fprintf(os.Stderr, "sourceant-agent %s listening on %s, core on %s\n", Version, cfg.Listen, coreURL) + fmt.Fprintf(os.Stderr, "sourceant-agent %s listening on %s, core on %s (%s)\n", + Version, cfg.Listen, coreURL, installed.Describe()) // Whichever half stops first ends the agent: an agent serving without a // core answers nothing, and a core nobody serves is not reachable. @@ -78,3 +86,19 @@ func run() error { return err } } + +// resolveCore decides which core to start, most specific first. +// +// An explicit command wins, because somebody naming one means it. Then what +// the installer wrote. Then the core on PATH, which is what a person working +// on the core itself already has and what makes the agent runnable before +// anything has been installed at all. +func resolveCore(cfg config.Config) runtime.Core { + if cfg.CoreWasChosen { + return runtime.Core{Runtime: runtime.Python, Command: cfg.Core} + } + if installed, err := runtime.Load(runtime.ConfigPath()); err == nil { + return installed.Core + } + return runtime.Core{Runtime: runtime.Python, Command: cfg.Core} +} diff --git a/internal/config/config.go b/internal/config/config.go index 1d1e1d7..d3b4998 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -26,15 +26,20 @@ type Config struct { Listen string // Core is the Python executable to supervise. Core string + // CoreWasChosen says somebody named that executable, rather than it being + // the fallback. An explicit choice outranks whatever was installed. + CoreWasChosen bool // CorePort is the port to start it on, zero to pick a free one. CorePort int } // FromEnvironment reads the configuration, filling in what was not set. func FromEnvironment() (Config, error) { + chosen := os.Getenv(EnvCore) cfg := Config{ - Listen: valueOr(EnvListen, DefaultListen), - Core: valueOr(EnvCore, DefaultCore), + Listen: valueOr(EnvListen, DefaultListen), + Core: valueOr(EnvCore, DefaultCore), + CoreWasChosen: chosen != "", } if raw := os.Getenv(EnvPort); raw != "" { port, err := strconv.Atoi(raw) diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go new file mode 100644 index 0000000..a4aa680 --- /dev/null +++ b/internal/runtime/runtime.go @@ -0,0 +1,159 @@ +// Package runtime says how to start the Python core on this machine. +// +// There are two ways to have it, and which one a person chose is a fact about +// their machine rather than about either binary: the installer writes it down +// and the agent reads it. Without that file the agent looks for the core on +// PATH, which is what a developer working on the core itself already has. +package runtime + +import ( + "encoding/json" + "errors" + "fmt" + "os" + "path/filepath" + "strconv" +) + +// Kind is how the core is installed. +type Kind string + +const ( + // Python is the core as a program on this machine. + Python Kind = "python" + // Docker is the core as a container image. + Docker Kind = "docker" +) + +// DefaultImage is the published core. A tag is pinned at install time; this is +// only the fallback for a config that names none. +const DefaultImage = "ghcr.io/sourceant/sourceant:latest" + +// Core is everything needed to start the indexer. +type Core struct { + Runtime Kind `json:"runtime"` + // Command is the executable, for the python runtime. + Command string `json:"command,omitempty"` + // Image is the container, for the docker runtime. + Image string `json:"image,omitempty"` + // DataDir is where the index lives. Both runtimes must agree on it, or + // indexing and reading would address two different databases. + DataDir string `json:"data_dir,omitempty"` + // User is the uid:gid a container runs as, for the docker runtime. + // + // The image has a user of its own, and where that user's id differs from + // the person's, everything the container writes into the mounted index + // belongs to somebody who does not exist on this machine. The installer + // records who is installing so the container writes as them. + User string `json:"user,omitempty"` +} + +// Config is what the installer wrote. +type Config struct { + Core Core `json:"core"` +} + +// Home is where SourceAnt keeps what it installed. +func Home() string { + if override := os.Getenv("SOURCEANT_INSTALL_HOME"); override != "" { + return override + } + home, err := os.UserHomeDir() + if err != nil { + return ".sourceant" + } + return filepath.Join(home, ".sourceant") +} + +// ConfigPath is the file the installer writes and the agent reads. +func ConfigPath() string { return filepath.Join(Home(), "config.json") } + +// ErrNotInstalled says nothing has been installed here yet. +var ErrNotInstalled = errors.New("no runtime is installed") + +// Load reads the installed runtime. +func Load(path string) (Config, error) { + data, err := os.ReadFile(path) + if errors.Is(err, os.ErrNotExist) { + return Config{}, ErrNotInstalled + } + if err != nil { + return Config{}, err + } + var config Config + if err := json.Unmarshal(data, &config); err != nil { + return Config{}, fmt.Errorf("%s is not readable as a runtime: %w", path, err) + } + if config.Core.Runtime != Python && config.Core.Runtime != Docker { + return Config{}, fmt.Errorf("%s names runtime %q, which is neither python nor docker", path, config.Core.Runtime) + } + return config, nil +} + +// Save writes the runtime for the agent to read. +func Save(path string, config Config) error { + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { + return err + } + data, err := json.MarshalIndent(config, "", " ") + if err != nil { + return err + } + return os.WriteFile(path, append(data, '\n'), 0o644) +} + +// Serve is the command that starts the core listening on port. +// +// The two runtimes need different addresses for the same thing. A program on +// this machine binds loopback and is reached there. A container binding +// loopback would bind the container's own, reachable by nothing, so it binds +// every interface inside and is published to loopback outside. +func (c Core) Serve(port int) (string, []string, error) { + number := strconv.Itoa(port) + switch c.Runtime { + case Python: + if c.Command == "" { + return "", nil, errors.New("the python runtime names no command") + } + return c.Command, []string{"serve", "--host", "127.0.0.1", "--port", number}, nil + case Docker: + image := c.Image + if image == "" { + image = DefaultImage + } + args := []string{ + "run", "--rm", + "--name", "sourceant-core-" + number, + "-p", "127.0.0.1:" + number + ":" + number, + } + if c.DataDir != "" { + args = append(args, "-v", c.DataDir+":/data", "-e", "SOURCEANT_HOME=/data") + } + if c.User != "" { + args = append(args, "--user", c.User) + } + // The image starts a production server by default, so the entry point + // is replaced with the command line the agent actually wants. + args = append(args, "--entrypoint", "./sourceant", image, + "serve", "--host", "0.0.0.0", "--port", number) + return "docker", args, nil + default: + return "", nil, fmt.Errorf("runtime %q is neither python nor docker", c.Runtime) + } +} + +// Describe is one line naming what will be started. +func (c Core) Describe() string { + switch c.Runtime { + case Python: + return "python · " + c.Command + case Docker: + image := c.Image + if image == "" { + image = DefaultImage + } + return "docker · " + image + default: + return string(c.Runtime) + } +} diff --git a/internal/runtime/runtime_test.go b/internal/runtime/runtime_test.go new file mode 100644 index 0000000..2f5e345 --- /dev/null +++ b/internal/runtime/runtime_test.go @@ -0,0 +1,123 @@ +package runtime + +import ( + "errors" + "path/filepath" + "slices" + "strings" + "testing" +) + +func TestNothingInstalledIsSaidPlainly(t *testing.T) { + _, err := Load(filepath.Join(t.TempDir(), "config.json")) + + if !errors.Is(err, ErrNotInstalled) { + t.Fatalf("got %v, want ErrNotInstalled", err) + } +} + +func TestWhatTheInstallerWroteIsWhatTheAgentReads(t *testing.T) { + path := filepath.Join(t.TempDir(), "config.json") + written := Config{Core: Core{ + Runtime: Docker, + Image: "ghcr.io/sourceant/sourceant:v1", + DataDir: "/home/someone/.local/share/sourceant", + }} + + if err := Save(path, written); err != nil { + t.Fatalf("saving: %v", err) + } + read, err := Load(path) + if err != nil { + t.Fatalf("loading: %v", err) + } + + if read != written { + t.Errorf("got %+v, want %+v", read, written) + } +} + +func TestARuntimeThatIsNeitherIsRefusedWhenItIsRead(t *testing.T) { + path := filepath.Join(t.TempDir(), "config.json") + if err := Save(path, Config{Core: Core{Runtime: "podman"}}); err != nil { + t.Fatalf("saving: %v", err) + } + + if _, err := Load(path); err == nil { + t.Fatal("accepted a runtime that is neither python nor docker") + } +} + +func TestThePythonRuntimeBindsLoopbackDirectly(t *testing.T) { + core := Core{Runtime: Python, Command: "/opt/sourceant/bin/sourceant"} + + name, args, err := core.Serve(8931) + if err != nil { + t.Fatalf("building the command: %v", err) + } + + if name != "/opt/sourceant/bin/sourceant" { + t.Errorf("got %q, want the installed command", name) + } + want := []string{"serve", "--host", "127.0.0.1", "--port", "8931"} + if !slices.Equal(args, want) { + t.Errorf("got %v, want %v", args, want) + } +} + +// A container binding loopback binds its own, which nothing can reach, so it +// has to bind every interface inside and be published to loopback outside. +func TestTheDockerRuntimeBindsInsideAndPublishesOutside(t *testing.T) { + core := Core{Runtime: Docker, Image: "ghcr.io/sourceant/sourceant:v1", DataDir: "/data/here", User: "501:20"} + + name, args, err := core.Serve(8931) + if err != nil { + t.Fatalf("building the command: %v", err) + } + + if name != "docker" { + t.Errorf("got %q, want docker", name) + } + line := strings.Join(args, " ") + for _, want := range []string{ + "-p 127.0.0.1:8931:8931", + "--host 0.0.0.0 --port 8931", + "-v /data/here:/data", + "-e SOURCEANT_HOME=/data", + "--user 501:20", + "--entrypoint ./sourceant", + "ghcr.io/sourceant/sourceant:v1 serve", + } { + if !strings.Contains(line, want) { + t.Errorf("%q is missing from: docker %s", want, line) + } + } +} + +// Every docker flag has to come before the image, or docker reads it as an +// argument to the core instead of to itself. +func TestEveryDockerFlagComesBeforeTheImage(t *testing.T) { + core := Core{Runtime: Docker, Image: "ghcr.io/sourceant/sourceant:v1", DataDir: "/data/here", User: "501:20"} + + _, args, _ := core.Serve(8931) + + image := slices.Index(args, "ghcr.io/sourceant/sourceant:v1") + if image == -1 { + t.Fatal("the image is not in the command") + } + for _, flag := range []string{"--rm", "--name", "-p", "-v", "-e", "--user", "--entrypoint"} { + if at := slices.Index(args, flag); at > image { + t.Errorf("%s comes after the image, so docker would pass it to the core", flag) + } + } +} + +func TestADataDirNobodyChoseIsNotMounted(t *testing.T) { + core := Core{Runtime: Docker, Image: "img"} + + _, args, _ := core.Serve(8931) + + if slices.Contains(args, "-v") { + t.Errorf("mounted something without being told where: %v", args) + } +} From f1d8d439714d25b948249e035c196582049a222a Mon Sep 17 00:00:00 2001 From: nfebe Date: Fri, 28 Aug 2026 23:07:00 +0100 Subject: [PATCH 04/27] feat: Make the local view a place to work, not only a picture The graph is now one section of an app rather than the whole of it. Header, tabs, cards, badges and buttons follow one design system, so every surface reads as one product. Four sections. What is on this machine, the folders being read, the graph, and what is known about the code. Folders can be added, dropped and re-read without touching a terminal: a browser will not tell a page the absolute path of a folder somebody picked, so the agent lists the machine and the page navigates what it lists. Knowledge is the same store agents reach over MCP, for a person instead: the decisions, conventions and constraints behind the code, written down where they will be read. The graph now labels each link at its midpoint. The container runtime can now see the repositories it indexes. Your home is mounted at the path it already has, which is what lets one registry of absolute paths mean the same thing whichever runtime reads it. --- internal/api/server.go | 136 +++++ internal/api/server_test.go | 51 +- internal/api/writes_test.go | 145 ++++++ internal/browse/browse.go | 82 +++ internal/browse/browse_test.go | 103 ++++ internal/core/client.go | 130 +++++ internal/runtime/runtime.go | 10 + internal/runtime/runtime_test.go | 11 +- internal/ui/assets/app.js | 863 ++++++++++++++++++++----------- internal/ui/assets/graph.js | 225 ++++++++ internal/ui/assets/icons.js | 30 ++ internal/ui/assets/index.html | 72 +-- internal/ui/assets/styles.css | 806 +++++++++++++++++++++++++---- internal/ui/ui_test.go | 5 +- 14 files changed, 2226 insertions(+), 443 deletions(-) create mode 100644 internal/api/writes_test.go create mode 100644 internal/browse/browse.go create mode 100644 internal/browse/browse_test.go create mode 100644 internal/ui/assets/graph.js create mode 100644 internal/ui/assets/icons.js diff --git a/internal/api/server.go b/internal/api/server.go index 92d56e6..69c7930 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -14,6 +14,7 @@ import ( "strconv" "time" + "github.com/sourceant/agent/internal/browse" "github.com/sourceant/agent/internal/core" "github.com/sourceant/agent/internal/ui" ) @@ -23,6 +24,12 @@ type Reader interface { Healthy(ctx context.Context) bool Repositories(ctx context.Context) ([]core.Repository, error) Graph(ctx context.Context, repository string, opts core.GraphOptions) (core.Graph, error) + Register(ctx context.Context, path, name string) (core.Repository, error) + Forget(ctx context.Context, path string) error + Index(ctx context.Context, repository string, everything bool) ([]core.Indexed, error) + Knowledge(ctx context.Context, repository string, limit, offset int) (core.KnowledgePage, error) + RecordKnowledge(ctx context.Context, repository string, item core.Knowledge) (core.Knowledge, error) + ForgetKnowledge(ctx context.Context, repository, id string) error } // Supervision is the part of the supervisor this server reports on. @@ -62,7 +69,14 @@ func (s *Server) Handler() http.Handler { mux := http.NewServeMux() mux.HandleFunc("GET /health", s.health) mux.HandleFunc("GET /api/repositories", s.repositories) + mux.HandleFunc("POST /api/repositories", s.addRepository) + mux.HandleFunc("DELETE /api/repositories", s.dropRepository) + mux.HandleFunc("POST /api/index", s.index) mux.HandleFunc("GET /api/graph", s.graph) + mux.HandleFunc("GET /api/knowledge", s.knowledge) + mux.HandleFunc("PUT /api/knowledge", s.recordKnowledge) + mux.HandleFunc("DELETE /api/knowledge", s.forgetKnowledge) + mux.HandleFunc("GET /api/browse", s.browse) mux.Handle("GET /", ui.Handler()) return mux } @@ -117,6 +131,128 @@ func (s *Server) graph(w http.ResponseWriter, r *http.Request) { write(w, http.StatusOK, graph) } +func (s *Server) addRepository(w http.ResponseWriter, r *http.Request) { + var body struct { + Path string `json:"path"` + Name string `json:"name"` + } + if !readBody(w, r, &body) { + return + } + if body.Path == "" { + write(w, http.StatusBadRequest, problem{Error: "name a directory"}) + return + } + added, err := s.reader.Register(r.Context(), body.Path, body.Name) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, added) +} + +func (s *Server) dropRepository(w http.ResponseWriter, r *http.Request) { + path := r.URL.Query().Get("path") + if path == "" { + write(w, http.StatusBadRequest, problem{Error: "name a directory"}) + return + } + if err := s.reader.Forget(r.Context(), path); err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, map[string]string{"path": path}) +} + +func (s *Server) index(w http.ResponseWriter, r *http.Request) { + var body struct { + Repository string `json:"repository"` + Everything bool `json:"everything"` + } + if !readBody(w, r, &body) { + return + } + done, err := s.reader.Index(r.Context(), body.Repository, body.Everything) + if err != nil { + fail(w, err) + return + } + if done == nil { + done = []core.Indexed{} + } + write(w, http.StatusOK, done) +} + +func (s *Server) knowledge(w http.ResponseWriter, r *http.Request) { + repository := r.URL.Query().Get("repository") + if repository == "" { + write(w, http.StatusBadRequest, problem{Error: "name a repository"}) + return + } + limit, _ := strconv.Atoi(r.URL.Query().Get("limit")) + offset, _ := strconv.Atoi(r.URL.Query().Get("offset")) + page, err := s.reader.Knowledge(r.Context(), repository, limit, offset) + if err != nil { + fail(w, err) + return + } + if page.Items == nil { + page.Items = []core.Knowledge{} + } + write(w, http.StatusOK, page) +} + +func (s *Server) recordKnowledge(w http.ResponseWriter, r *http.Request) { + var body struct { + Repository string `json:"repository"` + core.Knowledge + } + if !readBody(w, r, &body) { + return + } + if body.Repository == "" || body.ID == "" || body.Summary == "" { + write(w, http.StatusBadRequest, problem{Error: "a repository, an id and a summary are needed"}) + return + } + recorded, err := s.reader.RecordKnowledge(r.Context(), body.Repository, body.Knowledge) + if err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, recorded) +} + +func (s *Server) forgetKnowledge(w http.ResponseWriter, r *http.Request) { + repository := r.URL.Query().Get("repository") + id := r.URL.Query().Get("id") + if repository == "" || id == "" { + write(w, http.StatusBadRequest, problem{Error: "a repository and an id are needed"}) + return + } + if err := s.reader.ForgetKnowledge(r.Context(), repository, id); err != nil { + fail(w, err) + return + } + write(w, http.StatusOK, map[string]string{"id": id}) +} + +func (s *Server) browse(w http.ResponseWriter, r *http.Request) { + listing, err := browse.At(r.URL.Query().Get("path")) + if err != nil { + write(w, http.StatusNotFound, problem{Error: err.Error()}) + return + } + write(w, http.StatusOK, listing) +} + +func readBody(w http.ResponseWriter, r *http.Request, into any) bool { + if err := json.NewDecoder(r.Body).Decode(into); err != nil { + write(w, http.StatusBadRequest, problem{Error: "the body is not readable as JSON"}) + return false + } + return true +} + type problem struct { Error string `json:"error"` } diff --git a/internal/api/server_test.go b/internal/api/server_test.go index b53fd03..d7ac536 100644 --- a/internal/api/server_test.go +++ b/internal/api/server_test.go @@ -12,12 +12,18 @@ import ( ) type stubReader struct { - up bool - repositories []core.Repository - graph core.Graph - err error - askedFor string - askedOptions core.GraphOptions + up bool + repositories []core.Repository + graph core.Graph + indexed []core.Indexed + knowledge core.KnowledgePage + err error + askedFor string + askedOptions core.GraphOptions + askedEverything bool + registered core.Repository + recorded core.Knowledge + forgot string } func (s *stubReader) Healthy(context.Context) bool { return s.up } @@ -32,6 +38,39 @@ func (s *stubReader) Graph(_ context.Context, repository string, opts core.Graph return s.graph, s.err } +func (s *stubReader) Register(_ context.Context, path, name string) (core.Repository, error) { + s.registered = core.Repository{Name: name, Path: path} + return s.registered, s.err +} + +func (s *stubReader) Forget(_ context.Context, path string) error { + s.forgot = path + return s.err +} + +func (s *stubReader) Index(_ context.Context, repository string, everything bool) ([]core.Indexed, error) { + s.askedFor = repository + s.askedEverything = everything + return s.indexed, s.err +} + +func (s *stubReader) Knowledge(_ context.Context, repository string, limit, offset int) (core.KnowledgePage, error) { + s.askedFor = repository + return s.knowledge, s.err +} + +func (s *stubReader) RecordKnowledge(_ context.Context, repository string, item core.Knowledge) (core.Knowledge, error) { + s.askedFor = repository + s.recorded = item + return item, s.err +} + +func (s *stubReader) ForgetKnowledge(_ context.Context, repository, id string) error { + s.askedFor = repository + s.forgot = id + return s.err +} + type stubSupervisor struct { starts int exit error diff --git a/internal/api/writes_test.go b/internal/api/writes_test.go new file mode 100644 index 0000000..5bbd6a2 --- /dev/null +++ b/internal/api/writes_test.go @@ -0,0 +1,145 @@ +package api + +import ( + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/sourceant/agent/internal/core" +) + +func body(t *testing.T, server *Server, method, target, payload string) *httptest.ResponseRecorder { + t.Helper() + recorder := httptest.NewRecorder() + request := httptest.NewRequest(method, target, strings.NewReader(payload)) + server.Handler().ServeHTTP(recorder, request) + return recorder +} + +func TestADirectoryCanBeCovered(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPost, "/api/repositories", + `{"path":"/home/me/billing","name":"acme/billing"}`) + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if reader.registered.Path != "/home/me/billing" || reader.registered.Name != "acme/billing" { + t.Errorf("registered %+v, want what was asked for", reader.registered) + } +} + +func TestCoveringNowhereIsRefused(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPost, "/api/repositories", `{}`) + + if response.Code != http.StatusBadRequest { + t.Errorf("got %d, want 400", response.Code) + } +} + +func TestADirectoryCanBeDropped(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodDelete, "/api/repositories?path=/home/me/billing", "") + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if reader.forgot != "/home/me/billing" { + t.Errorf("forgot %q, want the directory named", reader.forgot) + } +} + +func TestIndexingReportsWhatWasRead(t *testing.T) { + reader := &stubReader{indexed: []core.Indexed{{Repository: "acme/billing", Files: 12}}} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPost, "/api/index", `{"repository":"acme/billing"}`) + + var done []core.Indexed + decode(t, response, &done) + if len(done) != 1 || done[0].Files != 12 { + t.Errorf("got %+v, want what the core read", done) + } + if reader.askedFor != "acme/billing" { + t.Errorf("indexed %q, want acme/billing", reader.askedFor) + } +} + +func TestIndexingEverythingSaysSo(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + body(t, server, http.MethodPost, "/api/index", `{"everything":true}`) + + if !reader.askedEverything { + t.Error("asked for one repository, want all of them") + } +} + +func TestKnowledgeIsRecordedAgainstARepository(t *testing.T) { + reader := &stubReader{} + server := New(reader, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPut, "/api/knowledge", + `{"repository":"acme/billing","id":"retry","kind":"decision","summary":"Retry three times."}`) + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if reader.askedFor != "acme/billing" || reader.recorded.ID != "retry" { + t.Errorf("recorded %+v against %q", reader.recorded, reader.askedFor) + } +} + +func TestKnowledgeWithNothingToSayIsRefused(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := body(t, server, http.MethodPut, "/api/knowledge", + `{"repository":"acme/billing","id":"retry","kind":"decision"}`) + + if response.Code != http.StatusBadRequest { + t.Errorf("got %d, want 400", response.Code) + } +} + +func TestNothingRecordedIsAnEmptyListRatherThanNull(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/knowledge?repository=acme/billing") + + if !strings.Contains(response.Body.String(), `"items":[]`) { + t.Errorf("got %q, want an empty list", response.Body.String()) + } +} + +// A browser will not tell a page the absolute path of a folder somebody picked, +// so the agent lists the machine and the page navigates what it lists. +func TestBrowsingListsDirectoriesToPickFrom(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/browse?path="+t.TempDir()) + + if response.Code != http.StatusOK { + t.Fatalf("got %d, want 200", response.Code) + } + if !strings.Contains(response.Body.String(), `"entries"`) { + t.Errorf("got %q, want a listing", response.Body.String()) + } +} + +func TestBrowsingNowhereSaysSo(t *testing.T) { + server := New(&stubReader{}, stubSupervisor{}, "dev", "") + + response := call(t, server, "/api/browse?path=/definitely/not/here") + + if response.Code != http.StatusNotFound { + t.Errorf("got %d, want 404", response.Code) + } +} diff --git a/internal/browse/browse.go b/internal/browse/browse.go new file mode 100644 index 0000000..d12bd12 --- /dev/null +++ b/internal/browse/browse.go @@ -0,0 +1,82 @@ +// Package browse lists directories, so a person can pick one to index. +// +// A browser cannot give a page the absolute path of a folder somebody chose: +// its file picker deliberately withholds it. The agent is already on the +// machine, so it walks it and the page navigates what it lists. +package browse + +import ( + "os" + "path/filepath" + "sort" + "strings" +) + +// Entry is one directory that can be opened or picked. +type Entry struct { + Name string `json:"name"` + Path string `json:"path"` + // Repository says the directory is a git working tree, which is what + // somebody is nearly always looking for. + Repository bool `json:"repository"` +} + +// Listing is one directory and what is under it. +type Listing struct { + Path string `json:"path"` + Parent string `json:"parent"` + Entries []Entry `json:"entries"` +} + +// Home is where browsing starts when nowhere was named. +func Home() string { + home, err := os.UserHomeDir() + if err != nil { + return string(filepath.Separator) + } + return home +} + +// At lists the directories inside path. +// +// Only directories, and only their names: this exists to choose somewhere to +// index, and reading file contents is the indexer's job, not the picker's. +func At(path string) (Listing, error) { + if path == "" { + path = Home() + } + resolved, err := filepath.Abs(filepath.Clean(path)) + if err != nil { + return Listing{}, err + } + + items, err := os.ReadDir(resolved) + if err != nil { + return Listing{}, err + } + + entries := make([]Entry, 0, len(items)) + for _, item := range items { + if !item.IsDir() || strings.HasPrefix(item.Name(), ".") { + continue + } + full := filepath.Join(resolved, item.Name()) + entries = append(entries, Entry{ + Name: item.Name(), + Path: full, + Repository: isRepository(full), + }) + } + sort.Slice(entries, func(i, j int) bool { return entries[i].Name < entries[j].Name }) + + parent := filepath.Dir(resolved) + if parent == resolved { + parent = "" + } + return Listing{Path: resolved, Parent: parent, Entries: entries}, nil +} + +func isRepository(path string) bool { + info, err := os.Stat(filepath.Join(path, ".git")) + return err == nil && (info.IsDir() || info.Mode().IsRegular()) +} diff --git a/internal/browse/browse_test.go b/internal/browse/browse_test.go new file mode 100644 index 0000000..ab26c12 --- /dev/null +++ b/internal/browse/browse_test.go @@ -0,0 +1,103 @@ +package browse + +import ( + "os" + "path/filepath" + "testing" +) + +func tree(t *testing.T) string { + t.Helper() + root := t.TempDir() + for _, dir := range []string{"work", "work/billing", "work/billing/.git", "work/notes", ".hidden"} { + if err := os.MkdirAll(filepath.Join(root, dir), 0o755); err != nil { + t.Fatalf("building the tree: %v", err) + } + } + if err := os.WriteFile(filepath.Join(root, "work", "a-file"), []byte("x"), 0o644); err != nil { + t.Fatalf("writing a file: %v", err) + } + return root +} + +func TestItListsDirectoriesAndNotFiles(t *testing.T) { + root := tree(t) + + listing, err := At(filepath.Join(root, "work")) + if err != nil { + t.Fatalf("listing: %v", err) + } + + names := make([]string, 0, len(listing.Entries)) + for _, entry := range listing.Entries { + names = append(names, entry.Name) + } + if len(names) != 2 || names[0] != "billing" || names[1] != "notes" { + t.Errorf("got %v, want the two directories in order", names) + } +} + +func TestItMarksAWorkingTree(t *testing.T) { + root := tree(t) + + listing, _ := At(filepath.Join(root, "work")) + + for _, entry := range listing.Entries { + if entry.Name == "billing" && !entry.Repository { + t.Error("a directory with .git in it was not marked as a repository") + } + if entry.Name == "notes" && entry.Repository { + t.Error("a directory with no .git was marked as a repository") + } + } +} + +func TestHiddenDirectoriesAreLeftOut(t *testing.T) { + root := tree(t) + + listing, _ := At(root) + + for _, entry := range listing.Entries { + if entry.Name == ".hidden" { + t.Error("listed a hidden directory") + } + } +} + +func TestItSaysWhereUpIs(t *testing.T) { + root := tree(t) + + listing, _ := At(filepath.Join(root, "work")) + + if listing.Parent != root { + t.Errorf("got parent %q, want %q", listing.Parent, root) + } +} + +func TestTheTopOfTheTreeHasNoParent(t *testing.T) { + listing, err := At(string(filepath.Separator)) + if err != nil { + t.Fatalf("listing the root: %v", err) + } + + if listing.Parent != "" { + t.Errorf("got parent %q at the top of the tree, want none", listing.Parent) + } +} + +func TestNowhereNamedStartsAtHome(t *testing.T) { + listing, err := At("") + if err != nil { + t.Fatalf("listing: %v", err) + } + + if listing.Path != Home() { + t.Errorf("got %q, want %q", listing.Path, Home()) + } +} + +func TestADirectoryThatIsNotThereIsAnError(t *testing.T) { + if _, err := At(filepath.Join(t.TempDir(), "nowhere")); err == nil { + t.Fatal("listed a directory that does not exist") + } +} diff --git a/internal/core/client.go b/internal/core/client.go index a36a150..8e0d90e 100644 --- a/internal/core/client.go +++ b/internal/core/client.go @@ -6,6 +6,7 @@ package core import ( + "bytes" "context" "encoding/json" "fmt" @@ -135,6 +136,135 @@ func (c *Client) Graph(ctx context.Context, repository string, opts GraphOptions return get[Graph](ctx, c, "/api/code/graph", query) } +// Register covers one more directory, so the next index run reads it too. +func (c *Client) Register(ctx context.Context, path, name string) (Repository, error) { + return send[Repository](ctx, c, http.MethodPost, "/api/code/repositories", nil, map[string]string{ + "path": path, + "name": name, + }) +} + +// Forget stops covering a directory. What was already indexed is left alone. +func (c *Client) Forget(ctx context.Context, path string) error { + _, err := send[map[string]any](ctx, c, http.MethodDelete, "/api/code/repositories", + url.Values{"path": {path}}, nil) + return err +} + +// Indexed is what one repository's index run read. +type Indexed struct { + Repository string `json:"repository"` + Files int `json:"indexed"` + Unchanged int `json:"unchanged"` + Removed int `json:"removed"` + Skipped int `json:"skipped"` +} + +// Index reads repositories into the graph, one or all of them. +// +// The core answers when the reading is done, so this takes as long as the +// repository is large. The caller's context is what bounds it. +func (c *Client) Index(ctx context.Context, repository string, everything bool) ([]Indexed, error) { + return send[[]Indexed](ctx, c, http.MethodPost, "/api/code/index", nil, map[string]any{ + "repository": repository, + "everything": everything, + "update": true, + }) +} + +// Knowledge is one thing recorded about a repository. +type Knowledge struct { + ID string `json:"id"` + Kind string `json:"kind"` + Status string `json:"status"` + Summary string `json:"summary"` + Properties map[string]any `json:"properties"` +} + +// KnowledgePage is what a search answered. +type KnowledgePage struct { + Items []Knowledge `json:"items"` + Total int `json:"total"` + HasMore bool `json:"has_more"` +} + +// Knowledge reads what is recorded about one repository. +func (c *Client) Knowledge(ctx context.Context, repository string, limit, offset int) (KnowledgePage, error) { + query := url.Values{"repository": {repository}} + if limit > 0 { + query.Set("limit", strconv.Itoa(limit)) + } + if offset > 0 { + query.Set("offset", strconv.Itoa(offset)) + } + return get[KnowledgePage](ctx, c, "/api/knowledge", query) +} + +// RecordKnowledge writes something down about a repository. +func (c *Client) RecordKnowledge(ctx context.Context, repository string, item Knowledge) (Knowledge, error) { + return send[Knowledge](ctx, c, http.MethodPut, "/api/knowledge", nil, map[string]any{ + "repository": repository, + "id": item.ID, + "kind": item.Kind, + "status": item.Status, + "summary": item.Summary, + "properties": item.Properties, + }) +} + +// ForgetKnowledge removes something recorded. +func (c *Client) ForgetKnowledge(ctx context.Context, repository, id string) error { + _, err := send[map[string]any](ctx, c, http.MethodDelete, "/api/knowledge", + url.Values{"repository": {repository}, "id": {id}}, nil) + return err +} + +func send[T any](ctx context.Context, c *Client, method, path string, query url.Values, payload any) (T, error) { + var zero T + target := c.baseURL + path + if len(query) > 0 { + target += "?" + query.Encode() + } + + var body io.Reader + if payload != nil { + encoded, err := json.Marshal(payload) + if err != nil { + return zero, err + } + body = bytes.NewReader(encoded) + } + + req, err := http.NewRequestWithContext(ctx, method, target, body) + if err != nil { + return zero, err + } + req.Header.Set("Accept", "application/json") + if payload != nil { + req.Header.Set("Content-Type", "application/json") + } + + resp, err := c.http.Do(req) + if err != nil { + return zero, err + } + defer func() { _ = resp.Body.Close() }() + + answered, err := io.ReadAll(resp.Body) + if err != nil { + return zero, err + } + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return zero, &Error{StatusCode: resp.StatusCode, Detail: detail(answered)} + } + + var parsed envelope[T] + if err := json.Unmarshal(answered, &parsed); err != nil { + return zero, fmt.Errorf("sourceant core answered %s with something other than JSON: %w", path, err) + } + return parsed.Data, nil +} + func get[T any](ctx context.Context, c *Client, path string, query url.Values) (T, error) { var zero T target := c.baseURL + path diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go index a4aa680..d15ed86 100644 --- a/internal/runtime/runtime.go +++ b/internal/runtime/runtime.go @@ -39,6 +39,13 @@ type Core struct { // DataDir is where the index lives. Both runtimes must agree on it, or // indexing and reading would address two different databases. DataDir string `json:"data_dir,omitempty"` + // Mount is a host directory the container can see, for the docker runtime. + // + // The indexer reads the repository's files, so a container that cannot see + // them indexes nothing. It is mounted at the same path it has on the host, + // which is what lets one registry of absolute paths mean the same thing to + // both runtimes. A repository outside it is not readable this way. + Mount string `json:"mount,omitempty"` // User is the uid:gid a container runs as, for the docker runtime. // // The image has a user of its own, and where that user's id differs from @@ -129,6 +136,9 @@ func (c Core) Serve(port int) (string, []string, error) { if c.DataDir != "" { args = append(args, "-v", c.DataDir+":/data", "-e", "SOURCEANT_HOME=/data") } + if c.Mount != "" { + args = append(args, "-v", c.Mount+":"+c.Mount) + } if c.User != "" { args = append(args, "--user", c.User) } diff --git a/internal/runtime/runtime_test.go b/internal/runtime/runtime_test.go index 2f5e345..66a5d5a 100644 --- a/internal/runtime/runtime_test.go +++ b/internal/runtime/runtime_test.go @@ -68,7 +68,13 @@ func TestThePythonRuntimeBindsLoopbackDirectly(t *testing.T) { // A container binding loopback binds its own, which nothing can reach, so it // has to bind every interface inside and be published to loopback outside. func TestTheDockerRuntimeBindsInsideAndPublishesOutside(t *testing.T) { - core := Core{Runtime: Docker, Image: "ghcr.io/sourceant/sourceant:v1", DataDir: "/data/here", User: "501:20"} + core := Core{ + Runtime: Docker, + Image: "ghcr.io/sourceant/sourceant:v1", + DataDir: "/data/here", + Mount: "/home/someone", + User: "501:20", + } name, args, err := core.Serve(8931) if err != nil { @@ -84,6 +90,9 @@ func TestTheDockerRuntimeBindsInsideAndPublishesOutside(t *testing.T) { "--host 0.0.0.0 --port 8931", "-v /data/here:/data", "-e SOURCEANT_HOME=/data", + // At the same path on both sides, so one registry of absolute paths + // means the same thing whichever runtime reads it. + "-v /home/someone:/home/someone", "--user 501:20", "--entrypoint ./sourceant", "ghcr.io/sourceant/sourceant:v1 serve", diff --git a/internal/ui/assets/app.js b/internal/ui/assets/app.js index 8be461b..542895b 100644 --- a/internal/ui/assets/app.js +++ b/internal/ui/assets/app.js @@ -1,363 +1,646 @@ -/* The local code graph. - * - * Colours are concrete hex rather than the CSS custom properties above, - * because the graph draws to a canvas and cannot resolve them. They are the - * dashboard's palette, mapped onto what a code graph holds. - */ -const COLOURS = { - repository: '#E20C18', - directory: '#9560f0', - file: '#3b82f6', - import: '#f59e0b', - function: '#4ade80', - method: '#2dd4bf', - class: '#c084fc', - struct: '#22d3ee', - interface: '#22d3ee', - enum: '#22d3ee', +/* The local SourceAnt app: what this machine has indexed, and what is known + * about it. Everything comes from the agent, which is the only thing that + * knows where the indexer is. */ + +const view = document.getElementById('view') +const layer = document.getElementById('layer') +const tabs = document.getElementById('tabs') +const themeButton = document.getElementById('theme') + +const PAGES = [ + { id: '', label: 'Overview', icon: 'layout' }, + { id: 'repositories', label: 'Repositories', icon: 'boxes' }, + { id: 'graph', label: 'Code graph', icon: 'network' }, + { id: 'knowledge', label: 'Knowledge', icon: 'lightbulb' }, +] + +const state = { + page: '', + repositories: [], + repository: '', + status: null, + graph: null, + error: '', } -const OTHER = '#a1a1aa' -const LAYOUTS = [ - { id: 'force', label: 'Force', dag: null }, - { id: 'tree', label: 'Tree', dag: 'td' }, - { id: 'radial', label: 'Radial', dag: 'radialout' }, - { id: 'sideways', label: 'Sideways', dag: 'lr' }, -] +function escape(text) { + return String(text ?? '').replace(/[&<>"']/g, (c) => + ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]) +} -/* A file's kind is its language and a symbol's kind is what the parser called - * it, so kind alone cannot tell a Python file from a Python function. The - * labels the index carries can, which is what this reads. */ -function groupOf(node) { - if (node.synthetic) return node.synthetic - const labels = node.labels || [] - if (labels.includes('File')) return 'file' - if (labels.includes('Import')) return 'import' - return (node.kind || '').toLowerCase() +async function api(path, options = {}) { + const response = await fetch(path, { + ...options, + headers: options.body ? { 'Content-Type': 'application/json' } : undefined, + }) + const text = await response.text() + const body = text ? JSON.parse(text) : null + if (!response.ok) throw new Error(body?.error || `the agent answered ${response.status}`) + return body } -/* Files hold their symbols and their imports, and nothing holds the files, so - * drawing the index as it is stored scatters a repository into one island per - * file. The directories are already in every path; this reads them out and - * hangs the files off them, which is the difference between a repository and - * confetti. The nodes it adds are marked synthetic: they are how this view - * arranges what the index found, not something the index found. */ -function withFolders(data, repository) { - const root = { id: 'tree:', name: repository, kind: 'repository', synthetic: 'repository', path: '' } - const folders = new Map([['', root]]) - const links = [...data.links] - - const folderFor = (path) => { - if (folders.has(path)) return folders.get(path) - const cut = path.lastIndexOf('/', path.length - 2) - const parentPath = cut === -1 ? '' : path.slice(0, cut + 1) - const parent = folderFor(parentPath) - const folder = { - id: `tree:${path}`, - name: path.slice(parentPath.length).replace(/\/$/, ''), - kind: 'directory', - synthetic: 'directory', - path, - } - folders.set(path, folder) - links.push({ source: parent.id, target: folder.id, type: 'contains' }) - return folder - } +/* Rendering */ - for (const node of data.nodes) { - if (groupOf(node) !== 'file' || !node.path) continue - const cut = node.path.lastIndexOf('/') - const folder = folderFor(cut === -1 ? '' : node.path.slice(0, cut + 1)) - links.push({ source: folder.id, target: node.id, type: 'contains' }) - } +document.querySelector('.logo-mark').innerHTML = icon('ant', 15) - return { nodes: [...folders.values(), ...data.nodes], links } +function renderTabs() { + tabs.innerHTML = PAGES.map((page) => ` + + ${icon(page.icon, 14)}${page.label} + `).join('') } -function colourOf(node) { - return COLOURS[groupOf(node)] || OTHER +function head({ tile, iconName, title, sub, actions = '' }) { + return ` +
+
+ ${icon(iconName, 24)} +

${escape(title)}

${escape(sub)}

+
+
${actions}
+
` } -function shortName(name) { - return name && name.length > 30 ? `${name.slice(0, 29)}…` : name +function notice(message, bad = true) { + return message ? `

${escape(message)}

` : '' } -const element = { - canvas: document.getElementById('canvas'), - overlay: document.getElementById('overlay'), - repository: document.getElementById('repository'), - layouts: document.getElementById('layouts'), - search: document.getElementById('search'), - tests: document.getElementById('tests'), - imports: document.getElementById('imports'), - folders: document.getElementById('folders'), - symbols: document.getElementById('symbols'), - legend: document.getElementById('legend'), - tally: document.getElementById('tally'), - truncated: document.getElementById('truncated'), - theme: document.getElementById('theme'), - details: document.getElementById('details'), - detailsName: document.getElementById('details-name'), - detailsKind: document.getElementById('details-kind'), - detailsPath: document.getElementById('details-path'), - detailsLinks: document.getElementById('details-links'), - closeDetails: document.getElementById('close-details'), +function needRepository() { + return ` +
+

Nothing indexed yet

+

Add a folder and SourceAnt reads it into a graph you can look at and record against.

+ ${icon('plus', 16)} Add a repository +
` } -const state = { - graph: null, - loaded: { nodes: [], links: [], truncated: false }, - layout: 'force', - matching: null, - selected: null, - labelled: false, +function repositoryPicker() { + if (state.repositories.length < 2) return '' + return `` } -function canvasColour(name) { - return getComputedStyle(document.documentElement).getPropertyValue(name).trim() -} +/* Overview */ -function say(message) { - element.overlay.innerHTML = message - element.overlay.hidden = false -} +async function overview() { + view.innerHTML = head({ + tile: 'memory', iconName: 'layout', + title: 'Overview', + sub: 'What SourceAnt has on this machine.', + }) + notice(state.error) + '
' -async function read(path) { - const response = await fetch(path) - if (!response.ok) { - const body = await response.json().catch(() => ({})) - throw new Error(body.error || `the agent answered ${response.status}`) + const body = document.getElementById('body') + if (state.repositories.length === 0) { + body.innerHTML = needRepository() + return } - return response.json() + + const counts = await Promise.all(state.repositories.map(async (repository) => { + const [graph, knowledge] = await Promise.all([ + api(`/api/graph?repository=${encodeURIComponent(repository.name)}`).catch(() => null), + api(`/api/knowledge?repository=${encodeURIComponent(repository.name)}`).catch(() => null), + ]) + return { + repository, + files: graph ? graph.nodes.filter((n) => (n.labels || []).includes('File')).length : 0, + nodes: graph ? graph.nodes.length : 0, + knowledge: knowledge ? knowledge.total : 0, + } + })) + + const total = (key) => counts.reduce((sum, item) => sum + item[key], 0) + body.innerHTML = ` +
+ ${stat('Repositories', state.repositories.length)} + ${stat('Files', total('files'))} + ${stat('Nodes', total('nodes'))} + ${stat('Knowledge', total('knowledge'))} +
+
${counts.map(({ repository, files, knowledge }) => ` +
+ ${icon('folder', 22)} +
+

${escape(repository.name)}

+ ${files ? 'Indexed' : 'Not indexed'} +
+

${escape(repository.path)}

+
+ ${icon('file', 14)} ${files.toLocaleString()} files + ${icon('lightbulb', 14)} ${knowledge.toLocaleString()} recorded +
+
+
+ Graph +
+
`).join('')} +
+

Reviews are not here. A review reads a pull request, which is a thing the + hosted service does; nothing on this machine produces one.

` } -/* What is drawn, after the toggles and before the layout. Dropping a node has - * to drop the links that reach it, or the renderer is handed an edge with no - * end and stops drawing entirely. */ -/* A repository's every function is a texture rather than a picture, so what - * opens is its shape: folders and files. Symbols and imports are there to be - * asked for. */ -function wanted(node) { - const group = groupOf(node) - if (group === 'import') return element.imports.checked - if (group === 'file') return true - return element.symbols.checked +function stat(label, value) { + return `
${escape(label)}
+
${value.toLocaleString()}
` } -function visible() { - const nodes = state.loaded.nodes.filter(wanted) - const kept = new Set(nodes.map((node) => node.id)) - const links = state.loaded.links - .filter((link) => kept.has(link.source.id || link.source) && kept.has(link.target.id || link.target)) - .map((link) => ({ source: link.source.id || link.source, target: link.target.id || link.target, type: link.type })) +/* Repositories */ + +async function repositories() { + view.innerHTML = head({ + tile: 'graph', iconName: 'boxes', + title: 'Repositories', + sub: 'The folders SourceAnt reads on this machine.', + actions: ``, + }) + notice(state.error) + '
' + + document.getElementById('add').onclick = openPicker + const body = document.getElementById('body') + + if (state.repositories.length === 0) { + body.innerHTML = `
+

No folders yet

+

Point SourceAnt at a repository on this machine and it reads the files into a graph.

+ +
` + document.getElementById('add-empty').onclick = openPicker + return + } + + body.innerHTML = `
${state.repositories.map((repository) => ` +
+ ${icon('folder', 22)} +
+

${escape(repository.name)}

+

${escape(repository.path)}

+
+ Reading… +
+
+
+ + +
+
`).join('')}
` + + for (const button of body.querySelectorAll('[data-index]')) { + button.onclick = () => reindex(button.dataset.index, button) + } + for (const button of body.querySelectorAll('[data-drop]')) { + button.onclick = () => drop(button.dataset.drop) + } - const data = { nodes: nodes.map((node) => ({ ...node })), links } - return element.folders.checked ? withFolders(data, element.repository.value) : data + for (const repository of state.repositories) { + const graph = await api(`/api/graph?repository=${encodeURIComponent(repository.name)}`).catch(() => null) + const slot = body.querySelector(`[data-counts="${CSS.escape(repository.name)}"]`) + if (!slot) continue + const files = graph ? graph.nodes.filter((n) => (n.labels || []).includes('File')).length : 0 + slot.innerHTML = files + ? `${icon('file', 14)} ${files.toLocaleString()} files + ${icon('link', 14)} ${graph.links.length.toLocaleString()} links` + : 'Not indexed yet. Re-index to read it.' + } } -function draw() { - const data = visible() - const dag = LAYOUTS.find((layout) => layout.id === state.layout).dag - - if (!state.graph) { - state.graph = new ForceGraph(element.canvas) - state.graph - .backgroundColor('rgba(0,0,0,0)') - .nodeRelSize(4) - .nodeLabel((node) => `${node.name} · ${node.kind}`) - .nodeCanvasObject(paintNode) - .nodePointerAreaPaint((node, colour, ctx) => { - ctx.fillStyle = colour - ctx.beginPath() - ctx.arc(node.x, node.y, 7, 0, 2 * Math.PI) - ctx.fill() - }) - .linkColor(() => canvasColour('--canvas-link')) - .linkWidth(0.7) - .linkDirectionalArrowLength(3) - .linkDirectionalArrowRelPos(1) - .onNodeClick(select) - .onBackgroundClick(() => select(null)) - state.graph.onEngineStop(() => state.graph.zoomToFit(400, 40)) +async function reindex(name, button) { + const original = button.innerHTML + button.disabled = true + button.innerHTML = `${icon('loader', 14, 'spin')} Reading…` + try { + await api('/api/index', { method: 'POST', body: JSON.stringify({ repository: name }) }) + state.error = '' + } catch (error) { + state.error = error.message } + button.disabled = false + button.innerHTML = original + await route() +} - // A drawing small enough to read gets its names at any zoom. A large one - // would be soup, so there the names wait until something is zoomed into. - state.labelled = data.nodes.length <= 400 +async function drop(path) { + if (!confirm(`Stop covering ${path}?\n\nWhat was already indexed is left alone.`)) return + try { + await api(`/api/repositories?path=${encodeURIComponent(path)}`, { method: 'DELETE' }) + state.error = '' + } catch (error) { + state.error = error.message + } + await load() + await route() +} - state.graph - .dagMode(dag) - .dagLevelDistance(dag ? 90 : 40) - .onDagError(() => undefined) - .width(element.canvas.clientWidth) - .height(element.canvas.clientHeight) - .graphData(data) +/* The folder picker. + * + * A browser will not tell a page the absolute path of a folder somebody chose, + * so the agent lists this machine and the page navigates what it lists. */ +function openPicker() { + let here = '' + const close = () => { layer.innerHTML = '' } + + const show = async (path) => { + let listing + try { + listing = await api(`/api/browse?path=${encodeURIComponent(path || '')}`) + } catch (error) { + layer.querySelector('#picker').innerHTML = + `

${escape(error.message)}

` + return + } + here = listing.path + layer.querySelector('#crumbs').textContent = here + layer.querySelector('#chosen').textContent = here + layer.querySelector('#picker').innerHTML = ` + ${listing.parent ? `` : ''} + ${listing.entries.map((entry) => ` + `).join('')} + ${listing.entries.length === 0 ? '

Nothing inside.

' : ''}` + for (const button of layer.querySelectorAll('[data-go]')) { + button.onclick = () => show(button.dataset.go) + } + } - element.tally.textContent = `${data.nodes.length.toLocaleString()} nodes · ${data.links.length.toLocaleString()} links` - element.overlay.hidden = data.nodes.length > 0 - if (data.nodes.length === 0) { - say('Nothing here yet. Index it with sourceant index.') + layer.innerHTML = ` +
` + + layer.querySelector('#cancel').onclick = close + layer.querySelector('#scrim').onclick = (event) => { + if (event.target.id === 'scrim') close() + } + layer.querySelector('#confirm').onclick = async () => { + const button = layer.querySelector('#confirm') + const problem = layer.querySelector('#picker-error') + button.disabled = true + button.innerHTML = `${icon('loader', 16, 'spin')} Reading…` + try { + await api('/api/repositories', { + method: 'POST', + body: JSON.stringify({ path: here, name: layer.querySelector('#repo-name').value.trim() }), + }) + await api('/api/index', { method: 'POST', body: JSON.stringify({ repository: '', everything: true }) }) + close() + await load() + await route() + } catch (error) { + problem.hidden = false + problem.textContent = error.message + button.disabled = false + button.innerHTML = `${icon('plus', 16)} Add and index` + } } - renderLegend(data.nodes) + + show('') } -function paintNode(node, ctx, scale) { - const dimmed = state.matching !== null && !state.matching.has(node.id) - const colour = colourOf(node) - ctx.globalAlpha = dimmed ? 0.15 : 1 - - ctx.beginPath() - ctx.arc(node.x, node.y, node.id === state.selected ? 6 : 4, 0, 2 * Math.PI) - ctx.fillStyle = colour - ctx.fill() - if (node.id === state.selected) { - ctx.lineWidth = 1.5 / scale - ctx.strokeStyle = canvasColour('--canvas-label') - ctx.stroke() +/* Code graph */ + +let drawing = null + +async function graphPage() { + view.innerHTML = head({ + tile: 'graph', iconName: 'network', + title: 'Code graph', + sub: 'Your code, and how it holds together.', + actions: repositoryPicker(), + }) + notice(state.error) + '
' + + const body = document.getElementById('body') + if (state.repositories.length === 0) { + body.innerHTML = needRepository() + return } - if (state.labelled || scale > 1.4 || state.matching !== null) { - const size = Math.max(11 / scale, 2) - ctx.font = `${groupOf(node) === 'file' ? '600 ' : ''}${size}px Inter, sans-serif` - ctx.fillStyle = colour - ctx.textAlign = 'left' - ctx.textBaseline = 'middle' - ctx.fillText(shortName(node.name), node.x + 6, node.y) + body.innerHTML = ` +
+
${LAYOUTS.map((layout) => ` + `).join('')}
+
+ + + + + +
+
+
+
+
Reading the index…
+ +
+ +
` + + const picker = document.getElementById('pick-repo') + if (picker) picker.onchange = () => { state.repository = picker.value; loadGraph() } + + drawing?.destroy() + drawing = new CodeGraph(document.getElementById('canvas'), { onSelect: showDetails }) + + document.getElementById('layouts').onclick = (event) => { + const button = event.target.closest('button[data-layout]') + if (!button) return + for (const other of document.querySelectorAll('#layouts button')) { + other.setAttribute('aria-pressed', String(other === button)) + } + drawing.setLayout(button.dataset.layout) } - ctx.globalAlpha = 1 + document.getElementById('find').oninput = (event) => drawing.highlight(event.target.value) + for (const id of ['folders', 'symbols', 'imports']) { + document.getElementById(id).onchange = redraw + } + document.getElementById('tests').onchange = loadGraph + + await loadGraph() } -function renderLegend(nodes) { - const present = new Set(nodes.map(groupOf)) - const seen = [] - for (const group of present) { - seen.push({ group, colour: COLOURS[group] || OTHER }) +async function loadGraph() { + const overlay = document.getElementById('overlay') + if (!overlay) return + overlay.hidden = false + overlay.textContent = 'Reading the index…' + try { + const tests = document.getElementById('tests').checked + state.graph = await api(`/api/graph?repository=${encodeURIComponent(state.repository)}${tests ? '&include_tests=true' : ''}`) + redraw() + } catch (error) { + overlay.textContent = error.message } - seen.sort((a, b) => a.group.localeCompare(b.group)) - element.legend.innerHTML = seen - .map(({ group, colour }) => - `${group || 'other'}`) - .join('') } -function select(node) { - state.selected = node ? node.id : null - element.details.hidden = !node - if (node) { - const degree = state.loaded.links.filter((link) => - (link.source.id || link.source) === node.id || (link.target.id || link.target) === node.id).length - element.detailsName.textContent = node.name - element.detailsKind.textContent = node.synthetic - ? `${node.kind} · this view's arrangement` - : (groupOf(node) === node.kind ? node.kind : `${groupOf(node)} · ${node.kind}`) - element.detailsPath.textContent = node.path || '—' - element.detailsLinks.textContent = node.synthetic ? '—' : degree +function redraw() { + if (!state.graph) return + const keepImports = document.getElementById('imports').checked + const keepSymbols = document.getElementById('symbols').checked + const nodes = state.graph.nodes.filter((node) => { + const group = groupOf(node) + if (group === 'import') return keepImports + if (group === 'file') return true + return keepSymbols + }) + const kept = new Set(nodes.map((node) => node.id)) + const links = state.graph.links + .filter((link) => kept.has(link.source) && kept.has(link.target)) + .map((link) => ({ ...link })) + + let data = { nodes: nodes.map((node) => ({ ...node })), links } + if (document.getElementById('folders').checked) data = withFolders(data, state.repository) + + drawing.show(data) + + const overlay = document.getElementById('overlay') + overlay.hidden = data.nodes.length > 0 + if (data.nodes.length === 0) { + overlay.innerHTML = 'Nothing here yet. Re-index it from Repositories.' } - if (state.graph) state.graph.nodeCanvasObject(paintNode) + document.getElementById('tally').textContent = + `${data.nodes.length.toLocaleString()} nodes · ${data.links.length.toLocaleString()} links` + + const groups = [...new Set(data.nodes.map(groupOf))].sort() + document.getElementById('legend').innerHTML = groups.map((group) => + `${escape(group || 'other')}`).join('') + + const truncated = document.getElementById('truncated') + truncated.hidden = !state.graph.truncated + truncated.textContent = 'This repository is larger than the limit, so this is part of it, not all of it.' } -function highlight(term) { - const needle = term.trim().toLowerCase() - state.matching = needle - ? new Set(state.loaded.nodes - .filter((node) => node.name.toLowerCase().includes(needle) || (node.path || '').toLowerCase().includes(needle)) - .map((node) => node.id)) - : null - if (state.graph) state.graph.nodeCanvasObject(paintNode) +function showDetails(node) { + const panel = document.getElementById('details') + if (!panel) return + panel.hidden = !node + if (!node) return + const degree = state.graph.links.filter((link) => + link.source === node.id || link.target === node.id).length + panel.innerHTML = ` + +

${escape(node.name)}

+
+
Kind
${escape(node.synthetic ? `${node.kind} · this view's arrangement` : node.kind)}
+
Path
${escape(node.path || '—')}
+
Links
${node.synthetic ? '—' : degree}
+
` + document.getElementById('close-details').onclick = () => drawing.select(null) } -async function load() { - const repository = element.repository.value - if (!repository) return - say('Reading the index…') +/* Knowledge */ + +async function knowledge() { + view.innerHTML = head({ + tile: 'memory', iconName: 'lightbulb', + title: 'Knowledge', + sub: 'The decisions, conventions and constraints behind this code.', + actions: `${repositoryPicker()} + `, + }) + notice(state.error) + '
' + + const body = document.getElementById('body') + if (state.repositories.length === 0) { + body.innerHTML = needRepository() + return + } + + const picker = document.getElementById('pick-repo') + if (picker) picker.onchange = () => { state.repository = picker.value; knowledge() } + document.getElementById('record').onclick = () => openRecord() + + let page try { - const query = new URLSearchParams({ repository }) - if (element.tests.checked) query.set('include_tests', 'true') - const graph = await read(`/api/graph?${query}`) - state.loaded = graph - state.selected = null - element.details.hidden = true - element.truncated.hidden = !graph.truncated - if (graph.truncated) { - element.truncated.textContent = - 'This repository is larger than the limit, so this is part of it, not all of it.' - } - draw() + page = await api(`/api/knowledge?repository=${encodeURIComponent(state.repository)}&limit=100`) } catch (error) { - say(`Could not read the graph: ${error.message}`) + body.innerHTML = notice(error.message) + return } -} -async function start() { - buildLayouts() - applyStoredTheme() + if (page.items.length === 0) { + body.innerHTML = `
+

Nothing recorded yet

+

Why a thing is the way it is outlives the code that does it. Write one down and every + agent reading this repository over MCP gets it too.

+ +
` + document.getElementById('record-empty').onclick = () => openRecord() + return + } - try { - const repositories = await read('/api/repositories') - if (repositories.length === 0) { - element.repository.innerHTML = '' - say('No repository is registered on this machine. Add one with sourceant repo add <path>.') + body.innerHTML = `
${page.items.map((item) => ` +
+ ${icon('lightbulb', 22)} +
+
+

${escape(item.id)}

+ ${escape(item.kind)} + ${item.status ? `${escape(item.status)}` : ''} +
+

${escape(item.summary)}

+ ${Object.keys(item.properties || {}).length ? `
${ + Object.entries(item.properties).map(([key, value]) => + `
${escape(key)}
${escape(typeof value === 'string' ? value : JSON.stringify(value))}
`).join('') + }
` : ''} +
+
+ + +
+
`).join('')}
` + + for (const button of body.querySelectorAll('[data-edit]')) { + button.onclick = () => openRecord(page.items.find((item) => item.id === button.dataset.edit)) + } + for (const button of body.querySelectorAll('[data-forget]')) { + button.onclick = () => forget(button.dataset.forget) + } +} + +const KINDS = ['decision', 'convention', 'constraint', 'pattern', 'workaround', 'requirement'] + +function openRecord(existing) { + const close = () => { layer.innerHTML = '' } + layer.innerHTML = ` +
` + + layer.querySelector('#cancel').onclick = close + layer.querySelector('#scrim').onclick = (event) => { + if (event.target.id === 'scrim') close() + } + layer.querySelector('#save').onclick = async () => { + const problem = layer.querySelector('#record-error') + const id = layer.querySelector('#k-id').value.trim() + const summary = layer.querySelector('#k-summary').value.trim() + if (!id || !summary) { + problem.hidden = false + problem.textContent = 'A name and what is true are both needed.' return } - element.repository.innerHTML = repositories - .map((repository) => ``) - .join('') - await load() - } catch (error) { - say(`Could not reach the agent: ${error.message}`) + const why = layer.querySelector('#k-why').value.trim() + try { + await api('/api/knowledge', { + method: 'PUT', + body: JSON.stringify({ + repository: state.repository, + id, + kind: layer.querySelector('#k-kind').value, + status: existing?.status || 'accepted', + summary, + properties: why ? { ...(existing?.properties || {}), why } : (existing?.properties || {}), + }), + }) + close() + await knowledge() + } catch (error) { + problem.hidden = false + problem.textContent = error.message + } } } -function buildLayouts() { - element.layouts.innerHTML = LAYOUTS - .map((layout) => - ``) - .join('') - element.layouts.addEventListener('click', (event) => { - const button = event.target.closest('button[data-layout]') - if (!button) return - state.layout = button.dataset.layout - for (const other of element.layouts.querySelectorAll('button')) { - other.setAttribute('aria-pressed', String(other === button)) - } - draw() - }) +async function forget(id) { + if (!confirm(`Forget ${id}?`)) return + try { + await api(`/api/knowledge?repository=${encodeURIComponent(state.repository)}&id=${encodeURIComponent(id)}`, + { method: 'DELETE' }) + } catch (error) { + state.error = error.message + } + await knowledge() } -function applyStoredTheme() { - let stored = null +/* Shell */ + +async function load() { try { - stored = localStorage.getItem('sourceant-theme') - } catch { - stored = null + state.repositories = await api('/api/repositories') + state.error = '' + } catch (error) { + state.repositories = [] + state.error = `${error.message}. Is sourceant-agent running?` + } + if (!state.repositories.some((repository) => repository.name === state.repository)) { + state.repository = state.repositories[0]?.name || '' } - setTheme(stored === 'light' ? 'light' : 'dark') +} + +async function route() { + state.page = (location.hash.replace(/^#\/?/, '') || '').split('?')[0] + if (!PAGES.some((page) => page.id === state.page)) state.page = '' + renderTabs() + view.classList.toggle('fills', state.page === 'graph') + if (state.page !== 'graph') { + drawing?.destroy() + drawing = null + } + if (state.page === 'repositories') return repositories() + if (state.page === 'graph') return graphPage() + if (state.page === 'knowledge') return knowledge() + return overview() } function setTheme(theme) { document.documentElement.className = theme - element.theme.textContent = theme === 'dark' ? 'Light' : 'Dark' + themeButton.innerHTML = icon(theme === 'dark' ? 'sun' : 'moon', 16) + themeButton.setAttribute('aria-label', theme === 'dark' ? 'Light mode' : 'Dark mode') try { localStorage.setItem('sourceant-theme', theme) } catch { // A browser that refuses storage still gets the theme, just not the memory. } - if (state.graph) state.graph.linkColor(() => canvasColour('--canvas-link')) + drawing?.repaint() } -element.repository.addEventListener('change', load) -element.tests.addEventListener('change', load) -element.imports.addEventListener('change', draw) -element.folders.addEventListener('change', draw) -element.symbols.addEventListener('change', draw) -element.search.addEventListener('input', (event) => highlight(event.target.value)) -element.closeDetails.addEventListener('click', () => select(null)) -element.theme.addEventListener('click', () => - setTheme(document.documentElement.className === 'dark' ? 'light' : 'dark')) -new ResizeObserver(() => { - if (state.graph) { - state.graph.width(element.canvas.clientWidth).height(element.canvas.clientHeight) - } -}).observe(element.canvas) +themeButton.onclick = () => + setTheme(document.documentElement.className === 'dark' ? 'light' : 'dark') +window.addEventListener('hashchange', route) + +let stored = null +try { + stored = localStorage.getItem('sourceant-theme') +} catch { + stored = null +} +setTheme(stored === 'light' ? 'light' : 'dark') -start() +load().then(route) diff --git a/internal/ui/assets/graph.js b/internal/ui/assets/graph.js new file mode 100644 index 0000000..c70fdef --- /dev/null +++ b/internal/ui/assets/graph.js @@ -0,0 +1,225 @@ +/* The graph, drawn the way the dashboard draws one. + * + * Node radius, label placement, link colour and width, the arrows and the + * midpoint edge labels are all the dashboard's, so a person who has seen the + * hosted graph recognises this one. Colours are concrete hex rather than the + * CSS custom properties, because the graph draws to a canvas and cannot + * resolve them. + */ +const COLOURS = { + repository: '#E20C18', + directory: '#9560f0', + file: '#3b82f6', + import: '#f59e0b', + function: '#4ade80', + method: '#2dd4bf', + class: '#c084fc', + struct: '#22d3ee', + interface: '#22d3ee', + enum: '#22d3ee', +} +const OTHER = '#a1a1aa' + +const LAYOUTS = [ + { id: 'force', label: 'Force', dag: null }, + { id: 'tree', label: 'Tree', dag: 'td' }, + { id: 'radial', label: 'Radial', dag: 'radialout' }, + { id: 'layered', label: 'Layered', dag: 'lr' }, +] + +/* A file's kind is its language and a symbol's kind is what the parser called + * it, so kind alone cannot tell a Python file from a Python function. The + * labels the index carries can, which is what this reads. */ +function groupOf(node) { + if (node.synthetic) return node.synthetic + const labels = node.labels || [] + if (labels.includes('File')) return 'file' + if (labels.includes('Import')) return 'import' + return (node.kind || '').toLowerCase() +} + +function colourOf(node) { + return COLOURS[groupOf(node)] || OTHER +} + +function shortName(name) { + return name && name.length > 28 ? `${name.slice(0, 27)}…` : name +} + +function canvasColour(name) { + return getComputedStyle(document.documentElement).getPropertyValue(name).trim() +} + +/* Files hold their symbols and their imports, and nothing holds the files, so + * drawing the index as it is stored scatters a repository into one island per + * file. The directories are already in every path; this reads them out and + * hangs the files off them, which is the difference between a repository and + * confetti. The nodes it adds are marked synthetic: they are how this view + * arranges what the index found, not something the index found. */ +function withFolders(data, repository) { + const root = { id: 'tree:', name: repository, kind: 'repository', synthetic: 'repository', path: '' } + const folders = new Map([['', root]]) + const links = [...data.links] + + const folderFor = (path) => { + if (folders.has(path)) return folders.get(path) + const cut = path.lastIndexOf('/', path.length - 2) + const parentPath = cut === -1 ? '' : path.slice(0, cut + 1) + const parent = folderFor(parentPath) + const folder = { + id: `tree:${path}`, + name: path.slice(parentPath.length).replace(/\/$/, ''), + kind: 'directory', + synthetic: 'directory', + path, + } + folders.set(path, folder) + links.push({ source: parent.id, target: folder.id, type: 'contains' }) + return folder + } + + for (const node of data.nodes) { + if (groupOf(node) !== 'file' || !node.path) continue + const cut = node.path.lastIndexOf('/') + const folder = folderFor(cut === -1 ? '' : node.path.slice(0, cut + 1)) + links.push({ source: folder.id, target: node.id, type: 'contains' }) + } + + return { nodes: [...folders.values(), ...data.nodes], links } +} + +class CodeGraph { + constructor(element, { onSelect } = {}) { + this.element = element + this.onSelect = onSelect || (() => {}) + this.graph = null + this.layout = 'force' + this.matching = null + this.selected = null + this.labelled = false + this.observer = new ResizeObserver(() => this.resize()) + this.observer.observe(element) + } + + destroy() { + this.observer.disconnect() + this.graph?._destructor?.() + this.graph = null + this.element.innerHTML = '' + } + + resize() { + if (!this.graph) return + this.graph.width(this.element.clientWidth).height(this.element.clientHeight) + } + + setLayout(id) { + this.layout = id + this.draw() + } + + highlight(term) { + const needle = term.trim().toLowerCase() + this.matching = needle + ? new Set(this.data.nodes + .filter((node) => node.name.toLowerCase().includes(needle) || + (node.path || '').toLowerCase().includes(needle)) + .map((node) => node.id)) + : null + this.repaint() + } + + select(node) { + this.selected = node ? node.id : null + this.repaint() + this.onSelect(node) + } + + repaint() { + if (this.graph) this.graph.nodeCanvasObject(this.paintNode) + } + + show(data) { + this.data = data + this.selected = null + this.draw() + } + + draw() { + const data = this.data + const dag = LAYOUTS.find((layout) => layout.id === this.layout).dag + // A drawing small enough to read gets its names at any zoom, as the hosted + // graph does. A large one would be soup, so there they wait for a zoom. + this.labelled = data.nodes.length <= 400 + + this.paintNode = (node, ctx, scale) => { + const dimmed = this.matching !== null && !this.matching.has(node.id) + const colour = colourOf(node) + ctx.globalAlpha = dimmed ? 0.15 : 1 + + ctx.beginPath() + ctx.arc(node.x, node.y, node.id === this.selected ? 6 : 4, 0, 2 * Math.PI) + ctx.fillStyle = colour + ctx.fill() + if (node.id === this.selected) { + ctx.lineWidth = 1.5 / scale + ctx.strokeStyle = canvasColour('--canvas-label') + ctx.stroke() + } + + if (this.labelled || scale > 1.4 || this.matching !== null) { + const size = Math.max(11 / scale, 2) + const heavy = groupOf(node) === 'repository' || groupOf(node) === 'file' + ctx.font = `${heavy ? 'bold ' : ''}${size}px Inter, sans-serif` + ctx.fillStyle = colour + ctx.textAlign = 'left' + ctx.textBaseline = 'middle' + ctx.fillText(shortName(node.name), node.x + 6, node.y) + } + ctx.globalAlpha = 1 + } + + if (!this.graph) { + this.graph = new ForceGraph(this.element) + this.graph + .backgroundColor('rgba(0,0,0,0)') + .nodeRelSize(4) + .nodeLabel((node) => `${node.name} · ${node.kind}`) + .nodePointerAreaPaint((node, colour, ctx) => { + ctx.fillStyle = colour + ctx.beginPath() + ctx.arc(node.x, node.y, 7, 0, 2 * Math.PI) + ctx.fill() + }) + .linkWidth(0.7) + .linkDirectionalArrowLength(3) + .linkDirectionalArrowRelPos(1) + .linkCanvasObjectMode(() => 'after') + .linkCanvasObject((link, ctx, scale) => { + const start = link.source + const end = link.target + if (!link.type || typeof start !== 'object' || typeof end !== 'object') return + if (!this.labelled && scale <= 1.4) return + const size = Math.max(9 / scale, 1.5) + ctx.font = `${size}px monospace` + ctx.fillStyle = canvasColour('--canvas-label') + ctx.textAlign = 'center' + ctx.textBaseline = 'middle' + ctx.fillText(link.type, (start.x + end.x) / 2, (start.y + end.y) / 2) + }) + .onNodeClick((node) => this.select(node)) + .onBackgroundClick(() => this.select(null)) + this.graph.onEngineStop(() => this.graph.zoomToFit(500, 40)) + } + + this.graph + .nodeCanvasObject(this.paintNode) + .linkColor(() => canvasColour('--canvas-link')) + .dagMode(dag) + .dagLevelDistance(dag ? 90 : 40) + .onDagError(() => undefined) + .width(this.element.clientWidth) + .height(this.element.clientHeight) + .graphData(data) + } +} diff --git a/internal/ui/assets/icons.js b/internal/ui/assets/icons.js new file mode 100644 index 0000000..5a5b092 --- /dev/null +++ b/internal/ui/assets/icons.js @@ -0,0 +1,30 @@ +/* The dashboard draws with lucide. These are the same glyphs, inlined, so the + * page needs nothing from a network it may not have. */ +const ICON_PATHS = { + ant: '', + boxes: '', + network: '', + lightbulb: '', + layout: '', + folder: '', + plus: '', + trash: '', + refresh: '', + sun: '', + moon: '', + x: '', + check: '', + chevronUp: '', + chevronRight: '', + loader: '', + file: '', + link: '', + pencil: '', + search: '', +} + +function icon(name, size = 16, extra = '') { + const paths = ICON_PATHS[name] || '' + return `${paths}` +} diff --git a/internal/ui/assets/index.html b/internal/ui/assets/index.html index d261c7c..80d2c06 100644 --- a/internal/ui/assets/index.html +++ b/internal/ui/assets/index.html @@ -3,69 +3,33 @@ -Code graph · SourceAnt +SourceAnt -
-
-
- -
-

Code graph

-

What the indexer found on this machine.

-
-
-
- - -
-
- -
-
-
- - - - - -
-
- -
-
-
Loading…
- +
+ +
- - -
-
-
-
+
+
+
+ + + diff --git a/internal/ui/assets/styles.css b/internal/ui/assets/styles.css index 888fac1..5e75fce 100644 --- a/internal/ui/assets/styles.css +++ b/internal/ui/assets/styles.css @@ -1,35 +1,65 @@ -/* The tokens are the dashboard's, so the local view and the hosted one read as +/* The tokens are the dashboard's, so the local app and the hosted one read as one product. Dark is the default there and here; .light is the override. */ :root, -.light { - --background: 240 20% 98%; - --foreground: 240 10% 10%; - --card: 0 0% 100%; - --muted: 240 10% 94%; - --muted-foreground: 240 5% 45%; - --border: 240 10% 90%; - --primary: 357 89% 47%; - --primary-foreground: 0 0% 100%; - --accent: 357 60% 96%; - --radius: 0.25rem; - --canvas-link: #b4b4bd; - --canvas-label: #52525b; - color-scheme: light; -} - .dark { + color-scheme: dark; --background: 240 10% 3.9%; --foreground: 0 0% 98%; --card: 240 9% 7%; - --muted: 240 5% 14%; - --muted-foreground: 240 5% 64.9%; - --border: 240 6% 16%; + --card-foreground: 0 0% 98%; + --popover: 240 9% 7%; --primary: 357 89% 47%; --primary-foreground: 0 0% 100%; + --secondary: 240 4% 16%; + --secondary-foreground: 0 0% 98%; + --muted: 240 5% 14%; + --muted-foreground: 240 5% 64.9%; --accent: 240 4% 16%; + --accent-foreground: 0 0% 98%; + --destructive: 0 62.8% 50.6%; + --destructive-foreground: 0 0% 98%; + --success: 142 71% 45%; + --warning: 38 92% 50%; + --border: 240 6% 16%; + --input: 240 6% 16%; + --ring: 357 89% 47%; + --radius: 0.25rem; + --pillar-memory: 217 91% 60%; + --pillar-graph: 262 83% 66%; + --pillar-review: 142 71% 45%; + --pillar-tokens: 38 92% 50%; --canvas-link: #52525b; --canvas-label: #9ca3af; - color-scheme: dark; +} + +.light { + color-scheme: light; + --background: 240 20% 98%; + --foreground: 240 10% 10%; + --card: 0 0% 100%; + --card-foreground: 240 10% 10%; + --popover: 0 0% 100%; + --primary: 357 89% 47%; + --primary-foreground: 0 0% 100%; + --secondary: 240 10% 94%; + --secondary-foreground: 240 10% 20%; + --muted: 240 10% 94%; + --muted-foreground: 240 5% 45%; + --accent: 357 60% 96%; + --accent-foreground: 357 70% 40%; + --destructive: 0 84% 60%; + --destructive-foreground: 0 0% 100%; + --success: 142 70% 35%; + --warning: 38 92% 45%; + --border: 240 10% 90%; + --input: 240 10% 90%; + --ring: 357 89% 47%; + --pillar-memory: 217 91% 55%; + --pillar-graph: 262 83% 58%; + --pillar-review: 142 71% 40%; + --pillar-tokens: 38 92% 45%; + --canvas-link: #b4b4bd; + --canvas-label: #52525b; } * { @@ -37,21 +67,146 @@ border-color: hsl(var(--border)); } +/* Anything given a display beats the browser's own rule for the hidden + attribute, so hiding has to say so louder than laying out does. */ +[hidden] { + display: none !important; +} + +html, +body { + height: 100%; +} + body { margin: 0; - padding: 2rem 1.5rem; + display: flex; + flex-direction: column; background: hsl(var(--background)); color: hsl(var(--foreground)); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; + font-size: 14px; -webkit-font-smoothing: antialiased; } +svg { + flex: none; +} + +/* Header, at the dashboard's 3rem with its blurred card background. */ +header.bar { + height: 3rem; + flex: none; + z-index: 40; + border-bottom: 1px solid hsl(var(--border)); + background: hsl(var(--card) / 0.8); + backdrop-filter: blur(4px); +} + +.bar-inner { + height: 100%; + display: flex; + align-items: center; + gap: 0.25rem; + padding: 0 1rem; + min-width: 0; +} + +.logo { + display: flex; + align-items: center; + gap: 0.5rem; + margin-right: 0.75rem; + font-weight: 600; + color: hsl(var(--foreground)); + text-decoration: none; + flex: none; +} + +.logo-mark { + width: 1.5rem; + height: 1.5rem; + display: grid; + place-items: center; + border-radius: var(--radius); + background: hsl(var(--primary)); + color: hsl(var(--primary-foreground)); +} + +.divider { + width: 1px; + height: 1rem; + background: hsl(var(--border)); + margin: 0 0.25rem; + flex: none; +} + +nav.tabs { + display: flex; + align-items: center; + gap: 0.125rem; + min-width: 0; + overflow-x: auto; + scrollbar-width: none; +} + +nav.tabs::-webkit-scrollbar { + display: none; +} + +nav.tabs a { + display: flex; + flex: none; + align-items: center; + gap: 0.375rem; + padding: 0.25rem 0.625rem; + border-radius: var(--radius); + font-size: 0.875rem; + color: hsl(var(--muted-foreground)); + text-decoration: none; + transition: background-color 0.15s, color 0.15s; +} + +nav.tabs a:hover { + background: hsl(var(--muted)); + color: hsl(var(--foreground)); +} + +nav.tabs a[aria-current="page"] { + background: hsl(var(--primary) / 0.1); + color: hsl(var(--primary)); + font-weight: 500; +} + +.spacer { + flex: 1; + min-width: 0; +} + main { + flex: 1; + min-height: 0; + overflow-y: auto; +} + +.container { max-width: 1400px; margin: 0 auto; + padding: 1rem 1.5rem 1.5rem; + display: flex; + flex-direction: column; + min-height: 100%; } -header { +/* A page that fills the space it is given needs a definite height to resolve + against, not a minimum, or it grows to its content instead. */ +.container.fills { + height: 100%; + min-height: 0; +} + +/* Page heading, matching the dashboard's icon tile and two lines. */ +.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; @@ -60,23 +215,41 @@ header { margin-bottom: 1.5rem; } -.title { +.page-title { display: flex; align-items: center; gap: 0.75rem; } -.mark { +.tile { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border-radius: calc(var(--radius) + 2px); - background: hsl(262 83% 66% / 0.15); - color: hsl(262 83% 66%); flex: none; } +.tile.graph { + background: hsl(var(--pillar-graph) / 0.15); + color: hsl(var(--pillar-graph)); +} + +.tile.memory { + background: hsl(var(--pillar-memory) / 0.15); + color: hsl(var(--pillar-memory)); +} + +.tile.review { + background: hsl(var(--pillar-review) / 0.15); + color: hsl(var(--pillar-review)); +} + +.tile.tokens { + background: hsl(var(--pillar-tokens) / 0.15); + color: hsl(var(--pillar-tokens)); +} + h1 { font-size: 1.25rem; font-weight: 600; @@ -84,37 +257,185 @@ h1 { line-height: 1.3; } -.subtitle { +.sub { margin: 0.15rem 0 0; font-size: 0.875rem; color: hsl(var(--muted-foreground)); } -select, +/* Card */ +.card { + border: 1px solid hsl(var(--border)); + border-radius: 0.5rem; + background: hsl(var(--card)); + color: hsl(var(--card-foreground)); + box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); +} + +.card-pad { + padding: 1rem 1.25rem; +} + +.card + .card { + margin-top: 0.75rem; +} + +/* Button, mirroring the dashboard's variants. */ +.btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.375rem; + white-space: nowrap; + height: 2.25rem; + padding: 0 1rem; + border: 0; + border-radius: var(--radius); + font: inherit; + font-size: 0.875rem; + font-weight: 500; + cursor: pointer; + background: hsl(var(--primary)); + color: hsl(var(--primary-foreground)); + box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); + transition: background-color 0.15s, color 0.15s; +} + +.btn:hover:not(:disabled) { + background: hsl(var(--primary) / 0.9); +} + +.btn:disabled { + opacity: 0.5; + pointer-events: none; +} + +.btn.outline { + background: hsl(var(--background)); + color: hsl(var(--foreground)); + border: 1px solid hsl(var(--input)); +} + +.btn.outline:hover:not(:disabled) { + background: hsl(var(--accent)); + color: hsl(var(--accent-foreground)); +} + +.btn.ghost { + background: none; + color: hsl(var(--muted-foreground)); + box-shadow: none; +} + +.btn.ghost:hover:not(:disabled) { + background: hsl(var(--accent)); + color: hsl(var(--accent-foreground)); +} + +.btn.destructive { + background: hsl(var(--destructive)); + color: hsl(var(--destructive-foreground)); +} + +.btn.sm { + height: 2rem; + padding: 0 0.75rem; + font-size: 0.75rem; +} + +.btn.icon { + width: 2.25rem; + padding: 0; +} + +/* Badge */ +.badge { + display: inline-flex; + align-items: center; + border: 1px solid transparent; + border-radius: 9999px; + padding: 0.125rem 0.625rem; + font-size: 0.75rem; + font-weight: 600; +} + +.badge.secondary { + background: hsl(var(--secondary)); + color: hsl(var(--secondary-foreground)); +} + +.badge.success { + background: hsl(var(--success) / 0.2); + color: hsl(var(--success)); +} + +.badge.warning { + background: hsl(var(--warning) / 0.2); + color: hsl(var(--warning)); +} + +.badge.glow { + border-color: hsl(var(--primary) / 0.3); + background: hsl(var(--primary) / 0.1); + color: hsl(var(--primary)); +} + +.badge.outline { + border-color: hsl(var(--border)); + color: hsl(var(--foreground)); +} + +/* Inputs */ +input[type="text"], input[type="search"], -button { +textarea, +select { + width: 100%; font: inherit; - color: inherit; - background: hsl(var(--card)); - border: 1px solid hsl(var(--border)); - border-radius: calc(var(--radius) + 2px); - padding: 0.375rem 0.75rem; font-size: 0.875rem; + color: hsl(var(--foreground)); + background: hsl(var(--muted) / 0.5); + border: 1px solid hsl(var(--input)); + border-radius: var(--radius); + padding: 0.5rem 0.75rem; + outline: none; } -button { - cursor: pointer; +input:focus, +textarea:focus, +select:focus { + border-color: hsl(var(--primary) / 0.5); } -.controls { - display: flex; - flex-wrap: wrap; +textarea { + resize: vertical; + min-height: 5rem; +} + +label.field { + display: block; + margin-bottom: 0.375rem; + font-size: 0.75rem; + font-weight: 500; + text-transform: uppercase; + letter-spacing: 0.05em; + color: hsl(var(--muted-foreground)); +} + +.field-row + .field-row { + margin-top: 1rem; +} + +.checkline { + display: inline-flex; align-items: center; - justify-content: space-between; - gap: 0.75rem; - margin-bottom: 0.75rem; + gap: 0.375rem; + font-size: 0.75rem; + color: hsl(var(--muted-foreground)); + cursor: pointer; } +/* Segmented control */ .segmented { display: inline-flex; gap: 0.125rem; @@ -128,10 +449,12 @@ button { border: 0; background: none; padding: 0.25rem 0.75rem; + font: inherit; font-size: 0.75rem; font-weight: 500; color: hsl(var(--muted-foreground)); border-radius: var(--radius); + cursor: pointer; transition: background-color 0.15s, color 0.15s; } @@ -140,33 +463,237 @@ button { color: hsl(var(--primary)); } -.toggles { +/* Lists */ +.rows { + display: flex; + flex-direction: column; +} + +.row { display: flex; align-items: center; - gap: 1rem; + gap: 0.75rem; + padding: 0.875rem 1.25rem; + border-bottom: 1px solid hsl(var(--border)); +} + +.row:last-child { + border-bottom: 0; +} + +.row-main { + min-width: 0; + flex: 1; +} + +.row-title { + font-weight: 500; + overflow-wrap: anywhere; +} + +.row-sub { + margin-top: 0.15rem; font-size: 0.75rem; color: hsl(var(--muted-foreground)); + font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; + overflow-wrap: anywhere; +} + +.row-actions { + display: flex; + gap: 0.375rem; + flex: none; +} + +/* Card grid, as the dashboard lists repositories. */ +.grid-cards { + display: grid; + gap: 0.75rem; +} + +.item { + display: flex; + align-items: flex-start; + gap: 1rem; + padding: 1.25rem; +} + +.card.hoverable { + transition: border-color 0.2s, transform 0.2s; +} + +.card.hoverable:hover { + border-color: hsl(var(--primary) / 0.5); + transform: translateY(-2px); +} + +.item-icon { + width: 2.75rem; + height: 2.75rem; + display: grid; + place-items: center; + border-radius: 0.5rem; + flex: none; + background: hsl(var(--pillar-graph) / 0.15); + color: hsl(var(--pillar-graph)); } -.toggles label { +.item-body { + flex: 1; + min-width: 0; +} + +.item-head { + display: flex; + align-items: center; + gap: 0.5rem; + margin-bottom: 0.25rem; + flex-wrap: wrap; +} + +.item-head h3 { + margin: 0; + font-size: 0.9375rem; + font-weight: 600; + overflow-wrap: anywhere; +} + +.item-path { + font-size: 0.8125rem; + color: hsl(var(--muted-foreground)); + font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; + overflow-wrap: anywhere; +} + +.item-meta { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.25rem 1rem; + margin-top: 0.5rem; + font-size: 0.8125rem; + color: hsl(var(--muted-foreground)); +} + +.item-meta span { display: inline-flex; align-items: center; gap: 0.375rem; - cursor: pointer; } +.item-actions { + display: flex; + gap: 0.25rem; + flex: none; +} + +.summary { + margin: 0.25rem 0 0; + font-size: 0.875rem; + color: hsl(var(--muted-foreground)); + overflow-wrap: anywhere; +} + +.props { + margin: 0.5rem 0 0; + display: grid; + grid-template-columns: auto 1fr; + gap: 0.2rem 0.75rem; + font-size: 0.75rem; +} + +.props dt { + color: hsl(var(--muted-foreground)); +} + +.props dd { + margin: 0; + font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; + overflow-wrap: anywhere; +} + +.spin { + animation: spin 1s linear infinite; +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +/* Stats */ +.stats { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); + gap: 0.75rem; + margin-bottom: 1.5rem; +} + +.stat { + padding: 1rem 1.25rem; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.stat-label { + font-size: 0.75rem; + color: hsl(var(--muted-foreground)); +} + +.stat-value { + margin-top: 0.25rem; + font-size: 1.5rem; + font-weight: 600; + font-variant-numeric: tabular-nums; +} + +/* Empty state */ +.empty { + padding: 3rem 1.5rem; + text-align: center; + color: hsl(var(--muted-foreground)); +} + +.empty h2 { + margin: 0 0 0.5rem; + font-size: 1rem; + font-weight: 600; + color: hsl(var(--foreground)); +} + +.empty p { + margin: 0 auto 1rem; + max-width: 32rem; + font-size: 0.875rem; +} + +code { + font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; + font-size: 0.8125rem; + background: hsl(var(--muted)); + padding: 0.1rem 0.35rem; + border-radius: var(--radius); +} + +/* Graph stage */ +/* The graph fills what is left rather than growing to its canvas. + flex-basis 0 with min-height 0 is what stops a flex item being sized by its + content, which for a canvas is whatever height it was last given. */ .stage { position: relative; + flex: 1 1 0; + min-height: 0; border: 1px solid hsl(var(--border)); - border-radius: calc(var(--radius) + 4px); + border-radius: 0.5rem; background: hsl(var(--card)); overflow: hidden; } #canvas { - height: 62vh; - min-height: 420px; width: 100%; + height: 100%; } .overlay { @@ -181,18 +708,6 @@ button { background: hsl(var(--card)); } -.overlay[hidden] { - display: none; -} - -.overlay code { - font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; - font-size: 0.8125rem; - background: hsl(var(--muted)); - padding: 0.15rem 0.4rem; - border-radius: var(--radius); -} - .details { position: absolute; top: 0.75rem; @@ -205,12 +720,8 @@ button { border-radius: calc(var(--radius) + 2px); } -.details[hidden] { - display: none; -} - .details h2 { - margin: 0 0 0.5rem; + margin: 0 1.5rem 0.5rem 0; font-size: 0.9375rem; font-weight: 600; overflow-wrap: anywhere; @@ -234,24 +745,12 @@ button { overflow-wrap: anywhere; } -.details button { +.details .btn.icon { position: absolute; - top: 0.5rem; - right: 0.5rem; - border: 0; - background: none; - padding: 0.25rem; - line-height: 1; - color: hsl(var(--muted-foreground)); -} - -footer { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: space-between; - gap: 1rem; - margin-top: 1rem; + top: 0.4rem; + right: 0.4rem; + width: 1.75rem; + height: 1.75rem; } .legend { @@ -275,21 +774,146 @@ footer { flex: none; } +.toolbar { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + margin-bottom: 0.75rem; +} + +.toolbar-group { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.75rem; +} + +.toolbar input[type="search"], +.toolbar select, +.page-head select { + width: auto; + min-width: 12rem; +} + +.foot { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 1rem; + margin-top: 0.75rem; +} + .tally { font-size: 0.75rem; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; } -.warning { - margin-top: 0.75rem; - padding: 0.625rem 0.875rem; +/* Notices */ +.notice { + padding: 0.75rem 1rem; + margin-bottom: 1rem; font-size: 0.8125rem; - border: 1px solid hsl(38 92% 50% / 0.35); - background: hsl(38 92% 50% / 0.1); border-radius: calc(var(--radius) + 2px); + border: 1px solid hsl(var(--warning) / 0.35); + background: hsl(var(--warning) / 0.1); } -.warning[hidden] { - display: none; +.notice.bad { + border-color: hsl(var(--destructive) / 0.4); + background: hsl(var(--destructive) / 0.12); +} + +/* Modal */ +.scrim { + position: fixed; + inset: 0; + z-index: 50; + display: grid; + place-items: center; + padding: 1rem; + background: rgb(0 0 0 / 0.6); + backdrop-filter: blur(2px); +} + +.modal { + width: 100%; + max-width: 34rem; + max-height: 85vh; + overflow-y: auto; + padding: 1.25rem 1.5rem 1.5rem; + border: 1px solid hsl(var(--border)); + border-radius: 0.5rem; + background: hsl(var(--popover)); + box-shadow: 0 10px 30px rgb(0 0 0 / 0.35); +} + +.modal h2 { + margin: 0 0 1rem; + font-size: 1.125rem; + font-weight: 600; +} + +.modal-actions { + display: flex; + align-items: center; + gap: 0.5rem; + padding-top: 1.25rem; +} + +/* Folder picker */ +.crumbs { + display: flex; + align-items: center; + gap: 0.375rem; + margin-bottom: 0.5rem; + font-size: 0.75rem; + color: hsl(var(--muted-foreground)); + font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; + overflow-wrap: anywhere; +} + +.picker { + height: 16rem; + overflow-y: auto; + border: 1px solid hsl(var(--border)); + border-radius: var(--radius); + background: hsl(var(--muted) / 0.3); +} + +.picker button { + display: flex; + align-items: center; + gap: 0.5rem; + width: 100%; + padding: 0.5rem 0.75rem; + border: 0; + background: none; + font: inherit; + font-size: 0.8125rem; + color: hsl(var(--foreground)); + cursor: pointer; + text-align: left; +} + +.picker button:hover { + background: hsl(var(--accent)); +} + +.picker .marker { + margin-left: auto; + flex: none; +} + +.muted { + color: hsl(var(--muted-foreground)); +} + +.tight { + margin: 0.5rem 0 0; + font-size: 0.75rem; + color: hsl(var(--muted-foreground)); } diff --git a/internal/ui/ui_test.go b/internal/ui/ui_test.go index 02d50fe..1a8bbe4 100644 --- a/internal/ui/ui_test.go +++ b/internal/ui/ui_test.go @@ -23,7 +23,10 @@ func TestItServesEveryAssetThePageAsksFor(t *testing.T) { } body := page.Body.String() - for _, asset := range []string{"styles.css", "app.js", "vendor/force-graph.min.js", "favicon.svg"} { + for _, asset := range []string{ + "styles.css", "app.js", "icons.js", "graph.js", + "vendor/force-graph.min.js", "favicon.svg", + } { if !strings.Contains(body, asset) { t.Errorf("the page does not ask for %s", asset) continue From a8c216075f83a8c0ff47dc61022a5f1ee7d17f9b Mon Sep 17 00:00:00 2001 From: nfebe Date: Fri, 28 Aug 2026 23:38:01 +0100 Subject: [PATCH 05/27] feat: Build the view on one design system rather than a copy of one The local view is Vue now, built by Vite into what the binary embeds. It uses one set of tokens and components rather than copies of them: the same Card, Button, Badge, Avatar and Logo, lucide for icons, force-graph in 2D and 3d-force-graph for Tree, Radial, Layered and Force. Copying a design by hand is what let the two drift apart. The mark was a glyph somebody drew instead of the ant, the navigation used names nothing else uses, the theme sat on a bare button rather than under the account, and every mode but the flat one had quietly stopped being three-dimensional. Navigation covers what a machine has. Anything needing a pull request or another person is absent, because nothing on a machine produces one. Nobody signs in to their own machine, so the avatar is generated from the machine's name. It is there because the shell has a shape people know, not because there is an account behind it. --- .gitignore | 2 + Makefile | 26 +- README.md | 8 +- internal/ui/assets/app.js | 646 --- .../assets/assets/3d-force-graph-9_wZMVcC.js | 1151 +++++ internal/ui/assets/assets/Paired-B5xWXdbq.js | 14 + .../ui/assets/assets/force-graph-BunJtbL4.js | 29 + internal/ui/assets/assets/index-BqUe1JKj.css | 1 + internal/ui/assets/assets/index-CsXy5pyf.js | 169 + .../assets/three-spritetext-vp3JBkiZ.js | 4 + .../ui/assets/assets/three.module-CGesFut6.js | 4116 +++++++++++++++++ internal/ui/assets/favicon.svg | 11 +- internal/ui/assets/graph.js | 225 - internal/ui/assets/icons.js | 30 - internal/ui/assets/index.html | 35 +- internal/ui/assets/styles.css | 919 ---- internal/ui/assets/vendor/force-graph.LICENSE | 21 - internal/ui/assets/vendor/force-graph.min.js | 5 - internal/ui/ui_test.go | 53 +- ui/index.html | 13 + ui/package-lock.json | 3466 ++++++++++++++ ui/package.json | 34 + ui/postcss.config.js | 6 + ui/public/favicon.svg | 10 + ui/src/App.vue | 169 + ui/src/api.js | 39 + ui/src/assets/main.css | 163 + ui/src/components/CodeGraph.vue | 182 + ui/src/components/EmptyMachine.vue | 19 + ui/src/components/FolderPicker.vue | 112 + ui/src/components/PageHead.vue | 32 + ui/src/components/ui/Avatar.vue | 51 + ui/src/components/ui/Badge.vue | 41 + ui/src/components/ui/Button.vue | 58 + ui/src/components/ui/Card.vue | 28 + ui/src/components/ui/Logo.vue | 49 + ui/src/components/ui/Modal.vue | 73 + ui/src/composables/useRepositories.js | 29 + ui/src/composables/useTheme.js | 30 + ui/src/lib/graph.js | 92 + ui/src/lib/utils.ts | 6 + ui/src/main.js | 25 + ui/src/pages/Graph.vue | 182 + ui/src/pages/Knowledge.vue | 211 + ui/src/pages/Overview.vue | 97 + ui/src/pages/Repositories.vue | 128 + ui/src/pages/Settings.vue | 70 + ui/tailwind.config.js | 124 + ui/vite.config.js | 20 + 49 files changed, 11123 insertions(+), 1901 deletions(-) delete mode 100644 internal/ui/assets/app.js create mode 100644 internal/ui/assets/assets/3d-force-graph-9_wZMVcC.js create mode 100644 internal/ui/assets/assets/Paired-B5xWXdbq.js create mode 100644 internal/ui/assets/assets/force-graph-BunJtbL4.js create mode 100644 internal/ui/assets/assets/index-BqUe1JKj.css create mode 100644 internal/ui/assets/assets/index-CsXy5pyf.js create mode 100644 internal/ui/assets/assets/three-spritetext-vp3JBkiZ.js create mode 100644 internal/ui/assets/assets/three.module-CGesFut6.js delete mode 100644 internal/ui/assets/graph.js delete mode 100644 internal/ui/assets/icons.js delete mode 100644 internal/ui/assets/styles.css delete mode 100644 internal/ui/assets/vendor/force-graph.LICENSE delete mode 100644 internal/ui/assets/vendor/force-graph.min.js create mode 100644 ui/index.html create mode 100644 ui/package-lock.json create mode 100644 ui/package.json create mode 100644 ui/postcss.config.js create mode 100644 ui/public/favicon.svg create mode 100644 ui/src/App.vue create mode 100644 ui/src/api.js create mode 100644 ui/src/assets/main.css create mode 100644 ui/src/components/CodeGraph.vue create mode 100644 ui/src/components/EmptyMachine.vue create mode 100644 ui/src/components/FolderPicker.vue create mode 100644 ui/src/components/PageHead.vue create mode 100644 ui/src/components/ui/Avatar.vue create mode 100755 ui/src/components/ui/Badge.vue create mode 100755 ui/src/components/ui/Button.vue create mode 100644 ui/src/components/ui/Card.vue create mode 100755 ui/src/components/ui/Logo.vue create mode 100755 ui/src/components/ui/Modal.vue create mode 100644 ui/src/composables/useRepositories.js create mode 100644 ui/src/composables/useTheme.js create mode 100644 ui/src/lib/graph.js create mode 100755 ui/src/lib/utils.ts create mode 100644 ui/src/main.js create mode 100644 ui/src/pages/Graph.vue create mode 100644 ui/src/pages/Knowledge.vue create mode 100644 ui/src/pages/Overview.vue create mode 100644 ui/src/pages/Repositories.vue create mode 100644 ui/src/pages/Settings.vue create mode 100644 ui/tailwind.config.js create mode 100644 ui/vite.config.js diff --git a/.gitignore b/.gitignore index b8ba3ef..5c9de7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ sourceant-agent coverage.out coverage.html +ui/node_modules/ +ui/dist/ diff --git a/Makefile b/Makefile index 26105ca..28077fa 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help deps build test test-race test-coverage fmt fmt-check vet lint lint-install clean qa +.PHONY: help deps ui ui-deps ui-dev build build-go test test-race test-coverage fmt fmt-check vet lint lint-install clean qa BINARY_NAME=sourceant-agent VERSION?=$(shell cat VERSION 2>/dev/null || echo "dev") @@ -9,8 +9,11 @@ LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME) -X help: @echo "SourceAnt agent - build commands" @echo "" - @echo "make deps - Download dependencies" - @echo "make build - Build the agent binary" + @echo "make deps - Download dependencies, Go and npm" + @echo "make ui - Build the local view into what the binary embeds" + @echo "make ui-dev - Run the view against a running agent" + @echo "make build - Build the view, then the agent binary" + @echo "make build-go - Build the binary with whatever view is embedded" @echo "make test - Run unit tests" @echo "make test-race - Run unit tests under the race detector" @echo "make test-coverage - Run tests with a coverage report" @@ -21,11 +24,24 @@ help: @echo "make qa - Run fmt-check, vet, lint, and tests" @echo "make clean - Clean build artifacts" -deps: +deps: ui-deps go mod download go mod tidy -build: +ui-deps: + cd ui && npm install --no-audit --no-fund + +# Vite writes into internal/ui/assets, which is what the binary embeds, so a +# build and the sources it came from cannot disagree. +ui: + cd ui && npm run build + +ui-dev: + cd ui && npm run dev + +build: ui build-go + +build-go: go build $(LDFLAGS) -o $(BINARY_NAME) ./cmd/agent test: diff --git a/README.md b/README.md index 578f955..7513090 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,11 @@ It never parses code. The grammars and the graph shape live in the Python core, Starts the core on a free port and waits for it to answer. Restarts it when it dies, backing off as failures repeat. Serves its own HTTP surface on `127.0.0.1:8930`, where `/health` reports whether the core is up and how many times it has been started, and `/api/repositories` and `/api/graph` read the index. -It also serves the graph view at `/`. The assets are embedded in the binary, so the view works with no network and cannot drift from the agent serving it. +It also serves the local view at `/`: Overview, Knowledge graph, Knowledge, Repositories, Settings. The assets are embedded in the binary, so the view works with no network and cannot drift from the agent serving it. + +The view is Vue, built by Vite from `ui/`, and it takes the dashboard's design system rather than imitating it: the same tokens, the same Card, Button, Badge, Avatar and Logo, lucide for icons, force-graph in 2D and 3d-force-graph for Tree, Radial, Layered and Force. Copying a design by hand is what let the two drift apart the first time. + +There are no reviews here. A review reads a pull request, which is a thing the hosted service does. What opens is the repository's shape: folders and files. Symbols, imports and the test suite are there to be asked for, because a repository's every function is a texture rather than a picture. The folder nodes are this view's arrangement, read out of the paths the index already carries; the index stores no folders of its own. @@ -16,6 +20,8 @@ Loopback is the default because the agent reads a working tree. The machine it r ## Running it +Building needs Go and npm: `make build` builds the view, then the binary that embeds it. `make build-go` skips the view when nothing about it changed, and `make ui-dev` runs it against an agent already running. + ```bash make build ./sourceant-agent diff --git a/internal/ui/assets/app.js b/internal/ui/assets/app.js deleted file mode 100644 index 542895b..0000000 --- a/internal/ui/assets/app.js +++ /dev/null @@ -1,646 +0,0 @@ -/* The local SourceAnt app: what this machine has indexed, and what is known - * about it. Everything comes from the agent, which is the only thing that - * knows where the indexer is. */ - -const view = document.getElementById('view') -const layer = document.getElementById('layer') -const tabs = document.getElementById('tabs') -const themeButton = document.getElementById('theme') - -const PAGES = [ - { id: '', label: 'Overview', icon: 'layout' }, - { id: 'repositories', label: 'Repositories', icon: 'boxes' }, - { id: 'graph', label: 'Code graph', icon: 'network' }, - { id: 'knowledge', label: 'Knowledge', icon: 'lightbulb' }, -] - -const state = { - page: '', - repositories: [], - repository: '', - status: null, - graph: null, - error: '', -} - -function escape(text) { - return String(text ?? '').replace(/[&<>"']/g, (c) => - ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]) -} - -async function api(path, options = {}) { - const response = await fetch(path, { - ...options, - headers: options.body ? { 'Content-Type': 'application/json' } : undefined, - }) - const text = await response.text() - const body = text ? JSON.parse(text) : null - if (!response.ok) throw new Error(body?.error || `the agent answered ${response.status}`) - return body -} - -/* Rendering */ - -document.querySelector('.logo-mark').innerHTML = icon('ant', 15) - -function renderTabs() { - tabs.innerHTML = PAGES.map((page) => ` - - ${icon(page.icon, 14)}${page.label} - `).join('') -} - -function head({ tile, iconName, title, sub, actions = '' }) { - return ` -
-
- ${icon(iconName, 24)} -

${escape(title)}

${escape(sub)}

-
-
${actions}
-
` -} - -function notice(message, bad = true) { - return message ? `

${escape(message)}

` : '' -} - -function needRepository() { - return ` -
-

Nothing indexed yet

-

Add a folder and SourceAnt reads it into a graph you can look at and record against.

- ${icon('plus', 16)} Add a repository -
` -} - -function repositoryPicker() { - if (state.repositories.length < 2) return '' - return `` -} - -/* Overview */ - -async function overview() { - view.innerHTML = head({ - tile: 'memory', iconName: 'layout', - title: 'Overview', - sub: 'What SourceAnt has on this machine.', - }) + notice(state.error) + '
' - - const body = document.getElementById('body') - if (state.repositories.length === 0) { - body.innerHTML = needRepository() - return - } - - const counts = await Promise.all(state.repositories.map(async (repository) => { - const [graph, knowledge] = await Promise.all([ - api(`/api/graph?repository=${encodeURIComponent(repository.name)}`).catch(() => null), - api(`/api/knowledge?repository=${encodeURIComponent(repository.name)}`).catch(() => null), - ]) - return { - repository, - files: graph ? graph.nodes.filter((n) => (n.labels || []).includes('File')).length : 0, - nodes: graph ? graph.nodes.length : 0, - knowledge: knowledge ? knowledge.total : 0, - } - })) - - const total = (key) => counts.reduce((sum, item) => sum + item[key], 0) - body.innerHTML = ` -
- ${stat('Repositories', state.repositories.length)} - ${stat('Files', total('files'))} - ${stat('Nodes', total('nodes'))} - ${stat('Knowledge', total('knowledge'))} -
-
${counts.map(({ repository, files, knowledge }) => ` -
- ${icon('folder', 22)} -
-

${escape(repository.name)}

- ${files ? 'Indexed' : 'Not indexed'} -
-

${escape(repository.path)}

-
- ${icon('file', 14)} ${files.toLocaleString()} files - ${icon('lightbulb', 14)} ${knowledge.toLocaleString()} recorded -
-
-
- Graph -
-
`).join('')} -
-

Reviews are not here. A review reads a pull request, which is a thing the - hosted service does; nothing on this machine produces one.

` -} - -function stat(label, value) { - return `
${escape(label)}
-
${value.toLocaleString()}
` -} - -/* Repositories */ - -async function repositories() { - view.innerHTML = head({ - tile: 'graph', iconName: 'boxes', - title: 'Repositories', - sub: 'The folders SourceAnt reads on this machine.', - actions: ``, - }) + notice(state.error) + '
' - - document.getElementById('add').onclick = openPicker - const body = document.getElementById('body') - - if (state.repositories.length === 0) { - body.innerHTML = `
-

No folders yet

-

Point SourceAnt at a repository on this machine and it reads the files into a graph.

- -
` - document.getElementById('add-empty').onclick = openPicker - return - } - - body.innerHTML = `
${state.repositories.map((repository) => ` -
- ${icon('folder', 22)} -
-

${escape(repository.name)}

-

${escape(repository.path)}

-
- Reading… -
-
-
- - -
-
`).join('')}
` - - for (const button of body.querySelectorAll('[data-index]')) { - button.onclick = () => reindex(button.dataset.index, button) - } - for (const button of body.querySelectorAll('[data-drop]')) { - button.onclick = () => drop(button.dataset.drop) - } - - for (const repository of state.repositories) { - const graph = await api(`/api/graph?repository=${encodeURIComponent(repository.name)}`).catch(() => null) - const slot = body.querySelector(`[data-counts="${CSS.escape(repository.name)}"]`) - if (!slot) continue - const files = graph ? graph.nodes.filter((n) => (n.labels || []).includes('File')).length : 0 - slot.innerHTML = files - ? `${icon('file', 14)} ${files.toLocaleString()} files - ${icon('link', 14)} ${graph.links.length.toLocaleString()} links` - : 'Not indexed yet. Re-index to read it.' - } -} - -async function reindex(name, button) { - const original = button.innerHTML - button.disabled = true - button.innerHTML = `${icon('loader', 14, 'spin')} Reading…` - try { - await api('/api/index', { method: 'POST', body: JSON.stringify({ repository: name }) }) - state.error = '' - } catch (error) { - state.error = error.message - } - button.disabled = false - button.innerHTML = original - await route() -} - -async function drop(path) { - if (!confirm(`Stop covering ${path}?\n\nWhat was already indexed is left alone.`)) return - try { - await api(`/api/repositories?path=${encodeURIComponent(path)}`, { method: 'DELETE' }) - state.error = '' - } catch (error) { - state.error = error.message - } - await load() - await route() -} - -/* The folder picker. - * - * A browser will not tell a page the absolute path of a folder somebody chose, - * so the agent lists this machine and the page navigates what it lists. */ -function openPicker() { - let here = '' - const close = () => { layer.innerHTML = '' } - - const show = async (path) => { - let listing - try { - listing = await api(`/api/browse?path=${encodeURIComponent(path || '')}`) - } catch (error) { - layer.querySelector('#picker').innerHTML = - `

${escape(error.message)}

` - return - } - here = listing.path - layer.querySelector('#crumbs').textContent = here - layer.querySelector('#chosen').textContent = here - layer.querySelector('#picker').innerHTML = ` - ${listing.parent ? `` : ''} - ${listing.entries.map((entry) => ` - `).join('')} - ${listing.entries.length === 0 ? '

Nothing inside.

' : ''}` - for (const button of layer.querySelectorAll('[data-go]')) { - button.onclick = () => show(button.dataset.go) - } - } - - layer.innerHTML = ` -
` - - layer.querySelector('#cancel').onclick = close - layer.querySelector('#scrim').onclick = (event) => { - if (event.target.id === 'scrim') close() - } - layer.querySelector('#confirm').onclick = async () => { - const button = layer.querySelector('#confirm') - const problem = layer.querySelector('#picker-error') - button.disabled = true - button.innerHTML = `${icon('loader', 16, 'spin')} Reading…` - try { - await api('/api/repositories', { - method: 'POST', - body: JSON.stringify({ path: here, name: layer.querySelector('#repo-name').value.trim() }), - }) - await api('/api/index', { method: 'POST', body: JSON.stringify({ repository: '', everything: true }) }) - close() - await load() - await route() - } catch (error) { - problem.hidden = false - problem.textContent = error.message - button.disabled = false - button.innerHTML = `${icon('plus', 16)} Add and index` - } - } - - show('') -} - -/* Code graph */ - -let drawing = null - -async function graphPage() { - view.innerHTML = head({ - tile: 'graph', iconName: 'network', - title: 'Code graph', - sub: 'Your code, and how it holds together.', - actions: repositoryPicker(), - }) + notice(state.error) + '
' - - const body = document.getElementById('body') - if (state.repositories.length === 0) { - body.innerHTML = needRepository() - return - } - - body.innerHTML = ` -
-
${LAYOUTS.map((layout) => ` - `).join('')}
-
- - - - - -
-
-
-
-
Reading the index…
- -
- -
` - - const picker = document.getElementById('pick-repo') - if (picker) picker.onchange = () => { state.repository = picker.value; loadGraph() } - - drawing?.destroy() - drawing = new CodeGraph(document.getElementById('canvas'), { onSelect: showDetails }) - - document.getElementById('layouts').onclick = (event) => { - const button = event.target.closest('button[data-layout]') - if (!button) return - for (const other of document.querySelectorAll('#layouts button')) { - other.setAttribute('aria-pressed', String(other === button)) - } - drawing.setLayout(button.dataset.layout) - } - document.getElementById('find').oninput = (event) => drawing.highlight(event.target.value) - for (const id of ['folders', 'symbols', 'imports']) { - document.getElementById(id).onchange = redraw - } - document.getElementById('tests').onchange = loadGraph - - await loadGraph() -} - -async function loadGraph() { - const overlay = document.getElementById('overlay') - if (!overlay) return - overlay.hidden = false - overlay.textContent = 'Reading the index…' - try { - const tests = document.getElementById('tests').checked - state.graph = await api(`/api/graph?repository=${encodeURIComponent(state.repository)}${tests ? '&include_tests=true' : ''}`) - redraw() - } catch (error) { - overlay.textContent = error.message - } -} - -function redraw() { - if (!state.graph) return - const keepImports = document.getElementById('imports').checked - const keepSymbols = document.getElementById('symbols').checked - const nodes = state.graph.nodes.filter((node) => { - const group = groupOf(node) - if (group === 'import') return keepImports - if (group === 'file') return true - return keepSymbols - }) - const kept = new Set(nodes.map((node) => node.id)) - const links = state.graph.links - .filter((link) => kept.has(link.source) && kept.has(link.target)) - .map((link) => ({ ...link })) - - let data = { nodes: nodes.map((node) => ({ ...node })), links } - if (document.getElementById('folders').checked) data = withFolders(data, state.repository) - - drawing.show(data) - - const overlay = document.getElementById('overlay') - overlay.hidden = data.nodes.length > 0 - if (data.nodes.length === 0) { - overlay.innerHTML = 'Nothing here yet. Re-index it from Repositories.' - } - document.getElementById('tally').textContent = - `${data.nodes.length.toLocaleString()} nodes · ${data.links.length.toLocaleString()} links` - - const groups = [...new Set(data.nodes.map(groupOf))].sort() - document.getElementById('legend').innerHTML = groups.map((group) => - `${escape(group || 'other')}`).join('') - - const truncated = document.getElementById('truncated') - truncated.hidden = !state.graph.truncated - truncated.textContent = 'This repository is larger than the limit, so this is part of it, not all of it.' -} - -function showDetails(node) { - const panel = document.getElementById('details') - if (!panel) return - panel.hidden = !node - if (!node) return - const degree = state.graph.links.filter((link) => - link.source === node.id || link.target === node.id).length - panel.innerHTML = ` - -

${escape(node.name)}

-
-
Kind
${escape(node.synthetic ? `${node.kind} · this view's arrangement` : node.kind)}
-
Path
${escape(node.path || '—')}
-
Links
${node.synthetic ? '—' : degree}
-
` - document.getElementById('close-details').onclick = () => drawing.select(null) -} - -/* Knowledge */ - -async function knowledge() { - view.innerHTML = head({ - tile: 'memory', iconName: 'lightbulb', - title: 'Knowledge', - sub: 'The decisions, conventions and constraints behind this code.', - actions: `${repositoryPicker()} - `, - }) + notice(state.error) + '
' - - const body = document.getElementById('body') - if (state.repositories.length === 0) { - body.innerHTML = needRepository() - return - } - - const picker = document.getElementById('pick-repo') - if (picker) picker.onchange = () => { state.repository = picker.value; knowledge() } - document.getElementById('record').onclick = () => openRecord() - - let page - try { - page = await api(`/api/knowledge?repository=${encodeURIComponent(state.repository)}&limit=100`) - } catch (error) { - body.innerHTML = notice(error.message) - return - } - - if (page.items.length === 0) { - body.innerHTML = `
-

Nothing recorded yet

-

Why a thing is the way it is outlives the code that does it. Write one down and every - agent reading this repository over MCP gets it too.

- -
` - document.getElementById('record-empty').onclick = () => openRecord() - return - } - - body.innerHTML = `
${page.items.map((item) => ` -
- ${icon('lightbulb', 22)} -
-
-

${escape(item.id)}

- ${escape(item.kind)} - ${item.status ? `${escape(item.status)}` : ''} -
-

${escape(item.summary)}

- ${Object.keys(item.properties || {}).length ? `
${ - Object.entries(item.properties).map(([key, value]) => - `
${escape(key)}
${escape(typeof value === 'string' ? value : JSON.stringify(value))}
`).join('') - }
` : ''} -
-
- - -
-
`).join('')}
` - - for (const button of body.querySelectorAll('[data-edit]')) { - button.onclick = () => openRecord(page.items.find((item) => item.id === button.dataset.edit)) - } - for (const button of body.querySelectorAll('[data-forget]')) { - button.onclick = () => forget(button.dataset.forget) - } -} - -const KINDS = ['decision', 'convention', 'constraint', 'pattern', 'workaround', 'requirement'] - -function openRecord(existing) { - const close = () => { layer.innerHTML = '' } - layer.innerHTML = ` -
` - - layer.querySelector('#cancel').onclick = close - layer.querySelector('#scrim').onclick = (event) => { - if (event.target.id === 'scrim') close() - } - layer.querySelector('#save').onclick = async () => { - const problem = layer.querySelector('#record-error') - const id = layer.querySelector('#k-id').value.trim() - const summary = layer.querySelector('#k-summary').value.trim() - if (!id || !summary) { - problem.hidden = false - problem.textContent = 'A name and what is true are both needed.' - return - } - const why = layer.querySelector('#k-why').value.trim() - try { - await api('/api/knowledge', { - method: 'PUT', - body: JSON.stringify({ - repository: state.repository, - id, - kind: layer.querySelector('#k-kind').value, - status: existing?.status || 'accepted', - summary, - properties: why ? { ...(existing?.properties || {}), why } : (existing?.properties || {}), - }), - }) - close() - await knowledge() - } catch (error) { - problem.hidden = false - problem.textContent = error.message - } - } -} - -async function forget(id) { - if (!confirm(`Forget ${id}?`)) return - try { - await api(`/api/knowledge?repository=${encodeURIComponent(state.repository)}&id=${encodeURIComponent(id)}`, - { method: 'DELETE' }) - } catch (error) { - state.error = error.message - } - await knowledge() -} - -/* Shell */ - -async function load() { - try { - state.repositories = await api('/api/repositories') - state.error = '' - } catch (error) { - state.repositories = [] - state.error = `${error.message}. Is sourceant-agent running?` - } - if (!state.repositories.some((repository) => repository.name === state.repository)) { - state.repository = state.repositories[0]?.name || '' - } -} - -async function route() { - state.page = (location.hash.replace(/^#\/?/, '') || '').split('?')[0] - if (!PAGES.some((page) => page.id === state.page)) state.page = '' - renderTabs() - view.classList.toggle('fills', state.page === 'graph') - if (state.page !== 'graph') { - drawing?.destroy() - drawing = null - } - if (state.page === 'repositories') return repositories() - if (state.page === 'graph') return graphPage() - if (state.page === 'knowledge') return knowledge() - return overview() -} - -function setTheme(theme) { - document.documentElement.className = theme - themeButton.innerHTML = icon(theme === 'dark' ? 'sun' : 'moon', 16) - themeButton.setAttribute('aria-label', theme === 'dark' ? 'Light mode' : 'Dark mode') - try { - localStorage.setItem('sourceant-theme', theme) - } catch { - // A browser that refuses storage still gets the theme, just not the memory. - } - drawing?.repaint() -} - -themeButton.onclick = () => - setTheme(document.documentElement.className === 'dark' ? 'light' : 'dark') -window.addEventListener('hashchange', route) - -let stored = null -try { - stored = localStorage.getItem('sourceant-theme') -} catch { - stored = null -} -setTheme(stored === 'light' ? 'light' : 'dark') - -load().then(route) diff --git a/internal/ui/assets/assets/3d-force-graph-9_wZMVcC.js b/internal/ui/assets/assets/3d-force-graph-9_wZMVcC.js new file mode 100644 index 0000000..3c727cb --- /dev/null +++ b/internal/ui/assets/assets/3d-force-graph-9_wZMVcC.js @@ -0,0 +1,1151 @@ +import{C as Ua,R as tp,M as tt,T as kr,V as ce,P as wc,a as V,b as At,B as Hi,c as sr,S as Rc,d as Kt,e as rp,f as ea,L as Ky,G as sp,g as np,h as ip,i as Yy,Q as Qy,j as op,k as Zy,l as Jy,w as z,H as ht,m as Ec,N as Ds,n as ap,o as Ac,F as eb,p as tb,y as up,q as Be,r as O,s as We,t as ps,u as yt,v as er,x as He,z as ft,A as Ls,D as Gr,E as Ni,W as fa,I as br,J as js,K as rb,O as lp,U as sb,X as Cc,Y as cp,Z as nb,_ as ib,$ as ob,a0 as ab,a1 as ub,a2 as lb,a3 as cb,a4 as db,a5 as Tn,a6 as St,a7 as vn,a8 as Fs,a9 as Ze,aa as Ge,ab as dt,ac as dp,ad as qi,ae as Xi,af as Vr,ag as $r,ah as tr,ai as Ki,aj as Yi,ak as Mc,al as hp,am as fp,an as zr,ao as Bc,ap as Pc,aq as Oa,ar as pp,as as xr,at as Li,au as hb,av as fb,aw as ss,ax as Sn,ay as Dr,az as rs,aA as Mn,aB as pb,aC as Dc,aD as Fc,aE as pa,aF as Ia,aG as oe,aH as Qi,aI as Lc,aJ as Rd,aK as ka,aL as Ui,aM as gb,aN as ga,aO as Ga,aP as Oi,aQ as Va,aR as ls,aS as yl,aT as Bn,aU as gp,aV as Lt,aW as mp,aX as ma,aY as Pn,aZ as yp,a_ as Zi,a$ as Uc,b0 as bp,b1 as _p,b2 as Ed,b3 as Dn,b4 as mb,b5 as xp,b6 as Tp,b7 as vp,b8 as Sp,b9 as Np,ba as wp,bb as Rp,bc as Ep,bd as Ap,be as Cp,bf as Mp,bg as Bp,bh as yb,bi as bb,bj as _b,bk as Pp,bl as Wr,bm as mn,bn as yn,bo as bn,bp as Fr,bq as Dp,br as Fp,bs as Lp,bt as Up,bu as Op,bv as Ip,bw as kp,bx as Gp,by as Oc,bz as ta,bA as ra,bB as sa,bC as na,bD as Ad,bE as Cd,bF as Md,bG as Bd,bH as bl,bI as _l,bJ as xl,bK as Tl,bL as vl,bM as ya,bN as Sl,bO as Nl,bP as wl,bQ as Rl,bR as El,bS as Al,bT as Cl,bU as Ml,bV as Bl,bW as Pl,bX as Dl,bY as Fl,bZ as Ll,b_ as Ul,b$ as Ol,c0 as Il,c1 as kl,c2 as Gl,c3 as Vl,c4 as $l,c5 as ba,c6 as zl,c7 as Vp,c8 as xb,c9 as Tb,ca as vb,cb as Sb,cc as Nb,cd as wb,ce as Rb,cf as Eb,cg as Ab,ch as Cb,ci as Mb,cj as $a,ck as Ic,cl as Bb,cm as Pb,cn as Db,co as _a,cp as Fb,cq as Lb,cr as Ub,cs as Ob,ct as Ib,cu as kb,cv as Gb,cw as Vb,cx as $b,cy as zb,cz as Wb,cA as jb,cB as Hb,cC as qb,cD as Xb,cE as Kb,cF as Yb,cG as Qb,cH as $p,cI as zp,cJ as Zb,cK as Jb,cL as e_,cM as xa,cN as t_,cO as r_,cP as Wp,cQ as jp,cR as s_,cS as n_,cT as i_,cU as o_,cV as kc,cW as Hp,cX as a_,cY as u_,cZ as l_,c_,c$ as Ta,d0 as va,d1 as nu,d2 as iu,d3 as d_,d4 as h_,d5 as f_,d6 as p_,d7 as Pd,d8 as g_,d9 as Dd,da as m_,db as y_,dc as qp,dd as b_,de as __}from"./three.module-CGesFut6.js";import{l as pe,o as x_,k as T_,j as Gc,q as v_,r as S_,u as N_,v as w_,w as R_,y as E_,z as A_,h as Xp,x as C_,G as M_,A as Fd,E as Ld}from"./Paired-B5xWXdbq.js";const Nn=new wc,Lr=new ce,Kp=new V,ou=new ce,ia=new ce,Sa=new V,Wl=new V,Yp=new At,Qp=new V,Zp=new V;let lt=null,fr=null;const Ur=[],cs={NONE:-1,PAN:0,ROTATE:1};class B_ extends Ua{constructor(e,t,r=null){super(t,r),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new tp,this.mouseButtons={LEFT:tt.PAN,MIDDLE:tt.PAN,RIGHT:tt.ROTATE},this.touches={ONE:kr.PAN},this._onPointerMove=P_.bind(this),this._onPointerDown=D_.bind(this),this._onPointerCancel=F_.bind(this),this._onContextMenu=L_.bind(this),r!==null&&this.connect(r)}connect(e){super.connect(e),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerCancel),this.domElement.addEventListener("pointerleave",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerCancel),this.domElement.removeEventListener("pointerleave",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="",this.domElement.style.cursor=""}dispose(){this.disconnect()}_updatePointer(e){const t=this.domElement.getBoundingClientRect();Lr.x=(e.clientX-t.left)/t.width*2-1,Lr.y=-(e.clientY-t.top)/t.height*2+1}_updateState(e){let t;if(e.pointerType==="touch")t=this.touches.ONE;else switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=null}switch(t){case tt.PAN:case kr.PAN:this.state=cs.PAN;break;case tt.ROTATE:case kr.ROTATE:this.state=cs.ROTATE;break;default:this.state=cs.NONE}}}function P_(i){const e=this.object,t=this.domElement,r=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(i),r.setFromCamera(Lr,e),lt)this.state===cs.PAN?r.ray.intersectPlane(Nn,Sa)&&(lt.position.copy(Sa.sub(Kp).applyMatrix4(Yp)),this.dispatchEvent({type:"drag",object:lt})):this.state===cs.ROTATE&&(ou.subVectors(Lr,ia).multiplyScalar(this.rotateSpeed),lt.rotateOnWorldAxis(Qp,ou.x),lt.rotateOnWorldAxis(Zp.normalize(),-ou.y),this.dispatchEvent({type:"drag",object:lt})),ia.copy(Lr);else if(i.pointerType==="mouse"||i.pointerType==="pen")if(Ur.length=0,r.setFromCamera(Lr,e),r.intersectObjects(this.objects,this.recursive,Ur),Ur.length>0){const s=Ur[0].object;Nn.setFromNormalAndCoplanarPoint(e.getWorldDirection(Nn.normal),Wl.setFromMatrixPosition(s.matrixWorld)),fr!==s&&fr!==null&&(this.dispatchEvent({type:"hoveroff",object:fr}),t.style.cursor="auto",fr=null),fr!==s&&(this.dispatchEvent({type:"hoveron",object:s}),t.style.cursor="pointer",fr=s)}else fr!==null&&(this.dispatchEvent({type:"hoveroff",object:fr}),t.style.cursor="auto",fr=null);ia.copy(Lr)}}function D_(i){const e=this.object,t=this.domElement,r=this.raycaster;this.enabled!==!1&&(this._updatePointer(i),this._updateState(i),Ur.length=0,r.setFromCamera(Lr,e),r.intersectObjects(this.objects,this.recursive,Ur),Ur.length>0&&(this.transformGroup===!0?lt=Jp(Ur[0].object):lt=Ur[0].object,Nn.setFromNormalAndCoplanarPoint(e.getWorldDirection(Nn.normal),Wl.setFromMatrixPosition(lt.matrixWorld)),r.ray.intersectPlane(Nn,Sa)&&(this.state===cs.PAN?(Yp.copy(lt.parent.matrixWorld).invert(),Kp.copy(Sa).sub(Wl.setFromMatrixPosition(lt.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:lt})):this.state===cs.ROTATE&&(Qp.set(0,1,0).applyQuaternion(e.quaternion).normalize(),Zp.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:lt})))),ia.copy(Lr))}function F_(){this.enabled!==!1&&(lt&&(this.dispatchEvent({type:"dragend",object:lt}),lt=null),this.domElement.style.cursor=fr?"pointer":"auto",this.state=cs.NONE)}function L_(i){this.enabled!==!1&&i.preventDefault()}function Jp(i,e=null){return i.isGroup&&(e=i),i.parent===null?e:Jp(i.parent,e)}function U_(i){I_(i);const e=O_(i);return i.on=e.on,i.off=e.off,i.fire=e.fire,i}function O_(i){let e=Object.create(null);return{on:function(t,r,s){if(typeof r!="function")throw new Error("callback is expected to be a function");let n=e[t];return n||(n=e[t]=[]),n.push({callback:r,ctx:s}),i},off:function(t,r){if(typeof t>"u")return e=Object.create(null),i;if(e[t])if(typeof r!="function")delete e[t];else{const o=e[t];for(let a=0;a1&&(s=Array.prototype.slice.call(arguments,1));for(let n=0;n0&&(d.fire("changed",o),o.length=0)}function le(G){if(typeof G!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+G);for(var j=e.values(),ne=j.next();!ne.done;){if(G(ne.value))return!0;ne=j.next()}}}function G_(i,e){this.id=i,this.links=null,this.data=e}function Ud(i,e){i.links?i.links.add(e):i.links=new Set([e])}function Od(i,e,t,r){this.fromId=i,this.toId=e,this.data=t,this.id=r}function oo(i,e){return i.toString()+"👉 "+e.toString()}function V_(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ao={exports:{}},Zs={exports:{}},au,Id;function eg(){return Id||(Id=1,au=function(e){return e===0?"x":e===1?"y":e===2?"z":"c"+(e+1)}),au}var uu,kd;function Gn(){if(kd)return uu;kd=1;const i=eg();return uu=function(t){return r;function r(s,n){let o=n&&n.indent||0,a=n&&n.join!==void 0?n.join:` +`,u=Array(o+1).join(" "),l=[];for(let c=0;c {var}max) {var}max = pos.{var};",{indent:6})} + } + + // Makes the bounds square. + var maxSideLength = -Infinity; + ${c("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})} + + currentInCache = 0; + root = newNode(); + ${c("root.min_{var} = {var}min;",{indent:4})} + ${c("root.max_{var} = {var}min + maxSideLength;",{indent:4})} + + i = bodies.length - 1; + if (i >= 0) { + root.body = bodies[i]; + } + while (i--) { + insert(bodies[i], root); + } + } + + function insert(newBody) { + insertStack.reset(); + insertStack.push(root, newBody); + + while (!insertStack.isEmpty()) { + var stackItem = insertStack.pop(); + var node = stackItem.node; + var body = stackItem.body; + + if (!node.body) { + // This is internal node. Update the total mass of the node and center-of-mass. + ${c("var {var} = body.pos.{var};",{indent:8})} + node.mass += body.mass; + ${c("node.mass_{var} += body.mass * {var};",{indent:8})} + + // Recursively insert the body in the appropriate quadrant. + // But first find the appropriate quadrant. + var quadIdx = 0; // Assume we are in the 0's quad. + ${c("var min_{var} = node.min_{var};",{indent:8})} + ${c("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})} + +${f(8)} + + var child = getChild(node, quadIdx); + + if (!child) { + // The node is internal but this quadrant is not taken. Add + // subnode to it. + child = newNode(); + ${c("child.min_{var} = min_{var};",{indent:10})} + ${c("child.max_{var} = max_{var};",{indent:10})} + child.body = body; + + setChild(node, quadIdx, child); + } else { + // continue searching in this quadrant. + insertStack.push(child, body); + } + } else { + // We are trying to add to the leaf node. + // We have to convert current leaf into internal node + // and continue adding two nodes. + var oldBody = node.body; + node.body = null; // internal nodes do not cary bodies + + if (isSamePosition(oldBody.pos, body.pos)) { + // Prevent infinite subdivision by bumping one node + // anywhere in this quadrant + var retriesCount = 3; + do { + var offset = random.nextDouble(); + ${c("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})} + + ${c("oldBody.pos.{var} = node.min_{var} + d{var};",{indent:12})} + retriesCount -= 1; + // Make sure we don't bump it out of the box. If we do, next iteration should fix it + } while (retriesCount > 0 && isSamePosition(oldBody.pos, body.pos)); + + if (retriesCount === 0 && isSamePosition(oldBody.pos, body.pos)) { + // This is very bad, we ran out of precision. + // if we do not return from the method we'll get into + // infinite loop here. So we sacrifice correctness of layout, and keep the app running + // Next layout iteration should get larger bounding box in the first step and fix this + return; + } + } + // Next iteration should subdivide node further. + insertStack.push(node, oldBody); + insertStack.push(node, body); + } + } + } +} +return createQuadTree; + +`;function f(m){let y=[],x=Array(m+1).join(" ");for(let _=0;_ max_${e(_)}) {`),y.push(x+` quadIdx = quadIdx + ${Math.pow(2,_)};`),y.push(x+` min_${e(_)} = max_${e(_)};`),y.push(x+` max_${e(_)} = node.max_${e(_)};`),y.push(x+"}");return y.join(` +`)}function p(){let m=Array(11).join(" "),y=[];for(let x=0;x 0) { + return this.stack[--this.popIdx]; + } + }, + reset: function () { + this.popIdx = 0; + } +}; + +function InsertStackElement(node, body) { + this.node = node; // QuadTree node + this.body = body; // physical body which needs to be inserted to node +} +`}return Er.exports}var uo={exports:{}},$d;function W_(){if($d)return uo.exports;$d=1,uo.exports=e,uo.exports.generateFunctionBody=t;const i=Gn();function e(r){let s=t(r);return new Function("bodies","settings","random",s)}function t(r){let s=i(r);return` + var boundingBox = { + ${s("min_{var}: 0, max_{var}: 0,",{indent:4})} + }; + + return { + box: boundingBox, + + update: updateBoundingBox, + + reset: resetBoundingBox, + + getBestNewPosition: function (neighbors) { + var ${s("base_{var} = 0",{join:", "})}; + + if (neighbors.length) { + for (var i = 0; i < neighbors.length; ++i) { + let neighborPos = neighbors[i].pos; + ${s("base_{var} += neighborPos.{var};",{indent:10})} + } + + ${s("base_{var} /= neighbors.length;",{indent:8})} + } else { + ${s("base_{var} = (boundingBox.min_{var} + boundingBox.max_{var}) / 2;",{indent:8})} + } + + var springLength = settings.springLength; + return { + ${s("{var}: base_{var} + (random.nextDouble() - 0.5) * springLength,",{indent:8})} + }; + } + }; + + function updateBoundingBox() { + var i = bodies.length; + if (i === 0) return; // No bodies - no borders. + + ${s("var max_{var} = -Infinity;",{indent:4})} + ${s("var min_{var} = Infinity;",{indent:4})} + + while(i--) { + // this is O(n), it could be done faster with quadtree, if we check the root node bounds + var bodyPos = bodies[i].pos; + ${s("if (bodyPos.{var} < min_{var}) min_{var} = bodyPos.{var};",{indent:6})} + ${s("if (bodyPos.{var} > max_{var}) max_{var} = bodyPos.{var};",{indent:6})} + } + + ${s("boundingBox.min_{var} = min_{var};",{indent:4})} + ${s("boundingBox.max_{var} = max_{var};",{indent:4})} + } + + function resetBoundingBox() { + ${s("boundingBox.min_{var} = boundingBox.max_{var} = 0;",{indent:4})} + } +`}return uo.exports}var lo={exports:{}},zd;function j_(){if(zd)return lo.exports;zd=1;const i=Gn();lo.exports=e,lo.exports.generateCreateDragForceFunctionBody=t;function e(r){let s=t(r);return new Function("options",s)}function t(r){return` + if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number'); + + return { + update: function(body) { + ${i(r)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})} + } + }; +`}return lo.exports}var co={exports:{}},Wd;function H_(){if(Wd)return co.exports;Wd=1;const i=Gn();co.exports=e,co.exports.generateCreateSpringForceFunctionBody=t;function e(r){let s=t(r);return new Function("options","random",s)}function t(r){let s=i(r);return` + if (!Number.isFinite(options.springCoefficient)) throw new Error('Spring coefficient is not a number'); + if (!Number.isFinite(options.springLength)) throw new Error('Spring length is not a number'); + + return { + /** + * Updates forces acting on a spring + */ + update: function (spring) { + var body1 = spring.from; + var body2 = spring.to; + var length = spring.length < 0 ? options.springLength : spring.length; + ${s("var d{var} = body2.pos.{var} - body1.pos.{var};",{indent:6})} + var r = Math.sqrt(${s("d{var} * d{var}",{join:" + "})}); + + if (r === 0) { + ${s("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:8})} + r = Math.sqrt(${s("d{var} * d{var}",{join:" + "})}); + } + + var d = r - length; + var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r; + + ${s("body1.force.{var} += coefficient * d{var}",{indent:6})}; + body1.springCount += 1; + body1.springLength += r; + + ${s("body2.force.{var} -= coefficient * d{var}",{indent:6})}; + body2.springCount += 1; + body2.springLength += r; + } + }; +`}return co.exports}var ho={exports:{}},jd;function q_(){if(jd)return ho.exports;jd=1;const i=Gn();ho.exports=e,ho.exports.generateIntegratorFunctionBody=t;function e(r){let s=t(r);return new Function("bodies","timeStep","adaptiveTimeStepWeight",s)}function t(r){let s=i(r);return` + var length = bodies.length; + if (length === 0) return 0; + + ${s("var d{var} = 0, t{var} = 0;",{indent:2})} + + for (var i = 0; i < length; ++i) { + var body = bodies[i]; + if (body.isPinned) continue; + + if (adaptiveTimeStepWeight && body.springCount) { + timeStep = (adaptiveTimeStepWeight * body.springLength/body.springCount); + } + + var coeff = timeStep / body.mass; + + ${s("body.velocity.{var} += coeff * body.force.{var};",{indent:4})} + ${s("var v{var} = body.velocity.{var};",{indent:4})} + var v = Math.sqrt(${s("v{var} * v{var}",{join:" + "})}); + + if (v > 1) { + // We normalize it so that we move within timeStep range. + // for the case when v <= 1 - we let velocity to fade out. + ${s("body.velocity.{var} = v{var} / v;",{indent:6})} + } + + ${s("d{var} = timeStep * body.velocity.{var};",{indent:4})} + + ${s("body.pos.{var} += d{var};",{indent:4})} + + ${s("t{var} += Math.abs(d{var});",{indent:4})} + } + + return (${s("t{var} * t{var}",{join:" + "})})/length; +`}return ho.exports}var lu,Hd;function X_(){if(Hd)return lu;Hd=1,lu=i;function i(e,t,r,s){this.from=e,this.to=t,this.length=r,this.coefficient=s}return lu}var cu,qd;function K_(){if(qd)return cu;qd=1,cu=i;function i(e,t){var r;if(e||(e={}),t){for(r in t)if(t.hasOwnProperty(r)){var s=e.hasOwnProperty(r),n=typeof t[r],o=!s||typeof e[r]!==n;o?e[r]=t[r]:n==="object"&&(e[r]=i(e[r],t[r]))}}return e}return cu}var du,Xd;function tg(){if(Xd)return du;Xd=1;function i(r){t(r);const s=e(r);return r.on=s.on,r.off=s.off,r.fire=s.fire,r}function e(r){let s=Object.create(null);return{on:function(n,o,a){if(typeof o!="function")throw new Error("callback is expected to be a function");let u=s[n];return u||(u=s[n]=[]),u.push({callback:o,ctx:a}),r},off:function(n,o){if(typeof n>"u")return s=Object.create(null),r;if(s[n])if(typeof o!="function")delete s[n];else{const a=s[n];for(let u=0;u1&&(a=Array.prototype.slice.call(arguments,1));for(let u=0;u=1||u===0);return l*Math.sqrt(-2*Math.log(u)/u)}e.prototype.levy=r;function r(){var u=1.5,l=Math.pow(s(1+u)*Math.sin(Math.PI*u/2)/(s((1+u)/2)*u*Math.pow(2,(u-1)/2)),1/u);return this.gaussian()*l/Math.pow(Math.abs(this.gaussian()),1/u)}function s(u){return Math.sqrt(2*Math.PI/u)*Math.pow(1/Math.E*(u+1/(12*u-1/(10*u))),u)}function n(){var u=this.seed;return u=u+2127912214+(u<<12)&4294967295,u=(u^3345072700^u>>>19)&4294967295,u=u+374761393+(u<<5)&4294967295,u=(u+3550635116^u<<9)&4294967295,u=u+4251993797+(u<<3)&4294967295,u=(u^3042594569^u>>>16)&4294967295,this.seed=u,(u&268435455)/268435456}function o(u){return Math.floor(this.nextDouble()*u)}function a(u,l){var c=l||i();if(typeof c.next!="function")throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:h,shuffle:d};function d(){var f,p,g;for(f=u.length-1;f>0;--f)p=c.next(f+1),g=u[p],u[p]=u[f],u[f]=g;return u}function h(f){var p,g,m;for(p=u.length-1;p>0;--p)g=c.next(p+1),m=u[g],u[g]=u[p],u[p]=m,f(m);u.length&&f(u[0])}}return Jn.exports}var hu,Yd;function Qd(){if(Yd)return hu;Yd=1,hu=a;var i=$_(),e=z_(),t=W_(),r=j_(),s=H_(),n=q_(),o={};function a(c){var d=X_(),h=K_(),f=tg();if(c){if(c.springCoeff!==void 0)throw new Error("springCoeff was renamed to springCoefficient");if(c.dragCoeff!==void 0)throw new Error("dragCoeff was renamed to dragCoefficient")}c=h(c,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var p=o[c.dimensions];if(!p){var g=c.dimensions;p={Body:i(g,c.debug),createQuadTree:e(g),createBounds:t(g),createDragForce:r(g),createSpringForce:s(g),integrate:n(g)},o[g]=p}var m=p.Body,y=p.createQuadTree,x=p.createBounds,_=p.createDragForce,N=p.createSpringForce,A=p.integrate,v=B=>new m(B),S=Y_().random(42),P=[],F=[],U=y(c,S),W=x(P,c,S),se=N(c,S),ie=_(c),he=0,X=[],ue=new Map,D=0;le("nbody",ne),le("spring",Ae);var I={bodies:P,quadTree:U,springs:F,settings:c,addForce:le,removeForce:G,getForces:j,step:function(){for(var B=0;B=0?_e:-1);return F.push(ke),ke},getTotalMovement:function(){return he},removeSpring:function(B){if(B){var L=F.indexOf(B);if(L>-1)return F.splice(L,1),!0}},getBestNewBodyPosition:function(B){return W.getBestNewPosition(B)},getBBox:Y,getBoundingBox:Y,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(B){return B!==void 0?(c.gravity=B,U.options({gravity:B}),this):c.gravity},theta:function(B){return B!==void 0?(c.theta=B,U.options({theta:B}),this):c.theta},random:S};return u(c,I),f(I),I;function Y(){return W.update(),W.box}function le(B,L){if(ue.has(B))throw new Error("Force "+B+" is already added");ue.set(B,L),X.push(L)}function G(B){var L=X.indexOf(ue.get(B));L<0||(X.splice(L,1),ue.delete(B))}function j(){return ue}function ne(){if(P.length!==0){U.insertBodies(P);for(var B=P.length;B--;){var L=P[B];L.isPinned||(L.reset(),U.updateBodyForce(L),ie.update(L))}}}function Ae(){for(var B=F.length;B--;)se.update(F[B])}}function u(c,d){for(var h in c)l(c,d,h)}function l(c,d,h){if(c.hasOwnProperty(h)&&typeof d[h]!="function"){var f=Number.isFinite(c[h]);f?d[h]=function(p){if(p!==void 0){if(!Number.isFinite(p))throw new Error("Value of "+h+" should be a valid number.");return c[h]=p,d}return c[h]}:d[h]=function(p){return p!==void 0?(c[h]=p,d):c[h]}}}return hu}var Zd;function Q_(){if(Zd)return ao.exports;Zd=1,ao.exports=e,ao.exports.simulator=Qd();var i=tg();function e(r,s){if(!r)throw new Error("Graph structure cannot be undefined");var n=s&&s.createSimulator||Qd(),o=n(s);if(Array.isArray(s))throw new Error("Physics settings is expected to be an object");var a=r.version>19?ue:X;s&&typeof s.nodeMass=="function"&&(a=s.nodeMass);var u=new Map,l={},c=0,d=o.settings.springTransform||t;v(),_();var h=!1,f={step:function(){if(c===0)return p(!0),!0;var D=o.step();f.lastMove=D,f.fire("step");var I=D/c,Y=I<=.01;return p(Y),Y},getNodePosition:function(D){return he(D).pos},setNodePosition:function(D){var I=he(D);I.setPosition.apply(I,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(D){var I=l[D];if(I)return{from:I.from.pos,to:I.to.pos}},getGraphRect:function(){return o.getBBox()},forEachBody:g,pinNode:function(D,I){var Y=he(D.id);Y.isPinned=!!I},isNodePinned:function(D){return he(D.id).isPinned},dispose:function(){r.off("changed",A),f.fire("disposed")},getBody:x,getSpring:y,getForceVectorLength:m,simulator:o,graph:r,lastMove:0};return i(f),f;function p(D){h!==D&&(h=D,N(D))}function g(D){u.forEach(D)}function m(){var D=0,I=0;return g(function(Y){D+=Math.abs(Y.force.x),I+=Math.abs(Y.force.y)}),Math.sqrt(D*D+I*I)}function y(D,I){var Y;if(I===void 0)typeof D!="object"?Y=D:Y=D.id;else{var le=r.hasLink(D,I);if(!le)return;Y=le.id}return l[Y]}function x(D){return u.get(D)}function _(){r.on("changed",A)}function N(D){f.fire("stable",D)}function A(D){for(var I=0;Ii.length)&&(e=i.length);for(var t=0,r=Array(e);ti.length)&&(e=i.length);for(var t=0,r=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},n=s.dataBindAttr,o=n===void 0?"__data":n,a=s.objBindAttr,u=a===void 0?"__threeObj":a;return og(this,e),r=ig(this,e),za(r,"scene",void 0),Jd(r,bu,void 0),Jd(r,po,void 0),r.scene=t,eh(bu,r,o),eh(po,r,u),r.onRemoveObj(function(){}),r}return lg(e,i),ug(e,[{key:"onCreateObj",value:function(r){var s=this;return yu(e,"onCreateObj",this)([function(n){var o=r(n);return n[mu(po,s)]=o,o[mu(bu,s)]=n,s.scene.add(o),o}]),this}},{key:"onRemoveObj",value:function(r){var s=this;return yu(e,"onRemoveObj",this)([function(n,o){var a=yu(e,"getData",s)([n]);r(n,o),s.scene.remove(n),$c(n),delete a[mu(po,s)]}]),this}}])})(px),ri=function(e){return isNaN(e)?parseInt(Xp(e).toHex(),16):e},_u=function(e){return isNaN(e)?Xp(e).getAlpha():1},Ax=x_(T_);function sh(i,e,t){!e||typeof t!="string"||i.filter(function(r){return!r[t]}).forEach(function(r){r[t]=Ax(e(r))})}function Cx(i,e){var t=i.nodes,r=i.links,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=s.nodeFilter,o=n===void 0?function(){return!0}:n,a=s.onLoopError,u=a===void 0?function(f){throw"Invalid DAG structure! Found cycle in node path: ".concat(f.join(" -> "),".")}:a,l={};t.forEach(function(f){return l[e(f)]={data:f,out:[],depth:-1,skip:!o(f)}}),r.forEach(function(f){var p=f.source,g=f.target,m=N(p),y=N(g);if(!l.hasOwnProperty(m))throw"Missing source node with id: ".concat(m);if(!l.hasOwnProperty(y))throw"Missing target node with id: ".concat(y);var x=l[m],_=l[y];x.out.push(_);function N(A){return Kl(A)==="object"?e(A):A}});var c=[];h(Object.values(l));var d=Object.assign.apply(Object,[{}].concat(Zt(Object.entries(l).filter(function(f){var p=wi(f,2),g=p[1];return!g.skip}).map(function(f){var p=wi(f,2),g=p[0],m=p[1];return za({},g,m.depth)}))));return d;function h(f){for(var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,m=function(){var N=f[y];if(p.indexOf(N)!==-1){var A=[].concat(Zt(p.slice(p.indexOf(N))),[N]).map(function(v){return e(v.data)});return c.some(function(v){return v.length===A.length&&v.every(function(S,P){return S===A[P]})})||(c.push(A),u(A)),1}g>N.depth&&(N.depth=g,h(N.out,[].concat(Zt(p),[N]),g+(N.skip?0:1)))},y=0,x=f.length;y2?-60:-30),e<3&&s(t.graphData.nodes,"z"),e<2&&s(t.graphData.nodes,"y");function s(n,o){n.forEach(function(a){delete a[o],delete a["v".concat(o)]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine==="d3"&&(t.graphData.nodes||[]).forEach(function(r){return r.fx=r.fy=r.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:"id"},nodeVal:{default:"val"},nodeResolution:{default:8},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,r){return r===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,r),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t=e.forceEngine!=="ngraph";return e.engineRunning&&r(),s(),n(),this;function r(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||t&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()0){var v=g.x-p.x,S=g.y-p.y||0,P=new te.Vector3().subVectors(x,y),F=P.clone().multiplyScalar(m).cross(v!==0||S!==0?new te.Vector3(0,0,1):new te.Vector3(0,1,0)).applyAxisAngle(P.normalize(),A).add(new te.Vector3().addVectors(y,x).divideScalar(2));N=new te.QuadraticBezierCurve3(y,F,x)}else{var U=m*70,W=-A,se=W+Math.PI/2;N=new te.CubicBezierCurve3(y,new te.Vector3(U*Math.cos(se),U*Math.sin(se),0).add(y),new te.Vector3(U*Math.cos(W),U*Math.sin(W),0).add(y),x)}h.__curve=N}}}}function s(){var o=pe(e.linkDirectionalArrowRelPos),a=pe(e.linkDirectionalArrowLength),u=pe(e.nodeVal);e.arrowDataMapper.entries().forEach(function(l){var c=wi(l,2),d=c[0],h=c[1];if(h){var f=t?d:e.layout.getLinkPosition(e.layout.graph.getLink(d.source,d.target).id),p=f[t?"source":"from"],g=f[t?"target":"to"];if(!(!p||!g||!p.hasOwnProperty("x")||!g.hasOwnProperty("x"))){var m=Math.cbrt(Math.max(0,u(p)||1))*e.nodeRelSize,y=Math.cbrt(Math.max(0,u(g)||1))*e.nodeRelSize,x=a(d),_=o(d),N=d.__curve?function(U){return d.__curve.getPoint(U)}:function(U){var W=function(ie,he,X,ue){return he[ie]+(X[ie]-he[ie])*ue||0};return{x:W("x",p,g,U),y:W("y",p,g,U),z:W("z",p,g,U)}},A=d.__curve?d.__curve.getLength():Math.sqrt(["x","y","z"].map(function(U){return Math.pow((g[U]||0)-(p[U]||0),2)}).reduce(function(U,W){return U+W},0)),v=m+x+(A-m-y-x)*_,S=N(v/A),P=N((v-x)/A);["x","y","z"].forEach(function(U){return h.position[U]=P[U]});var F=ag(te.Vector3,Zt(["x","y","z"].map(function(U){return S[U]})));h.parent.localToWorld(F),h.lookAt(F)}}})}function n(){var o=pe(e.linkDirectionalParticleSpeed),a=pe(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(u){var l=e.particlesDataMapper.getObj(u),c=l&&l.children,d=u.__singleHopPhotonsObj&&u.__singleHopPhotonsObj.children;if(!((!d||!d.length)&&(!c||!c.length))){var h=t?u:e.layout.getLinkPosition(e.layout.graph.getLink(u.source,u.target).id),f=h[t?"source":"from"],p=h[t?"target":"to"];if(!(!f||!p||!f.hasOwnProperty("x")||!p.hasOwnProperty("x"))){var g=o(u),m=Math.abs(a(u)),y=u.__curve?function(_){return u.__curve.getPoint(_)}:function(_){var N=function(v,S,P,F){return S[v]+(P[v]-S[v])*F||0};return{x:N("x",f,p,_),y:N("y",f,p,_),z:N("z",f,p,_)}},x=[].concat(Zt(c||[]),Zt(d||[]));x.forEach(function(_,N){var A=_.parent.__linkThreeObjType==="singleHopPhotons";if(_.hasOwnProperty("__progressRatio")||(_.__progressRatio=A?g<0?1:0:(N+m)/c.length),_.__progressRatio+=g,_.__progressRatio>=1||_.__progressRatio<0)if(!A)_.__progressRatio=_.__progressRatio%1,_.__progressRatio<0&&_.__progressRatio++;else{_.parent.remove(_),rh(_);return}var v=_.__progressRatio,S=y(v);_.geometry.type!=="SphereGeometry"&&_.lookAt(S.x,S.y,S.z),["x","y","z"].forEach(function(P){return _.position[P]=S[P]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var r=new te.Group;r.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=r,e.graphScene.add(r)}var s=pe(e.linkDirectionalParticleThreeObject)(t);if(s&&e.linkDirectionalParticleThreeObject===s&&(s=s.clone()),!s){var n=pe(e.linkDirectionalParticleWidth),o=Math.ceil(n(t)*10)/10/2,a=e.linkDirectionalParticleResolution,u=new te.SphereGeometry(o,a,a),l=pe(e.linkColor),c=pe(e.linkDirectionalParticleColor),d=c(t)||l(t)||"#f0f0f0",h=new te.Color(ri(d)),f=e.linkOpacity*3,p=new te.MeshLambertMaterial({color:h,transparent:!0,opacity:f});s=new te.Mesh(u,p)}t.__singleHopPhotonsObj.add(s)}return this},getGraphBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0};if(!e.initialised)return null;var r=(function s(n){var o=[];if(n.geometry){n.geometry.computeBoundingBox();var a=new te.Box3;a.copy(n.geometry.boundingBox).applyMatrix4(n.matrixWorld),o.push(a)}return o.concat.apply(o,Zt((n.children||[]).filter(function(u){return!u.hasOwnProperty("__graphObjType")||u.__graphObjType==="node"&&t(u.__data)}).map(s)))})(e.graphScene);return r.length?Object.assign.apply(Object,Zt(["x","y","z"].map(function(s){return za({},s,[E_(r,function(n){return n.min[s]}),A_(r,function(n){return n.max[s]})])}))):null}},stateInit:function(){return{d3ForceLayout:S_().force("link",N_()).force("charge",w_()).force("center",R_()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new ti(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new ti(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new ti(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new ti(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var r=function(L){return L.some(function(Q){return t.hasOwnProperty(Q)})};if(e.engineRunning=!1,typeof e.onUpdate=="function"&&e.onUpdate(),e.nodeAutoColorBy!==null&&r(["nodeAutoColorBy","graphData","nodeColor"])&&sh(e.graphData.nodes,pe(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&r(["linkAutoColorBy","graphData","linkColor"])&&sh(e.graphData.links,pe(e.linkAutoColorBy),e.linkColor),e._flushObjects||r(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var s=pe(e.nodeThreeObject),n=pe(e.nodeThreeObjectExtend),o=pe(e.nodeVal),a=pe(e.nodeColor),u=pe(e.nodeVisibility),l={},c={};(e._flushObjects||r(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(B){var L=s(B),Q=n(B);L&&e.nodeThreeObject===L&&(L=L.clone());var _e;return L&&!Q?_e=L:(_e=new te.Mesh,_e.__graphDefaultObj=!0,L&&Q&&_e.add(L)),_e.__graphObjType="node",_e}).onUpdateObj(function(B,L){if(B.__graphDefaultObj){var Q=o(L)||1,_e=Math.cbrt(Q)*e.nodeRelSize,ke=e.nodeResolution;(!B.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||B.geometry.parameters.radius!==_e||B.geometry.parameters.widthSegments!==ke)&&(l.hasOwnProperty(Q)||(l[Q]=new te.SphereGeometry(_e,ke,ke)),B.geometry.dispose(),B.geometry=l[Q]);var Ve=a(L),$e=new te.Color(ri(Ve||"#ffffaa")),ir=e.nodeOpacity*_u(Ve);(B.material.type!=="MeshLambertMaterial"||!B.material.color.equals($e)||B.material.opacity!==ir)&&(c.hasOwnProperty(Ve)||(c[Ve]=new te.MeshLambertMaterial({color:$e,transparent:!0,opacity:ir})),B.material.dispose(),B.material=c[Ve])}}).digest(e.graphData.nodes.filter(u))}if(e._flushObjects||r(["graphData","linkThreeObject","linkThreeObjectExtend","linkMaterial","linkColor","linkWidth","linkVisibility","linkResolution","linkOpacity","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject"])){var d=pe(e.linkThreeObject),h=pe(e.linkThreeObjectExtend),f=pe(e.linkMaterial),p=pe(e.linkVisibility),g=pe(e.linkColor),m=pe(e.linkWidth),y={},x={},_={},N=e.graphData.links.filter(p);if((e._flushObjects||r(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(B){var L=B.__data&&B.__data.__singleHopPhotonsObj;L&&(L.parent.remove(L),rh(L),delete B.__data.__singleHopPhotonsObj)}).onCreateObj(function(B){var L=d(B),Q=h(B);L&&e.linkThreeObject===L&&(L=L.clone());var _e;if(!L||Q){var ke=!!m(B);if(ke)_e=new te.Mesh;else{var Ve=new te.BufferGeometry;Ve[xu]("position",new te.BufferAttribute(new Float32Array(6),3)),_e=new te.Line(Ve)}}var $e;return L?Q?($e=new te.Group,$e.__graphDefaultObj=!0,$e.add(_e),$e.add(L)):$e=L:($e=_e,$e.__graphDefaultObj=!0),$e.renderOrder=10,$e.__graphObjType="link",$e}).onUpdateObj(function(B,L){if(B.__graphDefaultObj){var Q=B.children.length?B.children[0]:B,_e=Math.ceil(m(L)*10)/10,ke=!!_e;if(ke){var Ve=_e/2,$e=e.linkResolution;if(!Q.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||Q.geometry.parameters.radiusTop!==Ve||Q.geometry.parameters.radialSegments!==$e){if(!y.hasOwnProperty(_e)){var ir=new te.CylinderGeometry(Ve,Ve,1,$e,1,!1);ir[go](new te.Matrix4().makeTranslation(0,1/2,0)),ir[go](new te.Matrix4().makeRotationX(Math.PI/2)),y[_e]=ir}Q.geometry.dispose(),Q.geometry=y[_e]}}var xs=f(L);if(xs)Q.material=xs;else{var qr=g(L),Qn=new te.Color(ri(qr||"#f0f0f0")),Qs=e.linkOpacity*_u(qr),Xr=ke?"MeshLambertMaterial":"LineBasicMaterial";if(Q.material.type!==Xr||!Q.material.color.equals(Qn)||Q.material.opacity!==Qs){var Zn=ke?x:_;Zn.hasOwnProperty(qr)||(Zn[qr]=new te[Xr]({color:Qn,transparent:Qs<1,opacity:Qs,depthWrite:Qs>=1})),Q.material.dispose(),Q.material=Zn[qr]}}}}).digest(N),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var A=pe(e.linkDirectionalArrowLength),v=pe(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var B=new te.Mesh(void 0,new te.MeshLambertMaterial({transparent:!0}));return B.__linkThreeObjType="arrow",B}).onUpdateObj(function(B,L){var Q=A(L),_e=e.linkDirectionalArrowResolution;if(!B.geometry.type.match(/^Cone(Buffer)?Geometry$/)||B.geometry.parameters.height!==Q||B.geometry.parameters.radialSegments!==_e){var ke=new te.ConeGeometry(Q*.25,Q,_e);ke.translate(0,Q/2,0),ke.rotateX(Math.PI/2),B.geometry.dispose(),B.geometry=ke}var Ve=v(L)||g(L)||"#f0f0f0";B.material.color=new te.Color(ri(Ve)),B.material.opacity=e.linkOpacity*3*_u(Ve)}).digest(N.filter(A))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var S=pe(e.linkDirectionalParticles),P=pe(e.linkDirectionalParticleWidth),F=pe(e.linkDirectionalParticleColor),U=pe(e.linkDirectionalParticleThreeObject),W={},se={};e.particlesDataMapper.onCreateObj(function(){var B=new te.Group;return B.__linkThreeObjType="photons",B.__photonDataMapper=new ti(B),B}).onUpdateObj(function(B,L){var Q=!!B.children.length&&B.children[0],_e=U(L),ke,Ve;if(_e)ke=_e.geometry,Ve=_e.material;else{var $e=Math.ceil(P(L)*10)/10/2,ir=e.linkDirectionalParticleResolution;Q&&Q.geometry.parameters.radius===$e&&Q.geometry.parameters.widthSegments===ir?ke=Q.geometry:(se.hasOwnProperty($e)||(se[$e]=new te.SphereGeometry($e,ir,ir)),ke=se[$e]);var xs=F(L)||g(L)||"#f0f0f0",qr=new te.Color(ri(xs)),Qn=e.linkOpacity*3;Q&&Q.material.color.equals(qr)&&Q.material.opacity===Qn?Ve=Q.material:(W.hasOwnProperty(xs)||(W[xs]=new te.MeshLambertMaterial({color:qr,transparent:!0,opacity:Qn})),Ve=W[xs])}Q&&(Q.geometry!==ke&&Q.geometry.dispose(),Q.material!==Ve&&Q.material.dispose());var Qs=Math.round(Math.abs(S(L)));B.__photonDataMapper.id(function(Xr){return Xr.idx}).onCreateObj(function(){return new te.Mesh(ke,Ve)}).onUpdateObj(function(Xr){Xr.geometry=ke,Xr.material=Ve}).digest(Zt(new Array(Qs)).map(function(Xr,Zn){return{idx:Zn}}))}).digest(N.filter(S))}}if(e._flushObjects=!1,r(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(B){B.source=B[e.linkSource],B.target=B[e.linkTarget]});var ie=e.forceEngine!=="ngraph",he;if(ie){(he=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var X=e.d3ForceLayout.force("link");X&&X.id(function(B){return B[e.nodeId]}).links(e.graphData.links);var ue=e.dagMode&&Cx(e.graphData,function(B){return B[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),D=Math.max.apply(Math,Zt(Object.values(ue||[]))),I=e.dagLevelDistance||e.graphData.nodes.length/(D||1)*Mx*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var Y=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(B){return delete B[Y]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var le=["rl","td","zout"].includes(e.dagMode),G=function(L){return(ue[L[e.nodeId]]-D/2)*I*(le?-1:1)},j=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(B){return B[j]=G(B)})}e.d3ForceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?v_(function(B){var L=ue[B[e.nodeId]]||-1;return(e.dagMode==="radialin"?D-L:L)*I}).strength(function(B){return e.dagNodeFilter(B)?1:0}):null)}else{var ne=nh.graph();e.graphData.nodes.forEach(function(B){ne.addNode(B[e.nodeId])}),e.graphData.links.forEach(function(B){ne.addLink(B.source,B.target)}),he=nh.forcelayout(ne,Nx({dimensions:e.numDimensions},e.ngraphPhysics)),he.graph=ne}for(var Ae=0;Ae0&&e.d3ForceLayout.alpha()1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=(function(s){function n(){var o;og(this,n);for(var a=arguments.length,u=new Array(a),l=0;l0){const{width:a,height:u}=e.context;t.bufferWidth=a,t.bufferHeight=u}const{environmentIntensity:n,environmentRotation:o}=e.scene;t.environmentIntensity=n,t.environmentRotation=o.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={id:s.isInterleavedBufferAttribute?s.data.uuid:s.id,version:s.isInterleavedBufferAttribute?s.data.version:s.version}}return t}containsNode(e){const t=e.material;for(const r in t)if(t[r]&&t[r].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=ah.get(e);return t===void 0&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},ah.set(e,t)),t}getMaterialData(e){let t=oh.get(e);if(t===void 0){t={_renderId:-1,_equal:!1};for(const r of this.refreshUniforms){const s=e[r];s!=null&&(typeof s=="object"&&s.clone!==void 0?s.isTexture===!0?t[r]={id:s.id,version:0}:t[r]=s.clone():t[r]=s)}oh.set(e,t)}return t}equals(e,t,r){const{object:s,material:n,geometry:o}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(s.matrixWorld)!==!0)return a.worldMatrix.copy(s.matrixWorld),!1;const u=this.getMaterialData(e.material);if(u._renderId!==r){u._renderId=r;for(const d in u){const h=u[d],f=n[d];if(d!=="_renderId"&&d!=="_equal"){if(h.equals!==void 0){if(h.equals(f)===!1)return h.copy(f),u._equal=!1,!1}else if(f.isTexture===!0){if(h.id!==f.id||h.version!==f.version)return h.id=f.id,h.version=f.version,u._equal=!1,!1}else if(h!==f)return u[d]=f,u._equal=!1,!1}}if(u.transmission>0){const{width:d,height:h}=e.context;if(a.bufferWidth!==d||a.bufferHeight!==h)return a.bufferWidth=d,a.bufferHeight=h,u._equal=!1,!1}u._equal=!0}else if(u._equal===!1)return!1;if(a.geometryId!==o.id)return a.geometryId=o.id,!1;const l=this.getGeometryData(e.geometry);if(l._renderId!==r){l._renderId=r;const d=o.attributes,h=l.attributes;let f=0,p=0;for(const N in d)f++;for(const N in h){p++;const A=h[N],v=d[N];if(v===void 0)return delete h[N],l._equal=!1,!1;const S=v.isInterleavedBufferAttribute?v.data.uuid:v.id,P=v.isInterleavedBufferAttribute?v.data.version:v.version;if(A.id!==S||A.version!==P)return A.id=S,A.version=P,l._equal=!1,!1}if(p!==f)return l.attributes=this.getAttributesData(d),l._equal=!1,!1;const g=o.index,m=l.indexId,y=l.indexVersion,x=g?g.id:null,_=g?g.version:null;if(m!==x||y!==_)return l.indexId=x,l.indexVersion=_,l._equal=!1,!1;if(l.drawRange.start!==o.drawRange.start||l.drawRange.count!==o.drawRange.count)return l.drawRange.start=o.drawRange.start,l.drawRange.count=o.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(l._equal===!1)return!1;if(a.morphTargetInfluences){let d=!1;for(let h=0;h{const r=t.match(e);if(!r)return null;const s=r[1]||r[2]||"",n=r[3].split("?")[0],o=parseInt(r[4],10),a=parseInt(r[5],10),u=n.split("/").pop();return{fn:s,file:u,line:o,column:a}}).filter(t=>t&&!Ux.some(r=>r.test(t.file)))}class bt{constructor(e=null){this.isStackTrace=!0,this.stack=Ox(e||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(this.stack.length===0)return e;const t=this.stack.map(r=>{const s=`${r.file}:${r.line}:${r.column}`;return r.fn?` at ${r.fn} (${s})`:` at ${s}`}).join(` +`);return`${e} +${t}`}}function zc(i,e=0){let t=3735928559^e,r=1103547991^e;if(Array.isArray(i))for(let s=0,n;s>>16,2246822507),t^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&r)+(t>>>0)}const Vn=i=>zc(i),Ji=i=>zc(i),Ri=(...i)=>zc(i),Ix=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),uh=new WeakMap;function pg(i){return Ix.get(i)}function Na(i){if(i==null)return null;const e=typeof i;return i.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":i.isVector2===!0?"vec2":i.isVector3===!0?"vec3":i.isVector4===!0?"vec4":i.isMatrix2===!0?"mat2":i.isMatrix3===!0?"mat3":i.isMatrix4===!0?"mat4":i.isColor===!0?"color":i instanceof ArrayBuffer?"ArrayBuffer":null}function Wc(i,...e){const t=i?i.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),i==="color"?new Kt(...e):t==="vec2"?new ce(...e):t==="vec3"?new V(...e):t==="vec4"?new He(...e):t==="mat2"?new Wp(...e):t==="mat3"?new Qi(...e):t==="mat4"?new At(...e):i==="bool"?e[0]||!1:i==="float"||i==="int"||i==="uint"?e[0]||0:i==="string"?e[0]||"":i==="ArrayBuffer"?Gx(e[0]):null}function gg(i){let e=uh.get(i);return e===void 0&&(e={},uh.set(i,e)),e}function kx(i){let e="";const t=new Uint8Array(i);for(let r=0;re.charCodeAt(0)).buffer}const si={VERTEX:"vertex"},re={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},zt={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},Vx=["fragment","vertex"],Tu=["setup","analyze","generate"],vu=[...Vx,"compute"],$n=["x","y","z","w"],$x={analyze:"setup",generate:"analyze"};let zx=0;class J extends Oa{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=re.NONE,this.updateBeforeType=re.NONE,this.updateAfterType=re.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=zx++,this.stackTrace=null,J.captureStackTrace===!0&&(this.stackTrace=new bt)}set needsUpdate(e){e===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=xa.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,re.FRAME)}onRenderUpdate(e){return this.onUpdate(e,re.RENDER)}onObjectUpdate(e){return this.onUpdate(e,re.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const r of Object.getOwnPropertyNames(this)){const s=this[r];if(!(r.startsWith("_")===!0||e.has(s))){if(Array.isArray(s)===!0)for(let n=0;n0&&(e.inputNodes=r)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const n of e.inputNodes[r])s.push(t[n]);this[r]=s}else if(typeof e.inputNodes[r]=="object"){const s={};for(const n in e.inputNodes[r]){const o=e.inputNodes[r][n];s[n]=t[o]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[t];n===void 0&&(n={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function o(a){const u=[];for(const l in a){const c=a[l];delete c.metadata,u.push(c)}return u}if(s){const a=o(e.textures),u=o(e.images),l=o(e.nodes);a.length>0&&(n.textures=a),u.length>0&&(n.images=u),l.length>0&&(n.nodes=l)}return n}}J.captureStackTrace=!1;class zn extends J{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),r=this.node.build(e),s=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${r}[ ${s} ]`}}class mg extends J{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))(r===null||e.getTypeLength(t)===e.getTypeLength(s))&&(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),n=r.build(e,s);return e.format(n,s,t)}}class Xe extends J{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const s=e.getVectorType(this.getNodeType(e,t)),n=e.getDataFromNode(this);if(n.propertyName!==void 0)return e.format(n.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(e)){const o=super.build(e,s),a=e.getVarFromNode(this,null,s),u=e.getPropertyName(a);return e.addLineFlowCode(`${u} = ${o}`,this),n.snippet=o,n.propertyName=u,e.format(n.propertyName,s,t)}}return super.build(e,t)}}class Wx extends Xe{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,r)=>t+e.getTypeLength(r.getNodeType(e)),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),n=this.nodes,o=e.getComponentType(r),a=[];let u=0;for(const c of n){if(u>=s){O(`TSL: Length of parameters exceeds maximum length of function '${r}()' type.`,this.stackTrace);break}let d=c.getNodeType(e),h=e.getTypeLength(d),f;if(u+h>s&&(O(`TSL: Length of '${r}()' data exceeds maximum length of output type.`,this.stackTrace),h=s-u,d=e.getTypeFromLength(h)),u+=h,f=c.build(e,d),e.getComponentType(d)!==o){const g=e.getTypeFromLength(h,o);f=e.format(f,d,g)}a.push(f)}const l=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(l,r,t)}}const jx=$n.join("");class Hx extends J{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max($n.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let n=null;if(s>1){let o=null;this.getVectorLength()>=s&&(o=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=r.build(e,o);this.components.length===s&&this.components===jx.slice(0,this.components.length)?n=e.format(u,o,t):n=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else n=r.build(e,t);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class qx extends Xe{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,n=this.getNodeType(e),o=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,o),u=s.build(e,a),l=t.build(e,n),c=e.getTypeLength(n),d=[];for(let h=0;hi.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),ch=i=>Yx(i).split("").sort().join("");J.prototype.assign=function(...i){if(this.isStackNode!==!0)return ks!==null?ks.assign(this,...i):O("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new bt),this;{const e=Yl.get("assign");return this.addToStack(e(...i))}};J.prototype.toVarIntent=function(){return this};J.prototype.get=function(i){return new Kx(this,i)};const Ei={};function mo(i,e,t){Ei[i]=Ei[e]=Ei[t]={get(){this._cache=this._cache||{};let o=this._cache[i];return o===void 0&&(o=new Hx(this,i),this._cache[i]=o),o},set(o){this[i].assign(H(o))}};const r=i.toUpperCase(),s=e.toUpperCase(),n=t.toUpperCase();J.prototype["set"+r]=J.prototype["set"+s]=J.prototype["set"+n]=function(o){const a=ch(i);return new qx(this,a,H(o))},J.prototype["flip"+r]=J.prototype["flip"+s]=J.prototype["flip"+n]=function(){const o=ch(i);return new Xx(this,o)}}const or=["x","y","z","w"],ar=["r","g","b","a"],ur=["s","t","p","q"];for(let i=0;i<4;i++){let e=or[i],t=ar[i],r=ur[i];mo(e,t,r);for(let s=0;s<4;s++){e=or[i]+or[s],t=ar[i]+ar[s],r=ur[i]+ur[s],mo(e,t,r);for(let n=0;n<4;n++){e=or[i]+or[s]+or[n],t=ar[i]+ar[s]+ar[n],r=ur[i]+ur[s]+ur[n],mo(e,t,r);for(let o=0;o<4;o++)e=or[i]+or[s]+or[n]+or[o],t=ar[i]+ar[s]+ar[n]+ar[o],r=ur[i]+ur[s]+ur[n]+ur[o],mo(e,t,r)}}}for(let i=0;i<32;i++)Ei[i]={get(){this._cache=this._cache||{};let e=this._cache[i];return e===void 0&&(e=new zn(this,new wr(i,"uint")),this._cache[i]=e),e},set(e){this[i].assign(H(e))}};Object.defineProperties(J.prototype,Ei);const Qx=function(i,e=null){const t=Na(i);return t==="node"?i:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?H(Ql(i,e)):t==="shader"?i.isFn?i:R(i):i},Zx=function(i,e=null){for(const t in i)i[t]=H(i[t],e);return i},Jx=function(i,e=null){const t=i.length;for(let r=0;ru?(O(`TSL: "${d}" parameter length exceeds limit.`,new bt),c.slice(0,u)):c}return e===null?n=(...c)=>s(new i(...wn(l(c)))):t!==null?(t=H(t),n=(...c)=>s(new i(e,...wn(l(c)),t))):n=(...c)=>s(new i(e,...wn(l(c)))),n.setParameterLength=(...c)=>(c.length===1?a=u=c[0]:c.length===2&&([a,u]=c),n),n.setName=c=>(o=c,n),n},eT=function(i,...e){return new i(...wn(e))};class tT extends J{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:r}=this,s=e.getNodeProperties(t),n=e.getClosestSubBuild(t.subBuilds)||"",o=n||"default";if(s[o])return s[o];const a=e.subBuildFn,u=e.fnCall;e.subBuildFn=n,e.fnCall=this;let l=null;if(t.layout){if(r){const h=t.layout.inputs;if(bg(r)){const f=r;for(let p=0;p{let x;return Symbol.iterator===m?x=function*(){yield void 0}:x=Reflect.get(g,m,y),x}}),d=r?sT(r):null,h=Array.isArray(r)?r.length>0:r!==null,f=t.jsFunc,p=h||f.length>1?f(d,c):f(c);l=H(p)}return e.subBuildFn=a,e.fnCall=u,t.once&&(s[o]=l),l}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getSubBuildOutput(this);return t[r]=t[r]||this.setupOutput(e),t[r].subBuild=e.getClosestSubBuild(this),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),n=e.getNodeProperties(this),o=e.getSubBuildOutput(this),a=this.getOutputNode(e),u=e.fnCall;if(e.fnCall=this,s==="setup"){const l=e.getSubBuildProperty("initialized",this);if(n[l]!==!0&&(n[l]=!0,n[o]=this.getOutputNode(e),n[o].build(e),this.shaderNode.subBuilds))for(const c of e.chaining){const d=e.getDataFromNode(c,"any");d.subBuilds=d.subBuilds||new Set;for(const h of this.shaderNode.subBuilds)d.subBuilds.add(h)}r=n[o]}else s==="analyze"?a.build(e,t):s==="generate"&&(r=a.build(e,t)||"");return e.fnCall=u,r}}function bg(i){return i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)}function rT(i){let e;return Kc(i),bg(i)?e=[...i]:e=i[0],e}function sT(i){let e=0;return Kc(i),new Proxy(i,{get:(t,r,s)=>{let n;if(r==="length")return n=i.length,n;if(Symbol.iterator===r)n=function*(){for(const o of i)yield H(o)};else{if(i.length>0)if(Object.getPrototypeOf(i[0])===Object.prototype){const o=i[0];o[r]===void 0?n=o[e++]:n=Reflect.get(o,r,s)}else i[0]instanceof J&&(i[r]===void 0?n=i[e++]:n=Reflect.get(i,r,s));else n=Reflect.get(t,r,s);n=H(n)}return n}})}class nT extends J{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new tT(this,e)}setup(){return this.call()}}const iT=[!1,!0],oT=[0,1,2,3],aT=[-1,-2],_g=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Hc=new Map;for(const i of iT)Hc.set(i,new wr(i));const qc=new Map;for(const i of oT)qc.set(i,new wr(i,"uint"));const Xc=new Map([...qc].map(i=>new wr(i.value,"int")));for(const i of aT)Xc.set(i,new wr(i,"int"));const Wa=new Map([...Xc].map(i=>new wr(i.value)));for(const i of _g)Wa.set(i,new wr(i));for(const i of _g)Wa.set(-i,new wr(-i));const ja={bool:Hc,uint:qc,ints:Xc,float:Wa},dh=new Map([...Hc,...Wa]),Ql=(i,e)=>dh.has(i)?dh.get(i):i.isNode===!0?i:new wr(i,e),Ke=function(i,e=null){return(...t)=>{for(const s of t)if(s===void 0)return O(`TSL: Invalid parameter for the type "${i}".`,new bt),new wr(0,i);if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(s=>{const n=typeof s;return n!=="object"&&n!=="function"}))&&(t=[Wc(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return yo(e.get(t[0]));if(t.length===1){const s=Ql(t[0],i);return s.nodeType===i?yo(s):yo(new mg(s,i))}const r=t.map(s=>Ql(s));return yo(new Wx(r,i))}};function Zl(i){return i&&i.isNode&&i.traverse(e=>{e.isConstNode&&(i=e.value)}),!!i}const uT=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function xi(i,e){return new nT(i,e)}const H=(i,e=null)=>Qx(i,e),yo=(i,e=null)=>H(i,e).toVarIntent(),Kc=(i,e=null)=>new Zx(i,e),wn=(i,e=null)=>new Jx(i,e),Pe=(i,e=null,t=null,r=null)=>new yg(i,e,t,r),k=(i,...e)=>new eT(i,...e),$=(i,e=null,t=null,r={})=>new yg(i,e,t,{...r,intent:!0});let lT=0;class cT extends J{constructor(e,t=null){super();let r=null;t!==null&&(typeof t=="object"?r=t.return:(typeof t=="string"?r=t:O("TSL: Invalid layout type.",new bt),t=null)),this.shaderNode=new xi(e,r),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const r={name:"fn"+lT++,type:t,inputs:[]};for(const s in e)s!=="return"&&r.inputs.push({name:s,type:e[s]});e=r}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return O('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function R(i,e=null){const t=new cT(i,e);return new Proxy(()=>{},{apply(r,s,n){return t.call(...n)},get(r,s,n){return Reflect.get(t,s,n)},set(r,s,n,o){return Reflect.set(t,s,n,o)}})}const wa=i=>{ks=i},xg=()=>ks,me=(...i)=>ks.If(...i);function Tg(i){return ks&&ks.addToStack(i),i}E("toStack",Tg);const dT=new Ke("color"),w=new Ke("float",ja.float),Ue=new Ke("int",ja.ints),de=new Ke("uint",ja.uint),Ha=new Ke("bool",ja.bool),ee=new Ke("vec2"),Nt=new Ke("ivec2"),vg=new Ke("uvec2"),hT=new Ke("bvec2"),C=new Ke("vec3"),Sg=new Ke("ivec3"),Ng=new Ke("uvec3"),fT=new Ke("bvec3"),q=new Ke("vec4"),wg=new Ke("ivec4"),Rg=new Ke("uvec4"),pT=new Ke("bvec4"),Yc=new Ke("mat2"),rt=new Ke("mat3"),Us=new Ke("mat4");E("toColor",dT);E("toFloat",w);E("toInt",Ue);E("toUint",de);E("toBool",Ha);E("toVec2",ee);E("toIVec2",Nt);E("toUVec2",vg);E("toBVec2",hT);E("toVec3",C);E("toIVec3",Sg);E("toUVec3",Ng);E("toBVec3",fT);E("toVec4",q);E("toIVec4",wg);E("toUVec4",Rg);E("toBVec4",pT);E("toMat2",Yc);E("toMat3",rt);E("toMat4",Us);const gT=Pe(zn).setParameterLength(2),mT=(i,e)=>new mg(H(i),e);E("element",gT);E("convert",mT);E("append",i=>(z("TSL: .append() has been renamed to .toStack().",new bt),Tg(i)));class be extends J{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1,s=null){super(e),this.name=t,this.varying=r,this.placeholderNode=H(s),this.isPropertyNode=!0,this.global=!0}getNodeType(e){const t=super.getNodeType(e);return t==="output"?e.getOutputType():t}customCacheKey(){return Vn(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(this.varying===!0)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),this.placeholderNode!==null&&e.hasWriteUsage(this)===!1){const r=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${r}`,this)}return e.getPropertyName(t)}}const gs=(i,e,t=null)=>new be(i,e,!1,t),Wn=(i,e,t=null)=>new be(i,e,!0,t),Se=k(be,"vec4","DiffuseColor"),gn=k(be,"vec3","DiffuseContribution"),hh=k(be,"vec3","EmissiveColor"),Or=k(be,"float","Roughness"),os=k(be,"float","Metalness"),Jl=k(be,"float","Clearcoat"),Ai=k(be,"float","ClearcoatRoughness"),Gt=k(be,"vec3","Sheen"),As=k(be,"float","SheenRoughness"),Qc=k(be,"float","Iridescence"),ec=k(be,"float","IridescenceIOR"),tc=k(be,"float","IridescenceThickness"),rc=k(be,"float","AlphaT"),ws=k(be,"float","Anisotropy"),oa=k(be,"vec3","AnisotropyT"),Rn=k(be,"vec3","AnisotropyB"),Gs=k(be,"color","SpecularColor"),_n=k(be,"color","SpecularColorBlended"),xn=k(be,"float","SpecularF90"),sc=k(be,"float","Shininess"),Ci=k(be,"output","Output"),En=k(be,"float","dashSize"),Ra=k(be,"float","gapSize"),aa=k(be,"float","IOR"),nc=k(be,"float","Transmission"),Eg=k(be,"float","Thickness"),Ag=k(be,"float","AttenuationDistance"),Cg=k(be,"color","AttenuationColor"),Mg=k(be,"float","Dispersion"),fh=k(be,"float","AmbientOcclusion",!1,1);class Bg extends J{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1,s=null){super("string"),this.name=e,this.shared=t,this.order=r,this.updateType=s,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const yT=(i,e=1,t=null)=>new Bg(i,!1,e,t),Zc=(i,e=0,t=null)=>new Bg(i,!0,e,t);re.FRAME;const Z=Zc("render",0,re.RENDER),bT=yT("object",1,re.OBJECT);class eo extends jc{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=bT}setName(e){return this.name=e,this}label(e){return z('TSL: "label()" has been deprecated. Use "setName()" instead.',new bt),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(r=>{const s=e(r,this);s!==void 0&&(this.value=s)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let n=e.getNodeFromHash(s);n===void 0&&(e.setHashNode(this,s),n=this);const o=n.getInputType(e),a=e.getUniformFromNode(n,o,e.shaderStage,this.name||e.context.nodeName),u=e.getPropertyName(a);e.context.nodeName!==void 0&&delete e.context.nodeName;let l=u;if(r==="bool"){const c=e.getDataFromNode(this);let d=c.propertyName;if(d===void 0){const h=e.getVarFromNode(this,null,"bool");d=e.getPropertyName(h),c.propertyName=d,l=e.format(u,o,r),e.addLineFlowCode(`${d} = ${l}`,this)}l=d}return e.format(l,r,t)}}const K=(i,e)=>{const t=uT(e||i);if(t===i&&(i=Wc(t)),i&&i.isNode===!0){let r=i.value;i.traverse(s=>{s.isConstNode===!0&&(r=s.value)}),i=r}return new eo(i,t)};class ph extends Xe{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const _T=(...i)=>{let e;if(i.length===1){const t=i[0];e=new ph(null,t.length,t)}else{const t=i[0],r=i[1];e=new ph(t,r)}return H(e)};E("toArray",(i,e)=>_T(Array(e).fill(i)));class xT extends Xe{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return $n.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=t.getScope(),n=e.getDataFromNode(s);n.assign=!0;const o=e.getNodeProperties(this);o.sourceNode=r,o.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),n=this.needsSplitAssign(e),o=r.build(e),a=r.getNodeType(e),u=s.build(e,a),l=s.getNodeType(e),c=e.getDataFromNode(this);let d;if(c.initialized===!0)t!=="void"&&(d=o);else if(n){const h=e.getVarFromNode(this,null,a),f=e.getPropertyName(h);e.addLineFlowCode(`${f} = ${u}`,this);const p=r.node,m=p.node.context({assign:!0}).build(e);for(let y=0;y{const c=l.type,d=c==="pointer";let h;return d?h="&"+u.build(e):h=u.build(e,c),h};if(Array.isArray(n)){if(n.length>s.length)O("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=s.length;else if(n.length(e=e.length>1||e[0]&&e[0].isNode===!0?wn(e):Kc(e[0]),new vT(H(i),e));E("call",ST);const NT={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ie extends Xe{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let n=new Ie(e,t,r);for(let o=0;o>"||r==="<<")return e.getIntegerType(o);if(r==="&&"||r==="||"||r==="^^")return"bool";if(r==="!"){const u=e.getTypeLength(o);return u>1?`bvec${u}`:"bool"}else if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){const u=Math.max(e.getTypeLength(o),e.getTypeLength(a));return u>1?`bvec${u}`:"bool"}else{if(e.isMatrix(o)){if(a==="float")return o;if(e.isVector(a))return e.getVectorFromMatrix(o);if(e.isMatrix(a))return o}else if(e.isMatrix(a)){if(o==="float")return a;if(e.isVector(o))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(o)?a:o}}generate(e,t){const r=this.op,{aNode:s,bNode:n}=this,o=this.getNodeType(e,t);let a=null,u=null;o!=="void"?(a=s.getNodeType(e),u=n?n.getNodeType(e):null,r==="<"||r===">"||r==="<="||r===">="||r==="=="||r==="!="?e.isVector(a)?u=a:e.isVector(u)?a=u:a!==u&&(a=u="float"):r===">>"||r==="<<"?(a=o,u=e.changeComponentType(u,"uint")):r==="%"?(a=o,u=e.isInteger(a)&&e.isInteger(u)?u:a):e.isMatrix(a)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(a):e.isMatrix(u)||(a=u=o):e.isMatrix(u)?a==="float"?a="float":e.isVector(a)?a=e.getVectorFromMatrix(u):a=u=o:a=u=o):a=u=o;const l=s.build(e,a),c=n?n.build(e,u):null,d=e.getFunctionOperator(r);if(t!=="void"){const h=e.renderer.coordinateSystem===fa;if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">=")return h?e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${l}, ${c} )`,o,t):e.format(`( ${l} ${r} ${c} )`,o,t):e.format(`( ${l} ${r} ${c} )`,o,t);if(r==="%")return e.isInteger(u)?e.format(`( ${l} % ${c} )`,o,t):e.format(`${this.getOperatorMethod(e,o)}( ${l}, ${c} )`,o,t);if(r==="!")return h&&e.isVector(a)?e.format(`not( ${l} )`,t):e.format(`( ${r} ${l} )`,a,t);if(r==="~")return e.format(`( ${r} ${l} )`,a,t);if(d)return e.format(`${d}( ${l}, ${c} )`,o,t);if(e.isMatrix(a)&&u==="float")return e.format(`( ${c} ${r} ${l} )`,o,t);if(a==="float"&&e.isMatrix(u))return e.format(`${l} ${r} ${c}`,o,t);{let f=`( ${l} ${r} ${c} )`;return!h&&o==="bool"&&e.isVector(a)&&e.isVector(u)&&(f=`all${f}`),e.format(f,o,t)}}else if(a!=="void")return d?e.format(`${d}( ${l}, ${c} )`,o,t):e.isMatrix(a)&&u==="float"?e.format(`${c} ${r} ${l}`,o,t):e.format(`${l} ${r} ${c}`,o,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Rt=$(Ie,"+").setParameterLength(2,1/0).setName("add"),xt=$(Ie,"-").setParameterLength(2,1/0).setName("sub"),ae=$(Ie,"*").setParameterLength(2,1/0).setName("mul"),vr=$(Ie,"/").setParameterLength(2,1/0).setName("div"),Pg=$(Ie,"%").setParameterLength(2).setName("mod"),wT=$(Ie,"==").setParameterLength(2).setName("equal"),RT=$(Ie,"!=").setParameterLength(2).setName("notEqual"),ET=$(Ie,"<").setParameterLength(2).setName("lessThan"),AT=$(Ie,">").setParameterLength(2).setName("greaterThan"),CT=$(Ie,"<=").setParameterLength(2).setName("lessThanEqual"),MT=$(Ie,">=").setParameterLength(2).setName("greaterThanEqual"),BT=$(Ie,"&&").setParameterLength(2,1/0).setName("and"),PT=$(Ie,"||").setParameterLength(2,1/0).setName("or"),DT=$(Ie,"!").setParameterLength(1).setName("not"),FT=$(Ie,"^^").setParameterLength(2).setName("xor"),LT=$(Ie,"&").setParameterLength(2).setName("bitAnd"),UT=$(Ie,"~").setParameterLength(1).setName("bitNot"),OT=$(Ie,"|").setParameterLength(2).setName("bitOr"),IT=$(Ie,"^").setParameterLength(2).setName("bitXor"),kT=$(Ie,"<<").setParameterLength(2).setName("shiftLeft"),GT=$(Ie,">>").setParameterLength(2).setName("shiftRight"),VT=R(([i])=>(i.addAssign(1),i)),$T=R(([i])=>(i.subAssign(1),i)),zT=R(([i])=>{const e=Ue(i).toConst();return i.addAssign(1),e}),WT=R(([i])=>{const e=Ue(i).toConst();return i.subAssign(1),e});E("add",Rt);E("sub",xt);E("mul",ae);E("div",vr);E("mod",Pg);E("equal",wT);E("notEqual",RT);E("lessThan",ET);E("greaterThan",AT);E("lessThanEqual",CT);E("greaterThanEqual",MT);E("and",BT);E("or",PT);E("not",DT);E("xor",FT);E("bitAnd",LT);E("bitNot",UT);E("bitOr",OT);E("bitXor",IT);E("shiftLeft",kT);E("shiftRight",GT);E("incrementBefore",VT);E("decrementBefore",$T);E("increment",zT);E("decrement",WT);class T extends Xe{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===T.MAX||e===T.MIN)&&arguments.length>3){let n=new T(e,t,r);for(let o=3;oo&&n>a?t:o>a?r:a>n?s:t}generateNodeType(e){const t=this.method;return t===T.LENGTH||t===T.DISTANCE||t===T.DOT?"float":t===T.CROSS?"vec3":t===T.ALL||t===T.ANY?"bool":t===T.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let n=null;if(s===T.ONE_MINUS)n=xt(1,t);else if(s===T.RECIPROCAL)n=vr(1,t);else if(s===T.DIFFERENCE)n=Ft(xt(t,r));else if(s===T.TRANSFORM_DIRECTION){let o,a;e.isMatrix(t.getNodeType(e))?(o=t,a=r):(o=r,a=t),n=Ht(ae(o,q(C(a),0)).xyz)}return n!==null?n:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let s=this.method;const n=this.getNodeType(e),o=this.getInputType(e),a=this.aNode,u=this.bNode,l=this.cNode,c=e.renderer.coordinateSystem;if(s===T.NEGATE)return e.format("( - "+a.build(e,o)+" )",n,t);{const d=[];return s===T.CROSS?d.push(a.build(e,n),u.build(e,n)):c===fa&&s===T.STEP?d.push(a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":o),u.build(e,o)):c===fa&&(s===T.MIN||s===T.MAX)?d.push(a.build(e,o),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":o)):s===T.REFRACT?d.push(a.build(e,o),u.build(e,o),l.build(e,"float")):s===T.MIX?d.push(a.build(e,o),u.build(e,o),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":o)):(c===Ui&&s===T.ATAN&&u!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===T.DFDX||s===T.DFDY)&&(z(`TSL: '${s}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),s="/*"+s+"*/"),d.push(a.build(e,o)),u!==null&&d.push(u.build(e,o)),l!==null&&d.push(l.build(e,o))),e.format(`${e.getMethod(s,n)}( ${d.join(", ")} )`,n,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}T.ALL="all";T.ANY="any";T.RADIANS="radians";T.DEGREES="degrees";T.EXP="exp";T.EXP2="exp2";T.LOG="log";T.LOG2="log2";T.SQRT="sqrt";T.INVERSE_SQRT="inversesqrt";T.FLOOR="floor";T.CEIL="ceil";T.NORMALIZE="normalize";T.FRACT="fract";T.SIN="sin";T.SINH="sinh";T.COS="cos";T.COSH="cosh";T.TAN="tan";T.TANH="tanh";T.ASIN="asin";T.ASINH="asinh";T.ACOS="acos";T.ACOSH="acosh";T.ATAN="atan";T.ATANH="atanh";T.ABS="abs";T.SIGN="sign";T.LENGTH="length";T.NEGATE="negate";T.ONE_MINUS="oneMinus";T.DFDX="dFdx";T.DFDY="dFdy";T.ROUND="round";T.RECIPROCAL="reciprocal";T.TRUNC="trunc";T.FWIDTH="fwidth";T.TRANSPOSE="transpose";T.DETERMINANT="determinant";T.INVERSE="inverse";T.EQUALS="equals";T.MIN="min";T.MAX="max";T.STEP="step";T.REFLECT="reflect";T.DISTANCE="distance";T.DIFFERENCE="difference";T.DOT="dot";T.CROSS="cross";T.POW="pow";T.TRANSFORM_DIRECTION="transformDirection";T.MIX="mix";T.CLAMP="clamp";T.REFRACT="refract";T.SMOOTHSTEP="smoothstep";T.FACEFORWARD="faceforward";const Jc=w(1e-6),jT=w(Math.PI),HT=$(T,T.ALL).setParameterLength(1),qT=$(T,T.ANY).setParameterLength(1),XT=$(T,T.RADIANS).setParameterLength(1),KT=$(T,T.DEGREES).setParameterLength(1),Dg=$(T,T.EXP).setParameterLength(1),Ii=$(T,T.EXP2).setParameterLength(1),Fg=$(T,T.LOG).setParameterLength(1),jr=$(T,T.LOG2).setParameterLength(1),ds=$(T,T.SQRT).setParameterLength(1),YT=$(T,T.INVERSE_SQRT).setParameterLength(1),Os=$(T,T.FLOOR).setParameterLength(1),ed=$(T,T.CEIL).setParameterLength(1),Ht=$(T,T.NORMALIZE).setParameterLength(1),Sr=$(T,T.FRACT).setParameterLength(1),Dt=$(T,T.SIN).setParameterLength(1),QT=$(T,T.SINH).setParameterLength(1),pr=$(T,T.COS).setParameterLength(1),ZT=$(T,T.COSH).setParameterLength(1),JT=$(T,T.TAN).setParameterLength(1),ev=$(T,T.TANH).setParameterLength(1),tv=$(T,T.ASIN).setParameterLength(1),rv=$(T,T.ASINH).setParameterLength(1),Lg=$(T,T.ACOS).setParameterLength(1),sv=$(T,T.ACOSH).setParameterLength(1),nv=$(T,T.ATAN).setParameterLength(1,2),iv=$(T,T.ATANH).setParameterLength(1),Ft=$(T,T.ABS).setParameterLength(1),Ug=$(T,T.SIGN).setParameterLength(1),Hr=$(T,T.LENGTH).setParameterLength(1),Og=$(T,T.NEGATE).setParameterLength(1),ov=$(T,T.ONE_MINUS).setParameterLength(1),Ig=$(T,T.DFDX).setParameterLength(1),kg=$(T,T.DFDY).setParameterLength(1),av=$(T,T.ROUND).setParameterLength(1),uv=$(T,T.RECIPROCAL).setParameterLength(1),lv=$(T,T.TRUNC).setParameterLength(1),Gg=$(T,T.FWIDTH).setParameterLength(1),cv=$(T,T.TRANSPOSE).setParameterLength(1),dv=$(T,T.DETERMINANT).setParameterLength(1),hv=$(T,T.INVERSE).setParameterLength(1),Ln=$(T,T.MIN).setParameterLength(2,1/0),st=$(T,T.MAX).setParameterLength(2,1/0),ki=$(T,T.STEP).setParameterLength(2),fv=$(T,T.REFLECT).setParameterLength(2),pv=$(T,T.DISTANCE).setParameterLength(2),gv=$(T,T.DIFFERENCE).setParameterLength(2),Vs=$(T,T.DOT).setParameterLength(2),$s=$(T,T.CROSS).setParameterLength(2),qa=$(T,T.POW).setParameterLength(2),Vg=i=>ae(i,i),mv=i=>ae(i,i,i),$g=i=>ae(i,i,i,i),yv=$(T,T.TRANSFORM_DIRECTION).setParameterLength(2),bv=(i,e)=>Ht(ae(e,q(C(i),0)).xyz),_v=(i,e)=>Ht(q(C(i),0).mul(e).xyz),xv=i=>ae(Ug(i),qa(Ft(i),1/3)),zg=i=>Vs(i,i),xe=$(T,T.MIX).setParameterLength(3),hs=(i,e=0,t=1)=>new T(T.CLAMP,H(i),H(e),H(t)),td=i=>hs(i),Wg=$(T,T.REFRACT).setParameterLength(3),nr=$(T,T.SMOOTHSTEP).setParameterLength(3),Tv=$(T,T.FACEFORWARD).setParameterLength(3),vv=R(([i])=>{const r=43758.5453,s=Vs(i.xy,ee(12.9898,78.233)),n=Pg(s,jT);return Sr(Dt(n).mul(r))}),Sv=(i,e,t)=>xe(e,t,i),Nv=(i,e,t)=>nr(e,t,i),wv=(i,e)=>ki(e,i);E("all",HT);E("any",qT);E("radians",XT);E("degrees",KT);E("exp",Dg);E("exp2",Ii);E("log",Fg);E("log2",jr);E("sqrt",ds);E("inverseSqrt",YT);E("floor",Os);E("ceil",ed);E("normalize",Ht);E("fract",Sr);E("sin",Dt);E("sinh",QT);E("cos",pr);E("cosh",ZT);E("tan",JT);E("tanh",ev);E("asin",tv);E("asinh",rv);E("acos",Lg);E("acosh",sv);E("atan",nv);E("atanh",iv);E("abs",Ft);E("sign",Ug);E("length",Hr);E("lengthSq",zg);E("negate",Og);E("oneMinus",ov);E("dFdx",Ig);E("dFdy",kg);E("round",av);E("reciprocal",uv);E("trunc",lv);E("fwidth",Gg);E("min",Ln);E("max",st);E("step",wv);E("reflect",fv);E("distance",pv);E("dot",Vs);E("cross",$s);E("pow",qa);E("pow2",Vg);E("pow3",mv);E("pow4",$g);E("transformDirection",yv);E("transformNormalByViewMatrix",bv);E("transformNormalByInverseViewMatrix",_v);E("mix",Sv);E("clamp",hs);E("refract",Wg);E("smoothstep",Nv);E("faceForward",Tv);E("difference",gv);E("saturate",td);E("cbrt",xv);E("transpose",cv);E("determinant",dv);E("inverse",hv);E("rand",vv);class Rv extends J{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}generateNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(r!==null){const n=r.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(s))return n}return s}setup(e){const t=this.condNode,r=this.ifNode.isolate(),s=this.elseNode?this.elseNode.isolate():null,n=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=n,s!==null&&(e.getDataFromNode(s).parentNodeBlock=n);const o=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=o?r:r.context({nodeBlock:r}),a.elseNode=s?o?s:s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;const{condNode:n,ifNode:o,elseNode:a}=e.getNodeProperties(this),u=e.currentFunctionNode,l=t!=="void",c=l?gs(r).build(e):"";s.nodeProperty=c;const d=n.build(e,"bool");if(e.context.uniformFlow&&a!==null){const p=o.build(e,r),g=a.build(e,r),m=e.getTernary(d,p,g);return e.format(m,r,t)}e.addFlowCode(` +${e.tab}if ( ${d} ) { + +`).addFlowTab();let f=o.build(e,r);if(f&&(l?f=c+" = "+f+";":(f="return "+f+";",u===null&&(z("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),f="// "+f))),e.removeFlowTab().addFlowCode(e.tab+" "+f+` + +`+e.tab+"}"),a!==null){e.addFlowCode(` else { + +`).addFlowTab();let p=a.build(e,r);p&&(l?p=c+" = "+p+";":(p="return "+p+";",u===null&&(z("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),p="// "+p))),e.removeFlowTab().addFlowCode(e.tab+" "+p+` + +`+e.tab+`} + +`)}else e.addFlowCode(` + +`);return e.format(c,r,t)}}const Ut=Pe(Rv).setParameterLength(2,3);E("select",Ut);class rd extends J{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),s=this.node.build(e,t);return e.setContext(r),s}}const Hs=(i=null,e={})=>{let t=i;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new rd(t,e)},Ev=i=>Hs(i,{uniformFlow:!0}),jg=(i,e)=>Hs(i,{nodeName:e});function Av(i,e,t=null){return Hs(t,{getShadow:({light:r,shadowColorNode:s})=>e===r?s.mul(i):s})}function Cv(i,e=null){return Hs(e,{getAO:(t,{material:r})=>r.transparent===!0?t:t!==null?t.mul(i):i})}function Mv(i,e){return z('TSL: "label()" has been deprecated. Use "setName()" instead.'),jg(i,e)}E("context",Hs);E("label",Mv);E("uniformFlow",Ev);E("setName",jg);E("builtinShadowContext",(i,e,t)=>Av(e,t,i));E("builtinAOContext",(i,e)=>Cv(e,i));class ua extends J{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0],r=this.getShared(t);if(this!==r)return r.build(...e);if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let s=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){const a=t.getDataFromNode(this);a.forceDeclaration=!0,s=!0}const n=t.getBaseStack();s?n.addToStackBefore(this):n.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:n}=e,o=n.backend.isWebGPUBackend===!0;let a=!1,u=!1;s&&(a=e.isDeterministic(t),u=o?s:a);const l=this.getNodeType(e);if(l=="void")return this.isIntent(e)!==!0&&O('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);const c=e.getVectorType(l),d=t.build(e,c),h=e.getVarFromNode(this,r,c,void 0,u),f=e.getPropertyName(h);let p=f;if(u)if(o)p=a?`const ${f}`:`let ${f}`;else{const g=t.getArrayCount(e);p=`const ${e.getVar(h.type,f,g)}`}return e.addLineFlowCode(`${p} = ${d}`,this),f}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const sd=Pe(ua),Bv=(i,e=null)=>sd(i,e).toStack(),Pv=(i,e=null)=>sd(i,e,!0).toStack(),Dv=i=>sd(i).setIntent(!0).toStack();E("toVar",Bv);E("toConst",Pv);E("toVarIntent",Dv);class Fv extends J{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const An=(i,e,t=null)=>new Fv(H(i),e,t);class Lv extends J{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=An(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(r===void 0){const s=this.name,n=this.getNodeType(e),o=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,n,o,a),t.node=An(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation=e.shaderStage==="fragment"),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(si.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),s=this.setupVarying(e);if(r[t]===void 0){const n=this.getNodeType(e),o=e.getPropertyName(s,si.VERTEX);if(e.shaderStage===si.VERTEX){const a=r.node.build(e,n);e.addLineFlowCode(`${o} = ${a}`,this)}else e.flowNodeFromShaderStage(si.VERTEX,r.node,n,o);r[t]=o}return e.getPropertyName(s)}}const qs=Pe(Lv).setParameterLength(1,2),Uv=i=>qs(i);E("toVarying",qs);E("toVertexStage",Uv);const Ov=R(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),r=i.lessThanEqual(.04045);return xe(e,t,r)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Iv=R(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),r=i.lessThanEqual(.0031308);return xe(e,t,r)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),nd="WorkingColorSpace",kv="OutputColorSpace";class Hg extends Xe{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===nd?We.workingColorSpace:t===kv?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let n=t;return We.enabled===!1||r===s||!r||!s||(We.getTransfer(r)===oe&&(n=q(Ov(n.rgb),n.a)),We.getPrimaries(r)!==We.getPrimaries(s)&&(n=q(rt(We._getMatrix(new Qi,r,s)).mul(n.rgb),n.a)),We.getTransfer(s)===oe&&(n=q(Iv(n.rgb),n.a))),n}}const Gv=(i,e)=>new Hg(H(i),nd,e),id=(i,e)=>new Hg(H(i),e,nd);E("workingToColorSpace",Gv);E("colorSpaceToWorking",id);let Vv=class extends zn{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class qg extends J{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=re.OBJECT}setGroup(e){return this.group=e,this}element(e){return new Vv(this,H(e))}setNodeType(e){const t=K(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let s=1;snew qg(i,e,t);class zv extends qg{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(Z)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const Wv=(i,e,t=null)=>new zv(i,e,t);class jv extends Xe{static get type(){return"ToneMappingNode"}constructor(e,t=qv,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Ri(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,r=this._toneMapping;if(r===Ds)return t;let s=null;const n=e.renderer.library.getToneMappingFunction(r);return n!==null?s=q(n(t.rgb,this.exposureNode),t.a):(O("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const Hv=(i,e,t)=>new jv(i,H(e),H(t)),qv=Wv("toneMappingExposure","float");E("toneMapping",(i,e,t)=>Hv(e,t,i));const gh=new WeakMap;function mh(i,e){let t=gh.get(i);return t===void 0&&(t=new l_(i,e),gh.set(i,t)),t}class Kr extends jc{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=kc,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let r=e.globalCache.getData(this.value);r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),r=e.getTypeLength(t),s=this.value,n=this.bufferStride||r,o=this.bufferOffset;let a;s.isInterleavedBuffer===!0?a=s:s.isBufferAttribute===!0?a=mh(s.array,n):a=mh(s,n);const u=new u_(a,r,o);a.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.context.nodeName;r!==void 0&&delete e.context.nodeName;const s=e.getBufferAttributeFromNode(this,t,r),n=e.getPropertyName(s);let o=null;if(e.shaderStage==="vertex"||e.shaderStage==="compute")this.name=n,o=n;else{let a;r&&(a=r+"Varying"),o=qs(this,a).build(e,t)}return o}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function od(i,e=null,t=0,r=0,s=kc,n=!1){return e==="mat3"||e===null&&i.itemSize===9?rt(new Kr(i,"vec3",9,0).setUsage(s).setInstanced(n),new Kr(i,"vec3",9,3).setUsage(s).setInstanced(n),new Kr(i,"vec3",9,6).setUsage(s).setInstanced(n)):e==="mat4"||e===null&&i.itemSize===16?Us(new Kr(i,"vec4",16,0).setUsage(s).setInstanced(n),new Kr(i,"vec4",16,4).setUsage(s).setInstanced(n),new Kr(i,"vec4",16,8).setUsage(s).setInstanced(n),new Kr(i,"vec4",16,12).setUsage(s).setInstanced(n)):new Kr(i,e,t,r).setUsage(s)}const Xg=(i,e=null,t=0,r=0)=>od(i,e,t,r),Kg=(i,e=null,t=0,r=0)=>od(i,e,t,r,kc,!0),Yg=(i,e=null,t=0,r=0)=>od(i,e,t,r,Ia,!0);E("toAttribute",i=>Xg(i.value));class Le extends J{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s;if(r===Le.VERTEX)s=e.getVertexIndex();else if(r===Le.INSTANCE)s=e.getInstanceIndex();else if(r===Le.DRAW)s=e.getDrawIndex();else if(r===Le.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Le.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else if(r===Le.SUBGROUP)s=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+r);let n;return e.shaderStage==="vertex"||e.shaderStage==="compute"?n=s:n=qs(this).build(e,t),n}}Le.VERTEX="vertex";Le.INSTANCE="instance";Le.SUBGROUP="subgroup";Le.INVOCATION_LOCAL="invocationLocal";Le.INVOCATION_SUBGROUP="invocationSubgroup";Le.DRAW="draw";const Xv=k(Le,Le.VERTEX),Un=k(Le,Le.INSTANCE);Le.SUBGROUP;Le.INVOCATION_SUBGROUP;Le.INVOCATION_LOCAL;const Kv=k(Le,Le.DRAW);class Yv extends J{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=re.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return z('TSL: "label()" has been deprecated. Use "setName()" instead.',new bt),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){this.count!==null&&this.countNode===null&&(this.countNode=K(this.count,"uint").onObjectUpdate(()=>this.count));const t=this.computeNode.build(e);if(t){const r=e.getNodeProperties(this);r.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if(r==="compute"){const s=this.computeNode.build(e,"void");if(s!==""&&e.addLineFlowCode(s,this),this.count!==null&&e.allowEarlyReturns===!0){const n=this.countNode.build(e,"uint"),o=Un.build(e,"uint");e.flow.code=`${e.tab}if ( ${o} >= ${n} ) { return; } + +${e.flow.code}`}}else{const n=e.getNodeProperties(this).outputComputeNode;if(n)return n.build(e,t)}}}const Qg=(i,e=[64])=>{(e.length===0||e.length>3)&&O("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new bt);for(let t=0;t{const r=Qg(i,t);return typeof e=="number"?r.count=e:r.dispatchSize=e,r};E("compute",Qv);E("computeKernel",Qg);class Zv extends J{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const n=this.node.build(e,...t);return e.setCache(r),n}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const Mi=i=>new Zv(H(i));function Jv(i,e=!0){return z('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),Mi(i).setParent(e)}E("cache",Jv);E("isolate",Mi);class e0 extends J{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const t0=Pe(e0).setParameterLength(2);E("bypass",t0);const Zg=R(([i,e,t,r=w(0),s=w(1),n=Ha(!1)])=>{let o=i.sub(e).div(t.sub(e));return Zl(n)&&(o=o.clamp()),o.mul(s.sub(r)).add(r)});function r0(i,e,t,r=w(0),s=w(1)){return Zg(i,e,t,r,s,!0)}E("remap",Zg);E("remapClamp",r0);class la extends J{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if(r==="void")e.addLineFlowCode(s,this);else return e.format(s,r,t)}}const gr=Pe(la).setParameterLength(1,2),s0=i=>(i?Ut(i,gr("discard")):gr("discard")).toStack();E("discard",s0);const Jg=R(([i])=>q(i.rgb.mul(i.a),i.a),{color:"vec4",return:"vec4"}),n0=R(([i])=>i.a.equal(0).select(q(0),q(i.rgb.div(i.a),i.a)),{color:"vec4",return:"vec4"});class i0 extends Xe{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=q(t.rgb,t.a.clamp(0,1)),t=n0(t);const r=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||Ds,s=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Dn;return r!==Ds&&(t=t.toneMapping(r)),s!==Dn&&s!==We.workingColorSpace&&(t=t.workingToColorSpace(s)),t=Jg(t),t}}const em=(i,e=null,t=null)=>new i0(H(i),e,t);E("renderOutput",em);class o0 extends Xe{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e);if(t!==null)t(e,r);else{const s="--- TSL debug - "+e.shaderStage+" shader ---",n="-".repeat(s.length);let o="";o+="// #"+s+`# +`,o+=e.flow.code.replace(/^\t/mg,"")+` +`,o+="/* ... */ "+r+` /* ... */ +`,o+="// #"+n+`# +`,p_(o)}return r}}const a0=(i,e=null)=>new o0(H(i),e).toStack();E("debug",a0);class tm extends Oa{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class u0 extends J{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=re.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==tm&&Be('TSL: ".toInspector()" is only available with WebGPU.'),t}}function l0(i,e="",t=null){return i=H(i),i.before(new u0(i,e,t))}E("toInspector",l0);class rm extends J{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const n=e.geometry.getAttribute(t),o=e.getTypeFromAttribute(n),a=e.getAttribute(t,o);return e.shaderStage==="vertex"?e.format(a.name,o,r):qs(this).build(e,r)}else return z(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const Wt=(i,e=null)=>new rm(i,e),Xs=(i=0)=>Wt("uv"+(i>0?i:""),"vec2");class c0 extends J{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const Gi=Pe(c0).setParameterLength(1,2);class d0 extends eo{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=re.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&r.width!==void 0){const{width:s,height:n}=r;this.value=Math.log2(Math.max(s,n))}}}const h0=Pe(d0).setParameterLength(1);class f0 extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const sm=new Ic;class to extends eo{static get type(){return"TextureNode"}constructor(e=sm,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=re.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?this.gatherNode===null?"float":"vec4":this.value.type===Ge?"uvec4":this.value.type===Ze?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Xs(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=K(this.value.matrix)),this._matrixUniform.mul(C(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=K(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(Ue(Gi(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||r.isTexture!==!0)throw new f0("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const s=R(()=>{let u=this.uvNode;return(u===null||e.context.forceUVContext===!0)&&e.context.getUV&&(u=e.context.getUV(this,e)),u||(u=this.getDefaultUV()),this.updateMatrix===!0&&(u=this.getTransformedUV(u)),u=this.setupUV(e,u),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?re.OBJECT:re.NONE,u})();let n=this.levelNode;n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this));let o=null,a=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(js.TEXTURE_COMPARE))o=this.compareNode;else{const u=r.compareFunction;u===null||u===Uc||u===Zi||u===ma||u===Pn?a=this.compareNode:(o=this.compareNode,Be('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=s,t.levelNode=n,t.biasNode=this.biasNode,t.compareNode=o,t.compareStepNode=a,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,s,n,o,a,u,l,c,d){const h=this.value;let f;return n?f=e.generateTextureBias(h,t,r,n,o,c):u?f=e.generateTextureGrad(h,t,r,u,o,c):l?a?f=e.generateTextureGatherCompare(h,t,r,a,o,c,d):f=e.generateTextureGather(h,t,r,l,o,c,d):a?f=e.generateTextureCompare(h,t,r,a,o,c):this.sampler===!1?f=e.generateTextureLoad(h,t,r,s,o,c):s?f=e.generateTextureLevel(h,t,r,s,o,c):f=e.generateTexture(h,t,r,o,c),f}generate(e,t){const r=this.value,s=e.getNodeProperties(this),n=super.generate(e,"property");if(/^sampler/.test(t))return n+"_sampler";if(e.isReference(t))return n;{const o=e.getDataFromNode(this);let a=this.getNodeType(e),u=o.propertyName;if(u===void 0){const{uvNode:c,levelNode:d,biasNode:h,compareNode:f,compareStepNode:p,depthNode:g,gradNode:m,gatherNode:y,offsetNode:x}=s,_=this.generateUV(e,c),N=d?d.build(e,"float"):null,A=h?h.build(e,"float"):null,v=g?g.build(e,"int"):null,S=f?f.build(e,"float"):null,P=p?p.build(e,"float"):null,F=m?[m[0].build(e,"vec2"),m[1].build(e,"vec2")]:null,U=y?y.build(e,"int"):null,W=x?this.generateOffset(e,x):null,se=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;U&&(a="vec4");let ie=v;ie===null&&r.isArrayTexture&&this.isTexture3DNode!==!0&&(ie="0");const he=e.getVarFromNode(this);u=e.getPropertyName(he);let X=this.generateSnippet(e,n,_,N,A,ie,S,F,U,W,se);if(P!==null){const ue=r.compareFunction;ue===ma||ue===Pn?X=ki(gr(X,a),gr(P,"float")).build(e,a):X=ki(gr(P,"float"),gr(X,a)).build(e,a)}e.addLineFlowCode(`${u} = ${X}`,this),o.snippet=X,o.propertyName=u}let l=u;return e.needsToWorkingColorSpace(r)&&(l=id(gr(l,a),r.colorSpace).setup(e).build(e,a)),e.format(l,a,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=H(e),t.referenceNode=this.getBase(),H(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=H(e).mul(h0(t)),t.referenceNode=this.getBase();const r=t.value;return t.generateMipmaps===!1&&(r&&r.generateMipmaps===!1||r.minFilter===Lt||r.magFilter===Lt)&&(z("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),H(t)}level(e){const t=this.clone();return t.levelNode=H(e),t.referenceNode=this.getBase(),H(t)}size(e){return Gi(this,e)}bias(e){const t=this.clone();return t.biasNode=H(e),t.referenceNode=this.getBase(),H(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=H(e),t.referenceNode=this.getBase(),H(t)}grad(e,t){const r=this.clone();return r.gradNode=[H(e),H(t)],r.referenceNode=this.getBase(),H(r)}gather(e=0){const t=this.clone();return t.gatherNode=H(e),t.referenceNode=this.getBase(),H(t)}depth(e){const t=this.clone();return t.depthNode=H(e),t.referenceNode=this.getBase(),H(t)}offset(e){const t=this.clone();return t.offsetNode=H(e),t.referenceNode=this.getBase(),H(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();const r=this._flipYUniform;r!==null&&(r.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}const p0=Pe(to).setParameterLength(1,4).setName("texture"),Ne=(i=sm,e=null,t=null,r=null)=>{let s;return i&&i.isTextureNode===!0?(s=H(i.clone()),s.referenceNode=i.getBase(),e!==null&&(s.uvNode=H(e)),t!==null&&(s.levelNode=H(t)),r!==null&&(s.biasNode=H(r))):s=p0(i,e,t,r),s},Jt=(...i)=>Ne(...i).setSampler(!1);class ad extends eo{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const ud=(i,e,t)=>new ad(i,e,t);class g0 extends zn{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(e),s=this.node.getPaddedType();return e.format(t,s,r)}}class m0 extends ad{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Na(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=re.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if(r==="float"||r==="int"||r==="uint")for(let s=0;snew m0(i,e);class y0 extends J{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Ks=Pe(y0).setParameterLength(1);let ni,ii;class Re extends J{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===Re.DPR?"float":this.scope===Re.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=re.NONE;return(this.scope===Re.SIZE||this.scope===Re.VIEWPORT||this.scope===Re.DPR)&&(e=re.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Re.VIEWPORT?t!==null?ii.copy(t.viewport):(e.getViewport(ii),ii.multiplyScalar(e.getPixelRatio())):this.scope===Re.DPR?this._output.value=e.getPixelRatio():t!==null?(ni.width=t.width,ni.height=t.height):e.getDrawingBufferSize(ni)}setup(){const e=this.scope;let t=null;return e===Re.SIZE?t=K(ni||(ni=new ce)):e===Re.VIEWPORT?t=K(ii||(ii=new He)):e===Re.DPR?t=K(1):t=ee(jn.div(ic)),this._output=t,t}generate(e){if(this.scope===Re.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(ic).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}Re.COORDINATE="coordinate";Re.VIEWPORT="viewport";Re.SIZE="size";Re.UV="uv";Re.DPR="dpr";const nm=k(Re,Re.DPR),as=k(Re,Re.UV),ic=k(Re,Re.SIZE),jn=k(Re,Re.COORDINATE),Bi=k(Re,Re.VIEWPORT),b0=Bi.zw;Bi.xy;let Su=null,bo=null,Nu=null,_o=null,wu=null,xo=null,Ru=null,To=null,Eu=null,vo=null;const ro=K(0,"uint").setName("u_cameraIndex").setGroup(Zc("cameraIndex")).toVarying("v_cameraIndex"),Cs=K("float").setName("cameraNear").setGroup(Z).onRenderUpdate(({camera:i})=>i.near),Ms=K("float").setName("cameraFar").setGroup(Z).onRenderUpdate(({camera:i})=>i.far),rr=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrix);bo===null?bo=Tt(t).setGroup(Z).setName("cameraProjectionMatrices"):bo.array=t,e=bo.element(i.isMultiViewCamera?Ks("gl_ViewID_OVR"):ro)}else Su===null&&(Su=K(i.projectionMatrix).setName("cameraProjectionMatrix").setGroup(Z).onRenderUpdate(({camera:t})=>t.projectionMatrix)),e=Su;return e}).once()(),_0=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrixInverse);_o===null?_o=Tt(t).setGroup(Z).setName("cameraProjectionMatricesInverse"):_o.array=t,e=_o.element(i.isMultiViewCamera?Ks("gl_ViewID_OVR"):ro)}else Nu===null&&(Nu=K(i.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(Z).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse)),e=Nu;return e}).once()(),Hn=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorldInverse);xo===null?xo=Tt(t).setGroup(Z).setName("cameraViewMatrices"):xo.array=t,e=xo.element(i.isMultiViewCamera?Ks("gl_ViewID_OVR"):ro)}else wu===null&&(wu=K(i.matrixWorldInverse).setName("cameraViewMatrix").setGroup(Z).onRenderUpdate(({camera:t})=>t.matrixWorldInverse)),e=wu;return e}).once()(),ld=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorld);To===null?To=Tt(t).setGroup(Z).setName("cameraWorldMatrices"):To.array=t,e=To.element(i.isMultiViewCamera?Ks("gl_ViewID_OVR"):ro)}else Ru===null&&(Ru=K(i.matrixWorld).setName("cameraWorldMatrix").setGroup(Z).onRenderUpdate(({camera:t})=>t.matrixWorld)),e=Ru;return e}).once()(),x0=R(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(let r=0,s=i.cameras.length;r{const n=r.cameras,o=s.array;for(let a=0,u=n.length;ar.value.setFromMatrixPosition(t.matrixWorld))),e=Eu;return e}).once()(),yh=new c_;class Ce extends J{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=re.OBJECT,this.uniformNode=new eo(null)}generateNodeType(){const e=this.scope;if(e===Ce.WORLD_MATRIX)return"mat4";if(e===Ce.POSITION||e===Ce.VIEW_POSITION||e===Ce.DIRECTION||e===Ce.SCALE)return"vec3";if(e===Ce.RADIUS)return"float"}update(e){const t=this.object3d,r=this.uniformNode,s=this.scope;if(s===Ce.WORLD_MATRIX)r.value=t.matrixWorld;else if(s===Ce.POSITION)r.value=r.value||new V,r.value.setFromMatrixPosition(t.matrixWorld);else if(s===Ce.SCALE)r.value=r.value||new V,r.value.setFromMatrixScale(t.matrixWorld);else if(s===Ce.DIRECTION)r.value=r.value||new V,t.getWorldDirection(r.value);else if(s===Ce.VIEW_POSITION){const n=e.camera;r.value=r.value||new V,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(n.matrixWorldInverse)}else if(s===Ce.RADIUS){const n=e.object.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),yh.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),r.value=yh.radius}}generate(e){const t=this.scope;return t===Ce.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Ce.POSITION||t===Ce.VIEW_POSITION||t===Ce.DIRECTION||t===Ce.SCALE?this.uniformNode.nodeType="vec3":t===Ce.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Ce.WORLD_MATRIX="worldMatrix";Ce.POSITION="position";Ce.SCALE="scale";Ce.VIEW_POSITION="viewPosition";Ce.DIRECTION="direction";Ce.RADIUS="radius";class Xt extends Ce{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}Xt.DIRECTION;const zs=k(Xt,Xt.WORLD_MATRIX);Xt.POSITION;Xt.SCALE;Xt.VIEW_POSITION;Xt.RADIUS;const T0=K(new Qi).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),Ws=R(i=>i.context.modelViewMatrix||v0).once()().toVar("modelViewMatrix"),v0=Hn.mul(zs),bh=R(i=>(i.context.isHighPrecisionModelViewMatrix=!0,K("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),_h=R(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return K("mat3").onObjectUpdate(({object:t,camera:r})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),S0=R(i=>i.shaderStage!=="fragment"?(Be("TSL: `clipSpace` is only available in fragment stage."),q()):i.context.clipSpace.toVarying("v_clipSpace")).once()(),mt=Wt("position","vec3"),Qe=mt.toVarying("positionLocal"),Ea=mt.toVarying("positionPrevious"),On=R(i=>zs.mul(Qe).xyz.toVarying(i.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),im=R(()=>Qe.transformDirection(zs).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),je=R(i=>{if(i.shaderStage==="fragment"&&i.material.vertexNode){const e=_0.mul(S0);return e.xyz.div(e.w).toVar("positionView")}return i.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),Ee=R(i=>{let e;return i.camera.isOrthographicCamera?e=C(0,0,1):e=je.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class N0 extends J{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===ft?"false":e.getFrontFacing()}}const w0=k(N0),om=w(w0).mul(2).sub(1),so=R(([i],{material:e})=>{const t=e.side;return t===ft?i=i.mul(-1):t===Gr&&(i=i.mul(om)),i}),am=Wt("normal","vec3"),Nr=R(i=>i.geometry.hasAttribute("normal")===!1?(z('TSL: Vertex attribute "normal" not found on geometry.'),C(0,1,0)):am,"vec3").once()().toVar("normalLocal"),R0=je.dFdx().cross(je.dFdy()).normalize().toVar("normalFlat"),Vi=R(i=>{let e;return i.isFlatShading()?e=R0:e=lm(Nr).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),E0=R(i=>{let e=Vi.transformNormalByInverseViewMatrix(Hn);return i.isFlatShading()!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),ge=R(i=>{let e;return i.subBuildFn==="NORMAL"||i.subBuildFn==="VERTEX"?(e=Vi,i.isFlatShading()!==!0&&(e=so(e))):e=i.context.setupNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),qn=ge.transformNormalByInverseViewMatrix(Hn).toVar("normalWorld"),Bs=R(({subBuildFn:i,context:e})=>{let t;return i==="NORMAL"||i==="VERTEX"?t=ge:t=e.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),um=R(([i,e=zs])=>rt(e).inverse().transpose().mul(i).normalize());E("transformNormal",um);const lm=R(([i],e)=>{const t=e.context.modelNormalViewMatrix;return t?i.transformNormalByViewMatrix(t):T0.mul(i).transformNormalByViewMatrix(Hn)});R(()=>(z('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),ge)).once(["NORMAL","VERTEX"])();R(()=>(z('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),qn)).once(["NORMAL","VERTEX"])();R(()=>(z('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Bs)).once(["NORMAL","VERTEX"])();const Au=new At,A0=K(0).onReference(({material:i})=>i).onObjectUpdate(({material:i})=>i.refractionRatio),Cu=K(1).onReference(({material:i})=>i).onObjectUpdate(function({material:i,scene:e}){return i.envMap?i.envMapIntensity:e.environmentIntensity}),oc=K(new At).onReference(function(i){return i.material}).onObjectUpdate(function({material:i,scene:e}){const r=(e.environment!==null||e.environmentNode&&e.environmentNode.isNode)&&i.envMap===null?e.environmentRotation:i.envMapRotation;return r?Au.makeRotationFromEuler(r).transpose():Au.identity(),Au}),C0=Ee.negate().reflect(ge),M0=Ee.negate().refract(ge,A0),B0=C0.transformDirection(ld).toVar("reflectVector"),P0=M0.transformDirection(ld).toVar("refractVector"),D0=new $a;class F0 extends to{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Ta?B0:e.mapping===va?P0:(O('CubeTextureNode: Mapping "%s" not supported.',e.mapping),C(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return r.isDepthTexture===!0?e.renderer.coordinateSystem===Ui?C(t.x,t.y.negate(),t.z):t:(t=oc.mul(t),(e.renderer.coordinateSystem===Ui||!r.isRenderTargetTexture)&&(t=C(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const L0=Pe(F0).setParameterLength(1,4).setName("cubeTexture"),vt=(i=D0,e=null,t=null,r=null)=>{let s;return i&&i.isCubeTextureNode===!0?(s=H(i.clone()),s.referenceNode=i,e!==null&&(s.uvNode=H(e)),t!==null&&(s.levelNode=H(t)),r!==null&&(s.biasNode=H(r))):s=L0(i,e,t,r),s};class U0 extends zn{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(e),s=this.getNodeType(e);return e.format(t,r,s)}}class cd extends J{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=re.OBJECT}element(e){return new U0(this,H(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return z('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=ud(null,e,this.count):Array.isArray(this.getValueFromReference())?(t=Tt(null,e),t.updateType=re.OBJECT):e==="texture"?t=Ne(null):e==="cubeTexture"?t=vt(null):t=K(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let s=1;snew cd(i,e,t),O0=(i,e,t,r)=>new cd(i,e,r,t);class I0 extends cd{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const ns=(i,e,t=null)=>new I0(i,e,t),cm=Xs(),k0=je.dFdx(),G0=je.dFdy(),dm=cm.dFdx(),hm=cm.dFdy(),fm=ge,pm=G0.cross(fm),gm=fm.cross(k0),ac=pm.mul(dm.x).add(gm.mul(hm.x)),uc=pm.mul(dm.y).add(gm.mul(hm.y)),xh=ac.dot(ac).max(uc.dot(uc)),mm=xh.equal(0).select(0,xh.inverseSqrt()),V0=ac.mul(mm).toVar("tangentViewFrame"),$0=uc.mul(mm).toVar("bitangentViewFrame"),ym=Wt("tangent","vec4"),Aa=ym.xyz.toVar("tangentLocal"),bm=R(i=>{let e;return i.subBuildFn==="VERTEX"||i.geometry.hasAttribute("tangent")?e=Ws.mul(q(Aa,0)).xyz.toVarying("v_tangentView").normalize():e=V0,i.isFlatShading()!==!0&&(e=so(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),z0=R(([i,e],t)=>{let r=i.mul(ym.w).xyz;return t.subBuildFn==="NORMAL"&&t.isFlatShading()!==!0&&(r=r.toVarying(e)),r}).once(["NORMAL"]),W0=R(i=>{let e;return i.subBuildFn==="VERTEX"||i.geometry.hasAttribute("tangent")?e=z0(ge.cross(bm),"v_bitangentView").normalize():e=$0,i.isFlatShading()!==!0&&(e=so(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),Ti=rt(bm,W0,ge).toVar("TBNViewMatrix"),j0=R(()=>{let i=Rn.cross(Ee);return i=i.cross(Rn).normalize(),i=xe(i,ge,ws.mul(Or.oneMinus()).oneMinus().pow2().pow2()).normalize(),i}).once()(),H0=i=>H(i).mul(.5).add(.5),Th=i=>C(i,ds(td(w(1).sub(Vs(i,i)))));class q0 extends Xe{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=nu,this.unpackNormalMode=iu}setup(e){const{normalMapType:t,scaleNode:r,unpackNormalMode:s}=this;let n=this.node.mul(2).sub(1);if(t===nu?s===Hp?n=Th(n.xy):s===d_?n=Th(n.yw):s!==iu&&O(`THREE.NodeMaterial: Unexpected unpack normal mode: ${s}`):s!==iu&&O(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${s}'`),r!==null){let a=r;e.isFlatShading()===!0&&(a=so(a)),n=C(n.xy.mul(a),n.z)}let o=null;return t===h_?o=lm(n):t===nu?o=Ti.mul(n).normalize():(O(`NodeMaterial: Unsupported normal map type: ${t}`),o=ge),o}}const vh=Pe(q0).setParameterLength(1,2),X0=R(({textureNode:i,bumpScale:e})=>{const t=s=>i.isolate().context({getUV:n=>s(n.uvNode||Xs()),forceUVContext:!0}),r=w(t(s=>s));return ee(w(t(s=>s.add(s.dFdx()))).sub(r),w(t(s=>s.add(s.dFdy()))).sub(r)).mul(e)}),K0=R(i=>{const{surf_pos:e,surf_norm:t,dHdxy:r}=i,s=e.dFdx().normalize(),n=e.dFdy().normalize(),o=t,a=n.cross(o),u=o.cross(s),l=s.dot(a).mul(om),c=l.sign().mul(r.x.mul(a).add(r.y.mul(u)));return l.abs().mul(t).sub(c).normalize()});class Y0 extends Xe{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(e){if(e.material.wireframe===!0)return ge;const t=this.scaleNode!==null?this.scaleNode:1,r=X0({textureNode:this.textureNode,bumpScale:t});return K0({surf_pos:je,surf_norm:ge,dHdxy:r})}}const Q0=Pe(Y0).setParameterLength(1,2),Sh=new Map;class M extends J{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=Sh.get(e);return r===void 0&&(r=ns(e,t),Sh.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===M.COLOR){const n=t.color!==void 0?this.getColor(r):C();t.map&&t.map.isTexture===!0?s=n.mul(this.getTexture("map")):s=n}else if(r===M.OPACITY){const n=this.getFloat(r);t.alphaMap&&t.alphaMap.isTexture===!0?s=n.mul(this.getTexture("alpha")):s=n}else if(r===M.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?s=this.getTexture("specular").r:s=w(1);else if(r===M.SPECULAR_INTENSITY){const n=this.getFloat(r);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?s=n.mul(this.getTexture(r).a):s=n}else if(r===M.SPECULAR_COLOR){const n=this.getColor(r);t.specularColorMap&&t.specularColorMap.isTexture===!0?s=n.mul(this.getTexture(r).rgb):s=n}else if(r===M.ROUGHNESS){const n=this.getFloat(r);t.roughnessMap&&t.roughnessMap.isTexture===!0?s=n.mul(this.getTexture(r).g):s=n}else if(r===M.METALNESS){const n=this.getFloat(r);t.metalnessMap&&t.metalnessMap.isTexture===!0?s=n.mul(this.getTexture(r).b):s=n}else if(r===M.EMISSIVE){const n=this.getFloat("emissiveIntensity"),o=this.getColor(r).mul(n);t.emissiveMap&&t.emissiveMap.isTexture===!0?s=o.mul(this.getTexture(r)):s=o}else if(r===M.NORMAL)t.normalMap?(s=vh(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType,(t.normalMap.format==tr||t.normalMap.format==ba||t.normalMap.format==ya)&&(s.unpackNormalMode=Hp)):t.bumpMap?s=Q0(this.getTexture("bump").r,this.getFloat("bumpScale")):s=ge;else if(r===M.CLEARCOAT){const n=this.getFloat(r);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?s=n.mul(this.getTexture(r).r):s=n}else if(r===M.CLEARCOAT_ROUGHNESS){const n=this.getFloat(r);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?s=n.mul(this.getTexture(r).r):s=n}else if(r===M.CLEARCOAT_NORMAL)t.clearcoatNormalMap?s=vh(this.getTexture(r),this.getCache(r+"Scale","vec2")):s=ge;else if(r===M.SHEEN){const n=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?s=n.mul(this.getTexture("sheenColor").rgb):s=n}else if(r===M.SHEEN_ROUGHNESS){const n=this.getFloat(r);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?s=n.mul(this.getTexture(r).a):s=n,s=s.clamp(1e-4,1)}else if(r===M.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const n=this.getTexture(r);s=Yc(oi.x,oi.y,oi.y.negate(),oi.x).mul(n.rg.mul(2).sub(ee(1)).normalize().mul(n.b))}else s=oi;else if(r===M.IRIDESCENCE_THICKNESS){const n=Me("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const o=Me("0","float",t.iridescenceThicknessRange);s=n.sub(o).mul(this.getTexture(r).g).add(o)}else s=n}else if(r===M.TRANSMISSION){const n=this.getFloat(r);t.transmissionMap?s=n.mul(this.getTexture(r).r):s=n}else if(r===M.THICKNESS){const n=this.getFloat(r);t.thicknessMap?s=n.mul(this.getTexture(r).g):s=n}else if(r===M.IOR)s=this.getFloat(r);else if(r===M.LIGHT_MAP)t.lightMap?s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity")):s=C(0);else if(r===M.AO)t.aoMap?s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1):s=w(1);else if(r===M.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):w(0);else{const n=this.getNodeType(e);s=this.getCache(r,n)}return s}}M.ALPHA_TEST="alphaTest";M.COLOR="color";M.OPACITY="opacity";M.SHININESS="shininess";M.SPECULAR="specular";M.SPECULAR_STRENGTH="specularStrength";M.SPECULAR_INTENSITY="specularIntensity";M.SPECULAR_COLOR="specularColor";M.REFLECTIVITY="reflectivity";M.ROUGHNESS="roughness";M.METALNESS="metalness";M.NORMAL="normal";M.CLEARCOAT="clearcoat";M.CLEARCOAT_ROUGHNESS="clearcoatRoughness";M.CLEARCOAT_NORMAL="clearcoatNormal";M.EMISSIVE="emissive";M.ROTATION="rotation";M.SHEEN="sheen";M.SHEEN_ROUGHNESS="sheenRoughness";M.ANISOTROPY="anisotropy";M.IRIDESCENCE="iridescence";M.IRIDESCENCE_IOR="iridescenceIOR";M.IRIDESCENCE_THICKNESS="iridescenceThickness";M.IOR="ior";M.TRANSMISSION="transmission";M.THICKNESS="thickness";M.ATTENUATION_DISTANCE="attenuationDistance";M.ATTENUATION_COLOR="attenuationColor";M.LINE_SCALE="scale";M.LINE_DASH_SIZE="dashSize";M.LINE_GAP_SIZE="gapSize";M.LINE_WIDTH="linewidth";M.LINE_DASH_OFFSET="dashOffset";M.POINT_SIZE="size";M.DISPERSION="dispersion";M.LIGHT_MAP="light";M.AO="ao";const Z0=k(M,M.ALPHA_TEST),J0=k(M,M.COLOR),eS=k(M,M.SHININESS),tS=k(M,M.EMISSIVE),_m=k(M,M.OPACITY),rS=k(M,M.SPECULAR),Nh=k(M,M.SPECULAR_INTENSITY),sS=k(M,M.SPECULAR_COLOR),ca=k(M,M.SPECULAR_STRENGTH),Mu=k(M,M.REFLECTIVITY),nS=k(M,M.ROUGHNESS),iS=k(M,M.METALNESS),oS=k(M,M.NORMAL),aS=k(M,M.CLEARCOAT),uS=k(M,M.CLEARCOAT_ROUGHNESS),lS=k(M,M.CLEARCOAT_NORMAL),cS=k(M,M.ROTATION),dS=k(M,M.SHEEN),hS=k(M,M.SHEEN_ROUGHNESS),fS=k(M,M.ANISOTROPY),pS=k(M,M.IRIDESCENCE),gS=k(M,M.IRIDESCENCE_IOR),mS=k(M,M.IRIDESCENCE_THICKNESS),yS=k(M,M.TRANSMISSION),bS=k(M,M.THICKNESS),_S=k(M,M.IOR),xS=k(M,M.ATTENUATION_DISTANCE),TS=k(M,M.ATTENUATION_COLOR),xm=k(M,M.LINE_SCALE),Tm=k(M,M.LINE_DASH_SIZE),vm=k(M,M.LINE_GAP_SIZE),lc=k(M,M.LINE_WIDTH),Sm=k(M,M.LINE_DASH_OFFSET),vS=k(M,M.POINT_SIZE),SS=k(M,M.DISPERSION),Nm=k(M,M.LIGHT_MAP),NS=k(M,M.AO),oi=K(new ce).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),wS=R(i=>i.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class ct extends J{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===ct.OBJECT?this.updateType=re.OBJECT:e===ct.MATERIAL?this.updateType=re.RENDER:e===ct.FRAME?this.updateType=re.FRAME:e===ct.BEFORE_OBJECT?this.updateBeforeType=re.OBJECT:e===ct.BEFORE_MATERIAL?this.updateBeforeType=re.RENDER:e===ct.BEFORE_FRAME&&(this.updateBeforeType=re.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}ct.OBJECT="object";ct.MATERIAL="material";ct.FRAME="frame";ct.BEFORE_OBJECT="beforeObject";ct.BEFORE_MATERIAL="beforeMaterial";ct.BEFORE_FRAME="beforeFrame";const wm=(i,e)=>new ct(i,e).toStack(),dd=i=>wm(ct.OBJECT,i),RS=i=>wm(ct.FRAME,i);class ES extends zn{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.isContextAssign();if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?r=e.generatePBO(this):r=this.node.build(e):r=super.generate(e),s!==!0){const n=this.getNodeType(e);r=e.format(r,n,t)}return r}}const AS=Pe(ES).setParameterLength(2);class CS extends ad{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,n=null;t&&t.isStructTypeNode?(s="struct",n=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=pg(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=n,this.access=zt.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let r=e.globalCache.getData(this.value);r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return AS(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(zt.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Xg(this.value),this._varying=qs(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const Rm=(i,e=null,t=0)=>new CS(i,e,t),cc=new WeakMap,wh=new WeakMap,dc=new WeakMap;function Em(i,e){let t;const r=Math.max(e.count,1);if(e.isStorageInstancedBufferAttribute===!0)t=Rm(e,"mat4",r).element(Un);else if(r*16*4<=i.getUniformBufferLimit())t=ud(e.array,"mat4",r).element(Un);else{let o=cc.get(e);o||(o=new o_(e.array,16,1),cc.set(e,o));const a=e.usage===Ia?Yg:Kg,u=[a(o,"vec4",16,0),a(o,"vec4",16,4),a(o,"vec4",16,8),a(o,"vec4",16,12)];t=Us(...u)}return t}function MS(i,e,t){let r=dc.get(i);if(r===void 0){const s=e.clone();r={previousInstanceMatrix:s,node:Em(t,s)},dc.set(i,r)}return r.node}const Am=Wn("vec3","vInstanceColor"),BS=R(([i,e=null],t)=>{const r=i.isStorageInstancedBufferAttribute===!0,s=e&&e.isStorageInstancedBufferAttribute===!0,n=Em(t,i);let o=null;r||Math.max(i.count,1)*16*4>t.getUniformBufferLimit()&&(o=cc.get(i));let a=null,u=null;if(e)if(s)a=Rm(e,"vec3",Math.max(e.count,1)).element(Un);else{let c=wh.get(e);c||(c=new r_(e.array,3),wh.set(e,c)),u=c;const d=e.usage===Ia?Yg:Kg;a=C(d(c,"vec3",3,0))}(o!==null||u!==null)&&RS(()=>{o!==null&&(o.clearUpdateRanges(),o.updateRanges.push(...i.updateRanges),i.version!==o.version&&(o.version=i.version)),e&&u!==null&&(u.clearUpdateRanges(),u.updateRanges.push(...e.updateRanges),e.version!==u.version&&(u.version=e.version))});const l=n.mul(Qe).xyz;if(Qe.assign(l),t.needsPreviousData()){const c=t.object;dd(({object:h})=>{dc.get(h).previousInstanceMatrix.array.set(i.array)});const d=MS(c,i,t);Ea.assign(d.mul(Ea).xyz)}if(t.hasGeometryAttribute("normal")){const c=um(Nr,n);Nr.assign(c)}a!==null&&Am.assign(a)},"void"),PS=R(([i])=>{const{instanceMatrix:e,instanceColor:t}=i;BS(e,t)},"void"),DS=R(([i,e])=>{const t=Ue(Gi(Jt(i),0).x).toConst(),r=Ue(e),s=r.mod(t).toConst(),n=r.div(t).toConst();return Jt(i,Nt(s,n))}),FS=R(([i,e])=>{const t=Ue(Gi(Jt(i),0).x).toConst(),r=Ue(e).mod(t).toConst(),s=Ue(e).div(t).toConst();return Jt(i,Nt(r,s)).x}),Cm=Wn("vec4","vBatchColor"),LS=R(([i],e)=>{const t=e.getDrawIndex()===null?Un:Kv,r=FS(i._indirectTexture,Ue(t)),s=i._matricesTexture,n=Ue(Gi(Jt(s),0).x).toConst(),o=w(r).mul(4).toInt().toConst(),a=o.mod(n).toConst(),u=o.div(n).toConst(),l=Us(Jt(s,Nt(a,u)),Jt(s,Nt(a.add(1),u)),Jt(s,Nt(a.add(2),u)),Jt(s,Nt(a.add(3),u))),c=i._colorsTexture;if(c!==null){const p=DS(c,r);Cm.assign(p)}const d=rt(l);Qe.assign(l.mul(Qe));const h=Nr.div(C(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),f=d.mul(h).xyz;Nr.assign(f),e.hasGeometryAttribute("tangent")&&Aa.mulAssign(d)},"void"),Rh=new WeakMap,hc=new WeakMap;function Mm(i,e,t,r,s,n){const o=i.element(s.x),a=i.element(s.y),u=i.element(s.z),l=i.element(s.w),c=t.mul(e),d=Rt(o.mul(n.x).mul(c),a.mul(n.y).mul(c),u.mul(n.z).mul(c),l.mul(n.w).mul(c));return r.mul(d).xyz}function US(i,e,t,r,s,n,o){const a=i.element(n.x),u=i.element(n.y),l=i.element(n.z),c=i.element(n.w);let d=Rt(o.x.mul(a),o.y.mul(u),o.z.mul(l),o.w.mul(c));d=s.mul(d).mul(r);const h=d.transformDirection(e).xyz,f=d.transformDirection(t).xyz;return{skinNormal:h,skinTangent:f}}function OS(i,e,t,r,s){const n=i.skeleton;let o=hc.get(n);if(o===void 0){n.update();const a=new Float32Array(n.boneMatrices);o={previousBoneMatrices:a,node:ud(a,"mat4",n.bones.length)},hc.set(n,o)}return Mm(o.node,Ea,e,t,r,s)}const IS=R(([i],e)=>{const t=Wt("skinIndex","uvec4"),r=Wt("skinWeight","vec4"),s=Me("bindMatrix","mat4"),n=Me("bindMatrixInverse","mat4"),o=O0("skeleton.boneMatrices","mat4",i.skeleton.bones.length);if(dd(({object:u,frameId:l})=>{const c=u.skeleton;if(Rh.get(c)!==l){Rh.set(c,l);const d=hc.get(c);d!==void 0&&d.previousBoneMatrices.set(c.boneMatrices),c.update()}}),e.needsPreviousData()){const u=OS(i,s,n,t,r);Ea.assign(u)}const a=Mm(o,Qe,s,n,t,r);if(Qe.assign(a),e.hasGeometryAttribute("normal")){const{skinNormal:u,skinTangent:l}=US(o,Nr,Aa,s,n,t,r);Nr.assign(u),e.hasGeometryAttribute("tangent")&&Aa.assign(l)}},"void");class kS extends J{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const r={};for(let a=0,u=this.params.length-1;aNumber(d)?p=">=":p="<"));let m;if(l)m=`while ( ${d} )`;else{const y={start:c,end:d},x=y.start,_=y.end;let N;const A=()=>p.includes("<")?"+=":"-=";if(g!=null)switch(typeof g){case"function":N=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":N=h+" "+A()+" "+e.generateConst(f,g);break;case"string":N=h+" "+g;break;default:g.isNode?N=h+" "+A()+" "+g.build(e):(O("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),N="break /* invalid update */")}else f==="int"||f==="uint"?g=p.includes("<")?"++":"--":g=A()+" 1.",N=h+" "+g;const v=e.getVar(f,h)+" = "+x,S=h+" "+p+" "+_;m=`for ( ${v}; ${S}; ${N} )`}e.addFlowCode((o===0?` +`:"")+e.tab+m+` { + +`).addFlowTab()}const n=s.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(` +`+e.tab+n);for(let o=0,a=this.params.length-1;onew kS(wn(i,"int")).toStack(),GS=()=>gr("break").toStack(),Bu=new WeakMap,Ct=new He,Eh=new WeakMap,Ah=R(({bufferMap:i,influence:e,stride:t,width:r,depth:s,offset:n})=>{const o=Ue(Xv).mul(t).add(n),a=o.div(r),u=o.sub(a.mul(r));return Jt(i,Nt(u,a)).depth(s).xyz.mul(e)});function VS(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,r=i.morphAttributes.color!==void 0,s=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,n=s!==void 0?s.length:0;let o=Bu.get(i);if(o===void 0||o.count!==n){let y=function(){g.dispose(),Bu.delete(i),i.removeEventListener("dispose",y)};o!==void 0&&o.texture.dispose();const a=i.morphAttributes.position||[],u=i.morphAttributes.normal||[],l=i.morphAttributes.color||[];let c=0;e===!0&&(c=1),t===!0&&(c=2),r===!0&&(c=3);let d=i.attributes.position.count*c,h=1;const f=4096;d>f&&(h=Math.ceil(d/f),d=f);const p=new Float32Array(d*h*4*n),g=new t_(p,d,h,n);g.type=dt,g.needsUpdate=!0;const m=c*4;for(let x=0;x{const{geometry:e}=i,t=e.morphAttributes.position!==void 0,r=e.hasAttribute("normal")&&e.morphAttributes.normal!==void 0,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,n=s!==void 0?s.length:0;if(n===0)return;let o=Eh.get(i);(o===void 0||o.count!==n)&&(o={base:K(1),influences:i.morphTargetInfluences?Tt(i.morphTargetInfluences,"float"):null,count:n},Eh.set(i,o));const{base:a,influences:u}=o,{texture:l,stride:c,size:d}=VS(e);t===!0&&Qe.mulAssign(a),r===!0&&Nr.mulAssign(a);const h=Ue(d.width);$t(n,({i:f})=>{const p=w(0).toVar();i.count>1&&i.morphTexture!==null&&i.morphTexture!==void 0?p.assign(Jt(i.morphTexture,Nt(Ue(f).add(1),Ue(Un))).r):p.assign(u.element(f).toVar()),me(p.notEqual(0),()=>{t===!0&&Qe.addAssign(Ah({bufferMap:l,influence:p,stride:c,width:h,depth:f,offset:Ue(0)})),r===!0&&Nr.addAssign(Ah({bufferMap:l,influence:p,stride:c,width:h,depth:f,offset:Ue(1)}))})}),dd(({object:f})=>{const{base:p,influences:g}=o;f.geometry.morphTargetsRelative?p.value=1:p.value=1-f.morphTargetInfluences.reduce((m,y)=>m+y,0),g&&(g.array=f.morphTargetInfluences,g.update())})},"void");class Xn extends J{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class zS extends Xn{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class WS extends rd{static get type(){return"LightingContextNode"}constructor(e,t=null,r=[],s=null,n=null){super(e),this.lightingModel=t,this.materialLightings=r,this.backdropNode=s,this.backdropAlphaNode=n,this._value=null}getContext(){const{materialLightings:e,backdropNode:t,backdropAlphaNode:r}=this,s=C().toVar("directDiffuse"),n=C().toVar("directSpecular"),o=C().toVar("indirectDiffuse"),a=C().toVar("indirectSpecular"),u={directDiffuse:s,directSpecular:n,indirectDiffuse:o,indirectSpecular:a};return{radiance:C().toVar("radiance"),irradiance:C().toVar("irradiance"),iblIrradiance:C().toVar("iblIrradiance"),ambientOcclusion:w(1).toVar("ambientOcclusion"),reflectedLight:u,materialLightings:e,backdrop:t,backdropAlpha:r}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const jS=Pe(WS);class HS extends Xn{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const Ts=new ce;class Bm extends to{static get type(){return"ViewportTextureNode"}constructor(e=as,t=null,r=null){let s=null;r===null?(s=new pp,s.minFilter=ls,r=s):s=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=re.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),e===null)return t;if(r.has(e)===!1){const s=t.clone();r.set(e,s)}return r.get(e)}updateReference(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),n=r||s;return this.value=this.getTextureForReference(n),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget(),s=t.getCanvasTarget(),n=r||s;n===null?t.getDrawingBufferSize(Ts):n.getDrawingBufferSize?n.getDrawingBufferSize(Ts):Ts.set(n.width,n.height);const o=this.getTextureForReference(n);(o.image.width!==Ts.width||o.image.height!==Ts.height)&&(o.image.width=Ts.width,o.image.height=Ts.height,o.needsUpdate=!0);const a=o.generateMipmaps;o.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(o),o.generateMipmaps=a}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const Pm=Pe(Bm,null,null,{generateMipmaps:!0}).setParameterLength(0,3),qS=Pm(),XS=(i=as,e=null)=>qS.sample(i,e);let Pu=null;class KS extends Bm{static get type(){return"ViewportDepthTextureNode"}constructor(e=as,t=null,r=null){r===null&&(Pu===null&&(Pu=new xr),r=Pu),super(e,t,r)}}const YS=Pe(KS).setParameterLength(0,3);class wt extends J{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===wt.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===wt.DEPTH_BASE)r!==null&&(s=Fm().assign(r));else if(t===wt.DEPTH)e.isPerspectiveCamera?s=Dm(je.z,Cs,Ms):s=Cn(je.z,Cs,Ms);else if(t===wt.LINEAR_DEPTH)if(r!==null)if(e.isPerspectiveCamera){const n=hd(r,Cs,Ms);s=Cn(n,Cs,Ms)}else s=r;else s=Cn(je.z,Cs,Ms);return s}}wt.DEPTH_BASE="depthBase";wt.DEPTH="depth";wt.LINEAR_DEPTH="linearDepth";const Cn=(i,e,t)=>i.add(e).div(e.sub(t)),QS=R(([i,e,t],r)=>r.renderer.reversedDepthBuffer===!0?t.sub(e).mul(i).sub(t):e.sub(t).mul(i).sub(e)),Dm=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),ZS=(i,e,t)=>e.mul(i.add(t)).div(i.mul(e.sub(t))),hd=R(([i,e,t],r)=>r.renderer.reversedDepthBuffer===!0?e.mul(t).div(e.sub(t).mul(i).sub(e)):e.mul(t).div(t.sub(e).mul(i).sub(t))),fd=(i,e,t)=>{e=e.max(1e-6).toVar();const r=jr(i.negate().div(e)),s=jr(t.div(e));return r.div(s)},Fm=Pe(wt,wt.DEPTH_BASE),Lm=k(wt,wt.DEPTH),JS=Pe(wt,wt.LINEAR_DEPTH).setParameterLength(0,1);YS();Lm.assign=i=>Fm(i);class qt extends J{static get type(){return"ClippingNode"}constructor(e=qt.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.hardwareClipping,this.scope===qt.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===qt.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return R(()=>{const r=w().toVar("distanceToPlane"),s=w().toVar("distanceToGradient"),n=w(1).toVar("clipOpacity"),o=t.length;if(this.hardwareClipping===!1&&o>0){const u=Tt(t).setGroup(Z);$t(o,({i:l})=>{const c=u.element(l);r.assign(je.dot(c.xyz).negate().add(c.w)),s.assign(r.fwidth().div(2)),n.mulAssign(nr(s.negate(),s,r))})}const a=e.length;if(a>0){const u=Tt(e).setGroup(Z),l=w(1).toVar("intersectionClipOpacity");$t(a,({i:c})=>{const d=u.element(c);r.assign(je.dot(d.xyz).negate().add(d.w)),s.assign(r.fwidth().div(2)),l.mulAssign(nr(s.negate(),s,r).oneMinus())}),n.mulAssign(l.oneMinus())}Se.a.mulAssign(n),Se.a.equal(0).discard()})()}setupDefault(e,t){return R(()=>{const r=t.length;if(this.hardwareClipping===!1&&r>0){const n=Tt(t).setGroup(Z);$t(r,({i:o})=>{const a=n.element(o);je.dot(a.xyz).greaterThan(a.w).discard()})}const s=e.length;if(s>0){const n=Tt(e).setGroup(Z),o=Ha(!0).toVar("clipped");$t(s,({i:a})=>{const u=n.element(a);o.assign(je.dot(u.xyz).greaterThan(u.w).and(o))}),o.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),R(()=>{const s=Tt(e).setGroup(Z),n=Ks(t.getClipDistance());$t(r,({i:o})=>{const a=s.element(o),u=je.dot(a.xyz).sub(a.w).negate();n.element(o).assign(u)})})()}}qt.ALPHA_TO_COVERAGE="alphaToCoverage";qt.DEFAULT="default";qt.HARDWARE="hardware";const eN=()=>new qt,tN=()=>new qt(qt.ALPHA_TO_COVERAGE),rN=()=>new qt(qt.HARDWARE),sN=.05,Ch=R(([i])=>Sr(ae(1e4,Dt(ae(17,i.x).add(ae(.1,i.y)))).mul(Rt(.1,Ft(Dt(ae(13,i.y).add(i.x))))))),Mh=R(([i])=>Ch(ee(Ch(i.xy),i.z))),nN=R(([i])=>{const e=st(Hr(Ig(i.xyz)),Hr(kg(i.xyz))),t=w(1).div(w(sN).mul(e)).toVar("pixScale"),r=ee(Ii(Os(jr(t))),Ii(ed(jr(t)))),s=ee(Mh(Os(r.x.mul(i.xyz))),Mh(Os(r.y.mul(i.xyz)))),n=Sr(jr(t)),o=Rt(ae(n.oneMinus(),s.x),ae(n,s.y)),a=Ln(n,n.oneMinus()),u=C(o.mul(o).div(ae(2,a).mul(xt(1,a))),o.sub(ae(.5,a)).div(xt(1,a)),xt(1,xt(1,o).mul(xt(1,o)).div(ae(2,a).mul(xt(1,a))))),l=o.lessThan(a.oneMinus()).select(o.lessThan(a).select(u.x,u.y),u.z);return hs(l,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class iN extends rm{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),r=e.hasGeometryAttribute(t);let s;return r===!0?s=super.generate(e):s=e.generateConst(this.nodeType,new He(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const oN=(i=0)=>new iN(i);class qe extends Rd{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const r=this[t];r&&r.isNode===!0&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(Vn(t.slice(0,-4)),r.getCacheKey());return this.type+Ji(e)}build(e){this.setup(e)}setupObserver(e){return new Lx(e)}setup(e){e.context.setupNormal=()=>An(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=this.setupVertex(e),n=An(this.vertexNode||s,"VERTEX");e.context.clipSpace=n,e.stack.outputNode=n,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let o;const a=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(r!==null?r.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);const u=this.setupLighting(e);a!==null&&e.stack.addToStack(a);const l=q(u,Se.a).max(0);o=this.setupOutput(e,l),Ci.assign(o);const c=this.outputNode!==null;if(c&&(o=this.outputNode),e.context.getOutput&&(o=e.context.getOutput(o,e)),r!==null){const d=t.getMRT(),h=this.mrtNode;d!==null?(c&&Ci.assign(o),o=d,h!==null&&(o=d.merge(h))):h!==null&&(o=h)}}else{let u=this.fragmentNode;u.isOutputStructNode!==!0&&(u=u.convert(e.getOutputType())),o=this.setupOutput(e,u)}e.stack.outputNode=o,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const n=e.renderer.currentSamples;this.alphaToCoverage&&n>1?s=tN():e.stack.addToStack(eN())}return s}setupHardwareClipping(e){if(e.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(rN()),e.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(s===null){const n=t.getMRT();n&&n.has("depth")?s=n.get("depth"):t.logarithmicDepthBuffer===!0&&(r.isPerspectiveCamera?s=fd(je.z,Cs,Ms):s=Cn(je.z,Cs,Ms))}s!==null&&Lm.assign(s).toStack()}setupPositionView(){return Ws.mul(Qe).xyz}setupModelViewProjection(){return rr.mul(je)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),wS}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&$S(t),t.isSkinnedMesh===!0&&IS(t),this.displacementMap){const s=ns("displacementMap","texture"),n=ns("displacementScale","float"),o=ns("displacementBias","float");Qe.addAssign(Nr.normalize().mul(s.x.mul(n).add(o)))}return t.isBatchedMesh&&LS(t),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&PS(t),this.positionNode!==null&&Qe.assign(An(this.positionNode,"POSITION","vec3")),Qe}setupDiffuseColor(e){const{object:t,geometry:r}=e;this.maskNode!==null&&Ha(this.maskNode).not().discard();let s=this.colorNode?q(this.colorNode):J0;this.vertexColors===!0&&r.hasAttribute("color")&&(s=s.mul(oN())),t.instanceColor&&(s=Am.mul(s)),t.isBatchedMesh&&t._colorsTexture&&(s=Cm.mul(s)),Se.assign(s);const n=this.opacityNode?w(this.opacityNode):_m;Se.a.assign(Se.a.mul(n));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?w(this.alphaTestNode):Z0,this.alphaToCoverage===!0?(Se.a=nr(o,o.add(Gg(Se.a)),Se.a),Se.a.lessThanEqual(0).discard()):Se.a.lessThanEqual(o).discard()),this.alphaHash===!0&&Se.a.lessThan(nN(Qe)).discard(),e.isOpaque()&&Se.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?C(0):Se.rgb}setupNormal(){return this.normalNode?C(this.normalNode):oS}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ns("envMap","cubeTexture"):ns("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new HS(Nm)),t}setupMaterialLightings(e){const t=[];if(e.renderer.lighting.enabled===!1)return t;const r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);return s&&s.isLightingNode&&t.push(s),e.context.ambientOcclusion&&t.push(new zS(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;t===null&&e.material.aoMap&&(t=NS),e.context.getAO&&(t=e.context.getAO(t,e)),t!==null&&(fh.assign(t),e.context.ambientOcclusion=fh)}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:n}=this,o=this.lights===!0||this.lightsNode!==null,a=this.lights===!0?this.setupMaterialLightings(e):[],u=o?this.lightsNode||e.lightsNode:null;let l=this.setupOutgoingLight(e);if(u&&(a.length>0||u.getScope().hasLights)){const c=this.setupLightingModel(e)||null;l=jS(u,c,a,r,s)}else r!==null&&(l=C(s!==null?xe(l,r,s):r));return(n&&n.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(hh.assign(C(n||tS)),l=l.add(hh)),l}setupFog(e,t){const r=e.fogNode;return r&&(Ci.assign(t),t=q(r.toVar())),t}setupPremultipliedAlpha(e,t){return Jg(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const r in e){const s=e[r];this[r]===void 0&&(this[r]=s,s&&s.clone&&(this[r]=s.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const r in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,r)===void 0&&t[r].get!==void 0&&Object.defineProperty(this.constructor.prototype,r,t[r])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const r=Rd.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:n,childNode:o}of this._getNodeChildren())r.inputNodes[n]=o.toJSON(e).uuid;function s(n){const o=[];for(const a in n){const u=n[a];delete u.metadata,o.push(u)}return o}if(t){const n=s(e.textures),o=s(e.images),a=s(e.nodes);n.length>0&&(r.textures=n),o.length>0&&(r.images=o),a.length>0&&(r.nodes=a)}return r}copy(e){const t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(const r in t)if(t[r].set!==void 0&&e[r]!==void 0){const s=e[r];this[r]&&this[r].copy!==void 0?this[r].copy(s):this[r]=s}for(const r in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(r)&&this[r]!==void 0&&e[r]!==void 0){const s=e[r];this[r]&&this[r].copy!==void 0?this[r].copy(s):this[r]=s}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(r=>r.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}}const aN=new op;class uN extends qe{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(aN),this.setValues(e)}}const lN=new Rb;class cN extends qe{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(lN),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?w(this.offsetNode):Sm,t=this.dashScaleNode?w(this.dashScaleNode):xm,r=this.dashSizeNode?w(this.dashSizeNode):Tm,s=this.gapSizeNode?w(this.gapSizeNode):vm;En.assign(r),Ra.assign(s);const n=qs(Wt("lineDistance").mul(t));(e?n.add(e):n).mod(En.add(Ra)).greaterThan(En).discard()}}const da=Wn("vec3","worldStart"),fc=Wn("vec3","worldEnd"),Um=Wn("float","lineDistance"),Rs=Wn("vec4","worldPos"),Bh=R(({start:i,end:e})=>{const t=rr.element(2).element(2),r=rr.element(3).element(2);return t.greaterThan(0).select(r.negate().div(t.add(1)),r.mul(-.5).div(t)).sub(i.z).div(e.z.sub(i.z))},{start:"vec4",end:"vec4",return:"float"}),dN=R(({p1:i,p2:e,p3:t,p4:r})=>{const s=i.sub(t),n=r.sub(t),o=e.sub(i),a=s.dot(n),u=n.dot(o),l=s.dot(o),c=n.dot(n),h=o.dot(o).mul(c).sub(u.mul(u)),p=a.mul(u).sub(l.mul(c)).div(h).clamp(),g=a.add(u.mul(p)).div(c).clamp();return ee(p,g)},{p1:"vec3",p2:"vec3",p3:"vec3",p4:"vec3",return:"vec2"});R(({material:i})=>{const e=i._useDash,t=i._useWorldUnits,r=Wt("instanceStart"),s=Wt("instanceEnd"),n=q(Ws.mul(q(r,1))).toVar("start"),o=q(Ws.mul(q(s,1))).toVar("end");let a,u;e&&(a=w(Wt("instanceDistanceStart")).toVar("distanceStart"),u=w(Wt("instanceDistanceEnd")).toVar("distanceEnd")),t&&(da.assign(n.xyz),fc.assign(o.xyz));const l=Bi.z.div(Bi.w),c=rr.element(2).element(3).equal(-1);if(me(c,()=>{me(n.z.lessThan(0).and(o.z.greaterThan(0)),()=>{const y=Bh({start:n,end:o});o.assign(q(xe(n.xyz,o.xyz,y),o.w)),e&&u.assign(xe(a,u,y))}).ElseIf(o.z.lessThan(0).and(n.z.greaterThanEqual(0)),()=>{const y=Bh({start:o,end:n});n.assign(q(xe(o.xyz,n.xyz,y),n.w)),e&&a.assign(xe(u,a,y))})}),e){const y=i.dashScaleNode?w(i.dashScaleNode):xm,x=i.offsetNode?w(i.offsetNode):Sm;let _=mt.y.lessThan(.5).select(y.mul(a),y.mul(u));_=_.add(x),Um.assign(_)}const d=rr.mul(n),h=rr.mul(o),f=d.xyz.div(d.w),p=h.xyz.div(h.w),g=p.xy.sub(f.xy).toVar();g.x.assign(g.x.mul(l)),g.assign(g.normalize());const m=q().toVar();if(t){const y=o.xyz.sub(n.xyz).normalize(),x=xe(n.xyz,o.xyz,.5).normalize(),_=y.cross(x).normalize(),N=y.cross(_);Rs.assign(mt.y.lessThan(.5).select(n,o));const A=lc.mul(.5);Rs.addAssign(q(mt.x.lessThan(0).select(_.mul(A),_.mul(A).negate()),0)),e||(Rs.addAssign(q(mt.y.lessThan(.5).select(y.mul(A).negate(),y.mul(A)),0)),Rs.addAssign(q(N.mul(A),0)),me(mt.y.greaterThan(1).or(mt.y.lessThan(0)),()=>{Rs.subAssign(q(N.mul(2).mul(A),0))})),m.assign(rr.mul(Rs));const v=C().toVar();v.assign(mt.y.lessThan(.5).select(f,p)),m.z.assign(v.z.mul(m.w))}else{const y=ee(g.y,g.x.negate()).toVar("offset");g.x.assign(g.x.div(l)),y.x.assign(y.x.div(l)),y.assign(mt.x.lessThan(0).select(y.negate(),y)),me(mt.y.lessThan(0),()=>{y.assign(y.sub(g))}).ElseIf(mt.y.greaterThan(1),()=>{y.assign(y.add(g))}),y.assign(y.mul(lc)),y.assign(y.div(Bi.w.div(nm))),m.assign(mt.y.lessThan(.5).select(d,h)),y.assign(y.mul(m.w)),m.assign(m.add(q(y,0,0)))}return m})();R(({material:i,renderer:e})=>{const t=i._useAlphaToCoverage,r=i._useDash,s=i._useWorldUnits,n=Xs();if(r){const a=i.dashSizeNode?w(i.dashSizeNode):Tm,u=i.gapSizeNode?w(i.gapSizeNode):vm;En.assign(a),Ra.assign(u),n.y.lessThan(-1).or(n.y.greaterThan(1)).discard(),Um.mod(En.add(Ra)).greaterThan(En).discard()}const o=w(1).toVar("alpha");if(s){const a=Rs.xyz.normalize().mul(1e5),u=fc.sub(da),l=dN({p1:da,p2:fc,p3:C(0,0,0),p4:a}),c=da.add(u.mul(l.x)),d=a.mul(l.y),p=c.sub(d).length().div(lc);if(!r)if(t&&e.currentSamples>0){const g=p.fwidth();o.assign(nr(g.negate().add(.5),g.add(.5),p).oneMinus())}else p.greaterThan(.5).discard()}else if(t&&e.currentSamples>0){const a=n.x,u=n.y.greaterThan(0).select(n.y.sub(1),n.y.add(1)),l=a.mul(a).add(u.mul(u)),c=w(l.fwidth()).toVar("dlen");me(n.y.abs().greaterThan(1),()=>{o.assign(nr(c.oneMinus(),c.add(1),l).oneMinus())})}else me(n.y.abs().greaterThan(1),()=>{const a=n.x,u=n.y.greaterThan(0).select(n.y.sub(1),n.y.add(1));a.mul(a).add(u.mul(u)).greaterThan(1).discard()});return o})();const hN=new Nb;class fN extends qe{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(hN),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?w(this.opacityNode):_m;Se.assign(id(q(H0(ge),e),Ec))}}const Om=R(([i=im])=>{const e=i.z.atan(i.x).mul(1/(Math.PI*2)).add(.5),t=i.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return ee(e,t)}),Ph=R(([i=Xs()])=>{const e=i.x.sub(.5).mul(Math.PI*2),t=i.y.sub(.5).mul(Math.PI),r=t.cos(),s=r.mul(e.cos()),n=t.sin(),o=r.mul(e.sin());return C(s,n,o)});class Im extends ps{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1},s=[r,r,r,r,r,r];this.texture=new $a(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,s=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new jp(5,5,5),o=Om(im),a=new qe;a.colorNode=Ne(t,o,0),a.side=ft,a.blending=Wr;const u=new sr(n,a),l=new Ac;l.add(u),t.minFilter===ls&&(t.minFilter=yt);const c=new s_(1,10,this),d=e.getMRT();return e.setMRT(null),c.update(e,l),e.setMRT(d),t.minFilter=r,t.generateMipmaps=s,u.geometry.dispose(),u.material.dispose(),this}clear(e,t=!0,r=!0,s=!0){const n=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,r,s);e.setRenderTarget(n)}}const Pi=new WeakMap;class pN extends Xe{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=vt(null);const t=new $a;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=re.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const n=s.isTextureNode?s.value:r[s.property];if(n&&n.isTexture){const o=n.mapping;if(o===Dc||o===Fc){if(Pi.has(n)){const a=Pi.get(n);Dh(a,n.mapping),this._cubeTexture=a}else{const a=n.image;if(gN(a)){const u=new Im(a.height);u.fromEquirectangularTexture(t,n),Dh(u.texture,n.mapping),this._cubeTexture=u.texture,Pi.set(n,u.texture),n.addEventListener("dispose",km)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function gN(i){return i==null?!1:i.height>0}function km(i){const e=i.target;e.removeEventListener("dispose",km);const t=Pi.get(e);t!==void 0&&(Pi.delete(e),t.dispose())}function Dh(i,e){e===Dc?i.mapping=Ta:e===Fc&&(i.mapping=va)}const Gm=Pe(pN).setParameterLength(1);class pd extends Xn{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Gm(this.envNode)}}class mN extends Xn{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=w(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Xa{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Vm extends Xa{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(q(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(q(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(Se.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,n=e.context.environment;if(n)switch(t.combine){case e_:s.rgb.assign(xe(s.rgb,s.rgb.mul(n.rgb),ca.mul(Mu)));break;case Jb:s.rgb.assign(xe(s.rgb,n.rgb,ca.mul(Mu)));break;case Zb:s.rgb.addAssign(n.rgb.mul(ca.mul(Mu)));break;default:z("BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const yN=new ss;class bN extends qe{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(yN),this.setValues(e)}setupNormal(){return so(Vi)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new pd(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new mN(Nm)),t}setupOutgoingLight(){return Se.rgb}setupLightingModel(){return new Vm}}const $i=R(({f0:i,f90:e,dotVH:t})=>{const r=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(r.oneMinus()).add(e.mul(r))}),In=R(i=>i.diffuseColor.mul(1/Math.PI)),_N=()=>w(.25),xN=R(({dotNH:i})=>sc.mul(w(.5)).add(1).mul(w(1/Math.PI)).mul(i.pow(sc))),TN=R(({lightDirection:i})=>{const e=i.add(Ee).normalize(),t=ge.dot(e).clamp(),r=Ee.dot(e).clamp(),s=$i({f0:Gs,f90:1,dotVH:r}),n=_N(),o=xN({dotNH:t});return s.mul(n).mul(o)});class $m extends Vm{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const n=ge.dot(e).clamp().mul(t);r.directDiffuse.addAssign(n.mul(In({diffuseColor:Se.rgb}))),this.specular===!0&&r.directSpecular.addAssign(n.mul(TN({lightDirection:e})).mul(ca))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(In({diffuseColor:Se}))),s.indirectDiffuse.mulAssign(t)}}const vN=new rp;class SN extends qe{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(vN),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new pd(t):null}setupLightingModel(){return new $m(!1)}}const NN=new xb;class wN extends qe{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(NN),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new pd(t):null}setupLightingModel(){return new $m}setupVariants(){const e=(this.shininessNode?w(this.shininessNode):eS).max(1e-4);sc.assign(e);const t=this.specularNode||rS;Gs.assign(t)}}const RN=R(i=>{if(i.geometry.hasAttribute("normal")===!1)return w(0);const e=Vi.dFdx().abs().max(Vi.dFdy().abs());return e.x.max(e.y).max(e.z)}),zm=R(i=>{const{roughness:e}=i,t=RN();let r=e.max(.0525);return r=r.add(t),r=r.min(1),r}),EN=R(({alpha:i,dotNL:e,dotNV:t})=>{const r=i.pow2(),s=e.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt()),n=t.mul(r.add(r.oneMinus().mul(e.pow2())).sqrt());return vr(.5,s.add(n).max(Jc))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),AN=R(({alphaT:i,alphaB:e,dotTV:t,dotBV:r,dotTL:s,dotBL:n,dotNV:o,dotNL:a})=>{const u=a.mul(C(i.mul(t),e.mul(r),o).length()),l=o.mul(C(i.mul(s),e.mul(n),a).length());return vr(.5,u.add(l).max(Jc))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),CN=R(({alpha:i,dotNH:e})=>{const t=i.pow2(),r=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),MN=w(1/Math.PI),BN=R(({alphaT:i,alphaB:e,dotNH:t,dotTH:r,dotBH:s})=>{const n=i.mul(e),o=C(e.mul(r),i.mul(s),n.mul(t)),a=o.dot(o),u=n.div(a);return MN.mul(n.mul(u.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),Wm=R(({lightDirection:i,f0:e,f90:t,roughness:r,f:s,normalView:n=ge,USE_IRIDESCENCE:o,USE_ANISOTROPY:a})=>{const u=r.pow2(),l=i.add(Ee).normalize(),c=n.dot(i).clamp(),d=n.dot(Ee).clamp(),h=n.dot(l).clamp(),f=Ee.dot(l).clamp();let p=$i({f0:e,f90:t,dotVH:f}),g,m;if(Zl(o)&&(p=Qc.mix(p,s)),Zl(a)){const y=oa.dot(i),x=oa.dot(Ee),_=oa.dot(l),N=Rn.dot(i),A=Rn.dot(Ee),v=Rn.dot(l);g=AN({alphaT:rc,alphaB:u,dotTV:x,dotBV:A,dotTL:y,dotBL:N,dotNV:d,dotNL:c}),m=BN({alphaT:rc,alphaB:u,dotNH:h,dotTH:_,dotBH:v})}else g=EN({alpha:u,dotNL:c,dotNV:d}),m=CN({alpha:u,dotNH:h});return p.mul(g).mul(m)}),PN=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let lr=null;const Ca=R(({roughness:i,dotNV:e})=>{lr===null&&(lr=new Vp(PN,16,16,tr,ht),lr.name="DFG_LUT",lr.minFilter=yt,lr.magFilter=yt,lr.wrapS=Oi,lr.wrapT=Oi,lr.generateMipmaps=!1,lr.needsUpdate=!0);const t=ee(i,e);return Ne(lr,t).rg}),DN=R(({lightDirection:i,f0:e,f90:t,roughness:r,f:s,USE_IRIDESCENCE:n,USE_ANISOTROPY:o})=>{const a=Wm({lightDirection:i,f0:e,f90:t,roughness:r,f:s,USE_IRIDESCENCE:n,USE_ANISOTROPY:o}),u=ge.dot(i).clamp(),l=ge.dot(Ee).clamp(),c=Ca({roughness:r,dotNV:l}),d=Ca({roughness:r,dotNV:u}),h=e.mul(c.x).add(t.mul(c.y)),f=e.mul(d.x).add(t.mul(d.y)),p=c.x.add(c.y),g=d.x.add(d.y),m=w(1).sub(p),y=w(1).sub(g),x=e.add(e.oneMinus().mul(.047619)),_=h.mul(f).mul(x).div(w(1).sub(m.mul(y).mul(x).mul(x)).add(Jc)),N=m.mul(y),A=_.mul(N);return a.add(A)}),jm=R(i=>{const{dotNV:e,specularColor:t,specularF90:r,roughness:s}=i,n=Ca({dotNV:e,roughness:s});return t.mul(n.x).add(r.mul(n.y))}),Fh=R(({f:i,f90:e,dotVH:t})=>{const r=t.oneMinus().saturate(),s=r.mul(r),n=r.mul(s,s).clamp(0,.9999);return i.sub(C(e).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),FN=R(({roughness:i,dotNH:e})=>{const t=i.pow2(),r=w(1).div(t),n=e.pow2().oneMinus().max(.0078125);return w(2).add(r).mul(n.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),LN=R(({dotNV:i,dotNL:e})=>w(1).div(w(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),UN=R(({lightDirection:i})=>{const e=i.add(Ee).normalize(),t=ge.dot(i).clamp(),r=ge.dot(Ee).clamp(),s=ge.dot(e).clamp(),n=FN({roughness:As,dotNH:s}),o=LN({dotNV:r,dotNL:t});return Gt.mul(n).mul(o)}),Lh=R(({N:i,V:e,roughness:t})=>{const n=.0078125,o=i.dot(e).saturate(),a=ee(t,o.oneMinus().sqrt());return a.assign(a.mul(.984375).add(n)),a}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),ON=R(({f:i})=>{const e=i.length();return st(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),So=R(({v1:i,v2:e})=>{const t=i.dot(e),r=t.abs().toVar(),s=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),n=r.add(4.1616724).mul(r).add(3.417594).toVar(),o=s.div(n),a=t.greaterThan(0).select(o,st(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return i.cross(e).mul(a)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),Du=R(({N:i,V:e,P:t,mInv:r,p0:s,p1:n,p2:o,p3:a})=>{const u=n.sub(s).toVar(),l=a.sub(s).toVar(),c=u.cross(l),d=C().toVar();return me(c.dot(t.sub(s)).greaterThanEqual(0),()=>{const h=e.sub(i.mul(e.dot(i))).normalize(),f=i.cross(h).negate(),p=r.mul(rt(h,f,i).transpose()).toVar(),g=p.mul(s.sub(t)).normalize().toVar(),m=p.mul(n.sub(t)).normalize().toVar(),y=p.mul(o.sub(t)).normalize().toVar(),x=p.mul(a.sub(t)).normalize().toVar(),_=C(0).toVar();_.addAssign(So({v1:g,v2:m})),_.addAssign(So({v1:m,v2:y})),_.addAssign(So({v1:y,v2:x})),_.addAssign(So({v1:x,v2:g})),d.assign(C(ON({f:_})))}),d}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Ka=1/6,Hm=i=>ae(Ka,ae(i,ae(i,i.negate().add(3)).sub(3)).add(1)),pc=i=>ae(Ka,ae(i,ae(i,ae(3,i).sub(6))).add(4)),qm=i=>ae(Ka,ae(i,ae(i,ae(-3,i).add(3)).add(3)).add(1)),gc=i=>ae(Ka,qa(i,3)),Uh=i=>Hm(i).add(pc(i)),Oh=i=>qm(i).add(gc(i)),Ih=i=>Rt(-1,pc(i).div(Hm(i).add(pc(i)))),kh=i=>Rt(1,gc(i).div(qm(i).add(gc(i)))),Gh=(i,e,t)=>{const r=i.uvNode,s=ae(r,e.zw).add(.5),n=Os(s),o=Sr(s),a=Uh(o.x),u=Oh(o.x),l=Ih(o.x),c=kh(o.x),d=Ih(o.y),h=kh(o.y),f=ee(n.x.add(l),n.y.add(d)).sub(.5).mul(e.xy),p=ee(n.x.add(c),n.y.add(d)).sub(.5).mul(e.xy),g=ee(n.x.add(l),n.y.add(h)).sub(.5).mul(e.xy),m=ee(n.x.add(c),n.y.add(h)).sub(.5).mul(e.xy),y=Uh(o.y).mul(Rt(a.mul(i.sample(f).level(t)),u.mul(i.sample(p).level(t)))),x=Oh(o.y).mul(Rt(a.mul(i.sample(g).level(t)),u.mul(i.sample(m).level(t))));return y.add(x)},IN=R(([i,e])=>{const t=ee(i.size(Ue(e))),r=ee(i.size(Ue(e.add(1)))),s=vr(1,t),n=vr(1,r),o=Gh(i,q(s,t),Os(e)),a=Gh(i,q(n,r),ed(e));return Sr(e).mix(o,a)}),Vh=R(([i,e,t,r,s])=>{const n=C(Wg(e.negate(),Ht(i),vr(1,r))),o=C(Hr(s[0].xyz),Hr(s[1].xyz),Hr(s[2].xyz));return Ht(n).mul(t.mul(o))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),kN=R(([i,e])=>i.mul(hs(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),GN=Pm(),VN=XS(),$h=R(([i,e,t],{material:r})=>{const n=(r.side===ft?GN:VN).sample(i),o=jr(ic.x).mul(kN(e,t));return IN(n,o)}),zh=R(([i,e,t])=>(me(t.notEqual(0),()=>{const r=Fg(e).negate().div(t);return Dg(r.negate().mul(i))}),C(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),$N=R(([i,e,t,r,s,n,o,a,u,l,c,d,h,f,p])=>{let g,m;if(p){g=q().toVar(),m=C().toVar();const A=c.sub(1).mul(p.mul(.025)),v=C(c.sub(A),c,c.add(A));$t({start:0,end:3},({i:S})=>{const P=v.element(S),F=Vh(i,e,d,P,a),U=o.add(F),W=l.mul(u.mul(q(U,1))),se=ee(W.xy.div(W.w)).toVar();se.addAssign(1),se.divAssign(2),se.assign(ee(se.x,se.y.oneMinus()));const ie=$h(se,t,P);g.element(S).assign(ie.element(S)),g.a.addAssign(ie.a),m.element(S).assign(r.element(S).mul(zh(Hr(F),h,f).element(S)))}),g.a.divAssign(3)}else{const A=Vh(i,e,d,c,a),v=o.add(A),S=l.mul(u.mul(q(v,1))),P=ee(S.xy.div(S.w)).toVar();P.addAssign(1),P.divAssign(2),P.assign(ee(P.x,P.y.oneMinus())),g=$h(P,t,c),m=r.mul(zh(Hr(A),h,f))}const y=m.rgb.mul(g.rgb),x=i.dot(e).clamp(),_=C(jm({dotNV:x,specularColor:s,specularF90:n,roughness:t})),N=m.r.add(m.g,m.b).div(3);return q(_.oneMinus().mul(y),g.a.oneMinus().mul(N).oneMinus())}),zN=rt(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),WN=i=>{const e=i.sqrt();return C(1).add(e).div(C(1).sub(e))},Wh=(i,e)=>i.sub(e).div(i.add(e)).pow2(),jN=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),r=C(54856e-17,44201e-17,52481e-17),s=C(1681e3,1795300,2208400),n=C(43278e5,93046e5,66121e5),o=w(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let a=r.mul(n.mul(2*Math.PI).sqrt()).mul(s.mul(t).add(e).cos()).mul(t.pow2().negate().mul(n).exp());return a=C(a.x.add(o),a.y,a.z).div(10685e-11),zN.mul(a)},jh=R(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:r,baseF0:s})=>{const n=xe(i,e,nr(0,.03,r)),a=i.div(n).pow2().mul(t.pow2().oneMinus()).oneMinus();me(a.lessThan(0),()=>C(1));const u=a.sqrt(),l=Wh(n,i),c=$i({f0:l,f90:1,dotVH:t}),d=c.oneMinus(),h=n.lessThan(i).select(Math.PI,0),f=w(Math.PI).sub(h),p=WN(s.clamp(0,.9999)),g=Wh(p,n.toVec3()),m=$i({f0:g,f90:1,dotVH:u}),y=C(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),x=n.mul(r,u,2),_=C(f).add(y),N=c.mul(m).clamp(1e-5,.9999),A=N.sqrt(),v=d.pow2().mul(m).div(C(1).sub(N)),P=c.add(v).toVar(),F=v.sub(d).toVar();return $t({start:1,end:2,condition:"<=",name:"m"},({m:U})=>{F.mulAssign(A);const W=jN(w(U).mul(x),w(U).mul(_)).mul(2);P.addAssign(F.mul(W))}),P.max(C(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),ai=R(({normal:i,viewDir:e,roughness:t})=>{const r=i.dot(e).saturate(),s=t.mul(t),n=t.add(.1).reciprocal(),o=w(-1.9362).add(t.mul(1.0678)).add(s.mul(.4573)).sub(n.mul(.8469)),a=w(-.6014).add(t.mul(.5538)).sub(s.mul(.467)).sub(n.mul(.1255));return o.mul(r).add(a).exp().saturate()}),ui=C(.04),No=w(1);class Xm extends Xa{constructor(e=!1,t=!1,r=!1,s=!1,n=!1,o=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=n,this.dispersion=o,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=C().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=C().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=C().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=C().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=C().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=ge.dot(Ee).clamp(),r=jh({outsideIOR:w(1),eta2:ec,cosTheta1:t,thinFilmThickness:tc,baseF0:Gs}),s=jh({outsideIOR:w(1),eta2:ec,cosTheta1:t,thinFilmThickness:tc,baseF0:Se.rgb});this.iridescenceFresnel=xe(r,s,os),this.iridescenceF0Dielectric=Fh({f:r,f90:1,dotVH:t}),this.iridescenceF0Metallic=Fh({f:s,f90:1,dotVH:t}),this.iridescenceF0=xe(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,os)}if(this.transmission===!0){const t=On,r=x0.sub(On).normalize(),s=qn,n=e.context;n.backdrop=$N(s,r,Or,gn,_n,xn,t,zs,Hn,rr,aa,Eg,Cg,Ag,this.dispersion?Mg:null),n.backdropAlpha=nc,Se.a.mulAssign(xe(1,n.backdrop.a,nc))}super.start(e)}computeMultiscattering(e,t,r,s,n=null){const o=ge.dot(Ee).clamp(),a=Ca({roughness:Or,dotNV:o}),u=n?Qc.mix(s,n):s,l=u.mul(a.x).add(r.mul(a.y)),d=a.x.add(a.y).oneMinus(),h=u.add(u.oneMinus().mul(.047619)),f=l.mul(h).div(d.mul(h).oneMinus());e.addAssign(l),t.addAssign(f.mul(d))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const n=ge.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(n.mul(UN({lightDirection:e})));const o=ai({normal:ge,viewDir:Ee,roughness:As}),a=ai({normal:ge,viewDir:e,roughness:As}),u=Gt.r.max(Gt.g).max(Gt.b).mul(o.max(a)).oneMinus();n.mulAssign(u)}if(this.clearcoat===!0){const a=Bs.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(a.mul(Wm({lightDirection:e,f0:ui,f90:No,roughness:Ai,normalView:Bs})))}r.directDiffuse.addAssign(n.mul(In({diffuseColor:gn}))),r.directSpecular.addAssign(n.mul(DN({lightDirection:e,f0:_n,f90:1,roughness:Or,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:n,ltc_1:o,ltc_2:a}){const u=t.add(r).sub(s),l=t.sub(r).sub(s),c=t.sub(r).add(s),d=t.add(r).add(s),h=ge,f=Ee,p=je.toVar(),g=Lh({N:h,V:f,roughness:Or}),m=o.sample(g).toVar(),y=a.sample(g).toVar(),x=rt(C(m.x,0,m.y),C(0,1,0),C(m.z,0,m.w)).toVar(),_=_n.mul(y.x).add(xn.sub(_n).mul(y.y)).toVar();if(n.directSpecular.addAssign(e.mul(_).mul(Du({N:h,V:f,P:p,mInv:x,p0:u,p1:l,p2:c,p3:d}))),n.directDiffuse.addAssign(e.mul(gn).mul(Du({N:h,V:f,P:p,mInv:rt(1,0,0,0,1,0,0,0,1),p0:u,p1:l,p2:c,p3:d}))),this.clearcoat===!0){const N=Bs,A=Lh({N,V:f,roughness:Ai}),v=o.sample(A),S=a.sample(A),P=rt(C(v.x,0,v.y),C(0,1,0),C(v.z,0,v.w)),F=ui.mul(S.x).add(No.sub(ui).mul(S.y));this.clearcoatSpecularDirect.addAssign(e.mul(F).mul(Du({N,V:f,P:p,mInv:P,p0:u,p1:l,p2:c,p3:d})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context,s=t.mul(In({diffuseColor:gn})).toVar();if(this.sheen===!0){const n=ai({normal:ge,viewDir:Ee,roughness:As}),o=Gt.r.max(Gt.g).max(Gt.b).mul(n).oneMinus();s.mulAssign(o)}r.indirectDiffuse.addAssign(s)}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(r.mul(Gt,ai({normal:ge,viewDir:Ee,roughness:As}))),this.clearcoat===!0){const m=Bs.dot(Ee).clamp(),y=jm({dotNV:m,specularColor:ui,specularF90:No,roughness:Ai});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(y))}const n=C().toVar("singleScatteringDielectric"),o=C().toVar("multiScatteringDielectric"),a=C().toVar("singleScatteringMetallic"),u=C().toVar("multiScatteringMetallic");this.computeMultiscattering(n,o,xn,Gs,this.iridescenceF0Dielectric),this.computeMultiscattering(a,u,xn,Se.rgb,this.iridescenceF0Metallic);const l=xe(n,a,os),c=xe(o,u,os),d=n.add(o),h=gn.mul(d.oneMinus()),f=r.mul(1/Math.PI),p=t.mul(l).add(c.mul(f)).toVar(),g=h.mul(f).toVar();if(this.sheen===!0){const m=ai({normal:ge,viewDir:Ee,roughness:As}),y=Gt.r.max(Gt.g).max(Gt.b).mul(m).oneMinus();p.mulAssign(y),g.mulAssign(y)}s.indirectSpecular.addAssign(p),s.indirectDiffuse.addAssign(g)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,n=ge.dot(Ee).clamp().add(t),o=Or.mul(-16).oneMinus().negate().exp2(),a=t.sub(n.pow(o).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(a)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const r=Bs.dot(Ee).clamp(),s=$i({dotVH:r,f0:ui,f90:No}),n=t.mul(Jl.mul(s).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Jl));t.assign(n)}if(this.sheen===!0){const r=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(r)}}}const Hh=w(1),mc=w(-2),wo=w(.8),Fu=w(-1),Ro=w(.4),Lu=w(2),Eo=w(.305),Uu=w(3),qh=w(.21),HN=w(4),Xh=w(4),qN=w(16),XN=R(([i])=>{const e=C(Ft(i)).toVar(),t=w(-1).toVar();return me(e.x.greaterThan(e.z),()=>{me(e.x.greaterThan(e.y),()=>{t.assign(Ut(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Ut(i.y.greaterThan(0),1,4))})}).Else(()=>{me(e.z.greaterThan(e.y),()=>{t.assign(Ut(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Ut(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),KN=R(([i,e])=>{const t=ee().toVar();return me(e.equal(0),()=>{t.assign(ee(i.z,i.y).div(Ft(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(ee(i.x.negate(),i.z.negate()).div(Ft(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(ee(i.x.negate(),i.y).div(Ft(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(ee(i.z.negate(),i.y).div(Ft(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(ee(i.x.negate(),i.z).div(Ft(i.y)))}).Else(()=>{t.assign(ee(i.x,i.y).div(Ft(i.z)))}),ae(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),YN=R(([i])=>{const e=w(0).toVar();return me(i.greaterThanEqual(wo),()=>{e.assign(Hh.sub(i).mul(Fu.sub(mc)).div(Hh.sub(wo)).add(mc))}).ElseIf(i.greaterThanEqual(Ro),()=>{e.assign(wo.sub(i).mul(Lu.sub(Fu)).div(wo.sub(Ro)).add(Fu))}).ElseIf(i.greaterThanEqual(Eo),()=>{e.assign(Ro.sub(i).mul(Uu.sub(Lu)).div(Ro.sub(Eo)).add(Lu))}).ElseIf(i.greaterThanEqual(qh),()=>{e.assign(Eo.sub(i).mul(HN.sub(Uu)).div(Eo.sub(qh)).add(Uu))}).Else(()=>{e.assign(w(-2).mul(jr(ae(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),QN=R(([i,e])=>{const t=i.toVar();t.assign(ae(2,t).sub(1));const r=C(t,1).toVar();return me(e.equal(0),()=>{r.assign(r.zyx)}).ElseIf(e.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ZN=R(([i,e,t,r,s,n])=>{const o=w(t),a=C(e),u=hs(YN(o),mc,n),l=Sr(u),c=Os(u),d=C(zi(i,a,c,r,s,n)).toVar();return me(l.notEqual(0),()=>{const h=C(zi(i,a,c.add(1),r,s,n)).toVar();d.assign(xe(d,h,l))}),d}),zi=R(([i,e,t,r,s,n])=>{const o=w(t).toVar(),a=C(e),u=w(XN(a)).toVar(),l=w(st(Xh.sub(o),0)).toVar();o.assign(st(o,Xh));const c=w(Ii(o)).toVar(),d=ee(KN(a,u).mul(c.sub(2)).add(1)).toVar();return me(u.greaterThan(2),()=>{d.y.addAssign(c),u.subAssign(3)}),d.x.addAssign(u.mul(c)),d.x.addAssign(l.mul(ae(3,qN))),d.y.addAssign(ae(4,Ii(n).sub(c))),d.x.mulAssign(r),d.y.mulAssign(s),i.sample(d).grad(ee(),ee())}),Ou=R(({envMap:i,mipInt:e,outputDirection:t,theta:r,axis:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const u=pr(r),l=t.mul(u).add(s.cross(t).mul(Dt(r))).add(s.mul(s.dot(t).mul(u.oneMinus())));return zi(i,l,e,n,o,a)}),JN=R(({n:i,latitudinal:e,poleAxis:t,outputDirection:r,weights:s,samples:n,dTheta:o,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d})=>{const h=C(Ut(e,t,$s(t,r))).toVar();me(h.equal(C(0)),()=>{h.assign(C(r.z,0,r.x.negate()))}),h.assign(Ht(h));const f=C().toVar();return f.addAssign(s.element(0).mul(Ou({theta:0,axis:h,outputDirection:r,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d}))),$t({start:Ue(1),end:i},({i:p})=>{me(p.greaterThanEqual(n),()=>{GS()});const g=w(o.mul(w(p))).toVar();f.addAssign(s.element(p).mul(Ou({theta:g.mul(-1),axis:h,outputDirection:r,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d}))),f.addAssign(s.element(p).mul(Ou({theta:g,axis:h,outputDirection:r,mipInt:a,envMap:u,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:d})))}),q(f,1)}),ew=R(([i])=>{const e=de(i).toVar();return e.assign(e.shiftLeft(de(16)).bitOr(e.shiftRight(de(16)))),e.assign(e.bitAnd(de(1431655765)).shiftLeft(de(1)).bitOr(e.bitAnd(de(2863311530)).shiftRight(de(1)))),e.assign(e.bitAnd(de(858993459)).shiftLeft(de(2)).bitOr(e.bitAnd(de(3435973836)).shiftRight(de(2)))),e.assign(e.bitAnd(de(252645135)).shiftLeft(de(4)).bitOr(e.bitAnd(de(4042322160)).shiftRight(de(4)))),e.assign(e.bitAnd(de(16711935)).shiftLeft(de(8)).bitOr(e.bitAnd(de(4278255360)).shiftRight(de(8)))),w(e).mul(23283064365386963e-26)}),tw=R(([i,e])=>ee(w(i).div(w(e)),ew(i))),rw=R(([i,e,t])=>{const r=t.mul(t).toConst(),s=C(1,0,0).toConst(),n=$s(e,s).toConst(),o=ds(i.x).toConst(),a=ae(2,3.14159265359).mul(i.y).toConst(),u=o.mul(pr(a)).toConst(),l=o.mul(Dt(a)).toVar(),c=ae(.5,e.z.add(1)).toConst();l.assign(c.oneMinus().mul(ds(u.mul(u).oneMinus())).add(c.mul(l)));const d=s.mul(u).add(n.mul(l)).add(e.mul(ds(st(0,u.mul(u).add(l.mul(l)).oneMinus()))));return Ht(C(r.mul(d.x),r.mul(d.y),st(0,d.z)))}),sw=R(({roughness:i,mipInt:e,envMap:t,N_immutable:r,GGX_SAMPLES:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const u=C(r).toVar(),l=C(0).toVar(),c=w(0).toVar();return me(i.lessThan(.001),()=>{l.assign(zi(t,u,e,n,o,a))}).Else(()=>{const d=Ut(Ft(u.z).lessThan(.999),C(0,0,1),C(1,0,0)),h=Ht($s(d,u)).toVar(),f=$s(u,h).toVar();$t({start:de(0),end:s},({i:p})=>{const g=tw(p,s),m=rw(g,C(0,0,1),i),y=Ht(h.mul(m.x).add(f.mul(m.y)).add(u.mul(m.z))),x=Ht(y.mul(Vs(u,y).mul(2)).sub(u)),_=st(Vs(u,x),0);me(_.greaterThan(0),()=>{const N=zi(t,x,e,n,o,a);l.addAssign(N.mul(_)),c.addAssign(_)})}),me(c.greaterThan(0),()=>{l.assign(l.div(c))})}),q(l,1)}),us=4,Kh=[.125,.215,.35,.446,.526,.582],Ps=20,nw=512,li=new Lc(-1,1,1,-1,0,1),iw=new Li(90,1),Yh=new Kt;let Iu=null,ku=0,Gu=0;const ow=new V,Ma=new WeakMap,aw=[3,1,5,0,4,2],Vu=QN(Xs(),Wt("faceIndex")).normalize(),Ya=C(Vu.x,Vu.y,Vu.z);class uw{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,n={}){const{size:o=256,position:a=ow,renderTarget:u=null}=n;if(this._setSize(o),this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');Iu=this._renderer.getRenderTarget(),ku=this._renderer.getActiveCubeFace(),Gu=this._renderer.getActiveMipmapLevel();const l=u||this._allocateTarget(!0);return this._init(l),this._sceneToCubeUV(e,r,s,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(e,t=0,r=.1,s=100,n={}){return Be('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,s,n)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return Be('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return Be('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zh(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Jh(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===Ta||e.mapping===va?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?y:0,y,y),l.render(e,o)}l.autoClear=c,e.background=p}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===Ta||e.mapping===va;s?this._cubemapMaterial===null&&(this._cubemapMaterial=Zh(e)):this._equirectMaterial===null&&(this._equirectMaterial=Jh(e));const n=s?this._cubemapMaterial:this._equirectMaterial;n.fragmentNode.value=e;const o=this._lodMeshes[0];o.material=n;const a=this._cubeSize;this._setViewport(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(o,li)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let n=1;np-us?r-p+us:0),y=4*(this._cubeSize-g);e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.roughness.value=f,u.mipInt.value=p-t,this._setViewport(n,m,y,3*g,2*g),s.setRenderTarget(n),s.render(a,li),n.texture.frame=(n.texture.frame||0)+1,u.envMap.value=n.texture,u.roughness.value=0,u.mipInt.value=p-r,this._setViewport(e,m,y,3*g,2*g),s.setRenderTarget(e),s.render(a,li)}_blur(e,t,r,s,n){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,r,s,"latitudinal",n),this._halfBlur(o,e,r,r,s,"longitudinal",n)}_halfBlur(e,t,r,s,n,o,a){const u=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&O("blur direction must be either latitudinal or longitudinal!");const c=3,d=this._lodMeshes[s];d.material=l;const h=Ma.get(l),f=this._sizeLods[r]-1,p=isFinite(n)?Math.PI/(2*f):2*Math.PI/(2*Ps-1),g=n/p,m=isFinite(n)?1+Math.floor(c*g):Ps;m>Ps&&z(`sigmaRadians, ${n}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ps}`);const y=[];let x=0;for(let S=0;S_-us?s-_+us:0),v=4*(this._cubeSize-N);this._setViewport(t,A,v,3*N,2*N),u.setRenderTarget(t),u.render(d,li)}_setViewport(e,t,r,s,n){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-n-r,s,n),e.scissor.set(t,e.height-n-r,s,n)):(e.viewport.set(t,r,s,n),e.scissor.set(t,r,s,n))}}function lw(i){const e=[],t=[],r=[];let s=i;const n=i-us+1+Kh.length;for(let o=0;oi-us?u=Kh[o-i+us-1]:o===0&&(u=0),t.push(u);const l=1/(a-2),c=-l,d=1+l,h=[c,c,d,c,d,d,c,c,d,d,c,d],f=6,p=6,g=3,m=2,y=1,x=new Float32Array(g*p*f),_=new Float32Array(m*p*f),N=new Float32Array(y*p*f);for(let v=0;v2?0:-1,F=[S,P,0,S+2/3,P,0,S+2/3,P+1,0,S,P,0,S+2/3,P+1,0,S,P+1,0],U=aw[v];x.set(F,g*p*U),_.set(h,m*p*U);const W=[U,U,U,U,U,U];N.set(W,y*p*U)}const A=new Hi;A.setAttribute("position",new ea(x,g)),A.setAttribute("uv",new ea(_,m)),A.setAttribute("faceIndex",new ea(N,y)),r.push(new sr(A,null)),s>us&&s--}return{lodMeshes:r,sizeLods:e,sigmas:t}}function Qh(i,e,t){const r={magFilter:yt,minFilter:yt,generateMipmaps:!1,type:ht,format:er,colorSpace:f_,depthBuffer:t},s=new ps(i,e,r);return s.texture.mapping=pa,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function Qa(i){const e=new qe;return e.depthTest=!1,e.depthWrite=!1,e.blending=Wr,e.name=`PMREM_${i}`,e}function cw(i,e,t){const r=Tt(new Array(Ps).fill(0)),s=K(new V(0,1,0)),n=K(0),o=w(Ps),a=K(0),u=K(1),l=Ne(),c=K(0),d=w(1/e),h=w(1/t),f=w(i),p={n:o,latitudinal:a,weights:r,poleAxis:s,outputDirection:Ya,dTheta:n,samples:u,envMap:l,mipInt:c,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:h,CUBEUV_MAX_MIP:f},g=Qa("blur");return g.fragmentNode=JN({...p,latitudinal:a.equal(1)}),Ma.set(g,p),g}function dw(i,e,t){const r=Ne(),s=K(0),n=K(0),o=w(1/e),a=w(1/t),u=w(i),l={envMap:r,roughness:s,mipInt:n,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:u},c=Qa("ggx");return c.fragmentNode=sw({...l,N_immutable:Ya,GGX_SAMPLES:de(nw)}),Ma.set(c,l),c}function Zh(i){const e=Qa("cubemap");return e.fragmentNode=vt(i,Ya),e}function Jh(i){const e=Qa("equirect");return e.fragmentNode=Ne(i,Om(Ya),0),e}const ef=new WeakMap;function hw(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function fw(i,e,t){const r=pw(e);let s=r.get(i);if((s!==void 0?s.pmremVersion:-1)!==i.pmremVersion){const o=i.image;if(i.isCubeTexture)if(mw(o))s=t.fromCubemap(i,s);else return null;else if(yw(o))s=t.fromEquirectangular(i,s);else return null;if(s.pmremVersion=i.pmremVersion,r.has(i)===!1){const a=()=>{i.removeEventListener("dispose",a);const u=r.get(i);u!==void 0&&(u.dispose(),r.delete(i))};i.addEventListener("dispose",a)}r.set(i,s)}return s.texture}function pw(i){let e=ef.get(i);return e===void 0&&(e=new WeakMap,ef.set(i,e)),e}class gw extends Xe{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new Ic;s.isRenderTargetTexture=!0,this._texture=Ne(s),this._width=K(0),this._height=K(0),this._maxMip=K(0),this.updateBeforeType=re.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=hw(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(s.isPMREMTexture===!0||s.mapping===pa?t=s:t=fw(s,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new uw(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?oc.mul(C(t.x,t.y.negate(),t.z)):oc.mul(t);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ZN(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function mw(i){if(i==null)return!1;let e=0;const t=6;for(let r=0;r0}const Km=Pe(gw).setParameterLength(1,3),tf=new WeakMap;class bw extends Xn{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const d=r.isTextureNode?r.value:t[r.property],h=this._getPMREMNodeCache(e.renderer);let f=h.get(d);f===void 0&&(f=Km(d),h.set(d,f)),r=f}const n=t.useAnisotropy===!0||t.anisotropy>0?j0:ge,o=r.context(rf(Or,n)).mul(Cu),a=r.context(_w(qn)).mul(Math.PI).mul(Cu),u=Mi(o),l=Mi(a);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(l);const c=e.context.lightingModel.clearcoatRadiance;if(c){const d=r.context(rf(Ai,Bs)).mul(Cu),h=Mi(d);c.addAssign(h)}}_getPMREMNodeCache(e){let t=tf.get(e);return t===void 0&&(t=new WeakMap,tf.set(e,t)),t}}const rf=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Ee.negate().reflect(e),t=$g(i).mix(t,e).normalize(),t=t.transformDirection(ld)),t),getTextureLevel:()=>i}},_w=i=>({getUV:()=>i,getTextureLevel:()=>w(1)}),xw=new Tb;class Ym extends qe{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(xw),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new bw(t):null}setupLightingModel(){return new Xm}setupSpecular(){const e=xe(C(.04),Se.rgb,os);Gs.assign(C(.04)),_n.assign(e),xn.assign(1)}setupVariants(){const e=this.metalnessNode?w(this.metalnessNode):iS;os.assign(e);let t=this.roughnessNode?w(this.roughnessNode):nS;t=zm({roughness:t}),Or.assign(t),this.setupSpecular(),gn.assign(Se.rgb.mul(e.oneMinus()))}}const Tw=new vb;class vw extends Ym{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(Tw),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?w(this.iorNode):_S;aa.assign(e),Gs.assign(Ln(Vg(aa.sub(1).div(aa.add(1))).mul(sS),C(1)).mul(Nh)),_n.assign(xe(Gs,Se.rgb,os)),xn.assign(xe(Nh,1,os))}setupLightingModel(){return new Xm(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?w(this.clearcoatNode):aS,r=this.clearcoatRoughnessNode?w(this.clearcoatRoughnessNode):uS;Jl.assign(t),Ai.assign(zm({roughness:r}))}if(this.useSheen){const t=this.sheenNode?C(this.sheenNode):dS,r=this.sheenRoughnessNode?w(this.sheenRoughnessNode):hS;Gt.assign(t),As.assign(r)}if(this.useIridescence){const t=this.iridescenceNode?w(this.iridescenceNode):pS,r=this.iridescenceIORNode?w(this.iridescenceIORNode):gS,s=this.iridescenceThicknessNode?w(this.iridescenceThicknessNode):mS;Qc.assign(t),ec.assign(r),tc.assign(s)}if(this.useAnisotropy){const t=(this.anisotropyNode?ee(this.anisotropyNode):fS).toVar();ws.assign(t.length()),me(ws.equal(0),()=>{t.assign(ee(1,0))}).Else(()=>{t.divAssign(ee(ws)),ws.assign(ws.saturate())}),rc.assign(ws.pow2().mix(Or.pow2(),1)),oa.assign(Ti[0].mul(t.x).add(Ti[1].mul(t.y))),Rn.assign(Ti[1].mul(t.x).sub(Ti[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?w(this.transmissionNode):yS,r=this.thicknessNode?w(this.thicknessNode):bS,s=this.attenuationDistanceNode?w(this.attenuationDistanceNode):xS,n=this.attenuationColorNode?C(this.attenuationColorNode):TS;if(nc.assign(t),Eg.assign(r),Ag.assign(s),Cg.assign(n),this.useDispersion){const o=this.dispersionNode?w(this.dispersionNode):SS;Mg.assign(o)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?C(this.clearcoatNormalNode):lS}setup(e){e.context.setupClearcoatNormal=()=>An(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}}const Sw=R(({normal:i,lightDirection:e,builder:t})=>{const r=i.dot(e),s=ee(r.mul(.5).add(.5),0);if(t.material.gradientMap){const n=ns("gradientMap","texture").context({getUV:()=>s});return C(n.r)}else{const n=s.fwidth().mul(.5);return xe(C(.7),C(1),nr(w(.7).sub(n.x),w(.7).add(n.x),s.x))}});class Nw extends Xa{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const n=Sw({normal:am,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(n.mul(In({diffuseColor:Se.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(In({diffuseColor:Se}))),s.indirectDiffuse.mulAssign(t)}}const ww=new Sb;class Rw extends qe{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ww),this.setValues(e)}setupLightingModel(){return new Nw}}const Ew=R(()=>{const i=C(Ee.z,0,Ee.x.negate()).normalize(),e=Ee.cross(i);return ee(i.dot(ge),e.dot(ge)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),Aw=new wb;class Cw extends qe{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Aw),this.setValues(e)}setupVariants(e){const t=Ew;let r;e.material.matcap?r=ns("matcap","texture").context({getUV:()=>t}):r=C(xe(.2,.8,t.y)),Se.rgb.mulAssign(r.rgb)}}class Mw extends Xe{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if(this.getNodeType(e)==="vec2"){const n=t.cos(),o=t.sin();return Yc(n,o,o.negate(),n).mul(r)}else{const n=t,o=Us(q(1,0,0,0),q(0,pr(n.x),Dt(n.x).negate(),0),q(0,Dt(n.x),pr(n.x),0),q(0,0,0,1)),a=Us(q(pr(n.y),0,Dt(n.y),0),q(0,1,0,0),q(Dt(n.y).negate(),0,pr(n.y),0),q(0,0,0,1)),u=Us(q(pr(n.z),Dt(n.z).negate(),0,0),q(Dt(n.z),pr(n.z),0,0),q(0,0,1,0),q(0,0,0,1));return o.mul(a).mul(u).mul(q(r,1)).xyz}}}const Qm=Pe(Mw).setParameterLength(2),Bw=new Ab;class Zm extends qe{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Bw),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:s,rotationNode:n,scaleNode:o,sizeAttenuation:a}=this,u=Ws.mul(C(s||0));let l=ee(zs[0].xyz.length(),zs[1].xyz.length());o!==null&&(l=l.mul(ee(o))),r.isPerspectiveCamera&&a===!1&&(l=l.mul(u.z.negate()));let c=mt.xy;if(t.center&&t.center.isVector2===!0){const f=$v("center","vec2",t);c=c.sub(f.sub(.5))}c=c.mul(l);const d=w(n||cS),h=Qm(c,d);return q(u.xy.add(h),u.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Pw=new Eb,Dw=new ce;class Fw extends Zm{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Pw),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Ws.mul(C(e||Qe)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:s,scaleNode:n,sizeNode:o,sizeAttenuation:a}=this;let u=super.setupVertex(e);if(t.isNodeMaterial!==!0)return u;let l=o!==null?ee(o):vS;l=l.mul(nm),r.isPerspectiveCamera&&a===!0&&(l=l.mul(Lw.div(je.z.negate()))),n&&n.isNode&&(l=l.mul(ee(n)));let c=mt.xy;if(s&&s.isNode){const d=w(s);c=Qm(c,d)}return c=c.mul(l),c=c.div(b0.div(2)),c=c.mul(u.w),u=u.add(q(c,0,0)),u}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const Lw=K(1).onFrameUpdate(function({renderer:i}){const e=i.getSize(Dw);this.value=.5*e.y});class Uw extends Xa{constructor(){super(),this.shadowNode=w(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Se.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Se.rgb)}}const Ow=new Cb;class Iw extends qe{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Ow),this.setValues(e)}setupLightingModel(){return new Uw}}gs("vec3");gs("vec3");gs("vec3");class kw{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class fs{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let r=this.weakMaps[t];return r===void 0&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);for(let r=0;r{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.getNodeBuilderState().hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set,n={};for(const o of e){let a;if(o.node&&o.node.attribute?a=o.node.attribute:(a=t.getAttribute(o.name),a!==void 0&&(a.isInterleavedBufferAttribute?n[o.name]=a.data.uuid:n[o.name]=a.id)),a===void 0)continue;r.push(a);const u=a.isInterleavedBufferAttribute?a.data:a;s.add(u)}return this.attributes=r,this.attributesId=n,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:n}=this,o=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),u=a!==null;let l=1;if(r.isInstancedBufferGeometry===!0?l=r.instanceCount:e.count!==void 0&&(l=Math.max(0,e.count)),l===0)return null;if(o.instanceCount=l,e.isBatchedMesh===!0)return o;let c=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(c=2);let d=n.start*c,h=(n.start+n.count)*c;s!==null&&(d=Math.max(d,s.start*c),h=Math.min(h,(s.start+s.count)*c));const f=r.attributes.position;let p=1/0;u?p=a.count:f!=null&&(p=f.count),d=Math.max(d,0),h=Math.min(h,p);const g=h-d;return g<0||g===1/0?null:(o.vertexCount=g,o.firstVertex=d,o)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let n=0,o=s.length;n1)&&(s+=e.uuid+","),s+=this.context.id+",",s+=e.receiveShadow+",",Vn(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(r===void 0)return!0;const s=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==s)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Ri(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ri(e,1)),e=Ri(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const cr=[];class zw{constructor(e,t,r,s,n,o){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=n,this.info=o,this.chainMaps={}}get(e,t,r,s,n,o,a,u){const l=this.getChainMap(u);cr[0]=e,cr[1]=t,cr[2]=o,cr[3]=n;let c=l.get(cr);return c===void 0?(c=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,n,o,a,u),l.set(cr,c)):(c.camera=s,c.updateClipping(a),c.needsGeometryUpdate&&c.setGeometry(e.geometry),(c.version!==t.version||c.needsUpdate)&&(c.initialCacheKey!==c.getCacheKey()?(c.dispose(),c=this.get(e,t,r,s,n,o,a,u)):c.version=t.version)),cr[0]=null,cr[1]=null,cr[2]=null,cr[3]=null,c}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new fs)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,n,o,a,u,l,c,d){const h=this.getChainMap(d),f=new $w(e,t,r,s,n,o,a,u,l,c);return f.onDispose=()=>{this.pipelines.delete(f),this.bindings.deleteForRender(f),this.nodes.delete(f),h.delete(f.getChainArray())},f}}class ms{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const jt={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},is=16,Ww=211,jw=212;class Hw extends ms{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){const t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){const r=this.get(e);if(r.version===void 0)t===jt.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===jt.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===jt.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===jt.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),r.version=this._getBufferAttribute(e).version;else{const s=this._getBufferAttribute(e);(r.version=65535?Pb:Db)(e,1);return s.version=Jm(i),s.__id=ey(i),s}class qw extends ms{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,r=this.get(t);r.initialized=!0,this.info.memory.geometries++;const s=()=>{this.info.memory.geometries--;const n=t.index,o=e.getAttributes();n!==null&&this.attributes.delete(n);for(const u of o)this.attributes.delete(u);const a=this.wireframes.get(t);a!==void 0&&this.attributes.delete(a),t.removeEventListener("dispose",s),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",s),this._geometryDisposeListeners.set(t,s)}updateAttributes(e){const t=e.getAttributes();for(const n of t)n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute?this.updateAttribute(n,jt.STORAGE):this.updateAttribute(n,jt.VERTEX);const r=this.getIndex(e);r!==null&&this.updateAttribute(r,jt.INDEX);const s=e.geometry.indirect;s!==null&&this.updateAttribute(s,jt.INDIRECT)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(r.wireframe===!0){const n=this.wireframes;let o=n.get(t);o===void 0?(o=nf(t),n.set(t,o)):(o.version!==Jm(t)||o.__id!==ey(t))&&(this.attributes.delete(o),o=nf(t),n.set(t,o)),s=o}return s}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class Xw{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):O("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(const e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){const t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){const r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){const t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){const{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){const t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){const t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===Tn||e.type===St?t=1:e.type===vn||e.type===Fs||e.type===ht?t=2:(e.type===Ze||e.type===Ge||e.type===dt)&&(t=4);let r=4;e.format===dp||e.format===qi||e.format===Xi||e.format===Vr||e.format===$r?r=1:e.format===tr||e.format===Ki?r=2:(e.format===Yi||e.format===Mc)&&(r=3);let s=t*r;e.type===hp||e.type===fp?s=2:(e.type===zr||e.type===Bc||e.type===Pc)&&(s=4);const n=e.width||1,o=e.height||1,a=e.isCubeTexture?6:e.depth||1;let u=n*o*a*s;const l=e.mipmaps;if(l&&l.length>0){let c=0;for(let d=0;d>d),p=h.height||Math.max(1,o>>d);c+=f*p*a*s}}u+=c}else e.generateMipmaps&&(u=u*1.333);return Math.round(u)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}class ty{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Kw extends ty{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class Yw extends ty{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Qw=0;class $u{constructor(e,t,r,s=null,n=null){this.id=Qw++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=n,this.usedTimes=0}}class Zw extends ms{constructor(e,t,r){super(),this.backend=e,this.nodes=t,this.info=r,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const n=s.pipeline;n&&(n.usedTimes--,n.computeProgram.usedTimes--);const o=this.nodes.getForCompute(e);let a=this.programs.compute.get(o.computeShader);a===void 0&&(n&&n.computeProgram.usedTimes===0&&this._releaseProgram(n.computeProgram),a=new $u(o.computeShader,"compute",e.name,o.transforms,o.nodeAttributes),this.programs.compute.set(o.computeShader,a),r.createProgram(a),this.info.createProgram(a));const u=this._getComputeCacheKey(e,a);let l=this.caches.get(u);l===void 0&&(n&&n.usedTimes===0&&this._releasePipeline(n),l=this._getComputePipeline(e,a,u,t)),l.usedTimes++,a.usedTimes++,s.version=e.version,s.pipeline=l}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const n=s.pipeline;n&&(n.usedTimes--,n.vertexProgram.usedTimes--,n.fragmentProgram.usedTimes--);const o=e.getNodeBuilderState(),a=e.material?e.material.name:"";let u=this.programs.vertex.get(o.vertexShader);u===void 0&&(n&&n.vertexProgram.usedTimes===0&&this._releaseProgram(n.vertexProgram),u=new $u(o.vertexShader,"vertex",a),this.programs.vertex.set(o.vertexShader,u),r.createProgram(u),this.info.createProgram(u));let l=this.programs.fragment.get(o.fragmentShader);l===void 0&&(n&&n.fragmentProgram.usedTimes===0&&this._releaseProgram(n.fragmentProgram),l=new $u(o.fragmentShader,"fragment",a),this.programs.fragment.set(o.fragmentShader,l),r.createProgram(l),this.info.createProgram(l));const c=this._getRenderCacheKey(e,u,l);let d=this.caches.get(c);d===void 0?(n&&n.usedTimes===0&&this._releasePipeline(n),d=this._getRenderPipeline(e,u,l,c,t)):e.pipeline=d,d.usedTimes++,u.usedTimes++,l.usedTimes++,s.pipeline=d}return s.pipeline}isReady(e){const r=this.get(e).pipeline;if(r===void 0)return!1;const s=this.backend.get(r);return s.pipeline!==void 0&&s.pipeline!==null}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,s){r=r||this._getComputeCacheKey(e,t);let n=this.caches.get(r);return n===void 0&&(n=new Yw(r,t),this.caches.set(r,n),this.backend.createComputePipeline(n,s)),n}_getRenderPipeline(e,t,r,s,n){s=s||this._getRenderCacheKey(e,t,r);let o=this.caches.get(s);return o===void 0&&(o=new Kw(s,t,r),this.caches.set(s,o),e.pipeline=o,this.backend.createRenderPipeline(e,n)),o}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Jw extends ms{constructor(e,t,r,s,n,o){super(),this.backend=e,this.textures=r,this.pipelines=n,this.attributes=s,this.nodes=t,this.info=o,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings(),r=this.get(e);return r.initialized!==!0&&(this._createBindings(t),r.initialized=!0),t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings,r=this.get(e);return(r.initialized!==!0||r.bindings!==t)&&(r.bindings!==void 0&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const r=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(r),this.delete(e)}deleteForRender(e){const t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(const t of e){const r=this.get(t);if(r.bindGroup===void 0){for(const s of t.bindings)if(s.isUniformBuffer)this.backend.createUniformBuffer(s),this.info.createUniformBuffer(s);else if(s.isSampledTexture)this.textures.updateTexture(s.texture);else if(s.isSampler)this.textures.updateSampler(s);else if(s.isStorageBuffer){const n=s.attribute,o=n.isIndirectStorageBufferAttribute?jt.INDIRECT:jt.STORAGE;this.attributes.update(n,o)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}}_destroyBindings(e){for(const t of e){const r=this.get(t);if(r.usedTimes--,r.usedTimes===0){for(const s of t.bindings)s.isUniformBuffer?(this.backend.destroyUniformBuffer(s),this.info.destroyUniformBuffer(s),s.release()):s.isSampler&&(s.isSampledTexture!==!0&&this.backend.destroySampler(s),s.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(const t of e)this._update(t,e)}_update(e,t){const{backend:r}=this;let s=!1,n=!0,o=0,a=0;for(const u of e.bindings)if(this.nodes.updateGroup(u)!==!1){if(u.isStorageBuffer){const c=u.attribute,d=c.isIndirectStorageBufferAttribute?jt.INDIRECT:jt.STORAGE,h=r.get(u);this.attributes.update(c,d),h.attribute!==c&&(h.attribute=c,s=!0)}if(u.isUniformBuffer)u.update()&&r.updateBinding(u);else if(u.isSampledTexture){const c=u.update(),d=u.texture,h=this.textures.get(d);if(c&&(this.textures.updateTexture(d),u.generation!==h.generation&&(u.generation=h.generation,s=!0),h.bindGroups.add(e)),r.get(d).externalTexture!==void 0||h.isDefaultTexture?n=!1:(o=o*10+d.id,a+=d.version),d.isStorageTexture===!0&&d.mipmapsAutoUpdate===!0){const p=this.get(d);u.store===!0?p.needsMipmap=!0:this.textures.needsMipmaps(d)&&p.needsMipmap===!0&&(this.backend.generateMipmaps(d),p.needsMipmap=!1)}}else if(u.isSampler&&u.update()){const d=this.textures.updateSampler(u);u.samplerKey!==d&&(u.samplerKey=d,s=!0)}u.isBuffer&&u.updateRanges.length>0&&u.clearUpdateRanges()}s===!0&&this.backend.updateBindings(e,t,n?o:0,a)}}const eR=Object.freeze([]);function tR(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?i.z-e.z:i.id-e.id}function of(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function af(i){return(i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode)&&i.side===Gr&&i.forceSinglePass===!1}class rR{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0,this._lastOcclusionObject=null}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,n,o,a){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:n,group:o,clippingContext:a},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=r,u.groupOrder=s,u.renderOrder=e.renderOrder,u.z=n,u.group=o,u.clippingContext=a),this.renderItemsIndex++,u}push(e,t,r,s,n,o,a){const u=this.getNextRenderItem(e,t,r,s,n,o,a);e.occlusionTest===!0&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),r.transparent===!0||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(af(r)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,r,s,n,o,a){const u=this.getNextRenderItem(e,t,r,s,n,o,a);r.transparent===!0||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(af(r)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t,r){this.opaque.length>1&&this.opaque.sort(e||tR),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||of),this.transparent.length>1&&this.transparent.sort(t||of),r&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:eR);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,l=a.height>>t;let c=e.depthTexture||n[t];const d=e.depthBuffer===!0||e.stencilBuffer===!0;let h=!1;const f=c!==void 0&&c.image!==void 0&&c.image.depth>1,p=a.depth>1&&(e.useArrayDepthTexture||e.multiview||f);c===void 0&&d&&(c=new xr,c.format=e.stencilBuffer?$r:Vr,c.type=e.stencilBuffer?zr:Ge,c.image.width=u,c.image.height=l,c.image.depth=a.depth,c.renderTarget=e,n[t]=c),c&&(c.isArrayTexture=p),(r.width!==a.width||a.height!==r.height)&&(h=!0,c&&(c.needsUpdate=!0,c.image.width=u,c.image.height=l,c.image.depth=p?a.depth:1)),r.width=a.width,r.height=a.height,r.textures=o,r.depthTexture=c||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(h=!0,c&&(c.needsUpdate=!0),r.sampleCount=s);const g={sampleCount:s};if(e.isXRRenderTarget!==!0){for(let m=0;m{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}updateTexture(e,t={}){const r=this.get(e);if(r.initialized===!0&&r.version===e.version)return;const s=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,n=this.backend;if(s&&r.initialized===!0&&n.destroyTexture(e),e.isFramebufferTexture){const l=this.renderer.getRenderTarget();l?e.type=l.texture.type:e.type=St}if(e.isHTMLTexture&&e.image){const l=this.renderer.domElement;if("requestPaint"in l){if(l.hasAttribute("layoutsubtree")||l.setAttribute("layoutsubtree","true"),e.image.parentNode!==l&&l.appendChild(e.image),this._htmlTextures.size===0){const c=this._htmlTextures;l.onpaint=d=>{const h=d&&d.changedElements;for(const f of c)(!h||h.includes(f.image))&&(f.needsUpdate=!0)}}this._htmlTextures.add(e)}}const{width:o,height:a,depth:u}=this.getSize(e);if(t.width=o,t.height=a,t.depth=u,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,o,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,s||e.isStorageTexture===!0||e.isExternalTexture===!0)n.createTexture(e,t),r.generation=e.version;else if(e.version>0){const l=e.image;if(l===void 0)z("Renderer: Texture marked for update but image is undefined.");else if(l.complete===!1)z("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const d=[];for(const h of e.images)d.push(h);t.images=d}else t.image=l;(r.isDefaultTexture===void 0||r.isDefaultTexture===!0)&&(n.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),e.source.dataReady===!0&&n.updateTexture(e,t);const c=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!c&&n.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else n.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;r.initialized!==!0&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&We.enabled===!0&&We.getTransfer(e.colorSpace)!==oe&&z("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=aR){let r=e.images?e.images[0]:e.image;return r?(r.image!==void 0&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):typeof VideoFrame<"u"&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return e.mipmaps.length>0?s=e.mipmaps.length:e.isCompressedTexture===!0?s=1:s=Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){const t=this.get(e),r=t.textures,s=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let n=0;n{s.isOverrideContextNode===!0&&e.push(s.value.overrideNodes)});const t=new Map(e.flatMap(s=>Array.from(s.entries()))),r=super.getFlowContextData();return r.overrideNodes=t,r}}function lR(i,e=null,t=null){if(e&&e.isNode){const r=e;e=()=>r}return new sy(new Map([[i,e]]),t)}E("overrideNode",(i,e,t)=>lR(e,t,i));function cR(i,e=null){const t=new Map;for(const[r,s]of i){const n=s!==null?typeof s=="function"?s:()=>s:null;t.set(r,n)}return new sy(t,e)}E("overrideNodes",(i,e)=>cR(e,i));class dR extends be{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){const r=this.getNodeType(e),s=e.getStructTypeNode(r);let n;return s!==null?n=s.getMemberType(e,t):(O(`TSL: Member "${t}" not found in struct "${r}".`,new bt),n="float"),n}getHash(){return String(this.id)}generate(){return this.name}}class hR extends J{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):"void"}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=-1){if(e.isNode!==!0)return O("TSL: Invalid node added to stack.",new bt),this;if(t===-1)if(this._currentNode){let r=this._nodeDataLibrary.get(this._currentNode);r===void 0&&(r={delta:0},this._nodeDataLibrary.set(this._currentNode,r)),r.delta++,t=this.nodes.indexOf(this._currentNode)+r.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}addToStackBefore(e){const t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){const r=new xi(t);return this._currentCond=Ut(e,r),this.addToStack(this._currentCond)}ElseIf(e,t){const r=new xi(t),s=Ut(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new xi(e),this}Switch(e){return this._expressionNode=H(e),this}Case(...e){const t=[];if(e.length>=2)for(let a=0;anew ny(i,"uint","float"),Ao={};class Is extends T{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){r==="int"?t.assign(fR(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return de;case"int":return Ue;case"uvec2":return vg;case"uvec3":return Ng;case"uvec4":return Rg;case"ivec2":return Nt;case"ivec3":return Sg;case"ivec4":return wg}}_createTrailingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return R(([n])=>{const o=de(0);this._resolveElementType(n,o,t);const a=w(o.bitAnd(Og(o))),l=pR(a).shiftRight(23).sub(127);return r(l)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return R(([n])=>{me(n.equal(de(0)),()=>de(32));const o=de(0),a=de(0);return this._resolveElementType(n,o,t),me(o.shiftRight(16).equal(0),()=>{a.addAssign(16),o.shiftLeftAssign(16)}),me(o.shiftRight(24).equal(0),()=>{a.addAssign(8),o.shiftLeftAssign(8)}),me(o.shiftRight(28).equal(0),()=>{a.addAssign(4),o.shiftLeftAssign(4)}),me(o.shiftRight(30).equal(0),()=>{a.addAssign(2),o.shiftLeftAssign(2)}),me(o.shiftRight(31).equal(0),()=>{a.addAssign(1)}),r(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const r=this._returnDataNode(t);return R(([n])=>{const o=de(0);this._resolveElementType(n,o,t),o.assign(o.sub(o.shiftRight(de(1)).bitAnd(de(1431655765)))),o.assign(o.bitAnd(de(858993459)).add(o.shiftRight(de(2)).bitAnd(de(858993459))));const a=o.add(o.shiftRight(de(4))).bitAnd(de(252645135)).mul(de(16843009)).shiftRight(de(24));return r(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,s){const n=this._returnDataNode(t);return R(([a])=>{if(r===1)return n(s(a));{const u=n(0),l=["x","y","z","w"];for(let c=0;cd(r))()}}Is.COUNT_TRAILING_ZEROS="countTrailingZeros";Is.COUNT_LEADING_ZEROS="countLeadingZeros";Is.COUNT_ONE_BITS="countOneBits";new At;const gR=new ps;as.flipX();gR.depthTexture=new xr(1,1);const Wu=new Lc(-1,1,1,-1,0,1);class mR extends Hi{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new _a([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new _a(t,2))}}const yR=new mR;class iy extends sr{constructor(e=null){super(yR,e),this.camera=Wu,this.isQuadMesh=!0}async renderAsync(e){Be('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,Wu)}render(e){e.render(this,Wu)}}const oy=R(([i])=>Sr(w(52.9829189).mul(Sr(Vs(i,ee(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),mr=R(([i,e,t])=>{const r=w(2.399963229728653),s=ds(w(i).add(.5).div(w(e))),n=w(i).mul(r).add(t);return ee(pr(n),Dt(n)).mul(s)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]}),ju=new At,bR=K(0).setGroup(Z).onRenderUpdate(({scene:i})=>i.backgroundBlurriness),uf=K(1).setGroup(Z).onRenderUpdate(({scene:i})=>i.backgroundIntensity),_R=K(new At).setGroup(Z).onRenderUpdate(({scene:i})=>{const e=i.background;return e!==null&&e.isTexture&&e.mapping!==Bb||i.backgroundNode&&i.backgroundNode.isNode?ju.makeRotationFromEuler(i.backgroundRotation).transpose():ju.identity(),ju});R(({texture:i,uv:e})=>{const r=C().toVar();return me(e.x.lessThan(1e-4),()=>{r.assign(C(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{r.assign(C(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{r.assign(C(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{r.assign(C(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{r.assign(C(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{r.assign(C(0,0,-1))}).Else(()=>{const n=i.sample(e.add(C(-.01,0,0))).r.sub(i.sample(e.add(C(.01,0,0))).r),o=i.sample(e.add(C(0,-.01,0))).r.sub(i.sample(e.add(C(0,.01,0))).r),a=i.sample(e.add(C(0,0,-.01))).r.sub(i.sample(e.add(C(0,0,.01))).r);r.assign(C(n,o,a))}),r.normalize()});R(([i,e])=>i.mul(e).floor().div(e));const Co=new ce;class xR extends to{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){const t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class lf extends xR{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}class Wi extends Xe{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._width=1,this._height=1;const n=new ps(this._width,this._height,{type:ht,...s});n.texture.name="output";let o=null;(this.scope===Wi.DEPTH||s.depthBuffer!==!1)&&(o=new xr,o.isRenderTargetTexture=!0,o.name="depth",n.depthTexture=o),this.renderTarget=n,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:n.texture},o!==null&&(this._textures.depth=o),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=K(0),this._cameraFar=K(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=re.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return z("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return z("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){if(e==="depth")throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new lf(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new lf(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=hd(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const r=this._cameraNear,s=this._cameraFar,n=this.getViewZNode(e);this._linearDepthNodes[e]=t=Cn(n,r,s)}return t}async compileAsync(e){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),e.reversedDepthBuffer===!0&&this.renderTarget.depthTexture!==null&&(this.renderTarget.depthTexture.type=dt),this.scope===Wi.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s;const n=t.getOutputRenderTarget();n&&n.isXRRenderTarget===!0?(s=t.xr.getCamera(),t.xr.updateCamera(s),Co.set(n.width,n.height)):(s=this.camera,t.getDrawingBufferSize(Co)),this.setSize(Co.width,Co.height);const o=t.getRenderTarget(),a=t.getMRT(),u=t.autoClear,l=t.transparent,c=t.opaque,d=s.layers.mask,h=t.contextNode,f=r.overrideMaterial;this._cameraNear.value=s.near,this._cameraFar.value=s.far,this._layers!==null&&(s.layers.mask=this._layers.mask);for(const g in this._previousTextures)this.toggleTexture(g);this.overrideMaterial!==null&&(r.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:Hs({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const p=r.name;r.name=this.name?this.name:r.name,t.render(r,s),r.name=p,r.overrideMaterial=f,t.setRenderTarget(o),t.setMRT(a),t.autoClear=u,t.transparent=l,t.opaque=c,t.contextNode=h,s.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._resolutionScale),s=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,s),this._scissor!==null?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,r,s){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new He),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,s))}setViewport(e,t,r,s){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new He),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,s))}dispose(){this.renderTarget.dispose()}}Wi.COLOR="color";Wi.DEPTH="depth";const TR=R(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),vR=R(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),SR=R(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),r=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(r).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),NR=R(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),wR=R(([i,e])=>{const t=rt(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=rt(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=NR(i),i=r.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),RR=rt(C(1.6605,-.1246,-.0182),C(-.5876,1.1329,-.1006),C(-.0728,-.0083,1.1187)),ER=rt(C(.6274,.0691,.0164),C(.3293,.9195,.088),C(.0433,.0113,.8956)),AR=R(([i])=>{const e=C(i).toVar(),t=C(e.mul(e)).toVar(),r=C(t.mul(t)).toVar();return w(15.5).mul(r.mul(t)).sub(ae(40.14,r.mul(e))).add(ae(31.96,r).sub(ae(6.868,t.mul(e))).add(ae(.4298,t).add(ae(.1191,e).sub(.00232))))}),CR=R(([i,e])=>{const t=C(i).toVar(),r=rt(C(.856627153315983,.137318972929847,.11189821299995),C(.0951212405381588,.761241990602591,.0767994186031903),C(.0482516061458583,.101439036467562,.811302368396859)),s=rt(C(1.1271005818144368,-.1413297634984383,-.14132976349843826),C(-.11060664309660323,1.157823702216272,-.11060664309660294),C(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=w(-12.47393),o=w(4.026069);return t.mulAssign(e),t.assign(ER.mul(t)),t.assign(r.mul(t)),t.assign(st(t,1e-10)),t.assign(jr(t)),t.assign(t.sub(n).div(o.sub(n))),t.assign(hs(t,0,1)),t.assign(AR(t)),t.assign(s.mul(t)),t.assign(qa(st(C(0),t),C(2.2))),t.assign(RR.mul(t)),t.assign(hs(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),MR=R(([i,e])=>{const t=w(.76),r=w(.15);i=i.mul(e);const s=Ln(i.r,Ln(i.g,i.b)),n=Ut(s.lessThan(.08),s.sub(ae(6.25,s.mul(s))),.04);i.subAssign(n);const o=st(i.r,st(i.g,i.b));me(o.lessThan(t),()=>i);const a=xt(1,t),u=xt(1,a.mul(a).div(o.add(a.sub(t))));i.mulAssign(u.div(o));const l=xt(1,vr(1,r.mul(o.sub(u)).add(1)));return xe(i,C(u),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Fe extends J{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const s of t)s.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}class BR extends Fe{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return r===void 0&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,n=r.type,o=e.getCodeFromNode(this,n);s!==""&&(o.name=s);const a=e.getPropertyName(o),u=this.getNodeFunction(e).getCode(a);return o.code=u+` +`,t==="property"?a:e.format(`${a}()`,n,t)}}function md(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||je.z).negate()}const PR=R(([i,e],t)=>{const r=md(t);return nr(i,e,r)}),DR=R(([i],e)=>{const t=md(e);return i.mul(i,t,t).negate().exp().oneMinus()});R(([i,e],t)=>{const r=md(t),n=e.sub(On.y).max(0).toConst().mul(r).toConst();return i.mul(i,n,n).negate().exp().oneMinus()});const cf=R(([i,e])=>q(e.toFloat().mix(Ci.rgb,i.toVec3()),Ci.a));class FR extends J{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){const{scope:t}=this,{renderer:r}=e;r.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier +`):e.addLineFlowCode(`${t}Barrier()`,this)}}Pe(FR);class Rr extends J{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,n=this.getNodeType(e),o=this.getInputType(e),a=this.pointerNode,u=this.valueNode,l=[];l.push(`&${a.build(e,o)}`),u!==null&&l.push(u.build(e,o));const c=`${e.getMethod(s,n)}( ${l.join(", ")} )`;if(r?r.length===1&&r[0].isStackNode===!0:!1)e.addLineFlowCode(c,this);else return t.constNode===void 0&&(t.constNode=gr(c,n).toConst()),t.constNode.build(e)}}Rr.ATOMIC_LOAD="atomicLoad";Rr.ATOMIC_STORE="atomicStore";Rr.ATOMIC_ADD="atomicAdd";Rr.ATOMIC_SUB="atomicSub";Rr.ATOMIC_MAX="atomicMax";Rr.ATOMIC_MIN="atomicMin";Rr.ATOMIC_AND="atomicAnd";Rr.ATOMIC_OR="atomicOr";Rr.ATOMIC_XOR="atomicXor";Pe(Rr);class ye extends Xe{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),n=e.isMatrix(r)?0:e.getTypeLength(r);return s>n?t:r}generateNodeType(e){const t=this.method;return t===ye.SUBGROUP_ELECT?"bool":t===ye.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,s=this.getNodeType(e),n=this.getInputType(e),o=this.aNode,a=this.bNode,u=[];if(r===ye.SUBGROUP_BROADCAST||r===ye.SUBGROUP_SHUFFLE||r===ye.QUAD_BROADCAST){const c=a.getNodeType(e);u.push(o.build(e,s),a.build(e,c==="float"?"int":s))}else r===ye.SUBGROUP_SHUFFLE_XOR||r===ye.SUBGROUP_SHUFFLE_DOWN||r===ye.SUBGROUP_SHUFFLE_UP?u.push(o.build(e,s),a.build(e,"uint")):(o!==null&&u.push(o.build(e,n)),a!==null&&u.push(a.build(e,n)));const l=u.length===0?"()":`( ${u.join(", ")} )`;return e.format(`${e.getMethod(r,s)}${l}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}ye.SUBGROUP_ELECT="subgroupElect";ye.SUBGROUP_BALLOT="subgroupBallot";ye.SUBGROUP_ADD="subgroupAdd";ye.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";ye.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";ye.SUBGROUP_MUL="subgroupMul";ye.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";ye.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";ye.SUBGROUP_AND="subgroupAnd";ye.SUBGROUP_OR="subgroupOr";ye.SUBGROUP_XOR="subgroupXor";ye.SUBGROUP_MIN="subgroupMin";ye.SUBGROUP_MAX="subgroupMax";ye.SUBGROUP_ALL="subgroupAll";ye.SUBGROUP_ANY="subgroupAny";ye.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";ye.QUAD_SWAP_X="quadSwapX";ye.QUAD_SWAP_Y="quadSwapY";ye.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";ye.SUBGROUP_BROADCAST="subgroupBroadcast";ye.SUBGROUP_SHUFFLE="subgroupShuffle";ye.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor";ye.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp";ye.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown";ye.QUAD_BROADCAST="quadBroadcast";let Mo;function Za(i){Mo=Mo||new WeakMap;let e=Mo.get(i);return e===void 0&&Mo.set(i,e={}),e}function yd(i){const e=Za(i);return e.shadowMatrix||(e.shadowMatrix=K("mat4").setGroup(Z).onRenderUpdate(t=>((i.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(i.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(i.shadow.camera.coordinateSystem=t.camera.coordinateSystem,i.shadow.camera.updateProjectionMatrix()),i.shadow.updateMatrices(i)),i.shadow.matrix)))}function LR(i,e=On){const t=yd(i).mul(e);return t.xyz.div(t.w)}function ay(i){const e=Za(i);return e.position||(e.position=K(new V).setGroup(Z).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(i.matrixWorld)))}function UR(i){const e=Za(i);return e.targetPosition||(e.targetPosition=K(new V).setGroup(Z).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(i.target.matrixWorld)))}function uy(i){const e=Za(i);return e.viewPosition||(e.viewPosition=K(new V).setGroup(Z).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new V,r.value.setFromMatrixPosition(i.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}const ly=i=>Hn.transformDirection(ay(i).sub(UR(i))),OR=gs("vec3","totalDiffuse"),IR=gs("vec3","totalSpecular"),kR=gs("vec3","outgoingLight"),GR=i=>i.sort((e,t)=>e.id-t.id),VR=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},Hu=new WeakMap,ci=[];class cy extends J{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=OR,this.totalSpecularNode=IR,this.outgoingLightNode=kR,this._lights=[],this.global=!0}customCacheKey(){const e=this._lights;for(let r=0;r0}}class $R extends J{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=re.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){dy.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||On)}}const dy=gs("vec3","shadowPositionWorld");function zR(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new Kt),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function WR(i,e){return e=zR(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function jR(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function HR(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function qR(i,e){return e=HR(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function XR(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function KR(i,e,t){return t=WR(i,t),t=qR(e,t),t}function YR(i,e,t){jR(i,t),XR(e,t)}const Ba=new WeakMap,QR=R(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let r=Ne(i,e.xy).setName("t_basic");return i.isArrayTexture&&(r=r.depth(t)),r.compare(e.z)}),ZR=R(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:r})=>{const s=(c,d)=>{let h=Ne(i,c);return i.isArrayTexture&&(h=h.depth(r)),h.compare(d)},n=Me("mapSize","vec2",t).setGroup(Z),o=Me("radius","float",t).setGroup(Z),a=ee(1).div(n),u=o.mul(a.x),l=oy(jn.xy).mul(6.28318530718);return Rt(s(e.xy.add(mr(0,5,l).mul(u)),e.z),s(e.xy.add(mr(1,5,l).mul(u)),e.z),s(e.xy.add(mr(2,5,l).mul(u)),e.z),s(e.xy.add(mr(3,5,l).mul(u)),e.z),s(e.xy.add(mr(4,5,l).mul(u)),e.z)).mul(1/5)}),JR=R(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:r})=>{const s=Me("mapSize","vec2",t).setGroup(Z),n=ee(1).div(s),o=e.xy,a=Sr(o.mul(s).add(.5)).toConst();o.subAssign(a.sub(.5).mul(n));const u=f=>{let p=Ne(i,o).offset(f).gather();return i.isArrayTexture&&(p=p.depth(r)),p.compare(e.z)},l=u(Nt(-1,1)).toConst(),c=u(Nt(1,1)).toConst(),d=u(Nt(-1,-1)).toConst(),h=u(Nt(1,-1)).toConst();return Rt(xe(l.x,c.y,a.x).add(l.y).add(c.x).mul(a.y),xe(l.w,c.z,a.x).add(l.z).add(c.w),xe(d.x,h.y,a.x).add(d.y).add(h.x),xe(d.w,h.z,a.x).add(d.z).add(h.w).mul(a.y.oneMinus())).mul(1/9)}),eE=R(({depthTexture:i,shadowCoord:e,depthLayer:t},r)=>{let s=Ne(i).sample(e.xy);i.isArrayTexture&&(s=s.depth(t)),s=s.rg;const n=s.x,o=st(1e-7,s.y.mul(s.y)),a=r.renderer.reversedDepthBuffer?ki(n,e.z):ki(e.z,n),u=w(1).toVar();return me(a.notEqual(1),()=>{const l=e.z.sub(n);let c=o.div(o.add(l.mul(l)));c=hs(xt(c,.3).div(.65)),u.assign(st(a,c))}),u}),tE=i=>{let e=Ba.get(i);return e===void 0&&(e=new qe,e.colorNode=q(0,0,0,1),e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.blending=Wr,e.fog=!1,Ba.set(i,e)),e},rE=i=>{const e=Ba.get(i);e!==void 0&&(e.dispose(),Ba.delete(i))},df=new fs,sn=[],sE=(i,e,t,r)=>{sn[0]=i,sn[1]=e;let s=df.get(sn);return(s===void 0||s.shadowType!==t||s.useVelocity!==r)&&(s=(n,o,a,u,l,c,d,h,f)=>{(n.castShadow===!0||n.receiveShadow&&t===Ni)&&(r&&(gg(n).useVelocity=!0),n.onBeforeShadow(i,n,a,e.camera,u,o.overrideMaterial,c),i.renderObject(n,o,a,u,l,c,d,h,f),n.onAfterShadow(i,n,a,e.camera,u,o.overrideMaterial,c))},s.shadowType=t,s.useVelocity=r,df.set(sn,s)),sn[0]=null,sn[1]=null,s},nE=R(({samples:i,radius:e,size:t,shadowPass:r,depthLayer:s})=>{const n=w(0).toVar("meanVertical"),o=w(0).toVar("squareMeanVertical"),a=i.lessThanEqual(w(1)).select(w(0),w(2).div(i.sub(1))),u=i.lessThanEqual(w(1)).select(w(0),w(-1));$t({start:Ue(0),end:Ue(i),type:"int",condition:"<"},({i:c})=>{const d=u.add(w(c).mul(a));let h=r.sample(Rt(jn.xy,ee(0,d).mul(e)).div(t));r.value.isArrayTexture&&(h=h.depth(s)),h=h.x,n.addAssign(h),o.addAssign(h.mul(h))}),n.divAssign(i),o.divAssign(i);const l=ds(o.sub(n.mul(n)).max(0));return ee(n,l)}),iE=R(({samples:i,radius:e,size:t,shadowPass:r,depthLayer:s})=>{const n=w(0).toVar("meanHorizontal"),o=w(0).toVar("squareMeanHorizontal"),a=i.lessThanEqual(w(1)).select(w(0),w(2).div(i.sub(1))),u=i.lessThanEqual(w(1)).select(w(0),w(-1));$t({start:Ue(0),end:Ue(i),type:"int",condition:"<"},({i:c})=>{const d=u.add(w(c).mul(a));let h=r.sample(Rt(jn.xy,ee(d,0).mul(e)).div(t));r.value.isArrayTexture&&(h=h.depth(s)),n.addAssign(h.x),o.addAssign(Rt(h.y.mul(h.y),h.x.mul(h.x)))}),n.divAssign(i),o.divAssign(i);const l=ds(o.sub(n.mul(n)).max(0));return ee(n,l)}),oE=[QR,ZR,JR,eE];let qu;const Bo=new iy;class hy extends $R{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:n,depthLayer:o}){const a=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),u=t({depthTexture:r,shadowCoord:s,shadow:n,depthLayer:o});return a.select(u,w(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,n=r.biasNode||Me("bias","float",r).setGroup(Z);let o=t,a;if(r.camera.isOrthographicCamera||s.logarithmicDepthBuffer!==!0)o=o.xyz.div(o.w),a=o.z;else{const u=o.w;o=o.xy.div(u);const l=Me("near","float",r.camera).setGroup(Z),c=Me("far","float",r.camera).setGroup(Z);a=fd(u.negate(),l,c)}return o=C(o.x,o.y.oneMinus(),s.reversedDepthBuffer?a.sub(n):a.add(n)),o}getShadowFilterFn(e){return oE[e]}setupRenderTarget(e,t){const r=new xr(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?Pn:Zi;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t,camera:r}=e,{light:s,shadow:n}=this,{depthTexture:o,shadowMap:a}=this.setupRenderTarget(n,e),u=t.shadowMap.type,l=t.hasCompatibility(js.TEXTURE_COMPARE);if((u===ap||u===a_)&&l?(o.minFilter=yt,o.magFilter=yt):(o.minFilter=Lt,o.magFilter=Lt),n.camera.coordinateSystem=r.coordinateSystem,n.camera.updateProjectionMatrix(),u===Ni&&n.isPointLightShadow!==!0){o.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:tr,type:ht,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:tr,type:ht,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:tr,type:ht,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(n.mapSize.width,n.mapSize.height,{format:tr,type:ht,depthBuffer:!1}));let v=Ne(o);o.isArrayTexture&&(v=v.depth(this.depthLayer));let S=Ne(this.vsmShadowMapVertical.texture);o.isArrayTexture&&(S=S.depth(this.depthLayer));const P=Me("blurSamples","float",n).setGroup(Z),F=Me("radius","float",n).setGroup(Z),U=Me("mapSize","vec2",n).setGroup(Z);let W=this.vsmMaterialVertical||(this.vsmMaterialVertical=new qe);W.fragmentNode=nE({samples:P,radius:F,size:U,shadowPass:v,depthLayer:this.depthLayer}).context(e.getSharedContext()),W.name="VSMVertical",W=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new qe),W.fragmentNode=iE({samples:P,radius:F,size:U,shadowPass:S,depthLayer:this.depthLayer}).context(e.getSharedContext()),W.name="VSMHorizontal"}const c=Me("intensity","float",n).setGroup(Z),d=Me("normalBias","float",n).setGroup(Z),h=yd(s),f=qn.mul(d);let p;!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?p=h.mul(dy.add(f)):p=K("mat4").onObjectUpdate(({object:S},P)=>P.value.multiplyMatrices(h.value,S.matrixWorld)).mul(Qe).add(h.mul(q(f,0)));const g=this.setupShadowCoord(e,p),m=n.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(m===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const y=u===Ni&&n.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:o,x=this.setupShadowFilter(e,{filterFn:m,shadowTexture:a.texture,depthTexture:y,shadowCoord:g,shadow:n,depthLayer:this.depthLayer});let _;t.shadowMap.transmitted===!0&&(a.texture.isCubeTexture?_=vt(a.texture,g.xyz):(_=Ne(a.texture,g),o.isArrayTexture&&(_=_.depth(this.depthLayer))));let N;_?N=xe(1,x.rgb.mix(_,1),c.mul(_.a)).toVar():N=xe(1,x,c).toVar(),this.shadowMap=a,this.shadow.map=a;const A=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return _&&N.toInspector(`${A} / Color`,()=>this.shadowMap.texture.isCubeTexture?vt(this.shadowMap.texture,Ph()):Ne(this.shadowMap.texture)),N.toInspector(`${A} / Depth`,()=>{const v=Me("near","float",this.shadow.camera),S=Me("far","float",this.shadow.camera);let P;this.shadowMap.texture.isCubeTexture?P=vt(this.shadowMap.depthTexture,Ph()).r:P=Ne(this.shadowMap.depthTexture).r;let F;return this.shadow.camera.isPerspectiveCamera?F=hd(P,v,S):F=QS(P,v,S),F=Cn(F,v,S),F.oneMinus()})}setup(e){if(e.renderer.shadowMap.enabled!==!1)return R(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),r===null&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:n,scene:o}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);const a=o.name;o.name=`Shadow Map [ ${s.name||"ID: "+s.id} ]`,n.render(o,t.camera),o.name=a}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:n,scene:o,camera:a}=e,u=n.shadowMap.type,l=t.depthTexture.version;this._depthVersionCached=l;const c=s.camera.layers.mask;(s.camera.layers.mask&4294967294)===0&&(s.camera.layers.mask=a.layers.mask);const d=n.getRenderObjectFunction(),h=n.getMRT(),f=h?h.has("velocity"):!1;qu=KR(n,o,qu),o.overrideMaterial=tE(r),n.setRenderObjectFunction(sE(n,s,u,f)),n.setClearColor(0,0),n.setRenderTarget(t),this.renderShadow(e),n.setRenderObjectFunction(d),u===Ni&&s.isPointLightShadow!==!0&&this.vsmPass(n),s.camera.layers.mask=c,YR(n,o,qu)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Bo.material=this.vsmMaterialVertical,Bo.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Bo.material=this.vsmMaterialHorizontal,Bo.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,rE(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const aE=(i,e)=>new hy(i,e),uE=new Kt,hf=new At,di=new V,Xu=new V,lE=[new V(1,0,0),new V(-1,0,0),new V(0,-1,0),new V(0,1,0),new V(0,0,1),new V(0,0,-1)],cE=[new V(0,-1,0),new V(0,-1,0),new V(0,0,-1),new V(0,0,1),new V(0,-1,0),new V(0,-1,0)],dE=[new V(1,0,0),new V(-1,0,0),new V(0,1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1)],hE=[new V(0,-1,0),new V(0,-1,0),new V(0,0,1),new V(0,0,-1),new V(0,-1,0),new V(0,-1,0)],fE=R(({depthTexture:i,bd3D:e,dp:t})=>vt(i,e).compare(t)),pE=R(({depthTexture:i,bd3D:e,dp:t,shadow:r})=>{const s=Me("radius","float",r).setGroup(Z),n=Me("mapSize","vec2",r).setGroup(Z),o=s.div(n.x),a=Ft(e),u=Ht($s(e,a.x.greaterThan(a.z).select(C(0,1,0),C(1,0,0)))),l=$s(e,u),c=oy(jn.xy).mul(6.28318530718),d=mr(0,5,c),h=mr(1,5,c),f=mr(2,5,c),p=mr(3,5,c),g=mr(4,5,c);return vt(i,e.add(u.mul(d.x).add(l.mul(d.y)).mul(o))).compare(t).add(vt(i,e.add(u.mul(h.x).add(l.mul(h.y)).mul(o))).compare(t)).add(vt(i,e.add(u.mul(f.x).add(l.mul(f.y)).mul(o))).compare(t)).add(vt(i,e.add(u.mul(p.x).add(l.mul(p.y)).mul(o))).compare(t)).add(vt(i,e.add(u.mul(g.x).add(l.mul(g.y)).mul(o))).compare(t)).mul(1/5)}),gE=R(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:r},s)=>{const n=t.xyz.toConst(),o=n.abs().toConst(),a=o.x.max(o.y).max(o.z),u=K("float").setGroup(Z).onRenderUpdate(()=>r.camera.near),l=K("float").setGroup(Z).onRenderUpdate(()=>r.camera.far),c=Me("bias","float",r).setGroup(Z),d=w(1).toVar();return me(a.sub(l).lessThanEqual(0).and(a.sub(u).greaterThanEqual(0)),()=>{let h;s.renderer.reversedDepthBuffer?(h=ZS(a.negate(),u,l),h.subAssign(c)):s.renderer.logarithmicDepthBuffer?(h=fd(a.negate(),u,l),h.addAssign(c)):(h=Dm(a.negate(),u,l),h.addAssign(c));const f=n.normalize();d.assign(i({depthTexture:e,bd3D:f,dp:h,shadow:r}))}),d});class mE extends hy{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===n_?fE:pE}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:n}){return gE({filterFn:t,depthTexture:r,shadowCoord:s,shadow:n})}setupRenderTarget(e,t){const r=new i_(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?Pn:Zi;const s=t.createCubeRenderTarget(e.mapSize.width);return s.texture.name="PointShadowMap",s.depthTexture=r,{shadowMap:s,depthTexture:r}}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:n,scene:o}=e,a=t.camera,u=t.matrix,l=n.coordinateSystem===Ui,c=l?lE:dE,d=l?cE:hE;r.setSize(t.mapSize.width,t.mapSize.width);const h=n.autoClear,f=n.getClearColor(uE),p=n.getClearAlpha();n.autoClear=!1,n.setClearColor(t.clearColor,t.clearAlpha);for(let g=0;g<6;g++){n.setRenderTarget(r,g),n.clear();const m=s.distance||a.far;m!==a.far&&(a.far=m,a.updateProjectionMatrix()),di.setFromMatrixPosition(s.matrixWorld),a.position.copy(di),Xu.copy(a.position),Xu.add(c[g]),a.up.copy(d[g]),a.lookAt(Xu),a.updateMatrixWorld(),u.makeTranslation(-di.x,-di.y,-di.z),hf.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),t._frustum.setFromProjectionMatrix(hf,a.coordinateSystem,a.reversedDepth);const y=o.name;o.name=`Point Light Shadow [ ${s.name||"ID: "+s.id} ] - Face ${g+1}`,n.render(o,a),o.name=y}n.autoClear=h,n.setClearColor(f,p)}}const yE=(i,e)=>new mE(i,e);class Ys extends Xn{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Kt,this.colorNode=e&&e.colorNode||K(this.color).setGroup(Z),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=re.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return uy(this.light).sub(e.context.positionView||je)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return aE(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){const s=this.light.shadow.shadowNode;let n;s!==void 0?n=H(s):n=this.setupShadowNode(),this.shadowNode=n,this.shadowColorNode=r=this.colorNode.mul(n),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const fy=R(({lightDistance:i,cutoffDistance:e,decayExponent:t})=>{const r=i.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(r.mul(i.div(e).pow4().oneMinus().clamp().pow2()),r)}),bE=({color:i,lightVector:e,cutoffDistance:t,decayExponent:r})=>{const s=e.normalize(),n=e.length(),o=fy({lightDistance:n,cutoffDistance:t,decayExponent:r}),a=i.mul(o);return{lightDirection:s,lightColor:a}};class _E extends Ys{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=K(0).setGroup(Z),this.decayExponentNode=K(2).setGroup(Z)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return yE(this.light)}setupDirect(e){return bE({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}R(([i=Xs()],{renderer:e,material:t})=>{const r=zg(i.mul(2).sub(1));let s;if(t.alphaToCoverage&&e.currentSamples>0){const n=w(r.fwidth()).toVar();s=nr(n.oneMinus(),n.add(1),r).oneMinus()}else s=Ut(r.greaterThan(1),0,1);return s});const xE=R(([i,e])=>{const t=i.x,r=i.y,s=i.z;let n=e.element(0).mul(.886227);return n=n.add(e.element(1).mul(2*.511664).mul(r)),n=n.add(e.element(2).mul(2*.511664).mul(s)),n=n.add(e.element(3).mul(2*.511664).mul(t)),n=n.add(e.element(4).mul(2*.429043).mul(t).mul(r)),n=n.add(e.element(5).mul(2*.429043).mul(r).mul(s)),n=n.add(e.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),n=n.add(e.element(7).mul(2*.429043).mul(t).mul(s)),n=n.add(e.element(8).mul(.429043).mul(ae(t,t).sub(ae(r,r)))),n}),Yt=new gd;class TE extends ms{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,n=this.nodes.getBackgroundNode(e)||e.background;let o=!1;if(n===null)s._clearColor.getRGB(Yt),Yt.a=s._clearColor.a;else if(n.isColor===!0)n.getRGB(Yt),Yt.a=1,o=!0;else if(n.isNode===!0){const u=this.get(e),l=n;Yt.copy(s._clearColor);let c=u.backgroundMesh;if(c===void 0){let _=function(){n.removeEventListener("dispose",_),c.material.dispose(),c.geometry.dispose()};const h=q(l).mul(uf).context({getUV:()=>_R.mul(E0),getTextureLevel:()=>bR}),f=rr.element(3).element(3).equal(1),p=vr(1,rr.element(1).element(1)).mul(3),g=f.select(Qe.mul(p),Qe),m=Ws.mul(q(g,0));let y=rr.mul(q(m.xyz,1));y=y.setZ(y.w);const x=new qe;x.name="Background.material",x.side=ft,x.depthTest=!1,x.depthWrite=!1,x.allowOverride=!1,x.fog=!1,x.lights=!1,x.vertexNode=y,x.colorNode=h,u.backgroundMeshNode=h,u.backgroundMesh=c=new sr(new Rc(1,32,32),x),c.frustumCulled=!1,c.name="Background.mesh",n.addEventListener("dispose",_)}const d=l.getCacheKey();u.backgroundCacheKey!==d&&(u.backgroundMeshNode.node=q(l).mul(uf),u.backgroundMeshNode.needsUpdate=!0,c.material.needsUpdate=!0,u.backgroundCacheKey=d),t.unshift(c,c.geometry,c.material,0,0,null,null)}else O("Renderer: Unsupported background configuration.",n);const a=s.xr.getEnvironmentBlendMode();if(a==="additive"?Yt.set(0,0,0,1):a==="alpha-blend"&&Yt.set(0,0,0,0),s.autoClear===!0||o===!0){const u=r.clearColorValue;u.r=Yt.r,u.g=Yt.g,u.b=Yt.b,u.a=Yt.a,(s.backend.isWebGLBackend===!0||s.alpha===!0)&&(u.r*=u.a,u.g*=u.a,u.b*=u.a),r.depthClearValue=s.getClearDepth(),r.stencilClearValue=s.getClearStencil(),r.clearColor=s.autoClearColor===!0,r.clearDepth=s.autoClearDepth===!0,r.clearStencil=s.autoClearStencil===!0}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let vE=0;class yc{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=vE++}}class SE{constructor(e,t,r,s,n,o,a,u,l,c,d=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=d,this.nodeAttributes=s,this.bindings=n,this.updateNodes=o,this.updateBeforeNodes=a,this.updateAfterNodes=u,this.observer=l,this.hardwareClipping=c,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const s=new yc(t.name,[]);e.push(s);for(const n of t.bindings)s.bindings.push(n.clone())}else e.push(t);return e}}class ff{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class NE{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class py{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class wE extends py{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class RE{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let EE=0;class Ku{constructor(e=null){this.id=EE++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class AE{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class ys{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class CE extends ys{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class ME extends ys{constructor(e,t=new ce){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class BE extends ys{constructor(e,t=new V){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class PE extends ys{constructor(e,t=new He){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class DE extends ys{constructor(e,t=new Kt){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class FE extends ys{constructor(e,t=new Wp){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class LE extends ys{constructor(e,t=new Qi){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class UE extends ys{constructor(e,t=new At){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class OE extends CE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class IE extends ME{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class kE extends BE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class GE extends PE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class VE extends DE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class $E extends FE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class zE extends LE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class WE extends UE{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let jE=0;const pf=new WeakMap,gf=new WeakMap,HE=new WeakMap,qE=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Po=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0")),gy=i=>{if(i.writeUsageCount>0)return!0;if(i.subBuildsCache!==void 0){for(const e in i.subBuildsCache)if(gy(i.subBuildsCache[e]))return!0}return!1};class my{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=zu(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Ku,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:jE++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute("normal")===!1}isOpaque(){const e=this.material;return e.transparent===!1&&e.blending===Fr&&e.alphaToCoverage===!1}createRenderTarget(e,t,r){return new ps(e,t,r)}createCubeRenderTarget(e,t){return new Im(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t="vec4";const r=this.renderer.getRenderTarget();if(r!==null){const s=r.textures[e].type,n=r.textures[e].format;let o="vec";s===Ze?o="ivec":s===Ge&&(o="uvec"),n===qi||n===Xi?s===Ze?t="int":s===Ge?t="uint":t="float":n===tr||n===Ki?t=`${o}2`:n===Yi||n===Mc?t=`${o}3`:t=`${o}4`}return t}getOutputStructName(){}_getBindGroup(e,t){const r=t[0].groupNode;let s=r.shared;if(s)for(let o=1;od.nodeUniform.node.id-h.nodeUniform.node.id);for(const d of c.uniforms)o+=d.nodeUniform.node.id}else o+=c.nodeUniform.id;const a=this.renderer._currentRenderContext||this.renderer;let u=pf.get(a);u===void 0&&(u=new Map,pf.set(a,u));const l=Vn(o);n=u.get(l),n===void 0&&(n=new yc(e,t),u.set(l,n))}else n=new yc(e,t);return n}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return s===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(e===null){const t={},r=this.bindings;for(const s of vu)for(const n in r[s]){const o=r[s][n],a=t[n]||(t[n]=[]);for(const u of o)a.includes(u)===!1&&a.push(u)}e=[];for(const s in t){const n=t[s],o=this._getBindGroup(s,n);e.push(o)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,r)=>t.bindings[0].groupNode.order-r.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Po(t.r)}, ${Po(t.g)}, ${Po(t.b)} )`;const r=this.getTypeLength(e),s=this.getComponentType(e),n=o=>this.generateConst(s,o);if(r===2)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)} )`;if(r===3)return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)} )`;if(r===4&&e!=="mat2")return`${this.getType(e)}( ${n(t.x)}, ${n(t.y)}, ${n(t.z)}, ${n(t.w)} )`;if(r>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(n).join(", ")} )`;if(r>4)return`${this.getType(e)}()`;throw new Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const r=this.attributes;for(const n of r)if(n.name===e)return n;const s=new ff(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;return e.isDepthTexture===!0?"float":t===Ze?"int":t===Ge?"uint":"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let r=pg(e);const s=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return qE.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,n=e.normalized;let o;return!(e instanceof zp)&&n!==!0&&(o=this.getTypeFromArray(r)),this.getTypeFromLength(s,o)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return r!==null?Number(r[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw new Error("THREE.NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=zu(this.stack);const e=xg();return this.stacks.push(e),wa(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){const r=this.getDataFromNode(t);r.stack=e}return this.stack=e.parent,wa(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){r=r===null?e.isGlobal(this)?this.globalCache:this.cache:r;let s=r.getData(e);s===void 0&&(s={},r.setData(e,s)),s[t]===void 0&&(s[t]={});let n=s[t];if(this.subBuildLayers.length===0)return n;const o=s.any?s.any.subBuilds:null,a=this.getClosestSubBuild(o);return a&&(n.subBuildsCache===void 0&&(n.subBuildsCache={}),n=n.subBuildsCache[a]||(n.subBuildsCache[a]={}),n.subBuilds=o),n}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t,r=null){const s=this.getDataFromNode(e,"vertex");let n=s.bufferAttribute;if(n===void 0){const o=this.uniforms.index++;r===null&&(r="nodeAttribute"+o),n=new ff(r,t,e),this.bufferAttributes.push(n),s.bufferAttribute=n}return n}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const n=this.getDataFromNode(e,s,this.globalCache);let o=n.structType;if(o===void 0){const a=this.structs.index++;r===null&&(r="StructType"+a),o=new AE(r,t),this.structs[s].push(o),this.types[s][r]=e,n.structType=o}return o}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const n=this.getDataFromNode(e,r,this.globalCache);let o=n.uniform;if(o===void 0){const a=this.uniforms.index++;o=new NE(s||"nodeUniform"+a,t,e),this.uniforms[r].push(o),this.registerDeclaration(o),n.uniform=o}return o}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,n=!1){const o=this.getDataFromNode(e,s),a=this.getSubBuildProperty("variable",o.subBuilds);let u=o[a];if(u===void 0){const l=n?"_const":"_var",c=this.vars[s]||(this.vars[s]=[]),d=this.vars[l]||(this.vars[l]=0);t===null&&(t=(n?"nodeConst":"nodeVar")+d,this.vars[l]++),a!=="variable"&&(t=this.getSubBuildProperty(t,o.subBuilds));const h=e.getArrayCount(this);u=new py(t,r,n,h),n||c.push(u),this.registerDeclaration(u),o[a]=u}return u}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(const t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,n=null){const o=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",o.subBuilds);let u=o[a];if(u===void 0){const l=this.varyings,c=l.length;t===null&&(t="nodeVarying"+c),a!=="varying"&&(t=this.getSubBuildProperty(t,o.subBuilds)),u=new wE(t,r,s,n),l.push(u),this.registerDeclaration(u),o[a]=u}return u}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=e.name;let n=s,o=this.getPropertyName(e),a=1;for(;r[o]!==void 0;)n=s+"_"+a++,e.name=n,o=this.getPropertyName(e);n!==s&&z(`TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${n}'.`),r[o]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let n=s.code;if(n===void 0){const o=this.codes[r]||(this.codes[r]=[]),a=o.length;n=new RE("nodeCode"+a,t),o.push(n),s.code=n}return n}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let n=!0,o=t;for(;o;){if(s.get(o)===!0){n=!1;break}o=this.getDataFromNode(o).parentNodeBlock}if(n)for(const a of r)this.addLineFlowCode(a)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),n=s.flowCodes||(s.flowCodes=[]),o=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);n.push(t),o.set(r,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; +`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=this.renderer.backend;let r=gf.get(t);r===void 0&&(r=new WeakMap,gf.set(t,r));let s=r.get(e);if(s===void 0){s=new BR;const n=this.currentFunctionNode;this.currentFunctionNode=s,s.code=this.buildFunctionCode(e),this.currentFunctionNode=n,r.set(e,s)}return s}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let o=0;const a=Object.values(this);return{next:()=>({value:a[o],done:o++>=a.length})}}};for(const o of t.inputs)r[o.name]=new dR(o.type,o.name);e.layout=null;const s=e.call(r),n=this.flowStagesNode(s,t.type);return e.layout=t,n}flowBuildStage(e,t,r=null){const s=this.getBuildStage();this.setBuildStage(t);const n=e.build(this,r);return this.setBuildStage(s),n}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,n=this.declarations,o=this.cache,a=this.buildStage,u=this.stack,l={code:""};this.flow=l,this.vars={},this.declarations={},this.cache=new Ku,this.stack=zu();for(const c of Tu)this.setBuildStage(c),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=n,this.cache=o,this.stack=u,this.setBuildStage(a),l}getFunctionOperator(){return null}buildFunctionCode(){z("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const n=this.tab,o=this.cache,a=this.shaderStage,u=this.context;this.setShaderStage(e);const l={...this.context};delete l.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=l;let c=null;if(this.buildStage==="generate"){const d=this.flowChildNode(t,r);s!==null&&(d.code+=`${this.tab+s} = ${d.result}; +`),this.flowCode[e]=this.flowCode[e]+d.code,c=d}else c=t.build(this);return this.setShaderStage(a),this.cache=o,this.tab=n,this.context=u,c}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){z("Abstract function.")}getVaryings(){z("Abstract function.")}getVar(e,t,r=null){return`${r!==null?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e,t=!1){const r=[],s=this.vars[e];if(s!==void 0)for(const n of s)r.push(`${this.getVar(n.type,n.name,n.count)};`);return r.join(t?` +`:` + `)}getUniforms(){z("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(t!==void 0)for(const s of t)r+=s.code+` +`;return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){z("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;const r=this.subBuildLayers;for(let s=t.length-1;s>=0;s--){const n=t[s];if(r.includes(n))return n}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r;t!==null?r=this.getClosestSubBuild(t):r=this.subBuildFn;let s;return r?s=e?r+"_"+e:r:s=e,s}prebuild(){const{object:e,renderer:t,material:r}=this;if(t.contextNode.isContextNode===!0?this.context={...this.context,...t.contextNode.getFlowContextData()}:O('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(r.contextNode.isContextNode===!0?this.context={...this.context,...r.contextNode.getFlowContextData()}:O('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),r!==null){let s=t.library.fromMaterial(r);s===null&&(O(`NodeBuilder: Material "${r.type}" is not compatible.`),s=new qe),s.build(this)}else this.addFlow("compute",e)}build(){this.prebuild();for(const e of Tu){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of vu){this.setShaderStage(t);const r=this.flowNodes[t];for(const s of r)e==="generate"?this.flowNode(s):s.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(const e of Tu){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of vu){this.setShaderStage(t);const r=this.flowNodes[t];for(const s of r)e==="generate"?this.flowNode(s):s.build(this);await up()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=HE.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){const r=this.getSharedDataFromNode(e);let s=r.cache;if(s===void 0){if(t==="float"||t==="int"||t==="uint")s=new OE(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")s=new IE(e);else if(t==="vec3"||t==="ivec3"||t==="uvec3")s=new kE(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")s=new GE(e);else if(t==="color")s=new VE(e);else if(t==="mat2")s=new $E(e);else if(t==="mat3")s=new zE(e);else if(t==="mat4")s=new WE(e);else throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);r.cache=s}return s}format(e,t,r){if(t=this.getVectorType(t),r=this.getVectorType(r),t===r||r===null||this.isReference(r))return e;const s=this.getTypeLength(t),n=this.getTypeLength(r);return s===16&&n===9?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:s===9&&n===4?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||n>4||n===0?e:s===n?`${this.getType(r)}( ${e} )`:s>n?(e=r==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,n)}`,this.format(e,this.getTypeFromLength(n,this.getComponentType(t)),r)):n===4&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:s===2?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(s===1&&n>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${ka} - Node System +`}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||gg(this.object).useVelocity===!0}}class mf{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return r===void 0&&(r={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===re.FRAME){const s=this._getMaps(this.updateBeforeMap,r);if(s.frameId!==this.frameId){const n=s.frameId;s.frameId=this.frameId,e.updateBefore(this)===!1&&(s.frameId=n)}}else if(t===re.RENDER){const s=this._getMaps(this.updateBeforeMap,r);if(s.renderId!==this.renderId){const n=s.renderId;s.renderId=this.renderId,e.updateBefore(this)===!1&&(s.renderId=n)}}else t===re.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===re.FRAME){const s=this._getMaps(this.updateAfterMap,r);s.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(s.frameId=this.frameId)}else if(t===re.RENDER){const s=this._getMaps(this.updateAfterMap,r);s.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(s.renderId=this.renderId)}else t===re.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===re.FRAME){const s=this._getMaps(this.updateMap,r);s.frameId!==this.frameId&&e.update(this)!==!1&&(s.frameId=this.frameId)}else if(t===re.RENDER){const s=this._getMaps(this.updateMap,r);s.renderId!==this.renderId&&e.update(this)!==!1&&(s.renderId=this.renderId)}else t===re.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class bd{constructor(e,t,r=null,s="",n=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=n}}bd.isNodeFunctionInput=!0;class XE extends Ys{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class KE extends Ys{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:ly(this.light),lightColor:e}}}class YE extends Ys{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=ay(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=K(new Kt).setGroup(Z)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:s}=this,o=qn.dot(s).mul(.5).add(.5),a=xe(r,t,o);e.context.irradiance.addAssign(a)}}class _d extends Ys{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=K(0).setGroup(Z),this.penumbraCosNode=K(0).setGroup(Z),this.cutoffDistanceNode=K(0).setGroup(Z),this.decayExponentNode=K(0).setGroup(Z),this.colorNode=K(this.color).setGroup(Z)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:s}=this;return nr(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return r===void 0&&(r=LR(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:n}=this,o=this.getLightVector(e),a=o.normalize(),u=a.dot(ly(n)),l=this.getSpotAttenuation(e,u),c=o.length(),d=fy({lightDistance:c,cutoffDistance:r,decayExponent:s});let h=t.mul(l).mul(d),f,p;return n.colorNode?(p=this.getLightCoord(e),f=n.colorNode(p)):n.map&&(p=this.getLightCoord(e),f=Ne(n.map,p.xy).onRenderUpdate(()=>n.map)),f&&(h=p.mul(2).sub(1).abs().lessThan(1).all().select(h.mul(f),h)),{lightColor:h,lightDirection:a}}}class QE extends _d{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&r.isTexture===!0){const n=t.acos().mul(1/Math.PI);this._iesTextureNode=Ne(r,ee(n,0),0),s=this._iesTextureNode.r}else s=super.getSpotAttenuation(e,t);return s}update(e){super.update(e),this._iesTextureNode!==null&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}class ZE extends Ys{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let r=0;r<9;r++)t.push(new V);this.lightProbe=Tt(t)}update(e){const{light:t}=this;super.update(e);for(let r=0;r<9;r++)this.lightProbe.array[r].copy(t.sh.coefficients[r]).multiplyScalar(t.intensity)}setup(e){const t=xE(qn,this.lightProbe);e.context.irradiance.addAssign(t)}}const JE=R(([i,e])=>{const t=i.abs().sub(e);return Hr(st(t,0)).add(Ln(st(t.x,t.y),0))});class eA extends _d{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let r=1;t.map!==null&&(r=t.map.width/t.map.height),t.shadow.aspect=r}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=w(0),r=this.penumbraCosNode,s=yd(this.light).mul(e.context.positionWorld||On);return me(s.w.greaterThan(0),()=>{const n=s.xyz.div(s.w),o=JE(n.xy.sub(ee(.5)),ee(.5)),a=vr(-1,xt(1,Lg(r)).sub(1));t.assign(td(o.mul(-2).mul(a)))}),t}}const Yu=new At,Do=new At;let hi=null;class tA extends Ys{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=K(new V).setGroup(Z),this.halfWidth=K(new V).setGroup(Z),this.updateType=re.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;Do.identity(),Yu.copy(t.matrixWorld),Yu.premultiply(r),Do.extractRotation(Yu),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Do),this.halfHeight.value.applyMatrix4(Do)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=Ne(hi.LTC_FLOAT_1),r=Ne(hi.LTC_FLOAT_2)):(t=Ne(hi.LTC_HALF_1),r=Ne(hi.LTC_HALF_2));const{colorNode:s,light:n}=this,o=uy(n);return{lightColor:s,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){hi=e}}class yy{parseFunction(){z("Abstract function.")}}class xd{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){z("Abstract function.")}}xd.isNodeFunction=!0;const rA=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,sA=/[a-z_0-9]+/ig,yf="#pragma main",nA=i=>{i=i.trim();const e=i.indexOf(yf),t=e!==-1?i.slice(e+yf.length):i,r=t.match(rA);if(r!==null&&r.length===5){const s=r[4],n=[];let o=null;for(;(o=sA.exec(s))!==null;)n.push(o);const a=[];let u=0;for(;u{let u=this._createNodeBuilder(e,e.material);try{t?await u.buildAsync():u.build()}catch(l){u=this._createNodeBuilder(e,new qe),t?await u.buildAsync():u.build(),O("TSL: "+l)}return u};if(t)return a().then(u=>(s=this._createNodeBuilderState(u),n.set(o,s),s.usedTimes++,r.nodeBuilderState=s,s));{let u=this._createNodeBuilder(e,e.material);try{u.build()}catch(l){u=this._createNodeBuilder(e,new qe),u.build();let c=l.stackTrace;!c&&l.stack&&(c=new bt(l.stack)),O("TSL: "+l,c)}s=this._createNodeBuilderState(u),n.set(o,s)}}s.usedTimes++,r.nodeBuilderState=s}return s}getForRenderAsync(e){const t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){const t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;const r=this.getForRenderCacheKey(e),s=this.nodeBuilderCache.get(r);return s!==void 0?(s.usedTimes++,t.nodeBuilderState=s,s):(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){if(this._buildInProgress||this._buildQueue.length===0)return;this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()})}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(r===void 0||t.version!==e.version){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),r=this._createNodeBuilderState(s),t.nodeBuilderState=r,t.version=e.version}return r}_createNodeBuilderState(e){return new SE(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(this.renderer.lighting.enabled===!1)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){It[0]=e,It[1]=t;const r=this.renderer.info.calls,s=this.callHashCache.get(It)||{};if(s.callId!==r){if(Ar.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Ar.push(this.renderer.lighting.enabled?1:0),this.renderer.lighting.enabled){Ar.push(t.getCacheKey(!0)),Ar.push(this.renderer.shadowMap.enabled?1:0),Ar.push(this.renderer.shadowMap.type);const o=this.getEnvironmentNode(e);o&&Ar.push(o.getCacheKey())}const n=this.getFogNode(e);n&&Ar.push(n.getCacheKey()),s.callId=r,s.cacheKey=Ji(Ar),this.callHashCache.set(It,s),Ar.length=0}return It[0]=null,It[1]=null,s.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const s=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==r||s){const n=this.getCacheNode("background",r,()=>{if(r.isCubeTexture===!0||r.mapping===Dc||r.mapping===Fc||r.mapping===pa){if(e.backgroundBlurriness>0||r.mapping===pa)return Km(r);{let o;return r.isCubeTexture===!0?o=vt(r):o=Ne(r),Gm(o)}}else{if(r.isTexture===!0)return Ne(r,as.flipY()).setUpdateMatrix(!0);r.isColor!==!0&&O("WebGPUNodes: Unsupported background configuration.",r)}},s);t.backgroundNode=n,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const n=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let o=n.get(t);return(o===void 0||s)&&(o=r(),n.set(t,o)),o}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const s=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const n=Me("color","color",r).setGroup(Z),o=Me("density","float",r).setGroup(Z);return cf(n,DR(o))}else if(r.isFog){const n=Me("color","color",r).setGroup(Z),o=Me("near","float",r).setGroup(Z),a=Me("far","float",r).setGroup(Z);return cf(n,PR(o,a))}else O("Renderer: Unsupported fog configuration.",r)});t.fogNode=s,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const s=this.getCacheNode("environment",r,()=>{if(r.isCubeTexture===!0)return vt(r);if(r.isTexture===!0)return Ne(r);O("Nodes: Unsupported environment configuration.",r)});t.environmentNode=s,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,n=null){const o=this.nodeFrame;return o.renderer=e,o.scene=t,o.object=r,o.camera=s,o.material=n,o}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){const t=this.renderer;let r;return e.isArrayTexture?this.backend.isWebGLBackend?r=Ne(e,as).depth(Ks("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):r=Ne(e,as).depth(bf).renderOutput(t.toneMapping,t.currentColorSpace):r=Ne(e,as).renderOutput(t.toneMapping,t.currentColorSpace),r}setOutputLayerIndex(e){bf.value=e}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const s of r.updateNodes)t.updateNode(s)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const s of r.updateNodes)t.updateNode(s)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new mf,this.nodeBuilderCache=new Map,this.cacheLib={}}}const Qu=new wc;class Pa{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new At,this.viewNormalMatrix=new Qi,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,r){const s=e.length;for(let n=0;n0&&(Be("THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session."),this._currentSamples===null&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){const t=this.getWebGPUBinding(),r=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:"depth24plus"});this._glProjLayer=r,e.updateRenderState({layers:[r]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new ps(r.textureWidth,r.textureHeight,{depth:2,minFilter:yt,magFilter:yt,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,this._useMultiviewIfPossible===!0&&Be("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}_disposeWebGPUSession(){const e=this._renderer,t=this._xrRenderTarget;if(t===null||e.backend.isWebGPUBackend!==!0)return;const r=e.backend,s=e._textures,n=r.get?r.get(t):null;n&&(n.descriptors=void 0);const o=a=>{a!=null&&(r.delete&&r.delete(a),s.delete&&s.delete(a))};for(let a=0;aem(d,r.toneMapping,r.outputColorSpace)}),vf.set(u,l))}else l=u;r.contextNode=l,r.setRenderTarget(a.renderTarget),a.rendercall(),r.contextNode=u}r.setRenderTarget(o),r._setXRLayerSize(n.x,n.y),this.isPresenting=s}getSession(){return this._session}async setSession(e){const t=this._renderer;t.initialized===!1&&await t.init(),this._gl=t.getContext();const r=this._gl;if(this._session=e,e!==null){if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(this._supportsLayers===!0){let s=null,n=null,o=null;const a=r.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(o=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,s=t.stencil?$r:Vr,n=t.stencil?zr:Ge);const u={colorFormat:r.RGBA8,depthFormat:o,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(u.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const l=this._glBinding.createProjectionLayer(u),c=[l];this._glProjLayer=l,t.setPixelRatio(1),t._setXRLayerSize(l.textureWidth,l.textureHeight);const d=this._useMultiview?2:1,h=new xr(l.textureWidth,l.textureHeight,n,void 0,void 0,void 0,void 0,void 0,void 0,s,d);if(this._xrRenderTarget=new vi(l.textureWidth,l.textureHeight,{format:er,type:St,colorSpace:t.outputColorSpace,depthTexture:h,stencilBuffer:t.stencil,samples:a.antialias?4:0,resolveDepthBuffer:l.ignoreDepthValues===!1,resolveStencilBuffer:l.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const f of this._layers)f.plane.material=new ss({color:16777215,side:f.type==="cylinder"?ft:Ls}),f.plane.material.blending=Sn,f.plane.material.blendEquation=Dr,f.plane.material.blendSrc=rs,f.plane.material.blendDst=rs,f.xrlayer=this._createXRLayer(f),c.unshift(f.xrlayer);e.updateRenderState({layers:c})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());const s={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},n=new XRWebGLLayer(e,r,s);this._glBaseLayer=n,e.updateRenderState({baseLayer:n}),t.setPixelRatio(1),t._setXRLayerSize(n.framebufferWidth,n.framebufferHeight),this._xrRenderTarget=new vi(n.framebufferWidth,n.framebufferHeight,{format:er,type:St,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:n.ignoreDepthValues===!1,resolveStencilBuffer:n.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(t===null)return;const r=e.near,s=e.far,n=this._cameraXR,o=this._cameraL,a=this._cameraR;n.near=a.near=o.near=r,n.far=a.far=o.far=s,n.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==n.near||this._currentDepthFar!==n.far)&&(t.updateRenderState({depthNear:n.near,depthFar:n.far}),this._currentDepthNear=n.near,this._currentDepthFar=n.far),n.layers.mask=e.layers.mask|6,o.layers.mask=n.layers.mask&-5,a.layers.mask=n.layers.mask&-3;const u=e.parent,l=n.cameras;Sf(n,u);for(let c=0;c=0&&(t[n]=null,e[n].disconnect(s))}for(let r=0;r=t.length){t.push(s),n=a;break}else if(t[a]===null){t[a]=s,n=a;break}if(n===-1)break}const o=e[n];o&&o.connect(s)}}function bA(i){return i.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(i.translation,i.quaternion),width:i.width/2,height:i.height/2,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(i.translation,i.quaternion),radius:i.radius,centralAngle:i.centralAngle,aspectRatio:i.aspectRatio,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1})}function _A(i,e){if(e===void 0)return;const t=this._cameraXR,r=this._renderer,s=r.backend,n=this._glBaseLayer,o=this.getReferenceSpace(),a=e.getViewerPose(o);if(this._xrFrame=e,a!==null){const u=a.views,l=this._isWebGPUSession()?this._getWebGPUViewData(u):null;this._glBaseLayer!==null&&l===null&&s.setXRTarget(n.framebuffer);let c=!1;u.length!==t.cameras.length&&(t.cameras.length=0,c=!0);for(let h=0;h{await this.compileAsync(m,g,p);const x=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,_=this._renderLists.get(p,g),N=this._renderContexts.get(x,this._mrt),A=p.overrideMaterial||m.material,v=this._objects.get(m,A,p,g,_.lightsNode,N,N.clippingContext),{fragmentShader:S,vertexShader:P}=v.getNodeBuilderState();return{fragmentShader:S,vertexShader:P}}}}async init(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(s){if(this._getFallback!==null)try{this.backend=r=this._getFallback(s),await r.init(this)}catch(n){t(n);return}else{t(s);return}}this._nodes=new aA(this,r),this._animation=new kw(this,this._nodes,this.info),this._attributes=new Hw(r,this.info),this._background=new TE(this,this._nodes),this._geometries=new qw(this._attributes,this.info),this._textures=new uR(this,r,this.info),this._pipelines=new Zw(r,this._nodes,this.info),this._bindings=new Jw(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new zw(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new sR(this.lighting),this._bundles=new lA,this._renderContexts=new oR(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)}),this._initPromise)}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const s=this._nodes.nodeFrame,n=s.renderId,o=this._currentRenderContext,a=this._currentRenderObjectFunction,u=this._handleObjectFunction,l=this._compilationPromises;r===null&&(r=e);const c=e.isScene===!0?e:r.isScene===!0?r:Nf,h=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,f=this._renderContexts.get(h,this._mrt),p=this._activeMipmapLevel,g=[];this._currentRenderContext=f,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=g,s.renderId++,s.update(),f.depth=this.depth,f.stencil=this.stencil,f.clippingContext||(f.clippingContext=new Pa),f.clippingContext.updateGlobal(c,t),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t),c.onBeforeRender(this,e,t,h);const m=t.isArrayCamera?Lo:Fo;t.isArrayCamera?m.setFromArrayCamera(t):(on.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),m.setFromProjectionMatrix(on,t.coordinateSystem,t.reversedDepth));const y=this._renderLists.get(c,t);if(y.begin(),this._projectObject(e,t,0,y,f.clippingContext),r!==e&&r.traverseVisible(function(v){v.isLight&&v.layers.test(t.layers)&&y.pushLight(v)}),y.finish(),h!==null){this._textures.updateRenderTarget(h,p);const v=this._textures.get(h);f.textures=v.textures,f.depthTexture=v.depthTexture}else f.textures=null,f.depthTexture=null;r!==e?this._background.update(r,y,f):this._background.update(c,y,f);const x=y.opaque,_=y.transparent,N=y.transparentDoublePass,A=y.lightsNode;this.opaque===!0&&x.length>0&&this._renderObjects(x,t,c,A),this.transparent===!0&&_.length>0&&this._renderTransparents(_,N,t,c,A),s.renderId=n,this._currentRenderContext=o,this._currentRenderObjectFunction=a,this._handleObjectFunction=u,this._compilationPromises=l;for(const v of g){const S=this._objects.get(v.object,v.material,v.scene,v.camera,v.lightsNode,v.renderContext,v.clippingContext,v.passId);S.drawRange=v.object.geometry.drawRange,S.group=v.group,await this._nodes.getForRenderAsync(S),this._nodes.updateBefore(S),this._geometries.updateForRender(S),this._nodes.updateForRender(S),this._bindings.updateForRender(S);const P=[];this._pipelines.getForRender(S,P),P.length>0&&await Promise.all(P),this._nodes.updateAfter(S),await up()}}async renderAsync(e,t){Be('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){O("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;e===!0?(t.modelViewMatrix=bh,t.modelNormalViewMatrix=_h):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===bh&&e.modelNormalViewMatrix===_h}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return Be('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: + +Message: ${e.message}`;e.reason&&(t+=` +Reason: ${e.reason}`),O(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),O(t)}_bundleNeedsUpdate(e,t){return t.bundleGPU===void 0||e.version!==t.version}_renderBundle(e,t,r){const{bundleGroup:s,camera:n,renderList:o}=e,a=this._currentRenderContext,u=this._bundles.get(s,n,a),l=this.backend.get(u);if(this._bundleNeedsUpdate(s,l)){this.backend.beginBundle(a),this._currentRenderBundle=u;const{transparentDoublePass:d,transparent:h,opaque:f}=o;this.opaque===!0&&f.length>0&&this._renderObjects(f,n,t,r),this.transparent===!0&&h.length>0&&this._renderTransparents(h,d,n,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,u),l.version=s.version}else{const{renderObjects:d}=l;for(let h=0,f=d.length;h{l.removeEventListener("dispose",m),c.dispose(),this._frameBufferTargets.delete(l)};l.addEventListener("dispose",m),this._frameBufferTargets.set(l,c)}const d=this.getOutputRenderTarget();c.depthBuffer=a,c.stencilBuffer=u,d!==null?c.setSize(d.width,d.height,d.depth):c.setSize(n,o,1);const h=this._outputRenderTarget?this._outputRenderTarget.viewport:l._viewport,f=this._outputRenderTarget?this._outputRenderTarget.scissor:l._scissor,p=this._outputRenderTarget?1:l._pixelRatio,g=this._outputRenderTarget?this._outputRenderTarget.scissorTest:l._scissorTest;return c.viewport.copy(h),c.scissor.copy(f),c.viewport.multiplyScalar(p),c.scissor.multiplyScalar(p),c.scissorTest=g,c.multiview=d!==null?d.multiview:!1,c.useArrayDepthTexture=d!==null?d.useArrayDepthTexture:!1,c.resolveDepthBuffer=d!==null?d.resolveDepthBuffer:!0,c._autoAllocateDepthBuffer=d!==null?d._autoAllocateDepthBuffer:!1,c}_renderScene(e,t,r=!0){if(this._isDeviceLost===!0)return;const s=r?this._getFrameBufferTarget():null,n=this._nodes.nodeFrame,o=n.renderId,a=this._currentRenderContext,u=this._currentRenderObjectFunction,l=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;const c=e.isScene===!0?e:Nf,d=this._renderTarget||this._outputRenderTarget,h=this._activeCubeFace,f=this._activeMipmapLevel;let p;if(s!==null?(p=s,this.setRenderTarget(p)):p=d,p!==null&&p.depthBuffer===!0){const ie=this._textures.get(p);ie.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),ie.depthInitialized=!0)}const g=this._renderContexts.get(p,this._mrt,this._callDepth);this._currentRenderContext=g,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(g),this.inspector.beginRender(this.backend.getTimestampUID(g),e,t,p),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t);const m=this._canvasTarget;let y=m._viewport,x=m._scissor,_=m._pixelRatio;p!==null&&(y=p.viewport,x=p.scissor,_=1),this.getDrawingBufferSize(nn),Zu.set(0,0,nn.width,nn.height);const N=y.minDepth===void 0?0:y.minDepth,A=y.maxDepth===void 0?1:y.maxDepth;g.viewportValue.copy(y).multiplyScalar(_).floor(),g.viewportValue.width>>=f,g.viewportValue.height>>=f,g.viewportValue.minDepth=N,g.viewportValue.maxDepth=A,g.viewport=g.viewportValue.equals(Zu)===!1,g.scissorValue.copy(x).multiplyScalar(_).floor(),g.scissor=m._scissorTest&&g.scissorValue.equals(Zu)===!1,g.scissorValue.width>>=f,g.scissorValue.height>>=f,g.clippingContext||(g.clippingContext=new Pa),g.clippingContext.updateGlobal(c,t),c.onBeforeRender(this,e,t,p);const v=t.isArrayCamera?Lo:Fo;t.isArrayCamera?v.setFromArrayCamera(t):(on.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),v.setFromProjectionMatrix(on,t.coordinateSystem,t.reversedDepth));const S=this._renderLists.get(e,t);if(S.begin(),this._projectObject(e,t,0,S,g.clippingContext),S.finish(),this.sortObjects===!0&&S.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),p!==null){this._textures.updateRenderTarget(p,f);const ie=this._textures.get(p);g.textures=ie.textures,g.depthTexture=ie.depthTexture,g.width=ie.width,g.height=ie.height,g.renderTarget=p,g.depth=p.depthBuffer,g.stencil=p.stencilBuffer}else g.textures=null,g.depthTexture=null,g.width=nn.width,g.height=nn.height,g.depth=this.depth,g.stencil=this.stencil;g.width>>=f,g.height>>=f,g.activeCubeFace=h,g.activeMipmapLevel=f,g.occlusionQueryCount=S.occlusionQueryCount,g.scissorValue.max(Cr.set(0,0,0,0)),g.scissorValue.x+g.scissorValue.width>g.width&&(g.scissorValue.width=Math.max(g.width-g.scissorValue.x,0)),g.scissorValue.y+g.scissorValue.height>g.height&&(g.scissorValue.height=Math.max(g.height-g.scissorValue.y,0)),this._background.update(c,S,g),g.camera=t,this.backend.beginRender(g);const{bundles:P,lightsNode:F,transparentDoublePass:U,transparent:W,opaque:se}=S;return P.length>0&&this._renderBundles(P,c,F),this.opaque===!0&&se.length>0&&this._renderObjects(se,t,c,F),this.transparent===!0&&W.length>0&&this._renderTransparents(W,U,t,c,F),this.backend.finishRender(g),n.renderId=o,this._currentRenderContext=a,this._currentRenderObjectFunction=u,this._handleObjectFunction=l,this.lighting.finishRender(e),this._callDepth--,s!==null&&(this.setRenderTarget(d,h,f),this._renderOutput(p)),c.onAfterRender(this,e,t,p),this.inspector.finishRender(this.backend.getTimestampUID(g)),g}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._nodes.getOutputCacheKey();let r=this._quadCache.get(e.texture),s;if(r===void 0){s=new iy(new qe),s.name="Output Color Transform",s.material.name="outputColorTransform",s.material.fragmentNode=this._nodes.getOutputNode(e.texture),r={quad:s,cacheKey:t},this._quadCache.set(e.texture,r);const a=()=>{s.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",a)};e.texture.addEventListener("dispose",a)}else s=r.quad,r.cacheKey!==t&&(s.material.fragmentNode=this._nodes.getOutputNode(e.texture),s.material.needsUpdate=!0,r.cacheKey=t);const n=this.autoClear,o=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(s,e),this.autoClear=n,this.xr.enabled=o}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,r=0,s=-1){if(t!==null&&t.isReadbackBuffer&&this.info.memoryMap.has(t)===!1){this.info.createReadbackBuffer(t);const n=()=>{t.removeEventListener("dispose",n),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",n)}if(r%4!==0||s>0&&s%4!==0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,r,s)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,s){this._canvasTarget.setScissor(e,t,r,s)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,s,n=0,o=1){this._canvasTarget.setViewport(e,t,r,s,n,o)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(this._initialized===!1)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');const s=this._renderTarget||this._getFrameBufferTarget();let n=null;if(s!==null){this._textures.updateRenderTarget(s);const o=this._textures.get(s);n=this._renderContexts.get(s,null,-1),n.textures=o.textures,n.depthTexture=o.depthTexture,n.width=o.width,n.height=o.height,n.renderTarget=s,n.depth=s.depthBuffer,n.stencil=s.stencilBuffer;const a=this.backend.getClearColor();n.clearColorValue.r=a.r,n.clearColorValue.g=a.g,n.clearColorValue.b=a.b,n.clearColorValue.a=a.a,n.clearDepthValue=this.getClearDepth(),n.clearStencilValue=this.getClearStencil(),n.activeCubeFace=this.getActiveCubeFace(),n.activeMipmapLevel=this.getActiveMipmapLevel(),s.depthBuffer===!0&&(o.depthInitialized=!0)}this.backend.clear(e,t,r,n),s!==null&&this._renderTarget===null&&this._renderOutput(s)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){Be('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){Be('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){Be('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){Be('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==Ds,t=this.currentColorSpace!==We.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget!==null?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:Ds}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:We.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){if(this._initialized===!0){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(const e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(const e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return z("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,s=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const n=this.backend,o=this._pipelines,a=this._bindings,u=this._nodes,l=Array.isArray(e)?e:[e];if(l[0]===void 0||l[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");n.beginCompute(e);for(const c of l){if(o.has(c)===!1){const f=()=>{c.removeEventListener("dispose",f),o.delete(c),a.deleteForCompute(c),u.delete(c)};c.addEventListener("dispose",f);const p=c.onInitFunction;p!==null&&p.call(c,{renderer:this})}u.updateForCompute(c),a.updateForCompute(c);const d=a.getForCompute(c),h=o.getForCompute(c,d);n.compute(e,c,d,h,t)}n.finishCompute(e),r.renderId=s,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return Be('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){Be('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Cr.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Cr.copy(t).floor();else{O("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Cr.set(0,0,e.image.width,e.image.height);let r=this._currentRenderContext,s;r!==null?s=r.renderTarget:(s=this._renderTarget||this._getFrameBufferTarget(),s!==null&&(this._textures.updateRenderTarget(s),r=this._textures.get(s))),this._textures.updateTexture(e,{renderTarget:s}),this.backend.copyFramebufferToTexture(e,r,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,r=null,s=null,n=0,o=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,n,o),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,r,s,n,o=0,a=0){return this.backend.copyTextureToBuffer(e.textures[o],t,r,s,n,a)}_projectObject(e,t,r,s,n){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(n=n.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const u=t.isArrayCamera?Lo:Fo;if(!e.frustumCulled||u.intersectsSprite(e)){this.sortObjects===!0&&Cr.setFromMatrixPosition(e.matrixWorld).applyMatrix4(on);const{geometry:l,material:c}=e;c.visible&&s.push(e,l,c,r,Cr.z,null,n)}}else if(e.isLineLoop)O("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const u=t.isArrayCamera?Lo:Fo;if(!e.frustumCulled||u.intersectsObject(e)){const{geometry:l,material:c}=e;if(this.sortObjects===!0&&(l.boundingSphere===null&&l.computeBoundingSphere(),Cr.copy(l.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(on)),Array.isArray(c)){const d=l.groups;for(let h=0,f=d.length;h0){for(const{material:o}of t)o.side=ft;this._renderObjects(t,r,s,n,"backSide");for(const{material:o}of t)o.side=Ls;this._renderObjects(e,r,s,n);for(const{material:o}of t)o.side=Gr}else this._renderObjects(e,r,s,n)}_renderObjects(e,t,r,s,n=null){for(let o=0,a=e.length;o(f.not().discard(),p))(l)}}e.depthNode&&e.depthNode.isNode&&(c=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?u=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(u=e.positionNode),r={version:t,colorNode:l,depthNode:c,positionNode:u},this._cacheShadowNodes.set(e,r)}return r}_updateCamera(e){const t=this.xr;if(t.isPresenting===!1){let r=!1;if(this.reversedDepthBuffer===!0&&e.reversedDepth!==!0){if(e._reversedDepth=!0,e.isArrayCamera)for(const n of e.cameras)n._reversedDepth=!0;r=!0}const s=this.coordinateSystem;if(e.coordinateSystem!==s){if(e.coordinateSystem=s,e.isArrayCamera)for(const n of e.cameras)n.coordinateSystem=s;r=!0}if(r===!0&&(e.updateProjectionMatrix(),e.isArrayCamera))for(const n of e.cameras)n.updateProjectionMatrix()}return e.parent===null&&e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.enabled===!0&&t.isPresenting===!0&&(t.cameraAutoUpdate===!0&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,r,s,n,o,a,u=null,l=null){let c=!1,d,h,f,p,g,m,y;const x=this._currentSourceMaterial;if(e.onBeforeRender(this,t,r,s,n,o),n.allowOverride===!0&&t.overrideMaterial!==null){this._currentSourceMaterial=n;const _=t.overrideMaterial;if(c=!0,d=_.isNodeMaterial?_.colorNode:null,h=_.isNodeMaterial?_.depthNode:null,f=_.isNodeMaterial?_.positionNode:null,p=t.overrideMaterial.side,g=_.displacementMap,m=_.displacementScale,y=_.displacementBias,n.positionNode&&n.positionNode.isNode&&(_.positionNode=n.positionNode),_.alphaTest=n.alphaTest,_.alphaMap=n.alphaMap,_.displacementMap=n.displacementMap,_.displacementScale=n.displacementScale,_.displacementBias=n.displacementBias,_.transparent=n.transparent||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode,_.isShadowPassMaterial){const{colorNode:N,depthNode:A,positionNode:v}=this._getShadowNodes(n);this.shadowMap.type===Ni?_.side=n.shadowSide!==null?n.shadowSide:n.side:_.side=n.shadowSide!==null?n.shadowSide:TA[n.side],N!==null&&(_.colorNode=N),A!==null&&(_.depthNode=A),v!==null&&(_.positionNode=v)}n=_}n.transparent===!0&&n.side===Gr&&n.forceSinglePass===!1?(n.side=ft,this._handleObjectFunction(e,n,t,r,a,o,u,"backSide"),n.side=Ls,this._handleObjectFunction(e,n,t,r,a,o,u,l),n.side=Gr):this._handleObjectFunction(e,n,t,r,a,o,u,l),c&&(t.overrideMaterial.colorNode=d,t.overrideMaterial.depthNode=h,t.overrideMaterial.positionNode=f,t.overrideMaterial.side=p,t.overrideMaterial.displacementMap=g,t.overrideMaterial.displacementScale=m,t.overrideMaterial.displacementBias=y),this._currentSourceMaterial=x,e.onAfterRender(this,t,r,s,n,o)}hasCompatibility(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,s,n,o,a,u){const l=this._objects.get(e,t,r,s,n,this._currentRenderContext,a,u);l.drawRange=e.geometry.drawRange,l.group=o,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup);const c=this._nodes.needsRefresh(l);c&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),this._pipelines.isReady(l)&&(this.backend.draw(l,this.info),c&&this._nodes.updateAfter(l))}_createObjectPipeline(e,t,r,s,n,o,a,u){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:r,camera:s,lightsNode:n,group:o,clippingContext:a,passId:u,renderContext:this._currentRenderContext});return}const l=this._objects.get(e,t,r,s,n,this._currentRenderContext,a,u);l.drawRange=e.geometry.drawRange,l.group=o,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l),this._pipelines.getForRender(l,this._compilationPromises),this._nodes.updateAfter(l)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class _y{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function xy(i){return i+(is-i%is)%is}class Ty extends _y{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return xy(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}class vy extends Ty{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let SA=0;class Sy extends vy{constructor(e,t){super("UniformBuffer_"+SA++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return xy(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class NA extends vy{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){const t=e.index;if(this._addedIndices.has(t))return;let r=this._updateRangeCache.get(t);r===void 0&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r0?d:"";a=`${l.name} { + ${c} ${o.name}[${h}]; +}; +`}else{const l=o.groupNode.name;if(s[l]===void 0){const c=this.uniformGroups[l];if(c!==void 0){const d=[];for(const h of c.uniforms){const f=h.getType(),p=this.getVectorType(f),g=h.nodeUniform.node.precision;let m=`${p} ${h.name};`;g!==null&&(m=Rf[g]+" "+m),d.push(" "+m)}s[l]=d}}u=!0}if(!u){const l=o.node.precision;l!==null&&(a=Rf[l]+" "+a),a="uniform "+a,r.push(a)}}let n="";for(const o in s){const a=s[o];n+=this._getGLSLUniformStruct(o,a.join(` +`))+` +`}return n+=r.join(` +`),n}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ze){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;s instanceof Uint32Array||s instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const r=this.getAttributesArray();let s=0;for(const n of r)t+=`layout( location = ${s++} ) in ${n.type} ${n.name}; +`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(` ${r.type} ${r.name};`);return t.join(` +`)}getStructs(e){const t=[],r=this.structs[e],s=[];for(const n of r)if(n.output)for(const o of n.members)s.push(`layout( location = ${o.index} ) out ${o.type} ${o.name};`);else{let o="struct "+n.name+` { +`;o+=this.getStructMembers(n),o+=` +}; +`,t.push(o)}return e==="fragment"&&s.length===0&&s.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),` +`+s.join(` +`)+` + +`+t.join(` +`)}getVaryings(e){let t="";const r=this.varyings;if(e==="vertex"||e==="compute")for(const s of r){e==="compute"&&(s.needsInterpolation=!0);const n=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){const o=Af[s.interpolationType]||s.interpolationType,a=Cf[s.interpolationSampling]||"";t+=`${o} ${a} out ${n} ${s.name}; +`}else{const o=n.includes("int")||n.includes("uv")||n.includes("iv")?"flat ":"";t+=`${o}out ${n} ${s.name}; +`}else t+=`${n} ${s.name}; +`}else if(e==="fragment"){for(const s of r)if(s.needsInterpolation){const n=this.getType(s.type);if(s.interpolationType){const o=Af[s.interpolationType]||s.interpolationType,a=Cf[s.interpolationSampling]||"";t+=`${o} ${a} in ${n} ${s.name}; +`}else{const o=n.includes("int")||n.includes("uv")||n.includes("iv")?"flat ":"";t+=`${o}in ${n} ${s.name}; +`}}}for(const s of this.builtins[e])t+=`${s}; +`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((r,s)=>r*s,1)}u`}getSubgroupSize(){O("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){O("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){O("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);s.has(e)===!1&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const s=this.renderer.backend.extensions;this.object.isBatchedMesh&&s.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(r!==void 0)for(const{name:s,behavior:n}of r.values())t.push(`#extension ${s} : ${n}`);return t.join(` +`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=Ef[e];if(t===void 0){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance";break}if(r!==void 0){const s=this.renderer.backend.extensions;s.has(r)&&(s.get(r),t=!0)}Ef[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+=` +`),r+=` // flow -> ${l} + `),r+=`${u.code} + `,a===n&&t!=="compute"&&(r+=`// result + `,t==="vertex"?(r+="gl_Position = ",r+=`${this.format(u.result,n.getNodeType(this),"vec4")};`):t==="fragment"&&(a.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${this.format(u.result,n.getNodeType(this),this.getOutputType())};`)))}const o=e[t];if(o.extensions=this.getExtensions(t),o.uniforms=this.getUniforms(t),o.attributes=this.getAttributes(t),o.varyings=this.getVaryings(t),o.vars=this.getVars(t,!0),o.structs=this.getStructs(t),o.codes=this.getCodes(t),o.transforms=this.getTransforms(t),o.flow=r,t==="vertex"){const a=this.renderer.backend.extensions;this.object.isBatchedMesh&&a.has("WEBGL_multi_draw")===!1&&(o.uniforms+=` +uniform uint nodeUniformDrawId; +`)}}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const n=super.getUniformFromNode(e,t,r,s),o=this.getDataFromNode(e,r,this.globalCache);let a=o.uniformGPU;if(a===void 0){const u=e.groupNode,l=u.name,c=this.getBindGroupArray(l,r);if(t==="texture")a=new Ja(n.name,n.node,u),c.push(a);else if(t==="cubeTexture"||t==="cubeDepthTexture")a=new Ry(n.name,n.node,u),c.push(a);else if(t==="texture3D")a=new bc(n.name,n.node,u),c.push(a);else if(t==="buffer"){n.name=`buffer${e.id}`;const d=this.getSharedDataFromNode(e);let h=d.buffer;h===void 0&&(e.name=`NodeBuffer_${e.id}`,h=new Sy(e,u),h.name=e.name,d.buffer=h),c.push(h),a=h}else{let d=this.uniformGroups[l];d===void 0?(d=new Ny(l,u),this.uniformGroups[l]=d,c.push(d)):c.indexOf(d)===-1&&c.push(d),a=this.getNodeUniform(n,t);const h=a.name;d.uniforms.some(p=>p.name===h)||d.addUniform(a)}o.uniformGPU=a}return n}}let Ju=null,an=null;class Ey{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[br.RENDER]:null,[br.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let s;e.isComputeNode===!0?s="c:"+this.renderer.info.compute.frameCalls:s="r:"+this.renderer.info.render.frameCalls,t.timestampUID=s+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?br.COMPUTE:br.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){Be("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t)return;const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return Ju=Ju||new ce,this.renderer.getDrawingBufferSize(Ju)}setScissorTest(){}getClearColor(){const e=this.renderer;return an=an||new gd,e.getClearColor(an),an.getRGB(an),an}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:gb(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${ka} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}let PA=0;class DA{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class FA{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,n=e.array,o=e.usage||s.STATIC_DRAW,a=e.isInterleavedBufferAttribute?e.data:e,u=r.get(a);let l=u.bufferGPU;l===void 0&&(l=this._createBuffer(s,t,n,o),u.bufferGPU=l,u.bufferType=t,u.version=a.version);let c;if(n instanceof Float32Array)c=s.FLOAT;else if(typeof Float16Array<"u"&&n instanceof Float16Array)c=s.HALF_FLOAT;else if(n instanceof Uint16Array)e.isFloat16BufferAttribute?c=s.HALF_FLOAT:c=s.UNSIGNED_SHORT;else if(n instanceof Int16Array)c=s.SHORT;else if(n instanceof Uint32Array)c=s.UNSIGNED_INT;else if(n instanceof Int32Array)c=s.INT;else if(n instanceof Int8Array)c=s.BYTE;else if(n instanceof Uint8Array)c=s.UNSIGNED_BYTE;else if(n instanceof Uint8ClampedArray)c=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+n);let d={bufferGPU:l,bufferType:t,type:c,byteLength:n.byteLength,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:c===s.INT||c===s.UNSIGNED_INT||e.gpuType===Ze,id:PA++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const h=this._createBuffer(s,t,n,o);d=new DA(d,h)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,n=e.isInterleavedBufferAttribute?e.data:e,o=t.get(n),a=o.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,o.bufferGPU),u.length===0)r.bufferSubData(a,0,s);else{for(let l=0,c=u.length;l{t.buffer=null,t._mapped=!1,t.removeEventListener("release",h),t.removeEventListener("dispose",h)};t.addEventListener("release",h),t.addEventListener("dispose",h),d=new Uint8Array(new ArrayBuffer(c)),t.buffer=d.buffer}else d=new Uint8Array(t);return o.bindBuffer(o.COPY_READ_BUFFER,l),o.getBufferSubData(o.COPY_READ_BUFFER,r,d),o.bindBuffer(o.COPY_READ_BUFFER,null),o.bindBuffer(o.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:d.buffer}_createBuffer(e,t,r,s){const n=e.createBuffer();return e.bindBuffer(t,n),e.bufferData(t,r,s),e.bindBuffer(t,null),n}}let fi,Mr;class LA{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;fi={[Dr]:e.FUNC_ADD,[Tp]:e.FUNC_SUBTRACT,[xp]:e.FUNC_REVERSE_SUBTRACT},Mr={[rs]:e.ZERO,[Bp]:e.ONE,[Mp]:e.SRC_COLOR,[Cp]:e.SRC_ALPHA,[Ap]:e.SRC_ALPHA_SATURATE,[Ep]:e.DST_COLOR,[Rp]:e.DST_ALPHA,[wp]:e.ONE_MINUS_SRC_COLOR,[Np]:e.ONE_MINUS_SRC_ALPHA,[Sp]:e.ONE_MINUS_DST_COLOR,[vp]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=new He().fromArray(t),this.currentViewport=new He().fromArray(r),this._tempVec4=new He}enable(e){const{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==yb?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===bb?t.cullFace(t.BACK):e===_b?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,r){const s=this.gl,n=this.backend.drawBuffersIndexedExt;if(!n){Be("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.");return}for(let o=0;o0?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r)for(let u=0;u<8;u++)u{function n(){const o=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(o===e.WAIT_FAILED){e.deleteSync(t),s();return}if(o===e.TIMEOUT_EXPIRED){requestAnimationFrame(n);return}e.deleteSync(t),r()}n()})}}let Bf=!1,Uo,el,Pf;class OA{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,Bf===!1&&(this._init(),Bf=!0)}_init(){const e=this.gl;Uo={[Va]:e.REPEAT,[Oi]:e.CLAMP_TO_EDGE,[Ga]:e.MIRRORED_REPEAT},el={[Lt]:e.NEAREST,[gp]:e.NEAREST_MIPMAP_NEAREST,[Bn]:e.NEAREST_MIPMAP_LINEAR,[yt]:e.LINEAR,[yl]:e.LINEAR_MIPMAP_NEAREST,[ls]:e.LINEAR_MIPMAP_LINEAR},Pf={[_p]:e.NEVER,[bp]:e.ALWAYS,[Uc]:e.LESS,[Zi]:e.LEQUAL,[yp]:e.EQUAL,[Pn]:e.GEQUAL,[ma]:e.GREATER,[mp]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return e.isCubeTexture===!0?r=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?r=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?r=t.TEXTURE_3D:r=t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,n,o=!1){const{gl:a,extensions:u}=this;if(e!==null){if(a[e]!==void 0)return a[e];z("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let l=null;s&&(l=u.get("EXT_texture_norm16"),l||z("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let c=t;if(t===a.RED&&(r===a.FLOAT&&(c=a.R32F),r===a.HALF_FLOAT&&(c=a.R16F),r===a.UNSIGNED_BYTE&&(c=a.R8),r===a.BYTE&&(c=a.R8_SNORM),r===a.UNSIGNED_SHORT&&l&&(c=l.R16_EXT),r===a.SHORT&&l&&(c=l.R16_SNORM_EXT)),t===a.RED_INTEGER&&(r===a.UNSIGNED_BYTE&&(c=a.R8UI),r===a.UNSIGNED_SHORT&&(c=a.R16UI),r===a.UNSIGNED_INT&&(c=a.R32UI),r===a.BYTE&&(c=a.R8I),r===a.SHORT&&(c=a.R16I),r===a.INT&&(c=a.R32I)),t===a.RG&&(r===a.FLOAT&&(c=a.RG32F),r===a.HALF_FLOAT&&(c=a.RG16F),r===a.UNSIGNED_BYTE&&(c=a.RG8),r===a.BYTE&&(c=a.RG8_SNORM),r===a.UNSIGNED_SHORT&&l&&(c=l.RG16_EXT),r===a.SHORT&&l&&(c=l.RG16_SNORM_EXT)),t===a.RG_INTEGER&&(r===a.UNSIGNED_BYTE&&(c=a.RG8UI),r===a.UNSIGNED_SHORT&&(c=a.RG16UI),r===a.UNSIGNED_INT&&(c=a.RG32UI),r===a.BYTE&&(c=a.RG8I),r===a.SHORT&&(c=a.RG16I),r===a.INT&&(c=a.RG32I)),t===a.RGB){const d=o?Ed:We.getTransfer(n);r===a.FLOAT&&(c=a.RGB32F),r===a.HALF_FLOAT&&(c=a.RGB16F),r===a.UNSIGNED_BYTE&&(c=d===oe?a.SRGB8:a.RGB8),r===a.BYTE&&(c=a.RGB8_SNORM),r===a.UNSIGNED_SHORT&&l&&(c=l.RGB16_EXT),r===a.SHORT&&l&&(c=l.RGB16_SNORM_EXT),r===a.UNSIGNED_SHORT_5_6_5&&(c=a.RGB565),r===a.UNSIGNED_SHORT_5_5_5_1&&(c=a.RGB5_A1),r===a.UNSIGNED_SHORT_4_4_4_4&&(c=a.RGB4),r===a.UNSIGNED_INT_5_9_9_9_REV&&(c=a.RGB9_E5),r===a.UNSIGNED_INT_10F_11F_11F_REV&&(c=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(r===a.UNSIGNED_BYTE&&(c=a.RGB8UI),r===a.UNSIGNED_SHORT&&(c=a.RGB16UI),r===a.UNSIGNED_INT&&(c=a.RGB32UI),r===a.BYTE&&(c=a.RGB8I),r===a.SHORT&&(c=a.RGB16I),r===a.INT&&(c=a.RGB32I)),t===a.RGBA){const d=o?Ed:We.getTransfer(n);r===a.FLOAT&&(c=a.RGBA32F),r===a.HALF_FLOAT&&(c=a.RGBA16F),r===a.UNSIGNED_BYTE&&(c=d===oe?a.SRGB8_ALPHA8:a.RGBA8),r===a.BYTE&&(c=a.RGBA8_SNORM),r===a.UNSIGNED_SHORT&&l&&(c=l.RGBA16_EXT),r===a.SHORT&&l&&(c=l.RGBA16_SNORM_EXT),r===a.UNSIGNED_SHORT_4_4_4_4&&(c=a.RGBA4),r===a.UNSIGNED_SHORT_5_5_5_1&&(c=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(r===a.UNSIGNED_BYTE&&(c=a.RGBA8UI),r===a.UNSIGNED_SHORT&&(c=a.RGBA16UI),r===a.UNSIGNED_INT&&(c=a.RGBA32UI),r===a.BYTE&&(c=a.RGBA8I),r===a.SHORT&&(c=a.RGBA16I),r===a.INT&&(c=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(r===a.UNSIGNED_SHORT&&(c=a.DEPTH_COMPONENT16),r===a.UNSIGNED_INT&&(c=a.DEPTH_COMPONENT24),r===a.FLOAT&&(c=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&r===a.UNSIGNED_INT_24_8&&(c=a.DEPTH24_STENCIL8),(c===a.R16F||c===a.R32F||c===a.RG16F||c===a.RG32F||c===a.RGBA16F||c===a.RGBA32F)&&u.get("EXT_color_buffer_float"),c}setTextureParameters(e,t){const{gl:r,extensions:s,backend:n}=this,{state:o}=this.backend,a=We.getPrimaries(We.workingColorSpace),u=t.colorSpace===Dn?null:We.getPrimaries(t.colorSpace),l=t.colorSpace===Dn||a===u?r.NONE:r.BROWSER_DEFAULT_WEBGL;o.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),o.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),o.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),o.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,l),r.texParameteri(e,r.TEXTURE_WRAP_S,Uo[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,Uo[t.wrapT]),(e===r.TEXTURE_3D||e===r.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,Uo[t.wrapR])),r.texParameteri(e,r.TEXTURE_MAG_FILTER,el[t.magFilter]);const c=t.mipmaps!==void 0&&t.mipmaps.length>0,d=t.minFilter===yt&&c?ls:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,el[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,Pf[t.compareFunction])),s.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===Lt||t.minFilter!==Bn&&t.minFilter!==ls||t.type===dt&&s.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const h=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,h.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,n.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,n=this.getGLTextureType(e);let o=s[n];o===void 0&&(o=t.createTexture(),r.state.bindTexture(n,o),t.texParameteri(n,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.NEAREST),s[n]=o),r.set(e,{textureGPU:o,glTextureType:n})}createTexture(e,t){const{gl:r,backend:s}=this;let n,o,a,u,l;if(e.isExternalTexture===!0)n=e.sourceTexture,o=this.getGLTextureType(e);else{const{levels:c,width:d,height:h,depth:f}=t;a=s.utils.convert(e.format,e.colorSpace),u=s.utils.convert(e.type),l=this.getInternalFormat(e.internalFormat,a,u,e.normalized,e.colorSpace,e.isVideoTexture),n=r.createTexture(),o=this.getGLTextureType(e),s.state.bindTexture(o,n),this.setTextureParameters(o,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,c,l,d,h,f):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,c,l,d,h,f):e.isVideoTexture||r.texStorage2D(o,c,l,d,h)}s.set(e,{textureGPU:n,glTextureType:o,glFormat:a,glType:u,glInternalFormat:l})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{state:n}=s,{textureGPU:o,glTextureType:a,glFormat:u,glType:l}=s.get(t),{width:c,height:d}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(a,o),n.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(a,0,0,0,c,d,u,l,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:n}=t,{textureGPU:o,glTextureType:a,glFormat:u,glType:l,glInternalFormat:c}=this.backend.get(e);if(!(e.isRenderTargetTexture||o===void 0))if(this.backend.state.bindTexture(a,o),this.setTextureParameters(a,e),e.isCompressedTexture){const d=e.mipmaps,h=t.image;for(let f=0;f0){const h=mb(d.width,d.height,e.format,e.type);for(const f of e.layerUpdates){const p=d.data.subarray(f*h/d.data.BYTES_PER_ELEMENT,(f+1)*h/d.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,f,d.width,d.height,1,u,l,p)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,d.width,d.height,d.depth,u,l,d.data)}else if(e.isData3DTexture){const d=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,d.width,d.height,d.depth,u,l,d.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,c,u,l,t.image);else if(e.isHTMLTexture)typeof r.texElementImage2D=="function"&&(r.texElementImage2D.length===3?r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,t.image):r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image));else{const d=e.mipmaps;if(d.length>0)for(let h=0,f=d.length;h0,h=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const f=a!==0||u!==0;let p,g;if(e.isDepthTexture===!0?(p=s.DEPTH_BUFFER_BIT,g=s.DEPTH_ATTACHMENT,t.stencil&&(p|=s.STENCIL_BUFFER_BIT)):(p=s.COLOR_BUFFER_BIT,g=s.COLOR_ATTACHMENT0),f){const m=this.backend.get(t.renderTarget),y=m.framebuffers[t.getCacheKey()],x=m.msaaFrameBuffer;n.bindFramebuffer(s.DRAW_FRAMEBUFFER,y),n.bindFramebuffer(s.READ_FRAMEBUFFER,x);const _=h-u-c;s.blitFramebuffer(a,_,a+l,_+c,a,_,a+l,_+c,p,s.NEAREST),n.bindFramebuffer(s.READ_FRAMEBUFFER,y),n.bindTexture(s.TEXTURE_2D,o),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,_,l,c),n.unbindTexture()}else{const m=s.createFramebuffer();n.bindFramebuffer(s.DRAW_FRAMEBUFFER,m),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,g,s.TEXTURE_2D,o,0),s.blitFramebuffer(0,0,l,c,0,0,l,c,p,s.NEAREST),s.deleteFramebuffer(m)}}else n.bindTexture(s.TEXTURE_2D,o),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,a,h-c-u,l,c),n.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:n}=this,o=t.renderTarget,{depthTexture:a,depthBuffer:u,stencilBuffer:l,width:c,height:d}=o;if(n.bindRenderbuffer(n.RENDERBUFFER,e),u&&!l){let h=n.DEPTH_COMPONENT24;s===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(n.RENDERBUFFER,o.samples,h,c,d):r>0?(a&&a.isDepthTexture&&a.type===n.FLOAT&&(h=n.DEPTH_COMPONENT32F),n.renderbufferStorageMultisample(n.RENDERBUFFER,r,h,c,d)):n.renderbufferStorage(n.RENDERBUFFER,h,c,d),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e)}else u&&l&&(r>0?n.renderbufferStorageMultisample(n.RENDERBUFFER,r,n.DEPTH24_STENCIL8,c,d):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,c,d),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e));n.bindRenderbuffer(n.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,s,n,o){const{backend:a,gl:u}=this,{textureGPU:l,glFormat:c,glType:d}=this.backend.get(e),h=u.createFramebuffer();a.state.bindFramebuffer(u.READ_FRAMEBUFFER,h);const f=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+o:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,f,l,0);const p=this._getTypedArrayType(d),g=this._getBytesPerTexel(d,c),y=s*n*g,x=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,x),u.bufferData(u.PIXEL_PACK_BUFFER,y,u.STREAM_READ),u.readPixels(t,r,s,n,c,d,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();const _=new p(y/p.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,x),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,_),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),a.state.bindFramebuffer(u.READ_FRAMEBUFFER,null),u.deleteFramebuffer(h),_}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;if(e===r.UNSIGNED_BYTE&&(s=1),(e===r.UNSIGNED_SHORT_4_4_4_4||e===r.UNSIGNED_SHORT_5_5_5_1||e===r.UNSIGNED_SHORT_5_6_5||e===r.UNSIGNED_SHORT||e===r.HALF_FLOAT)&&(s=2),(e===r.UNSIGNED_INT||e===r.FLOAT)&&(s=4),t===r.RGBA)return s*4;if(t===r.RGB)return s*3;if(t===r.ALPHA)return s}dispose(){const{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}}function Oo(i){return i.isDataTexture?i.image.data:typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?i:i.data}class IA{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class kA{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;const e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}const Df={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class GA{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:s,object:n,type:o,info:a,index:u}=this;u!==0?r.drawElements(s,t,o,e):r.drawArrays(s,e,t),a.update(n,t,1)}renderInstances(e,t,r){const{gl:s,mode:n,type:o,index:a,object:u,info:l}=this;r!==0&&(a!==0?s.drawElementsInstanced(n,t,o,e,r):s.drawArraysInstanced(n,e,t,r),l.update(u,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:n,object:o,info:a}=this;if(r===0)return;const u=s.get("WEBGL_multi_draw");if(u===null)for(let l=0;lthis.maxQueries)return Be(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;const r=this.queries[t];if(r)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(s){O("Error in beginQuery:",s),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(r){O("Error in endQuery:",r),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[n,o]of this.queryOffsets)if(this.queryStates.get(o)==="ended"){const u=this.queries[o];e.set(n,this.resolveQuery(u))}if(e.size===0)return this.lastValue;const t={},r=[];for(const[n,o]of e){const a=n.match(/^(.*):f(\d+)$/),u=parseInt(a[2]);r.includes(u)===!1&&r.push(u),t[u]===void 0&&(t[u]=0);const l=await o;this.timestamps.set(n,l),t[u]+=l}const s=t[r[r.length-1]];return this.lastValue=s,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return O("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let r,s=!1;const n=()=>{r&&(clearTimeout(r),r=null)},o=u=>{s||(s=!0,n(),t(u))},a=()=>{if(this.isDisposed){o(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){o(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){r=setTimeout(a,1);return}const c=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(c)/1e6)}catch(u){O("Error checking query:",u),t(this.lastValue)}};a()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class Ff extends Ey{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=t.context!==void 0?t.context:e.domElement.getContext("webgl2",r);function n(o){o.preventDefault();const a={api:"WebGL",message:o.statusMessage||"Unknown reason",reason:null,originalEvent:o};e.onDeviceLost(a)}this._onContextLost=n,e.domElement.addEventListener("webglcontextlost",n,!1),this.gl=s,this.extensions=new IA(this),this.capabilities=new kA(this),this.attributeUtils=new FA(this),this.textureUtils=new OA(this),this.bufferRenderer=new GA(this),this.state=new LA(this),this.utils=new UA(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(z("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return fa}get hasTimestamp(){return this.disjoint!==null}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),r!==null){const n=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:n}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&z("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new VA(this.gl,e,2048));const r=this.timestampQueryPool[e];r.allocateQueriesForContext(t)!==null&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:n,height:o}=this.getDrawingBufferSize();t.viewport(0,0,n,o)}if(e.scissor)this.updateScissor(e);else{const{width:n,height:o}=this.getDrawingBufferSize();t.scissor(0,0,n,o)}this.initTimestampQuery(br.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),n=s.previousContext;r.resetVertexState();const o=e.occlusionQueryCount;o>0&&(o>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const a=e.textures;if(a!==null)for(let u=0;u{let u=0;for(let l=0;l1?t.renderInstances(r,s,n):t.render(r,s)}draw(e){const{object:t,pipeline:r,material:s,context:n,hardwareClippingPlanes:o}=e,{programGPU:a}=this.get(r),{gl:u,state:l}=this,c=this.get(n),d=e.getDrawParameters();if(d===null)return;this._bindUniforms(e.getBindings());const h=t.isMesh&&t.matrixWorld.determinantAffine()<0;l.setMaterial(s,h,o),n.mrt!==null&&n.textures!==null&&l.setMRTBlending(n.textures,n.mrt,s),l.useProgram(a);const f=e.getAttributes(),p=this.get(f);let g=p.vaoGPU;if(g===void 0){const S=this._getVaoKey(f);g=this.vaoCache[S],g===void 0&&(g=this._createVao(f),this.vaoCache[S]=g,p.vaoGPU=g)}const m=e.getIndex(),y=m!==null?this.get(m).bufferGPU:null;l.setVertexState(g,y);const x=c.lastOcclusionObject;if(x!==t&&x!==void 0){if(x!==null&&x.occlusionTest===!0&&(u.endQuery(u.ANY_SAMPLES_PASSED),c.occlusionQueryIndex++),t.occlusionTest===!0){const S=u.createQuery();u.beginQuery(u.ANY_SAMPLES_PASSED,S),c.occlusionQueries[c.occlusionQueryIndex]=S,c.occlusionQueryObjects[c.occlusionQueryIndex]=t}c.lastOcclusionObject=t}const _=this.bufferRenderer;t.isPoints?_.mode=u.POINTS:t.isLineSegments?_.mode=u.LINES:t.isLine?_.mode=u.LINE_STRIP:t.isLineLoop?_.mode=u.LINE_LOOP:s.wireframe===!0?(l.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),_.mode=u.LINES):_.mode=u.TRIANGLES;const{vertexCount:N,instanceCount:A}=d;let{firstVertex:v}=d;if(_.object=t,m!==null){v*=m.array.BYTES_PER_ELEMENT;const S=this.get(m);_.index=m.count,_.type=S.type}else _.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const S=this.get(e.camera),P=e.camera.cameras,F=e.getBindingGroup("cameraIndex").bindings[0];if(S.indexesGPU===void 0||S.indexesGPU.length!==P.length){const X=new Uint32Array([0,0,0,0]),ue=[];for(let D=0,I=P.length;D{const h=this.parallel,f=()=>{r.getProgramParameter(a,h.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),d()):requestAnimationFrame(f)};f()});t.push(c);return}this._completeCompile(e,s)}_handleSource(e,t){const r=e.split(` +`),s=[],n=Math.max(t-6,0),o=Math.min(t+6,r.length);for(let a=n;a":" "} ${u}: ${r[a]}`)}return s.join(` +`)}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),o=(e.getShaderInfoLog(t)||"").trim();if(s&&o==="")return"";const a=/ERROR: 0:(\d+)/.exec(o);if(a){const u=parseInt(a[1]);return r.toUpperCase()+` + +`+o+` + +`+this._handleSource(e.getShaderSource(t),u)}else return o}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,o=(s.getProgramInfoLog(e)||"").trim();if(s.getProgramParameter(e,s.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(s,e,r,t);else{const a=this._getShaderErrors(s,r,"vertex"),u=this._getShaderErrors(s,t,"fragment");O("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+` + +Program Info Log: `+o+` +`+a+` +`+u)}else o!==""&&z("WebGLProgram: Program Info Log:",o)}}_completeCompile(e,t){const{state:r,gl:s}=this,n=this.get(t),{programGPU:o,fragmentShader:a,vertexShader:u}=n;s.getProgramParameter(o,s.LINK_STATUS)===!1&&this._logProgramError(o,a,u),r.useProgram(o);const l=e.getBindings();this._setupBindings(l,o),this.set(t,{programGPU:o,pipeline:o})}createComputePipeline(e,t){const{state:r,gl:s}=this,n={stage:"fragment",code:`#version 300 es +precision highp float; +void main() {}`};this.createProgram(n);const{computeProgram:o}=e,a=s.createProgram(),u=this.get(n).shaderGPU,l=this.get(o).shaderGPU,c=o.transforms,d=[],h=[];for(let m=0;mDf[s]===e),r=this.extensions;for(let s=0;s1,f=n.isXRRenderTarget===!0,p=f===!0&&n._hasExternalTextures===!0;let g=o.msaaFrameBuffer,m=o.depthRenderbuffer;const y=this.extensions.get("WEBGL_multisampled_render_to_texture"),x=this.extensions.get("OVR_multiview2"),_=this._useMultisampledExtension(n),N=ry(e);let A;if(c?(o.cubeFramebuffers||(o.cubeFramebuffers={}),A=o.cubeFramebuffers[N]):f&&p===!1?A=this._xrFramebuffer:(o.framebuffers||(o.framebuffers={}),A=o.framebuffers[N]),A===void 0){A=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,A);const v=e.textures,S=[];if(c){o.cubeFramebuffers[N]=A;const{textureGPU:F}=this.get(v[0]),U=this.renderer._activeCubeFace,W=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+U,F,W)}else{o.framebuffers[N]=A;for(let F=0;F0&&_===!1&&!n.multiview){if(g===void 0){const v=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);const S=[],P=e.textures;for(let F=0;F0&&this._useMultisampledExtension(s)===!1){const o=n.framebuffers[e.getCacheKey()];let a=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));const u=n.msaaFrameBuffer,l=n.msaaRenderbuffers,c=e.textures,d=c.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,u),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,o),d)for(let h=0;h0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const Si={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list"},Tr=typeof self<"u"&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Je={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},gt={Store:"store"},Te={Load:"load",Clear:"clear"},Lf={CCW:"ccw",CW:"cw"},Uf={None:"none",Back:"back"},Da={Uint16:"uint16",Uint32:"uint32"},b={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R16Unorm:"r16unorm",R16Snorm:"r16snorm",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RG16Unorm:"rg16unorm",RG16Snorm:"rg16snorm",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA16Unorm:"rgba16unorm",RGBA16Snorm:"rgba16snorm",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},tl={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},Vt={Linear:"linear",Nearest:"nearest"},fe={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},vs={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},Of={None:0,All:15},Qr={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},rl={Storage:"storage",ReadOnlyStorage:"read-only-storage"},sl={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},If={NonFiltering:"non-filtering",Comparison:"comparison"},Ss={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},kf={TwoD:"2d",ThreeD:"3d"},et={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},$A={All:"all"},Io={Vertex:"vertex",Instance:"instance"},Fa={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},Gf={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class zA extends wy{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class WA extends Ty{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let jA=0;class HA extends WA{constructor(e,t){super("StorageBuffer_"+jA++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:zt.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}const nl=[null];class qA{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.stencil?this.backend.renderer.reversedDepthBuffer===!0?t=b.Depth32FloatStencil8:t=b.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?t=b.Depth32Float:t=b.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const n=this.backend.renderer,o=n.getRenderTarget();t=o?o.samples:n.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);const r=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return e.textures!==null?e.textures.map(t=>this.getTextureFormatGPU(t)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return Si.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Si.LineList;if(e.isLine)return Si.LineStrip;if(e.isMesh)return Si.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const t=this.backend.parameters.outputType;if(t===void 0)return this._preferredCanvasFormat===null&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(t===St)return b.BGRA8Unorm;if(t===ht)return b.RGBA16Float;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function yr(i,e){nl[0]=e,i.queue.submit(nl),nl[0]=null}class Cy{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class Kn{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}class no{constructor(){this.label=""}reset(){this.label=""}}class My{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}class Di{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}class Fi{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}class By{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new XA,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}class XA{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}}class Py{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class Td{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}class vd{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}}const Zr=new Cy,Jr=new Kn,ko=new no,il=new My,ol=new Fi,un=new By,pi=new Di,Go=new Py,ln=new Td,ze=new vd;class KA extends ms{constructor(e){super(),this.device=e;const t=` +struct VarysStruct { + @builtin( position ) Position: vec4f, + @location( 0 ) vTex : vec2f, + @location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32, +}; + +@group( 0 ) @binding ( 2 ) +var flipY: u32; + +@vertex +fn mainVS( + @builtin( vertex_index ) vertexIndex : u32, + @builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct { + + var Varys : VarysStruct; + + var pos = array( + vec2f( -1, -1 ), + vec2f( -1, 3 ), + vec2f( 3, -1 ), + ); + + let p = pos[ vertexIndex ]; + let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 ); + Varys.vTex = p * mult + vec2f( 0.5 ); + Varys.Position = vec4f( p, 0, 1 ); + Varys.vBaseArrayLayer = instanceIndex; + + return Varys; + +} + +@group( 0 ) @binding( 0 ) +var imgSampler : sampler; + +@group( 0 ) @binding( 1 ) +var img2d : texture_2d; + +@fragment +fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( img2d, imgSampler, Varys.vTex ); + +} + +@group( 0 ) @binding( 1 ) +var img2dArray : texture_2d_array; + +@fragment +fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer ); + +} + +const faceMat = array( + mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x + mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x + mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y + mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y + mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z + mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z +); + +@group( 0 ) @binding( 1 ) +var imgCube : texture_cube; + +@fragment +fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 { + + return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) ); + +} +`;this.mipmapSampler=e.createSampler({minFilter:Vt.Linear}),this.flipYSampler=e.createSampler({minFilter:Vt.Nearest}),Jr.size=4,Jr.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(Jr),Jr.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),Jr.size=4,Jr.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(Jr),Jr.reset(),this.transferPipelines={},Go.label="mipmap",Go.code=t,this.mipmapShaderModule=e.createShaderModule(Go),Go.reset()}getTransferPipeline(e,t){t=t||"2d-array";const r=`${e}-${t}`;let s=this.transferPipelines[r];return s===void 0&&(un.label=`mipmap-${e}-${t}`,un.vertex={module:this.mipmapShaderModule},un.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},un.layout="auto",s=this.device.createRenderPipeline(un),un.reset(),this.transferPipelines[r]=s),s}flipY(e,t,r=0){const s=t.format,{width:n,height:o}=t.size;ln.size.width=n,ln.size.height=o,ln.format=s,ln.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;const a=this.device.createTexture(ln);ln.reset();const u=this.getTransferPipeline(s,e.textureBindingViewDimension),l=this.getTransferPipeline(s,a.textureBindingViewDimension),c=this.device.createCommandEncoder(ko),d=(h,f,p,g,m,y)=>{const x=h.getBindGroupLayout(0);ze.dimension=f.textureBindingViewDimension||"2d-array",ze.mipLevelCount=1;const _=f.createView(ze);ze.reset(),Zr.layout=x,Zr.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:_},{binding:2,resource:{buffer:y?this.flipUniformBuffer:this.noFlipUniformBuffer}});const N=this.device.createBindGroup(Zr);Zr.reset(),ze.dimension="2d",ze.mipLevelCount=1,ze.baseArrayLayer=m,ze.arrayLayerCount=1;const A=g.createView(ze);ze.reset(),pi.view=A,pi.loadOp=Te.Clear,pi.storeOp=gt.Store,ol.colorAttachments.push(pi);const v=c.beginRenderPass(ol);ol.reset(),pi.reset(),v.setPipeline(h),v.setBindGroup(0,N),v.draw(3,1,0,p),v.end()};d(u,e,r,a,0,!1),d(l,a,0,e,r,!0),yr(this.device,c.finish()),a.destroy()}generateMipmaps(e,t=null){const r=this.get(e),s=r.layers||this._mipmapCreateBundles(e);let n=t;n===null&&(ko.label="mipmapEncoder",n=this.device.createCommandEncoder(ko),ko.reset()),this._mipmapRunBundles(n,s),t===null&&yr(this.device,n.finish()),r.layers=s}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),s=r.getBindGroupLayout(0),n=[];for(let o=1;o0)for(let o=0,a=s.length;o0){for(const o of e.layerUpdates)this._copyBufferToTexture(t.image,r.texture,n,o,e.flipY,o);e.clearLayerUpdates()}else for(let o=0;o0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,n,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,n);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,n);else if(e.isHTMLTexture){const o=this.backend.device,a=this.backend.renderer.domElement,u=e.image;if(typeof o.queue.copyElementImageToTexture!="function")return;if(!r.hasPaintCallback){r.hasPaintCallback=!0,a.requestPaint();return}const l=n.size.width,c=n.size.height;o.queue.copyElementImageToTexture.length===2?o.queue.copyElementImageToTexture({source:u},{destination:{texture:r.texture},width:l,height:c}):o.queue.copyElementImageToTexture(u,l,c,{texture:r.texture}),e.flipY&&this._flipY(r.texture,n)}else if(s.length>0)for(let o=0,a=s.length;o0?e.width:r.size.width,c=a>0?e.height:r.size.height;zo.source=e,zo.flipY=n,cn.texture=t,cn.mipLevel=a,cn.origin.z=s,cn.premultipliedAlpha=o,at.width=l,at.height=c;try{u.queue.copyExternalImageToTexture(zo,cn,at)}catch{}finally{zo.reset(),cn.reset(),at.reset()}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new KA(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,s,n,o=0,a=0){const u=this.backend.device,l=e.data,c=this._getBytesPerTexel(r.format),d=e.width*c;ut.texture=t,ut.mipLevel=a,ut.origin.z=s,Ir.offset=e.width*e.height*c*o,Ir.bytesPerRow=d,at.width=e.width,at.height=e.height,u.queue.writeTexture(ut,l,Ir,at),ut.reset(),Ir.reset(),at.reset(),n===!0&&this._flipY(t,r,s)}_copyCompressedBufferToTexture(e,t,r,s=null){const n=this.backend.device,o=this._getBlockData(r.format),a=r.size.depthOrArrayLayers>1,u=s&&s.size>0?s:null;for(let l=0;l]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,oC=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,$f={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},aC=i=>{i=i.trim();const e=i.match(iC);if(e!==null&&e.length===4){const t=e[2],r=[];let s=null;for(;(s=oC.exec(t))!==null;)r.push({name:s[1],type:s[2]});const n=[];for(let c=0;c "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class lC extends yy{parseFunction(e){return new uC(e)}}const cC={[zt.READ_ONLY]:"read",[zt.WRITE_ONLY]:"write",[zt.READ_WRITE]:"read_write"},zf={[Va]:"repeat",[Oi]:"clamp",[Ga]:"mirror"},al={vertex:Tr.VERTEX,fragment:Tr.FRAGMENT,compute:Tr.COMPUTE},Wf={instance:!0,swizzleAssign:!1,storageBuffer:!0},dC={"^^":"tsl_xor"},hC={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},jf={},gi={tsl_xor:new Fe("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Fe("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Fe("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Fe("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Fe("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Fe("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Fe("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Fe("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Fe("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Fe("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Fe("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Fe("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),inverse_mat2:new Fe(` +fn tsl_inverse_mat2( m : mat2x2 ) -> mat2x2 { + + let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ]; + + return mat2x2( + m[ 1 ][ 1 ], - m[ 0 ][ 1 ], + - m[ 1 ][ 0 ], m[ 0 ][ 0 ] + ) * ( 1.0 / det ); + +} +`),inverse_mat3:new Fe(` +fn tsl_inverse_mat3( m : mat3x3 ) -> mat3x3 { + + let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; + let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; + let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; + + let b01 = a22 * a11 - a12 * a21; + let b11 = - a22 * a10 + a12 * a20; + let b21 = a21 * a10 - a11 * a20; + + let det = a00 * b01 + a01 * b11 + a02 * b21; + + return mat3x3( + b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ), + b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ), + b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 ) + ) * ( 1.0 / det ); + +} +`),inverse_mat4:new Fe(` +fn tsl_inverse_mat4( m : mat4x4 ) -> mat4x4 { + + let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ]; + let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ]; + let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ]; + let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ]; + + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + + let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + return mat4x4( + a11 * b11 - a12 * b10 + a13 * b09, + a02 * b10 - a01 * b11 - a03 * b09, + a31 * b05 - a32 * b04 + a33 * b03, + a22 * b04 - a21 * b05 - a23 * b03, + a12 * b08 - a10 * b11 - a13 * b07, + a00 * b11 - a02 * b08 + a03 * b07, + a32 * b02 - a30 * b05 - a33 * b01, + a20 * b05 - a22 * b02 + a23 * b01, + a10 * b10 - a11 * b08 + a13 * b06, + a01 * b08 - a00 * b10 - a03 * b06, + a30 * b04 - a31 * b02 + a33 * b00, + a21 * b02 - a20 * b04 - a23 * b00, + a11 * b07 - a10 * b09 - a12 * b06, + a00 * b09 - a01 * b07 + a02 * b06, + a31 * b01 - a30 * b03 - a32 * b00, + a20 * b03 - a21 * b01 + a22 * b00 + ) * ( 1.0 / det ); + +} +`),biquadraticTexture:new Fe(` +fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { + + let res = vec2f( iRes ); + + let uvScaled = coord * res; + let uvWrapping = ( ( uvScaled % res ) + res ) % res; + + // https://www.shadertoy.com/view/WtyXRy + + let uv = uvWrapping - 0.5; + let iuv = floor( uv ); + let f = fract( uv ); + + let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); + let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); + let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); + let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); + + return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); + +} +`),biquadraticTextureArray:new Fe(` +fn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f { + + let res = vec2f( iRes ); + + let uvScaled = coord * res; + let uvWrapping = ( ( uvScaled % res ) + res ) % res; + + // https://www.shadertoy.com/view/WtyXRy + + let uv = uvWrapping - 0.5; + let iuv = floor( uv ); + let f = fract( uv ); + + let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level ); + let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level ); + let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level ); + let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level ); + + return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); + +} +`)},fC={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inverse_mat2:"tsl_inverse_mat2",inverse_mat3:"tsl_inverse_mat3",inverse_mat4:"tsl_inverse_mat4",inversesqrt:"inverseSqrt",bitcast:"bitcast",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let Fy="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(Fy+=`diagnostic( off, derivative_uniformity ); +`);class pC extends my{constructor(e,t){super(e,t,new lC),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,r,s,n,o=this.shaderStage){return o==="fragment"?s?n?`textureSample( ${t}, ${t}_sampler, ${r}, ${s}, ${n} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:n?`textureSample( ${t}, ${t}_sampler, ${r}, ${n} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",s)}generateTextureSampleLevel(e,t,r,s,n,o){return this.isUnfilterable(e)===!1?n?o?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${s} )`:o?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,o,s,n):this.generateTextureLod(e,t,r,n,o,s)}generateWrapFunction(e){const t=`tsl_coord_${zf[e.wrapS]}S_${zf[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`;let r=jf[t];if(r===void 0){const s=[],n=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let o=`fn ${t}( coord : ${n} ) -> ${n} { + + return ${n}( +`;const a=(u,l)=>{u===Va?(s.push(gi.repeatWrapping_float),o+=` tsl_repeatWrapping_float( coord.${l} )`):u===Oi?(s.push(gi.clampWrapping_float),o+=` tsl_clampWrapping_float( coord.${l} )`):u===Ga?(s.push(gi.mirrorWrapping_float),o+=` tsl_mirrorWrapping_float( coord.${l} )`):(o+=` coord.${l}`,z(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};a(e.wrapS,"x"),o+=`, +`,a(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(o+=`, +`,a(e.wrapR,"z")),o+=` + ); + +} +`,jf[t]=r=new Fe(o,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.cache);s.dimensionsSnippet===void 0&&(s.dimensionsSnippet={});let n=s.dimensionsSnippet[r];if(s.dimensionsSnippet[r]===void 0){let o,a;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),l=u>1;e.is3DTexture||e.isData3DTexture?a="vec3":a="vec2",l||e.isStorageTexture?o=t:o=`${t}${r?`, u32( ${r} )`:""}`,n=new ua(new la(`textureDimensions( ${o} )`,a)),s.dimensionsSnippet[r]=n,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(s.arrayLayerCount=new ua(new la(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new ua(new la("6u","u32")))}return n.build(this)}generateFilteredTexture(e,t,r,s,n="0u",o){const a=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,n);return s&&(r=`${r} + vec2(${s}) / ${u}`),o?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${a}( ${r} ), ${u}, u32( ${o} ), u32( ${n} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${a}( ${r} ), ${u}, u32( ${n} ) )`)}generateTextureLod(e,t,r,s,n,o="0u"){if(e.isCubeTexture===!0){n&&(r=`${r} + vec3(${n})`);const f=e.isDepthTexture?"u32":"f32";return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${f}( ${o} ) )`}const a=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,o),l=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",c=l==="vec3"?"vec3( 1, 1, 1 )":"vec2( 1, 1 )";n&&(r=`${r} + ${l}(${n}) / ${l}( ${u} )`);const d=`${l}( 0 )`,h=`${l}( ${u} - ${c} )`;return r=`${l}( clamp( floor( ${a}( ${r} ) * ${l}( ${u} ) ), ${d}, ${h} ) )`,this.generateTextureLoad(e,t,r,o,s,null)}generateStorageTextureLoad(e,t,r,s,n,o){o&&(r=`${r} + ${o}`);let a;return n?a=`textureLoad( ${t}, ${r}, ${n} )`:a=`textureLoad( ${t}, ${r} )`,a}generateTextureLoad(e,t,r,s,n,o){s===null&&(s="0u"),o&&(r=`${r} + ${o}`);let a;return n?a=`textureLoad( ${t}, ${r}, ${n}, u32( ${s} ) )`:(a=`textureLoad( ${t}, ${r}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,r,s,n){let o;return s?o=`textureStore( ${t}, ${r}, ${s}, ${n} )`:o=`textureStore( ${t}, ${r}, ${n} )`,o}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(js.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.type===dt||this.isSampleCompare(e)===!1&&e.minFilter===Lt&&e.magFilter===Lt||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,n,o=this.shaderStage){let a=null;return this.isUnfilterable(e)?a=this.generateTextureLod(e,t,r,s,n,"0",o):a=this._generateTextureSample(e,t,r,s,n,o),a}generateTextureGrad(e,t,r,s,n,o,a=this.shaderStage){if(a==="fragment")return n?o?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${n}, ${s[0]}, ${s[1]}, ${o} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${n}, ${s[0]}, ${s[1]} )`:o?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]}, ${o} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;O(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,r,s,n,o,a=this.shaderStage){if(a==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?o?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${s} )`:o?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;O(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureGather(e,t,r,s,n,o){const a=e.isDepthTexture===!0?"":`${s}, `;return n?o?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${n}, ${o} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${n} )`:o?`textureGather( ${a}${t}, ${t}_sampler, ${r}, ${o} )`:`textureGather( ${a}${t}, ${t}_sampler, ${r})`}generateTextureGatherCompare(e,t,r,s,n,o){return n?o?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${n}, ${s})`:o?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s})`}generateTextureLevel(e,t,r,s,n,o){return this.isUnfilterable(e)===!1?n?o?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${n}, ${s} )`:o?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,o,s,n):this.generateTextureLod(e,t,r,n,o,s)}generateTextureBias(e,t,r,s,n,o,a=this.shaderStage){if(a==="fragment")return n?o?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${n}, ${s}, ${o} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${n}, ${s} )`:o?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${o} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;O(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const r=e.name,s=e.type;return s==="texture"||s==="cubeTexture"||s==="cubeDepthTexture"||s==="storageTexture"||s==="texture3D"?r:s==="buffer"||s==="storageBuffer"||s==="indirectStorageBuffer"?this.isCustomStruct(e)?r:r+".value":e.groupNode.name+"."+r}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=dC[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(z("WebGPURenderer: Atomic operations are only supported in compute shaders."),zt.READ_WRITE):zt.READ_ONLY:e.access}getStorageAccess(e,t){return cC[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const n=super.getUniformFromNode(e,t,r,s),o=this.getDataFromNode(e,r,this.globalCache);if(o.uniformGPU===void 0){let a;const u=e.groupNode,l=u.name,c=this.getBindGroupArray(l,r);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let d=null;const h=this.getNodeAccess(e,r);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?d=new bc(n.name,n.node,u,h):d=new Ja(n.name,n.node,u,h):t==="cubeTexture"||t==="cubeDepthTexture"?d=new Ry(n.name,n.node,u,h):t==="texture3D"&&(d=new bc(n.name,n.node,u,h)),d.store=e.isStorageTextureNode===!0,d.mipLevel=d.store?e.mipLevel:0,d.setVisibility(al[r]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&d.store===!1||e.gatherNode!==null){const p=new zA(`${n.name}_sampler`,n.node,u);p.setVisibility(al[r]),c.push(p,d),a=[p,d]}else c.push(d),a=[d]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const d=this.getSharedDataFromNode(e);let h=d.buffer;if(h===void 0){const f=t==="buffer"?Sy:HA;h=new f(e,u),d.buffer=h}h.setVisibility(h.getVisibility()|al[r]),c.push(h),a=h,n.name=s||"NodeBuffer_"+n.id}else{let d=this.uniformGroups[l];d===void 0&&(d=new Ny(l,u),d.setVisibility(Tr.VERTEX|Tr.FRAGMENT|Tr.COMPUTE),this.uniformGroups[l]=d),c.indexOf(d)===-1&&c.push(d),a=this.getNodeUniform(n,t);const h=a.name;d.uniforms.some(p=>p.name===h)||d.addUniform(a)}o.uniformGPU=a}return n}getBuiltin(e,t,r,s=this.shaderStage){const n=this.builtins[s]||(this.builtins[s]=new Map);return n.has(e)===!1&&n.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const o of t.inputs)s.push(o.name+" : "+this.getType(o.type));let n=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} { +${r.vars} +${r.code} +`;return r.result&&(n+=` return ${r.result}; +`),n+=` +} +`,n}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(r!==void 0)for(const s of r)t.push(`enable ${s};`);return t.join(` +`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(r!==void 0)for(const{name:s,property:n,type:o}of r.values())t.push(`@builtin( ${s} ) ${n} : ${o}`);return t.join(`, + `)}getScopedArray(e,t,r,s){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:r,scope:s,bufferType:n,bufferCount:o}of this.scopedArrays.values()){const a=this.getType(n);t.push(`var<${s}> ${r}: array< ${a}, ${o} >;`)}return t.join(` +`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const r=this.getBuiltins("attribute");r&&t.push(r);const s=this.getAttributesArray();for(let n=0,o=s.length;n"),t.push(` ${s+r.name} : ${n}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`, +`)}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const s=[];for(const n of r){let o=`struct ${n.name} { +`;o+=this.getStructMembers(n),o+=` +};`,s.push(o)}t=` +`+s.join(` + +`)+` +`}return t}getVar(e,t,r=null,s=""){let n=`var${s} ${t} : `;return r!==null?n+=this.generateArrayDeclaration(e,r):n+=this.getType(e),n}getVars(e,t=!1){let r="";t&&(r="");const s=[],n=this.vars[e];if(n!==void 0)for(const o of n)s.push(`${this.getVar(o.type,o.name,o.count,r)};`);return t?s.join(` +`):` + ${s.join(` + `)} +`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","builtinClipSpace","vec4","vertex"),e==="vertex"||e==="fragment"){const n=this.varyings,o=this.vars[e];let a=0;for(let u=0;ur.value.itemSize;return s&&!n}getUniforms(e){const t=this.renderer.backend,r=this.uniforms[e],s=[],n=[],o=[],a={};for(const l of r){const c=l.groupNode.name,d=this.bindingsIndexes[c];if(l.type==="texture"||l.type==="cubeTexture"||l.type==="cubeDepthTexture"||l.type==="storageTexture"||l.type==="texture3D"){const h=l.node,f=h.value;(f.isCubeTexture===!0||this.isUnfilterable(f)===!1&&h.isStorageTextureNode!==!0||h.gatherNode!==null)&&(this.isSampleCompare(f)&&h.compareNode!==null?s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name}_sampler : sampler_comparison;`):s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name}_sampler : sampler;`));let g,m="";const{primarySamples:y}=t.utils.getTextureSampleData(f);if(y>1&&(m="_multisampled"),f.isCubeTexture===!0&&f.isDepthTexture===!0)g="texture_depth_cube";else if(f.isCubeTexture===!0)g="texture_cube";else if(f.isDepthTexture===!0)t.compatibilityMode&&f.compareFunction===null?g=`texture${m}_2d`:g=`texture_depth${m}_2d${f.isArrayTexture===!0?"_array":""}`;else if(l.node.isStorageTextureNode===!0){const x=_c(f,t.device),_=this.getStorageAccess(l.node,e),N=l.node.value.is3DTexture,A=l.node.value.isArrayTexture;g=`texture_storage_${N?"3d":`2d${A?"_array":""}`}<${x}, ${_}>`}else if(f.isArrayTexture===!0||f.isDataArrayTexture===!0||f.isCompressedArrayTexture===!0)g="texture_2d_array";else if(f.is3DTexture===!0||f.isData3DTexture===!0)g="texture_3d";else{const x=this.getComponentTypeFromTexture(f).charAt(0);g=`texture${m}_2d<${x}32>`}s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${l.name} : ${g};`)}else if(l.type==="buffer"||l.type==="storageBuffer"||l.type==="indirectStorageBuffer"){const h=l.node,f=this.getType(h.getNodeType(this)),p=h.bufferCount,g=p>0&&l.type==="buffer"?", "+p:"",m=h.isStorageBufferNode?`storage, ${this.getStorageAccess(h,e)}`:"uniform";if(this.isCustomStruct(l))n.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var<${m}> ${l.name} : ${f};`);else{const x=` value : array< ${h.isAtomic?`atomic<${f}>`:`${f}`}${g} >`;n.push(this._getWGSLStructBinding(l.name,x,m,d.binding++,d.group))}}else{const h=l.groupNode.name;if(a[h]===void 0){const f=this.uniformGroups[h];if(f!==void 0){const p=[];for(const m of f.uniforms){const y=m.getType(),x=this.getType(this.getVectorType(y));p.push(` ${m.name} : ${x}`)}let g=this.uniformGroupsBindings[h];g===void 0&&(g={index:d.binding++,id:d.group},this.uniformGroupsBindings[h]=g),a[h]={index:g.index,id:g.id,snippets:p}}}}}for(const l in a){const c=a[l];o.push(this._getWGSLStructBinding(l,c.snippets.join(`, +`),"uniform",c.index,c.id))}return[...s,...n,...o].join(` +`)}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=this.allowGlobalVariables,s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t,r),s.codes=this.getCodes(t),s.directives=this.getDirectives(t),s.scopedArrays=this.getScopedArrays(t);let n=`// code + +`;n+=this.flowCode[t];const o=this.flowNodes[t],a=o[o.length-1],u=a.outputNode,l=u!==void 0&&u.isOutputStructNode===!0;for(const c of o){const d=this.getFlowData(c),h=c.name;if(h&&(n.length>0&&(n+=` +`),n+=` // flow -> ${h} +`),n+=`${d.code} + `,c===a&&t!=="compute"){if(n+=`// result + + `,t==="vertex")n+=`varyings.builtinClipSpace = ${d.result};`;else if(t==="fragment")if(l)s.returnType=u.getNodeType(this),s.structs+="var output : "+s.returnType+";",n+=`return ${d.result};`;else{let f=` @location( 0 ) color: ${this.getType(this.getOutputType())}`;const p=this.getBuiltins("output");p&&(f+=`, + `+p),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",f),s.structs+=` +var output : OutputStruct;`,n+=`output.color = ${this.format(d.result,a.getNodeType(this),this.getOutputType())}; + + return output;`}}}s.flow=n}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return t!==null&&(r=this._getWGSLMethod(e+"_"+t)),r===void 0&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return hC[e]||e}isAvailable(e){let t=Wf[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),Wf[e]=t),t}_getWGSLMethod(e){return gi[e]!==void 0&&this._include(e),fC[e]}_include(e){const t=gi[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} +// directives +${e.directives} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// varyings +${e.varyings} +var varyings : VaryingsStruct; + +// vars +${e.vars} + +// codes +${e.codes} + +@vertex +fn main( ${e.attributes} ) -> VaryingsStruct { + + // flow + ${e.flow} + + return varyings; + +} +`}_getWGSLFragmentCode(e){return`${this.getSignature()} +// global +${Fy} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// vars +${e.vars} + +// codes +${e.codes} + +@fragment +fn main( ${e.varyings} ) -> ${e.returnType} { + + // flow + ${e.flow} + +} +`}_getWGSLComputeCode(e,t){const[r,s,n]=t;return`${this.getSignature()} +// directives +${e.directives} + +// system +var instanceIndex : u32; + +// locals +${e.scopedArrays} + +// structs +${e.structs} + +// uniforms +${e.uniforms} + +// vars +${this.allowGlobalVariables?e.vars:""} + +// codes +${e.codes} + +@compute @workgroup_size( ${r}, ${s}, ${n} ) +fn main( ${e.attributes} ) { + + // local vars + ${this.allowGlobalVariables?"":e.vars} + + // system + instanceIndex = globalId.x + + globalId.y * ( ${r} * numWorkgroups.x ) + + globalId.z * ( ${r} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y ); + + // flow + ${e.flow} + +} +`}_getWGSLStruct(e,t){return` +struct ${e} { +${t} +};`}_getWGSLStructBinding(e,t,r,s=0,n=0){const o=e+"Struct";return`${this._getWGSLStruct(o,t)} +@binding( ${s} ) @group( ${n} ) +var<${r}> ${e} : ${o};`}}const ot=new Kn,ul=new no,Ly=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array<"u"&&Ly.set(Float16Array,["float16"]);const gC=new Map([[zp,["float16"]]]),mC=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class yC{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,n=s.get(r);let o=n.buffer;if(o===void 0){const a=s.device;let u=r.array;if(e.normalized===!1){if(u.constructor===Int16Array||u.constructor===Int8Array)u=new Int32Array(u);else if((u.constructor===Uint16Array||u.constructor===Uint8Array)&&(u=new Uint32Array(u),t&GPUBufferUsage.INDEX))for(let h=0;h1&&r.itemSize*u.BYTES_PER_ELEMENT%4!==0){const h=r.itemSize*u.BYTES_PER_ELEMENT;l=Math.floor((h+3)/4)*4/u.BYTES_PER_ELEMENT}if(l!==void 0){const h=r.itemSize,f=new u.constructor(r.count*l);for(let p=0;p1&&d%4!==0&&(d=Math.floor((d+3)/4)*4)),n.normalized===!1&&(n.array.constructor===Int16Array||n.array.constructor===Uint16Array)&&(d=4),u={arrayStride:d,attributes:[],stepMode:h},r.set(a,u)}const l=this._getVertexFormat(n),c=n.isInterleavedBufferAttribute===!0?n.offset*o:0;u.attributes.push({shaderLocation:s,offset:c,format:l})}return Array.from(r.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,r=0,s=-1){const n=this.backend,o=n.device,u=n.get(this._getBufferAttribute(e)).buffer,l=s===-1?u.size-r:s;let c;if(t!==null&&t.isReadbackBuffer){const f=n.get(t);if(t._mapped===!0)throw new Error("THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.");if(t._mapped=!0,f.readBufferGPU===void 0){ot.label=`${t.name}_readback`,ot.size=t.maxByteLength,ot.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=o.createBuffer(ot),ot.reset();const p=()=>{t.buffer=null,t._mapped=!1,c.unmap()},g=()=>{t.buffer=null,t._mapped=!1,c.destroy(),n.delete(t),t.removeEventListener("release",p),t.removeEventListener("dispose",g)};t.addEventListener("release",p),t.addEventListener("dispose",g),f.readBufferGPU=c}else c=f.readBufferGPU}else ot.label=`${e.name}_readback`,ot.size=l,ot.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,c=o.createBuffer(ot),ot.reset();ul.label=`readback_encoder_${e.name}`;const d=o.createCommandEncoder(ul);ul.reset(),d.copyBufferToBuffer(u,r,c,0,l);const h=d.finish();if(yr(o,h),await c.mapAsync(GPUMapMode.READ,0,l),t===null){const p=c.getMappedRange(0,l).slice();return c.destroy(),p}else{if(t.isReadbackBuffer)return t.buffer=c.getMappedRange(0,l),t;{const f=c.getMappedRange(0,l);return new Uint8Array(t).set(new Uint8Array(f)),c.destroy(),t}}}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,s=e.array.constructor,n=e.constructor;let o;if(t===1)o=mC.get(s);else{const u=(gC.get(n)||Ly.get(s))[r?1:0];if(u){const l=s.BYTES_PER_ELEMENT*t,d=Math.floor((l+3)/4)*4/s.BYTES_PER_ELEMENT;if(d%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");o=`${u}x${d}`}}return o||O("WebGPUAttributeUtils: Vertex format not supported yet."),o}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const Mt=new Cy,mi=new Kn,dn=new vd;class bC{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class _C{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,r=t.device,s=t.get(e);if(s.layout)return s.layout.layoutGPU;const n=this._createLayoutEntries(e),o=Vn(JSON.stringify(n));let a=this._bindGroupLayoutCache.get(o);return a===void 0&&(a=new bC(r.createBindGroupLayout({entries:n})),this._bindGroupLayoutCache.set(o,a)),a.usedTimes++,s.layout=a,s.layoutKey=o,a.layoutGPU}createBindings(e,t,r,s=0){const{backend:n}=this,o=n.get(e),a=this.createBindingsLayout(e);let u;r>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[r]===s&&(u=o.groups[r])),u===void 0&&(u=this.createBindGroup(e,a),r>0&&(o.groups[r]=u,o.versions[r]=s)),o.group=u}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,n=t.get(e).buffer,o=e.updateRanges;if(o.length===0)r.queue.writeBuffer(n,0,s,0);else{const a=ga(s),u=a?1:s.BYTES_PER_ELEMENT;let l=o[0].start;for(let c=0,d=o.length;c1&&(h+=`-${u.texture.depthOrArrayLayers}`),h+=`-${c}-${d}`,l=u[h],l===void 0){const f=$A.All;let p;a.isSampledCubeTexture?p=et.Cube:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?p=et.TwoDArray:a.isSampledTexture3D?p=et.ThreeD:p=et.TwoD,dn.aspect=f,dn.dimension=p,dn.mipLevelCount=c,dn.baseMipLevel=d,l=u[h]=u.texture.createView(dn),dn.reset()}}Mt.entries.push({binding:n,resource:l})}else if(a.isSampler){const u=r.get(a);Mt.entries.push({binding:n,resource:u.sampler})}n++}const o=s.createBindGroup(Mt);return Mt.reset(),o}_createLayoutEntries(e){const t=[];let r=0;for(const s of e.bindings){const n=this.backend,o={binding:r,visibility:s.visibility};if(s.isUniformBuffer||s.isStorageBuffer){const a={};s.isStorageBuffer&&(s.visibility&Tr.COMPUTE&&(s.access===zt.READ_WRITE||s.access===zt.WRITE_ONLY)?a.type=rl.Storage:a.type=rl.ReadOnlyStorage),o.buffer=a}else if(s.isSampledTexture&&s.store){const a={};a.format=this.backend.get(s.texture).texture.format;const u=s.access;u===zt.READ_WRITE?a.access=sl.ReadWrite:u===zt.WRITE_ONLY?a.access=sl.WriteOnly:a.access=sl.ReadOnly,s.texture.isArrayTexture?a.viewDimension=et.TwoDArray:s.texture.is3DTexture&&(a.viewDimension=et.ThreeD),o.storageTexture=a}else if(s.isSampledTexture){const a={},{primarySamples:u}=n.utils.getTextureSampleData(s.texture);if(u>1&&(a.multisampled=!0,s.texture.isDepthTexture||(a.sampleType=Ss.UnfilterableFloat)),s.texture.isDepthTexture)n.compatibilityMode&&s.texture.compareFunction===null?a.sampleType=Ss.UnfilterableFloat:a.sampleType=Ss.Depth;else{const l=s.texture.type;l===Ze?a.sampleType=Ss.SInt:l===Ge?a.sampleType=Ss.UInt:l===dt&&(this.backend.hasFeature("float32-filterable")?a.sampleType=Ss.Float:a.sampleType=Ss.UnfilterableFloat)}s.isSampledCubeTexture?a.viewDimension=et.Cube:s.texture.isArrayTexture||s.texture.isDataArrayTexture||s.texture.isCompressedArrayTexture?a.viewDimension=et.TwoDArray:s.isSampledTexture3D&&(a.viewDimension=et.ThreeD),o.texture=a}else if(s.isSampler){const a={};s.texture.isDepthTexture&&(s.texture.compareFunction!==null&&s.textureNode.compareNode!==null&&n.hasCompatibility(js.TEXTURE_COMPARE)?a.type=If.Comparison:a.type=If.NonFiltering),o.sampler=a}else O(`WebGPUBindingUtils: Unsupported binding "${s}".`);t.push(o),r++}return t}deleteBindGroupData(e){const{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,r.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class xC{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}class TC{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}}class vC{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}}const yi=new TC,hn=new vC,fn=new My,Bt=new By;class SC{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:n,pipeline:o}=e,{vertexProgram:a,fragmentProgram:u}=o,l=this.backend,c=l.device,d=l.utils,h=l.get(o),f=[];for(const X of e.getBindings()){const ue=l.get(X),{layoutGPU:D}=ue.layout;f.push(D)}const p=l.attributeUtils.createShaderVertexBuffers(e);let g;s.blending!==Wr&&(s.blending!==Fr||s.transparent!==!1)&&(g=this._getBlending(s));let m={};s.stencilWrite===!0&&(m={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const y=this._getColorWriteMask(s),x=[];if(e.context.textures!==null){const X=e.context.textures,ue=e.context.mrt;for(let D=0;D1,Bt.layout=F;const U={},W=e.context.depth,se=e.context.stencil;(W===!0||se===!0)&&(W===!0&&(U.format=S,U.depthWriteEnabled=s.depthWrite,U.depthCompare=v),se===!0&&(U.stencilFront=m,U.stencilBack=m,U.stencilReadMask=s.stencilFuncMask,U.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&A.topology===Si.TriangleList&&(U.depthBias=s.polygonOffsetUnits,U.depthBiasSlopeScale=s.polygonOffsetFactor,U.depthBiasClamp=0),Bt.depthStencil=U),c.pushErrorScope("validation");const ie=[{program:a,module:_.module},{program:u,module:N.module}],he=Bt.label;if(t===null)h.pipeline=c.createRenderPipeline(Bt),Bt.reset(),c.popErrorScope().then(X=>{X!==null&&(h.error=!0,O(`WebGPURenderer: Render pipeline creation failed (${he}): ${X.message}`),this._reportShaderDiagnostics(ie,he))});else{const X=new Promise(async ue=>{try{let D=null,I=null;try{I=c.createRenderPipelineAsync(Bt)}catch(le){D=le}if(Bt.reset(),I!==null)try{h.pipeline=await I}catch(le){D=le}const Y=await c.popErrorScope();if(Y!==null||D!==null){h.error=!0;const le=Y&&Y.message||D&&D.message||"unknown";O(`WebGPURenderer: Async render pipeline creation failed (${he}): ${le}`),await this._reportShaderDiagnostics(ie,he)}}finally{ue()}});t.push(X)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:n}=r,o=s.getCurrentDepthStencilFormat(e),a=s.getCurrentColorFormats(e),u=this._getSampleCount(e);fn.label=t,fn.colorFormats=a,fn.depthStencilFormat=o,fn.sampleCount=u;const l=n.createRenderBundleEncoder(fn);return fn.reset(),l}createComputePipeline(e,t){const r=this.backend,s=r.device,n=r.get(e.computeProgram).module,o=r.get(e),a=[];for(const d of t){const h=r.get(d),{layoutGPU:f}=h.layout;a.push(f)}const u=e.computeProgram,l=`computePipeline_${u.stage}${u.name?`_${u.name}`:""}`;s.pushErrorScope("validation"),hn.bindGroupLayouts=a;const c=s.createPipelineLayout(hn);hn.reset(),yi.label=l,yi.compute=n,yi.layout=c,o.pipeline=s.createComputePipeline(yi),yi.reset(),s.popErrorScope().then(d=>{d!==null&&(o.error=!0,O(`WebGPURenderer: Compute pipeline creation failed (${l}): ${d.message}`),this._reportShaderDiagnostics([{program:u,module:n.module}],l))})}async _reportShaderDiagnostics(e,t){for(const{program:r,module:s}of e){const n=await s.getCompilationInfo();if(n.messages.length===0)continue;const o=r.code.split(` +`);for(const a of n.messages){const u=a.lineNum>0?` at line ${a.lineNum}${a.linePos>0?`:${a.linePos}`:""}`:"",l=`WebGPURenderer [${t} / ${r.stage} ${a.type}]${u}: ${a.message}`;let c="";a.lineNum>0&&a.lineNum<=o.length&&(c=` + ${o[a.lineNum-1]}`,a.linePos>0&&(c+=` + ${" ".repeat(a.linePos-1)}^`)),(a.type==="error"?O:z)(l+c)}}}_getBlending(e){let t,r;const s=e.blending,n=e.blendSrc,o=e.blendDst,a=e.blendEquation;if(s===Sn){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:n,l=e.blendDstAlpha!==null?e.blendDstAlpha:o,c=e.blendEquationAlpha!==null?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(n),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(c)}}else{const u=e.premultipliedAlpha,l=(c,d,h,f)=>{t={srcFactor:c,dstFactor:d,operation:vs.Add},r={srcFactor:h,dstFactor:f,operation:vs.Add}};if(u)switch(s){case Fr:l(fe.One,fe.OneMinusSrcAlpha,fe.One,fe.OneMinusSrcAlpha);break;case bn:l(fe.One,fe.One,fe.One,fe.One);break;case yn:l(fe.Zero,fe.OneMinusSrc,fe.Zero,fe.One);break;case mn:l(fe.Dst,fe.OneMinusSrcAlpha,fe.Zero,fe.One);break}else switch(s){case Fr:l(fe.SrcAlpha,fe.OneMinusSrcAlpha,fe.One,fe.OneMinusSrcAlpha);break;case bn:l(fe.SrcAlpha,fe.One,fe.One,fe.One);break;case yn:O(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case mn:O(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break}}if(t!==void 0&&r!==void 0)return{color:t,alpha:r};O("WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case rs:t=fe.Zero;break;case Bp:t=fe.One;break;case Mp:t=fe.Src;break;case wp:t=fe.OneMinusSrc;break;case Cp:t=fe.SrcAlpha;break;case Np:t=fe.OneMinusSrcAlpha;break;case Ep:t=fe.Dst;break;case Sp:t=fe.OneMinusDst;break;case Rp:t=fe.DstAlpha;break;case vp:t=fe.OneMinusDstAlpha;break;case Ap:t=fe.SrcAlphaSaturated;break;case Ww:t=fe.Constant;break;case jw:t=fe.OneMinusConstant;break;default:O("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case Vb:t=Je.Never;break;case Gb:t=Je.Always;break;case kb:t=Je.Less;break;case Ib:t=Je.LessEqual;break;case Ob:t=Je.Equal;break;case Ub:t=Je.GreaterEqual;break;case Lb:t=Je.Greater;break;case Fb:t=Je.NotEqual;break;default:O("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case Kb:t=Qr.Keep;break;case Xb:t=Qr.Zero;break;case qb:t=Qr.Replace;break;case Hb:t=Qr.Invert;break;case jb:t=Qr.IncrementClamp;break;case Wb:t=Qr.DecrementClamp;break;case zb:t=Qr.IncrementWrap;break;case $b:t=Qr.DecrementWrap;break;default:O("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Dr:t=vs.Add;break;case Tp:t=vs.Subtract;break;case xp:t=vs.ReverseSubtract;break;case Qb:t=vs.Min;break;case Yb:t=vs.Max;break;default:O("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},n=this.backend.utils;s.topology=n.getPrimitiveTopology(e,r),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?Da.Uint16:Da.Uint32);let o=r.side===ft;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(o=!o),s.frontFace=o===!0?Lf.CW:Lf.CCW,s.cullMode=r.side===Gr?Uf.None:Uf.Back,s}_getColorWriteMask(e){return e.colorWrite===!0?Of.All:Of.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Je.Always;else{const r=this.backend.parameters.reversedDepthBuffer?$p[e.depthFunc]:e.depthFunc;switch(r){case Gp:t=Je.Never;break;case kp:t=Je.Always;break;case Ip:t=Je.Less;break;case Op:t=Je.LessEqual;break;case Up:t=Je.Equal;break;case Lp:t=Je.GreaterEqual;break;case Fp:t=Je.Greater;break;case Dp:t=Je.NotEqual;break;default:O("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class Uy{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}const dr=new Kn,NC=new no,bi=new Uy;class wC extends Ay{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,bi.label=`queryset_global_timestamp_${t}`,bi.type="timestamp",bi.count=this.maxQueries,this.querySet=this.device.createQuerySet(bi),bi.reset();const s=this.maxQueries*8;dr.label=`buffer_timestamp_resolve_${t}`,dr.size=s,dr.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(dr),dr.reset(),dr.label=`buffer_timestamp_result_${t}`,dr.size=s,dr.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(dr),dr.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Be(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder(NC);s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const n=s.finish();if(yr(this.device,n),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const o=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a={},u=[];for(const[c,d]of e){const h=c.match(/^(.*):f(\d+)$/),f=parseInt(h[2]);u.includes(f)===!1&&u.push(f),a[f]===void 0&&(a[f]=0);const p=o[d],g=o[d+1],m=Number(g-p)/1e6;this.timestamps.set(c,m),a[f]+=m}const l=a[u[u.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=u,l}catch(e){return O("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){O("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){O("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class RC{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}}class Wo{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}class EC{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}}const Qt={r:0,g:0,b:0,a:1},Pt=new Kn,pt=new no,jo=new RC,_i=new Uy,Ho=new Py,qo=new EC,kt=new eu,hr=new eu,De=new vd,Br=new Dy;class AC extends Ey{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new qA(this),this.attributeUtils=new yC(this),this.bindingUtils=new _C(this),this.capabilities=new xC(this),this.pipelineUtils=new SC(this),this.textureUtils=new nC(this),this.occludedResolveCache=new Map;const t=typeof navigator>"u"?!0:/Android/.test(navigator.userAgent)===!1;this._compatibility={[js.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);const t=this.parameters;let r;if(t.device===void 0){const s={powerPreference:t.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},n=typeof navigator<"u"?await navigator.gpu.requestAdapter(s):null;if(n===null)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");const o=Object.values(Fa),a=[];for(const l of o)n.features.has(l)&&a.push(l);const u={requiredFeatures:a,requiredLimits:t.requiredLimits};r=await n.requestDevice(u)}else r=t.device;this.compatibilityMode=!r.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),r.lost.then(s=>{if(s.reason==="destroyed")return;const n={api:"WebGPU",message:s.message||"Unknown reason",reason:s.reason||null,originalEvent:s};e.onDeviceLost(n)}),r.onuncapturederror=s=>{const n=s.error,o=n&&n.constructor?n.constructor.name:"GPUError",a=n&&n.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:o,message:a,originalEvent:s})},this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(Fa.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,r=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(r===void 0){const s=this.parameters;e.isDefaultCanvasTarget===!0&&s.context!==void 0?r=s.context:r=e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${ka} webgpu`);const n=s.alpha?"premultiplied":"opaque",o=s.outputType===ht?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:n,toneMapping:{mode:o}}),t.context=r}return r}get coordinateSystem(){return Ui}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,r=0,s=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,s)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),s=e.currentSamples;let n=r.descriptor;if(n===void 0||r.samples!==s){if(n=new Fi,n.colorAttachments.push(new Di),e.depth===!0||e.stencil===!0){const u=new Wo;u.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),n.depthStencilAttachment=u}const a=n.colorAttachments[0];s>0?a.view=this.textureUtils.getColorBuffer().createView():a.resolveTarget=void 0,r.descriptor=n,r.samples=s}const o=n.colorAttachments[0];return s>0?o.resolveTarget=this.context.getCurrentTexture().createView():o.view=this.context.getCurrentTexture().createView(),n}_isRenderCameraDepthArray(e){const t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){const t=e.textures;if(t===null)return!1;for(let r=0;r1)if(f===!0){const y=e.camera.cameras;for(let x=0;x0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,_i.label=`occlusionQuerySet_${e.id}`,_i.type="occlusion",_i.count=s,n=r.createQuerySet(_i),_i.reset(),t.occlusionQuerySet=n,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null);let o;e.textures===null?o=this._getDefaultRenderPassDescriptor():o=this._getRenderPassDescriptor(e,{loadOp:Te.Load}),this.initTimestampQuery(br.RENDER,this.getTimestampUID(e),o),o.occlusionQuerySet=n;const a=o.depthStencilAttachment;if(e.textures!==null){const l=o.colorAttachments;for(let c=0;c0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const n=[];for(let o=0;o0){const n=r*8;let o=this.occludedResolveCache.get(n);o===void 0&&(Pt.size=n,Pt.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,o=this.device.createBuffer(Pt),Pt.reset(),this.occludedResolveCache.set(n,o)),Pt.size=n,Pt.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;const a=this.device.createBuffer(Pt);Pt.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,o,0),t.encoder.copyBufferToBuffer(o,0,a,0,n),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(yr(this.device,t.encoder.finish()),e.textures!==null){const n=e.textures;for(let o=0;op&&(n[0]=Math.min(f,p),n[1]=Math.ceil(f/p)),o.dispatchSize=n}n=o.dispatchSize}u.dispatchWorkgroups(n[0],n[1]||1,n[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),yr(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,s,n,o,a,u,l){const{object:c,material:d,context:h}=e,f=e.getIndex(),p=f!==null;l.pipeline!==s&&(u.setPipeline(s),l.pipeline=s);const g=l.bindingGroups;for(let m=0,y=n.length;m65535?4:2);for(let N=0;N0){const h=this.get(e.camera),f=e.camera.cameras,p=e.getBindingGroup("cameraIndex");if(h.indexesGPU===void 0||h.indexesGPU.length!==f.length){const m=this.get(p),y=[],x=new Uint32Array([0,0,0,0]);for(let _=0,N=f.length;_(z("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new Ff(e)));const r=new t(e);super(r,e),this.library=new BC,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}const ll={type:"change"},Sd={type:"start"},Nd={type:"end"},Hf=1e-6,ve={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},Xo=new ce,ts=new ce,DC=new V,Ko=new V,cl=new V,pn=new Mn,qf=new V,Yo=new V,dl=new V,Qo=new V;class FC extends Ua{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=["KeyA","KeyS","KeyD"],this.mouseButtons={LEFT:tt.ROTATE,MIDDLE:tt.DOLLY,RIGHT:tt.PAN},this.target=new V,this.state=ve.NONE,this.keyState=ve.NONE,this._lastPosition=new V,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new V,this._movePrev=new ce,this._moveCurr=new ce,this._lastAxis=new V,this._zoomStart=new ce,this._zoomEnd=new ce,this._panStart=new ce,this._panEnd=new ce,this._pointers=[],this._pointerPositions={},this._onPointerMove=UC.bind(this),this._onPointerDown=LC.bind(this),this._onPointerUp=OC.bind(this),this._onPointerCancel=IC.bind(this),this._onContextMenu=jC.bind(this),this._onMouseWheel=WC.bind(this),this._onKeyDown=GC.bind(this),this._onKeyUp=kC.bind(this),this._onTouchStart=HC.bind(this),this._onTouchMove=qC.bind(this),this._onTouchEnd=XC.bind(this),this._onMouseDown=VC.bind(this),this._onMouseMove=$C.bind(this),this._onMouseUp=zC.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction=""}dispose(){this.disconnect()}handleResize(){const e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>Hf&&(this.dispatchEvent(ll),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>Hf||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(ll),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=ve.NONE,this.keyState=ve.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(ll),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(ts.copy(this._panEnd).sub(this._panStart),ts.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;ts.x*=e,ts.y*=t}ts.multiplyScalar(this._eye.length()*this.panSpeed),Ko.copy(this._eye).cross(this.object.up).setLength(ts.x),Ko.add(DC.copy(this.object.up).setLength(ts.y)),this.object.position.add(Ko),this.target.add(Ko),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(ts.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Qo.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Qo.length();e?(this._eye.copy(this.object.position).sub(this.target),qf.copy(this._eye).normalize(),Yo.copy(this.object.up).normalize(),dl.crossVectors(Yo,qf).normalize(),Yo.setLength(this._moveCurr.y-this._movePrev.y),dl.setLength(this._moveCurr.x-this._movePrev.x),Qo.copy(Yo.add(dl)),cl.crossVectors(Qo,this._eye).normalize(),e*=this.rotateSpeed,pn.setFromAxisAngle(cl,e),this._eye.applyQuaternion(pn),this.object.up.applyQuaternion(pn),this._lastAxis.copy(cl),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),pn.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(pn),this.object.up.applyQuaternion(pn)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===ve.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=xa.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=xa.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Xo.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Xo}_getMouseOnCircle(e,t){return Xo.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Xo}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(r-=_t),s<-Math.PI?s+=_t:s>Math.PI&&(s-=_t),r<=s?this._spherical.theta=Math.max(r,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+s)/2?Math.max(r,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let n=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),n=o!=this._spherical.radius}if(Ye.setFromSpherical(this._spherical),Ye.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ye),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Ye.length();o=this._clampDistance(a*this._scale);const u=a-o;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),n=!!u}else if(this.object.isOrthographicCamera){const a=new V(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),n=u!==this.object.zoom;const l=new V(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=Ye.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Zo.origin.copy(this.object.position),Zo.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Zo.direction))hl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>hl||this._lastTargetPosition.distanceToSquared(this.target)>hl?(this.dispatchEvent(Xf),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?_t/60*this.autoRotateSpeed*e:_t/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ye.setFromMatrixColumn(t,0),Ye.multiplyScalar(-e),this._panOffset.add(Ye)}_panUp(e,t){this.screenSpacePanning===!0?Ye.setFromMatrixColumn(t,1):(Ye.setFromMatrixColumn(t,0),Ye.crossVectors(this.object.up,Ye)),Ye.multiplyScalar(e),this._panOffset.add(Ye)}_pan(e,t){const r=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ye.copy(s).sub(this.target);let n=Ye.length();n*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*n/r.clientHeight,this.object.matrix),this._panUp(2*t*n/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),s=e-r.left,n=t-r.top,o=r.width,a=r.height;this._mouse.x=s/o*2-1,this._mouse.y=-(n/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_t*this._rotateDelta.x/t.clientHeight),this._rotateUp(_t*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(_t*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-_t*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(_t*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-_t*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(r,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(r,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,s=e.pageY-t.y,n=Math.sqrt(r*r+s*s);this._dollyStart.set(0,n)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),s=.5*(e.pageX+r.x),n=.5*(e.pageY+r.y);this._rotateEnd.set(s,n)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_t*this._rotateDelta.x/t.clientHeight),this._rotateUp(_t*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(r,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,s=e.pageY-t.y,n=Math.sqrt(r*r+s*s);this._dollyEnd.set(0,n),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tYf||8*(1-this._lastQuaternion.dot(t.quaternion))>Yf)&&(this.dispatchEvent(lM),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function dM(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function hM(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function fM(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function pM(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,r=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-r)/r,this._updateRotationVector()}}function gM(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function mM(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function yM(i){this.enabled!==!1&&i.preventDefault()}const bM={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` + + varying vec2 vUv; + + void main() { + + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + }`,fragmentShader:` + + uniform float opacity; + + uniform sampler2D tDiffuse; + + varying vec2 vUv; + + void main() { + + vec4 texel = texture2D( tDiffuse, vUv ); + gl_FragColor = opacity * texel; + + + }`};class tu{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const _M=new Lc(-1,1,1,-1,0,1);class xM extends Hi{constructor(){super(),this.setAttribute("position",new _a([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new _a([0,2,0,0,2,0],2))}}const TM=new xM;class vM{constructor(e){this._mesh=new sr(TM,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,_M)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class SM extends tu{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Dd?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=m_.clone(e.uniforms),this.material=new Dd({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new vM(this.material)}render(e,t,r){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Zf extends tu{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,r){const s=e.getContext(),n=e.state;n.buffers.color.setMask(!1),n.buffers.depth.setMask(!1),n.buffers.color.setLocked(!0),n.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),n.buffers.stencil.setTest(!0),n.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),n.buffers.stencil.setFunc(s.ALWAYS,o,4294967295),n.buffers.stencil.setClear(a),n.buffers.stencil.setLocked(!0),e.setRenderTarget(r),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),n.buffers.color.setLocked(!1),n.buffers.depth.setLocked(!1),n.buffers.color.setMask(!0),n.buffers.depth.setMask(!0),n.buffers.stencil.setLocked(!1),n.buffers.stencil.setFunc(s.EQUAL,1,4294967295),n.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),n.buffers.stencil.setLocked(!0)}}class NM extends tu{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class wM{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const r=e.getSize(new ce);this._width=r.width,this._height=r.height,t=new y_(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:ht}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new SM(bM),this.copyPass.material.blending=Wr,this.timer=new qp}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&s<1?(a=n,u=o):s>=1&&s<2?(a=o,u=n):s>=2&&s<3?(u=n,l=o):s>=3&&s<4?(u=o,l=n):s>=4&&s<5?(a=o,l=n):s>=5&&s<6&&(a=n,l=o);var c=t-n/2,d=a+c,h=u+c,f=l+c;return r(d,h,f)}var Jf={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function PM(i){if(typeof i!="string")return i;var e=i.toLowerCase();return Jf[e]?"#"+Jf[e]:i}var DM=/^#[a-fA-F0-9]{6}$/,FM=/^#[a-fA-F0-9]{8}$/,LM=/^#[a-fA-F0-9]{3}$/,UM=/^#[a-fA-F0-9]{4}$/,pl=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,OM=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,IM=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,kM=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function kn(i){if(typeof i!="string")throw new _r(3);var e=PM(i);if(e.match(DM))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(FM)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(LM))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(UM)){var r=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:r}}var s=pl.exec(e);if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10)};var n=OM.exec(e.substring(0,50));if(n)return{red:parseInt(""+n[1],10),green:parseInt(""+n[2],10),blue:parseInt(""+n[3],10),alpha:parseFloat(""+n[4])>1?parseFloat(""+n[4])/100:parseFloat(""+n[4])};var o=IM.exec(e);if(o){var a=parseInt(""+o[1],10),u=parseInt(""+o[2],10)/100,l=parseInt(""+o[3],10)/100,c="rgb("+La(a,u,l)+")",d=pl.exec(c);if(!d)throw new _r(4,e,c);return{red:parseInt(""+d[1],10),green:parseInt(""+d[2],10),blue:parseInt(""+d[3],10)}}var h=kM.exec(e.substring(0,50));if(h){var f=parseInt(""+h[1],10),p=parseInt(""+h[2],10)/100,g=parseInt(""+h[3],10)/100,m="rgb("+La(f,p,g)+")",y=pl.exec(m);if(!y)throw new _r(4,e,m);return{red:parseInt(""+y[1],10),green:parseInt(""+y[2],10),blue:parseInt(""+y[3],10),alpha:parseFloat(""+h[4])>1?parseFloat(""+h[4])/100:parseFloat(""+h[4])}}throw new _r(5)}function GM(i){var e=i.red/255,t=i.green/255,r=i.blue/255,s=Math.max(e,t,r),n=Math.min(e,t,r),o=(s+n)/2;if(s===n)return i.alpha!==void 0?{hue:0,saturation:0,lightness:o,alpha:i.alpha}:{hue:0,saturation:0,lightness:o};var a,u=s-n,l=o>.5?u/(2-s-n):u/(s+n);switch(s){case e:a=(t-r)/u+(t=1?ky(i.hue,i.saturation,i.lightness):"rgba("+La(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new _r(2)}function Gy(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return vc("#"+Es(i)+Es(e)+Es(t));if(typeof i=="object"&&e===void 0&&t===void 0)return vc("#"+Es(i.red)+Es(i.green)+Es(i.blue));throw new _r(6)}function ru(i,e,t,r){if(typeof i=="object"&&e===void 0&&t===void 0&&r===void 0)return i.alpha>=1?Gy(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")";throw new _r(7)}var jM=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},HM=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},qM=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},XM=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function _s(i){if(typeof i!="object")throw new _r(8);if(HM(i))return ru(i);if(jM(i))return Gy(i);if(XM(i))return WM(i);if(qM(i))return zM(i);throw new _r(8)}function Vy(i,e,t){return function(){var s=t.concat(Array.prototype.slice.call(arguments));return s.length>=e?i.apply(this,s):Vy(i,e,s)}}function Ot(i){return Vy(i,i.length,[])}function KM(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{hue:t.hue+parseFloat(i)}))}Ot(KM);function Yn(i,e,t){return Math.max(i,Math.min(e,t))}function YM(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{lightness:Yn(0,1,t.lightness-parseFloat(i))}))}Ot(YM);function QM(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{saturation:Yn(0,1,t.saturation-parseFloat(i))}))}Ot(QM);function ZM(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{lightness:Yn(0,1,t.lightness+parseFloat(i))}))}Ot(ZM);function JM(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var r=kn(e),s=Et({},r,{alpha:typeof r.alpha=="number"?r.alpha:1}),n=kn(t),o=Et({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),a=s.alpha-o.alpha,u=parseFloat(i)*2-1,l=u*a===-1?u:u+a,c=1+u*a,d=(l/c+1)/2,h=1-d,f={red:Math.floor(s.red*d+o.red*h),green:Math.floor(s.green*d+o.green*h),blue:Math.floor(s.blue*d+o.blue*h),alpha:s.alpha*parseFloat(i)+o.alpha*(1-parseFloat(i))};return ru(f)}var eB=Ot(JM),$y=eB;function tB(i,e){if(e==="transparent")return e;var t=kn(e),r=typeof t.alpha=="number"?t.alpha:1,s=Et({},t,{alpha:Yn(0,1,(r*100+parseFloat(i)*100)/100)});return ru(s)}var rB=Ot(tB),sB=rB;function nB(i,e){if(e==="transparent")return e;var t=bs(e);return _s(Et({},t,{saturation:Yn(0,1,t.saturation+parseFloat(i))}))}Ot(nB);function iB(i,e){return e==="transparent"?e:_s(Et({},bs(e),{hue:parseFloat(i)}))}Ot(iB);function oB(i,e){return e==="transparent"?e:_s(Et({},bs(e),{lightness:parseFloat(i)}))}Ot(oB);function aB(i,e){return e==="transparent"?e:_s(Et({},bs(e),{saturation:parseFloat(i)}))}Ot(aB);function uB(i,e){return e==="transparent"?e:$y(parseFloat(i),"rgb(0, 0, 0)",e)}Ot(uB);function lB(i,e){return e==="transparent"?e:$y(parseFloat(i),"rgb(255, 255, 255)",e)}Ot(lB);function cB(i,e){if(e==="transparent")return e;var t=kn(e),r=typeof t.alpha=="number"?t.alpha:1,s=Et({},t,{alpha:Yn(0,1,+(r*100-parseFloat(i)*100).toFixed(2)/100)});return ru(s)}Ot(cB);function dB(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var hB=`.scene-nav-info { + position: absolute; + bottom: 5px; + width: 100%; + text-align: center; + color: slategrey; + opacity: 0.7; + font-size: 10px; + font-family: sans-serif; + pointer-events: none; + user-select: none; +} + +.scene-container canvas:focus { + outline: none; +}`;dB(hB);function Sc(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var r=null;if(e.hoverDuringDrag||!e.isPointerDragging){var s=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&s.sort(function(o,a){return e.hoverOrderComparator(o.object,a.object)});var n=s.find(function(o){return e.hoverFilter(o.object)})||null;r=n?n.object:null,e.intersection=n||null}r!==e.hoverObj&&(e.onHover(r,e.hoverObj,e.intersection),e.tooltip.content(r&&pe(e.tooltipContent)(r,e.intersection)||null),e.hoverObj=r)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,r=t.x,s=t.y;return{x:r,y:s}},cameraPosition:function(e,t,r,s){var n=e.camera;if(t&&e.initialised){var o,a,u=t,l=r||{x:0,y:0,z:0};if((o=e.povPosTween)===null||o===void 0||o.end(),(a=e.povTgtTween)===null||a===void 0||a.end(),!s)h(u),f(l);else{var c=Object.assign({},n.position),d=p();e.tweenGroup.add(e.povPosTween=new Fd(c).to(u,s).easing(Ld.Quadratic.Out).onUpdate(h).onComplete(function(){e.povPosTween=void 0,e.tweenGroup.remove(this)}).start()),e.tweenGroup.add(e.povTgtTween=new Fd(d).to(l,s/3).easing(Ld.Quadratic.Out).onUpdate(f).onComplete(function(){e.povTgtTween=void 0,e.tweenGroup.remove(this)}).start())}return this}return Object.assign({},n.position,{lookAt:p()});function h(g){var m=g.x,y=g.y,x=g.z;m!==void 0&&(n.position.x=m),y!==void 0&&(n.position.y=y),x!==void 0&&(n.position.z=x)}function f(g){var m=new Oe.Vector3(g.x,g.y,g.z);e.controls.enabled&&e.controls.target?e.controls.target=m:n.lookAt(m)}function p(){return Object.assign(new Oe.Vector3(0,0,-1e3).applyQuaternion(n.quaternion).add(n.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,s=arguments.length,n=new Array(s>3?s-3:0),o=3;o2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,n=e.camera;if(t){var o=new Oe.Vector3(0,0,0),a=Math.max.apply(Math,Ns(Object.entries(t).map(function(f){var p=xB(f,2),g=p[0],m=p[1];return Math.max.apply(Math,Ns(m.map(function(y){return Math.abs(o[g]-y)})))})))*2,u=(1-s*2/e.height)*n.fov,l=a/Math.atan(u*Math.PI/180),c=l/n.aspect,d=Math.max(l,c);if(d>0){var h=o.clone().sub(n.position).normalize().multiplyScalar(-d);this.cameraPosition(h,o,r)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},r=new Oe.Box3(new Oe.Vector3(0,0,0),new Oe.Vector3(0,0,0)),s=e.objects.filter(t);return s.length?(s.forEach(function(n){return r.expandByObject(n)}),Object.assign.apply(Object,Ns(["x","y","z"].map(function(n){return gB({},n,[r.min[n],r.max[n]])})))):null},getScreenCoords:function(e,t,r,s){var n=new Oe.Vector3(t,r,s);return n.project(this.camera()),{x:(n.x+1)*e.width/2,y:-(n.y-1)*e.height/2}},getSceneCoords:function(e,t,r){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,n=new Oe.Vector2(t/e.width*2-1,-(r/e.height)*2+1),o=new Oe.Raycaster;return o.setFromCamera(n,e.camera),Object.assign({},o.ray.at(s,new Oe.Vector3))},intersectingObjects:function(e,t,r){var s=new Oe.Vector2(t/e.width*2-1,-(r/e.height)*2+1),n=new Oe.Raycaster;return n.params.Line.threshold=e.lineHoverPrecision,n.params.Points.threshold=e.pointsHoverPrecision,n.setFromCamera(s,e.camera),n.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls},_destructor:function(e){var t,r,s;SB(e.scene),(t=e.controls)===null||t===void 0||t.dispose(),(r=e.renderer)===null||r===void 0||r.dispose(),(s=e.postProcessingComposer)===null||s===void 0||s.dispose()}},stateInit:function(){return{scene:new Oe.Scene,camera:new Oe.PerspectiveCamera,timer:new Oe.Timer,tweenGroup:new M_,lastRaycasterCheck:0}},init:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=r.controlType,n=s===void 0?"trackball":s,o=r.useWebGPU,a=o===void 0?!1:o,u=r.rendererConfig,l=u===void 0?{}:u,c=r.extraRenderers,d=c===void 0?[]:c,h=r.waitForLoadComplete,f=h===void 0?!0:h;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[n]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new C_(t.container),t.pointerPos=new Oe.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(p){return t.container.addEventListener(p,function(g){if(p==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&g.type==="pointermove"&&(g.pressure>0||t.isPointerPressed)&&(g.pointerType==="mouse"||g.movementX===void 0||[g.movementX,g.movementY].some(function(x){return Math.abs(x)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var m=y(t.container);t.pointerPos.x=g.pageX-m.left,t.pointerPos.y=g.pageY-m.top}function y(x){var _=x.getBoundingClientRect(),N=window.pageXOffset||document.documentElement.scrollLeft,A=window.pageYOffset||document.documentElement.scrollTop;return{top:_.top+A,left:_.left+N}}},{passive:!0})}),t.container.addEventListener("pointerup",function(p){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){p.button===0&&t.onClick(t.hoverObj||null,p,t.intersection),p.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,p,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(p){t.onRightClick&&p.preventDefault()}),t.renderer=new(a?PC:Oe.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},l)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=d,t.extraRenderers.forEach(function(p){p.domElement.style.position="absolute",p.domElement.style.top="0px",p.domElement.style.pointerEvents="none",t.container.appendChild(p.domElement)}),t.postProcessingComposer=new wM(t.renderer),t.postProcessingComposer.addPass(new RM(t.scene,t.camera)),t.controls=new{trackball:FC,orbit:YC,fly:cM}[n](t.camera,t.renderer.domElement),n==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(n==="trackball"||n==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Ns(t.extraRenderers)).forEach(function(p){return p.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new Oe.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!f,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var r,s=e.width,n=e.height;e.container.style.width="".concat(s,"px"),e.container.style.height="".concat(n,"px"),[e.renderer,e.postProcessingComposer].concat(Ns(e.extraRenderers)).forEach(function(f){return f.setSize(s,n)}),e.camera.aspect=s/n;var o=e.viewOffset.slice(0,2);o.some(function(f){return f})&&(r=e.camera).setViewOffset.apply(r,[s,n].concat(Ns(o),[s,n])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var a,u=e.width,l=e.height,c=e.viewOffset.slice(0,2);c.some(function(f){return f})?(a=e.camera).setViewOffset.apply(a,[u,l].concat(Ns(c),[u,l])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new Oe.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var d=kn(e.backgroundColor).alpha;d===void 0&&(d=1),e.renderer.setClearColor(new Oe.Color(sB(1,e.backgroundColor)),d)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new Oe.TextureLoader().load(e.backgroundImageUrl,function(f){f.colorSpace=Oe.SRGBColorSpace,e.skysphere.material=new Oe.MeshBasicMaterial({map:f,side:Oe.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&h()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&h())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(f){return e.scene.remove(f)}),e.lights.forEach(function(f){return e.scene.add(f)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(f){return e.scene.remove(f)}),e.objects.forEach(function(f){return e.scene.add(f)}));function h(){e.loadComplete=e.scene.visible=!0}}});function NB(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var wB=`.graph-info-msg { + top: 50%; + width: 100%; + text-align: center; + color: lavender; + opacity: 0.7; + font-size: 22px; + position: absolute; + font-family: Sans-serif; +} + +.scene-container .clickable { + cursor: pointer; +} + +.scene-container .grabbable { + cursor: move; + cursor: grab; + cursor: -moz-grab; + cursor: -webkit-grab; +} + +.scene-container .grabbable:active { + cursor: grabbing; + cursor: -moz-grabbing; + cursor: -webkit-grabbing; +}`;NB(wB);function Nc(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t1?a-1:0),l=1;l3?n-3:0),a=3;a=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),te.hasOwnProperty(e)?{space:te[e],local:t}:t}function wn(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===Ot&&e.documentElement.namespaceURI===Ot?e.createElement(t):e.createElementNS(n,t)}}function mn(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ee(t){var e=Ce(t);return(e.local?mn:wn)(e)}function xn(){}function Pe(t){return t==null?xn:function(){return this.querySelector(t)}}function An(t){typeof t!="function"&&(t=Pe(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=w&&(w=g+1);!(y=v[w])&&++w=0;)(s=r[i])&&(a&&s.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(s,a),a=s);return this}function Kn(t){t||(t=Qn);function e(h,l){return h&&l?t(h.__data__,l.__data__):!h-!l}for(var n=this._groups,r=n.length,i=new Array(r),a=0;ae?1:t>=e?0:NaN}function Zn(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Jn(){return Array.from(this)}function tr(){for(var t=this._groups,e=0,n=t.length;e1?this.each((e==null?hr:typeof e=="function"?_r:cr)(t,e,n??"")):dr(this.node(),t)}function dr(t,e){return t.style.getPropertyValue(e)||Re(t).getComputedStyle(t,null).getPropertyValue(e)}function gr(t){return function(){delete this[t]}}function vr(t,e){return function(){this[t]=e}}function yr(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function br(t,e){return arguments.length>1?this.each((e==null?gr:typeof e=="function"?yr:vr)(t,e)):this.node()[t]}function ze(t){return t.trim().split(/^|\s+/)}function qt(t){return t.classList||new $e(t)}function $e(t){this._node=t,this._names=ze(t.getAttribute("class")||"")}$e.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Fe(t,e){for(var n=qt(t),r=-1,i=e.length;++r=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function Gr(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,a;n{}};function Le(){for(var t=0,e=arguments.length,n={},r;t=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}_t.prototype=Le.prototype={constructor:_t,on:function(t,e){var n=this._,r=si(t+"",n),i,a=-1,s=r.length;if(arguments.length<2){for(;++a0)for(var n=new Array(i),r=0,i,a;r=0&&t._call.call(void 0,e),t=t._next;--J}function ne(){Q=(yt=ut.now())+St,J=nt=0;try{ui()}finally{J=0,hi(),Q=0}}function li(){var t=ut.now(),e=t-yt;e>Ue&&(St-=e,yt=t)}function hi(){for(var t,e=vt,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:vt=n);rt=t,zt(r)}function zt(t){if(!J){nt&&(nt=clearTimeout(nt));var e=t-Q;e>24?(t<1/0&&(nt=setTimeout(ne,t-ut.now()-St)),tt&&(tt=clearInterval(tt))):(tt||(yt=ut.now(),tt=setInterval(li,Ue)),J=1,qe(ne))}}class re extends Map{constructor(e,n=pi){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(ie(this,e))}has(e){return super.has(ie(this,e))}set(e,n){return super.set(ci(this,e),n)}delete(e){return super.delete(_i(this,e))}}function ie({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function ci({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function _i({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function pi(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Ys(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n=r)&&(n=r);else{let r=-1;for(let i of t)(i=e(i,++r,t))!=null&&(n=i)&&(n=i)}return n}function Ks(t,e){let n;if(e===void 0)for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let i of t)(i=e(i,++r,t))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}var di=typeof global=="object"&&global&&global.Object===Object&&global,gi=typeof self=="object"&&self&&self.Object===Object&&self,We=di||gi||Function("return this")(),bt=We.Symbol,Ge=Object.prototype,vi=Ge.hasOwnProperty,yi=Ge.toString,et=bt?bt.toStringTag:void 0;function bi(t){var e=vi.call(t,et),n=t[et];try{t[et]=void 0;var r=!0}catch{}var i=yi.call(t);return r&&(e?t[et]=n:delete t[et]),i}var wi=Object.prototype,mi=wi.toString;function xi(t){return mi.call(t)}var Ai="[object Null]",Mi="[object Undefined]",ae=bt?bt.toStringTag:void 0;function Si(t){return t==null?t===void 0?Mi:Ai:ae&&ae in Object(t)?bi(t):xi(t)}function ki(t){return t!=null&&typeof t=="object"}var Ni="[object Symbol]";function Ti(t){return typeof t=="symbol"||ki(t)&&Si(t)==Ni}var Ci=/\s/;function Ei(t){for(var e=t.length;e--&&Ci.test(t.charAt(e)););return e}var Pi=/^\s+/;function Ii(t){return t&&t.slice(0,Ei(t)+1).replace(Pi,"")}function $t(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var se=NaN,Oi=/^[-+]0x[0-9a-f]+$/i,Ri=/^0b[01]+$/i,zi=/^0o[0-7]+$/i,$i=parseInt;function oe(t){if(typeof t=="number")return t;if(Ti(t))return se;if($t(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=$t(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Ii(t);var n=Ri.test(t);return n||zi.test(t)?$i(t.slice(2),n?2:8):Oi.test(t)?se:+t}var Et=function(){return We.Date.now()},Fi="Expected a function",Hi=Math.max,ji=Math.min;function Di(t,e,n){var r,i,a,s,o,u,f=0,c=!1,h=!1,l=!0;if(typeof t!="function")throw new TypeError(Fi);e=oe(e)||0,$t(n)&&(c=!!n.leading,h="maxWait"in n,a=h?Hi(oe(n.maxWait)||0,e):a,l="trailing"in n?!!n.trailing:l);function p(b){var M=r,A=i;return r=i=void 0,f=b,s=t.apply(A,M),s}function d(b){return f=b,o=setTimeout(_,e),c?p(b):s}function m(b){var M=b-u,A=b-f,I=e-M;return h?ji(I,a-A):I}function v(b){var M=b-u,A=b-f;return u===void 0||M>=e||M<0||h&&A>=a}function _(){var b=Et();if(v(b))return g(b);o=setTimeout(_,m(b))}function g(b){return o=void 0,l&&r?p(b):(r=i=void 0,s)}function w(){o!==void 0&&clearTimeout(o),f=0,r=u=i=o=void 0}function x(){return o===void 0?s:g(Et())}function y(){var b=Et(),M=v(b);if(r=arguments,i=this,u=b,M){if(o===void 0)return d(u);if(h)return clearTimeout(o),o=setTimeout(_,e),p(u)}return o===void 0&&(o=setTimeout(_,e)),s}return y.cancel=w,y.flush=x,y}var st=Object.freeze({Linear:Object.freeze({None:function(t){return t},In:function(t){return t},Out:function(t){return t},InOut:function(t){return t}}),Quadratic:Object.freeze({In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}}),Cubic:Object.freeze({In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}}),Quartic:Object.freeze({In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}}),Quintic:Object.freeze({In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}}),Sinusoidal:Object.freeze({In:function(t){return 1-Math.sin((1-t)*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return .5*(1-Math.sin(Math.PI*(.5-t)))}}),Exponential:Object.freeze({In:function(t){return t===0?0:Math.pow(1024,t-1)},Out:function(t){return t===1?1:1-Math.pow(2,-10*t)},InOut:function(t){return t===0?0:t===1?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(2,-10*(t-1))+2)}}),Circular:Object.freeze({In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}}),Elastic:Object.freeze({In:function(t){return t===0?0:t===1?1:-Math.pow(2,10*(t-1))*Math.sin((t-1.1)*5*Math.PI)},Out:function(t){return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t-.1)*5*Math.PI)+1},InOut:function(t){return t===0?0:t===1?1:(t*=2,t<1?-.5*Math.pow(2,10*(t-1))*Math.sin((t-1.1)*5*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin((t-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(t){var e=1.70158;return t===1?1:t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return t===0?0:--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)}}),Bounce:Object.freeze({In:function(t){return 1-st.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?st.Bounce.In(t*2)*.5:st.Bounce.Out(t*2-1)*.5+.5}}),generatePow:function(t){return t===void 0&&(t=4),t=t1e4?1e4:t,{In:function(e){return Math.pow(e,t)},Out:function(e){return 1-Math.pow(1-e,t)},InOut:function(e){return e<.5?Math.pow(e*2,t)/2:(1-Math.pow(2-e*2,t))/2+.5}}}}),it=function(){return performance.now()},Li=(function(){function t(){for(var e=[],n=0;n0;){this._tweensAddedDuringUpdate={};for(var i=0;i1?a(t[n],t[n-1],n-r):a(t[i],t[i+1>n?n:i+1],r-i)},Utils:{Linear:function(t,e,n){return(e-t)*n+t}}},Xe=(function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t})(),Ht=new Li,Qs=(function(){function t(e,n){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=st.Linear.None,this._interpolationFunction=Ft.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Xe.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof n=="object"?(this._group=n,n.add(this)):n===!0&&(this._group=Ht,Ht.add(this))}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.getDuration=function(){return this._duration},t.prototype.to=function(e,n){if(n===void 0&&(n=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=n<0?0:n,this},t.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},t.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},t.prototype.start=function(e,n){if(e===void 0&&(e=it()),n===void 0&&(n=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var r in this._valuesStartRepeat)this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||n){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var a in this._valuesEnd)i[a]=this._valuesEnd[a];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,n)}return this},t.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},t.prototype._setupProperties=function(e,n,r,i,a){for(var s in r){var o=e[s],u=Array.isArray(o),f=u?"array":typeof o,c=!u&&Array.isArray(r[s]);if(!(f==="undefined"||f==="function")){if(c){var h=r[s];if(h.length===0)continue;for(var l=[o],p=0,d=h.length;p"u"||a)&&(n[s]=o),u||(n[s]*=1),c?i[s]=r[s].slice().reverse():i[s]=n[s]||0}}},t.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},t.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},t.prototype.pause=function(e){return e===void 0&&(e=it()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},t.prototype.resume=function(e){return e===void 0&&(e=it()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},t.prototype.stopChainedTweens=function(){for(var e=0,n=this._chainedTweens.length;eu)return 1;var m=Math.trunc(s/o),v=s-m*o,_=Math.min(v/r._duration,1);return _===0&&s===r._duration?1:_},c=f(),h=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,h),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),this._duration===0||s>=this._duration)if(this._repeat>0){var l=Math.min(Math.trunc((s-this._duration)/o)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=l);for(a in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[a]=="string"&&(this._valuesStartRepeat[a]=this._valuesStartRepeat[a]+parseFloat(this._valuesEnd[a])),this._yoyo&&this._swapEndStartRepeatValues(a),this._valuesStart[a]=this._valuesStartRepeat[a];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*l,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var p=0,d=this._chainedTweens.length;pt.length)&&(e=t.length);for(var n=0,r=Array(e);n=0,a=!n&&i&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return a?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return S(this.toString())},_applyModification:function(e,n){var r=e.apply(null,[this].concat([].slice.call(n)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(oa,arguments)},brighten:function(){return this._applyModification(fa,arguments)},darken:function(){return this._applyModification(ua,arguments)},desaturate:function(){return this._applyModification(ia,arguments)},saturate:function(){return this._applyModification(aa,arguments)},greyscale:function(){return this._applyModification(sa,arguments)},spin:function(){return this._applyModification(la,arguments)},_applyCombination:function(e,n){return e.apply(null,[this].concat([].slice.call(n)))},analogous:function(){return this._applyCombination(_a,arguments)},complement:function(){return this._applyCombination(ha,arguments)},monochromatic:function(){return this._applyCombination(pa,arguments)},splitcomplement:function(){return this._applyCombination(ca,arguments)},triad:function(){return this._applyCombination(_e,[3])},tetrad:function(){return this._applyCombination(_e,[4])}};S.fromRatio=function(t,e){if(wt(t)=="object"){var n={};for(var r in t)t.hasOwnProperty(r)&&(r==="a"?n[r]=t[r]:n[r]=at(t[r]));t=n}return S(t,e)};function Ji(t){var e={r:0,g:0,b:0},n=1,r=null,i=null,a=null,s=!1,o=!1;return typeof t=="string"&&(t=ba(t)),wt(t)=="object"&&(V(t.r)&&V(t.g)&&V(t.b)?(e=ta(t.r,t.g,t.b),s=!0,o=String(t.r).substr(-1)==="%"?"prgb":"rgb"):V(t.h)&&V(t.s)&&V(t.v)?(r=at(t.s),i=at(t.v),e=na(t.h,r,i),s=!0,o="hsv"):V(t.h)&&V(t.s)&&V(t.l)&&(r=at(t.s),a=at(t.l),e=ea(t.h,r,a),s=!0,o="hsl"),t.hasOwnProperty("a")&&(n=t.a)),n=Ye(n),{ok:s,format:t.format||o,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:n}}function ta(t,e,n){return{r:E(t,255)*255,g:E(e,255)*255,b:E(n,255)*255}}function ue(t,e,n){t=E(t,255),e=E(e,255),n=E(n,255);var r=Math.max(t,e,n),i=Math.min(t,e,n),a,s,o=(r+i)/2;if(r==i)a=s=0;else{var u=r-i;switch(s=o>.5?u/(2-r-i):u/(r+i),r){case t:a=(e-n)/u+(e1&&(h-=1),h<1/6?f+(c-f)*6*h:h<1/2?c:h<2/3?f+(c-f)*(2/3-h)*6:f}if(e===0)r=i=a=n;else{var o=n<.5?n*(1+e):n+e-n*e,u=2*n-o;r=s(u,o,t+1/3),i=s(u,o,t),a=s(u,o,t-1/3)}return{r:r*255,g:i*255,b:a*255}}function le(t,e,n){t=E(t,255),e=E(e,255),n=E(n,255);var r=Math.max(t,e,n),i=Math.min(t,e,n),a,s,o=r,u=r-i;if(s=r===0?0:u/r,r==i)a=0;else{switch(r){case t:a=(e-n)/u+(e>1)+720)%360;--e;)r.h=(r.h+i)%360,a.push(S(r));return a}function pa(t,e){e=e||6;for(var n=S(t).toHsv(),r=n.h,i=n.s,a=n.v,s=[],o=1/e;e--;)s.push(S({h:r,s:i,v:a})),a=(a+o)%1;return s}S.mix=function(t,e,n){n=n===0?0:n||50;var r=S(t).toRgb(),i=S(e).toRgb(),a=n/100,s={r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a};return S(s)};S.readability=function(t,e){var n=S(t),r=S(e);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)};S.isReadable=function(t,e,n){var r=S.readability(t,e),i,a;switch(a=!1,i=wa(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=r>=4.5;break;case"AAlarge":a=r>=3;break;case"AAAsmall":a=r>=7;break}return a};S.mostReadable=function(t,e,n){var r=null,i=0,a,s,o,u;n=n||{},s=n.includeFallbackColors,o=n.level,u=n.size;for(var f=0;fi&&(i=a,r=S(e[f]));return S.isReadable(t,r,{level:o,size:u})||!s?r:(n.includeFallbackColors=!1,S.mostReadable(t,["#fff","#000"],n))};var jt=S.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},da=S.hexNames=ga(jt);function ga(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function Ye(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function E(t,e){va(t)&&(t="100%");var n=ya(t);return t=Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),Math.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function kt(t){return Math.min(1,Math.max(0,t))}function H(t){return parseInt(t,16)}function va(t){return typeof t=="string"&&t.indexOf(".")!=-1&&parseFloat(t)===1}function ya(t){return typeof t=="string"&&t.indexOf("%")!=-1}function L(t){return t.length==1?"0"+t:""+t}function at(t){return t<=1&&(t=t*100+"%"),t}function Ke(t){return Math.round(parseFloat(t)*255).toString(16)}function pe(t){return H(t)/255}var D=(function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",i="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{CSS_UNIT:new RegExp(n),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}})();function V(t){return!!D.CSS_UNIT.exec(t)}function ba(t){t=t.replace(Qi,"").replace(Zi,"").toLowerCase();var e=!1;if(jt[t])t=jt[t],e=!0;else if(t=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=D.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=D.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=D.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=D.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=D.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=D.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=D.hex8.exec(t))?{r:H(n[1]),g:H(n[2]),b:H(n[3]),a:pe(n[4]),format:e?"name":"hex8"}:(n=D.hex6.exec(t))?{r:H(n[1]),g:H(n[2]),b:H(n[3]),format:e?"name":"hex"}:(n=D.hex4.exec(t))?{r:H(n[1]+""+n[1]),g:H(n[2]+""+n[2]),b:H(n[3]+""+n[3]),a:pe(n[4]+""+n[4]),format:e?"name":"hex8"}:(n=D.hex3.exec(t))?{r:H(n[1]+""+n[1]),g:H(n[2]+""+n[2]),b:H(n[3]+""+n[3]),format:e?"name":"hex"}:!1}function wa(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),n!=="small"&&n!=="large"&&(n="small"),{level:e,size:n}}var lt,P,Qe,Ze,Y,de,Je,tn,Pt,pt,ot,en,Bt,Dt,Lt,mt={},xt=[],ma=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Nt=Array.isArray;function U(t,e){for(var n in e)t[n]=e[n];return t}function Vt(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function xa(t,e,n){var r,i,a,s={};for(a in e)a=="key"?r=e[a]:a=="ref"?i=e[a]:s[a]=e[a];if(arguments.length>2&&(s.children=arguments.length>3?lt.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(a in t.defaultProps)s[a]===void 0&&(s[a]=t.defaultProps[a]);return ft(t,s,r,i,null)}function ft(t,e,n,r,i){var a={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Qe,__i:-1,__u:0};return i==null&&P.vnode!=null&&P.vnode(a),a}function Tt(t){return t.children}function dt(t,e){this.props=t,this.context=e}function Z(t,e){if(e==null)return t.__?Z(t.__,t.__i+1):null;for(var n;ee&&Y.sort(tn),t=Y.shift(),e=Y.length,Aa(t)}finally{Y.length=At.__r=0}}function rn(t,e,n,r,i,a,s,o,u,f,c){var h,l,p,d,m,v,_=r&&r.__k||xt,g=e.length;for(u=Ma(n,e,_,u,g),h=0;h0?s=t.__k[a]=ft(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):t.__k[a]=s,u=a+l,s.__=t,s.__b=t.__b+1,o=null,(f=s.__i=Sa(s,n,u,h))!=-1&&(h--,(o=n[f])&&(o.__u|=2)),o==null||o.__v==null?(f==-1&&(i>c?l--:iu?l--:l++,s.__u|=4))):t.__k[a]=null;if(h)for(a=0;a(c?1:0)){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&(2&f.__u)==0&&o==f.key&&u==f.type)return s}return-1}function ve(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||ma.test(e)?n:n+"px"}function ct(t,e,n,r,i){var a,s;t:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||ve(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||ve(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")a=e!=(e=e.replace(en,"$1")),s=e.toLowerCase(),e=s in t||e=="onFocusOut"||e=="onFocusIn"?s.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+a]=n,n?r?n[ot]=r[ot]:(n[ot]=Bt,t.addEventListener(e,a?Lt:Dt,a)):t.removeEventListener(e,a?Lt:Dt,a);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break t}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function ye(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[pt]==null)e[pt]=Bt++;else if(e[pt]0?t:Nt(t)?t.map(fn):t.constructor!==void 0?null:U({},t)}function ka(t,e,n,r,i,a,s,o,u){var f,c,h,l,p,d,m,v=n.props||mt,_=e.props,g=e.type;if(g=="svg"?i="http://www.w3.org/2000/svg":g=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(f=0;f2&&(o.children=arguments.length>3?lt.call(arguments,2):n),ft(t.type,o,r||t.key,i||t.ref,null)}lt=xt.slice,P={__e:function(t,e,n,r){for(var i,a,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(t)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),s=i.__d),s)return i.__E=i}catch(o){t=o}throw t}},Qe=0,Ze=function(t){return t!=null&&t.constructor===void 0},dt.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=U({},this.state),typeof t=="function"&&(t=t(U({},n),this.props)),t&&U(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ge(this))},dt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ge(this))},dt.prototype.render=Tt,Y=[],Je=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,tn=function(t,e){return t.__v.__b-e.__v.__b},At.__r=0,Pt=Math.random().toString(8),pt="__d"+Pt,ot="__a"+Pt,en=/(PointerCapture)$|Capture$/i,Bt=0,Dt=ye(!1),Lt=ye(!0);function be(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n"u")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",n==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}var La=`.float-tooltip-kap { + position: absolute; + width: max-content; /* prevent shrinking near right edge */ + max-width: max(50%, 150px); + padding: 3px 5px; + border-radius: 3px; + font: 12px sans-serif; + color: #eee; + background: rgba(0,0,0,0.6); + pointer-events: none; +} +`;Da(La);var Js=Ki({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=r.style,a=i===void 0?{}:i,s=!!e&&Mt(e)==="object"&&!!e.node&&typeof e.node=="function",o=ni(s?e.node():e);o.style("position")==="static"&&o.style("position","relative"),n.tooltipEl=o.append("div").attr("class","float-tooltip-kap"),Object.entries(a).forEach(function(f){var c=Ra(f,2),h=c[0],l=c[1];return n.tooltipEl.style(h,l)}),n.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));n.mouseInside=!1,o.on("mousemove.".concat(u),function(f){n.mouseInside=!0;var c=ii(f),h=o.node(),l=h.offsetWidth,p=h.offsetHeight,d=[n.offsetX===null||n.offsetX===void 0?"-".concat(c[0]/l*100,"%"):typeof n.offsetX=="number"?"calc(-50% + ".concat(n.offsetX,"px)"):n.offsetX,n.offsetY===null||n.offsetY===void 0?p>130&&p-c[1]<100?"calc(-100% - 6px)":"21px":typeof n.offsetY=="number"?n.offsetY<0?"calc(-100% - ".concat(Math.abs(n.offsetY),"px)"):"".concat(n.offsetY,"px"):n.offsetY];n.tooltipEl.style("left",c[0]+"px").style("top",c[1]+"px").style("transform","translate(".concat(d.join(","),")")),n.content&&n.tooltipEl.style("display","inline")}),o.on("mouseover.".concat(u),function(){n.mouseInside=!0,n.content&&n.tooltipEl.style("display","inline")}),o.on("mouseout.".concat(u),function(){n.mouseInside=!1,n.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):Ha(e.content)?(e.tooltipEl.text(""),ja(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function to(t,e,n){var r,i=1;t==null&&(t=0),e==null&&(e=0),n==null&&(n=0);function a(){var s,o=r.length,u,f=0,c=0,h=0;for(s=0;s=(u=(s+o)/2))?s=u:o=u,r=i,!(i=i[h=+c]))return r[h]=a,t;if(f=+t._x.call(null,i.data),e===f)return a.next=i,r?r[h]=a:t._root=a,t;do r=r?r[h]=new Array(2):t._root=new Array(2),(c=e>=(u=(s+o)/2))?s=u:o=u;while((h=+c)==(l=+(f>=u)));return r[l]=i,r[h]=a,t}function qa(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e);let r=1/0,i=-1/0;for(let a=0,s;ai&&(i=s));if(r>i)return this;this.cover(r).cover(i);for(let a=0;at||t>=n;)switch(s=+(ts||(a=f.x1)=h))&&(f=o[o.length-1],o[o.length-1]=o[o.length-1-c],o[o.length-1-c]=f)}else{var l=Math.abs(t-+this._x.call(null,u.data));l=(f=(s+o)/2))?s=f:o=f,e=n,!(n=n[h=+c]))return this;if(!n.length)break;e[h+1&1]&&(r=e,l=h)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):e?(a?e[h]=a:delete e[h],(n=e[0]||e[1])&&n===(e[1]||e[0])&&!n.length&&(r?r[l]=n:this._root=n),this):(this._root=a,this)}function Ya(t){for(var e=0,n=t.length;e=(h=(o+f)/2))?o=h:f=h,(v=n>=(l=(u+c)/2))?u=l:c=l,i=a,!(a=a[_=v<<1|m]))return i[_]=s,t;if(p=+t._x.call(null,a.data),d=+t._y.call(null,a.data),e===p&&n===d)return s.next=a,i?i[_]=s:t._root=s,t;do i=i?i[_]=new Array(4):t._root=new Array(4),(m=e>=(h=(o+f)/2))?o=h:f=h,(v=n>=(l=(u+c)/2))?u=l:c=l;while((_=v<<1|m)===(g=(d>=l)<<1|p>=h));return i[g]=a,i[_]=s,t}function rs(t){var e,n,r=t.length,i,a,s=new Array(r),o=new Array(r),u=1/0,f=1/0,c=-1/0,h=-1/0;for(n=0;nc&&(c=i),ah&&(h=a));if(u>c||f>h)return this;for(this.cover(u,f).cover(c,h),n=0;nt||t>=i||r>e||e>=a;)switch(f=(ec||(o=d.y0)>h||(u=d.x1)=_)<<1|t>=v)&&(d=l[l.length-1],l[l.length-1]=l[l.length-1-m],l[l.length-1-m]=d)}else{var g=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=g*g+w*w;if(x=(l=(s+u)/2))?s=l:u=l,(m=h>=(p=(o+f)/2))?o=p:f=p,e=n,!(n=n[v=m<<1|d]))return this;if(!n.length)break;(e[v+1&3]||e[v+2&3]||e[v+3&3])&&(r=e,_=v)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):e?(a?e[v]=a:delete e[v],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function us(t){for(var e=0,n=t.length;e=(d=(u+h)/2))?u=d:h=d,(y=n>=(m=(f+l)/2))?f=m:l=m,(b=r>=(v=(c+p)/2))?c=v:p=v,a=s,!(s=s[M=b<<2|y<<1|x]))return a[M]=o,t;if(_=+t._x.call(null,s.data),g=+t._y.call(null,s.data),w=+t._z.call(null,s.data),e===_&&n===g&&r===w)return o.next=s,a?a[M]=o:t._root=o,t;do a=a?a[M]=new Array(8):t._root=new Array(8),(x=e>=(d=(u+h)/2))?u=d:h=d,(y=n>=(m=(f+l)/2))?f=m:l=m,(b=r>=(v=(c+p)/2))?c=v:p=v;while((M=b<<2|y<<1|x)===(A=(w>=v)<<2|(g>=m)<<1|_>=d));return a[A]=s,a[M]=o,t}function bs(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let a=1/0,s=1/0,o=1/0,u=-1/0,f=-1/0,c=-1/0;for(let h=0,l,p,d,m;hu&&(u=p),df&&(f=d),mc&&(c=m));if(a>u||s>f||o>c)return this;this.cover(a,s,o).cover(u,f,c);for(let h=0;ht||t>=s||i>e||e>=o||a>n||n>=u;)switch(l=(nd||(f=w.y0)>m||(c=w.z0)>v||(h=w.x1)=M)<<2|(e>=b)<<1|t>=y)&&(w=_[_.length-1],_[_.length-1]=_[_.length-1-x],_[_.length-1-x]=w)}else{var A=t-+this._x.call(null,g.data),I=e-+this._y.call(null,g.data),T=n-+this._z.call(null,g.data),k=A*A+I*I+T*T;if(kMath.sqrt((t-r)**2+(e-i)**2+(n-a)**2);function Ss(t,e,n,r){const i=[],a=t-r,s=e-r,o=n-r,u=t+r,f=e+r,c=n+r;return this.visit((h,l,p,d,m,v,_)=>{if(!h.length)do{const g=h.data;Ms(t,e,n,this._x(g),this._y(g),this._z(g))<=r&&i.push(g)}while(h=h.next);return l>u||p>f||d>c||m=(m=(s+f)/2))?s=m:f=m,(w=p>=(v=(o+c)/2))?o=v:c=v,(x=d>=(_=(u+h)/2))?u=_:h=_,e=n,!(n=n[y=x<<2|w<<1|g]))return this;if(!n.length)break;(e[y+1&7]||e[y+2&7]||e[y+3&7]||e[y+4&7]||e[y+5&7]||e[y+6&7]||e[y+7&7])&&(r=e,b=y)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):e?(a?e[y]=a:delete e[y],(n=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&n===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[b]=n:this._root=n),this):(this._root=a,this)}function Ns(t){for(var e=0,n=t.length;e1&&(I=M.y+M.vy-b.y-b.vy||W(c)),o>2&&(T=M.z+M.vz-b.z-b.vz||W(c)),k=Math.sqrt(A*A+I*I+T*T),k=(k-a[x])/k*_*r[x],A*=k,I*=k,T*=k,M.vx-=A*(N=f[x]),o>1&&(M.vy-=I*N),o>2&&(M.vz-=T*N),b.vx+=A*(N=1-N),o>1&&(b.vy+=I*N),o>2&&(b.vz+=T*N)}function d(){if(s){var _,g=s.length,w=t.length,x=new Map(s.map((b,M)=>[e(b,M,s),b])),y;for(_=0,u=new Array(g);_typeof w=="function")||Math.random,o=g.find(w=>[1,2,3].includes(w))||2,d()},p.links=function(_){return arguments.length?(t=_,d(),p):t},p.id=function(_){return arguments.length?(e=_,p):e},p.iterations=function(_){return arguments.length?(h=+_,p):h},p.strength=function(_){return arguments.length?(n=typeof _=="function"?_:G(+_),m(),p):n},p.distance=function(_){return arguments.length?(i=typeof _=="function"?_:G(+_),v(),p):i},p}const js=1664525,Ds=1013904223,Se=4294967296;function Ls(){let t=1;return()=>(t=(js*t+Ds)%Se)/Se}var ke=3;function It(t){return t.x}function Ne(t){return t.y}function Us(t){return t.z}var qs=10,Bs=Math.PI*(3-Math.sqrt(5)),Vs=Math.PI*20/(9+Math.sqrt(221));function no(t,e){e=e||2;var n=Math.min(ke,Math.max(1,Math.round(e))),r,i=1,a=.001,s=1-Math.pow(a,1/300),o=0,u=.6,f=new Map,c=Ve(p),h=Le("tick","end"),l=Ls();t==null&&(t=[]);function p(){d(),h.call("tick",r),i1&&(x.fy==null?x.y+=x.vy*=u:(x.y=x.fy,x.vy=0)),n>2&&(x.fz==null?x.z+=x.vz*=u:(x.z=x.fz,x.vz=0));return r}function m(){for(var _=0,g=t.length,w;_1&&isNaN(w.y)||n>2&&isNaN(w.z)){var x=qs*(n>2?Math.cbrt(.5+_):n>1?Math.sqrt(.5+_):_),y=_*Bs,b=_*Vs;n===1?w.x=x:n===2?(w.x=x*Math.cos(y),w.y=x*Math.sin(y)):(w.x=x*Math.sin(y)*Math.cos(b),w.y=x*Math.cos(y),w.z=x*Math.sin(y)*Math.sin(b))}(isNaN(w.vx)||n>1&&isNaN(w.vy)||n>2&&isNaN(w.vz))&&(w.vx=0,n>1&&(w.vy=0),n>2&&(w.vz=0))}}function v(_){return _.initialize&&_.initialize(t,l,n),_}return m(),r={tick:d,restart:function(){return c.restart(p),r},stop:function(){return c.stop(),r},numDimensions:function(_){return arguments.length?(n=Math.min(ke,Math.max(1,Math.round(_))),f.forEach(v),r):n},nodes:function(_){return arguments.length?(t=_,m(),f.forEach(v),r):t},alpha:function(_){return arguments.length?(i=+_,r):i},alphaMin:function(_){return arguments.length?(a=+_,r):a},alphaDecay:function(_){return arguments.length?(s=+_,r):+s},alphaTarget:function(_){return arguments.length?(o=+_,r):o},velocityDecay:function(_){return arguments.length?(u=1-_,r):1-u},randomSource:function(_){return arguments.length?(l=_,f.forEach(v),r):l},force:function(_,g){return arguments.length>1?(g==null?f.delete(_):f.set(_,v(g)),r):f.get(_)},find:function(){var _=Array.prototype.slice.call(arguments),g=_.shift()||0,w=(n>1?_.shift():null)||0,x=(n>2?_.shift():null)||0,y=_.shift()||1/0,b=0,M=t.length,A,I,T,k,N,$;for(y*=y,b=0;b1?(h.on(_,g),r):h.on(_)}}}function ro(){var t,e,n,r,i,a=G(-30),s,o=1,u=1/0,f=.81;function c(d){var m,v=t.length,_=(e===1?cn(t,It):e===2?pn(t,It,Ne):e===3?gn(t,It,Ne,Us):null).visitAfter(l);for(i=d,m=0;m1&&(d.y=x/g),e>2&&(d.z=y/g)}else{v=d,v.x=v.data.x,e>1&&(v.y=v.data.y),e>2&&(v.z=v.data.z);do m+=s[v.data.index];while(v=v.next)}d.value=m}function p(d,m,v,_,g){if(!d.value)return!0;var w=[v,_,g][e-1],x=d.x-n.x,y=e>1?d.y-n.y:0,b=e>2?d.z-n.z:0,M=w-m,A=x*x+y*y+b*b;if(M*M/f1&&y===0&&(y=W(r),A+=y*y),e>2&&b===0&&(b=W(r),A+=b*b),A1&&(n.vy+=y*d.value*i/A),e>2&&(n.vz+=b*d.value*i/A)),!0;if(d.length||A>=u)return;(d.data!==n||d.next)&&(x===0&&(x=W(r),A+=x*x),e>1&&y===0&&(y=W(r),A+=y*y),e>2&&b===0&&(b=W(r),A+=b*b),A1&&(n.vy+=y*M),e>2&&(n.vz+=b*M));while(d=d.next)}return c.initialize=function(d,...m){t=d,r=m.find(v=>typeof v=="function")||Math.random,e=m.find(v=>[1,2,3].includes(v))||2,h()},c.strength=function(d){return arguments.length?(a=typeof d=="function"?d:G(+d),h(),c):a},c.distanceMin=function(d){return arguments.length?(o=d*d,c):Math.sqrt(o)},c.distanceMax=function(d){return arguments.length?(u=d*d,c):Math.sqrt(u)},c.theta=function(d){return arguments.length?(f=d*d,c):Math.sqrt(f)},c}function io(t,e,n,r){var i,a,s=G(.1),o,u;typeof t!="function"&&(t=G(+t)),e==null&&(e=0),n==null&&(n=0),r==null&&(r=0);function f(h){for(var l=0,p=i.length;l1&&(d.vy+=v*w),a>2&&(d.vz+=_*w)}}function c(){if(i){var h,l=i.length;for(o=new Array(l),u=new Array(l),h=0;h[1,2,3].includes(p))||2,c()},f.strength=function(h){return arguments.length?(s=typeof h=="function"?h:G(+h),c(),f):s},f.radius=function(h){return arguments.length?(t=typeof h=="function"?h:G(+h),c(),f):t},f.x=function(h){return arguments.length?(e=+h,f):e},f.y=function(h){return arguments.length?(n=+h,f):n},f.z=function(h){return arguments.length?(r=+h,f):r},f}function Ws(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}const Te=Symbol("implicit");function Gs(){var t=new re,e=[],n=[],r=Te;function i(a){let s=t.get(a);if(s===void 0){if(r!==Te)return r;t.set(a,s=e.push(a)-1)}return n[s%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new re;for(const s of a)t.has(s)||t.set(s,e.push(s)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return Gs(e,n).unknown(r)},Ws.apply(i,arguments),i}function Xs(t){for(var e=t.length/6|0,n=new Array(e),r=0;r()=>n;function oe(n,{sourceEvent:e,subject:r,target:i,identifier:o,active:u,x:a,y:s,dx:l,dy:c,dispatch:f}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:f}})}oe.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function $n(n){return!n.ctrlKey&&!n.button}function jn(){return this.parentNode}function Ln(n,e){return e??{x:n.x,y:n.y}}function Fn(){return navigator.maxTouchPoints||"ontouchstart"in this}function qn(){var n=$n,e=jn,r=Ln,i=Fn,o={},u=pe("start","drag","end"),a=0,s,l,c,f,h=0;function d(v){v.on("mousedown.drag",g).filter(i).on("touchstart.drag",C).on("touchmove.drag",m,Un).on("touchend.drag touchcancel.drag",A).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(v,_){if(!(f||!n.call(this,v,_))){var M=R(this,e.call(this,v,_),v,_,"mouse");M&&(Q(v.view).on("mousemove.drag",y,Ot).on("mouseup.drag",w,Ot),Be(v.view),Qt(v),c=!1,s=v.clientX,l=v.clientY,M("start",v))}}function y(v){if(wt(v),!c){var _=v.clientX-s,M=v.clientY-l;c=_*_+M*M>h}o.mouse("drag",v)}function w(v){Q(v.view).on("mousemove.drag mouseup.drag",null),Qe(v.view,c),wt(v),o.mouse("end",v)}function C(v,_){if(n.call(this,v,_)){var M=v.changedTouches,k=e.call(this,v,_),E=M.length,O,P;for(O=0;O>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?$t(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?$t(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Vn.exec(n))?new X(e[1],e[2],e[3],1):(e=Hn.exec(n))?new X(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Xn.exec(n))?$t(e[1],e[2],e[3],e[4]):(e=Wn.exec(n))?$t(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Yn.exec(n))?Ae(e[1],e[2]/100,e[3]/100,1):(e=Zn.exec(n))?Ae(e[1],e[2]/100,e[3]/100,e[4]):Ce.hasOwnProperty(n)?Ee(Ce[n]):n==="transparent"?new X(NaN,NaN,NaN,0):null}function Ee(n){return new X(n>>16&255,n>>8&255,n&255,1)}function $t(n,e,r,i){return i<=0&&(n=e=r=NaN),new X(n,e,r,i)}function Qn(n){return n instanceof Nt||(n=Dt(n)),n?(n=n.rgb(),new X(n.r,n.g,n.b,n.opacity)):new X}function ae(n,e,r,i){return arguments.length===1?Qn(n):new X(n,e,r,i??1)}function X(n,e,r,i){this.r=+n,this.g=+e,this.b=+r,this.opacity=+i}ye(X,ae,Je(Nt,{brighter(n){return n=n==null?Xt:Math.pow(Xt,n),new X(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?Rt:Math.pow(Rt,n),new X(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new X(mt(this.r),mt(this.g),mt(this.b),Wt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Me,formatHex:Me,formatHex8:Jn,formatRgb:Te,toString:Te}));function Me(){return`#${yt(this.r)}${yt(this.g)}${yt(this.b)}`}function Jn(){return`#${yt(this.r)}${yt(this.g)}${yt(this.b)}${yt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Te(){const n=Wt(this.opacity);return`${n===1?"rgb(":"rgba("}${mt(this.r)}, ${mt(this.g)}, ${mt(this.b)}${n===1?")":`, ${n})`}`}function Wt(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function mt(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function yt(n){return n=mt(n),(n<16?"0":"")+n.toString(16)}function Ae(n,e,r,i){return i<=0?n=e=r=NaN:r<=0||r>=1?n=e=NaN:e<=0&&(n=NaN),new J(n,e,r,i)}function tn(n){if(n instanceof J)return new J(n.h,n.s,n.l,n.opacity);if(n instanceof Nt||(n=Dt(n)),!n)return new J;if(n instanceof J)return n;n=n.rgb();var e=n.r/255,r=n.g/255,i=n.b/255,o=Math.min(e,r,i),u=Math.max(e,r,i),a=NaN,s=u-o,l=(u+o)/2;return s?(e===u?a=(r-i)/s+(r0&&l<1?0:a,new J(a,s,l,n.opacity)}function tr(n,e,r,i){return arguments.length===1?tn(n):new J(n,e,r,i??1)}function J(n,e,r,i){this.h=+n,this.s=+e,this.l=+r,this.opacity=+i}ye(J,tr,Je(Nt,{brighter(n){return n=n==null?Xt:Math.pow(Xt,n),new J(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?Rt:Math.pow(Rt,n),new J(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,r=this.l,i=r+(r<.5?r:1-r)*e,o=2*r-i;return new X(Jt(n>=240?n-240:n+120,o,i),Jt(n,o,i),Jt(n<120?n+240:n-120,o,i),this.opacity)},clamp(){return new J(Oe(this.h),jt(this.s),jt(this.l),Wt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=Wt(this.opacity);return`${n===1?"hsl(":"hsla("}${Oe(this.h)}, ${jt(this.s)*100}%, ${jt(this.l)*100}%${n===1?")":`, ${n})`}`}}));function Oe(n){return n=(n||0)%360,n<0?n+360:n}function jt(n){return Math.max(0,Math.min(1,n||0))}function Jt(n,e,r){return(n<60?e+(r-e)*n/60:n<180?r:n<240?e+(r-e)*(240-n)/60:e)*255}const en=n=>()=>n;function er(n,e){return function(r){return n+r*e}}function nr(n,e,r){return n=Math.pow(n,r),e=Math.pow(e,r)-n,r=1/r,function(i){return Math.pow(n+i*e,r)}}function rr(n){return(n=+n)==1?nn:function(e,r){return r-e?nr(e,r,n):en(isNaN(e)?r:e)}}function nn(n,e){var r=e-n;return r?er(n,r):en(isNaN(n)?e:n)}const Re=(function n(e){var r=rr(e);function i(o,u){var a=r((o=ae(o)).r,(u=ae(u)).r),s=r(o.g,u.g),l=r(o.b,u.b),c=nn(o.opacity,u.opacity);return function(f){return o.r=a(f),o.g=s(f),o.b=l(f),o.opacity=c(f),o+""}}return i.gamma=n,i})(1);function gt(n,e){return n=+n,e=+e,function(r){return n*(1-r)+e*r}}var ue=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,te=new RegExp(ue.source,"g");function ir(n){return function(){return n}}function or(n){return function(e){return n(e)+""}}function ar(n,e){var r=ue.lastIndex=te.lastIndex=0,i,o,u,a=-1,s=[],l=[];for(n=n+"",e=e+"";(i=ue.exec(n))&&(o=te.exec(e));)(u=o.index)>r&&(u=e.slice(r,u),s[a]?s[a]+=u:s[++a]=u),(i=i[0])===(o=o[0])?s[a]?s[a]+=o:s[++a]=o:(s[++a]=null,l.push({i:a,x:gt(i,o)})),r=te.lastIndex;return r180?f+=360:f-c>180&&(c+=360),d.push({i:h.push(o(h)+"rotate(",null,i)-2,x:gt(c,f)})):f&&h.push(o(h)+"rotate("+f+i)}function s(c,f,h,d){c!==f?d.push({i:h.push(o(h)+"skewX(",null,i)-2,x:gt(c,f)}):f&&h.push(o(h)+"skewX("+f+i)}function l(c,f,h,d,g,y){if(c!==h||f!==d){var w=g.push(o(g)+"scale(",null,",",null,")");y.push({i:w-4,x:gt(c,h)},{i:w-2,x:gt(f,d)})}else(h!==1||d!==1)&&g.push(o(g)+"scale("+h+","+d+")")}return function(c,f){var h=[],d=[];return c=n(c),f=n(f),u(c.translateX,c.translateY,f.translateX,f.translateY,h,d),a(c.rotate,f.rotate,h,d),s(c.skewX,f.skewX,h,d),l(c.scaleX,c.scaleY,f.scaleX,f.scaleY,h,d),c=f=null,function(g){for(var y=-1,w=d.length,C;++y{i.stop(),n(o+e)},e,r),i}var pr=pe("start","end","cancel","interrupt"),yr=[],an=0,Ne=1,le=2,Gt=3,Ue=4,ce=5,Vt=6;function Kt(n,e,r,i,o,u){var a=n.__transition;if(!a)n.__transition={};else if(r in a)return;mr(n,r,{name:e,index:i,group:o,on:pr,tween:yr,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:an})}function me(n,e){var r=tt(n,e);if(r.state>an)throw new Error("too late; already scheduled");return r}function rt(n,e){var r=tt(n,e);if(r.state>Gt)throw new Error("too late; already running");return r}function tt(n,e){var r=n.__transition;if(!r||!(r=r[e]))throw new Error("transition not found");return r}function mr(n,e,r){var i=n.__transition,o;i[e]=r,r.timer=wn(u,0,r.time);function u(c){r.state=Ne,r.timer.restart(a,r.delay,r.time),r.delay<=c&&a(c-r.delay)}function a(c){var f,h,d,g;if(r.state!==Ne)return l();for(f in i)if(g=i[f],g.name===r.name){if(g.state===Gt)return Ie(a);g.state===Ue?(g.state=Vt,g.timer.stop(),g.on.call("interrupt",n,n.__data__,g.index,g.group),delete i[f]):+fle&&i.state=0&&(e=e.slice(0,r)),!e||e==="start"})}function Wr(n,e,r){var i,o,u=Xr(e)?me:rt;return function(){var a=u(this,n),s=a.on;s!==i&&(o=(i=s).copy()).on(e,r),a.on=o}}function Yr(n,e){var r=this._id;return arguments.length<2?tt(this.node(),r).on.on(n):this.each(Wr(r,n,e))}function Zr(n){return function(){var e=this.parentNode;for(var r in this.__transition)if(+r!==n)return;e&&e.removeChild(this)}}function Kr(){return this.on("end.remove",Zr(this._id))}function Br(n){var e=this._name,r=this._id;typeof n!="function"&&(n=_n(n));for(var i=this._groups,o=i.length,u=new Array(o),a=0;a()=>n;function _i(n,{sourceEvent:e,target:r,transform:i,dispatch:o}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function ct(n,e,r){this.k=n,this.x=e,this.y=r}ct.prototype={constructor:ct,scale:function(n){return n===1?this:new ct(this.k*n,this.x,this.y)},translate:function(n,e){return n===0&e===0?this:new ct(this.k,this.x+this.k*n,this.y+this.k*e)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var xe=new ct(1,0,0);et.prototype=ct.prototype;function et(n){for(;!n.__zoom;)if(!(n=n.parentNode))return xe;return n.__zoom}function ee(n){n.stopImmediatePropagation()}function _t(n){n.preventDefault(),n.stopImmediatePropagation()}function ki(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function Ci(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function $e(){return this.__zoom||xe}function zi(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function Pi(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ei(n,e,r){var i=n.invertX(e[0][0])-r[0][0],o=n.invertX(e[1][0])-r[1][0],u=n.invertY(e[0][1])-r[0][1],a=n.invertY(e[1][1])-r[1][1];return n.translate(o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o),a>u?(u+a)/2:Math.min(0,u)||Math.max(0,a))}function Mi(){var n=ki,e=Ci,r=Ei,i=zi,o=Pi,u=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],s=250,l=gr,c=pe("start","zoom","end"),f,h,d,g=500,y=150,w=0,C=10;function m(p){p.property("__zoom",$e).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",P).filter(o).on("touchstart.zoom",N).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(p,z,x,T){var S=p.selection?p.selection():p;S.property("__zoom",$e),p!==S?_(p,z,x,T):S.interrupt().each(function(){M(this,arguments).event(T).start().zoom(null,typeof z=="function"?z.apply(this,arguments):z).end()})},m.scaleBy=function(p,z,x,T){m.scaleTo(p,function(){var S=this.__zoom.k,D=typeof z=="function"?z.apply(this,arguments):z;return S*D},x,T)},m.scaleTo=function(p,z,x,T){m.transform(p,function(){var S=e.apply(this,arguments),D=this.__zoom,I=x==null?v(S):typeof x=="function"?x.apply(this,arguments):x,j=D.invert(I),F=typeof z=="function"?z.apply(this,arguments):z;return r(R(A(D,F),I,j),S,a)},x,T)},m.translateBy=function(p,z,x,T){m.transform(p,function(){return r(this.__zoom.translate(typeof z=="function"?z.apply(this,arguments):z,typeof x=="function"?x.apply(this,arguments):x),e.apply(this,arguments),a)},null,T)},m.translateTo=function(p,z,x,T,S){m.transform(p,function(){var D=e.apply(this,arguments),I=this.__zoom,j=T==null?v(D):typeof T=="function"?T.apply(this,arguments):T;return r(xe.translate(j[0],j[1]).scale(I.k).translate(typeof z=="function"?-z.apply(this,arguments):-z,typeof x=="function"?-x.apply(this,arguments):-x),D,a)},T,S)};function A(p,z){return z=Math.max(u[0],Math.min(u[1],z)),z===p.k?p:new ct(z,p.x,p.y)}function R(p,z,x){var T=z[0]-x[0]*p.k,S=z[1]-x[1]*p.k;return T===p.x&&S===p.y?p:new ct(p.k,T,S)}function v(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function _(p,z,x,T){p.on("start.zoom",function(){M(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(T).end()}).tween("zoom",function(){var S=this,D=arguments,I=M(S,D).event(T),j=e.apply(S,D),F=x==null?v(j):typeof x=="function"?x.apply(S,D):x,V=Math.max(j[1][0]-j[0][0],j[1][1]-j[0][1]),G=S.__zoom,K=typeof z=="function"?z.apply(S,D):z,it=l(G.invert(F).concat(V/G.k),K.invert(F).concat(V/K.k));return function(B){if(B===1)B=K;else{var ot=it(B),Bt=V/ot[2];B=new ct(Bt,F[0]-ot[0]*Bt,F[1]-ot[1]*Bt)}I.zoom(null,B)}})}function M(p,z,x){return!x&&p.__zooming||new k(p,z)}function k(p,z){this.that=p,this.args=z,this.active=0,this.sourceEvent=null,this.extent=e.apply(p,z),this.taps=0}k.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,z){return this.mouse&&p!=="mouse"&&(this.mouse[1]=z.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=z.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=z.invert(this.touch1[0])),this.that.__zoom=z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var z=Q(this.that).datum();c.call(p,this.that,new _i(p,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:c}),z)}};function E(p,...z){if(!n.apply(this,arguments))return;var x=M(this,z).event(p),T=this.__zoom,S=Math.max(u[0],Math.min(u[1],T.k*Math.pow(2,i.apply(this,arguments)))),D=lt(p);if(x.wheel)(x.mouse[0][0]!==D[0]||x.mouse[0][1]!==D[1])&&(x.mouse[1]=T.invert(x.mouse[0]=D)),clearTimeout(x.wheel);else{if(T.k===S)return;x.mouse=[D,T.invert(D)],Ht(this),x.start()}_t(p),x.wheel=setTimeout(I,y),x.zoom("mouse",r(R(A(T,S),x.mouse[0],x.mouse[1]),x.extent,a));function I(){x.wheel=null,x.end()}}function O(p,...z){if(d||!n.apply(this,arguments))return;var x=p.currentTarget,T=M(this,z,!0).event(p),S=Q(p.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",V,!0),D=lt(p,x),I=p.clientX,j=p.clientY;Be(p.view),ee(p),T.mouse=[D,this.__zoom.invert(D)],Ht(this),T.start();function F(G){if(_t(G),!T.moved){var K=G.clientX-I,it=G.clientY-j;T.moved=K*K+it*it>w}T.event(G).zoom("mouse",r(R(T.that.__zoom,T.mouse[0]=lt(G,x),T.mouse[1]),T.extent,a))}function V(G){S.on("mousemove.zoom mouseup.zoom",null),Qe(G.view,T.moved),_t(G),T.event(G).end()}}function P(p,...z){if(n.apply(this,arguments)){var x=this.__zoom,T=lt(p.changedTouches?p.changedTouches[0]:p,this),S=x.invert(T),D=x.k*(p.shiftKey?.5:2),I=r(R(A(x,D),T,S),e.apply(this,z),a);_t(p),s>0?Q(this).transition().duration(s).call(_,I,T,p):Q(this).call(m.transform,I,T,p)}}function N(p,...z){if(n.apply(this,arguments)){var x=p.touches,T=x.length,S=M(this,z,p.changedTouches.length===T).event(p),D,I,j,F;for(ee(p),I=0;In.length)&&(e=n.length);for(var r=0,i=Array(e);r0&&arguments[0]!==void 0?arguments[0]:6;Di(this,n),je(this,pt,void 0),je(this,ut,void 0),Le(ut,this,e),this.reset()}return Ni(n,[{key:"reset",value:function(){Le(pt,this,["__reserved for background__"])}},{key:"register",value:function(r){if(W(pt,this).length>=Math.pow(2,24-W(ut,this)))return null;var i=W(pt,this).length,o=Fe(i,W(ut,this)),u=Vi(i+(o<<24-W(ut,this)));return W(pt,this).push(r),u}},{key:"lookup",value:function(r){if(!r)return null;var i=typeof r=="string"?Hi(r):fn.apply(void 0,ji(r));if(!i)return null;var o=i&Math.pow(2,24-W(ut,this))-1,u=i>>24-W(ut,this)&Math.pow(2,W(ut,this))-1;return Fe(o,W(ut,this))!==u||o>=W(pt,this).length?null:W(pt,this)[o]}}])})();const{abs:kt,cos:st,sin:vt,acos:Wi,atan2:Ct,sqrt:ht,pow:Y}=Math;function zt(n){return n<0?-Y(-n,1/3):Y(n,1/3)}const hn=Math.PI,qt=2*hn,dt=hn/2,Yi=1e-6,ne=Number.MAX_SAFE_INTEGER||9007199254740991,re=Number.MIN_SAFE_INTEGER||-9007199254740991,Zi={x:0,y:0,z:0},b={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(n,e){const r=e(n);let i=r.x*r.x+r.y*r.y;return typeof r.z<"u"&&(i+=r.z*r.z),ht(i)},compute:function(n,e,r){if(n===0)return e[0].t=0,e[0];const i=e.length-1;if(n===1)return e[i].t=1,e[i];const o=1-n;let u=e;if(i===0)return e[0].t=n,e[0];if(i===1){const s={x:o*u[0].x+n*u[1].x,y:o*u[0].y+n*u[1].y,t:n};return r&&(s.z=o*u[0].z+n*u[1].z),s}if(i<4){let s=o*o,l=n*n,c,f,h,d=0;i===2?(u=[u[0],u[1],u[2],Zi],c=s,f=o*n*2,h=l):i===3&&(c=s*o,f=s*n*3,h=o*l*3,d=n*l);const g={x:c*u[0].x+f*u[1].x+h*u[2].x+d*u[3].x,y:c*u[0].y+f*u[1].y+h*u[2].y+d*u[3].y,t:n};return r&&(g.z=c*u[0].z+f*u[1].z+h*u[2].z+d*u[3].z),g}const a=JSON.parse(JSON.stringify(e));for(;a.length>1;){for(let s=0;s1;o--,u--){const a=[];for(let s=0,l;s"u")n=.5;else if(n===0||n===1)return n;const r=Y(n,e)+Y(1-n,e),i=r-1;return kt(i/r)},projectionratio:function(n,e){if(e!==2&&e!==3)return!1;if(typeof n>"u")n=.5;else if(n===0||n===1)return n;const r=Y(1-n,e),i=Y(n,e)+r;return r/i},lli8:function(n,e,r,i,o,u,a,s){const l=(n*i-e*r)*(o-a)-(n-r)*(o*s-u*a),c=(n*i-e*r)*(u-s)-(e-i)*(o*s-u*a),f=(n-r)*(u-s)-(e-i)*(o-a);return f==0?!1:{x:l/f,y:c/f}},lli4:function(n,e,r,i){const o=n.x,u=n.y,a=e.x,s=e.y,l=r.x,c=r.y,f=i.x,h=i.y;return b.lli8(o,u,a,s,l,c,f,h)},lli:function(n,e){return b.lli4(n,n.c,e,e.c)},makeline:function(n,e){return new q(n.x,n.y,(n.x+e.x)/2,(n.y+e.y)/2,e.x,e.y)},findbbox:function(n){let e=ne,r=ne,i=re,o=re;return n.forEach(function(u){const a=u.bbox();e>a.x.min&&(e=a.x.min),r>a.y.min&&(r=a.y.min),i0&&(f.c1=l,f.c2=c,f.s1=n,f.s2=r,u.push(f))})}),u},makeshape:function(n,e,r){const i=e.points.length,o=n.points.length,u=b.makeline(e.points[i-1],n.points[0]),a=b.makeline(n.points[o-1],e.points[0]),s={startcap:u,forward:n,back:e,endcap:a,bbox:b.findbbox([u,n,e,a])};return s.intersections=function(l){return b.shapeintersections(s,s.bbox,l,l.bbox,r)},s},getminmax:function(n,e,r){if(!r)return{min:0,max:0};let i=ne,o=re,u,a;r.indexOf(0)===-1&&(r=[0].concat(r)),r.indexOf(1)===-1&&r.push(1);for(let s=0,l=r.length;so&&(o=a[e]);return{min:i,mid:(i+o)/2,max:o,size:o-i}},align:function(n,e){const r=e.p1.x,i=e.p1.y,o=-Ct(e.p2.y-i,e.p2.x-r),u=function(a){return{x:(a.x-r)*st(o)-(a.y-i)*vt(o),y:(a.x-r)*vt(o)+(a.y-i)*st(o)}};return n.map(u)},roots:function(n,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const r=n.length-1,i=b.align(n,e),o=function(k){return 0<=k&&k<=1};if(r===2){const k=i[0].y,E=i[1].y,O=i[2].y,P=k-2*E+O;if(P!==0){const N=-ht(E*E-k*O),U=-k+E,$=-(N+U)/P,p=-(-N+U)/P;return[$,p].filter(o)}else if(E!==O&&P===0)return[(2*E-O)/(2*E-2*O)].filter(o);return[]}const u=i[0].y,a=i[1].y,s=i[2].y,l=i[3].y;let c=-u+3*a-3*s+l,f=3*u-6*a+3*s,h=-3*u+3*a,d=u;if(b.approximately(c,0)){if(b.approximately(f,0))return b.approximately(h,0)?[]:[-d/h].filter(o);const k=ht(h*h-4*f*d),E=2*f;return[(k-h)/E,(-h-k)/E].filter(o)}f/=c,h/=c,d/=c;const g=(3*h-f*f)/3,y=g/3,w=(2*f*f*f-9*f*h+27*d)/27,C=w/2,m=C*C+y*y*y;let A,R,v,_,M;if(m<0){const k=-g/3,E=k*k*k,O=ht(E),P=-w/(2*O),N=P<-1?-1:P>1?1:P,U=Wi(N),$=zt(O),p=2*$;return v=p*st(U/3)-f/3,_=p*st((U+qt)/3)-f/3,M=p*st((U+2*qt)/3)-f/3,[v,_,M].filter(o)}else{if(m===0)return A=C<0?zt(-C):-zt(C),v=2*A-f/3,_=-A-f/3,[v,_].filter(o);{const k=ht(m);return A=zt(-C+k),R=zt(C+k),[A-R-f/3].filter(o)}}},droots:function(n){if(n.length===3){const e=n[0],r=n[1],i=n[2],o=e-2*r+i;if(o!==0){const u=-ht(r*r-e*i),a=-e+r,s=-(u+a)/o,l=-(-u+a)/o;return[s,l]}else if(r!==i&&o===0)return[(2*r-i)/(2*(r-i))];return[]}if(n.length===2){const e=n[0],r=n[1];return e!==r?[e/(e-r)]:[]}return[]},curvature:function(n,e,r,i,o){let u,a,s,l,c=0,f=0;const h=b.compute(n,e),d=b.compute(n,r),g=h.x*h.x+h.y*h.y;if(i?(u=ht(Y(h.y*d.z-d.y*h.z,2)+Y(h.z*d.x-d.z*h.x,2)+Y(h.x*d.y-d.x*h.y,2)),a=Y(g+h.z*h.z,3/2)):(u=h.x*d.y-h.y*d.x,a=Y(g,3/2)),u===0||a===0)return{k:0,r:0};if(c=u/a,f=a/u,!o){const y=b.curvature(n-.001,e,r,i,!0).k,w=b.curvature(n+.001,e,r,i,!0).k;l=(w-c+(c-y))/2,s=(kt(w-c)+kt(c-y))/2}return{k:c,r:f,dk:l,adk:s}},inflections:function(n){if(n.length<4)return[];const e=b.align(n,{p1:n[0],p2:n.slice(-1)[0]}),r=e[2].x*e[1].y,i=e[3].x*e[1].y,o=e[1].x*e[2].y,u=e[3].x*e[2].y,a=18*(-3*r+2*i+3*o-u),s=18*(3*r-i-3*o),l=18*(o-r);if(b.approximately(a,0)){if(!b.approximately(s,0)){let d=-l/s;if(0<=d&&d<=1)return[d]}return[]}const c=2*a;if(b.approximately(c,0))return[];const f=s*s-4*a*l;if(f<0)return[];const h=Math.sqrt(f);return[(h-s)/c,-(s+h)/c].filter(function(d){return 0<=d&&d<=1})},bboxoverlap:function(n,e){const r=["x","y"],i=r.length;for(let o=0,u,a,s,l;o=l)return!1;return!0},expandbox:function(n,e){e.x.minn.x.max&&(n.x.max=e.x.max),e.y.max>n.y.max&&(n.y.max=e.y.max),e.z&&e.z.max>n.z.max&&(n.z.max=e.z.max),n.x.mid=(n.x.min+n.x.max)/2,n.y.mid=(n.y.min+n.y.max)/2,n.z&&(n.z.mid=(n.z.min+n.z.max)/2),n.x.size=n.x.max-n.x.min,n.y.size=n.y.max-n.y.min,n.z&&(n.z.size=n.z.max-n.z.min)},pairiteration:function(n,e,r){const i=n.bbox(),o=e.bbox(),u=1e5,a=r||.5;if(i.x.size+i.y.sizeM||M>k)&&(_+=qt),_>k&&(E=k,k=_,_=E)):k4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");o=!0}}else if(u!==6&&u!==8&&u!==9&&u!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const a=this._3d=!o&&(u===9||u===12)||e&&e[0]&&typeof e[0].z<"u",s=this.points=[];for(let g=0,y=a?3:2;gg+Pt(y.y),0)"u"&&(o=.5),o===0)return new q(r,r,i);if(o===1)return new q(e,r,r);const u=q.getABC(2,e,r,i,o);return new q(e,u.A,i)}static cubicFromPoints(e,r,i,o,u){typeof o>"u"&&(o=.5);const a=q.getABC(3,e,r,i,o);typeof u>"u"&&(u=b.dist(r,a.C));const s=u*(1-o)/o,l=b.dist(e,i),c=(i.x-e.x)/l,f=(i.y-e.y)/l,h=u*c,d=u*f,g=s*c,y=s*f,w={x:r.x-h,y:r.y-d},C={x:r.x+g,y:r.y+y},m=a.A,A={x:m.x+(w.x-m.x)/(1-o),y:m.y+(w.y-m.y)/(1-o)},R={x:m.x+(C.x-m.x)/o,y:m.y+(C.y-m.y)/o},v={x:e.x+(A.x-e.x)/o,y:e.y+(A.y-e.y)/o},_={x:i.x+(R.x-i.x)/(1-o),y:i.y+(R.y-i.y)/(1-o)};return new q(e,v,_,i)}static getUtils(){return b}getUtils(){return q.getUtils()}static get PolyBezier(){return Mt}valueOf(){return this.toString()}toString(){return b.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,r=e[0].x,i=e[0].y,o=["M",r,i,this.order===2?"Q":"C"];for(let u=1,a=e.length;u0}length(){return b.length(this.derivative.bind(this))}static getABC(e=2,r,i,o,u=.5){const a=b.projectionratio(u,e),s=1-a,l={x:a*r.x+s*o.x,y:a*r.y+s*o.y},c=b.abcratio(u,e);return{A:{x:i.x+(i.x-l.x)/c,y:i.y+(i.y-l.y)/c},B:i,C:l,S:r,E:o}}getABC(e,r){r=r||this.get(e);let i=this.points[0],o=this.points[this.order];return q.getABC(this.order,i,r,o,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let r=0,i,o;r1?1:h,d=this.compute(h),d.t=h,d.d=c,d}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?b.computeWithRatios(e,this.points,this.ratios,this._3d):b.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,r=[e[0]],i=e.length;for(let o=1,u,a;o1;){i=[];for(let a=0,s,l=r.length-1;a=0&&a<=1}),r=r.concat(e[i].sort(b.numberSort))}).bind(this)),e.values=r.sort(b.numberSort).filter(function(i,o){return r.indexOf(i)===o}),e}bbox(){const e=this.extrema(),r={};return this.dims.forEach((function(i){r[i]=b.getminmax(this,i,e[i])}).bind(this)),r}overlaps(e){const r=this.bbox(),i=e.bbox();return b.bboxoverlap(r,i)}offset(e,r){if(typeof r<"u"){const i=this.get(e),o=this.normal(e),u={c:i,n:o,x:i.x+o.x*r,y:i.y+o.y*r};return this._3d&&(u.z=i.z+o.z*r),u}if(this._linear){const i=this.normal(0),o=this.points.map(function(u){const a={x:u.x+e*i.x,y:u.y+e*i.y};return u.z&&i.z&&(a.z=u.z+e*i.z),a});return[new q(o)]}return this.reduce().map(function(i){return i._linear?i.offset(e)[0]:i.scale(e)})}simple(){if(this.order===3){const o=b.angle(this.points[0],this.points[3],this.points[1]),u=b.angle(this.points[0],this.points[3],this.points[2]);if(o>0&&u<0||o<0&&u>0)return!1}const e=this.normal(0),r=this.normal(1);let i=e.x*r.x+e.y*r.y;return this._3d&&(i+=e.z*r.z),Pt(Qi(i))(1-s/o)*r+s/o*i);return new q(this.points.map((a,s)=>({x:a.x+e.x*u[s],y:a.y+e.y*u[s]})))}scale(e){const r=this.order;let i=!1;if(typeof e=="function"&&(i=e),i&&r===2)return this.raise().scale(i);const o=this.clockwise,u=this.points;if(this._linear)return this.translate(this.normal(0),i?i(0):e,i?i(1):e);const a=i?i(0):e,s=i?i(1):e,l=[this.offset(0,10),this.offset(1,10)],c=[],f=b.lli4(l[0],l[0].c,l[1],l[1].c);if(!f)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(h){const d=c[h*r]=b.copy(u[h*r]);d.x+=(h?s:a)*l[h].n.x,d.y+=(h?s:a)*l[h].n.y}),i?([0,1].forEach(function(h){if(!(r===2&&h)){var d=u[h+1],g={x:d.x-f.x,y:d.y-f.y},y=i?i((h+1)/r):e;i&&!o&&(y=-y);var w=Et(g.x*g.x+g.y*g.y);g.x/=w,g.y/=w,c[h+1]={x:d.x+y*g.x,y:d.y+y*g.y}}}),new q(c)):([0,1].forEach(h=>{if(r===2&&h)return;const d=c[h*r],g=this.derivative(h),y={x:d.x+g.x,y:d.y+g.y};c[h+1]=b.lli4(d,y,f,u[h+1])}),new q(c))}outline(e,r,i,o){if(r=r===void 0?e:r,this._linear){const _=this.normal(0),M=this.points[0],k=this.points[this.points.length-1];let E,O,P;i===void 0&&(i=e,o=r),E={x:M.x+_.x*e,y:M.y+_.y*e},P={x:k.x+_.x*i,y:k.y+_.y*i},O={x:(E.x+P.x)/2,y:(E.y+P.y)/2};const N=[E,O,P];E={x:M.x-_.x*r,y:M.y-_.y*r},P={x:k.x-_.x*o,y:k.y-_.y*o},O={x:(E.x+P.x)/2,y:(E.y+P.y)/2};const U=[P,O,E],$=b.makeline(U[2],N[0]),p=b.makeline(N[2],U[0]),z=[$,new q(N),p,new q(U)];return new Mt(z)}const u=this.reduce(),a=u.length,s=[];let l=[],c,f=0,h=this.length();const d=typeof i<"u"&&typeof o<"u";function g(_,M,k,E,O){return function(P){const N=E/k,U=(E+O)/k,$=M-_;return b.map(P,0,1,_+N*$,_+U*$)}}u.forEach(function(_){const M=_.length();d?(s.push(_.scale(g(e,i,h,f,M))),l.push(_.scale(g(-r,-o,h,f,M)))):(s.push(_.scale(e)),l.push(_.scale(-r))),f+=M}),l=l.map(function(_){return c=_.points,c[3]?_.points=[c[3],c[2],c[1],c[0]]:_.points=[c[2],c[1],c[0]],_}).reverse();const y=s[0].points[0],w=s[a-1].points[s[a-1].points.length-1],C=l[a-1].points[l[a-1].points.length-1],m=l[0].points[0],A=b.makeline(C,y),R=b.makeline(w,m),v=[A].concat(s).concat([R]).concat(l);return new Mt(v)}outlineshapes(e,r,i){r=r||e;const o=this.outline(e,r).curves,u=[];for(let a=1,s=o.length;a1,l.endcap.virtual=a{var s=this.get(a);return b.between(s.x,r,o)&&b.between(s.y,i,u)})}selfintersects(e){const r=this.reduce(),i=r.length-2,o=[];for(let u=0,a,s,l;u0&&(u=u.concat(s))}),u}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,i,o){const u=(o-i)/4,a=this.get(i+u),s=this.get(o-u),l=b.dist(e,r),c=b.dist(e,a),f=b.dist(e,s);return Pt(c-l)+Pt(f-l)}_iterate(e,r){let i=0,o=1,u;do{u=0,o=1;let a=this.get(i),s,l,c,f,h=!1,d=!1,g,y=o,w=1;do if(d=h,f=c,y=(i+o)/2,s=this.get(y),l=this.get(o),c=b.getccenter(a,s,l),c.interval={start:i,end:o},h=this._error(c,a,i,o)<=e,g=d&&!h,g||(w=o),h){if(o>=1){if(c.interval.end=w=1,f=c,o>1){let m={x:c.x+c.r*Ki(c.e),y:c.y+c.r*Bi(c.e)};c.e+=b.angle({x:c.x,y:c.y},m,this.get(1))}break}o=o+(o-i)/2}else o=y;while(!g&&u++<100);if(u>=100)break;f=f||c,r.push(f),i=w}while(o<1);return r}}function he(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,i=Array(e);r0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(s){return{keyAccessor:s,isProp:!(s instanceof Function)}}),u=n.reduce(function(s,l){var c=s,f=l;return o.forEach(function(h,d){var g=h.keyAccessor,y=h.isProp,w;if(y){var C=f,m=C[g],A=ao(C,[g].map(fo));w=m,f=A}else w=g(f,d);d+11&&arguments[1]!==void 0?arguments[1]:1;c===o.length?Object.keys(l).forEach(function(f){return l[f]=r(l[f])}):Object.values(l).forEach(function(f){return s(f,c+1)})})(u);var a=u;return i&&(a=[],(function s(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];c.length===o.length?a.push({keys:c,vals:l}):Object.entries(l).forEach(function(f){var h=so(f,2),d=h[0],g=h[1];return s(g,[].concat(lo(c),[d]))})})(u),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a});function go(n,e){e===void 0&&(e={});var r=e.insertAt;if(!(typeof document>"u")){var i=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",r==="top"&&i.firstChild?i.insertBefore(o,i.firstChild):i.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}var po=`.force-graph-container canvas { + display: block; + user-select: none; + outline: none; + -webkit-tap-highlight-color: transparent; +} + +.force-graph-container .clickable { + cursor: pointer; +} + +.force-graph-container .grabbable { + cursor: move; + cursor: grab; + cursor: -moz-grab; + cursor: -webkit-grab; +} + +.force-graph-container .grabbable:active { + cursor: grabbing; + cursor: -moz-grabbing; + cursor: -webkit-grabbing; +} +`;go(po);function de(n,e){(e==null||e>n.length)&&(e=n.length);for(var r=0,i=Array(e);r2&&arguments[2]!==void 0?arguments[2]:{},u=o.nodeFilter,a=u===void 0?function(){return!0}:u,s=o.onLoopError,l=s===void 0?function(g){throw"Invalid DAG structure! Found cycle in node path: ".concat(g.join(" -> "),".")}:s,c={};r.forEach(function(g){return c[e(g)]={data:g,out:[],depth:-1,skip:!a(g)}}),i.forEach(function(g){var y=g.source,w=g.target,C=v(y),m=v(w);if(!c.hasOwnProperty(C))throw"Missing source node with id: ".concat(C);if(!c.hasOwnProperty(m))throw"Missing target node with id: ".concat(m);var A=c[C],R=c[m];A.out.push(R);function v(_){return ge(_)==="object"?e(_):_}});var f=[];d(Object.values(c));var h=Object.assign.apply(Object,[{}].concat(Z(Object.entries(c).filter(function(g){var y=Tt(g,2),w=y[1];return!w.skip}).map(function(g){var y=Tt(g,2),w=y[0],C=y[1];return It({},w,C.depth)}))));return h;function d(g){for(var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,C=function(){var v=g[m];if(y.indexOf(v)!==-1){var _=[].concat(Z(y.slice(y.indexOf(v))),[v]).map(function(M){return e(M.data)});return f.some(function(M){return M.length===_.length&&M.every(function(k,E){return k===_[E]})})||(f.push(_),l(_)),1}w>v.depth&&(v.depth=w,d(v.out,[].concat(Z(y),[v]),w+(v.skip?0:1)))},m=0,A=g.length;me.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||e.d3AlphaMin>0&&e.forceLayout.alpha()0){var U=Math.atan2(P.y-O.y,P.x-O.x),$=N*E,p={x:(O.x+P.x)/2+$*Math.cos(U-Math.PI/2),y:(O.y+P.y)/2+$*Math.sin(U-Math.PI/2)};k.__controlPoints=[p.x,p.y]}else{var z=E*70;k.__controlPoints=[P.x,P.y-z,P.x+z,P.y]}}}}function u(){var s=1.6,l=.2,c=L(e.linkDirectionalArrowLength),f=L(e.linkDirectionalArrowRelPos),h=L(e.linkVisibility),d=L(e.linkDirectionalArrowColor||e.linkColor),g=L(e.nodeVal),y=e.ctx;y.save(),e.graphData.links.filter(h).forEach(function(w){var C=c(w);if(!(!C||C<0)){var m=w.source,A=w.target;if(!(!m||!A||!m.hasOwnProperty("x")||!A.hasOwnProperty("x"))){var R=Math.sqrt(Math.max(0,g(m)||1))*e.nodeRelSize,v=Math.sqrt(Math.max(0,g(A)||1))*e.nodeRelSize,_=Math.min(1,Math.max(0,f(w))),M=d(w)||"rgba(0,0,0,0.28)",k=C/s/2,E=w.__controlPoints&&Ve(q,[m.x,m.y].concat(Z(w.__controlPoints),[A.x,A.y])),O=E?function(x){return E.get(x)}:function(x){return{x:m.x+(A.x-m.x)*x||0,y:m.y+(A.y-m.y)*x||0}},P=E?E.length():Math.sqrt(Math.pow(A.x-m.x,2)+Math.pow(A.y-m.y,2)),N=R+C+(P-R-v-C)*_,U=O(N/P),$=O((N-C)/P),p=O((N-C*(1-l))/P),z=Math.atan2(U.y-$.y,U.x-$.x)-Math.PI/2;y.beginPath(),y.moveTo(U.x,U.y),y.lineTo($.x+k*Math.cos(z),$.y+k*Math.sin(z)),y.lineTo(p.x,p.y),y.lineTo($.x-k*Math.cos(z),$.y-k*Math.sin(z)),y.fillStyle=M,y.fill()}}}),y.restore()}function a(){var s=L(e.linkDirectionalParticles),l=L(e.linkDirectionalParticleSpeed),c=L(e.linkDirectionalParticleOffset),f=L(e.linkDirectionalParticleWidth),h=L(e.linkVisibility),d=L(e.linkDirectionalParticleColor||e.linkColor),g=e.ctx;g.save(),e.graphData.links.filter(h).forEach(function(y){var w=s(y);if(!(!y.hasOwnProperty("__photons")||!y.__photons.length)){var C=y.source,m=y.target;if(!(!C||!m||!C.hasOwnProperty("x")||!m.hasOwnProperty("x"))){var A=l(y),R=Math.abs(c(y)),v=y.__photons||[],_=Math.max(0,f(y)/2)/Math.sqrt(e.globalScale),M=d(y)||"rgba(0,0,0,0.28)";g.fillStyle=M;var k=y.__controlPoints?Ve(q,[C.x,C.y].concat(Z(y.__controlPoints),[m.x,m.y])):null,E=0,O=!1;v.forEach(function(P){var N=!!P.__singleHop;if(P.hasOwnProperty("__progressRatio")||(P.__progressRatio=N?A<0?1:0:(E+R)/w),!N&&E++,P.__progressRatio+=A,P.__progressRatio>=1||P.__progressRatio<0)if(!N)P.__progressRatio=P.__progressRatio%1,P.__progressRatio<0&&P.__progressRatio++;else{O=!0;return}var U=P.__progressRatio,$=k?k.get(U):{x:C.x+(m.x-C.x)*U||0,y:C.y+(m.y-C.y)*U||0};e.linkDirectionalParticleCanvasObject?e.linkDirectionalParticleCanvasObject($.x,$.y,y,g,e.globalScale):(g.beginPath(),g.arc($.x,$.y,_,0,2*Math.PI,!1),g.fill())}),O&&(y.__photons=y.__photons.filter(function(P){return!P.__singleHop||P.__progressRatio<=1&&P.__progressRatio>=0}))}}}),g.restore()}},emitParticle:function(e,r){return r&&(!r.__photons&&(r.__photons=[]),r.__photons.push({__singleHop:!0})),this}},stateInit:function(){return{forceLayout:On().force("link",Rn()).force("charge",Sn()).force("center",Dn()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,r){r.ctx=e},update:function(e,r){e.engineRunning=!1,e.onUpdate(),e.nodeAutoColorBy!==null&&Xe(e.graphData.nodes,L(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&Xe(e.graphData.links,L(e.linkAutoColorBy),e.linkColor),e.graphData.links.forEach(function(d){d.source=d[e.linkSource],d.target=d[e.linkTarget]}),e.forceLayout.stop().alpha(1).nodes(e.graphData.nodes);var i=e.forceLayout.force("link");i&&i.id(function(d){return d[e.nodeId]}).links(e.graphData.links);var o=e.dagMode&&zo(e.graphData,function(d){return d[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),u=Math.max.apply(Math,Z(Object.values(o||[]))),a=e.dagLevelDistance||e.graphData.nodes.length/(u||1)*Po*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu"].includes(r.dagMode)){var s=["lr","rl"].includes(r.dagMode)?"fx":"fy";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(d){return delete d[s]})}if(["lr","rl","td","bu"].includes(e.dagMode)){var l=["rl","bu"].includes(e.dagMode),c=function(g){return(o[g[e.nodeId]]-u/2)*a*(l?-1:1)},f=["lr","rl"].includes(e.dagMode)?"fx":"fy";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(d){return d[f]=c(d)})}e.forceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?An(function(d){var g=o[d[e.nodeId]]||-1;return(e.dagMode==="radialin"?u-g:g)*a}).strength(function(d){return e.dagNodeFilter(d)?1:0}):null);for(var h=0;h0&&e.forceLayout.alpha()1?s-1:0),c=1;c1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,o=arguments.length,u=new Array(o>3?o-3:0),a=3;a1&&arguments[1]!==void 0?arguments[1]:function(){return!0},i=L(e.nodeVal),o=function(s){return Math.sqrt(Math.max(0,i(s)||1))*e.nodeRelSize},u=e.graphData.nodes.filter(r).map(function(a){return{x:a.x,y:a.y,r:o(a)}});return u.length?{x:[we(u,function(a){return a.x-a.r}),be(u,function(a){return a.x+a.r})],y:[we(u,function(a){return a.y-a.r}),be(u,function(a){return a.y+a.r})]}:null},pauseAnimation:function(e){return e.animationFrameRequestId&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),this},resumeAnimation:function(e){return e.animationFrameRequestId||this._animationCycle(),this},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},Ro),stateInit:function(){return{lastSetZoom:1,zoom:Mi(),forceGraph:new Yt,shadowGraph:new Yt().cooldownTicks(0).nodeColor("__indexColor").linkColor("__indexColor").isShadow(!0),colorTracker:new Xi,tweenGroup:new Nn}},init:function(e,r){var i=this;e.innerHTML="";var o=document.createElement("div");o.classList.add("force-graph-container"),o.style.position="relative",e.appendChild(o),r.canvas=document.createElement("canvas"),r.backgroundColor&&(r.canvas.style.background=r.backgroundColor),o.appendChild(r.canvas),r.shadowCanvas=document.createElement("canvas");var u=r.canvas.getContext("2d"),a=r.shadowCanvas.getContext("2d",{willReadFrequently:!0}),s={x:-1e12,y:-1e12},l=function(){var h=null,d=window.devicePixelRatio,g=s.x>0&&s.y>0?a.getImageData(s.x*d,s.y*d,1,1):null;return g&&(h=r.colorTracker.lookup(g.data)),h};Q(r.canvas).call(qn().subject(function(){if(!r.enableNodeDrag)return null;var f=l();return f&&f.type==="Node"?f.d:null}).on("start",function(f){var h=f.subject;h.__initialDragPos={x:h.x,y:h.y,fx:h.fx,fy:h.fy},f.active||(h.fx=h.x,h.fy=h.y),r.canvas.classList.add("grabbable")}).on("drag",function(f){var h=f.subject,d=h.__initialDragPos,g=f,y=et(r.canvas).k,w={x:d.x+(g.x-d.x)/y-h.x,y:d.y+(g.y-d.y)/y-h.y};["x","y"].forEach(function(C){return h["f".concat(C)]=h[C]=d[C]+(g[C]-d[C])/y}),!(!h.__dragged&&To>=Math.sqrt(Ti(["x","y"].map(function(C){return Math.pow(f[C]-d[C],2)}))))&&(r.forceGraph.d3AlphaTarget(.3).resetCountdown(),r.isPointerDragging=!0,h.__dragged=!0,r.onNodeDrag(h,w))}).on("end",function(f){var h=f.subject,d=h.__initialDragPos,g={x:h.x-d.x,y:h.y-d.y};d.fx===void 0&&(h.fx=void 0),d.fy===void 0&&(h.fy=void 0),delete h.__initialDragPos,r.forceGraph.d3AlphaTarget()&&r.forceGraph.d3AlphaTarget(0).resetCountdown(),r.canvas.classList.remove("grabbable"),r.isPointerDragging=!1,h.__dragged&&(delete h.__dragged,r.onNodeDragEnd(h,g))})),r.zoom(r.zoom.__baseElem=Q(r.canvas)),r.zoom.__baseElem.on("dblclick.zoom",null),r.zoom.filter(function(f){return!f.button&&r.enableZoomPanInteraction&&(f.type!=="wheel"||L(r.enableZoomInteraction)(f))&&(f.type==="wheel"||L(r.enablePanInteraction)(f))}).on("zoom",function(f){var h=f.transform;[u,a].forEach(function(d){vn(d),d.translate(h.x,h.y),d.scale(h.k,h.k)}),r.isPointerDragging=!0,r.onZoom&&r.onZoom(xt(xt({},h),i.centerAt())),r.needsRedraw=!0}).on("end",function(f){r.isPointerDragging=!1,r.onZoomEnd&&r.onZoomEnd(xt(xt({},f.transform),i.centerAt()))}),ie(r),r.forceGraph.onNeedsRedraw(function(){return r.needsRedraw=!0}).onFinishUpdate(function(){et(r.canvas).k===r.lastSetZoom&&r.graphData.nodes.length&&(r.zoom.scaleTo(r.zoom.__baseElem,r.lastSetZoom=Mo/Math.cbrt(r.graphData.nodes.length)),r.needsRedraw=!0)}),r.tooltip=new In(o),["pointermove","pointerdown"].forEach(function(f){return o.addEventListener(f,function(h){f==="pointerdown"&&(r.isPointerPressed=!0,r.pointerDownEvent=h),!r.isPointerDragging&&h.type==="pointermove"&&r.onBackgroundClick&&(h.pressure>0||r.isPointerPressed)&&(h.pointerType==="mouse"||h.movementX===void 0||[h.movementX,h.movementY].some(function(y){return Math.abs(y)>1}))&&(r.isPointerDragging=!0);var d=g(o);s.x=h.pageX-d.left,s.y=h.pageY-d.top;function g(y){var w=y.getBoundingClientRect(),C=window.pageXOffset||document.documentElement.scrollLeft,m=window.pageYOffset||document.documentElement.scrollTop;return{top:w.top+m,left:w.left+C}}},{passive:!0})}),o.addEventListener("pointerup",function(f){if(r.isPointerPressed){if(r.isPointerPressed=!1,r.isPointerDragging){r.isPointerDragging=!1;return}var h=[f,r.pointerDownEvent];requestAnimationFrame(function(){if(f.button===0)if(r.hoverObj){var d=r["on".concat(r.hoverObj.type,"Click")];d&&d.apply(void 0,[r.hoverObj.d].concat(h))}else r.onBackgroundClick&&r.onBackgroundClick.apply(r,h);if(f.button===2)if(r.hoverObj){var g=r["on".concat(r.hoverObj.type,"RightClick")];g&&g.apply(void 0,[r.hoverObj.d].concat(h))}else r.onBackgroundRightClick&&r.onBackgroundRightClick.apply(r,h)})}},{passive:!0}),o.addEventListener("contextmenu",function(f){return!r.onBackgroundRightClick&&!r.onNodeRightClick&&!r.onLinkRightClick?!0:(f.preventDefault(),!1)}),r.forceGraph(u),r.shadowGraph(a);var c=Oi(function(){Ye(a,r.width,r.height),r.shadowGraph.linkWidth(function(h){return L(r.linkWidth)(h)+r.linkHoverPrecision});var f=et(r.canvas);r.shadowGraph.globalScale(f.k).tickFrame()},Eo);r.flushShadowCanvas=c.flush,(this._animationCycle=function f(){var h=!r.autoPauseRedraw||!!r.needsRedraw||r.forceGraph.isEngineRunning()||r.graphData.links.some(function(R){return R.__photons&&R.__photons.length});if(r.needsRedraw=!1,r.enablePointerInteraction){var d=r.isPointerDragging?null:l();if(d!==r.hoverObj){var g=r.hoverObj,y=g?g.type:null,w=d?d.type:null;if(y&&y!==w){var C=r["on".concat(y,"Hover")];C&&C(null,g.d)}if(w){var m=r["on".concat(w,"Hover")];m&&m(d.d,y===w?g.d:null)}r.tooltip.content(d&&L(r["".concat(d.type.toLowerCase(),"Label")])(d.d)||null),r.canvas.classList[(d&&r["on".concat(w,"Click")]||!d&&r.onBackgroundClick)&&L(r.showPointerCursor)(d==null?void 0:d.d)?"add":"remove"]("clickable"),r.hoverObj=d}h&&c()}if(h){Ye(u,r.width,r.height);var A=et(r.canvas).k;r.onRenderFramePre&&r.onRenderFramePre(u,A),r.forceGraph.globalScale(A).tickFrame(),r.onRenderFramePost&&r.onRenderFramePost(u,A)}r.tweenGroup.update(),r.animationFrameRequestId=requestAnimationFrame(f)})()},update:function(e){}});export{Do as default}; diff --git a/internal/ui/assets/assets/index-BqUe1JKj.css b/internal/ui/assets/assets/index-BqUe1JKj.css new file mode 100644 index 0000000..9768a24 --- /dev/null +++ b/internal/ui/assets/assets/index-BqUe1JKj.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Inter,system-ui,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root,.dark{color-scheme:dark;--background: 240 10% 3.9%;--foreground: 0 0% 98%;--card: 240 9% 7%;--card-foreground: 0 0% 98%;--popover: 240 9% 7%;--popover-foreground: 0 0% 98%;--primary: 357 89% 47%;--primary-foreground: 0 0% 100%;--secondary: 240 4% 16%;--secondary-foreground: 0 0% 98%;--muted: 240 5% 14%;--muted-foreground: 240 5% 64.9%;--accent: 240 4% 16%;--accent-foreground: 0 0% 98%;--destructive: 0 62.8% 50.6%;--destructive-foreground: 0 0% 98%;--success: 142 71% 45%;--success-foreground: 0 0% 98%;--warning: 38 92% 50%;--warning-foreground: 0 0% 98%;--border: 240 6% 16%;--input: 240 6% 16%;--ring: 357 89% 47%;--radius: .25rem;--brand: 357 89% 47%;--pillar-memory: 217 91% 60%;--pillar-graph: 262 83% 66%;--pillar-review: 142 71% 45%;--pillar-tokens: 38 92% 50%}.\!dark{color-scheme:dark!important;--background: 240 10% 3.9% !important;--foreground: 0 0% 98% !important;--card: 240 9% 7% !important;--card-foreground: 0 0% 98% !important;--popover: 240 9% 7% !important;--popover-foreground: 0 0% 98% !important;--primary: 357 89% 47% !important;--primary-foreground: 0 0% 100% !important;--secondary: 240 4% 16% !important;--secondary-foreground: 0 0% 98% !important;--muted: 240 5% 14% !important;--muted-foreground: 240 5% 64.9% !important;--accent: 240 4% 16% !important;--accent-foreground: 0 0% 98% !important;--destructive: 0 62.8% 50.6% !important;--destructive-foreground: 0 0% 98% !important;--success: 142 71% 45% !important;--success-foreground: 0 0% 98% !important;--warning: 38 92% 50% !important;--warning-foreground: 0 0% 98% !important;--border: 240 6% 16% !important;--input: 240 6% 16% !important;--ring: 357 89% 47% !important;--radius: .25rem !important;--brand: 357 89% 47% !important;--pillar-memory: 217 91% 60% !important;--pillar-graph: 262 83% 66% !important;--pillar-review: 142 71% 45% !important;--pillar-tokens: 38 92% 50% !important}.light{color-scheme:light;--background: 240 20% 98%;--foreground: 240 10% 10%;--card: 0 0% 100%;--card-foreground: 240 10% 10%;--popover: 0 0% 100%;--popover-foreground: 240 10% 10%;--primary: 357 89% 47%;--primary-foreground: 0 0% 100%;--secondary: 240 10% 94%;--secondary-foreground: 240 10% 20%;--muted: 240 10% 94%;--muted-foreground: 240 5% 45%;--accent: 357 60% 96%;--accent-foreground: 357 70% 40%;--destructive: 0 84% 60%;--destructive-foreground: 0 0% 100%;--success: 142 70% 35%;--success-foreground: 0 0% 100%;--warning: 38 92% 45%;--warning-foreground: 0 0% 100%;--border: 240 10% 90%;--input: 240 10% 90%;--ring: 357 89% 47%;--brand: 357 89% 47%;--pillar-memory: 217 91% 55%;--pillar-graph: 262 83% 58%;--pillar-review: 142 71% 40%;--pillar-tokens: 38 92% 45%}*{border-color:hsl(var(--border))}body{background-color:hsl(var(--background));font-family:Inter,system-ui,sans-serif;color:hsl(var(--foreground));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}html{scroll-behavior:smooth}.container{width:100%;margin-right:auto;margin-left:auto;padding-right:2rem;padding-left:2rem}@media(min-width:1400px){.container{max-width:1400px}}.light .gradient-text{--tw-gradient-from: #9333ea var(--tw-gradient-from-position);--tw-gradient-to: rgb(147 51 234 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);--tw-gradient-to: rgb(124 58 237 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), #7c3aed var(--tw-gradient-via-position), var(--tw-gradient-to);--tw-gradient-to: #db2777 var(--tw-gradient-to-position)}.light .glass{border-bottom-width:1px;border-color:hsl(var(--border) / .5);background-color:hsl(var(--background) / .9);--tw-backdrop-blur: blur(24px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.glow{box-shadow:0 0 60px -15px hsl(var(--primary) / .3)}.light .glow{box-shadow:0 0 60px -15px hsl(var(--primary) / .15)}.glow-sm{box-shadow:0 0 30px -10px hsl(var(--primary) / .2)}.light .glow-sm{box-shadow:0 0 30px -10px hsl(var(--primary) / .1)}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.right-0{right:0}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.top-2{top:.5rem}.top-3{top:.75rem}.top-4{top:1rem}.top-full{top:100%}.z-40{z-index:40}.z-50{z-index:50}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-1\.5{margin-right:.375rem}.mr-2{margin-right:.5rem}.mr-6{margin-right:1.5rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-2\.5{height:.625rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-\[85vh\]{max-height:85vh}.min-h-0{min-height:0px}.min-h-10{min-height:2.5rem}.min-h-7{min-height:1.75rem}.min-h-8{min-height:2rem}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-2\.5{width:.625rem}.w-3\.5{width:.875rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-52{width:13rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-80{width:20rem}.w-9{width:2.25rem}.w-full{width:100%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-10{min-width:2.5rem}.min-w-7{min-width:1.75rem}.min-w-8{min-width:2rem}.max-w-2xl{max-width:42rem}.max-w-\[calc\(100\%-1\.5rem\)\]{max-width:calc(100% - 1.5rem)}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.scale-100{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-95{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes fade-up{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}.animate-fade-up{animation:fade-up .4s ease-out}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-pointer{cursor:pointer}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-1{row-gap:.25rem}.gap-y-2{row-gap:.5rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-destructive\/40{border-color:hsl(var(--destructive) / .4)}.border-input{border-color:hsl(var(--input))}.border-primary\/30{border-color:hsl(var(--primary) / .3)}.border-transparent{border-color:transparent}.border-warning\/35{border-color:hsl(var(--warning) / .35)}.bg-background{background-color:hsl(var(--background))}.bg-background\/80{background-color:hsl(var(--background) / .8)}.bg-background\/90{background-color:hsl(var(--background) / .9)}.bg-border{background-color:hsl(var(--border))}.bg-card{background-color:hsl(var(--card))}.bg-card\/80{background-color:hsl(var(--card) / .8)}.bg-destructive{background-color:hsl(var(--destructive))}.bg-destructive\/10{background-color:hsl(var(--destructive) / .1)}.bg-muted{background-color:hsl(var(--muted))}.bg-muted\/30{background-color:hsl(var(--muted) / .3)}.bg-muted\/50{background-color:hsl(var(--muted) / .5)}.bg-pillar-graph\/15{background-color:hsl(var(--pillar-graph) / .15)}.bg-pillar-memory\/15{background-color:hsl(var(--pillar-memory) / .15)}.bg-pillar-review\/15{background-color:hsl(var(--pillar-review) / .15)}.bg-pillar-tokens\/15{background-color:hsl(var(--pillar-tokens) / .15)}.bg-primary{background-color:hsl(var(--primary))}.bg-primary\/10{background-color:hsl(var(--primary) / .1)}.bg-primary\/15{background-color:hsl(var(--primary) / .15)}.bg-secondary{background-color:hsl(var(--secondary))}.bg-success\/20{background-color:hsl(var(--success) / .2)}.bg-warning\/10{background-color:hsl(var(--warning) / .1)}.bg-warning\/20{background-color:hsl(var(--warning) / .2)}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.pb-4{padding-bottom:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-5{padding-top:1.25rem}.text-center{text-align:center}.font-mono{font-family:JetBrains Mono,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.tracking-tight{letter-spacing:-.025em}.tracking-wider{letter-spacing:.05em}.text-brand{color:hsl(var(--brand))}.text-card-foreground{color:hsl(var(--card-foreground))}.text-destructive-foreground{color:hsl(var(--destructive-foreground))}.text-foreground{color:hsl(var(--foreground))}.text-muted-foreground{color:hsl(var(--muted-foreground))}.text-pillar-graph{--tw-text-opacity: 1;color:hsl(var(--pillar-graph) / var(--tw-text-opacity, 1))}.text-pillar-memory{--tw-text-opacity: 1;color:hsl(var(--pillar-memory) / var(--tw-text-opacity, 1))}.text-pillar-review{--tw-text-opacity: 1;color:hsl(var(--pillar-review) / var(--tw-text-opacity, 1))}.text-pillar-tokens{--tw-text-opacity: 1;color:hsl(var(--pillar-tokens) / var(--tw-text-opacity, 1))}.text-primary{color:hsl(var(--primary))}.text-primary-foreground{color:hsl(var(--primary-foreground))}.text-secondary-foreground{color:hsl(var(--secondary-foreground))}.text-success{color:hsl(var(--success))}.text-warning{color:hsl(var(--warning))}.underline-offset-4{text-underline-offset:4px}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.backdrop-blur-xl{--tw-backdrop-blur: blur(24px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-100{transition-duration:.1s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-75{transition-duration:75ms}.ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.hover\:glow:hover{box-shadow:0 0 60px -15px hsl(var(--primary) / .3)}.light .hover\:glow:hover{box-shadow:0 0 60px -15px hsl(var(--primary) / .15)}.hover\:-translate-y-1:hover{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-primary\/50:hover{border-color:hsl(var(--primary) / .5)}.hover\:bg-accent:hover{background-color:hsl(var(--accent))}.hover\:bg-destructive\/90:hover{background-color:hsl(var(--destructive) / .9)}.hover\:bg-muted:hover{background-color:hsl(var(--muted))}.hover\:bg-primary\/90:hover{background-color:hsl(var(--primary) / .9)}.hover\:bg-secondary\/80:hover{background-color:hsl(var(--secondary) / .8)}.hover\:text-accent-foreground:hover{color:hsl(var(--accent-foreground))}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:underline:hover{text-decoration-line:underline}.focus\:border-primary\/50:focus{border-color:hsl(var(--primary) / .5)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-ring:focus{--tw-ring-color: hsl(var(--ring))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--ring))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:opacity-50:disabled{opacity:.5}@media(min-width:640px){.sm\:mr-3{margin-right:.75rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:px-4{padding-left:1rem;padding-right:1rem}}@media(min-width:1024px){.lg\:block{display:block}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:px-6{padding-left:1.5rem;padding-right:1.5rem}.lg\:pb-6{padding-bottom:1.5rem}.lg\:pt-4{padding-top:1rem}}@media(min-width:1280px){.xl\:inline{display:inline}}@media(min-width:1536px){.\32xl\:px-2\.5{padding-left:.625rem;padding-right:.625rem}} diff --git a/internal/ui/assets/assets/index-CsXy5pyf.js b/internal/ui/assets/assets/index-CsXy5pyf.js new file mode 100644 index 0000000..53d1203 --- /dev/null +++ b/internal/ui/assets/assets/index-CsXy5pyf.js @@ -0,0 +1,169 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./force-graph-BunJtbL4.js","./Paired-B5xWXdbq.js","./3d-force-graph-9_wZMVcC.js","./three.module-CGesFut6.js","./three-spritetext-vp3JBkiZ.js"])))=>i.map(i=>d[i]); +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))a(l);new MutationObserver(l=>{for(const r of l)if(r.type==="childList")for(const c of r.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(l){const r={};return l.integrity&&(r.integrity=l.integrity),l.referrerPolicy&&(r.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?r.credentials="include":l.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function a(l){if(l.ep)return;l.ep=!0;const r=n(l);fetch(l.href,r)}})();/** +* @vue/shared v3.5.42 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/function q5(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return n=>n in t}const Z1={},w3=[],S2=()=>{},H7=()=>!1,z4=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),H4=e=>e.startsWith("onUpdate:"),I1=Object.assign,J5=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},G0=Object.prototype.hasOwnProperty,v1=(e,t)=>G0.call(e,t),Y=Array.isArray,n3=e=>u4(e)==="[object Map]",H2=e=>u4(e)==="[object Set]",Z6=e=>u4(e)==="[object Date]",n1=e=>typeof e=="function",A1=e=>typeof e=="string",d2=e=>typeof e=="symbol",b1=e=>e!==null&&typeof e=="object",B7=e=>(b1(e)||n1(e))&&n1(e.then)&&n1(e.catch),U7=Object.prototype.toString,u4=e=>U7.call(e),W0=e=>u4(e).slice(8,-1),G7=e=>u4(e)==="[object Object]",Y5=e=>A1(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,G3=q5(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),B4=e=>{const t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},K0=/-\w/g,J1=B4(e=>e.replace(K0,t=>t.slice(1).toUpperCase())),q0=/\B([A-Z])/g,v3=B4(e=>e.replace(q0,"-$1").toLowerCase()),U4=B4(e=>e.charAt(0).toUpperCase()+e.slice(1)),o5=B4(e=>e?`on${U4(e)}`:""),k2=(e,t)=>!Object.is(e,t),k4=(e,...t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:a,value:n})},G4=e=>{const t=parseFloat(e);return isNaN(t)?e:t},J0=e=>{const t=A1(e)?Number(e):NaN;return isNaN(t)?e:t};let k6;const W4=()=>k6||(k6=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function K4(e){if(Y(e)){const t={};for(let n=0;n{if(n){const a=n.split(X0);a.length>1&&(t[a[0].trim()]=a[1].trim())}}),t}function X1(e){let t="";if(A1(e))t=e;else if(Y(e))for(let n=0;nB2(n,t))}const q7=e=>!!(e&&e.__v_isRef===!0),J=e=>A1(e)?e:e==null?"":Y(e)||b1(e)&&(e.toString===U7||!n1(e.toString))?q7(e)?J(e.value):JSON.stringify(e,J7,2):String(e),J7=(e,t)=>q7(t)?J7(e,t.value):n3(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[a,l],r)=>(n[s5(a,r)+" =>"]=l,n),{})}:H2(t)?{[`Set(${t.size})`]:[...t.values()].map(n=>s5(n))}:d2(t)?s5(t):b1(t)&&!Y(t)&&!G7(t)?String(t):t,s5=(e,t="")=>{var n;return d2(e)?`Symbol(${(n=e.description)!=null?n:t})`:e};/** +* @vue/reactivity v3.5.42 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/let D1;class le{constructor(t=!1){this.detached=t,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!t&&D1&&(D1.active?(this.parent=D1,this.index=(D1.scopes||(D1.scopes=[])).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,n;if(this.scopes){const a=this.scopes.slice();for(t=0,n=a.length;t0&&--this._on===0){if(D1===this)D1=this.prevScope;else{let t=D1;for(;t;){if(t.prevScope===this){t.prevScope=this.prevScope;break}t=t.prevScope}}this.prevScope=void 0}}stop(t){if(this._active){this._active=!1;let n,a;for(n=0,a=this.effects.length;n0)return;if(K3){let t=K3;for(K3=void 0;t;){const n=t.next;t.next=void 0,t.flags&=-9,t=n}}let e;for(;W3;){let t=W3;for(W3=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(a){e||(e=a)}t=n}}if(e)throw e}function e8(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function t8(e){let t,n=e.depsTail,a=n;for(;a;){const l=a.prevDep;a.version===-1?(a===n&&(n=l),t6(a),ce(a)):t=a,a.dep.activeLink=a.prevActiveLink,a.prevActiveLink=void 0,a=l}e.deps=t,e.depsTail=n}function S5(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(n8(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function n8(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===X3)||(e.globalVersion=X3,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!S5(e))))return;e.flags|=2;const t=e.dep,n=C1,a=f2;C1=e,f2=!0;try{e8(e);const l=e.fn(e._value);(t.version===0||k2(l,e._value))&&(e.flags|=128,e._value=l,t.version++)}catch(l){throw t.version++,l}finally{C1=n,f2=a,t8(e),e.flags&=-3}}function t6(e,t=!1){const{dep:n,prevSub:a,nextSub:l}=e;if(a&&(a.nextSub=l,e.prevSub=void 0),l&&(l.prevSub=a,e.nextSub=void 0),n.subs===e&&(n.subs=a,!a&&n.computed)){n.computed.flags&=-5;for(let r=n.computed.deps;r;r=r.nextDep)t6(r,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function ce(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}let f2=!0;const a8=[];function U2(){a8.push(f2),f2=!1}function G2(){const e=a8.pop();f2=e===void 0?!0:e}function A6(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const n=C1;C1=void 0;try{t()}finally{C1=n}}}let X3=0;class oe{constructor(t,n){this.sub=t,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class n6{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(t){if(!C1||!f2||C1===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==C1)n=this.activeLink=new oe(C1,this),C1.deps?(n.prevDep=C1.depsTail,C1.depsTail.nextDep=n,C1.depsTail=n):C1.deps=C1.depsTail=n,l8(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const a=n.nextDep;a.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=a),n.prevDep=C1.depsTail,n.nextDep=void 0,C1.depsTail.nextDep=n,C1.depsTail=n,C1.deps===n&&(C1.deps=a)}return n}trigger(t){this.version++,X3++,this.notify(t)}notify(t){Q5();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{e6()}}}function l8(e){if(e.dep.sc++,e.sub.flags&4){const t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let a=t.deps;a;a=a.nextDep)l8(a)}const n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}const E5=new WeakMap,m3=Symbol(""),R5=Symbol(""),Q3=Symbol("");function z1(e,t,n){if(f2&&C1){let a=E5.get(e);a||E5.set(e,a=new Map);let l=a.get(n);l||(a.set(n,l=new n6),l.map=a,l.key=n),l.track()}}function j2(e,t,n,a,l,r){const c=E5.get(e);if(!c){X3++;return}const s=o=>{o&&o.trigger()};if(Q5(),t==="clear")c.forEach(s);else{const o=Y(e),i=o&&Y5(n);if(o&&n==="length"){const u=Number(a);c.forEach((f,d)=>{(d==="length"||d===Q3||!d2(d)&&d>=u)&&s(f)})}else switch((n!==void 0||c.has(void 0))&&s(c.get(n)),i&&s(c.get(Q3)),t){case"add":o?i&&s(c.get("length")):(s(c.get(m3)),n3(e)&&s(c.get(R5)));break;case"delete":o||(s(c.get(m3)),n3(e)&&s(c.get(R5)));break;case"set":n3(e)&&s(c.get(m3));break}}e6()}function y3(e){const t=h1(e);return t===e?t:(z1(t,"iterate",Q3),r2(e)?t:t.map(p2))}function q4(e){return z1(e=h1(e),"iterate",Q3),e}function _2(e,t){return W2(e)?A3(g3(e)?p2(t):t):p2(t)}const se={__proto__:null,[Symbol.iterator](){return u5(this,Symbol.iterator,e=>_2(this,e))},concat(...e){return y3(this).concat(...e.map(t=>Y(t)?y3(t):t))},entries(){return u5(this,"entries",e=>(e[1]=_2(this,e[1]),e))},every(e,t){return I2(this,"every",e,t,void 0,arguments)},filter(e,t){return I2(this,"filter",e,t,n=>n.map(a=>_2(this,a)),arguments)},find(e,t){return I2(this,"find",e,t,n=>_2(this,n),arguments)},findIndex(e,t){return I2(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return I2(this,"findLast",e,t,n=>_2(this,n),arguments)},findLastIndex(e,t){return I2(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return I2(this,"forEach",e,t,void 0,arguments)},includes(...e){return f5(this,"includes",e)},indexOf(...e){return f5(this,"indexOf",e)},join(e){return y3(this).join(e)},lastIndexOf(...e){return f5(this,"lastIndexOf",e)},map(e,t){return I2(this,"map",e,t,void 0,arguments)},pop(){return L3(this,"pop")},push(...e){return L3(this,"push",e)},reduce(e,...t){return S6(this,"reduce",e,t)},reduceRight(e,...t){return S6(this,"reduceRight",e,t)},shift(){return L3(this,"shift")},some(e,t){return I2(this,"some",e,t,void 0,arguments)},splice(...e){return L3(this,"splice",e)},toReversed(){return y3(this).toReversed()},toSorted(e){return y3(this).toSorted(e)},toSpliced(...e){return y3(this).toSpliced(...e)},unshift(...e){return L3(this,"unshift",e)},values(){return u5(this,"values",e=>_2(this,e))}};function u5(e,t,n){const a=q4(e),l=a[t]();return a!==e&&!r2(e)&&(l._next=l.next,l.next=()=>{const r=l._next();return r.done||(r.value=n(r.value)),r}),l}const ie=Array.prototype;function I2(e,t,n,a,l,r){const c=q4(e),s=c!==e&&!r2(e),o=c[t];if(o!==ie[t]){const f=o.apply(e,r);return s?p2(f):f}let i=n;c!==e&&(s?i=function(f,d){return n.call(this,_2(e,f),d,e)}:n.length>2&&(i=function(f,d){return n.call(this,f,d,e)}));const u=o.call(c,i,a);return s&&l?l(u):u}function S6(e,t,n,a){const l=q4(e),r=l!==e&&!r2(e);let c=n,s=!1;l!==e&&(r?(s=a.length===0,c=function(i,u,f){return s&&(s=!1,i=_2(e,i)),n.call(this,i,_2(e,u),f,e)}):n.length>3&&(c=function(i,u,f){return n.call(this,i,u,f,e)}));const o=l[t](c,...a);return s?_2(e,o):o}function f5(e,t,n){const a=h1(e);z1(a,"iterate",Q3);const l=a[t](...n);return(l===-1||l===!1)&&r6(n[0])?(n[0]=h1(n[0]),a[t](...n)):l}function L3(e,t,n=[]){U2(),Q5();const a=h1(e)[t].apply(e,n);return e6(),G2(),a}const ue=q5("__proto__,__v_isRef,__isVue"),r8=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(d2));function fe(e){d2(e)||(e=String(e));const t=h1(this);return z1(t,"has",e),t.hasOwnProperty(e)}class c8{constructor(t=!1,n=!1){this._isReadonly=t,this._isShallow=n}get(t,n,a){if(n==="__v_skip")return t.__v_skip;const l=this._isReadonly,r=this._isShallow;if(n==="__v_isReactive")return!l;if(n==="__v_isReadonly")return l;if(n==="__v_isShallow")return r;if(n==="__v_raw")return a===(l?r?Me:u8:r?i8:s8).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(a)?t:void 0;const c=Y(t);if(!l){let o;if(c&&(o=se[n]))return o;if(n==="hasOwnProperty")return fe}const s=Reflect.get(t,n,$1(t)?t:a);if((d2(n)?r8.has(n):ue(n))||(l||z1(t,"get",n),r))return s;if($1(s)){const o=c&&Y5(n)?s:s.value;return l&&b1(o)?O5(o):o}return b1(s)?l?O5(s):J4(s):s}}class o8 extends c8{constructor(t=!1){super(!1,t)}set(t,n,a,l){let r=t[n];const c=Y(t)&&Y5(n);if(!this._isShallow){const i=W2(r);if(!r2(a)&&!W2(a)&&(r=h1(r),a=h1(a)),!c&&$1(r)&&!$1(a))return i||(r.value=a),!0}const s=c?Number(n)e,g4=e=>Reflect.getPrototypeOf(e);function ge(e,t,n){return function(...a){const l=this.__v_raw,r=h1(l),c=n3(r),s=e==="entries"||e===Symbol.iterator&&c,o=e==="keys"&&c,i=l[e](...a),u=n?T5:t?A3:p2;return!t&&z1(r,"iterate",o?R5:m3),I1(Object.create(i),{next(){const{value:f,done:d}=i.next();return d?{value:f,done:d}:{value:s?[u(f[0]),u(f[1])]:u(f),done:d}}})}}function v4(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function ve(e,t){const n={get(l){const r=this.__v_raw,c=h1(r),s=h1(l);e||(k2(l,s)&&z1(c,"get",l),z1(c,"get",s));const{has:o}=g4(c),i=t?T5:e?A3:p2;if(o.call(c,l))return i(r.get(l));if(o.call(c,s))return i(r.get(s));r!==c&&r.get(l)},get size(){const l=this.__v_raw;return!e&&z1(h1(l),"iterate",m3),l.size},has(l){const r=this.__v_raw,c=h1(r),s=h1(l);return e||(k2(l,s)&&z1(c,"has",l),z1(c,"has",s)),l===s?r.has(l):r.has(l)||r.has(s)},forEach(l,r){const c=this,s=c.__v_raw,o=h1(s),i=t?T5:e?A3:p2;return!e&&z1(o,"iterate",m3),s.forEach((u,f)=>l.call(r,i(u),i(f),c))}};return I1(n,e?{add:v4("add"),set:v4("set"),delete:v4("delete"),clear:v4("clear")}:{add(l){const r=h1(this),c=g4(r),s=h1(l),o=!t&&!r2(l)&&!W2(l)?s:l;return c.has.call(r,o)||k2(l,o)&&c.has.call(r,l)||k2(s,o)&&c.has.call(r,s)||(r.add(o),j2(r,"add",o,o)),this},set(l,r){!t&&!r2(r)&&!W2(r)&&(r=h1(r));const c=h1(this),{has:s,get:o}=g4(c);let i=s.call(c,l);i||(l=h1(l),i=s.call(c,l));const u=o.call(c,l);return c.set(l,r),i?k2(r,u)&&j2(c,"set",l,r):j2(c,"add",l,r),this},delete(l){const r=h1(this),{has:c,get:s}=g4(r);let o=c.call(r,l);o||(l=h1(l),o=c.call(r,l)),s&&s.call(r,l);const i=r.delete(l);return o&&j2(r,"delete",l,void 0),i},clear(){const l=h1(this),r=l.size!==0,c=l.clear();return r&&j2(l,"clear",void 0,void 0),c}}),["keys","values","entries",Symbol.iterator].forEach(l=>{n[l]=ge(l,e,t)}),n}function a6(e,t){const n=ve(e,t);return(a,l,r)=>l==="__v_isReactive"?!e:l==="__v_isReadonly"?e:l==="__v_raw"?a:Reflect.get(v1(n,l)&&l in a?n:a,l,r)}const be={get:a6(!1,!1)},ye={get:a6(!1,!0)},xe={get:a6(!0,!1)};const s8=new WeakMap,i8=new WeakMap,u8=new WeakMap,Me=new WeakMap;function we(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function J4(e){return W2(e)?e:l6(e,!1,pe,be,s8)}function f8(e){return l6(e,!1,me,ye,i8)}function O5(e){return l6(e,!0,he,xe,u8)}function l6(e,t,n,a,l){if(!b1(e)||e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;const r=l.get(e);if(r)return r;const c=we(W0(e));if(c===0)return e;const s=new Proxy(e,c===2?a:n);return l.set(e,s),s}function g3(e){return W2(e)?g3(e.__v_raw):!!(e&&e.__v_isReactive)}function W2(e){return!!(e&&e.__v_isReadonly)}function r2(e){return!!(e&&e.__v_isShallow)}function r6(e){return e?!!e.__v_raw:!1}function h1(e){const t=e&&e.__v_raw;return t?h1(t):e}function _e(e){return!v1(e,"__v_skip")&&Object.isExtensible(e)&&W7(e,"__v_skip",!0),e}const p2=e=>b1(e)?J4(e):e,A3=e=>b1(e)?O5(e):e;function $1(e){return e?e.__v_isRef===!0:!1}function d1(e){return d8(e,!1)}function Ze(e){return d8(e,!0)}function d8(e,t){return $1(e)?e:new ke(e,t)}class ke{constructor(t,n){this.dep=new n6,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?t:h1(t),this._value=n?t:p2(t),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(t){const n=this._rawValue,a=this.__v_isShallow||r2(t)||W2(t);t=a?t:h1(t),k2(t,n)&&(this._rawValue=t,this._value=a?t:p2(t),this.dep.trigger())}}function I(e){return $1(e)?e.value:e}const Ce={get:(e,t,n)=>t==="__v_raw"?e:I(Reflect.get(e,t,n)),set:(e,t,n,a)=>{const l=e[t];return $1(l)&&!$1(n)?(l.value=n,!0):Reflect.set(e,t,n,a)}};function p8(e){return g3(e)?e:new Proxy(e,Ce)}class Ae{constructor(t,n,a){this.fn=t,this.setter=n,this._value=void 0,this.dep=new n6(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=X3-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=a}notify(){if(this.flags|=16,!(this.flags&8)&&C1!==this)return Q7(this,!0),!0}get value(){const t=this.dep.track();return n8(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}function Se(e,t,n=!1){let a,l;return n1(e)?a=e:(a=e.get,l=e.set),new Ae(a,l,n)}const b4={},R4=new WeakMap;let f3;function Ee(e,t=!1,n=f3){if(n){let a=R4.get(n);a||R4.set(n,a=[]),a.push(e)}}function Re(e,t,n=Z1){const{immediate:a,deep:l,once:r,scheduler:c,augmentJob:s,call:o}=n,i=_=>l?_:r2(_)||l===!1||l===0?F2(_,1):F2(_);let u,f,d,h,y=!1,x=!1;if($1(e)?(f=()=>e.value,y=r2(e)):g3(e)?(f=()=>i(e),y=!0):Y(e)?(x=!0,y=e.some(_=>g3(_)||r2(_)),f=()=>e.map(_=>{if($1(_))return _.value;if(g3(_))return i(_);if(n1(_))return o?o(_,2):_()})):n1(e)?t?f=o?()=>o(e,2):e:f=()=>{if(d){U2();try{d()}finally{G2()}}const _=f3;f3=u;try{return o?o(e,3,[h]):e(h)}finally{f3=_}}:f=S2,t&&l){const _=f,H=l===!0?1/0:l;f=()=>F2(_(),H)}const b=re(),M=()=>{u.stop(),b&&b.active&&J5(b.effects,u)};if(r&&t){const _=t;t=(...H)=>{const F=_(...H);return M(),F}}let g=x?new Array(e.length).fill(b4):b4;const C=_=>{if(!(!(u.flags&1)||!u.dirty&&!_))if(t){const H=u.run();if(_||l||y||(x?H.some((F,$)=>k2(F,g[$])):k2(H,g))){d&&d();const F=f3;f3=u;try{const $=[H,g===b4?void 0:x&&g[0]===b4?[]:g,h];g=H,o?o(t,3,$):t(...$)}finally{f3=F}}}else u.run()};return s&&s(C),u=new Y7(f),u.scheduler=c?()=>c(C,!1):C,h=_=>Ee(_,!1,u),d=u.onStop=()=>{const _=R4.get(u);if(_){if(o)o(_,4);else for(const H of _)H();R4.delete(u)}},t?a?C(!0):g=u.run():c?c(C.bind(null,!0),!0):u.run(),M.pause=u.pause.bind(u),M.resume=u.resume.bind(u),M.stop=M,M}function F2(e,t=1/0,n){if(t<=0||!b1(e)||e.__v_skip||(n=n||new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,$1(e))F2(e.value,t,n);else if(Y(e))for(let a=0;a{F2(a,t,n)});else if(G7(e)){for(const a in e)F2(e[a],t,n);for(const a of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,a)&&F2(e[a],t,n)}return e}/** +* @vue/runtime-core v3.5.42 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/function f4(e,t,n,a){try{return a?e(...a):e()}catch(l){Y4(l,t,n)}}function o2(e,t,n,a){if(n1(e)){const l=f4(e,t,n,a);return l&&B7(l)&&l.catch(r=>{Y4(r,t,n)}),l}if(Y(e)){const l=[];for(let r=0;r>>1,l=K1[a],r=e4(l);r=e4(n)?K1.push(e):K1.splice(Oe(t),0,e),e.flags|=1,m8()}}function m8(){T4||(T4=h8.then(v8))}function Pe(e){if(!Y(e))Q2&&e.id===-1?Q2.splice(x3+1,0,e):e.flags&1||(_3.push(e),e.flags|=1);else for(let t=0;te4(n)-e4(a));if(_3.length=0,Q2){for(let n=0;ne.id==null?e.flags&2?-1:1/0:e.id;function v8(e){try{for(w2=0;w2{a._d&&$4(-1);const r=O4(t),c=z2.length;let s;try{s=e(...l)}finally{for(let o=z2.length;o>c;o--)d6();O4(r),a._d&&$4(1)}return s};return a._n=!0,a._c=!0,a._d=!0,a}function i2(e,t){if(F1===null)return e;const n=l5(F1),a=e.dirs||(e.dirs=[]);for(let l=0;l1)return n&&n1(t)?t.call(a&&a.proxy):t}}const Ie=Symbol.for("v-scx"),Le=()=>E2(Ie);function R2(e,t,n){return y8(e,t,n)}function y8(e,t,n=Z1){const{immediate:a,deep:l,flush:r,once:c}=n,s=I1({},n),o=t&&a||!t&&r!=="post";let i;if(r4){if(r==="sync"){const h=Le();i=h.__watcherHandles||(h.__watcherHandles=[])}else if(!o){const h=()=>{};return h.stop=S2,h.resume=S2,h.pause=S2,h}}const u=B1;s.call=(h,y,x)=>o2(h,u,y,x);let f=!1;r==="post"?s.scheduler=h=>{G1(h,u&&u.suspense)}:r!=="sync"&&(f=!0,s.scheduler=(h,y)=>{y?h():o6(h)}),s.augmentJob=h=>{t&&(h.flags|=4),f&&(h.flags|=2,u&&(h.id=u.uid,h.i=u))};const d=Re(e,t,s);return r4&&(i?i.push(d):o&&d()),d}function $e(e,t,n){const a=this.proxy,l=A1(e)?e.includes(".")?x8(a,e):()=>a[e]:e.bind(a,a);let r;n1(t)?r=t:(r=t.handler,n=t);const c=p4(this),s=y8(l,r.bind(a),n);return c(),s}function x8(e,t){const n=t.split(".");return()=>{let a=e;for(let l=0;le.__isTeleport,d3=e=>e&&(e.disabled||e.disabled===""),Ne=e=>e&&(e.defer||e.defer===""),R6=e=>typeof SVGElement<"u"&&e instanceof SVGElement,T6=e=>typeof MathMLElement=="function"&&e instanceof MathMLElement,P5=(e,t)=>{const n=e&&e.to;return A1(n)?t?t(n):null:n},Ve={name:"Teleport",__isTeleport:!0,process(e,t,n,a,l,r,c,s,o,i){const{mc:u,pc:f,pbc:d,o:{insert:h,querySelector:y,createText:x,createComment:b,parentNode:M}}=i,g=d3(t.props);let{dynamicChildren:C}=t;const _=($,R,N)=>{$.shapeFlag&16&&u($.children,R,N,l,r,c,s,o)},H=($=t)=>{const R=d3($.props),N=$.target=P5($.props,y),t1=I5(N,$,x,h);N&&(c!=="svg"&&R6(N)?c="svg":c!=="mathml"&&T6(N)&&(c="mathml"),l&&l.isCE&&(l.ce._teleportTargets||(l.ce._teleportTargets=new Set)).add(N),R||(_($,N,t1),H3($,!1)))},F=$=>{const R=()=>{if(X2.get($)===R){if(X2.delete($),d3($.props)){const N=M($.el)||n;_($,N,$.anchor),H3($,!0)}H($)}};X2.set($,R),G1(R,r)};if(e==null){const $=t.el=x(""),R=t.anchor=x("");if(h($,n,a),h(R,n,a),Ne(t.props)||r&&r.pendingBranch){F(t);return}g&&(_(t,n,R),H3(t,!0)),H()}else{t.el=e.el;const $=t.anchor=e.anchor,R=X2.get(e);if(R){R.flags|=8,X2.delete(e),F(t);return}t.targetStart=e.targetStart;const N=t.target=e.target,t1=t.targetAnchor=e.targetAnchor,s1=d3(e.props),D=s1?n:N,o1=s1?$:t1;if(c==="svg"||R6(N)?c="svg":(c==="mathml"||T6(N))&&(c="mathml"),C?(d(e.dynamicChildren,C,D,l,r,c,s),f6(e,t,!0)):o||f(e,t,D,o1,l,r,c,s,!1),g)s1?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):y4(t,n,$,i,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){const k1=P5(t.props,y);k1&&(t.target=k1,y4(t,k1,null,i,0))}else s1&&y4(t,N,t1,i,1);H3(t,g)}},remove(e,t,n,{um:a,o:{remove:l}},r){const{shapeFlag:c,children:s,anchor:o,targetStart:i,targetAnchor:u,target:f,props:d}=e,h=d3(d),y=r||!h,x=X2.get(e);if(x&&(x.flags|=8,X2.delete(e)),f&&(l(i),l(u)),r&&l(o),!x&&(h||f)&&c&16)for(let b=0;b{e.isMounted=!0}),s6(()=>{e.isUnmounting=!0}),e}const a2=[Function,Array],w8={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:a2,onEnter:a2,onAfterEnter:a2,onEnterCancelled:a2,onBeforeLeave:a2,onLeave:a2,onAfterLeave:a2,onLeaveCancelled:a2,onBeforeAppear:a2,onAppear:a2,onAfterAppear:a2,onAppearCancelled:a2},_8=e=>{const t=e.subTree;return t.component?_8(t.component):t},ze={name:"BaseTransition",props:w8,setup(e,{slots:t}){const n=Y8(),a=Fe();return()=>{const l=t.default&&C8(t.default(),!0),r=l&&l.length?Z8(l):n.subTree?w1():void 0;if(!r)return;const c=h1(e),{mode:s}=c;if(a.isLeaving)return d5(r);const o=P4(r);if(!o)return d5(r);let i=L5(o,c,a,n,f=>i=f);o.type!==H1&&t4(o,i);let u=n.subTree&&P4(n.subTree);if(u&&u.type!==H1&&!p3(u,o)&&_8(n).type!==H1){let f=L5(u,c,a,n);if(t4(u,f),s==="out-in"&&o.type!==H1)return a.isLeaving=!0,f.afterLeave=()=>{a.isLeaving=!1,n.job.flags&8||n.update(),delete f.afterLeave,u=void 0},d5(r);s==="in-out"&&o.type!==H1?f.delayLeave=(d,h,y)=>{const x=k8(a,u);x[String(u.key)]=u,d[l2]=()=>{h(),d[l2]=void 0,delete i.delayedLeave,u=void 0},i.delayedLeave=()=>{y(),delete i.delayedLeave,u=void 0}}:u=void 0}else u&&(u=void 0);return r}}};function Z8(e){let t=e[0];if(e.length>1){for(const n of e)if(n.type!==H1){t=n;break}}return t}const He=ze;function k8(e,t){const{leavingVNodes:n}=e;let a=n.get(t.type);return a||(a=Object.create(null),n.set(t.type,a)),a}function L5(e,t,n,a,l){const{appear:r,mode:c,persisted:s=!1,onBeforeEnter:o,onEnter:i,onAfterEnter:u,onEnterCancelled:f,onBeforeLeave:d,onLeave:h,onAfterLeave:y,onLeaveCancelled:x,onBeforeAppear:b,onAppear:M,onAfterAppear:g,onAppearCancelled:C}=t,_=String(e.key),H=k8(n,e),F=(N,t1)=>{N&&o2(N,a,9,t1)},$=(N,t1)=>{const s1=t1[1];F(N,t1),Y(N)?N.every(D=>D.length<=1)&&s1():N.length<=1&&s1()},R={mode:c,persisted:s,beforeEnter(N){let t1=o;if(!n.isMounted)if(r)t1=b||o;else return;N[l2]&&N[l2](!0);const s1=H[_];s1&&p3(e,s1)&&s1.el[l2]&&s1.el[l2](),F(t1,[N])},enter(N){if(H[_]===e)return;let t1=i,s1=u,D=f;if(!n.isMounted)if(r)t1=M||i,s1=g||u,D=C||f;else return;let o1=!1;N[$3]=R1=>{o1||(o1=!0,R1?F(D,[N]):F(s1,[N]),R.delayedLeave&&R.delayedLeave(),N[$3]=void 0)};const k1=N[$3].bind(null,!1);t1?$(t1,[N,k1]):k1()},leave(N,t1){const s1=String(e.key);if(N[$3]&&N[$3](!0),n.isUnmounting)return t1();F(d,[N]);let D=!1;N[l2]=k1=>{D||(D=!0,t1(),k1?F(x,[N]):F(y,[N]),N[l2]=void 0,H[s1]===e&&delete H[s1])};const o1=N[l2].bind(null,!1);H[s1]=e,h?$(h,[N,o1]):o1()},clone(N){const t1=L5(N,t,n,a,l);return l&&l(t1),t1}};return R}function d5(e){if(Q4(e))return e=a3(e),e.children=null,e}function P4(e){if(!Q4(e))return X4(e.type)&&e.children?Z8(e.children):e;if(e.component)return e.component.subTree;const{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&n1(n.default))return n.default()}}function t4(e,t){if(e.shapeFlag&6&&e.component){e.transition=t;const n=e.component.subTree;t4(X4(n.type)&&P4(n)||n,t)}else e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function C8(e,t=!1,n){let a=[],l=0;for(let r=0;r1)for(let r=0;rq3(x,t&&(Y(t)?t[b]:t),n,a,l));return}if(Z3(a)&&!l){a.shapeFlag&512&&a.type.__asyncResolved&&a.component.subTree.component&&q3(e,t,n,a.component.subTree);return}const r=a.shapeFlag&4?l5(a.component):a.el,c=l?null:r,{i:s,r:o}=e,i=t&&t.r,u=s.refs===Z1?s.refs={}:s.refs,f=s.setupState,d=h1(f),h=f===Z1?H7:x=>O6(u,x)?!1:v1(d,x),y=(x,b)=>!(b&&O6(u,b));if(i!=null&&i!==o){if(P6(t),A1(i))u[i]=null,h(i)&&(f[i]=null);else if($1(i)){const x=t;y(i,x.k)&&(i.value=null),x.k&&(u[x.k]=null)}}if(n1(o))f4(o,s,12,[c,u]);else{const x=A1(o),b=$1(o);if(x||b){const M=()=>{if(e.f){const g=x?h(o)?f[o]:u[o]:y()||!e.k?o.value:u[e.k];if(l)Y(g)&&J5(g,r);else if(Y(g))g.includes(r)||g.push(r);else if(x)u[o]=[r],h(o)&&(f[o]=u[o]);else{const C=[r];y(o,e.k)&&(o.value=C),e.k&&(u[e.k]=C)}}else x?(u[o]=c,h(o)&&(f[o]=c)):b&&(y(o,e.k)&&(o.value=c),e.k&&(u[e.k]=c))};if(c){const g=()=>{M(),I4.delete(e)};g.id=-1,I4.set(e,g),G1(g,n)}else P6(e),M()}}}function P6(e){const t=I4.get(e);t&&(t.flags|=8,I4.delete(e))}W4().requestIdleCallback;W4().cancelIdleCallback;const Z3=e=>!!e.type.__asyncLoader,Q4=e=>e.type.__isKeepAlive;function Be(e,t){S8(e,"a",t)}function Ue(e,t){S8(e,"da",t)}function S8(e,t,n=B1){const a=e.__wdc||(e.__wdc=()=>{let l=n;for(;l;){if(l.isDeactivated)return;l=l.parent}return e()});if(e5(t,a,n),n){let l=n.parent;for(;l&&l.parent;)Q4(l.parent.vnode)&&Ge(a,t,n,l),l=l.parent}}function Ge(e,t,n,a){const l=e5(t,e,a,!0);t5(()=>{J5(a[t],l)},n)}function e5(e,t,n=B1,a=!1){if(n){const l=n[e]||(n[e]=[]),r=t.__weh||(t.__weh=(...c)=>{U2();const s=p4(n),o=o2(t,n,e,c);return s(),G2(),o});return a?l.unshift(r):l.push(r),r}}const K2=e=>(t,n=B1)=>{(!r4||e==="sp")&&e5(e,(...a)=>t(...a),n)},We=K2("bm"),O2=K2("m"),Ke=K2("bu"),qe=K2("u"),s6=K2("bum"),t5=K2("um"),Je=K2("sp"),Ye=K2("rtg"),Xe=K2("rtc");function Qe(e,t=B1){e5("ec",e,t)}const E8="components";function I6(e,t){return T8(E8,e,!0,t)||e}const R8=Symbol.for("v-ndc");function k3(e){return A1(e)?T8(E8,e,!1)||e:e||R8}function T8(e,t,n=!0,a=!1){const l=F1||B1;if(l){const r=l.type;{const s=N9(r,!1);if(s&&(s===t||s===J1(t)||s===U4(J1(t))))return r}const c=L6(l[e]||r[e],t)||L6(l.appContext[e],t);return!c&&a?r:c}}function L6(e,t){return e&&(e[t]||e[J1(t)]||e[U4(J1(t))])}function c2(e,t,n,a){let l;const r=n,c=Y(e);if(c||A1(e)){const s=c&&g3(e);let o=!1,i=!1;s&&(o=!r2(e),i=W2(e),e=q4(e)),l=new Array(e.length);for(let u=0,f=e.length;ut(s,o,void 0,r));else{const s=Object.keys(e);l=new Array(s.length);for(let o=0,i=s.length;o0;return t!=="default"&&(i.name=t),T(),m1(y1,null,[j("slot",i,a)],u?-2:64)}let c=e[t];c&&c._c&&(c._d=!1);const s=z2.length;T();let o;try{const i=c&&O8(c(n)),u=n.key||r||i&&i.key;o=m1(y1,{key:(u&&!d2(u)?u:`_${t}`)+(!i&&a?"_fb":"")},i||(a?a():[]),i&&e._===1?64:-2)}catch(i){for(let u=z2.length;u>s;u--)d6();throw i}finally{c&&c._c&&(c._d=!0)}return o.scopeId&&(o.slotScopeIds=[o.scopeId+"-s"]),o}function O8(e){return e.some(t=>a4(t)?!(t.type===H1||t.type===y1&&!O8(t.children)):!0)?e:null}const $5=e=>e?X8(e)?l5(e):$5(e.parent):null,J3=I1(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>$5(e.parent),$root:e=>$5(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>I8(e),$forceUpdate:e=>e.f||(e.f=()=>{o6(e.update)}),$nextTick:e=>e.n||(e.n=c6.bind(e.proxy)),$watch:e=>$e.bind(e)}),p5=(e,t)=>e!==Z1&&!e.__isScriptSetup&&v1(e,t),e9={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:n,setupState:a,data:l,props:r,accessCache:c,type:s,appContext:o}=e;if(t[0]!=="$"){const d=c[t];if(d!==void 0)switch(d){case 1:return a[t];case 2:return l[t];case 4:return n[t];case 3:return r[t]}else{if(p5(a,t))return c[t]=1,a[t];if(l!==Z1&&v1(l,t))return c[t]=2,l[t];if(v1(r,t))return c[t]=3,r[t];if(n!==Z1&&v1(n,t))return c[t]=4,n[t];N5&&(c[t]=0)}}const i=J3[t];let u,f;if(i)return t==="$attrs"&&z1(e.attrs,"get",""),i(e);if((u=s.__cssModules)&&(u=u[t]))return u;if(n!==Z1&&v1(n,t))return c[t]=4,n[t];if(f=o.config.globalProperties,v1(f,t))return f[t]},set({_:e},t,n){const{data:a,setupState:l,ctx:r}=e;return p5(l,t)?(l[t]=n,!0):a!==Z1&&v1(a,t)?(a[t]=n,!0):v1(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(r[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:a,appContext:l,props:r,type:c}},s){let o;return!!(n[s]||e!==Z1&&s[0]!=="$"&&v1(e,s)||p5(t,s)||v1(r,s)||v1(a,s)||v1(J3,s)||v1(l.config.globalProperties,s)||(o=c.__cssModules)&&o[s])},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:v1(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};function $6(e){return Y(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}let N5=!0;function t9(e){const t=I8(e),n=e.proxy,a=e.ctx;N5=!1,t.beforeCreate&&N6(t.beforeCreate,e,"bc");const{data:l,computed:r,methods:c,watch:s,provide:o,inject:i,created:u,beforeMount:f,mounted:d,beforeUpdate:h,updated:y,activated:x,deactivated:b,beforeDestroy:M,beforeUnmount:g,destroyed:C,unmounted:_,render:H,renderTracked:F,renderTriggered:$,errorCaptured:R,serverPrefetch:N,expose:t1,inheritAttrs:s1,components:D,directives:o1,filters:k1}=t;if(i&&n9(i,a,null),c)for(const c1 in c){const i1=c[c1];n1(i1)&&(a[c1]=i1.bind(n))}if(l){const c1=l.call(n,n);b1(c1)&&(e.data=J4(c1))}if(N5=!0,r)for(const c1 in r){const i1=r[c1],Q1=n1(i1)?i1.bind(n,n):n1(i1.get)?i1.get.bind(n,n):S2,K=!n1(i1)&&n1(i1.set)?i1.set.bind(n):S2,e2=j1({get:Q1,set:K});Object.defineProperty(a,c1,{enumerable:!0,configurable:!0,get:()=>e2.value,set:N1=>e2.value=N1})}if(s)for(const c1 in s)P8(s[c1],a,n,c1);if(o){const c1=n1(o)?o.call(n):o;Reflect.ownKeys(c1).forEach(i1=>{C4(i1,c1[i1])})}u&&N6(u,e,"c");function u1(c1,i1){Y(i1)?i1.forEach(Q1=>c1(Q1.bind(n))):i1&&c1(i1.bind(n))}if(u1(We,f),u1(O2,d),u1(Ke,h),u1(qe,y),u1(Be,x),u1(Ue,b),u1(Qe,R),u1(Xe,F),u1(Ye,$),u1(s6,g),u1(t5,_),u1(Je,N),Y(t1))if(t1.length){const c1=e.exposed||(e.exposed={});t1.forEach(i1=>{Object.defineProperty(c1,i1,{get:()=>n[i1],set:Q1=>n[i1]=Q1,enumerable:!0})})}else e.exposed||(e.exposed={});H&&e.render===S2&&(e.render=H),s1!=null&&(e.inheritAttrs=s1),D&&(e.components=D),o1&&(e.directives=o1),N&&A8(e)}function n9(e,t,n=S2){Y(e)&&(e=V5(e));for(const a in e){const l=e[a];let r;b1(l)?"default"in l?r=E2(l.from||a,l.default,!0):r=E2(l.from||a):r=E2(l),$1(r)?Object.defineProperty(t,a,{enumerable:!0,configurable:!0,get:()=>r.value,set:c=>r.value=c}):t[a]=r}}function N6(e,t,n){o2(Y(e)?e.map(a=>a.bind(t.proxy)):e.bind(t.proxy),t,n)}function P8(e,t,n,a){let l=a.includes(".")?x8(n,a):()=>n[a];if(A1(e)){const r=t[e];n1(r)&&R2(l,r)}else if(n1(e))R2(l,e.bind(n));else if(b1(e))if(Y(e))e.forEach(r=>P8(r,t,n,a));else{const r=n1(e.handler)?e.handler.bind(n):t[e.handler];n1(r)&&R2(l,r,e)}}function I8(e){const t=e.type,{mixins:n,extends:a}=t,{mixins:l,optionsCache:r,config:{optionMergeStrategies:c}}=e.appContext,s=r.get(t);let o;return s?o=s:!l.length&&!n&&!a?o=t:(o={},l.length&&l.forEach(i=>L4(o,i,c,!0)),L4(o,t,c)),b1(t)&&r.set(t,o),o}function L4(e,t,n,a=!1){const{mixins:l,extends:r}=t;r&&L4(e,r,n,!0),l&&l.forEach(c=>L4(e,c,n,!0));for(const c in t)if(!(a&&c==="expose")){const s=a9[c]||n&&n[c];e[c]=s?s(e[c],t[c]):t[c]}return e}const a9={data:V6,props:D6,emits:D6,methods:B3,computed:B3,beforeCreate:U1,created:U1,beforeMount:U1,mounted:U1,beforeUpdate:U1,updated:U1,beforeDestroy:U1,beforeUnmount:U1,destroyed:U1,unmounted:U1,activated:U1,deactivated:U1,errorCaptured:U1,serverPrefetch:U1,components:B3,directives:B3,watch:r9,provide:V6,inject:l9};function V6(e,t){return t?e?function(){return I1(n1(e)?e.call(this,this):e,n1(t)?t.call(this,this):t)}:t:e}function l9(e,t){return B3(V5(e),V5(t))}function V5(e){if(Y(e)){const t={};for(let n=0;nt==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${J1(t)}Modifiers`]||e[`${v3(t)}Modifiers`];function i9(e,t,...n){if(e.isUnmounted)return;const a=e.vnode.props||Z1;let l=n;const r=t.startsWith("update:"),c=r&&s9(a,t.slice(7));c&&(c.trim&&(l=n.map(u=>A1(u)?u.trim():u)),c.number&&(l=l.map(G4)));let s,o=a[s=o5(t)]||a[s=o5(J1(t))];!o&&r&&(o=a[s=o5(v3(t))]),o&&o2(o,e,6,l);const i=a[s+"Once"];if(i){if(!e.emitted)e.emitted={};else if(e.emitted[s])return;e.emitted[s]=!0,o2(i,e,6,l)}}const u9=new WeakMap;function $8(e,t,n=!1){const a=n?u9:t.emitsCache,l=a.get(e);if(l!==void 0)return l;const r=e.emits;let c={},s=!1;if(!n1(e)){const o=i=>{const u=$8(i,t,!0);u&&(s=!0,I1(c,u))};!n&&t.mixins.length&&t.mixins.forEach(o),e.extends&&o(e.extends),e.mixins&&e.mixins.forEach(o)}return!r&&!s?(b1(e)&&a.set(e,null),null):(Y(r)?r.forEach(o=>c[o]=null):I1(c,r),b1(e)&&a.set(e,c),c)}function n5(e,t){return!e||!z4(t)?!1:(t=t.slice(2),t=t==="Once"?t:t.replace(/Once$/,""),v1(e,t[0].toLowerCase()+t.slice(1))||v1(e,v3(t))||v1(e,t))}function j6(e){const{type:t,vnode:n,proxy:a,withProxy:l,propsOptions:[r],slots:c,attrs:s,emit:o,render:i,renderCache:u,props:f,data:d,setupState:h,ctx:y,inheritAttrs:x}=e,b=O4(e);let M,g;try{if(n.shapeFlag&4){const _=l||a,H=_;M=Z2(i.call(H,_,u,f,h,d,y)),g=s}else{const _=t;M=Z2(_.length>1?_(f,{attrs:s,slots:c,emit:o}):_(f,null)),g=t.props?s:f9(s)}}catch(_){z2.length=0,Y4(_,e,1),M=j(H1)}let C=M;if(g&&x!==!1){const _=Object.keys(g),{shapeFlag:H}=C;_.length&&H&7&&(r&&_.some(H4)&&(g=d9(g,r)),C=a3(C,g,!1,!0))}if(n.dirs&&(C=a3(C,null,!1,!0),C.dirs=C.dirs?C.dirs.concat(n.dirs):n.dirs),n.transition){const _=X4(C.type)&&P4(C)||C;t4(_,n.transition)}return M=C,O4(b),M}const f9=e=>{let t;for(const n in e)(n==="class"||n==="style"||z4(n))&&((t||(t={}))[n]=e[n]);return t},d9=(e,t)=>{const n={};for(const a in e)(!H4(a)||!(a.slice(9)in t))&&(n[a]=e[a]);return n};function p9(e,t,n){const{props:a,children:l,component:r}=e,{props:c,children:s,patchFlag:o}=t,i=r.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&o>=0){if(o&1024)return!0;if(o&16)return a?F6(a,c,i):!!c;if(o&8){const u=t.dynamicProps;for(let f=0;fObject.create(V8),j8=e=>Object.getPrototypeOf(e)===V8;function m9(e,t,n,a=!1){const l={},r=D8();e.propsDefaults=Object.create(null),F8(e,t,l,r);for(const c in e.propsOptions[0])c in l||(l[c]=void 0);n?e.props=a?l:f8(l):e.type.props?e.props=l:e.props=r,e.attrs=r}function g9(e,t,n,a){const{props:l,attrs:r,vnode:{patchFlag:c}}=e,s=h1(l),[o]=e.propsOptions;let i=!1;if((a||c>0)&&!(c&16)){if(c&8){const u=e.vnode.dynamicProps;for(let f=0;f{o=!0;const[d,h]=z8(f,t,!0);I1(c,d),h&&s.push(...h)};!n&&t.mixins.length&&t.mixins.forEach(u),e.extends&&u(e.extends),e.mixins&&e.mixins.forEach(u)}if(!r&&!o)return b1(e)&&a.set(e,w3),w3;if(Y(r))for(let u=0;ue==="_"||e==="_ctx"||e==="$stable",u6=e=>Y(e)?e.map(Z2):[Z2(e)],b9=(e,t,n)=>{if(t._n)return t;const a=a1((...l)=>u6(t(...l)),n);return a._c=!1,a},H8=(e,t,n)=>{const a=e._ctx;for(const l in e){if(i6(l))continue;const r=e[l];if(n1(r))t[l]=b9(l,r,a);else if(r!=null){const c=u6(r);t[l]=()=>c}}},B8=(e,t)=>{const n=u6(t);e.slots.default=()=>n},U8=(e,t,n)=>{for(const a in t)(n||!i6(a))&&(e[a]=t[a])},y9=(e,t,n)=>{const a=e.slots=D8();if(e.vnode.shapeFlag&32){const l=t._;l?(U8(a,t,n),n&&W7(a,"_",l,!0)):H8(t,a)}else t&&B8(e,t)},x9=(e,t,n)=>{const{vnode:a,slots:l}=e;let r=!0,c=Z1;if(a.shapeFlag&32){const s=t._;s?n&&s===1?r=!1:U8(l,t,n):(r=!t.$stable,H8(t,l)),c=t}else t&&(B8(e,t),c={default:1});if(r)for(const s in l)!i6(s)&&c[s]==null&&delete l[s]},G1=k9;function M9(e){return w9(e)}function w9(e,t){const n=W4();n.__VUE__=!0;const{insert:a,remove:l,patchProp:r,createElement:c,createText:s,createComment:o,setText:i,setElementText:u,parentNode:f,nextSibling:d,setScopeId:h=S2,insertStaticContent:y}=e,x=(p,m,v,A=null,S=null,Z=null,V=void 0,L=null,P=!!m.dynamicChildren)=>{if(p===m)return;p&&!p3(p,m)&&(A=k(p),N1(p,S,Z,!0),p=null),m.patchFlag===-2&&(P=!1,m.dynamicChildren=null);const{type:E,ref:Q,shapeFlag:z}=m;switch(E){case a5:b(p,m,v,A);break;case H1:M(p,m,v,A);break;case A4:p==null&&g(m,v,A,V);break;case y1:D(p,m,v,A,S,Z,V,L,P);break;default:z&1?H(p,m,v,A,S,Z,V,L,P):z&6?o1(p,m,v,A,S,Z,V,L,P):(z&64||z&128)&&E.process(p,m,v,A,S,Z,V,L,P,q)}Q!=null&&S?q3(Q,p&&p.ref,Z,m||p,!m):Q==null&&p&&p.ref!=null&&q3(p.ref,null,Z,p,!0)},b=(p,m,v,A)=>{if(p==null)a(m.el=s(m.children),v,A);else{const S=m.el=p.el;m.children!==p.children&&i(S,m.children)}},M=(p,m,v,A)=>{p==null?a(m.el=o(m.children||""),v,A):m.el=p.el},g=(p,m,v,A)=>{[p.el,p.anchor]=y(p.children,m,v,A,p.el,p.anchor)},C=({el:p,anchor:m},v,A)=>{let S;for(;p&&p!==m;)S=d(p),a(p,v,A),p=S;a(m,v,A)},_=({el:p,anchor:m})=>{let v;for(;p&&p!==m;)v=d(p),l(p),p=v;l(m)},H=(p,m,v,A,S,Z,V,L,P)=>{if(m.type==="svg"?V="svg":m.type==="math"&&(V="mathml"),p==null)F(m,v,A,S,Z,V,L,P);else{const E=p.el&&p.el._isVueCE?p.el:null;try{E&&E._beginPatch(),N(p,m,S,Z,V,L,P)}finally{E&&E._endPatch()}}},F=(p,m,v,A,S,Z,V,L)=>{let P,E;const{props:Q,shapeFlag:z,transition:X,dirs:e1}=p;if(P=p.el=c(p.type,Z,Q&&Q.is,Q),z&8?u(P,p.children):z&16&&R(p.children,P,null,A,S,h5(p,Z),V,L),e1&&c3(p,null,A,"created"),$(P,p,p.scopeId,V,A),Q){for(const _1 in Q)_1!=="value"&&!G3(_1)&&r(P,_1,null,Q[_1],Z,A);"value"in Q&&r(P,"value",null,Q.value,Z),(E=Q.onVnodeBeforeMount)&&y2(E,A,p)}e1&&c3(p,null,A,"beforeMount");const f1=_9(S,X);f1&&X.beforeEnter(P),a(P,m,v),((E=Q&&Q.onVnodeMounted)||f1||e1)&&G1(()=>{try{E&&y2(E,A,p),f1&&X.enter(P),e1&&c3(p,null,A,"mounted")}finally{}},S)},$=(p,m,v,A,S)=>{if(v&&h(p,v),A)for(let Z=0;Z{for(let E=P;E{const L=m.el=p.el;let{patchFlag:P,dynamicChildren:E,dirs:Q}=m;P|=p.patchFlag&16;const z=p.props||Z1,X=m.props||Z1;let e1;if(v&&o3(v,!1),(e1=X.onVnodeBeforeUpdate)&&y2(e1,v,m,p),Q&&c3(m,p,v,"beforeUpdate"),v&&o3(v,!0),E&&(!p.dynamicChildren||p.dynamicChildren.length!==E.length)&&(P=0,V=!1,E=null),(z.innerHTML&&X.innerHTML==null||z.textContent&&X.textContent==null)&&u(L,""),E?t1(p.dynamicChildren,E,L,v,A,h5(m,S),Z):V||i1(p,m,L,null,v,A,h5(m,S),Z,!1),P>0){if(P&16)s1(L,z,X,v,S);else if(P&2&&z.class!==X.class&&r(L,"class",null,X.class,S),P&4&&r(L,"style",z.style,X.style,S),P&8){const f1=m.dynamicProps;for(let _1=0;_1{e1&&y2(e1,v,m,p),Q&&c3(m,p,v,"updated")},A)},t1=(p,m,v,A,S,Z,V)=>{for(let L=0;L{if(m!==v){if(m!==Z1)for(const Z in m)!G3(Z)&&!(Z in v)&&r(p,Z,m[Z],null,S,A);for(const Z in v){if(G3(Z))continue;const V=v[Z],L=m[Z];V!==L&&Z!=="value"&&r(p,Z,L,V,S,A)}"value"in v&&r(p,"value",m.value,v.value,S)}},D=(p,m,v,A,S,Z,V,L,P)=>{const E=m.el=p?p.el:s(""),Q=m.anchor=p?p.anchor:s("");let{patchFlag:z,dynamicChildren:X,slotScopeIds:e1}=m;e1&&(L=L?L.concat(e1):e1),p==null?(a(E,v,A),a(Q,v,A),R(m.children||[],v,Q,S,Z,V,L,P)):z>0&&z&64&&X&&p.dynamicChildren&&p.dynamicChildren.length===X.length?(t1(p.dynamicChildren,X,v,S,Z,V,L),(m.key!=null||S&&m===S.subTree)&&f6(p,m,!0)):i1(p,m,v,Q,S,Z,V,L,P)},o1=(p,m,v,A,S,Z,V,L,P)=>{m.slotScopeIds=L,p==null?m.shapeFlag&512?S.ctx.activate(m,v,A,V,P):k1(m,v,A,S,Z,V,P):R1(p,m,P)},k1=(p,m,v,A,S,Z,V)=>{const L=p.component=O9(p,A,S);if(Q4(p)&&(L.ctx.renderer=q),P9(L,!1,V),L.asyncDep){if(S&&S.registerDep(L,u1,V),!p.el){const P=L.subTree=j(H1);M(null,P,m,v),p.placeholder=P.el}}else u1(L,p,m,v,S,Z,V)},R1=(p,m,v)=>{const A=m.component=p.component;if(p9(p,m,v))if(A.asyncDep&&!A.asyncResolved){c1(A,m,v);return}else A.next=m,A.update();else m.el=p.el,A.vnode=m},u1=(p,m,v,A,S,Z,V)=>{const L=()=>{if(p.isMounted){let{next:z,bu:X,u:e1,parent:f1,vnode:_1}=p;{const v2=G8(p);if(v2){z&&(z.el=_1.el,c1(p,z,V)),v2.asyncDep.then(()=>{G1(()=>{p.isUnmounted||E()},S)});return}}let M1=z,T1;o3(p,!1),z?(z.el=_1.el,c1(p,z,V)):z=_1,X&&k4(X),(T1=z.props&&z.props.onVnodeBeforeUpdate)&&y2(T1,f1,z,_1),o3(p,!0);const V1=j6(p),g2=p.subTree;p.subTree=V1,x(g2,V1,f(g2.el),k(g2),p,S,Z),z.el=V1.el,M1===null&&h9(p,V1.el),e1&&G1(e1,S),(T1=z.props&&z.props.onVnodeUpdated)&&G1(()=>y2(T1,f1,z,_1),S)}else{let z;const{el:X,props:e1}=m,{bm:f1,m:_1,parent:M1,root:T1,type:V1}=p,g2=Z3(m);o3(p,!1),f1&&k4(f1),!g2&&(z=e1&&e1.onVnodeBeforeMount)&&y2(z,M1,m),o3(p,!0);{T1.ce&&T1.ce._hasShadowRoot()&&T1.ce._injectChildStyle(V1,p.parent?p.parent.type:void 0);const v2=p.subTree=j6(p);x(null,v2,v,A,p,S,Z),m.el=v2.el}if(_1&&G1(_1,S),!g2&&(z=e1&&e1.onVnodeMounted)){const v2=m;G1(()=>y2(z,M1,v2),S)}(m.shapeFlag&256||M1&&Z3(M1.vnode)&&M1.vnode.shapeFlag&256)&&p.a&&G1(p.a,S),p.isMounted=!0,m=v=A=null}};p.scope.on();const P=p.effect=new Y7(L);p.scope.off();const E=p.update=P.run.bind(P),Q=p.job=P.runIfDirty.bind(P);Q.i=p,Q.id=p.uid,P.scheduler=()=>o6(Q),o3(p,!0),E()},c1=(p,m,v)=>{m.component=p;const A=p.vnode.props;p.vnode=m,p.next=null,g9(p,m.props,A,v),x9(p,m.children,v),U2(),E6(p),G2()},i1=(p,m,v,A,S,Z,V,L,P=!1)=>{const E=p&&p.children,Q=p?p.shapeFlag:0,z=m.children,{patchFlag:X,shapeFlag:e1}=m;if(X>0){if(X&128){K(E,z,v,A,S,Z,V,L,P);return}else if(X&256){Q1(E,z,v,A,S,Z,V,L,P);return}}e1&8?(Q&16&&x1(E,S,Z),z!==E&&u(v,z)):Q&16?e1&16?K(E,z,v,A,S,Z,V,L,P):x1(E,S,Z,!0):(Q&8&&u(v,""),e1&16&&R(z,v,A,S,Z,V,L,P))},Q1=(p,m,v,A,S,Z,V,L,P)=>{p=p||w3,m=m||w3;const E=p.length,Q=m.length,z=Math.min(E,Q);let X;for(X=0;XQ?x1(p,S,Z,!0,!1,z):R(m,v,A,S,Z,V,L,P,z)},K=(p,m,v,A,S,Z,V,L,P)=>{let E=0;const Q=m.length;let z=p.length-1,X=Q-1;for(;E<=z&&E<=X;){const e1=p[E],f1=m[E]=P?D2(m[E]):Z2(m[E]);if(p3(e1,f1))x(e1,f1,v,null,S,Z,V,L,P);else break;E++}for(;E<=z&&E<=X;){const e1=p[z],f1=m[X]=P?D2(m[X]):Z2(m[X]);if(p3(e1,f1))x(e1,f1,v,null,S,Z,V,L,P);else break;z--,X--}if(E>z){if(E<=X){const e1=X+1,f1=e1X)for(;E<=z;)N1(p[E],S,Z,!0),E++;else{const e1=E,f1=E,_1=new Map;for(E=f1;E<=X;E++){const t2=m[E]=P?D2(m[E]):Z2(m[E]);t2.key!=null&&_1.set(t2.key,E)}let M1,T1=0;const V1=X-f1+1;let g2=!1,v2=0;const I3=new Array(V1);for(E=0;E=V1){N1(t2,S,Z,!0);continue}let b2;if(t2.key!=null)b2=_1.get(t2.key);else for(M1=f1;M1<=X;M1++)if(I3[M1-f1]===0&&p3(t2,m[M1])){b2=M1;break}b2===void 0?N1(t2,S,Z,!0):(I3[b2-f1]=E+1,b2>=v2?v2=b2:g2=!0,x(t2,m[b2],v,null,S,Z,V,L,P),T1++)}const M6=g2?Z9(I3):w3;for(M1=M6.length-1,E=V1-1;E>=0;E--){const t2=f1+E,b2=m[t2],w6=m[t2+1],_6=t2+1{const{el:Z,type:V,transition:L,children:P,shapeFlag:E}=p;if(E&6){e2(p.component.subTree,m,v,A);return}if(E&128){p.suspense.move(m,v,A);return}if(E&64){V.move(p,m,v,q);return}if(V===y1){a(Z,m,v);for(let z=0;zL.enter(Z),S));else{const{leave:z,delayLeave:X,afterLeave:e1}=L,f1=()=>{p.ctx.isUnmounted?l(Z):a(Z,m,v)},_1=()=>{const M1=Z._isLeaving||!!Z[l2];Z._isLeaving&&Z[l2](!0),L.persisted&&!M1?f1():z(Z,()=>{f1(),e1&&e1()})};X?X(Z,f1,_1):_1()}else a(Z,m,v)},N1=(p,m,v,A=!1,S=!1)=>{const{type:Z,props:V,ref:L,children:P,dynamicChildren:E,shapeFlag:Q,patchFlag:z,dirs:X,cacheIndex:e1,memo:f1}=p;if(z===-2&&(S=!1),L!=null&&(U2(),q3(L,null,v,p,!0),G2()),e1!=null&&(m.renderCache[e1]=void 0),Q&256){m.ctx.deactivate(p);return}const _1=Q&1&&X,M1=!Z3(p);let T1;if(M1&&(T1=V&&V.onVnodeBeforeUnmount)&&y2(T1,m,p),Q&6)S1(p.component,v,A);else{if(Q&128){p.suspense.unmount(v,A);return}_1&&c3(p,null,m,"beforeUnmount"),Q&64?p.type.remove(p,m,v,q,A):E&&!E.hasOnce&&(Z!==y1||z>0&&z&64)?x1(E,m,v,!1,!0):(Z===y1&&z&384||!S&&Q&16)&&x1(P,m,v),A&&P2(p)}const V1=f1!=null&&e1==null;(M1&&(T1=V&&V.onVnodeUnmounted)||_1||V1)&&G1(()=>{T1&&y2(T1,m,p),_1&&c3(p,null,m,"unmounted"),V1&&(p.el=null)},v)},P2=p=>{const{type:m,el:v,anchor:A,transition:S}=p;if(m===y1){m2(v,A);return}if(m===A4){_(p);return}const Z=()=>{l(v),S&&!S.persisted&&S.afterLeave&&S.afterLeave()};if(p.shapeFlag&1&&S&&!S.persisted){const{leave:V,delayLeave:L}=S,P=()=>V(v,Z);L?L(p.el,Z,P):P()}else Z()},m2=(p,m)=>{let v;for(;p!==m;)v=d(p),l(p),p=v;l(m)},S1=(p,m,v)=>{const{bum:A,scope:S,job:Z,subTree:V,um:L,m:P,a:E}=p;H6(P),H6(E),A&&k4(A),S.stop(),Z&&(Z.flags|=8,N1(V,p,m,v)),L&&G1(L,m),G1(()=>{p.isUnmounted=!0},m)},x1=(p,m,v,A=!1,S=!1,Z=0)=>{for(let V=Z;V{if(p.shapeFlag&6)return k(p.component.subTree);if(p.shapeFlag&128)return p.suspense.next();const m=d(p.anchor||p.el),v=m&&m[M8];return v?d(v):m};let B=!1;const O=(p,m,v)=>{let A;p==null?m._vnode&&(N1(m._vnode,null,null,!0),A=m._vnode.component):x(m._vnode||null,p,m,null,null,null,v),m._vnode=p,B||(B=!0,E6(A),g8(),B=!1)},q={p:x,um:N1,m:e2,r:P2,mt:k1,mc:R,pc:i1,pbc:t1,n:k,o:e};return{render:O,hydrate:void 0,createApp:o9(O)}}function h5({type:e,props:t},n){return n==="svg"&&e==="foreignObject"||n==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function o3({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function _9(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function f6(e,t,n=!1){const a=e.children,l=t.children;if(Y(a)&&Y(l))for(let r=0;r>1,e[n[s]]0&&(t[a]=n[r-1]),n[r]=a)}}for(r=n.length,c=n[r-1];r-- >0;)n[r]=c,c=t[c];return n}function G8(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:G8(t)}function H6(e){if(e)for(let t=0;te.__isSuspense;function k9(e,t){t&&t.pendingBranch?Y(e)?t.effects.push(...e):t.effects.push(e):Pe(e)}const y1=Symbol.for("v-fgt"),a5=Symbol.for("v-txt"),H1=Symbol.for("v-cmt"),A4=Symbol.for("v-stc"),z2=[];let n2=null;function T(e=!1){z2.push(n2=e?null:[])}function d6(){z2.pop(),n2=z2[z2.length-1]||null}let n4=1;function $4(e,t=!1){n4+=e,e<0&&n2&&t&&(n2.hasOnce=!0)}function q8(e){return e.dynamicChildren=n4>0?n2||w3:null,d6(),n4>0&&n2&&n2.push(e),e}function W(e,t,n,a,l,r){return q8(w(e,t,n,a,l,r,!0))}function m1(e,t,n,a,l){return q8(j(e,t,n,a,l,!0))}function a4(e){return e?e.__v_isVNode===!0:!1}function p3(e,t){return e.type===t.type&&e.key===t.key}const J8=({key:e})=>e??null,S4=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?A1(e)||$1(e)||n1(e)?{i:F1,r:e,k:t,f:!!n}:e:null);function w(e,t=null,n=null,a=0,l=null,r=e===y1?0:1,c=!1,s=!1){const o={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&J8(t),ref:t&&S4(t),scopeId:b8,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:r,patchFlag:a,dynamicProps:l,dynamicChildren:null,appContext:null,ctx:F1};return s?(N4(o,n),r&128&&e.normalize(o)):n&&(o.shapeFlag|=A1(n)?8:16),n4>0&&!c&&n2&&(o.patchFlag>0||r&6)&&o.patchFlag!==32&&n2.push(o),o}const j=C9;function C9(e,t=null,n=null,a=0,l=null,r=!1){if((!e||e===R8)&&(e=H1),a4(e)){const s=a3(e,t,!0);return n&&N4(s,n),n4>0&&!r&&n2&&(s.shapeFlag&6?n2[n2.indexOf(e)]=s:n2.push(s)),s.patchFlag=-2,s}if(V9(e)&&(e=e.__vccOpts),t){t=A9(t);let{class:s,style:o}=t;s&&!A1(s)&&(t.class=X1(s)),b1(o)&&(r6(o)&&!Y(o)&&(o=I1({},o)),t.style=K4(o))}const c=A1(e)?1:K8(e)?128:X4(e)?64:b1(e)?4:n1(e)?2:0;return w(e,t,n,a,l,c,r,!0)}function A9(e){return e?r6(e)||j8(e)?I1({},e):e:null}function a3(e,t,n=!1,a=!1){const{props:l,ref:r,patchFlag:c,children:s,transition:o}=e,i=t?E9(l||{},t):l,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:i,key:i&&J8(i),ref:t&&t.ref?n&&r?Y(r)?r.concat(S4(t)):[r,S4(t)]:S4(t):r,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:s,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==y1?c===-1?16:c|16:c,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:o,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&a3(e.ssContent),ssFallback:e.ssFallback&&a3(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return o&&a&&t4(u,o.clone(u)),u}function p1(e=" ",t=0){return j(a5,null,e,t)}function S9(e,t){const n=j(A4,null,e);return n.staticCount=t,n}function w1(e="",t=!1){return t?(T(),m1(H1,null,e)):j(H1,null,e)}function Z2(e){return e==null||typeof e=="boolean"?j(H1):Y(e)?j(y1,null,e.slice()):a4(e)?D2(e):j(a5,null,String(e))}function D2(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:a3(e)}function N4(e,t){let n=0;const{shapeFlag:a}=e;if(t==null)t=null;else if(Y(t))n=16;else if(typeof t=="object")if(a&65){const l=t.default;l&&(l._c&&(l._d=!1),N4(e,l()),l._c&&(l._d=!0));return}else{n=32;const l=t._;!l&&!j8(t)?t._ctx=F1:l===3&&F1&&(F1.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else if(n1(t)){if(a&65){N4(e,{default:t});return}t={default:t,_ctx:F1},n=32}else t=String(t),a&64?(n=16,t=[p1(t)]):n=8;e.children=t,e.shapeFlag|=n}function E9(...e){const t={};for(let n=0;nB1||F1;let V4,l4;{const e=W4(),t=(n,a)=>{let l;return(l=e[n])||(l=e[n]=[]),l.push(a),r=>{l.length>1?l.forEach(c=>c(r)):l[0](r)}};V4=t("__VUE_INSTANCE_SETTERS__",n=>B1=n),l4=t("__VUE_SSR_SETTERS__",n=>r4=n)}const p4=e=>{const t=B1;return V4(e),e.scope.on(),()=>{e.scope.off(),V4(t)}},B6=()=>{B1&&B1.scope.off(),V4(null)};function X8(e){return e.vnode.shapeFlag&4}let r4=!1;function P9(e,t=!1,n=!1){t&&l4(t);const{props:a,children:l}=e.vnode,r=X8(e);m9(e,a,r,t),y9(e,l,n||t);const c=r?I9(e,t):void 0;return t&&l4(!1),c}function I9(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,e9);const{setup:a}=n;if(a){U2();const l=e.setupContext=a.length>1?$9(e):null,r=p4(e),c=f4(a,e,0,[e.props,l]),s=B7(c);if(G2(),r(),(s||e.sp)&&!Z3(e)&&A8(e),s){if(c.then(B6,B6),t)return c.then(o=>{l4(!0);try{U6(e,o,t)}finally{l4(!1)}}).catch(o=>{Y4(o,e,0)});e.asyncDep=c}else U6(e,c)}else Q8(e)}function U6(e,t,n){n1(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:b1(t)&&(e.setupState=p8(t)),Q8(e)}function Q8(e,t,n){const a=e.type;e.render||(e.render=a.render||S2);{const l=p4(e);U2();try{t9(e)}finally{G2(),l()}}}const L9={get(e,t){return z1(e,"get",""),e[t]}};function $9(e){const t=n=>{e.exposed=n||{}};return{attrs:new Proxy(e.attrs,L9),slots:e.slots,emit:e.emit,expose:t}}function l5(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(p8(_e(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in J3)return J3[n](e)},has(t,n){return n in t||n in J3}})):e.proxy}function N9(e,t=!0){return n1(e)?e.displayName||e.name:e.name||t&&e.__name}function V9(e){return n1(e)&&"__vccOpts"in e}const j1=(e,t)=>Se(e,t,r4);function S3(e,t,n){try{$4(-1);const a=arguments.length;return a===2?b1(t)&&!Y(t)?a4(t)?j(e,null,[t]):j(e,t):j(e,null,t):(a>3?n=Array.prototype.slice.call(arguments,2):a===3&&a4(n)&&(n=[n]),j(e,t,n))}finally{$4(1)}}const D9="3.5.42";/** +* @vue/runtime-dom v3.5.42 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/let j5;const G6=typeof window<"u"&&window.trustedTypes;if(G6)try{j5=G6.createPolicy("vue",{createHTML:e=>e})}catch{}const e0=j5?e=>j5.createHTML(e):e=>e,j9="http://www.w3.org/2000/svg",F9="http://www.w3.org/1998/Math/MathML",V2=typeof document<"u"?document:null,W6=V2&&V2.createElement("template"),z9={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,a)=>{const l=t==="svg"?V2.createElementNS(j9,e):t==="mathml"?V2.createElementNS(F9,e):n?V2.createElement(e,{is:n}):V2.createElement(e);return e==="select"&&a&&a.multiple!=null&&l.setAttribute("multiple",a.multiple),l},createText:e=>V2.createTextNode(e),createComment:e=>V2.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>V2.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,a,l,r){const c=n?n.previousSibling:t.lastChild;if(l&&(l===r||l.nextSibling))for(;t.insertBefore(l.cloneNode(!0),n),!(l===r||!(l=l.nextSibling)););else{W6.innerHTML=e0(a==="svg"?`${e}`:a==="mathml"?`${e}`:e);const s=W6.content;if(a==="svg"||a==="mathml"){const o=s.firstChild;for(;o.firstChild;)s.appendChild(o.firstChild);s.removeChild(o)}t.insertBefore(s,n)}return[c?c.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},q2="transition",N3="animation",c4=Symbol("_vtc"),t0={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},H9=I1({},w8,t0),B9=e=>(e.displayName="Transition",e.props=H9,e),n0=B9((e,{slots:t})=>S3(He,U9(e),t)),s3=(e,t=[])=>{Y(e)?e.forEach(n=>n(...t)):e&&e(...t)},K6=e=>e?Y(e)?e.some(t=>t.length>1):e.length>1:!1;function U9(e){const t={};for(const D in e)D in t0||(t[D]=e[D]);if(e.css===!1)return t;const{name:n="v",type:a,duration:l,enterFromClass:r=`${n}-enter-from`,enterActiveClass:c=`${n}-enter-active`,enterToClass:s=`${n}-enter-to`,appearFromClass:o=r,appearActiveClass:i=c,appearToClass:u=s,leaveFromClass:f=`${n}-leave-from`,leaveActiveClass:d=`${n}-leave-active`,leaveToClass:h=`${n}-leave-to`}=e,y=G9(l),x=y&&y[0],b=y&&y[1],{onBeforeEnter:M,onEnter:g,onEnterCancelled:C,onLeave:_,onLeaveCancelled:H,onBeforeAppear:F=M,onAppear:$=g,onAppearCancelled:R=C}=t,N=(D,o1,k1,R1)=>{D._enterCancelled=R1,i3(D,o1?u:s),i3(D,o1?i:c),k1&&k1()},t1=(D,o1)=>{D._isLeaving=!1,i3(D,f),i3(D,h),i3(D,d),o1&&o1()},s1=D=>(o1,k1)=>{const R1=D?$:g,u1=()=>N(o1,D,k1);s3(R1,[o1,u1]),q6(()=>{i3(o1,D?o:r),L2(o1,D?u:s),K6(R1)||J6(o1,a,x,u1)})};return I1(t,{onBeforeEnter(D){s3(M,[D]),L2(D,r),L2(D,c)},onBeforeAppear(D){s3(F,[D]),L2(D,o),L2(D,i)},onEnter:s1(!1),onAppear:s1(!0),onLeave(D,o1){D._isLeaving=!0;const k1=()=>t1(D,o1);L2(D,f),D._enterCancelled?(L2(D,d),Q6(D)):(Q6(D),L2(D,d)),q6(()=>{D._isLeaving&&(i3(D,f),L2(D,h),K6(_)||J6(D,a,b,k1))}),s3(_,[D,k1])},onEnterCancelled(D){N(D,!1,void 0,!0),s3(C,[D])},onAppearCancelled(D){N(D,!0,void 0,!0),s3(R,[D])},onLeaveCancelled(D){t1(D),s3(H,[D])}})}function G9(e){if(e==null)return null;if(b1(e))return[m5(e.enter),m5(e.leave)];{const t=m5(e);return[t,t]}}function m5(e){return J0(e)}function L2(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[c4]||(e[c4]=new Set)).add(t)}function i3(e,t){t.split(/\s+/).forEach(a=>a&&e.classList.remove(a));const n=e[c4];n&&(n.delete(t),n.size||(e[c4]=void 0))}function q6(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let W9=0;function J6(e,t,n,a){const l=e._endId=++W9,r=()=>{l===e._endId&&a()};if(n!=null)return setTimeout(r,n);const{type:c,timeout:s,propCount:o}=K9(e,t);if(!c)return a();const i=c+"end";let u=0;const f=()=>{e.removeEventListener(i,d),r()},d=h=>{h.target===e&&++u>=o&&f()};setTimeout(()=>{u(n[y]||"").split(", "),l=a(`${q2}Delay`),r=a(`${q2}Duration`),c=Y6(l,r),s=a(`${N3}Delay`),o=a(`${N3}Duration`),i=Y6(s,o);let u=null,f=0,d=0;t===q2?c>0&&(u=q2,f=c,d=r.length):t===N3?i>0&&(u=N3,f=i,d=o.length):(f=Math.max(c,i),u=f>0?c>i?q2:N3:null,d=u?u===q2?r.length:o.length:0);const h=u===q2&&/\b(?:transform|all)(?:,|$)/.test(a(`${q2}Property`).toString());return{type:u,timeout:f,propCount:d,hasTransform:h}}function Y6(e,t){for(;e.lengthX6(n)+X6(e[a])))}function X6(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function Q6(e){return(e?e.ownerDocument:document).body.offsetHeight}function q9(e,t,n){const a=e[c4];a&&(t=(t?[t,...a]:[...a]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const e7=Symbol("_vod"),J9=Symbol("_vsh"),Y9=Symbol(""),X9=/(?:^|;)\s*display\s*:/;function Q9(e,t,n){const a=e.style,l=A1(n);let r=!1;if(n&&!l){if(t)if(A1(t))for(const c of t.split(";")){const s=c.slice(0,c.indexOf(":")).trim();n[s]==null&&U3(a,s,"")}else for(const c in t)n[c]==null&&U3(a,c,"");for(const c in n){c==="display"&&(r=!0);const s=n[c];s!=null?tt(e,c,!A1(t)&&t?t[c]:void 0,s)||U3(a,c,s):U3(a,c,"")}}else if(l){if(t!==n){const c=a[Y9];c&&(n+=";"+c),a.cssText=n,r=X9.test(n)}}else t&&e.removeAttribute("style");e7 in e&&(e[e7]=r?a.display:"",e[J9]&&(a.display="none"))}const x4=/\s*!important$/;function U3(e,t,n){if(Y(n))n.forEach(a=>U3(e,t,a));else if(n==null&&(n=""),t.startsWith("--"))x4.test(n)?e.setProperty(t,n.replace(x4,""),"important"):e.setProperty(t,n);else{const a=et(e,t);x4.test(n)?e.setProperty(v3(a),n.replace(x4,""),"important"):e[a]=n}}const t7=["Webkit","Moz","ms"],g5={};function et(e,t){const n=g5[t];if(n)return n;let a=J1(t);if(a!=="filter"&&a in e)return g5[t]=a;a=U4(a);for(let l=0;lv5||(ot.then(()=>v5=0),v5=Date.now());function it(e,t){const n=a=>{if(!a._vts)a._vts=Date.now();else if(a._vts<=n.attached)return;const l=n.value;if(Y(l)){const r=a.stopImmediatePropagation;a.stopImmediatePropagation=()=>{r.call(a),a._stopped=!0};const c=l.slice(),s=[a];for(let o=0;oe.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,ut=(e,t,n,a,l,r)=>{const c=l==="svg";t==="class"?q9(e,a,c):t==="style"?Q9(e,n,a):z4(t)?H4(t)||at(e,t,n,a,r):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):ft(e,t,a,c))?(l7(e,t,a),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&a7(e,t,a,c,r,t!=="value")):e._isVueCE&&(dt(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!A1(a)))?l7(e,J1(t),a,r,t):(t==="true-value"?e._trueValue=a:t==="false-value"&&(e._falseValue=a),a7(e,t,a,c))};function ft(e,t,n,a){if(a)return!!(t==="innerHTML"||t==="textContent"||t in e&&c7(t)&&n1(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const l=e.tagName;if(l==="IMG"||l==="VIDEO"||l==="CANVAS"||l==="SOURCE")return!1}return c7(t)&&A1(n)?!1:t in e}function dt(e,t){const n=e._def.props;if(!n)return!1;const a=J1(t);return Array.isArray(n)?n.some(l=>J1(l)===a):Object.keys(n).some(l=>J1(l)===a)}const E3=e=>{const t=e.props["onUpdate:modelValue"]||!1;return Y(t)?n=>k4(t,n):t};function pt(e){e.target.composing=!0}function o7(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const C2=Symbol("_assign"),M4=Symbol("_initialValue");function b5(e,t,n){return t&&(e=e.trim()),n&&(e=G4(e)),e}const E4={created(e,{modifiers:{lazy:t,trim:n,number:a}},l){e.parentNode&&(e.type==="text"?e[M4]=e.defaultValue.replace(/[\r\n]/g,""):e.type==="textarea"&&(e[M4]=e.defaultValue.replace(/\r\n?/g,` +`))),e[C2]=E3(l);const r=a||l.props&&l.props.type==="number";t3(e,t?"change":"input",c=>{c.target.composing||e[C2](b5(e.value,n,r))}),(n||r)&&t3(e,"change",()=>{e.value=b5(e.value,n,r)}),t||(t3(e,"compositionstart",pt),t3(e,"compositionend",o7),t3(e,"change",o7))},mounted(e,{value:t,modifiers:{trim:n,number:a}}){const l=t??"",r=e[M4];delete e[M4],r!==void 0&&(e.type==="text"||e.type==="textarea")&&e.value!==r?e[C2](b5(e.value,n,a)):e.value=l},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:a,trim:l,number:r}},c){if(e[C2]=E3(c),e.composing)return;const s=(r||e.type==="number")&&!/^0\d/.test(e.value)?G4(e.value):e.value,o=t??"";if(s===o)return;const i=e.getRootNode();(i instanceof Document||i instanceof ShadowRoot)&&i.activeElement===e&&e.type!=="range"&&(a&&t===n||l&&e.value.trim()===o)||(e.value=o)}},w4={deep:!0,created(e,t,n){e[C2]=E3(n),t3(e,"change",()=>{const a=e._modelValue,l=o4(e),r=e.checked,c=e[C2];if(Y(a)){const s=X5(a,l),o=s!==-1;if(r&&!o)c(a.concat(l));else if(!r&&o){const i=[...a];i.splice(s,1),c(i)}}else if(H2(a)){const s=new Set(a);r?s.add(l):s.delete(l),c(s)}else c(a0(e,r))})},mounted:s7,beforeUpdate(e,t,n){e[C2]=E3(n),s7(e,t,n)}};function s7(e,{value:t,oldValue:n},a){e._modelValue=t;let l;if(Y(t))l=X5(t,a.props.value)>-1;else if(H2(t))l=t.has(a.props.value);else{if(t===n)return;l=B2(t,a0(e,!0))}e.checked!==l&&(e.checked=l)}const F5={deep:!0,created(e,{value:t,modifiers:{number:n}},a){e._modelValue=t,t3(e,"change",()=>{const l=Array.prototype.filter.call(e.options,o=>o.selected).map(o=>n?G4(o4(o)):o4(o)),r=e.multiple,c=r?H2(e._modelValue)?new Set(l):l:l[0],s=e._pendingValue=[r,r?Y(c)?l.slice():l:c];try{e[C2](c)}finally{c6(()=>{e._pendingValue===s&&(e._pendingValue=void 0)})}}),e[C2]=E3(a)},mounted(e,{value:t}){i7(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[C2]=E3(n)},updated(e,{value:t}){const n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!ht(t,n[1],n[0]))&&i7(e,t)}};function ht(e,t,n){if(!n||Y(e))return B2(e,t);if(H2(e)){if(e.size!==t.length)return!1;for(const a of t)if(!e.has(a))return!1;return!0}return!1}function i7(e,t){const n=e.multiple,a=Y(t);if(!(n&&!a&&!H2(t))){for(let l=0,r=e.options.length;lString(i)===String(s)):c.selected=X5(t,s)>-1}else c.selected=t.has(s);else if(B2(o4(c),t)){e.selectedIndex!==l&&(e.selectedIndex=l);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function o4(e){return"_value"in e?e._value:e.value}function a0(e,t){const n=t?"_trueValue":"_falseValue";return n in e?e[n]:t}const mt=["ctrl","shift","alt","meta"],gt={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>mt.some(n=>e[`${n}Key`]&&!t.includes(n))},vt=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),a=t.join(".");return n[a]||(n[a]=((l,...r)=>{for(let c=0;c{const t=yt().createApp(...e),{mount:n}=t;return t.mount=a=>{const l=wt(a);if(!l)return;const r=t._component;!n1(r)&&!r.render&&!r.template&&(r.template=l.innerHTML),l.nodeType===1&&(l.textContent="");const c=n(l,!1,Mt(l));return l instanceof Element&&(l.removeAttribute("v-cloak"),l.setAttribute("data-v-app","")),c},t});function Mt(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function wt(e){return A1(e)?document.querySelector(e):e}/*! + * vue-router v4.6.4 + * (c) 2025 Eduardo San Martin Morote + * @license MIT + */const M3=typeof document<"u";function l0(e){return typeof e=="object"||"displayName"in e||"props"in e||"__vccOpts"in e}function _t(e){return e.__esModule||e[Symbol.toStringTag]==="Module"||e.default&&l0(e.default)}const g1=Object.assign;function y5(e,t){const n={};for(const a in t){const l=t[a];n[a]=h2(l)?l.map(e):e(l)}return n}const Y3=()=>{},h2=Array.isArray;function f7(e,t){const n={};for(const a in e)n[a]=a in t?t[a]:e[a];return n}const r0=/#/g,Zt=/&/g,kt=/\//g,Ct=/=/g,At=/\?/g,c0=/\+/g,St=/%5B/g,Et=/%5D/g,o0=/%5E/g,Rt=/%60/g,s0=/%7B/g,Tt=/%7C/g,i0=/%7D/g,Ot=/%20/g;function p6(e){return e==null?"":encodeURI(""+e).replace(Tt,"|").replace(St,"[").replace(Et,"]")}function Pt(e){return p6(e).replace(s0,"{").replace(i0,"}").replace(o0,"^")}function z5(e){return p6(e).replace(c0,"%2B").replace(Ot,"+").replace(r0,"%23").replace(Zt,"%26").replace(Rt,"`").replace(s0,"{").replace(i0,"}").replace(o0,"^")}function It(e){return z5(e).replace(Ct,"%3D")}function Lt(e){return p6(e).replace(r0,"%23").replace(At,"%3F")}function $t(e){return Lt(e).replace(kt,"%2F")}function s4(e){if(e==null)return null;try{return decodeURIComponent(""+e)}catch{}return""+e}const Nt=/\/$/,Vt=e=>e.replace(Nt,"");function x5(e,t,n="/"){let a,l={},r="",c="";const s=t.indexOf("#");let o=t.indexOf("?");return o=s>=0&&o>s?-1:o,o>=0&&(a=t.slice(0,o),r=t.slice(o,s>0?s:t.length),l=e(r.slice(1))),s>=0&&(a=a||t.slice(0,s),c=t.slice(s,t.length)),a=zt(a??t,n),{fullPath:a+r+c,path:a,query:l,hash:s4(c)}}function Dt(e,t){const n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}function d7(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||"/"}function jt(e,t,n){const a=t.matched.length-1,l=n.matched.length-1;return a>-1&&a===l&&R3(t.matched[a],n.matched[l])&&u0(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function R3(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function u0(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!Ft(e[n],t[n]))return!1;return!0}function Ft(e,t){return h2(e)?p7(e,t):h2(t)?p7(t,e):(e==null?void 0:e.valueOf())===(t==null?void 0:t.valueOf())}function p7(e,t){return h2(t)?e.length===t.length&&e.every((n,a)=>n===t[a]):e.length===1&&e[0]===t}function zt(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),a=e.split("/"),l=a[a.length-1];(l===".."||l===".")&&a.push("");let r=n.length-1,c,s;for(c=0;c1&&r--;else break;return n.slice(0,r).join("/")+"/"+a.slice(c).join("/")}const J2={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};let H5=(function(e){return e.pop="pop",e.push="push",e})({}),M5=(function(e){return e.back="back",e.forward="forward",e.unknown="",e})({});function Ht(e){if(!e)if(M3){const t=document.querySelector("base");e=t&&t.getAttribute("href")||"/",e=e.replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return e[0]!=="/"&&e[0]!=="#"&&(e="/"+e),Vt(e)}const Bt=/^[^#]+#/;function Ut(e,t){return e.replace(Bt,"#")+t}function Gt(e,t){const n=document.documentElement.getBoundingClientRect(),a=e.getBoundingClientRect();return{behavior:t.behavior,left:a.left-n.left-(t.left||0),top:a.top-n.top-(t.top||0)}}const r5=()=>({left:window.scrollX,top:window.scrollY});function Wt(e){let t;if("el"in e){const n=e.el,a=typeof n=="string"&&n.startsWith("#"),l=typeof n=="string"?a?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!l)return;t=Gt(l,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left!=null?t.left:window.scrollX,t.top!=null?t.top:window.scrollY)}function h7(e,t){return(history.state?history.state.position-t:-1)+e}const B5=new Map;function Kt(e,t){B5.set(e,t)}function qt(e){const t=B5.get(e);return B5.delete(e),t}function Jt(e){return typeof e=="string"||e&&typeof e=="object"}function f0(e){return typeof e=="string"||typeof e=="symbol"}let E1=(function(e){return e[e.MATCHER_NOT_FOUND=1]="MATCHER_NOT_FOUND",e[e.NAVIGATION_GUARD_REDIRECT=2]="NAVIGATION_GUARD_REDIRECT",e[e.NAVIGATION_ABORTED=4]="NAVIGATION_ABORTED",e[e.NAVIGATION_CANCELLED=8]="NAVIGATION_CANCELLED",e[e.NAVIGATION_DUPLICATED=16]="NAVIGATION_DUPLICATED",e})({});const d0=Symbol("");E1.MATCHER_NOT_FOUND+"",E1.NAVIGATION_GUARD_REDIRECT+"",E1.NAVIGATION_ABORTED+"",E1.NAVIGATION_CANCELLED+"",E1.NAVIGATION_DUPLICATED+"";function T3(e,t){return g1(new Error,{type:e,[d0]:!0},t)}function $2(e,t){return e instanceof Error&&d0 in e&&(t==null||!!(e.type&t))}const Yt=["params","query","hash"];function Xt(e){if(typeof e=="string")return e;if(e.path!=null)return e.path;const t={};for(const n of Yt)n in e&&(t[n]=e[n]);return JSON.stringify(t,null,2)}function Qt(e){const t={};if(e===""||e==="?")return t;const n=(e[0]==="?"?e.slice(1):e).split("&");for(let a=0;al&&z5(l)):[a&&z5(a)]).forEach(l=>{l!==void 0&&(t+=(t.length?"&":"")+n,l!=null&&(t+="="+l))})}return t}function en(e){const t={};for(const n in e){const a=e[n];a!==void 0&&(t[n]=h2(a)?a.map(l=>l==null?null:""+l):a==null?a:""+a)}return t}const tn=Symbol(""),g7=Symbol(""),h6=Symbol(""),m6=Symbol(""),U5=Symbol("");function V3(){let e=[];function t(a){return e.push(a),()=>{const l=e.indexOf(a);l>-1&&e.splice(l,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function e3(e,t,n,a,l,r=c=>c()){const c=a&&(a.enterCallbacks[l]=a.enterCallbacks[l]||[]);return()=>new Promise((s,o)=>{const i=d=>{d===!1?o(T3(E1.NAVIGATION_ABORTED,{from:n,to:t})):d instanceof Error?o(d):Jt(d)?o(T3(E1.NAVIGATION_GUARD_REDIRECT,{from:t,to:d})):(c&&a.enterCallbacks[l]===c&&typeof d=="function"&&c.push(d),s())},u=r(()=>e.call(a&&a.instances[l],t,n,i));let f=Promise.resolve(u);e.length<3&&(f=f.then(i)),f.catch(d=>o(d))})}function w5(e,t,n,a,l=r=>r()){const r=[];for(const c of e)for(const s in c.components){let o=c.components[s];if(!(t!=="beforeRouteEnter"&&!c.instances[s]))if(l0(o)){const i=(o.__vccOpts||o)[t];i&&r.push(e3(i,n,a,c,s,l))}else{let i=o();r.push(()=>i.then(u=>{if(!u)throw new Error(`Couldn't resolve component "${s}" at "${c.path}"`);const f=_t(u)?u.default:u;c.mods[s]=u,c.components[s]=f;const d=(f.__vccOpts||f)[t];return d&&e3(d,n,a,c,s,l)()}))}}return r}function nn(e,t){const n=[],a=[],l=[],r=Math.max(t.matched.length,e.matched.length);for(let c=0;cR3(i,s))?a.push(s):n.push(s));const o=e.matched[c];o&&(t.matched.find(i=>R3(i,o))||l.push(o))}return[n,a,l]}/*! + * vue-router v4.6.4 + * (c) 2025 Eduardo San Martin Morote + * @license MIT + */let an=()=>location.protocol+"//"+location.host;function p0(e,t){const{pathname:n,search:a,hash:l}=t,r=e.indexOf("#");if(r>-1){let c=l.includes(e.slice(r))?e.slice(r).length:1,s=l.slice(c);return s[0]!=="/"&&(s="/"+s),d7(s,"")}return d7(n,e)+a+l}function ln(e,t,n,a){let l=[],r=[],c=null;const s=({state:d})=>{const h=p0(e,location),y=n.value,x=t.value;let b=0;if(d){if(n.value=h,t.value=d,c&&c===y){c=null;return}b=x?d.position-x.position:0}else a(h);l.forEach(M=>{M(n.value,y,{delta:b,type:H5.pop,direction:b?b>0?M5.forward:M5.back:M5.unknown})})};function o(){c=n.value}function i(d){l.push(d);const h=()=>{const y=l.indexOf(d);y>-1&&l.splice(y,1)};return r.push(h),h}function u(){if(document.visibilityState==="hidden"){const{history:d}=window;if(!d.state)return;d.replaceState(g1({},d.state,{scroll:r5()}),"")}}function f(){for(const d of r)d();r=[],window.removeEventListener("popstate",s),window.removeEventListener("pagehide",u),document.removeEventListener("visibilitychange",u)}return window.addEventListener("popstate",s),window.addEventListener("pagehide",u),document.addEventListener("visibilitychange",u),{pauseListeners:o,listen:i,destroy:f}}function v7(e,t,n,a=!1,l=!1){return{back:e,current:t,forward:n,replaced:a,position:window.history.length,scroll:l?r5():null}}function rn(e){const{history:t,location:n}=window,a={value:p0(e,n)},l={value:t.state};l.value||r(a.value,{back:null,current:a.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function r(o,i,u){const f=e.indexOf("#"),d=f>-1?(n.host&&document.querySelector("base")?e:e.slice(f))+o:an()+e+o;try{t[u?"replaceState":"pushState"](i,"",d),l.value=i}catch(h){console.error(h),n[u?"replace":"assign"](d)}}function c(o,i){r(o,g1({},t.state,v7(l.value.back,o,l.value.forward,!0),i,{position:l.value.position}),!0),a.value=o}function s(o,i){const u=g1({},l.value,t.state,{forward:o,scroll:r5()});r(u.current,u,!0),r(o,g1({},v7(a.value,o,null),{position:u.position+1},i),!1),a.value=o}return{location:a,state:l,push:s,replace:c}}function cn(e){e=Ht(e);const t=rn(e),n=ln(e,t.state,t.location,t.replace);function a(r,c=!0){c||n.pauseListeners(),history.go(r)}const l=g1({location:"",base:e,go:a,createHref:Ut.bind(null,e)},t,n);return Object.defineProperty(l,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(l,"state",{enumerable:!0,get:()=>t.state.value}),l}function on(e){return e=location.host?e||location.pathname+location.search:"",e.includes("#")||(e+="#"),cn(e)}let h3=(function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.Group=2]="Group",e})({});var P1=(function(e){return e[e.Static=0]="Static",e[e.Param=1]="Param",e[e.ParamRegExp=2]="ParamRegExp",e[e.ParamRegExpEnd=3]="ParamRegExpEnd",e[e.EscapeNext=4]="EscapeNext",e})(P1||{});const sn={type:h3.Static,value:""},un=/[a-zA-Z0-9_]/;function fn(e){if(!e)return[[]];if(e==="/")return[[sn]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(h){throw new Error(`ERR (${n})/"${i}": ${h}`)}let n=P1.Static,a=n;const l=[];let r;function c(){r&&l.push(r),r=[]}let s=0,o,i="",u="";function f(){i&&(n===P1.Static?r.push({type:h3.Static,value:i}):n===P1.Param||n===P1.ParamRegExp||n===P1.ParamRegExpEnd?(r.length>1&&(o==="*"||o==="+")&&t(`A repeatable param (${i}) must be alone in its segment. eg: '/:ids+.`),r.push({type:h3.Param,value:i,regexp:u,repeatable:o==="*"||o==="+",optional:o==="*"||o==="?"})):t("Invalid state to consume buffer"),i="")}function d(){i+=o}for(;st.length?t.length===1&&t[0]===W1.Static+W1.Segment?1:-1:0}function h0(e,t){let n=0;const a=e.score,l=t.score;for(;n0&&t[t.length-1]<0}const gn={strict:!1,end:!0,sensitive:!1};function vn(e,t,n){const a=hn(fn(e.path),n),l=g1(a,{record:e,parent:t,children:[],alias:[]});return t&&!l.record.aliasOf==!t.record.aliasOf&&t.children.push(l),l}function bn(e,t){const n=[],a=new Map;t=f7(gn,t);function l(f){return a.get(f)}function r(f,d,h){const y=!h,x=M7(f);x.aliasOf=h&&h.record;const b=f7(t,f),M=[x];if("alias"in f){const _=typeof f.alias=="string"?[f.alias]:f.alias;for(const H of _)M.push(M7(g1({},x,{components:h?h.record.components:x.components,path:H,aliasOf:h?h.record:x})))}let g,C;for(const _ of M){const{path:H}=_;if(d&&H[0]!=="/"){const F=d.record.path,$=F[F.length-1]==="/"?"":"/";_.path=d.record.path+(H&&$+H)}if(g=vn(_,d,b),h?h.alias.push(g):(C=C||g,C!==g&&C.alias.push(g),y&&f.name&&!w7(g)&&c(f.name)),m0(g)&&o(g),x.children){const F=x.children;for(let $=0;${c(C)}:Y3}function c(f){if(f0(f)){const d=a.get(f);d&&(a.delete(f),n.splice(n.indexOf(d),1),d.children.forEach(c),d.alias.forEach(c))}else{const d=n.indexOf(f);d>-1&&(n.splice(d,1),f.record.name&&a.delete(f.record.name),f.children.forEach(c),f.alias.forEach(c))}}function s(){return n}function o(f){const d=Mn(f,n);n.splice(d,0,f),f.record.name&&!w7(f)&&a.set(f.record.name,f)}function i(f,d){let h,y={},x,b;if("name"in f&&f.name){if(h=a.get(f.name),!h)throw T3(E1.MATCHER_NOT_FOUND,{location:f});b=h.record.name,y=g1(x7(d.params,h.keys.filter(C=>!C.optional).concat(h.parent?h.parent.keys.filter(C=>C.optional):[]).map(C=>C.name)),f.params&&x7(f.params,h.keys.map(C=>C.name))),x=h.stringify(y)}else if(f.path!=null)x=f.path,h=n.find(C=>C.re.test(x)),h&&(y=h.parse(x),b=h.record.name);else{if(h=d.name?a.get(d.name):n.find(C=>C.re.test(d.path)),!h)throw T3(E1.MATCHER_NOT_FOUND,{location:f,currentLocation:d});b=h.record.name,y=g1({},d.params,f.params),x=h.stringify(y)}const M=[];let g=h;for(;g;)M.unshift(g.record),g=g.parent;return{name:b,path:x,params:y,matched:M,meta:xn(M)}}e.forEach(f=>r(f));function u(){n.length=0,a.clear()}return{addRoute:r,resolve:i,removeRoute:c,clearRoutes:u,getRoutes:s,getRecordMatcher:l}}function x7(e,t){const n={};for(const a of t)a in e&&(n[a]=e[a]);return n}function M7(e){const t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:yn(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,"mods",{value:{}}),t}function yn(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(const a in e.components)t[a]=typeof n=="object"?n[a]:n;return t}function w7(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function xn(e){return e.reduce((t,n)=>g1(t,n.meta),{})}function Mn(e,t){let n=0,a=t.length;for(;n!==a;){const r=n+a>>1;h0(e,t[r])<0?a=r:n=r+1}const l=wn(e);return l&&(a=t.lastIndexOf(l,a-1)),a}function wn(e){let t=e;for(;t=t.parent;)if(m0(t)&&h0(e,t)===0)return t}function m0({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function _7(e){const t=E2(h6),n=E2(m6),a=j1(()=>{const o=I(e.to);return t.resolve(o)}),l=j1(()=>{const{matched:o}=a.value,{length:i}=o,u=o[i-1],f=n.matched;if(!u||!f.length)return-1;const d=f.findIndex(R3.bind(null,u));if(d>-1)return d;const h=Z7(o[i-2]);return i>1&&Z7(u)===h&&f[f.length-1].path!==h?f.findIndex(R3.bind(null,o[i-2])):d}),r=j1(()=>l.value>-1&&An(n.params,a.value.params)),c=j1(()=>l.value>-1&&l.value===n.matched.length-1&&u0(n.params,a.value.params));function s(o={}){if(Cn(o)){const i=t[I(e.replace)?"replace":"push"](I(e.to)).catch(Y3);return e.viewTransition&&typeof document<"u"&&"startViewTransition"in document&&document.startViewTransition(()=>i),i}return Promise.resolve()}return{route:a,href:j1(()=>a.value.href),isActive:r,isExactActive:c,navigate:s}}function _n(e){return e.length===1?e[0]:e}const Zn=l3({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:_7,setup(e,{slots:t}){const n=J4(_7(e)),{options:a}=E2(h6),l=j1(()=>({[k7(e.activeClass,a.linkActiveClass,"router-link-active")]:n.isActive,[k7(e.exactActiveClass,a.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive}));return()=>{const r=t.default&&_n(t.default(n));return e.custom?r:S3("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:l.value},r)}}}),kn=Zn;function Cn(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function An(e,t){for(const n in t){const a=t[n],l=e[n];if(typeof a=="string"){if(a!==l)return!1}else if(!h2(l)||l.length!==a.length||a.some((r,c)=>r.valueOf()!==l[c].valueOf()))return!1}return!0}function Z7(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const k7=(e,t,n)=>e??t??n,Sn=l3({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:n}){const a=E2(U5),l=j1(()=>e.route||a.value),r=E2(g7,0),c=j1(()=>{let i=I(r);const{matched:u}=l.value;let f;for(;(f=u[i])&&!f.components;)i++;return i}),s=j1(()=>l.value.matched[c.value]);C4(g7,j1(()=>c.value+1)),C4(tn,s),C4(U5,l);const o=d1();return R2(()=>[o.value,s.value,e.name],([i,u,f],[d,h,y])=>{u&&(u.instances[f]=i,h&&h!==u&&i&&i===d&&(u.leaveGuards.size||(u.leaveGuards=h.leaveGuards),u.updateGuards.size||(u.updateGuards=h.updateGuards))),i&&u&&(!h||!R3(u,h)||!d)&&(u.enterCallbacks[f]||[]).forEach(x=>x(i))},{flush:"post"}),()=>{const i=l.value,u=e.name,f=s.value,d=f&&f.components[u];if(!d)return C7(n.default,{Component:d,route:i});const h=f.props[u],y=h?h===!0?i.params:typeof h=="function"?h(i):h:null,b=S3(d,g1({},y,t,{onVnodeUnmounted:M=>{M.component.isUnmounted&&(f.instances[u]=null)},ref:o}));return C7(n.default,{Component:b,route:i})||b}}});function C7(e,t){if(!e)return null;const n=e(t);return n.length===1?n[0]:n}const En=Sn;function Rn(e){const t=bn(e.routes,e),n=e.parseQuery||Qt,a=e.stringifyQuery||m7,l=e.history,r=V3(),c=V3(),s=V3(),o=Ze(J2);let i=J2;M3&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=y5.bind(null,k=>""+k),f=y5.bind(null,$t),d=y5.bind(null,s4);function h(k,B){let O,q;return f0(k)?(O=t.getRecordMatcher(k),q=B):q=k,t.addRoute(q,O)}function y(k){const B=t.getRecordMatcher(k);B&&t.removeRoute(B)}function x(){return t.getRoutes().map(k=>k.record)}function b(k){return!!t.getRecordMatcher(k)}function M(k,B){if(B=g1({},B||o.value),typeof k=="string"){const v=x5(n,k,B.path),A=t.resolve({path:v.path},B),S=l.createHref(v.fullPath);return g1(v,A,{params:d(A.params),hash:s4(v.hash),redirectedFrom:void 0,href:S})}let O;if(k.path!=null)O=g1({},k,{path:x5(n,k.path,B.path).path});else{const v=g1({},k.params);for(const A in v)v[A]==null&&delete v[A];O=g1({},k,{params:f(v)}),B.params=f(B.params)}const q=t.resolve(O,B),l1=k.hash||"";q.params=u(d(q.params));const p=Dt(a,g1({},k,{hash:Pt(l1),path:q.path})),m=l.createHref(p);return g1({fullPath:p,hash:l1,query:a===m7?en(k.query):k.query||{}},q,{redirectedFrom:void 0,href:m})}function g(k){return typeof k=="string"?x5(n,k,o.value.path):g1({},k)}function C(k,B){if(i!==k)return T3(E1.NAVIGATION_CANCELLED,{from:B,to:k})}function _(k){return $(k)}function H(k){return _(g1(g(k),{replace:!0}))}function F(k,B){const O=k.matched[k.matched.length-1];if(O&&O.redirect){const{redirect:q}=O;let l1=typeof q=="function"?q(k,B):q;return typeof l1=="string"&&(l1=l1.includes("?")||l1.includes("#")?l1=g(l1):{path:l1},l1.params={}),g1({query:k.query,hash:k.hash,params:l1.path!=null?{}:k.params},l1)}}function $(k,B){const O=i=M(k),q=o.value,l1=k.state,p=k.force,m=k.replace===!0,v=F(O,q);if(v)return $(g1(g(v),{state:typeof v=="object"?g1({},l1,v.state):l1,force:p,replace:m}),B||O);const A=O;A.redirectedFrom=B;let S;return!p&&jt(a,q,O)&&(S=T3(E1.NAVIGATION_DUPLICATED,{to:A,from:q}),e2(q,q,!0,!1)),(S?Promise.resolve(S):t1(A,q)).catch(Z=>$2(Z)?$2(Z,E1.NAVIGATION_GUARD_REDIRECT)?Z:K(Z):i1(Z,A,q)).then(Z=>{if(Z){if($2(Z,E1.NAVIGATION_GUARD_REDIRECT))return $(g1({replace:m},g(Z.to),{state:typeof Z.to=="object"?g1({},l1,Z.to.state):l1,force:p}),B||A)}else Z=D(A,q,!0,m,l1);return s1(A,q,Z),Z})}function R(k,B){const O=C(k,B);return O?Promise.reject(O):Promise.resolve()}function N(k){const B=m2.values().next().value;return B&&typeof B.runWithContext=="function"?B.runWithContext(k):k()}function t1(k,B){let O;const[q,l1,p]=nn(k,B);O=w5(q.reverse(),"beforeRouteLeave",k,B);for(const v of q)v.leaveGuards.forEach(A=>{O.push(e3(A,k,B))});const m=R.bind(null,k,B);return O.push(m),x1(O).then(()=>{O=[];for(const v of r.list())O.push(e3(v,k,B));return O.push(m),x1(O)}).then(()=>{O=w5(l1,"beforeRouteUpdate",k,B);for(const v of l1)v.updateGuards.forEach(A=>{O.push(e3(A,k,B))});return O.push(m),x1(O)}).then(()=>{O=[];for(const v of p)if(v.beforeEnter)if(h2(v.beforeEnter))for(const A of v.beforeEnter)O.push(e3(A,k,B));else O.push(e3(v.beforeEnter,k,B));return O.push(m),x1(O)}).then(()=>(k.matched.forEach(v=>v.enterCallbacks={}),O=w5(p,"beforeRouteEnter",k,B,N),O.push(m),x1(O))).then(()=>{O=[];for(const v of c.list())O.push(e3(v,k,B));return O.push(m),x1(O)}).catch(v=>$2(v,E1.NAVIGATION_CANCELLED)?v:Promise.reject(v))}function s1(k,B,O){s.list().forEach(q=>N(()=>q(k,B,O)))}function D(k,B,O,q,l1){const p=C(k,B);if(p)return p;const m=B===J2,v=M3?history.state:{};O&&(q||m?l.replace(k.fullPath,g1({scroll:m&&v&&v.scroll},l1)):l.push(k.fullPath,l1)),o.value=k,e2(k,B,O,m),K()}let o1;function k1(){o1||(o1=l.listen((k,B,O)=>{if(!S1.listening)return;const q=M(k),l1=F(q,S1.currentRoute.value);if(l1){$(g1(l1,{replace:!0,force:!0}),q).catch(Y3);return}i=q;const p=o.value;M3&&Kt(h7(p.fullPath,O.delta),r5()),t1(q,p).catch(m=>$2(m,E1.NAVIGATION_ABORTED|E1.NAVIGATION_CANCELLED)?m:$2(m,E1.NAVIGATION_GUARD_REDIRECT)?($(g1(g(m.to),{force:!0}),q).then(v=>{$2(v,E1.NAVIGATION_ABORTED|E1.NAVIGATION_DUPLICATED)&&!O.delta&&O.type===H5.pop&&l.go(-1,!1)}).catch(Y3),Promise.reject()):(O.delta&&l.go(-O.delta,!1),i1(m,q,p))).then(m=>{m=m||D(q,p,!1),m&&(O.delta&&!$2(m,E1.NAVIGATION_CANCELLED)?l.go(-O.delta,!1):O.type===H5.pop&&$2(m,E1.NAVIGATION_ABORTED|E1.NAVIGATION_DUPLICATED)&&l.go(-1,!1)),s1(q,p,m)}).catch(Y3)}))}let R1=V3(),u1=V3(),c1;function i1(k,B,O){K(k);const q=u1.list();return q.length?q.forEach(l1=>l1(k,B,O)):console.error(k),Promise.reject(k)}function Q1(){return c1&&o.value!==J2?Promise.resolve():new Promise((k,B)=>{R1.add([k,B])})}function K(k){return c1||(c1=!k,k1(),R1.list().forEach(([B,O])=>k?O(k):B()),R1.reset()),k}function e2(k,B,O,q){const{scrollBehavior:l1}=e;if(!M3||!l1)return Promise.resolve();const p=!O&&qt(h7(k.fullPath,0))||(q||!O)&&history.state&&history.state.scroll||null;return c6().then(()=>l1(k,B,p)).then(m=>m&&Wt(m)).catch(m=>i1(m,k,B))}const N1=k=>l.go(k);let P2;const m2=new Set,S1={currentRoute:o,listening:!0,addRoute:h,removeRoute:y,clearRoutes:t.clearRoutes,hasRoute:b,getRoutes:x,resolve:M,options:e,push:_,replace:H,go:N1,back:()=>N1(-1),forward:()=>N1(1),beforeEach:r.add,beforeResolve:c.add,afterEach:s.add,onError:u1.add,isReady:Q1,install(k){k.component("RouterLink",kn),k.component("RouterView",En),k.config.globalProperties.$router=S1,Object.defineProperty(k.config.globalProperties,"$route",{enumerable:!0,get:()=>I(o)}),M3&&!P2&&o.value===J2&&(P2=!0,_(l.location).catch(q=>{}));const B={};for(const q in J2)Object.defineProperty(B,q,{get:()=>o.value[q],enumerable:!0});k.provide(h6,S1),k.provide(m6,f8(B)),k.provide(U5,o);const O=k.unmount;m2.add(k),k.unmount=function(){m2.delete(k),m2.size<1&&(i=J2,o1&&o1(),o1=null,o.value=J2,P2=!1,c1=!1),O()}}};function x1(k){return k.reduce((B,O)=>B.then(()=>N(O)),Promise.resolve())}return S1}function Tn(e){return E2(m6)}/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const On=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const A7=e=>e==="";/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pn=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim();/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const S7=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const In=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase());/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ln=e=>{const t=In(e);return t.charAt(0).toUpperCase()+t.slice(1)};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var D3={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $n=({name:e,iconNode:t,absoluteStrokeWidth:n,"absolute-stroke-width":a,strokeWidth:l,"stroke-width":r,size:c=D3.width,color:s=D3.stroke,...o},{slots:i})=>S3("svg",{...D3,...o,width:c,height:c,stroke:s,"stroke-width":A7(n)||A7(a)||n===!0||a===!0?Number(l||r||D3["stroke-width"])*24/Number(c):l||r||D3["stroke-width"],class:Pn("lucide",o.class,...e?[`lucide-${S7(Ln(e))}-icon`,`lucide-${S7(e)}`]:["lucide-icon"]),...!i.default&&!On(o)&&{"aria-hidden":"true"}},[...t.map(u=>S3(...u)),...i.default?[i.default()]:[]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const L1=(e,t)=>(n,{slots:a,attrs:l})=>S3($n,{...l,...n,iconNode:t,name:e},a);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const g0=L1("boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Nn=L1("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vn=L1("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const v0=L1("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const g6=L1("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const b0=L1("layout-dashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const D4=L1("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dn=L1("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const y0=L1("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jn=L1("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const x0=L1("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const M0=L1("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fn=L1("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const O3=L1("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zn=L1("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const G5=L1("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const w0=L1("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _0=L1("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/** + * @license lucide-vue-next v0.563.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const v6=L1("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function u2(e){return e.replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(//g,">")}function Hn(e){var t,n,a,l,r,c,s;const o=(t=e.meta)===null||t===void 0?void 0:t.title,i=(n=e.meta)===null||n===void 0?void 0:n.creator,u=(a=e.meta)===null||a===void 0?void 0:a.source,f=(r=(l=e.meta)===null||l===void 0?void 0:l.license)===null||r===void 0?void 0:r.url,d=Bn(e);return!o&&!i&&!u&&!f&&!d?"":''+(o?`${u2(o)}`:"")+(i?`${u2(i)}`:"")+(u?`${u2((s=(c=e.meta)===null||c===void 0?void 0:c.source)!==null&&s!==void 0?s:"")}`:"")+(f?`${u2(f)}`:"")+(d?`${u2(d)}`:"")+""}function Bn(e){var t,n,a,l,r,c,s,o,i,u,f,d,h,y,x;let b=!((t=e.meta)===null||t===void 0)&&t.title?`„${(n=e.meta)===null||n===void 0?void 0:n.title}”`:"Design",M=`„${(l=(a=e.meta)===null||a===void 0?void 0:a.creator)!==null&&l!==void 0?l:"Unknown"}”`;!((r=e.meta)===null||r===void 0)&&r.source&&(b+=` (${e.meta.source})`);let g="";return((s=(c=e.meta)===null||c===void 0?void 0:c.license)===null||s===void 0?void 0:s.name)!=="MIT"&&((o=e.meta)===null||o===void 0?void 0:o.creator)!=="DiceBear"&&(!((i=e.meta)===null||i===void 0)&&i.title)&&(g+="Remix of "),g+=`${b} by ${M}`,!((f=(u=e.meta)===null||u===void 0?void 0:u.license)===null||f===void 0)&&f.name&&(g+=`, licensed under „${(h=(d=e.meta)===null||d===void 0?void 0:d.license)===null||h===void 0?void 0:h.name}”`,!((x=(y=e.meta)===null||y===void 0?void 0:y.license)===null||x===void 0)&&x.url&&(g+=` (${e.meta.license.url})`)),g}const E7=-2147483648,Un=2147483647,Gn=1024;function Z0(e){return e^=e<<13,e^=e>>17,e^=e<<5,e}function Wn(e){let t=0;for(let n=0;nt=Z0(t),a=(l,r)=>Math.floor((n()-E7)/(Un-E7)*(r+1-l)+l);return{seed:e,next:n,bool(l=50){return a(1,100)<=l},integer(l,r){return a(l,r)},pick(l,r){var c;return l.length===0?(n(),r):(c=l[a(0,l.length-1)])!==null&&c!==void 0?c:r},shuffle(l){const r=j4(n().toString()),c=[...l];for(let s=c.length-1;s>0;s--){const o=r.integer(0,s);[c[s],c[o]]=[c[o],c[s]]}return c},string(l,r="abcdefghijklmnopqrstuvwxyz1234567890"){const c=j4(n().toString());let s="";for(let o=0;o`;switch(a){case"solid":return i+e.body;case"gradientLinear":return``+e.body}}function qn(e,t){let{width:n,height:a,x:l,y:r}=P3(e),c=t?(t-100)/100:0,s=(n/2+l)*c*-1,o=(a/2+r)*c*-1;return`${e.body}`}function Jn(e,t,n){let a=P3(e),l=(a.width+a.x*2)*((t??0)/100),r=(a.height+a.y*2)*((n??0)/100);return`${e.body}`}function Yn(e,t){let{width:n,height:a,x:l,y:r}=P3(e);return`${e.body}`}function Xn(e){let{width:t,x:n}=P3(e);return`${e.body}`}function Qn(e,t){let{width:n,height:a,x:l,y:r}=P3(e),c=t?n*t/100:0,s=t?a*t/100:0;return`${e.body}`}function ea(e){const t={xmlns:"http://www.w3.org/2000/svg",...e.attributes};return Object.keys(t).map(n=>`${u2(n)}="${u2(t[n])}"`).join(" ")}function ta(e){const t=j4(Math.random().toString()),n={};return e.body.replace(/(id="|url\(#)([a-z0-9-_]+)([")])/gi,(a,l,r,c)=>(n[r]=n[r]||t.string(8),`${l}${n[r]}${c}`))}const na={properties:{seed:{type:"string"},flip:{type:"boolean",default:!1},rotate:{type:"integer",minimum:0,maximum:360,default:0},scale:{type:"integer",minimum:0,maximum:200,default:100},radius:{type:"integer",minimum:0,maximum:50,default:0},size:{type:"integer",minimum:1},backgroundColor:{type:"array",items:{type:"string",pattern:"^(transparent|[a-fA-F0-9]{6})$"}},backgroundType:{type:"array",items:{type:"string",enum:["solid","gradientLinear"]},default:["solid"]},backgroundRotation:{type:"array",items:{type:"integer",minimum:-360,maximum:360},default:[0,360]},translateX:{type:"integer",minimum:-100,maximum:100,default:0},translateY:{type:"integer",minimum:-100,maximum:100,default:0},clip:{type:"boolean",default:!0},randomizeIds:{type:"boolean",default:!1}}};function R7(e){var t;let n={},a=(t=e.properties)!==null&&t!==void 0?t:{};return Object.keys(a).forEach(l=>{let r=a[l];typeof r=="object"&&r.default!==void 0&&(Array.isArray(r.default)?n[l]=[...r.default]:typeof r.default=="object"?n[l]={...r.default}:n[l]=r.default)}),n}function aa(e,t){var n;let a={...R7(na),...R7((n=e.schema)!==null&&n!==void 0?n:{}),...t};return JSON.parse(JSON.stringify(a))}function T7(e){return e==="transparent"?e:`#${e}`}function la(e,t,n){var a;let l=e.shuffle(t);l.length<=1||t.length==2&&n=="gradientLinear"?(l=t,e.next()):l=e.shuffle(t),l.length===0&&(l=["transparent"]);const r=l[0],c=(a=l[1])!==null&&a!==void 0?a:l[0];return{primary:T7(r),secondary:T7(c)}}function ra(e,t={}){var n,a,l,r,c;t=aa(e,t);const s=j4(t.seed),o=e.create({prng:s,options:t}),i=s.pick((n=t.backgroundType)!==null&&n!==void 0?n:[],"solid"),{primary:u,secondary:f}=la(s,(a=t.backgroundColor)!==null&&a!==void 0?a:[],i),d=s.integer(!((l=t.backgroundRotation)===null||l===void 0)&&l.length?Math.min(...t.backgroundRotation):0,!((r=t.backgroundRotation)===null||r===void 0)&&r.length?Math.max(...t.backgroundRotation):0);t.size&&(o.attributes.width=t.size.toString(),o.attributes.height=t.size.toString()),t.scale!==void 0&&t.scale!==100&&(o.body=qn(o,t.scale)),t.flip&&(o.body=Xn(o)),t.rotate&&(o.body=Yn(o,t.rotate)),(t.translateX||t.translateY)&&(o.body=Jn(o,t.translateX,t.translateY)),u!=="transparent"&&f!=="transparent"&&(o.body=Kn(o,u,f,i,d)),(t.radius||t.clip)&&(o.body=Qn(o,(c=t.radius)!==null&&c!==void 0?c:0)),t.randomizeIds&&(o.body=ta(o));const h=ea(o),y=Hn(e),x=`${y}${o.body}`;return{toString:()=>x,toJson:()=>{var b;return{svg:x,extra:{primaryBackgroundColor:u,secondaryBackgroundColor:f,backgroundType:i,backgroundRotation:d,...(b=o.extra)===null||b===void 0?void 0:b.call(o)}}},toDataUri:()=>`data:image/svg+xml;utf8,${encodeURIComponent(x)}`}}const ca={variant01:(e,t)=>''},oa={variant25:(e,t)=>'',variant24:(e,t)=>'',variant23:(e,t)=>'',variant22:(e,t)=>'',variant21:(e,t)=>'',variant20:(e,t)=>'',variant19:(e,t)=>'',variant18:(e,t)=>'',variant17:(e,t)=>'',variant16:(e,t)=>'',variant15:(e,t)=>'',variant14:(e,t)=>'',variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant09:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant08:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant07:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant06:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant05:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant04:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant03:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant02:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`},variant01:(e,t)=>{var n,a;return`${(a=(n=e.bodyIcon)===null||n===void 0?void 0:n.value(e,t))!==null&&a!==void 0?a:""}`}},sa={variant63:(e,t)=>'',variant62:(e,t)=>'',variant61:(e,t)=>'',variant60:(e,t)=>'',variant59:(e,t)=>'',variant58:(e,t)=>'',variant57:(e,t)=>'',variant56:(e,t)=>'',variant55:(e,t)=>'',variant54:(e,t)=>'',variant53:(e,t)=>'',variant52:(e,t)=>'',variant51:(e,t)=>'',variant50:(e,t)=>'',variant49:(e,t)=>'',variant48:(e,t)=>'',variant47:(e,t)=>'',variant46:(e,t)=>'',variant45:(e,t)=>'',variant44:(e,t)=>'',variant43:(e,t)=>'',variant42:(e,t)=>'',variant41:(e,t)=>'',variant40:(e,t)=>'',variant39:(e,t)=>'',variant38:(e,t)=>'',variant37:(e,t)=>'',variant36:(e,t)=>'',variant35:(e,t)=>'',variant34:(e,t)=>'',variant33:(e,t)=>'',variant32:(e,t)=>'',variant31:(e,t)=>'',variant30:(e,t)=>'',variant29:(e,t)=>'',variant28:(e,t)=>'',variant27:(e,t)=>'',variant26:(e,t)=>'',variant25:(e,t)=>'',variant24:(e,t)=>'',variant23:(e,t)=>'',variant22:(e,t)=>'',variant21:(e,t)=>'',variant20:(e,t)=>'',variant19:(e,t)=>'',variant18:(e,t)=>'',variant17:(e,t)=>'',variant16:(e,t)=>'',variant15:(e,t)=>'',variant14:(e,t)=>'',variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>'',hat:(e,t)=>''},ia={variant30:(e,t)=>'',variant29:(e,t)=>'',variant28:(e,t)=>'',variant27:(e,t)=>'',variant26:(e,t)=>'',variant25:(e,t)=>'',variant24:(e,t)=>'',variant23:(e,t)=>'',variant22:(e,t)=>'',variant21:(e,t)=>'',variant20:(e,t)=>'',variant19:(e,t)=>'',variant18:(e,t)=>'',variant17:(e,t)=>'',variant16:(e,t)=>'',variant15:(e,t)=>'',variant14:(e,t)=>'',variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},ua={variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},fa={variant20:(e,t)=>'',variant19:(e,t)=>'',variant18:(e,t)=>'',variant17:(e,t)=>'',variant16:(e,t)=>'',variant15:(e,t)=>'',variant14:(e,t)=>'',variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},da={variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},pa={variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},ha={variant13:(e,t)=>'',variant12:(e,t)=>'',variant11:(e,t)=>'',variant10:(e,t)=>'',variant09:(e,t)=>'',variant08:(e,t)=>'',variant07:(e,t)=>'',variant06:(e,t)=>'',variant05:(e,t)=>'',variant04:(e,t)=>'',variant03:(e,t)=>'',variant02:(e,t)=>'',variant01:(e,t)=>''},ma={wavePointLongArms:(e,t)=>'',waveOkLongArms:(e,t)=>'',waveLongArms:(e,t)=>'',waveLongArm:(e,t)=>'',pointLongArm:(e,t)=>'',okLongArm:(e,t)=>'',point:(e,t)=>'',ok:(e,t)=>'',hand:(e,t)=>'',handPhone:(e,t)=>''},ga={electric:(e,t)=>'',saturn:(e,t)=>'',galaxy:(e,t)=>''},va=Object.freeze(Object.defineProperty({__proto__:null,base:ca,beard:ua,body:oa,bodyIcon:ga,brows:ha,eyes:da,gesture:ma,glasses:pa,hair:sa,lips:ia,nose:fa},Symbol.toStringTag,{value:"Module"}));function s2({prng:e,group:t,values:n=[]}){const a=va,l=e.pick(n);if(l&&a[t][l])return{name:l,value:a[t][l]}}function ba({prng:e,options:t}){const n=s2({prng:e,group:"base",values:t.base}),a=s2({prng:e,group:"body",values:t.body}),l=s2({prng:e,group:"hair",values:t.hair}),r=s2({prng:e,group:"lips",values:t.lips}),c=s2({prng:e,group:"beard",values:t.beard}),s=s2({prng:e,group:"nose",values:t.nose}),o=s2({prng:e,group:"eyes",values:t.eyes}),i=s2({prng:e,group:"glasses",values:t.glasses}),u=s2({prng:e,group:"brows",values:t.brows}),f=s2({prng:e,group:"gesture",values:t.gesture}),d=s2({prng:e,group:"bodyIcon",values:t.bodyIcon});return{base:n,body:a,hair:l,lips:r,beard:e.bool(t.beardProbability)?c:void 0,nose:s,eyes:o,glasses:e.bool(t.glassesProbability)?i:void 0,brows:u,gesture:e.bool(t.gestureProbability)?f:void 0,bodyIcon:e.bool(t.bodyIconProbability)?d:void 0}}function ya({prng:e,options:t}){return{}}const xa={$schema:"http://json-schema.org/draft-07/schema#",properties:{base:{type:"array",items:{type:"string",enum:["variant01"]},default:["variant01"]},beard:{type:"array",items:{type:"string",enum:["variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},beardProbability:{type:"integer",minimum:0,maximum:100,default:10},body:{type:"array",items:{type:"string",enum:["variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},bodyIcon:{type:"array",items:{type:"string",enum:["electric","saturn","galaxy"]},default:["electric","saturn","galaxy"]},bodyIconProbability:{type:"integer",minimum:0,maximum:100,default:75},brows:{type:"array",items:{type:"string",enum:["variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},eyes:{type:"array",items:{type:"string",enum:["variant05","variant04","variant03","variant02","variant01"]},default:["variant05","variant04","variant03","variant02","variant01"]},gesture:{type:"array",items:{type:"string",enum:["wavePointLongArms","waveOkLongArms","waveLongArms","waveLongArm","pointLongArm","okLongArm","point","ok","hand","handPhone"]},default:["wavePointLongArms","waveOkLongArms","waveLongArms","waveLongArm","pointLongArm","okLongArm","point","ok","hand","handPhone"]},gestureProbability:{type:"integer",minimum:0,maximum:100,default:10},glasses:{type:"array",items:{type:"string",enum:["variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},glassesProbability:{type:"integer",minimum:0,maximum:100,default:20},hair:{type:"array",items:{type:"string",enum:["variant63","variant62","variant61","variant60","variant59","variant58","variant57","variant56","variant55","variant54","variant53","variant52","variant51","variant50","variant49","variant48","variant47","variant46","variant45","variant44","variant43","variant42","variant41","variant40","variant39","variant38","variant37","variant36","variant35","variant34","variant33","variant32","variant31","variant30","variant29","variant28","variant27","variant26","variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01","hat"]},default:["variant63","variant62","variant61","variant60","variant59","variant58","variant57","variant56","variant55","variant54","variant53","variant52","variant51","variant50","variant49","variant48","variant47","variant46","variant45","variant44","variant43","variant42","variant41","variant40","variant39","variant38","variant37","variant36","variant35","variant34","variant33","variant32","variant31","variant30","variant29","variant28","variant27","variant26","variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01","hat"]},lips:{type:"array",items:{type:"string",enum:["variant30","variant29","variant28","variant27","variant26","variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant30","variant29","variant28","variant27","variant26","variant25","variant24","variant23","variant22","variant21","variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},nose:{type:"array",items:{type:"string",enum:["variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]},default:["variant20","variant19","variant18","variant17","variant16","variant15","variant14","variant13","variant12","variant11","variant10","variant09","variant08","variant07","variant06","variant05","variant04","variant03","variant02","variant01"]}}},Ma={title:"Notionists",creator:"Zoish",source:"https://heyzoish.gumroad.com/l/notionists",homepage:"https://bio.link/heyzoish",license:{name:"CC0 1.0",url:"https://creativecommons.org/publicdomain/zero/1.0/"}},wa=({prng:e,options:t})=>{var n,a,l,r,c,s,o,i,u,f,d,h,y,x,b,M,g,C,_,H;const F=ba({prng:e,options:t}),$=ya({prng:e,options:t});return{attributes:{viewBox:"0 0 1744 1744",fill:"none","shape-rendering":"auto"},body:`${(a=(n=F.base)===null||n===void 0?void 0:n.value(F,$))!==null&&a!==void 0?a:""}${(r=(l=F.body)===null||l===void 0?void 0:l.value(F,$))!==null&&r!==void 0?r:""}${(s=(c=F.hair)===null||c===void 0?void 0:c.value(F,$))!==null&&s!==void 0?s:""}${(i=(o=F.lips)===null||o===void 0?void 0:o.value(F,$))!==null&&i!==void 0?i:""}${(f=(u=F.beard)===null||u===void 0?void 0:u.value(F,$))!==null&&f!==void 0?f:""}${(h=(d=F.nose)===null||d===void 0?void 0:d.value(F,$))!==null&&h!==void 0?h:""}${(x=(y=F.eyes)===null||y===void 0?void 0:y.value(F,$))!==null&&x!==void 0?x:""}${(M=(b=F.glasses)===null||b===void 0?void 0:b.value(F,$))!==null&&M!==void 0?M:""}${(C=(g=F.brows)===null||g===void 0?void 0:g.value(F,$))!==null&&C!==void 0?C:""}${(H=(_=F.gesture)===null||_===void 0?void 0:_.value(F,$))!==null&&H!==void 0?H:""}`,extra:()=>({...Object.entries(F).reduce((R,[N,t1])=>(R[N]=t1==null?void 0:t1.name,R),{}),...Object.entries($).reduce((R,[N,t1])=>(R[`${N}Color`]=t1,R),{})})}},_a=Object.freeze(Object.defineProperty({__proto__:null,create:wa,meta:Ma,schema:xa},Symbol.toStringTag,{value:"Module"})),Za={class:"flex items-center gap-2.5"},ka=l3({__name:"Logo",props:{size:{default:"md"},showText:{type:Boolean,default:!0}},setup(e){const t={sm:"h-7 w-7 min-h-7 min-w-7",md:"h-8 w-8 min-h-8 min-w-8",lg:"h-10 w-10 min-h-10 min-w-10"},n={sm:"text-base",md:"text-lg",lg:"text-xl"};return(a,l)=>(T(),W("div",Za,[w("div",{class:X1([t[e.size],"relative flex-shrink-0"])},[...l[0]||(l[0]=[S9('',1)])],2),e.showText?(T(),W("span",{key:0,class:X1([n[e.size],"font-semibold tracking-tight"])},[...l[1]||(l[1]=[w("span",{class:"text-brand"},"Source",-1),w("span",{class:"text-brand"},"Ant",-1),w("span",{class:"text-muted-foreground font-normal ml-1"},"Memory",-1)])],2)):w1("",!0)]))}});function k0(e){var t,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t{const n=new Array(e.length+t.length);for(let a=0;a({classGroupId:e,validator:t}),A0=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),F4="-",O7=[],Sa="arbitrary..",Ea=e=>{const t=Ta(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return Ra(c);const s=c.split(F4),o=s[0]===""&&s.length>1?1:0;return S0(s,o,t)},getConflictingClassGroupIds:(c,s)=>{if(s){const o=a[c],i=n[c];return o?i?Ca(i,o):o:i||O7}return n[c]||O7}}},S0=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const l=e[t],r=n.nextPart.get(l);if(r){const i=S0(e,t+1,r);if(i)return i}const c=n.validators;if(c===null)return;const s=t===0?e.join(F4):e.slice(t).join(F4),o=c.length;for(let i=0;ie.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),a=t.slice(0,n);return a?Sa+a:void 0})(),Ta=e=>{const{theme:t,classGroups:n}=e;return Oa(n,t)},Oa=(e,t)=>{const n=A0();for(const a in e){const l=e[a];b6(l,n,a,t)}return n},b6=(e,t,n,a)=>{const l=e.length;for(let r=0;r{if(typeof e=="string"){Ia(e,t,n);return}if(typeof e=="function"){La(e,t,n,a);return}$a(e,t,n,a)},Ia=(e,t,n)=>{const a=e===""?t:E0(t,e);a.classGroupId=n},La=(e,t,n,a)=>{if(Na(e)){b6(e(a),t,n,a);return}t.validators===null&&(t.validators=[]),t.validators.push(Aa(n,e))},$a=(e,t,n,a)=>{const l=Object.entries(e),r=l.length;for(let c=0;c{let n=e;const a=t.split(F4),l=a.length;for(let r=0;r"isThemeGetter"in e&&e.isThemeGetter===!0,Va=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),a=Object.create(null);const l=(r,c)=>{n[r]=c,t++,t>e&&(t=0,a=n,n=Object.create(null))};return{get(r){let c=n[r];if(c!==void 0)return c;if((c=a[r])!==void 0)return l(r,c),c},set(r,c){r in n?n[r]=c:l(r,c)}}},W5="!",P7=":",Da=[],I7=(e,t,n,a,l)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:a,isExternal:l}),ja=e=>{const{prefix:t,experimentalParseClassName:n}=e;let a=l=>{const r=[];let c=0,s=0,o=0,i;const u=l.length;for(let x=0;xo?i-o:void 0;return I7(r,h,d,y)};if(t){const l=t+P7,r=a;a=c=>c.startsWith(l)?r(c.slice(l.length)):I7(Da,!1,c,void 0,!0)}if(n){const l=a;a=r=>n({className:r,parseClassName:l})}return a},Fa=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{t.set(n,1e6+a)}),n=>{const a=[];let l=[];for(let r=0;r0&&(l.sort(),a.push(...l),l=[]),a.push(c)):l.push(c)}return l.length>0&&(l.sort(),a.push(...l)),a}},za=e=>({cache:Va(e.cacheSize),parseClassName:ja(e),sortModifiers:Fa(e),postfixLookupClassGroupIds:Ha(e),...Ea(e)}),Ha=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let a=0;a{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:l,sortModifiers:r,postfixLookupClassGroupIds:c}=t,s=[],o=e.trim().split(Ba);let i="";for(let u=o.length-1;u>=0;u-=1){const f=o[u],{isExternal:d,modifiers:h,hasImportantModifier:y,baseClassName:x,maybePostfixModifierPosition:b}=n(f);if(d){i=f+(i.length>0?" "+i:i);continue}let M=!!b,g;if(M){const $=x.substring(0,b);g=a($);const R=g&&c[g]?a(x):void 0;R&&R!==g&&(g=R,M=!1)}else g=a(x);if(!g){if(!M){i=f+(i.length>0?" "+i:i);continue}if(g=a(x),!g){i=f+(i.length>0?" "+i:i);continue}M=!1}const C=h.length===0?"":h.length===1?h[0]:r(h).join(":"),_=y?C+W5:C,H=_+g;if(s.indexOf(H)>-1)continue;s.push(H);const F=l(g,M);for(let $=0;$0?" "+i:i)}return i},Ga=(...e)=>{let t=0,n,a,l="";for(;t{if(typeof e=="string")return e;let t,n="";for(let a=0;a{let n,a,l,r;const c=o=>{const i=t.reduce((u,f)=>f(u),e());return n=za(i),a=n.cache.get,l=n.cache.set,r=s,s(o)},s=o=>{const i=a(o);if(i)return i;const u=Ua(o,n);return l(o,u),u};return r=c,(...o)=>r(Ga(...o))},Ka=[],O1=e=>{const t=n=>n[e]||Ka;return t.isThemeGetter=!0,t},T0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,O0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,qa=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ja=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ya=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Xa=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Qa=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,el=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Y2=e=>qa.test(e),r1=e=>!!e&&!Number.isNaN(Number(e)),x2=e=>!!e&&Number.isInteger(Number(e)),_5=e=>e.endsWith("%")&&r1(e.slice(0,-1)),N2=e=>Ja.test(e),P0=()=>!0,tl=e=>Ya.test(e)&&!Xa.test(e),y6=()=>!1,nl=e=>Qa.test(e),al=e=>el.test(e),ll=e=>!U(e)&&!G(e),rl=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),cl=e=>r3(e,$0,y6),U=e=>T0.test(e),u3=e=>r3(e,N0,tl),L7=e=>r3(e,hl,r1),ol=e=>r3(e,D0,P0),sl=e=>r3(e,V0,y6),$7=e=>r3(e,I0,y6),il=e=>r3(e,L0,al),_4=e=>r3(e,j0,nl),G=e=>O0.test(e),j3=e=>b3(e,N0),ul=e=>b3(e,V0),N7=e=>b3(e,I0),fl=e=>b3(e,$0),dl=e=>b3(e,L0),Z4=e=>b3(e,j0,!0),pl=e=>b3(e,D0,!0),r3=(e,t,n)=>{const a=T0.exec(e);return a?a[1]?t(a[1]):n(a[2]):!1},b3=(e,t,n=!1)=>{const a=O0.exec(e);return a?a[1]?t(a[1]):n:!1},I0=e=>e==="position"||e==="percentage",L0=e=>e==="image"||e==="url",$0=e=>e==="length"||e==="size"||e==="bg-size",N0=e=>e==="length",hl=e=>e==="number",V0=e=>e==="family-name",D0=e=>e==="number"||e==="weight",j0=e=>e==="shadow",ml=()=>{const e=O1("color"),t=O1("font"),n=O1("text"),a=O1("font-weight"),l=O1("tracking"),r=O1("leading"),c=O1("breakpoint"),s=O1("container"),o=O1("spacing"),i=O1("radius"),u=O1("shadow"),f=O1("inset-shadow"),d=O1("text-shadow"),h=O1("drop-shadow"),y=O1("blur"),x=O1("perspective"),b=O1("aspect"),M=O1("ease"),g=O1("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],H=()=>[..._(),G,U],F=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto","contain","none"],R=()=>[G,U,o],N=()=>[Y2,"full","auto",...R()],t1=()=>[x2,"none","subgrid",G,U],s1=()=>["auto",{span:["full",x2,G,U]},x2,G,U],D=()=>[x2,"auto",G,U],o1=()=>["auto","min","max","fr",G,U],k1=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R1=()=>["start","end","center","stretch","center-safe","end-safe"],u1=()=>["auto",...R()],c1=()=>[Y2,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],i1=()=>[Y2,"screen","full","dvw","lvw","svw","min","max","fit",...R()],Q1=()=>[Y2,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],K=()=>[e,G,U],e2=()=>[..._(),N7,$7,{position:[G,U]}],N1=()=>["no-repeat",{repeat:["","x","y","space","round"]}],P2=()=>["auto","cover","contain",fl,cl,{size:[G,U]}],m2=()=>[_5,j3,u3],S1=()=>["","none","full",i,G,U],x1=()=>["",r1,j3,u3],k=()=>["solid","dashed","dotted","double"],B=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],O=()=>[r1,_5,N7,$7],q=()=>["","none",y,G,U],l1=()=>["none",r1,G,U],p=()=>["none",r1,G,U],m=()=>[r1,G,U],v=()=>[Y2,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[N2],breakpoint:[N2],color:[P0],container:[N2],"drop-shadow":[N2],ease:["in","out","in-out"],font:[ll],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[N2],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[N2],shadow:[N2],spacing:["px",r1],text:[N2],"text-shadow":[N2],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Y2,U,G,b]}],container:["container"],"container-type":[{"@container":["","normal","size",G,U]}],"container-named":[rl],columns:[{columns:[r1,U,G,s]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:H()}],overflow:[{overflow:F()}],"overflow-x":[{"overflow-x":F()}],"overflow-y":[{"overflow-y":F()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{"inset-s":N(),start:N()}],end:[{"inset-e":N(),end:N()}],"inset-bs":[{"inset-bs":N()}],"inset-be":[{"inset-be":N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[x2,"auto",G,U]}],basis:[{basis:[Y2,"full","auto",s,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[r1,Y2,"auto","initial","none",U]}],grow:[{grow:["",r1,G,U]}],shrink:[{shrink:["",r1,G,U]}],order:[{order:[x2,"first","last","none",G,U]}],"grid-cols":[{"grid-cols":t1()}],"col-start-end":[{col:s1()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":t1()}],"row-start-end":[{row:s1()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":o1()}],"auto-rows":[{"auto-rows":o1()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...k1(),"normal"]}],"justify-items":[{"justify-items":[...R1(),"normal"]}],"justify-self":[{"justify-self":["auto",...R1()]}],"align-content":[{content:["normal",...k1()]}],"align-items":[{items:[...R1(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R1(),{baseline:["","last"]}]}],"place-content":[{"place-content":k1()}],"place-items":[{"place-items":[...R1(),"baseline"]}],"place-self":[{"place-self":["auto",...R1()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:u1()}],mx:[{mx:u1()}],my:[{my:u1()}],ms:[{ms:u1()}],me:[{me:u1()}],mbs:[{mbs:u1()}],mbe:[{mbe:u1()}],mt:[{mt:u1()}],mr:[{mr:u1()}],mb:[{mb:u1()}],ml:[{ml:u1()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:c1()}],"inline-size":[{inline:["auto",...i1()]}],"min-inline-size":[{"min-inline":["auto",...i1()]}],"max-inline-size":[{"max-inline":["none",...i1()]}],"block-size":[{block:["auto",...Q1()]}],"min-block-size":[{"min-block":["auto",...Q1()]}],"max-block-size":[{"max-block":["none",...Q1()]}],w:[{w:[s,"screen",...c1()]}],"min-w":[{"min-w":[s,"screen","none",...c1()]}],"max-w":[{"max-w":[s,"screen","none","prose",{screen:[c]},...c1()]}],h:[{h:["screen","lh",...c1()]}],"min-h":[{"min-h":["screen","lh","none",...c1()]}],"max-h":[{"max-h":["screen","lh",...c1()]}],"font-size":[{text:["base",n,j3,u3]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,pl,ol]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",_5,U]}],"font-family":[{font:[ul,sl,t]}],"font-features":[{"font-features":[U]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[l,G,U]}],"line-clamp":[{"line-clamp":[r1,"none",G,L7]}],leading:[{leading:[r,...R()]}],"list-image":[{"list-image":["none",G,U]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",G,U]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:K()}],"text-color":[{text:K()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...k(),"wavy"]}],"text-decoration-thickness":[{decoration:[r1,"from-font","auto",G,u3]}],"text-decoration-color":[{decoration:K()}],"underline-offset":[{"underline-offset":[r1,"auto",G,U]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[x2,G,U]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",G,U]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",G,U]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:e2()}],"bg-repeat":[{bg:N1()}],"bg-size":[{bg:P2()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},x2,G,U],radial:["",G,U],conic:[x2,G,U]},dl,il]}],"bg-color":[{bg:K()}],"gradient-from-pos":[{from:m2()}],"gradient-via-pos":[{via:m2()}],"gradient-to-pos":[{to:m2()}],"gradient-from":[{from:K()}],"gradient-via":[{via:K()}],"gradient-to":[{to:K()}],rounded:[{rounded:S1()}],"rounded-s":[{"rounded-s":S1()}],"rounded-e":[{"rounded-e":S1()}],"rounded-t":[{"rounded-t":S1()}],"rounded-r":[{"rounded-r":S1()}],"rounded-b":[{"rounded-b":S1()}],"rounded-l":[{"rounded-l":S1()}],"rounded-ss":[{"rounded-ss":S1()}],"rounded-se":[{"rounded-se":S1()}],"rounded-ee":[{"rounded-ee":S1()}],"rounded-es":[{"rounded-es":S1()}],"rounded-tl":[{"rounded-tl":S1()}],"rounded-tr":[{"rounded-tr":S1()}],"rounded-br":[{"rounded-br":S1()}],"rounded-bl":[{"rounded-bl":S1()}],"border-w":[{border:x1()}],"border-w-x":[{"border-x":x1()}],"border-w-y":[{"border-y":x1()}],"border-w-s":[{"border-s":x1()}],"border-w-e":[{"border-e":x1()}],"border-w-bs":[{"border-bs":x1()}],"border-w-be":[{"border-be":x1()}],"border-w-t":[{"border-t":x1()}],"border-w-r":[{"border-r":x1()}],"border-w-b":[{"border-b":x1()}],"border-w-l":[{"border-l":x1()}],"divide-x":[{"divide-x":x1()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":x1()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...k(),"hidden","none"]}],"divide-style":[{divide:[...k(),"hidden","none"]}],"border-color":[{border:K()}],"border-color-x":[{"border-x":K()}],"border-color-y":[{"border-y":K()}],"border-color-s":[{"border-s":K()}],"border-color-e":[{"border-e":K()}],"border-color-bs":[{"border-bs":K()}],"border-color-be":[{"border-be":K()}],"border-color-t":[{"border-t":K()}],"border-color-r":[{"border-r":K()}],"border-color-b":[{"border-b":K()}],"border-color-l":[{"border-l":K()}],"divide-color":[{divide:K()}],"outline-style":[{outline:[...k(),"none","hidden"]}],"outline-offset":[{"outline-offset":[r1,G,U]}],"outline-w":[{outline:["",r1,j3,u3]}],"outline-color":[{outline:K()}],shadow:[{shadow:["","none",u,Z4,_4]}],"shadow-color":[{shadow:K()}],"inset-shadow":[{"inset-shadow":["none",f,Z4,_4]}],"inset-shadow-color":[{"inset-shadow":K()}],"ring-w":[{ring:x1()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:K()}],"ring-offset-w":[{"ring-offset":[r1,u3]}],"ring-offset-color":[{"ring-offset":K()}],"inset-ring-w":[{"inset-ring":x1()}],"inset-ring-color":[{"inset-ring":K()}],"text-shadow":[{"text-shadow":["none",d,Z4,_4]}],"text-shadow-color":[{"text-shadow":K()}],opacity:[{opacity:[r1,G,U]}],"mix-blend":[{"mix-blend":[...B(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":B()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[r1]}],"mask-image-linear-from-pos":[{"mask-linear-from":O()}],"mask-image-linear-to-pos":[{"mask-linear-to":O()}],"mask-image-linear-from-color":[{"mask-linear-from":K()}],"mask-image-linear-to-color":[{"mask-linear-to":K()}],"mask-image-t-from-pos":[{"mask-t-from":O()}],"mask-image-t-to-pos":[{"mask-t-to":O()}],"mask-image-t-from-color":[{"mask-t-from":K()}],"mask-image-t-to-color":[{"mask-t-to":K()}],"mask-image-r-from-pos":[{"mask-r-from":O()}],"mask-image-r-to-pos":[{"mask-r-to":O()}],"mask-image-r-from-color":[{"mask-r-from":K()}],"mask-image-r-to-color":[{"mask-r-to":K()}],"mask-image-b-from-pos":[{"mask-b-from":O()}],"mask-image-b-to-pos":[{"mask-b-to":O()}],"mask-image-b-from-color":[{"mask-b-from":K()}],"mask-image-b-to-color":[{"mask-b-to":K()}],"mask-image-l-from-pos":[{"mask-l-from":O()}],"mask-image-l-to-pos":[{"mask-l-to":O()}],"mask-image-l-from-color":[{"mask-l-from":K()}],"mask-image-l-to-color":[{"mask-l-to":K()}],"mask-image-x-from-pos":[{"mask-x-from":O()}],"mask-image-x-to-pos":[{"mask-x-to":O()}],"mask-image-x-from-color":[{"mask-x-from":K()}],"mask-image-x-to-color":[{"mask-x-to":K()}],"mask-image-y-from-pos":[{"mask-y-from":O()}],"mask-image-y-to-pos":[{"mask-y-to":O()}],"mask-image-y-from-color":[{"mask-y-from":K()}],"mask-image-y-to-color":[{"mask-y-to":K()}],"mask-image-radial":[{"mask-radial":[G,U]}],"mask-image-radial-from-pos":[{"mask-radial-from":O()}],"mask-image-radial-to-pos":[{"mask-radial-to":O()}],"mask-image-radial-from-color":[{"mask-radial-from":K()}],"mask-image-radial-to-color":[{"mask-radial-to":K()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":_()}],"mask-image-conic-pos":[{"mask-conic":[r1]}],"mask-image-conic-from-pos":[{"mask-conic-from":O()}],"mask-image-conic-to-pos":[{"mask-conic-to":O()}],"mask-image-conic-from-color":[{"mask-conic-from":K()}],"mask-image-conic-to-color":[{"mask-conic-to":K()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:e2()}],"mask-repeat":[{mask:N1()}],"mask-size":[{mask:P2()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",G,U]}],filter:[{filter:["","none",G,U]}],blur:[{blur:q()}],brightness:[{brightness:[r1,G,U]}],contrast:[{contrast:[r1,G,U]}],"drop-shadow":[{"drop-shadow":["","none",h,Z4,_4]}],"drop-shadow-color":[{"drop-shadow":K()}],grayscale:[{grayscale:["",r1,G,U]}],"hue-rotate":[{"hue-rotate":[r1,G,U]}],invert:[{invert:["",r1,G,U]}],saturate:[{saturate:[r1,G,U]}],sepia:[{sepia:["",r1,G,U]}],"backdrop-filter":[{"backdrop-filter":["","none",G,U]}],"backdrop-blur":[{"backdrop-blur":q()}],"backdrop-brightness":[{"backdrop-brightness":[r1,G,U]}],"backdrop-contrast":[{"backdrop-contrast":[r1,G,U]}],"backdrop-grayscale":[{"backdrop-grayscale":["",r1,G,U]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[r1,G,U]}],"backdrop-invert":[{"backdrop-invert":["",r1,G,U]}],"backdrop-opacity":[{"backdrop-opacity":[r1,G,U]}],"backdrop-saturate":[{"backdrop-saturate":[r1,G,U]}],"backdrop-sepia":[{"backdrop-sepia":["",r1,G,U]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",G,U]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[r1,"initial",G,U]}],ease:[{ease:["linear","initial",M,G,U]}],delay:[{delay:[r1,G,U]}],animate:[{animate:["none",g,G,U]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,G,U]}],"perspective-origin":[{"perspective-origin":H()}],rotate:[{rotate:l1()}],"rotate-x":[{"rotate-x":l1()}],"rotate-y":[{"rotate-y":l1()}],"rotate-z":[{"rotate-z":l1()}],scale:[{scale:p()}],"scale-x":[{"scale-x":p()}],"scale-y":[{"scale-y":p()}],"scale-z":[{"scale-z":p()}],"scale-3d":["scale-3d"],skew:[{skew:m()}],"skew-x":[{"skew-x":m()}],"skew-y":[{"skew-y":m()}],transform:[{transform:[G,U,"","none","gpu","cpu"]}],"transform-origin":[{origin:H()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:v()}],"translate-x":[{"translate-x":v()}],"translate-y":[{"translate-y":v()}],"translate-z":[{"translate-z":v()}],"translate-none":["translate-none"],zoom:[{zoom:[x2,G,U]}],accent:[{accent:K()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:K()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",G,U]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":K()}],"scrollbar-track-color":[{"scrollbar-track":K()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",G,U]}],fill:[{fill:["none",...K()]}],"stroke-w":[{stroke:[r1,j3,u3,L7]}],stroke:[{stroke:["none",...K()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},gl=Wa(ml);function h4(...e){return gl(C0(e))}const vl=["src","alt"],bl={key:1,class:"flex h-full w-full items-center justify-center bg-muted font-medium text-muted-foreground"},yl=l3({__name:"Avatar",props:{src:{},alt:{},fallback:{default:"?"},size:{default:"md"},class:{}},setup(e){const t=e,n={sm:"h-8 w-8 text-xs",md:"h-10 w-10 text-sm",lg:"h-12 w-12 text-base"},a=d1(!1),l=j1(()=>!t.src||a.value);return(r,c)=>(T(),W("div",{class:X1(I(h4)("relative flex shrink-0 overflow-hidden rounded-full",n[e.size],t.class))},[l.value?(T(),W("div",bl,J(e.fallback),1)):(T(),W("img",{key:0,src:e.src??void 0,alt:e.alt,class:"aspect-square h-full w-full object-cover",onError:c[0]||(c[0]=s=>a.value=!0)},null,40,vl))],2))}}),K5=d1(!0);function V7(e){K5.value=e,document.documentElement.classList.toggle("dark",e),document.documentElement.classList.toggle("light",!e);try{localStorage.setItem("sourceant-theme",e?"dark":"light")}catch{}}function F0(){return{isDark:K5,toggleTheme:()=>V7(!K5.value),restoreTheme:()=>{let e=null;try{e=localStorage.getItem("sourceant-theme")}catch{e=null}V7(e!=="light")}}}const xl={class:"flex h-screen flex-col bg-background"},Ml={class:"z-40 h-12 shrink-0 border-b bg-card/80 backdrop-blur-sm"},wl={class:"flex items-center h-full min-w-0 px-3 gap-1 sm:px-4"},_l={class:"hidden lg:flex items-center gap-0.5 min-w-0"},Zl={class:"hidden xl:inline"},kl={class:"relative shrink-0","data-dropdown":"user"},Cl={key:0,class:"absolute top-full right-0 mt-1 w-52 bg-card border rounded-lg shadow-lg py-1 z-50"},Al=["aria-label"],Sl={key:0,class:"lg:hidden shrink-0 border-b bg-card px-4 py-2 space-y-0.5"},El={class:"min-h-0 flex-1 overflow-y-auto"},Rl={class:"container mx-auto flex h-full flex-col px-4 pb-4 pt-3 lg:px-6 lg:pb-6 lg:pt-4"},Tl={__name:"App",setup(e){const{isDark:t,toggleTheme:n,restoreTheme:a}=F0(),l=Tn(),r=d1(!1),c=d1(!1),s=[{name:"Overview",href:"/",icon:b0},{name:"Knowledge graph",href:"/graph",icon:M0},{name:"Knowledge",href:"/knowledge",icon:D4},{name:"Repositories",href:"/repositories",icon:g0},{name:"Settings",href:"/settings",icon:G5}],o=j1(()=>ra(_a,{seed:location.hostname||"sourceant",radius:50}).toDataUri());function i(u){u.target.closest('[data-dropdown="user"]')||(c.value=!1)}return O2(()=>{a(),document.addEventListener("click",i)}),t5(()=>document.removeEventListener("click",i)),(u,f)=>{const d=I6("RouterLink"),h=I6("RouterView");return T(),W("div",xl,[w("header",Ml,[w("div",wl,[j(d,{to:"/",class:"shrink-0 mr-1 sm:mr-3"},{default:a1(()=>[j(ka,{size:"sm","show-text":!1})]),_:1}),f[7]||(f[7]=w("span",{class:"hidden lg:block h-4 w-px bg-border mx-1 shrink-0"},null,-1)),w("nav",_l,[(T(),W(y1,null,c2(s,y=>j(d,{key:y.href,to:y.href,title:y.name,class:X1(["flex shrink-0 items-center gap-1.5 px-2 py-1 rounded-md text-sm transition-colors 2xl:px-2.5",I(l).path===y.href?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-muted hover:text-foreground"])},{default:a1(()=>[(T(),m1(k3(y.icon),{class:"h-3.5 w-3.5 shrink-0"})),w("span",Zl,J(y.name),1)]),_:2},1032,["to","title","class"])),64))]),f[8]||(f[8]=w("div",{class:"flex-1 min-w-0"},null,-1)),w("div",kl,[w("button",{class:"flex items-center gap-1.5 p-1 rounded-md hover:bg-muted transition-colors","aria-label":"Account",onClick:f[0]||(f[0]=vt(y=>c.value=!c.value,["stop"]))},[j(yl,{src:o.value,size:"sm",class:"h-6 w-6"},null,8,["src"])]),j(n0,{"enter-active-class":"transition duration-100 ease-out","enter-from-class":"opacity-0 scale-95","enter-to-class":"opacity-100 scale-100","leave-active-class":"transition duration-75 ease-in","leave-from-class":"opacity-100 scale-100","leave-to-class":"opacity-0 scale-95"},{default:a1(()=>[c.value?(T(),W("div",Cl,[f[6]||(f[6]=w("div",{class:"px-3 py-2 border-b"},[w("p",{class:"text-sm font-medium truncate"},"This machine"),w("p",{class:"text-xs text-muted-foreground truncate"},"Nothing here has been shared.")],-1)),j(d,{to:"/settings",class:"flex items-center gap-2 px-3 py-1.5 text-sm hover:bg-muted transition-colors",onClick:f[1]||(f[1]=y=>c.value=!1)},{default:a1(()=>[j(I(G5),{class:"h-3.5 w-3.5 text-muted-foreground"}),f[5]||(f[5]=p1(" Settings ",-1))]),_:1}),w("button",{class:"flex items-center gap-2 w-full px-3 py-1.5 text-sm hover:bg-muted transition-colors",onClick:f[2]||(f[2]=(...y)=>I(n)&&I(n)(...y))},[(T(),m1(k3(I(t)?I(w0):I(x0)),{class:"h-3.5 w-3.5 text-muted-foreground"})),w("span",null,J(I(t)?"Light mode":"Dark mode"),1)])])):w1("",!0)]),_:1})]),w("button",{class:"lg:hidden shrink-0 p-1 rounded-md hover:bg-muted transition-colors","aria-label":r.value?"Close menu":"Open menu",onClick:f[3]||(f[3]=y=>r.value=!r.value)},[r.value?(T(),m1(I(v6),{key:1,class:"h-5 w-5"})):(T(),m1(I(jn),{key:0,class:"h-5 w-5"}))],8,Al)])]),r.value?(T(),W("div",Sl,[(T(),W(y1,null,c2(s,y=>j(d,{key:y.href,to:y.href,class:X1(["flex items-center gap-2 px-3 py-2 rounded-md text-sm transition-colors",I(l).path===y.href?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-muted hover:text-foreground"]),onClick:f[4]||(f[4]=x=>r.value=!1)},{default:a1(()=>[(T(),m1(k3(y.icon),{class:"h-4 w-4"})),p1(" "+J(y.name),1)]),_:2},1032,["to","class"])),64))])):w1("",!0),w("main",El,[w("div",Rl,[j(h)])])])}}},T2=l3({__name:"Card",props:{class:{},hover:{type:Boolean,default:!1},glow:{type:Boolean,default:!1}},setup(e){const t=e;return(n,a)=>(T(),W("div",{class:X1(I(h4)("rounded-lg border bg-card text-card-foreground shadow-sm",e.hover&&"transition-all duration-200 hover:border-primary/50 hover:-translate-y-1",e.glow&&"glow-sm",t.class))},[d4(n.$slots,"default")],2))}}),D7=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,j7=C0,z0=(e,t)=>n=>{var a;if((t==null?void 0:t.variants)==null)return j7(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:l,defaultVariants:r}=t,c=Object.keys(l).map(i=>{const u=n==null?void 0:n[i],f=r==null?void 0:r[i];if(u===null)return null;const d=D7(u)||D7(f);return l[i][d]}),s=n&&Object.entries(n).reduce((i,u)=>{let[f,d]=u;return d===void 0||(i[f]=d),i},{}),o=t==null||(a=t.compoundVariants)===null||a===void 0?void 0:a.reduce((i,u)=>{let{class:f,className:d,...h}=u;return Object.entries(h).every(y=>{let[x,b]=y;return Array.isArray(b)?b.includes({...r,...s}[x]):{...r,...s}[x]===b})?[...i,f,d]:i},[]);return j7(e,c,o,n==null?void 0:n.class,n==null?void 0:n.className)},i4=l3({__name:"Badge",props:{variant:{default:"default"},class:{}},setup(e){const t=z0("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow",outline:"text-foreground",success:"border-transparent bg-success/20 text-success",warning:"border-transparent bg-warning/20 text-warning",glow:"border-primary/30 bg-primary/10 text-primary"}},defaultVariants:{variant:"default"}}),n=e;return(a,l)=>(T(),W("div",{class:X1(I(h4)(I(t)({variant:e.variant}),n.class))},[d4(a.$slots,"default")],2))}}),q1=l3({__name:"Button",props:{variant:{default:"default"},size:{default:"default"},as:{default:"button"},class:{},disabled:{type:Boolean}},setup(e){const t=z0("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",glow:"bg-primary text-primary-foreground shadow-lg hover:bg-primary/90 glow-sm hover:glow"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-11 rounded-md px-8",xl:"h-12 rounded-lg px-10 text-base",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),n=e;return(a,l)=>(T(),m1(k3(e.as),{class:X1(I(h4)(I(t)({variant:e.variant,size:e.size}),n.class)),disabled:e.disabled},{default:a1(()=>[d4(a.$slots,"default")]),_:3},8,["class","disabled"]))}}),Ol={class:"flex flex-wrap items-start justify-between gap-4 mb-6"},Pl={class:"flex items-center gap-3"},Il={class:"text-xl font-semibold"},Ll={key:0,class:"text-sm text-muted-foreground"},$l={class:"flex flex-wrap items-center gap-2"},m4={__name:"PageHead",props:{icon:{type:[Object,Function],required:!0},title:{type:String,required:!0},sub:{type:String,default:""},pillar:{type:String,default:"graph"}},setup(e){const t={memory:"bg-pillar-memory/15 text-pillar-memory",graph:"bg-pillar-graph/15 text-pillar-graph",review:"bg-pillar-review/15 text-pillar-review",tokens:"bg-pillar-tokens/15 text-pillar-tokens"};return(n,a)=>(T(),W("div",Ol,[w("div",Pl,[w("div",{class:X1(["w-11 h-11 rounded-lg flex items-center justify-center shrink-0",t[e.pillar]])},[(T(),m1(k3(e.icon),{class:"w-6 h-6"}))],2),w("div",null,[w("h1",Il,J(e.title),1),e.sub?(T(),W("p",Ll,J(e.sub),1)):w1("",!0)])]),w("div",$l,[d4(n.$slots,"actions")])]))}},x6={__name:"EmptyMachine",setup(e){return(t,n)=>(T(),m1(T2,{class:"text-center py-16 px-6"},{default:a1(()=>[n[1]||(n[1]=w("h2",{class:"text-lg font-semibold mb-1"},"Nothing indexed yet",-1)),n[2]||(n[2]=w("p",{class:"text-muted-foreground text-sm mb-4 max-w-lg mx-auto"}," Point SourceAnt at a folder on this machine and it reads the code into a graph you can look at and record against. ",-1)),j(q1,{as:"a",href:"#/repositories",variant:"glow"},{default:a1(()=>[j(I(O3),{class:"mr-2 h-4 w-4"}),n[0]||(n[0]=p1(" Add a repository ",-1))]),_:1})]),_:1}))}};async function M2(e,t={}){const n=await fetch(e,{...t,headers:t.body?{"Content-Type":"application/json"}:void 0}),a=await n.text(),l=a?JSON.parse(a):null;if(!n.ok)throw new Error((l==null?void 0:l.error)||`the agent answered ${n.status}`);return l}const F3=e=>new URLSearchParams(Object.entries(e).filter(([,t])=>t!==""&&t!==!1)),Y1={status:()=>M2("/health"),repositories:()=>M2("/api/repositories"),addRepository:(e,t)=>M2("/api/repositories",{method:"POST",body:JSON.stringify({path:e,name:t})}),dropRepository:e=>M2(`/api/repositories?${F3({path:e})}`,{method:"DELETE"}),index:(e="",t=!1)=>M2("/api/index",{method:"POST",body:JSON.stringify({repository:e,everything:t})}),graph:(e,{includeTests:t=!1,pathPrefix:n=""}={})=>M2(`/api/graph?${F3({repository:e,include_tests:t,path_prefix:n})}`),knowledge:e=>M2(`/api/knowledge?${F3({repository:e,limit:100})}`),recordKnowledge:e=>M2("/api/knowledge",{method:"PUT",body:JSON.stringify(e)}),forgetKnowledge:(e,t)=>M2(`/api/knowledge?${F3({repository:e,id:t})}`,{method:"DELETE"}),browse:(e="")=>M2(`/api/browse?${F3({path:e})}`)},z3=d1([]),Z5=d1(""),k5=d1(""),C5=d1(!1);function c5(){async function e(){var t;C5.value=!0;try{z3.value=await Y1.repositories(),k5.value=""}catch(n){z3.value=[],k5.value=`${n.message}. Is sourceant-agent running?`}finally{C5.value=!1}z3.value.some(n=>n.name===Z5.value)||(Z5.value=((t=z3.value[0])==null?void 0:t.name)??"")}return{repositories:z3,chosen:Z5,error:k5,loading:C5,fetchRepositories:e}}const H0={repository:"#E20C18",directory:"#9560f0",file:"#3b82f6",import:"#f59e0b",function:"#4ade80",method:"#2dd4bf",class:"#c084fc",struct:"#22d3ee",interface:"#22d3ee",enum:"#22d3ee"},B0="#a1a1aa";function A2(e){if(e.synthetic)return e.synthetic;const t=e.labels||[];return t.includes("File")?"file":t.includes("Import")?"import":(e.kind||"").toLowerCase()}function Nl(e){return H0[A2(e)]||B0}function F7(e){return e&&e.length>28?`${e.slice(0,27)}…`:e}function Vl(e,t){const n={id:"tree:",name:t,kind:"repository",synthetic:"repository",path:""},a=new Map([["",n]]),l=[...e.links],r=c=>{if(a.has(c))return a.get(c);const s=c.lastIndexOf("/",c.length-2),o=s===-1?"":c.slice(0,s+1),i=r(o),u={id:`tree:${c}`,name:c.slice(o.length).replace(/\/$/,""),kind:"directory",synthetic:"directory",path:c};return a.set(c,u),l.push({source:i.id,target:u.id,type:"contains"}),u};for(const c of e.nodes){if(A2(c)!=="file"||!c.path)continue;const s=c.path.lastIndexOf("/"),o=r(s===-1?"":c.path.slice(0,s+1));l.push({source:o.id,target:c.id,type:"contains"})}return{nodes:[...a.values(),...e.nodes],links:l}}const Dl=[{id:"2d",label:"2D"},{id:"tree",label:"Tree"},{id:"radial",label:"Radial"},{id:"layered",label:"Layered"},{id:"web",label:"Force"}],jl={key:0,class:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm"},Fl={class:"grid gap-3 mb-6 sm:grid-cols-2 lg:grid-cols-4"},zl={class:"text-xs text-muted-foreground capitalize"},Hl={class:"mt-1 text-2xl font-semibold tabular-nums"},Bl={class:"grid gap-3"},Ul={class:"flex items-start gap-4"},Gl={class:"h-11 w-11 shrink-0 rounded-lg bg-pillar-graph/15 text-pillar-graph flex items-center justify-center"},Wl={class:"flex-1 min-w-0"},Kl={class:"flex items-center gap-2 mb-1"},ql={class:"font-semibold"},Jl={class:"text-sm text-muted-foreground font-mono break-all"},Yl={class:"flex flex-wrap items-center gap-4 mt-2 text-sm text-muted-foreground"},Xl={class:"flex items-center gap-1.5"},Ql={class:"flex items-center gap-1.5"},er={__name:"Overview",setup(e){const{repositories:t,error:n,fetchRepositories:a}=c5(),l=d1([]),r=j1(()=>({repositories:t.value.length,files:l.value.reduce((c,s)=>c+s.files,0),nodes:l.value.reduce((c,s)=>c+s.nodes,0),knowledge:l.value.reduce((c,s)=>c+s.knowledge,0)}));return O2(async()=>{await a(),l.value=await Promise.all(t.value.map(async c=>{const[s,o]=await Promise.all([Y1.graph(c.name).catch(()=>null),Y1.knowledge(c.name).catch(()=>null)]);return{repository:c,files:s?s.nodes.filter(i=>A2(i)==="file").length:0,nodes:s?s.nodes.length:0,knowledge:o?o.total:0}}))}),(c,s)=>(T(),W("div",null,[j(m4,{icon:I(b0),pillar:"memory",title:"Overview",sub:"What SourceAnt has on this machine."},null,8,["icon"]),I(n)?(T(),W("p",jl,J(I(n)),1)):w1("",!0),!I(n)&&I(t).length===0?(T(),m1(x6,{key:1})):I(t).length?(T(),W(y1,{key:2},[w("div",Fl,[(T(!0),W(y1,null,c2(r.value,(o,i)=>(T(),m1(T2,{key:i,class:"p-5"},{default:a1(()=>[w("p",zl,J(i),1),w("p",Hl,J(o.toLocaleString()),1)]),_:2},1024))),128))]),w("div",Bl,[(T(!0),W(y1,null,c2(l.value,o=>(T(),m1(T2,{key:o.repository.name,hover:"",class:"p-5"},{default:a1(()=>[w("div",Ul,[w("div",Gl,[j(I(g6),{class:"h-5 w-5"})]),w("div",Wl,[w("div",Kl,[w("h3",ql,J(o.repository.name),1),j(i4,{variant:o.files?"success":"warning"},{default:a1(()=>[p1(J(o.files?"Indexed":"Not indexed"),1)]),_:2},1032,["variant"])]),w("p",Jl,J(o.repository.path),1),w("div",Yl,[w("span",Xl,[j(I(v0),{class:"h-3.5 w-3.5"}),p1(J(o.files.toLocaleString())+" files ",1)]),w("span",Ql,[j(I(D4),{class:"h-3.5 w-3.5"}),p1(J(o.knowledge.toLocaleString())+" recorded ",1)])])]),j(q1,{as:"a",href:"#/graph",variant:"ghost",size:"sm",class:"shrink-0"},{default:a1(()=>[...s[0]||(s[0]=[p1("Graph",-1)])]),_:1})])]),_:2},1024))),128))]),s[1]||(s[1]=w("p",{class:"mt-4 text-xs text-muted-foreground"}," Reviews are not here. A review reads a pull request, which is a thing the hosted service does; nothing on this machine produces one. ",-1))],64)):w1("",!0)]))}},tr="modulepreload",nr=function(e,t){return new URL(e,t).href},z7={},A5=function(t,n,a){let l=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(f=>Promise.resolve(f).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const s=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),i=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));l=c(n.map(u=>{if(u=nr(u,a),u in z7)return;z7[u]=!0;const f=u.endsWith(".css"),d=f?'[rel="stylesheet"]':"";if(!!a)for(let x=s.length-1;x>=0;x--){const b=s[x];if(b.href===u&&(!f||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${d}`))return;const y=document.createElement("link");if(y.rel=f?"stylesheet":tr,f||(y.as="script"),y.crossOrigin="",y.href=u,i&&y.setAttribute("nonce",i),document.head.appendChild(y),f)return new Promise((x,b)=>{y.addEventListener("load",x),y.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${u}`)))})}))}function r(c){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=c,window.dispatchEvent(s),!s.defaultPrevented)throw c}return l.then(c=>{for(const s of c||[])s.status==="rejected"&&r(s.reason);return t().catch(r)})},ar={__name:"CodeGraph",props:{data:{type:Object,default:null},mode:{type:String,default:"2d"},repository:{type:String,default:""}},emits:["select"],setup(e,{emit:t}){const n=e,a=t,l=d1(null);let r=null,c=null,s=null;const o=h=>h==="tree"?"td":h==="radial"?"radialout":h==="layered"?"zout":null;function i(h){const y=A2(h);return y==="repository"?9:y==="directory"||y==="file"?7:5.5}function u(){const h=n.data||{nodes:[],links:[]};return{nodes:h.nodes.map(y=>({...y,color:Nl(y)})),links:h.links.map(y=>({...y}))}}function f(){var h;r&&((h=r._destructor)==null||h.call(r),r=null),l.value&&(l.value.innerHTML="")}async function d(h){if(!l.value)return;const y=h==="2d"?"2d":"3d";if(r&&c===y){y==="3d"&&r.dagMode(o(h)),r.graphData(u());return}if(f(),c=y,y==="2d"){const M=(await A5(async()=>{const{default:g}=await import("./force-graph-BunJtbL4.js");return{default:g}},__vite__mapDeps([0,1]),import.meta.url)).default;r=new M(l.value),r.backgroundColor("rgba(0,0,0,0)").graphData(u()).nodeRelSize(4).nodeColor(g=>g.color).nodeLabel("name").nodeCanvasObject((g,C,_)=>{C.beginPath(),C.arc(g.x,g.y,4,0,2*Math.PI),C.fillStyle=g.color,C.fill();const H=Math.max(11/_,2),F=A2(g)==="repository"||A2(g)==="file";C.font=`${F?"bold ":""}${H}px Inter, sans-serif`,C.fillStyle=g.color,C.textAlign="left",C.textBaseline="middle",C.fillText(F7(g.name),g.x+6,g.y)}).nodePointerAreaPaint((g,C,_)=>{_.fillStyle=C,_.beginPath(),_.arc(g.x,g.y,6,0,2*Math.PI),_.fill()}).linkColor(()=>"#52525b").linkWidth(.7).linkDirectionalArrowLength(3).linkDirectionalArrowRelPos(1).linkCanvasObjectMode(()=>"after").linkCanvasObject((g,C,_)=>{const H=g.source,F=g.target;if(!g.type||typeof H!="object"||typeof F!="object")return;const $=Math.max(9/_,1.5);C.font=`${$}px monospace`,C.fillStyle="#9ca3af",C.textAlign="center",C.textBaseline="middle",C.fillText(g.type,(H.x+F.x)/2,(H.y+F.y)/2)}).onNodeClick(g=>a("select",g)).onBackgroundClick(()=>a("select",null)).width(l.value.clientWidth).height(l.value.clientHeight),r.onEngineStop(()=>r.zoomToFit(500,40));return}const x=(await A5(async()=>{const{default:M}=await import("./3d-force-graph-9_wZMVcC.js");return{default:M}},__vite__mapDeps([2,3,1]),import.meta.url)).default,b=(await A5(async()=>{const{default:M}=await import("./three-spritetext-vp3JBkiZ.js");return{default:M}},__vite__mapDeps([4,3]),import.meta.url)).default;r=new x(l.value),r.backgroundColor("rgba(0,0,0,0)").showNavInfo(!1).enableNodeDrag(!1).onDagError(()=>{}).dagLevelDistance(46).dagMode(o(h)).graphData(u()).nodeLabel("name").nodeThreeObject(M=>{const g=new b(F7(M.name));return g.color=M.color,g.textHeight=i(M),g.fontWeight=A2(M)==="repository"?"700":"500",g}).linkColor(()=>"#52525b").linkOpacity(.35).linkWidth(.6).linkDirectionalArrowLength(2.5).linkDirectionalArrowRelPos(1).linkThreeObjectExtend(!0).linkThreeObject(M=>{if(!M.type)return null;const g=new b(M.type);return g.color="#9ca3af",g.textHeight=3,g}).linkPositionUpdate((M,{start:g,end:C})=>{M&&M.position.set((g.x+C.x)/2,(g.y+C.y)/2,(g.z+C.z)/2)}).onNodeClick(M=>a("select",M)).onBackgroundClick(()=>a("select",null)).width(l.value.clientWidth).height(l.value.clientHeight),r.onEngineStop(()=>r.zoomToFit(500,40))}return O2(async()=>{await d(n.mode),s=new ResizeObserver(()=>{r&&l.value&&r.width(l.value.clientWidth).height(l.value.clientHeight)}),l.value&&s.observe(l.value)}),R2(()=>n.mode,h=>d(h)),R2(()=>n.repository,()=>d(n.mode)),R2(()=>n.data,()=>d(n.mode),{deep:!0}),s6(()=>{s&&(s.disconnect(),s=null),f()}),(h,y)=>(T(),W("div",{ref_key:"el",ref:l,class:"h-full w-full"},null,512))}},lr={class:"flex h-full min-h-0 flex-col"},rr=["value"],cr={key:0,class:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm"},or={class:"mb-3 flex flex-wrap items-center justify-between gap-3"},sr={class:"inline-flex rounded-md border bg-card p-0.5"},ir=["onClick"],ur={class:"flex flex-wrap items-center gap-4 text-xs text-muted-foreground"},fr={class:"inline-flex items-center gap-1.5 cursor-pointer"},dr={class:"inline-flex items-center gap-1.5 cursor-pointer"},pr={class:"inline-flex items-center gap-1.5 cursor-pointer"},hr={class:"inline-flex items-center gap-1.5 cursor-pointer"},mr={class:"relative min-h-0 flex-1 overflow-hidden rounded-lg border bg-card"},gr={key:0,class:"absolute inset-0 grid place-items-center bg-card p-8 text-center text-sm text-muted-foreground"},vr={key:0},br={key:1},yr={key:1,class:"absolute right-3 top-3 w-80 max-w-[calc(100%-1.5rem)] rounded-md border bg-background/90 p-4 backdrop-blur-xl"},xr={class:"mb-2 mr-6 text-sm font-semibold break-all"},Mr={class:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs"},wr={class:"font-mono break-all"},_r={class:"font-mono break-all"},Zr={class:"font-mono"},kr={key:0,class:"mt-3 rounded-md border border-warning/35 bg-warning/10 px-4 py-2.5 text-sm"},Cr={class:"mt-3 flex flex-wrap items-center justify-between gap-4"},Ar={class:"flex flex-wrap gap-x-4 gap-y-2"},Sr={key:0,class:"text-xs text-muted-foreground tabular-nums"},Er={__name:"Graph",setup(e){const{repositories:t,chosen:n,error:a,fetchRepositories:l}=c5(),r=d1(null),c=d1(!1),s=d1("2d"),o=d1(null),i=d1(!0),u=d1(!1),f=d1(!1),d=d1(!1),h=j1(()=>{if(!r.value)return null;const M=r.value.nodes.filter(H=>{const F=A2(H);return F==="import"?f.value:F==="file"?!0:u.value}),g=new Set(M.map(H=>H.id)),C=r.value.links.filter(H=>g.has(H.source)&&g.has(H.target)),_={nodes:M.map(H=>({...H})),links:C.map(H=>({...H}))};return i.value?Vl(_,n.value):_}),y=j1(()=>h.value?[...new Set(h.value.nodes.map(A2))].sort().map(M=>({group:M,colour:H0[M]||B0})):[]),x=j1(()=>!o.value||!r.value?0:r.value.links.filter(M=>M.source===o.value.id||M.target===o.value.id).length);async function b(){if(n.value){c.value=!0,o.value=null;try{r.value=await Y1.graph(n.value,{includeTests:d.value}),a.value=""}catch(M){r.value=null,a.value=M.message}finally{c.value=!1}}}return R2([n,d],b),O2(async()=>{await l(),await b()}),(M,g)=>{var C;return T(),W("div",lr,[j(m4,{icon:I(M0),title:"Knowledge graph",sub:"Your code, and how it holds together."},{actions:a1(()=>[I(t).length>1?i2((T(),W("select",{key:0,"onUpdate:modelValue":g[0]||(g[0]=_=>$1(n)?n.value=_:null),class:"rounded-md border bg-card px-3 py-1.5 text-sm","aria-label":"Repository"},[(T(!0),W(y1,null,c2(I(t),_=>(T(),W("option",{key:_.name,value:_.name},J(_.name),9,rr))),128))],512)),[[F5,I(n)]]):w1("",!0)]),_:1},8,["icon"]),I(a)?(T(),W("p",cr,J(I(a)),1)):w1("",!0),I(t).length===0?(T(),m1(x6,{key:1})):(T(),W(y1,{key:2},[w("div",or,[w("div",sr,[(T(!0),W(y1,null,c2(I(Dl),_=>(T(),W("button",{key:_.id,type:"button",class:X1(["px-3 py-1 text-xs font-medium rounded transition-colors",s.value===_.id?"bg-primary/15 text-primary":"text-muted-foreground hover:text-foreground"]),onClick:H=>s.value=_.id},J(_.label),11,ir))),128))]),w("div",ur,[w("label",fr,[i2(w("input",{"onUpdate:modelValue":g[1]||(g[1]=_=>i.value=_),type:"checkbox"},null,512),[[w4,i.value]]),g[7]||(g[7]=p1(" Folders ",-1))]),w("label",dr,[i2(w("input",{"onUpdate:modelValue":g[2]||(g[2]=_=>u.value=_),type:"checkbox"},null,512),[[w4,u.value]]),g[8]||(g[8]=p1(" Symbols ",-1))]),w("label",pr,[i2(w("input",{"onUpdate:modelValue":g[3]||(g[3]=_=>f.value=_),type:"checkbox"},null,512),[[w4,f.value]]),g[9]||(g[9]=p1(" Imports ",-1))]),w("label",hr,[i2(w("input",{"onUpdate:modelValue":g[4]||(g[4]=_=>d.value=_),type:"checkbox"},null,512),[[w4,d.value]]),g[10]||(g[10]=p1(" Tests ",-1))]),w("span",null,J(s.value==="2d"?"Scroll to zoom, drag to pan":"Drag to rotate"),1)])]),w("div",mr,[j(ar,{data:h.value,mode:s.value,repository:I(n),onSelect:g[5]||(g[5]=_=>o.value=_)},null,8,["data","mode","repository"]),c.value||!h.value||h.value.nodes.length===0?(T(),W("div",gr,[c.value?(T(),W("span",vr,"Reading the index…")):(T(),W("span",br,"Nothing here yet. Re-index it from Repositories."))])):w1("",!0),o.value?(T(),W("aside",yr,[w("button",{class:"absolute right-2 top-2 rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":"Close",onClick:g[6]||(g[6]=_=>o.value=null)},[j(I(v6),{class:"h-3.5 w-3.5"})]),w("h2",xr,J(o.value.name),1),w("dl",Mr,[g[11]||(g[11]=w("dt",{class:"text-muted-foreground"},"Kind",-1)),w("dd",wr,J(o.value.synthetic?`${o.value.kind} · this view's arrangement`:o.value.kind),1),g[12]||(g[12]=w("dt",{class:"text-muted-foreground"},"Path",-1)),w("dd",_r,J(o.value.path||"—"),1),g[13]||(g[13]=w("dt",{class:"text-muted-foreground"},"Links",-1)),w("dd",Zr,J(o.value.synthetic?"—":x.value),1)])])):w1("",!0)]),(C=r.value)!=null&&C.truncated?(T(),W("p",kr," This repository is larger than the limit, so this is part of it, not all of it. ")):w1("",!0),w("div",Cr,[w("div",Ar,[(T(!0),W(y1,null,c2(y.value,_=>(T(),W("div",{key:_.group,class:"flex items-center gap-2 text-xs text-muted-foreground"},[w("span",{class:"h-2.5 w-2.5 rounded-sm",style:K4({backgroundColor:_.colour})},null,4),p1(" "+J(_.group||"other"),1)]))),128))]),h.value?(T(),W("p",Sr,J(h.value.nodes.length.toLocaleString())+" nodes · "+J(h.value.links.length.toLocaleString())+" links ",1)):w1("",!0)])],64))])}}},Rr={key:0,class:"fixed inset-0 z-50 flex items-center justify-center p-4"},U0=l3({__name:"Modal",props:{open:{type:Boolean},class:{},maxWidth:{default:"lg"}},emits:["close"],setup(e,{emit:t}){const n=e,a=t,l={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl"};function r(c){c.key==="Escape"&&a("close")}return O2(()=>window.addEventListener("keydown",r)),t5(()=>window.removeEventListener("keydown",r)),(c,s)=>(T(),m1(je,{to:"body"},[j(n0,{"enter-active-class":"transition duration-200","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition duration-150","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:a1(()=>[e.open?(T(),W("div",Rr,[w("div",{class:"absolute inset-0 bg-background/80 backdrop-blur-sm",onClick:s[0]||(s[0]=o=>a("close"))}),j(T2,{class:X1(I(h4)("relative w-full max-h-[85vh] overflow-auto p-6 animate-fade-up",l[e.maxWidth],n.class))},{default:a1(()=>[w("button",{class:"absolute top-4 right-4 p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",onClick:s[1]||(s[1]=o=>a("close"))},[j(I(v6),{class:"h-4 w-4"})]),d4(c.$slots,"default")]),_:3},8,["class"])])):w1("",!0)]),_:3})]))}}),Tr=["value"],Or={key:0,class:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm"},Pr={key:3,class:"grid gap-3"},Ir={class:"flex items-start gap-4"},Lr={class:"h-11 w-11 shrink-0 rounded-lg bg-pillar-memory/15 text-pillar-memory flex items-center justify-center"},$r={class:"flex-1 min-w-0"},Nr={class:"flex flex-wrap items-center gap-2 mb-1"},Vr={class:"font-semibold break-all"},Dr={class:"text-sm text-muted-foreground"},jr={key:0,class:"mt-2 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs"},Fr={class:"font-mono break-all"},zr={class:"flex shrink-0 items-center gap-1"},Hr={class:"text-lg font-semibold mb-4"},Br={class:"space-y-4"},Ur=["readonly"],Gr={key:0,class:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm"},Wr={class:"flex items-center gap-2 pt-2"},Kr={__name:"Knowledge",setup(e){const t=["decision","convention","constraint","pattern","workaround","requirement"],{repositories:n,chosen:a,error:l,fetchRepositories:r}=c5(),c=d1([]),s=d1(null),o=d1({id:"",kind:"decision",summary:"",why:""}),i=d1(""),u=d1(!1);async function f(){if(a.value)try{const x=await Y1.knowledge(a.value);c.value=x.items,l.value=""}catch(x){c.value=[],l.value=x.message}}function d(x){var b;s.value=x??{fresh:!0},o.value=x?{id:x.id,kind:x.kind,summary:x.summary,why:((b=x.properties)==null?void 0:b.why)??""}:{id:"",kind:"decision",summary:"",why:""},i.value=""}async function h(){var x,b,M;if(!o.value.id.trim()||!o.value.summary.trim()){i.value="A name and what is true are both needed.";return}u.value=!0;try{await Y1.recordKnowledge({repository:a.value,id:o.value.id.trim(),kind:o.value.kind,status:((x=s.value)==null?void 0:x.status)??"accepted",summary:o.value.summary.trim(),properties:o.value.why.trim()?{...((b=s.value)==null?void 0:b.properties)??{},why:o.value.why.trim()}:((M=s.value)==null?void 0:M.properties)??{}}),s.value=null,await f()}catch(g){i.value=g.message}finally{u.value=!1}}async function y(x){if(confirm(`Forget ${x.id}?`)){try{await Y1.forgetKnowledge(a.value,x.id)}catch(b){l.value=b.message}await f()}}return R2(a,f),O2(async()=>{await r(),await f()}),(x,b)=>(T(),W("div",null,[j(m4,{icon:I(D4),pillar:"memory",title:"Knowledge",sub:"The decisions, conventions and constraints behind this code."},{actions:a1(()=>[I(n).length>1?i2((T(),W("select",{key:0,"onUpdate:modelValue":b[0]||(b[0]=M=>$1(a)?a.value=M:null),class:"rounded-md border bg-card px-3 py-1.5 text-sm","aria-label":"Repository"},[(T(!0),W(y1,null,c2(I(n),M=>(T(),W("option",{key:M.name,value:M.name},J(M.name),9,Tr))),128))],512)),[[F5,I(a)]]):w1("",!0),I(n).length?(T(),m1(q1,{key:1,variant:"glow",onClick:b[1]||(b[1]=M=>d(null))},{default:a1(()=>[j(I(O3),{class:"mr-2 h-4 w-4"}),b[9]||(b[9]=p1(" Record something ",-1))]),_:1})):w1("",!0)]),_:1},8,["icon"]),I(l)?(T(),W("p",Or,J(I(l)),1)):w1("",!0),I(n).length===0?(T(),m1(x6,{key:1})):c.value.length===0?(T(),m1(T2,{key:2,class:"text-center py-16 px-6"},{default:a1(()=>[b[11]||(b[11]=w("h2",{class:"text-lg font-semibold mb-1"},"Nothing recorded yet",-1)),b[12]||(b[12]=w("p",{class:"text-muted-foreground text-sm mb-4 max-w-lg mx-auto"}," Why a thing is the way it is outlives the code that does it. Write one down and every agent reading this repository over MCP gets it too. ",-1)),j(q1,{variant:"glow",onClick:b[2]||(b[2]=M=>d(null))},{default:a1(()=>[j(I(O3),{class:"mr-2 h-4 w-4"}),b[10]||(b[10]=p1(" Record something ",-1))]),_:1})]),_:1})):(T(),W("div",Pr,[(T(!0),W(y1,null,c2(c.value,M=>(T(),m1(T2,{key:M.id,class:"p-5"},{default:a1(()=>{var g;return[w("div",Ir,[w("div",Lr,[j(I(D4),{class:"h-5 w-5"})]),w("div",$r,[w("div",Nr,[w("h3",Vr,J(M.id),1),j(i4,{variant:"secondary"},{default:a1(()=>[p1(J(M.kind),1)]),_:2},1024),M.status?(T(),m1(i4,{key:0,variant:"outline"},{default:a1(()=>[p1(J(M.status),1)]),_:2},1024)):w1("",!0)]),w("p",Dr,J(M.summary),1),(g=M.properties)!=null&&g.why?(T(),W("dl",jr,[b[13]||(b[13]=w("dt",{class:"text-muted-foreground"},"why",-1)),w("dd",Fr,J(M.properties.why),1)])):w1("",!0)]),w("div",zr,[j(q1,{variant:"ghost",size:"icon","aria-label":"Edit",onClick:C=>d(M)},{default:a1(()=>[j(I(Fn),{class:"h-4 w-4"})]),_:1},8,["onClick"]),j(q1,{variant:"ghost",size:"icon","aria-label":"Remove",onClick:C=>y(M)},{default:a1(()=>[j(I(_0),{class:"h-4 w-4"})]),_:1},8,["onClick"])])])]}),_:2},1024))),128))])),j(U0,{open:!!s.value,"max-width":"xl",onClose:b[8]||(b[8]=M=>s.value=null)},{default:a1(()=>{var M,g;return[w("h2",Hr,J((M=s.value)!=null&&M.fresh?"Record something":"Edit"),1),w("div",Br,[w("div",null,[b[14]||(b[14]=w("label",{class:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5 block"},"Name",-1)),i2(w("input",{"onUpdate:modelValue":b[3]||(b[3]=C=>o.value.id=C),readonly:!((g=s.value)!=null&&g.fresh),placeholder:"retry-limit",class:"w-full bg-muted/50 border rounded-md px-3 py-2 text-sm outline-none focus:border-primary/50 text-foreground"},null,8,Ur),[[E4,o.value.id]])]),w("div",null,[b[15]||(b[15]=w("label",{class:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5 block"},"Kind",-1)),i2(w("select",{"onUpdate:modelValue":b[4]||(b[4]=C=>o.value.kind=C),class:"w-full bg-muted/50 border rounded-md px-3 py-2 text-sm outline-none focus:border-primary/50 text-foreground"},[(T(),W(y1,null,c2(t,C=>w("option",{key:C},J(C),1)),64))],512),[[F5,o.value.kind]])]),w("div",null,[b[16]||(b[16]=w("label",{class:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5 block"},"What is true",-1)),i2(w("textarea",{"onUpdate:modelValue":b[5]||(b[5]=C=>o.value.summary=C),rows:"3",placeholder:"Charges retry three times, then stop.",class:"w-full bg-muted/50 border rounded-md px-3 py-2 text-sm outline-none focus:border-primary/50 text-foreground"},null,512),[[E4,o.value.summary]])]),w("div",null,[b[17]||(b[17]=w("label",{class:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5 block"},"Why",-1)),i2(w("textarea",{"onUpdate:modelValue":b[6]||(b[6]=C=>o.value.why=C),rows:"3",placeholder:"The provider rate limits after four.",class:"w-full bg-muted/50 border rounded-md px-3 py-2 text-sm outline-none focus:border-primary/50 text-foreground"},null,512),[[E4,o.value.why]])]),i.value?(T(),W("p",Gr,J(i.value),1)):w1("",!0),w("div",Wr,[j(q1,{disabled:u.value,onClick:h},{default:a1(()=>[j(I(Nn),{class:"mr-1.5 h-3.5 w-3.5"}),b[18]||(b[18]=p1(" Save ",-1))]),_:1},8,["disabled"]),j(q1,{variant:"outline",onClick:b[7]||(b[7]=C=>s.value=null)},{default:a1(()=>[...b[19]||(b[19]=[p1("Cancel",-1)])]),_:1})])])]}),_:1},8,["open"])]))}},qr={class:"mb-2 text-xs font-mono text-muted-foreground break-all"},Jr={class:"h-64 overflow-y-auto rounded-md border bg-muted/30"},Yr=["onClick"],Xr={class:"truncate"},Qr={key:1,class:"px-3 py-6 text-center text-sm text-muted-foreground"},ec={class:"mt-4"},tc={class:"mt-2 text-xs text-muted-foreground"},nc={class:"font-mono"},ac={key:0,class:"mt-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm"},lc={class:"flex items-center gap-2 pt-5"},rc={__name:"FolderPicker",props:{open:Boolean},emits:["close","added"],setup(e,{emit:t}){const n=e,a=t,l=d1(null),r=d1(""),c=d1(!1),s=d1("");async function o(u){try{l.value=await Y1.browse(u),s.value=""}catch(f){s.value=f.message}}R2(()=>n.open,u=>{u&&(r.value="",s.value="",c.value=!1,o(""))});async function i(){if(l.value){c.value=!0,s.value="";try{await Y1.addRepository(l.value.path,r.value.trim()),await Y1.index("",!0),a("added"),a("close")}catch(u){s.value=u.message}finally{c.value=!1}}}return(u,f)=>(T(),m1(U0,{open:e.open,"max-width":"lg",onClose:f[3]||(f[3]=d=>a("close"))},{default:a1(()=>{var d,h,y,x;return[f[9]||(f[9]=w("h2",{class:"text-lg font-semibold mb-3"},"Add a folder",-1)),w("p",qr,J((d=l.value)==null?void 0:d.path),1),w("div",Jr,[(h=l.value)!=null&&h.parent?(T(),W("button",{key:0,class:"flex w-full items-center gap-2 px-3 py-2 text-sm hover:bg-accent",onClick:f[0]||(f[0]=b=>o(l.value.parent))},[j(I(Vn),{class:"h-3.5 w-3.5"}),f[4]||(f[4]=w("span",{class:"text-muted-foreground"},"Up one",-1))])):w1("",!0),(T(!0),W(y1,null,c2(((y=l.value)==null?void 0:y.entries)??[],b=>(T(),W("button",{key:b.path,class:"flex w-full items-center gap-2 px-3 py-2 text-sm hover:bg-accent",onClick:M=>o(b.path)},[j(I(g6),{class:"h-3.5 w-3.5 text-muted-foreground"}),w("span",Xr,J(b.name),1),b.repository?(T(),m1(i4,{key:0,variant:"glow",class:"ml-auto shrink-0"},{default:a1(()=>[...f[5]||(f[5]=[p1("git",-1)])]),_:1})):w1("",!0)],8,Yr))),128)),l.value&&l.value.entries.length===0?(T(),W("p",Qr," Nothing inside. ")):w1("",!0)]),w("div",ec,[f[6]||(f[6]=w("label",{class:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-1.5 block",for:"repo-name"}," Name it (optional) ",-1)),i2(w("input",{id:"repo-name","onUpdate:modelValue":f[1]||(f[1]=b=>r.value=b),placeholder:"Taken from the git remote, or the folder name",class:"w-full bg-muted/50 border rounded-md px-3 py-2 text-sm outline-none focus:border-primary/50 text-foreground"},null,512),[[E4,r.value]])]),w("p",tc,[f[7]||(f[7]=p1(" Adding ",-1)),w("code",nc,J((x=l.value)==null?void 0:x.path),1)]),s.value?(T(),W("p",ac,J(s.value),1)):w1("",!0),w("div",lc,[j(q1,{disabled:c.value||!l.value,onClick:i},{default:a1(()=>[c.value?(T(),m1(I(y0),{key:0,class:"mr-1.5 h-3.5 w-3.5 animate-spin"})):(T(),m1(I(O3),{key:1,class:"mr-1.5 h-3.5 w-3.5"})),p1(" "+J(c.value?"Reading…":"Add and index"),1)]),_:1},8,["disabled"]),j(q1,{variant:"outline",onClick:f[2]||(f[2]=b=>a("close"))},{default:a1(()=>[...f[8]||(f[8]=[p1("Cancel",-1)])]),_:1})])]}),_:1},8,["open"]))}},cc={key:0,class:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm"},oc={key:2,class:"grid gap-3"},sc={class:"flex items-start gap-4"},ic={class:"h-11 w-11 shrink-0 rounded-lg bg-pillar-graph/15 text-pillar-graph flex items-center justify-center"},uc={class:"flex-1 min-w-0"},fc={class:"font-semibold mb-1"},dc={class:"text-sm text-muted-foreground font-mono break-all"},pc={class:"flex flex-wrap items-center gap-4 mt-2 text-sm text-muted-foreground"},hc={class:"flex items-center gap-1.5"},mc={class:"flex items-center gap-1.5"},gc={key:1},vc={key:2},bc={class:"flex shrink-0 items-center gap-1"},yc={__name:"Repositories",setup(e){const{repositories:t,error:n,fetchRepositories:a}=c5(),l=d1({}),r=d1(""),c=d1(!1);async function s(){for(const f of t.value){const d=await Y1.graph(f.name).catch(()=>null);l.value={...l.value,[f.name]:d?{files:d.nodes.filter(h=>A2(h)==="file").length,links:d.links.length}:null}}}async function o(){await a(),await s()}async function i(f){r.value=f;try{await Y1.index(f),n.value=""}catch(d){n.value=d.message}r.value="",await s()}async function u(f){if(confirm(`Stop covering ${f.path}? + +What was already indexed is left alone.`)){try{await Y1.dropRepository(f.path)}catch(d){n.value=d.message}await o()}}return O2(o),(f,d)=>(T(),W("div",null,[j(m4,{icon:I(g0),title:"Repositories",sub:"The folders SourceAnt reads on this machine."},{actions:a1(()=>[j(q1,{variant:"glow",onClick:d[0]||(d[0]=h=>c.value=!0)},{default:a1(()=>[j(I(O3),{class:"mr-2 h-4 w-4"}),d[3]||(d[3]=p1(" Add a folder ",-1))]),_:1})]),_:1},8,["icon"]),I(n)?(T(),W("p",cc,J(I(n)),1)):w1("",!0),I(t).length===0?(T(),m1(T2,{key:1,class:"text-center py-16 px-6"},{default:a1(()=>[d[5]||(d[5]=w("h2",{class:"text-lg font-semibold mb-1"},"No folders yet",-1)),d[6]||(d[6]=w("p",{class:"text-muted-foreground text-sm mb-4"}," Point SourceAnt at a repository and it reads the files into a graph. ",-1)),j(q1,{variant:"glow",onClick:d[1]||(d[1]=h=>c.value=!0)},{default:a1(()=>[j(I(O3),{class:"mr-2 h-4 w-4"}),d[4]||(d[4]=p1(" Add a folder ",-1))]),_:1})]),_:1})):(T(),W("div",oc,[(T(!0),W(y1,null,c2(I(t),h=>(T(),m1(T2,{key:h.path,class:"p-5"},{default:a1(()=>[w("div",sc,[w("div",ic,[j(I(g6),{class:"h-5 w-5"})]),w("div",uc,[w("h3",fc,J(h.name),1),w("p",dc,J(h.path),1),w("div",pc,[l.value[h.name]?(T(),W(y1,{key:0},[w("span",hc,[j(I(v0),{class:"h-3.5 w-3.5"}),p1(J(l.value[h.name].files.toLocaleString())+" files ",1)]),w("span",mc,[j(I(Dn),{class:"h-3.5 w-3.5"}),p1(J(l.value[h.name].links.toLocaleString())+" links ",1)])],64)):l.value[h.name]===null?(T(),W("span",gc,"Not indexed yet. Re-index to read it.")):(T(),W("span",vc,"Reading…"))])]),w("div",bc,[j(q1,{variant:"outline",size:"sm",disabled:r.value===h.name,onClick:y=>i(h.name)},{default:a1(()=>[r.value===h.name?(T(),m1(I(y0),{key:0,class:"mr-1.5 h-3.5 w-3.5 animate-spin"})):(T(),m1(I(zn),{key:1,class:"mr-1.5 h-3.5 w-3.5"})),p1(" "+J(r.value===h.name?"Reading…":"Re-index"),1)]),_:2},1032,["disabled","onClick"]),j(q1,{variant:"ghost",size:"icon","aria-label":`Remove ${h.name}`,onClick:y=>u(h)},{default:a1(()=>[j(I(_0),{class:"h-4 w-4"})]),_:1},8,["aria-label","onClick"])])])]),_:2},1024))),128))])),j(rc,{open:c.value,onClose:d[2]||(d[2]=h=>c.value=!1),onAdded:o},null,8,["open"])]))}},xc={key:0,class:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm"},Mc={class:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm"},wc={class:"font-mono"},_c={class:"font-mono break-all"},Zc={class:"font-mono"},kc={class:"font-mono break-all"},Cc={__name:"Settings",setup(e){const{isDark:t,toggleTheme:n}=F0(),a=d1(null),l=d1("");return O2(async()=>{try{a.value=await Y1.status()}catch(r){l.value=r.message}}),(r,c)=>(T(),W("div",null,[j(m4,{icon:I(G5),pillar:"tokens",title:"Settings",sub:"What is running, and how this looks."},null,8,["icon"]),l.value?(T(),W("p",xc,J(l.value),1)):w1("",!0),j(T2,{class:"p-5 mb-3"},{default:a1(()=>[c[0]||(c[0]=w("h2",{class:"font-semibold mb-3"},"Appearance",-1)),j(q1,{variant:"outline",onClick:I(n)},{default:a1(()=>[(T(),m1(k3(I(t)?I(w0):I(x0)),{class:"mr-2 h-4 w-4"})),p1(" "+J(I(t)?"Light mode":"Dark mode"),1)]),_:1},8,["onClick"])]),_:1}),a.value?(T(),m1(T2,{key:1,class:"p-5"},{default:a1(()=>[c[5]||(c[5]=w("h2",{class:"font-semibold mb-3"},"What is running",-1)),w("dl",Mc,[c[2]||(c[2]=w("dt",{class:"text-muted-foreground"},"Agent",-1)),w("dd",wc,J(a.value.version),1),c[3]||(c[3]=w("dt",{class:"text-muted-foreground"},"Indexer",-1)),w("dd",_c,[p1(J(a.value.core_url)+" ",1),j(i4,{variant:a.value.core_up?"success":"destructive",class:"ml-2"},{default:a1(()=>[p1(J(a.value.core_up?"answering":"not answering"),1)]),_:1},8,["variant"])]),c[4]||(c[4]=w("dt",{class:"text-muted-foreground"},"Starts",-1)),w("dd",Zc,J(a.value.core_starts),1),a.value.last_exit?(T(),W(y1,{key:0},[c[1]||(c[1]=w("dt",{class:"text-muted-foreground"},"Last exit",-1)),w("dd",kc,J(a.value.last_exit),1)],64)):w1("",!0)]),c[6]||(c[6]=w("p",{class:"mt-4 text-xs text-muted-foreground"},[p1(" Where the indexer comes from is chosen at install time and kept in "),w("code",{class:"font-mono"},"~/.sourceant/config.json"),p1(". ")],-1))]),_:1})):w1("",!0)]))}},Ac=Rn({history:on(),routes:[{path:"/",component:er},{path:"/graph",component:Er},{path:"/knowledge",component:Kr},{path:"/repositories",component:yc},{path:"/settings",component:Cc},{path:"/:rest(.*)*",redirect:"/"}]});xt(Tl).use(Ac).mount("#app"); diff --git a/internal/ui/assets/assets/three-spritetext-vp3JBkiZ.js b/internal/ui/assets/assets/three-spritetext-vp3JBkiZ.js new file mode 100644 index 0000000..3605c0d --- /dev/null +++ b/internal/ui/assets/assets/three-spritetext-vp3JBkiZ.js @@ -0,0 +1,4 @@ +import{df as q,dg as L,m as D,cg as K}from"./three.module-CGesFut6.js";function R(e,n){(n==null||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t0&&arguments[0]!==void 0?arguments[0]:"",h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:10,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"rgba(255, 255, 255, 1)";return Q(this,n),t=J(this,n,[new _.SpriteMaterial]),t._text="".concat(r),t._textHeight=h,t._color=i,t._backgroundColor=!1,t._padding=0,t._borderWidth=0,t._borderRadius=0,t._borderColor="white",t._offsetX=0,t._offsetY=0,t._strokeWidth=0,t._strokeColor="white",t._fontFace="system-ui",t._fontSize=90,t._fontWeight="normal",t._canvas=document.createElement("canvas"),t._genCanvas(),t}return tt(n,e),Z(n,[{key:"text",get:function(){return this._text},set:function(r){this._text=r,this._genCanvas()}},{key:"textHeight",get:function(){return this._textHeight},set:function(r){this._textHeight=r,this._genCanvas()}},{key:"color",get:function(){return this._color},set:function(r){this._color=r,this._genCanvas()}},{key:"backgroundColor",get:function(){return this._backgroundColor},set:function(r){this._backgroundColor=r,this._genCanvas()}},{key:"padding",get:function(){return this._padding},set:function(r){this._padding=r,this._genCanvas()}},{key:"borderWidth",get:function(){return this._borderWidth},set:function(r){this._borderWidth=r,this._genCanvas()}},{key:"borderRadius",get:function(){return this._borderRadius},set:function(r){this._borderRadius=r,this._genCanvas()}},{key:"borderColor",get:function(){return this._borderColor},set:function(r){this._borderColor=r,this._genCanvas()}},{key:"offsetX",get:function(){return this._offsetX},set:function(r){this._offsetX=r,this._genCanvas()}},{key:"offsetY",get:function(){return this._offsetY},set:function(r){this._offsetY=r,this._genCanvas()}},{key:"fontFace",get:function(){return this._fontFace},set:function(r){this._fontFace=r,this._genCanvas()}},{key:"fontSize",get:function(){return this._fontSize},set:function(r){this._fontSize=r,this._genCanvas()}},{key:"fontWeight",get:function(){return this._fontWeight},set:function(r){this._fontWeight=r,this._genCanvas()}},{key:"strokeWidth",get:function(){return this._strokeWidth},set:function(r){this._strokeWidth=r,this._genCanvas()}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(r){this._strokeColor=r,this._genCanvas()}},{key:"_genCanvas",value:function(){var r=this,h=this._canvas,i=h.getContext("2d"),c=1/this.textHeight,y=Array.isArray(this.borderWidth)?this.borderWidth:[this.borderWidth,this.borderWidth],o=y.map(function(s){return s*r.fontSize*c}),b=Array.isArray(this.borderRadius)?this.borderRadius:[this.borderRadius,this.borderRadius,this.borderRadius,this.borderRadius],a=b.map(function(s){return s*r.fontSize*c}),O=Array.isArray(this.padding)?this.padding:[this.padding,this.padding],w=O.map(function(s){return s*r.fontSize*c}),T=[this.offsetX,this.offsetY].map(function(s){return s*r.fontSize*c}),m=this.text.split(` +`),P="".concat(this.fontWeight," ").concat(this.fontSize,"px ").concat(this.fontFace);i.font=P;var j=Math.max.apply(Math,v(m.map(function(s){return i.measureText(s).width}))),B=this.fontSize*m.length,f=j+o[0]*2+w[0]*2,u=B+o[1]*2+w[1]*2;if(h.width=f+Math.abs(T[0]),h.height=u+Math.abs(T[1]),i.translate.apply(i,v(T.map(function(s){return Math.max(0,s)}))),this.borderWidth){if(i.strokeStyle=this.borderColor,o[0]){var C=o[0]/2;i.lineWidth=o[0],i.beginPath(),i.moveTo(C,a[0]),i.lineTo(C,u-a[3]),i.moveTo(f-C,a[1]),i.lineTo(f-C,u-a[2]),i.stroke()}if(o[1]){var k=o[1]/2;i.lineWidth=o[1],i.beginPath(),i.moveTo(Math.max(o[0],a[0]),k),i.lineTo(f-Math.max(o[0],a[1]),k),i.moveTo(Math.max(o[0],a[3]),u-k),i.lineTo(f-Math.max(o[0],a[2]),u-k),i.stroke()}if(this.borderRadius){var M=Math.max.apply(Math,v(o)),d=M/2;i.lineWidth=M,i.beginPath(),[!!a[0]&&[a[0],d,d,a[0]],!!a[1]&&[f-a[1],f-d,d,a[1]],!!a[2]&&[f-a[2],f-d,u-d,u-a[2]],!!a[3]&&[a[3],d,u-d,u-a[3]]].filter(function(s){return s}).forEach(function(s){var l=H(s,4),p=l[0],g=l[1],S=l[2],W=l[3];i.moveTo(p,S),i.quadraticCurveTo(g,S,g,W)}),i.stroke()}}this.backgroundColor&&(i.fillStyle=this.backgroundColor,this.borderRadius?(i.beginPath(),i.moveTo(o[0],a[0]),[[o[0],a[0],f-a[1],o[1],o[1],o[1]],[f-o[0],f-o[0],f-o[0],o[1],a[1],u-a[2]],[f-o[0],f-a[2],a[3],u-o[1],u-o[1],u-o[1]],[o[0],o[0],o[0],u-o[1],u-a[3],a[0]]].forEach(function(s){var l=H(s,6),p=l[0],g=l[1],S=l[2],W=l[3],X=l[4],G=l[5];i.quadraticCurveTo(p,W,g,X),i.lineTo(S,G)}),i.closePath(),i.fill()):i.fillRect(o[0],o[1],f-o[0]*2,u-o[1]*2)),i.translate.apply(i,v(o)),i.translate.apply(i,v(w)),i.font=P,i.fillStyle=this.color,i.textBaseline="bottom";var z=this.strokeWidth>0;z&&(i.lineWidth=this.strokeWidth*this.fontSize/10,i.strokeStyle=this.strokeColor),m.forEach(function(s,l){var p=(j-i.measureText(s).width)/2,g=(l+1)*r.fontSize;z&&i.strokeText(s,p,g),i.fillText(s,p,g)}),this.material.map&&this.material.map.dispose();var F=this.material.map=new _.CanvasTexture(h);F.colorSpace=_.SRGBColorSpace;var E=this.textHeight*m.length+y[1]*2+O[1]*2+Math.abs(this.offsetY);this.scale.set(E*h.width/h.height,E,0)}},{key:"clone",value:function(){return new this.constructor(this.text,this.textHeight,this.color).copy(this)}},{key:"copy",value:function(r){return _.Sprite.prototype.copy.call(this,r),this.color=r.color,this.backgroundColor=r.backgroundColor,this.padding=r.padding,this.borderWidth=r.borderWidth,this.borderColor=r.borderColor,this.offsetX=r.offsetX,this.offsetY=r.offsetY,this.fontFace=r.fontFace,this.fontSize=r.fontSize,this.fontWeight=r.fontWeight,this.strokeWidth=r.strokeWidth,this.strokeColor=r.strokeColor,this}}])})(_.Sprite);export{ut as default}; diff --git a/internal/ui/assets/assets/three.module-CGesFut6.js b/internal/ui/assets/assets/three.module-CGesFut6.js new file mode 100644 index 0000000..c08bc1d --- /dev/null +++ b/internal/ui/assets/assets/three.module-CGesFut6.js @@ -0,0 +1,4116 @@ +/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const og="185",lg={ROTATE:0,DOLLY:1,PAN:2},cg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},lc=0,io=1,cc=2,hg=0,Rs=1,hc=2,Bi=3,Nn=0,Lt=1,pn=2,_n=0,vi=1,so=2,ro=3,ao=4,uc=5,ug=6,Wn=100,fc=101,dc=102,pc=103,mc=104,gc=200,_c=201,vc=202,xc=203,Nr=204,Fr=205,Mc=206,Sc=207,yc=208,Ec=209,bc=210,Tc=211,Ac=212,wc=213,Rc=214,Or=0,Br=1,zr=2,Si=3,Vr=4,Gr=5,Hr=6,kr=7,ks=0,Cc=1,Pc=2,sn=0,dl=1,pl=2,ml=3,gl=4,_l=5,vl=6,xl=7,Ml=300,Zn=301,yi=302,$s=303,Qs=304,Ws=306,Wr=1e3,gn=1001,Xr=1002,mt=1003,Lc=1004,ji=1005,At=1006,js=1007,qn=1008,zt=1009,Sl=1010,yl=1011,Wi=1012,Aa=1013,an=1014,nn=1015,Mn=1016,wa=1017,Ra=1018,Xi=1020,El=35902,bl=35899,Tl=1021,Al=1022,Zt=1023,Sn=1026,Yn=1027,wl=1028,Ca=1029,Jn=1030,Pa=1031,fg=1032,La=1033,Cs=33776,Ps=33777,Ls=33778,Ds=33779,qr=35840,Yr=35841,Zr=35842,Jr=35843,Kr=36196,$r=37492,Qr=37496,jr=37488,ea=37489,Us=37490,ta=37491,na=37808,ia=37809,sa=37810,ra=37811,aa=37812,oa=37813,la=37814,ca=37815,ha=37816,ua=37817,fa=37818,da=37819,pa=37820,ma=37821,ga=36492,_a=36494,va=36495,xa=36283,Ma=36284,Ns=36285,Sa=36286,Dc=3200,Fn=0,Ic=1,In="",kt="srgb",Fs="srgb-linear",Os="linear",Ze="srgb",dg="",pg="rg",mg="ga",gg=0,jn=7680,_g=7681,vg=7682,xg=7683,Mg=34055,Sg=34056,yg=5386,Eg=512,bg=513,Tg=514,Ag=515,wg=516,Rg=517,Cg=518,oo=519,Uc=512,Nc=513,Fc=514,Da=515,Oc=516,Bc=517,Ia=518,zc=519,ya=35044,Pg=35048,lo="300 es",Jt=2e3,qi=2001,Lg={COMPUTE:"compute",RENDER:"render"},Dg={TEXTURE_COMPARE:"depthTextureCompare"};function Vc(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Ig(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Yi(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Gc(){const i=Yi("canvas");return i.style.display="block",i}const co={};function Bs(...i){const e="THREE."+i.shift();console.log(e,...i)}function Rl(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ae(...i){i=Rl(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Ve(...i){i=Rl(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function xi(...i){const e=i.join(" ");e in co||(co[e]=!0,Ae(...i))}function Ug(){return typeof self<"u"&&typeof self.scheduler<"u"&&typeof self.scheduler.yield<"u"?self.scheduler.yield():new Promise(i=>{requestAnimationFrame(i)})}function Hc(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const kc={[Or]:Br,[zr]:Hr,[Vr]:kr,[Si]:Gr,[Br]:Or,[Hr]:zr,[kr]:Vr,[Gr]:Si};class On{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r>8&255]+bt[i>>16&255]+bt[i>>24&255]+"-"+bt[e&255]+bt[e>>8&255]+"-"+bt[e>>16&15|64]+bt[e>>24&255]+"-"+bt[t&63|128]+bt[t>>8&255]+"-"+bt[t>>16&255]+bt[t>>24&255]+bt[n&255]+bt[n>>8&255]+bt[n>>16&255]+bt[n>>24&255]).toLowerCase()}function Fe(i,e,t){return Math.max(e,Math.min(t,i))}function Ua(i,e){return(i%e+e)%e}function Wc(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function Xc(i,e,t){return i!==e?(t-i)/(e-i):0}function Gi(i,e,t){return(1-t)*i+t*e}function qc(i,e,t,n){return Gi(i,e,1-Math.exp(-t*n))}function Yc(i,e=1){return e-Math.abs(Ua(i,e*2)-e)}function Zc(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Jc(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Kc(i,e){return i+Math.floor(Math.random()*(e-i+1))}function $c(i,e){return i+Math.random()*(e-i)}function Qc(i){return i*(.5-Math.random())}function jc(i){i!==void 0&&(ho=i);let e=ho+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function eh(i){return i*Vi}function th(i){return i*Ei}function nh(i){return(i&i-1)===0&&i!==0}function ih(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function sh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function rh(i,e,t,n,s){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+n)/2),u=a((e+n)/2),d=r((e-n)/2),h=a((e-n)/2),p=r((n-e)/2),v=a((n-e)/2);switch(s){case"XYX":i.set(o*u,l*d,l*h,o*c);break;case"YZY":i.set(l*h,o*u,l*d,o*c);break;case"ZXZ":i.set(l*d,l*h,o*u,o*c);break;case"XZX":i.set(o*u,l*v,l*p,o*c);break;case"YXY":i.set(l*p,o*u,l*v,o*c);break;case"ZYZ":i.set(l*v,l*p,o*u,o*c);break;default:Ae("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Ct(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Ne(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const Ng={DEG2RAD:Vi,RAD2DEG:Ei,generateUUID:vn,clamp:Fe,euclideanModulo:Ua,mapLinear:Wc,inverseLerp:Xc,lerp:Gi,damp:qc,pingpong:Yc,smoothstep:Zc,smootherstep:Jc,randInt:Kc,randFloat:$c,randFloatSpread:Qc,seededRandom:jc,degToRad:eh,radToDeg:th,isPowerOfTwo:nh,ceilPowerOfTwo:ih,floorPowerOfTwo:sh,setQuaternionFromProperEuler:rh,normalize:Ne,denormalize:Ct},ka=class ka{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Fe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Fe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};ka.prototype.isVector2=!0;let _e=ka;class Ai{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let l=n[s+0],c=n[s+1],u=n[s+2],d=n[s+3],h=r[a+0],p=r[a+1],v=r[a+2],S=r[a+3];if(d!==S||l!==h||c!==p||u!==v){let g=l*h+c*p+u*v+d*S;g<0&&(h=-h,p=-p,v=-v,S=-S,g=-g);let f=1-o;if(g<.9995){const w=Math.acos(g),A=Math.sin(w);f=Math.sin(f*w)/A,o=Math.sin(o*w)/A,l=l*f+h*o,c=c*f+p*o,u=u*f+v*o,d=d*f+S*o}else{l=l*f+h*o,c=c*f+p*o,u=u*f+v*o,d=d*f+S*o;const w=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=w,c*=w,u*=w,d*=w}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],l=n[s+1],c=n[s+2],u=n[s+3],d=r[a],h=r[a+1],p=r[a+2],v=r[a+3];return e[t]=o*v+u*d+l*p-c*h,e[t+1]=l*v+u*h+c*d-o*p,e[t+2]=c*v+u*p+o*h-l*d,e[t+3]=u*v-o*d-l*h-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),u=o(s/2),d=o(r/2),h=l(n/2),p=l(s/2),v=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*p*v,this._y=c*p*d-h*u*v,this._z=c*u*v+h*p*d,this._w=c*u*d-h*p*v;break;case"YXZ":this._x=h*u*d+c*p*v,this._y=c*p*d-h*u*v,this._z=c*u*v-h*p*d,this._w=c*u*d+h*p*v;break;case"ZXY":this._x=h*u*d-c*p*v,this._y=c*p*d+h*u*v,this._z=c*u*v+h*p*d,this._w=c*u*d-h*p*v;break;case"ZYX":this._x=h*u*d-c*p*v,this._y=c*p*d+h*u*v,this._z=c*u*v-h*p*d,this._w=c*u*d+h*p*v;break;case"YZX":this._x=h*u*d+c*p*v,this._y=c*p*d+h*u*v,this._z=c*u*v-h*p*d,this._w=c*u*d-h*p*v;break;case"XZY":this._x=h*u*d-c*p*v,this._y=c*p*d-h*u*v,this._z=c*u*v+h*p*d,this._w=c*u*d+h*p*v;break;default:Ae("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=n+o+d;if(h>0){const p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(u-l)*p,this._y=(r-c)*p,this._z=(a-s)*p}else if(n>o&&n>d){const p=2*Math.sqrt(1+n-o-d);this._w=(u-l)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+c)/p}else if(o>d){const p=2*Math.sqrt(1+o-n-d);this._w=(r-c)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+d-n-o);this._w=(a-s)/p,this._x=(r+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Fe(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-n*c,this._z=r*u+a*c+n*l-s*o,this._w=a*u-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const Wa=class Wa{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(uo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(uo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*n),u=2*(o*t-r*s),d=2*(r*n-a*t);return this.x=t+l*c+a*d-o*u,this.y=n+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this.z=Fe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this.z=Fe(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Fe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return er.copy(this).projectOnVector(e),this.sub(er)}reflect(e){return this.sub(er.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Fe(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Wa.prototype.isVector3=!0;let C=Wa;const er=new C,uo=new Ai,Xa=class Xa{constructor(e,t,n,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c)}set(e,t,n,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],u=n[4],d=n[7],h=n[2],p=n[5],v=n[8],S=s[0],g=s[3],f=s[6],w=s[1],A=s[4],M=s[7],T=s[2],E=s[5],R=s[8];return r[0]=a*S+o*w+l*T,r[3]=a*g+o*A+l*E,r[6]=a*f+o*M+l*R,r[1]=c*S+u*w+d*T,r[4]=c*g+u*A+d*E,r[7]=c*f+u*M+d*R,r[2]=h*S+p*w+v*T,r[5]=h*g+p*A+v*E,r[8]=h*f+p*M+v*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-n*r*u+n*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,p=c*r-a*l,v=t*d+n*h+s*p;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/v;return e[0]=d*S,e[1]=(s*c-u*n)*S,e[2]=(o*n-s*a)*S,e[3]=h*S,e[4]=(u*t-s*l)*S,e[5]=(s*r-o*t)*S,e[6]=p*S,e[7]=(n*l-c*t)*S,e[8]=(a*t-n*r)*S,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return xi("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(tr.makeScale(e,t)),this}rotate(e){return xi("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(tr.makeRotation(-e)),this}translate(e,t){return xi("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(tr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Xa.prototype.isMatrix3=!0;let Le=Xa;const tr=new Le,fo=new Le().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),po=new Le().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ah(){const i={enabled:!0,workingColorSpace:Fs,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Ze&&(s.r=xn(s.r),s.g=xn(s.g),s.b=xn(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Ze&&(s.r=Mi(s.r),s.g=Mi(s.g),s.b=Mi(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===In?Os:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return xi("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return xi("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Fs]:{primaries:e,whitePoint:n,transfer:Os,toXYZ:fo,fromXYZ:po,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:kt},outputColorSpaceConfig:{drawingBufferColorSpace:kt}},[kt]:{primaries:e,whitePoint:n,transfer:Ze,toXYZ:fo,fromXYZ:po,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:kt}}}),i}const Ge=ah();function xn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Mi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let ei;class oh{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ei===void 0&&(ei=Yi("canvas")),ei.width=e.width,ei.height=e.height;const s=ei.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ei}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Yi("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(ir).x}get height(){return this.source.getSize(ir).y}get depth(){return this.source.getSize(ir).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ae(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ae(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ml)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Wr:e.x=e.x-Math.floor(e.x);break;case gn:e.x=e.x<0?0:1;break;case Xr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Wr:e.y=e.y-Math.floor(e.y);break;case gn:e.y=e.y<0?0:1;break;case Xr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}St.DEFAULT_IMAGE=null;St.DEFAULT_MAPPING=Ml;St.DEFAULT_ANISOTROPY=1;const qa=class qa{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],p=l[5],v=l[9],S=l[2],g=l[6],f=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-S)<.01&&Math.abs(v-g)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+S)<.1&&Math.abs(v+g)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(c+1)/2,M=(p+1)/2,T=(f+1)/2,E=(u+h)/4,R=(d+S)/4,_=(v+g)/4;return A>M&&A>T?A<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(A),s=E/n,r=R/n):M>T?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=E/s,r=_/s):T<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(T),n=R/r,s=_/r),this.set(n,s,r,t),this}let w=Math.sqrt((g-v)*(g-v)+(d-S)*(d-S)+(h-u)*(h-u));return Math.abs(w)<.001&&(w=1),this.x=(g-v)/w,this.y=(d-S)/w,this.z=(h-u)/w,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Fe(this.x,e.x,t.x),this.y=Fe(this.y,e.y,t.y),this.z=Fe(this.z,e.z,t.z),this.w=Fe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Fe(this.x,e,t),this.y=Fe(this.y,e,t),this.z=Fe(this.z,e,t),this.w=Fe(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Fe(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};qa.prototype.isVector4=!0;let nt=qa;class hh extends On{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:At,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new nt(0,0,e,t),this.scissorTest=!1,this.viewport=new nt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new St(s),a=n.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),d.length>0&&(n.shapes=d),h.length>0&&(n.skeletons=h),p.length>0&&(n.animations=p),v.length>0&&(n.nodes=v)}return n.object=s,n;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;np+v?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=p-v&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(vh)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new ns;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Pl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Rn={h:0,s:0,l:0},is={h:0,s:0,l:0};function ar(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class Ce{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=kt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ge.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ge.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ge.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ge.workingColorSpace){if(e=Ua(e,1),t=Fe(t,0,1),n=Fe(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=ar(a,r,e+1/3),this.g=ar(a,r,e),this.b=ar(a,r,e-1/3)}return Ge.colorSpaceToWorking(this,s),this}setStyle(e,t=kt){function n(r){r!==void 0&&parseFloat(r)<1&&Ae("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ae("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ae("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=kt){const n=Pl[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ae("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=xn(e.r),this.g=xn(e.g),this.b=xn(e.b),this}copyLinearToSRGB(e){return this.r=Mi(e.r),this.g=Mi(e.g),this.b=Mi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=kt){return Ge.workingToColorSpace(Tt.copy(this),e),Math.round(Fe(Tt.r*255,0,255))*65536+Math.round(Fe(Tt.g*255,0,255))*256+Math.round(Fe(Tt.b*255,0,255))}getHexString(e=kt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ge.workingColorSpace){Ge.workingToColorSpace(Tt.copy(this),t);const n=Tt.r,s=Tt.g,r=Tt.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case n:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const qt=new C,hn=new C,or=new C,un=new C,si=new C,ri=new C,yo=new C,lr=new C,cr=new C,hr=new C,ur=new nt,fr=new nt,dr=new nt;class Wt{constructor(e=new C,t=new C,n=new C){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),qt.subVectors(e,t),s.cross(qt);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){qt.subVectors(s,t),hn.subVectors(n,t),or.subVectors(e,t);const a=qt.dot(qt),o=qt.dot(hn),l=qt.dot(or),c=hn.dot(hn),u=hn.dot(or),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,p=(c*l-o*u)*h,v=(a*u-o*l)*h;return r.set(1-p-v,v,p)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,un)===null?!1:un.x>=0&&un.y>=0&&un.x+un.y<=1}static getInterpolation(e,t,n,s,r,a,o,l){return this.getBarycoord(e,t,n,s,un)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,un.x),l.addScaledVector(a,un.y),l.addScaledVector(o,un.z),l)}static getInterpolatedAttribute(e,t,n,s,r,a){return ur.setScalar(0),fr.setScalar(0),dr.setScalar(0),ur.fromBufferAttribute(e,t),fr.fromBufferAttribute(e,n),dr.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(ur,r.x),a.addScaledVector(fr,r.y),a.addScaledVector(dr,r.z),a}static isFrontFacing(e,t,n,s){return qt.subVectors(n,t),hn.subVectors(e,t),qt.cross(hn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qt.subVectors(this.c,this.b),hn.subVectors(this.a,this.b),qt.cross(hn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Wt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Wt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return Wt.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return Wt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Wt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;si.subVectors(s,n),ri.subVectors(r,n),lr.subVectors(e,n);const l=si.dot(lr),c=ri.dot(lr);if(l<=0&&c<=0)return t.copy(n);cr.subVectors(e,s);const u=si.dot(cr),d=ri.dot(cr);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(n).addScaledVector(si,a);hr.subVectors(e,r);const p=si.dot(hr),v=ri.dot(hr);if(v>=0&&p<=v)return t.copy(r);const S=p*c-l*v;if(S<=0&&c>=0&&v<=0)return o=c/(c-v),t.copy(n).addScaledVector(ri,o);const g=u*v-p*d;if(g<=0&&d-u>=0&&p-v>=0)return yo.subVectors(r,s),o=(d-u)/(d-u+(p-v)),t.copy(s).addScaledVector(yo,o);const f=1/(g+S+h);return a=S*f,o=h*f,t.copy(n).addScaledVector(si,a).addScaledVector(ri,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Ji{constructor(e=new C(1/0,1/0,1/0),t=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Yt),Yt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ci),rs.subVectors(this.max,Ci),ai.subVectors(e.a,Ci),oi.subVectors(e.b,Ci),li.subVectors(e.c,Ci),Cn.subVectors(oi,ai),Pn.subVectors(li,oi),zn.subVectors(ai,li);let t=[0,-Cn.z,Cn.y,0,-Pn.z,Pn.y,0,-zn.z,zn.y,Cn.z,0,-Cn.x,Pn.z,0,-Pn.x,zn.z,0,-zn.x,-Cn.y,Cn.x,0,-Pn.y,Pn.x,0,-zn.y,zn.x,0];return!pr(t,ai,oi,li,rs)||(t=[1,0,0,0,1,0,0,0,1],!pr(t,ai,oi,li,rs))?!1:(as.crossVectors(Cn,Pn),t=[as.x,as.y,as.z],pr(t,ai,oi,li,rs))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Yt).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(fn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const fn=[new C,new C,new C,new C,new C,new C,new C,new C],Yt=new C,ss=new Ji,ai=new C,oi=new C,li=new C,Cn=new C,Pn=new C,zn=new C,Ci=new C,rs=new C,as=new C,Vn=new C;function pr(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Vn.fromArray(i,r);const o=s.x*Math.abs(Vn.x)+s.y*Math.abs(Vn.y)+s.z*Math.abs(Vn.z),l=e.dot(Vn),c=t.dot(Vn),u=n.dot(Vn);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const mn=xh();function xh(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,s[l]=24,s[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,s[l]=-c-1,s[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,s[l]=13,s[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,s[l]=24,s[l|256]=24):(n[l]=31744,n[l|256]=64512,s[l]=13,s[l|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,r[l]=c|u}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function Ft(i){Math.abs(i)>65504&&Ae("DataUtils.toHalfFloat(): Value out of range."),i=Fe(i,-65504,65504),mn.floatView[0]=i;const e=mn.uint32View[0],t=e>>23&511;return mn.baseTable[t]+((e&8388607)>>mn.shiftTable[t])}function os(i){const e=i>>10;return mn.uint32View[0]=mn.mantissaTable[mn.offsetTable[e]+(i&1023)]+mn.exponentTable[e],mn.floatView[0]}const dt=new C,ls=new _e;let Mh=0;class Vt extends On{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Mh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ya,this.updateRanges=[],this.gpuType=nn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Pi.subVectors(e,this.center);const t=Pi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Pi,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(mr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Pi.copy(e.center).add(mr)),this.expandByPoint(Pi.copy(e.center).sub(mr))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let yh=0;const Ht=new je,gr=new ht,ci=new C,Ot=new Ji,Li=new Ji,Mt=new C;class Dt extends On{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:yh++}),this.uuid=vn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Vc(e)?Dl:Ll)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Le().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Ht.makeRotationFromQuaternion(e),this.applyMatrix4(Ht),this}rotateX(e){return Ht.makeRotationX(e),this.applyMatrix4(Ht),this}rotateY(e){return Ht.makeRotationY(e),this.applyMatrix4(Ht),this}rotateZ(e){return Ht.makeRotationZ(e),this.applyMatrix4(Ht),this}translate(e,t,n){return Ht.makeTranslation(e,t,n),this.applyMatrix4(Ht),this}scale(e,t,n){return Ht.makeScale(e,t,n),this.applyMatrix4(Ht),this}lookAt(e){return gr.lookAt(e),gr.updateMatrix(),this.applyMatrix4(gr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ci).negate(),this.translate(ci.x,ci.y,ci.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;st.count&&Ae("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ji);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ve("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,p=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ae(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ae(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==vi&&(n.blending=this.blending),this.side!==Nn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Nr&&(n.blendSrc=this.blendSrc),this.blendDst!==Fr&&(n.blendDst=this.blendDst),this.blendEquation!==Wn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Si&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==oo&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==jn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==jn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==jn&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ce().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new _e().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new _e().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class bh extends It{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ce(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let hi;const Di=new C,ui=new C,fi=new C,di=new _e,Ii=new _e,Ul=new je,cs=new C,Ui=new C,hs=new C,Eo=new _e,_r=new _e,bo=new _e;class Bg extends ht{constructor(e=new bh){if(super(),this.isSprite=!0,this.type="Sprite",hi===void 0){hi=new Dt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Il(t,5);hi.setIndex([0,1,2,0,2,3]),hi.setAttribute("position",new zs(n,3,0,!1)),hi.setAttribute("uv",new zs(n,2,3,!1))}this.geometry=hi,this.material=e,this.center=new _e(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Ve('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),ui.setFromMatrixScale(this.matrixWorld),Ul.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),fi.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ui.multiplyScalar(-fi.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;us(cs.set(-.5,-.5,0),fi,a,ui,s,r),us(Ui.set(.5,-.5,0),fi,a,ui,s,r),us(hs.set(.5,.5,0),fi,a,ui,s,r),Eo.set(0,0),_r.set(1,0),bo.set(1,1);let o=e.ray.intersectTriangle(cs,Ui,hs,!1,Di);if(o===null&&(us(Ui.set(-.5,.5,0),fi,a,ui,s,r),_r.set(0,1),o=e.ray.intersectTriangle(cs,hs,Ui,!1,Di),o===null))return;const l=e.ray.origin.distanceTo(Di);le.far||t.push({distance:l,point:Di.clone(),uv:Wt.getInterpolation(Di,cs,Ui,hs,Eo,_r,bo,new _e),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function us(i,e,t,n,s,r){di.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Ii.x=r*di.x-s*di.y,Ii.y=s*di.x+r*di.y):Ii.copy(di),i.copy(e),i.x+=Ii.x,i.y+=Ii.y,i.applyMatrix4(Ul)}const dn=new C,vr=new C,fs=new C,Ln=new C,xr=new C,ds=new C,Mr=new C;class Oa{constructor(e=new C,t=new C(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,dn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=dn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(dn.copy(this.origin).addScaledVector(this.direction,t),dn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){vr.copy(e).add(t).multiplyScalar(.5),fs.copy(t).sub(e).normalize(),Ln.copy(this.origin).sub(vr);const r=e.distanceTo(t)*.5,a=-this.direction.dot(fs),o=Ln.dot(this.direction),l=-Ln.dot(fs),c=Ln.lengthSq(),u=Math.abs(1-a*a);let d,h,p,v;if(u>0)if(d=a*l-o,h=a*o-l,v=r*u,d>=0)if(h>=-v)if(h<=v){const S=1/u;d*=S,h*=S,p=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),p=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),p=-d*d+h*(h+2*l)+c;else h<=-v?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),p=-d*d+h*(h+2*l)+c):h<=v?(d=0,h=Math.min(Math.max(-r,-l),r),p=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),p=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),p=-d*d+h*(h+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(vr).addScaledVector(fs,h),p}intersectSphere(e,t){dn.subVectors(e.center,this.origin);const n=dn.dot(this.direction),s=dn.dot(dn)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(n=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(n=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),n>l||o>s)||((o>n||n!==n)&&(n=o),(l=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,dn)!==null}intersectTriangle(e,t,n,s,r){xr.subVectors(t,e),ds.subVectors(n,e),Mr.crossVectors(xr,ds);let a=this.direction.dot(Mr),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ln.subVectors(this.origin,e);const l=o*this.direction.dot(ds.crossVectors(Ln,ds));if(l<0)return null;const c=o*this.direction.dot(xr.cross(Ln));if(c<0||l+c>a)return null;const u=-o*Ln.dot(Mr);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Nl extends It{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ce(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new on,this.combine=ks,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const To=new je,Gn=new Oa,ps=new Xs,Ao=new C,ms=new C,gs=new C,_s=new C,Sr=new C,vs=new C,wo=new C,xs=new C;class yn extends ht{constructor(e=new Dt,t=new Nl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(To.copy(r).invert(),Gn.copy(e.ray).applyMatrix4(To),!(n.boundingBox!==null&&Gn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Gn)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let v=0,S=h.length;vt.far?null:{distance:c,point:xs.clone(),object:i}}function Ms(i,e,t,n,s,r,a,o,l,c){i.getVertexPosition(o,ms),i.getVertexPosition(l,gs),i.getVertexPosition(c,_s);const u=Th(i,e,t,n,ms,gs,_s,wo);if(u){const d=new C;Wt.getBarycoord(wo,ms,gs,_s,d),s&&(u.uv=Wt.getInterpolatedAttribute(s,o,l,c,d,new _e)),r&&(u.uv1=Wt.getInterpolatedAttribute(r,o,l,c,d,new _e)),a&&(u.normal=Wt.getInterpolatedAttribute(a,o,l,c,d,new C),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new C,materialIndex:0};Wt.getNormal(ms,gs,_s,h.normal),u.face=h,u.barycoord=d}return u}class Ah extends St{constructor(e=null,t=1,n=1,s,r,a,o,l,c=mt,u=mt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class zg extends Vt{constructor(e,t,n,s=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const yr=new C,wh=new C,Rh=new Le;class kn{constructor(e=new C(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=yr.subVectors(n,t).cross(wh.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const s=e.delta(yr),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Rh.getNormalMatrix(e),s=this.coplanarPoint(yr).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Hn=new Xs,Ch=new _e(.5,.5),Ss=new C;class Zi{constructor(e=new kn,t=new kn,n=new kn,s=new kn,r=new kn,a=new kn){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Jt,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],p=r[7],v=r[8],S=r[9],g=r[10],f=r[11],w=r[12],A=r[13],M=r[14],T=r[15];if(s[0].setComponents(c-a,p-u,f-v,T-w).normalize(),s[1].setComponents(c+a,p+u,f+v,T+w).normalize(),s[2].setComponents(c+o,p+d,f+S,T+A).normalize(),s[3].setComponents(c-o,p-d,f-S,T-A).normalize(),n)s[4].setComponents(l,h,g,M).normalize(),s[5].setComponents(c-l,p-h,f-g,T-M).normalize();else if(s[4].setComponents(c-l,p-h,f-g,T-M).normalize(),t===Jt)s[5].setComponents(c+l,p+h,f+g,T+M).normalize();else if(t===qi)s[5].setComponents(l,h,g,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Hn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Hn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Hn)}intersectsSprite(e){Hn.center.set(0,0,0);const t=Ch.distanceTo(e.center);return Hn.radius=.7071067811865476+t,Hn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Hn)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,Ss.y=s.normal.y>0?e.max.y:e.min.y,Ss.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Ss)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Ro=new je;class Fl{constructor(){this.coordinateSystem=Jt,this._frustums=[],this._count=0}setFromArrayCamera(e){const t=e.cameras,n=this._frustums;for(let s=0;s0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;rn)return;Er.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Er);if(!(ce.far))return{distance:c,point:Po.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}class Gg extends It{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ce(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}class Hg extends St{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=mt,this.minFilter=mt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Bl extends St{constructor(e=[],t=Zn,n,s,r,a,o,l,c,u){super(e,t,n,s,r,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class kg extends St{constructor(e,t,n,s,r,a,o,l,c){super(e,t,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class bi extends St{constructor(e,t,n=an,s,r,a,o=mt,l=mt,c,u=Sn,d=1){if(u!==Sn&&u!==Yn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const h={width:e,height:t,depth:d};super(h,s,r,a,o,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Na(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Ph extends bi{constructor(e,t=an,n=Zn,s,r,a=mt,o=mt,l,c=Sn){const u={width:e,height:e,depth:1},d=[u,u,u,u,u,u];super(e,e,t,n,s,r,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class zl extends St{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Ki extends Dt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],u=[],d=[];let h=0,p=0;v("z","y","x",-1,-1,n,t,e,a,r,0),v("z","y","x",1,-1,n,t,-e,a,r,1),v("x","z","y",1,1,e,n,t,s,a,2),v("x","z","y",1,-1,e,n,-t,s,a,3),v("x","y","z",1,-1,e,t,n,s,r,4),v("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new gt(c,3)),this.setAttribute("normal",new gt(u,3)),this.setAttribute("uv",new gt(d,2));function v(S,g,f,w,A,M,T,E,R,_,b){const D=M/R,P=T/_,N=M/2,X=T/2,Y=E/2,z=R+1,W=_+1;let H=0,$=0;const j=new C;for(let he=0;he0?1:-1,u.push(j.x,j.y,j.z),d.push(ve/R),d.push(1-he/_),H+=1}}for(let he=0;he<_;he++)for(let pe=0;pe0&&A(!0),t>0&&A(!1)),this.setIndex(u),this.setAttribute("position",new gt(d,3)),this.setAttribute("normal",new gt(h,3)),this.setAttribute("uv",new gt(p,2));function w(){const M=new C,T=new C;let E=0;const R=(t-e)/n;for(let _=0;_<=r;_++){const b=[],D=_/r,P=D*(t-e)+e;for(let N=0;N<=s;N++){const X=N/s,Y=X*l+o,z=Math.sin(Y),W=Math.cos(Y);T.x=P*z,T.y=-D*n+g,T.z=P*W,d.push(T.x,T.y,T.z),M.set(z,R,W).normalize(),h.push(M.x,M.y,M.z),p.push(X,1-D),b.push(v++)}S.push(b)}for(let _=0;_0||b!==0)&&(u.push(D,P,X),E+=3),(t>0||b!==r-1)&&(u.push(P,N,X),E+=3)}c.addGroup(f,E,0),f+=E}function A(M){const T=v,E=new _e,R=new C;let _=0;const b=M===!0?e:t,D=M===!0?1:-1;for(let N=1;N<=s;N++)d.push(0,g*D,0),h.push(0,D,0),p.push(.5,.5),v++;const P=v;for(let N=0;N<=s;N++){const Y=N/s*l+o,z=Math.cos(Y),W=Math.sin(Y);R.x=b*W,R.y=g*D,R.z=b*z,d.push(R.x,R.y,R.z),h.push(0,D,0),E.x=z*.5+.5,E.y=W*.5*D+.5,p.push(E.x,E.y),v++}for(let N=0;N0)l=s-1;else{l=s;break}if(s=l,n[s]===a)return s/(r-1);const u=n[s],h=n[s+1]-u,p=(a-u)/h;return(s+p)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new _e:new C);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new C,s=[],r=[],a=[],o=new C,l=new je;for(let p=0;p<=e;p++){const v=p/e;s[p]=this.getTangentAt(v,new C)}r[0]=new C,a[0]=new C;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),h<=c&&n.set(0,0,1),o.crossVectors(s[0],n).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(s[p-1],s[p]),o.length()>Number.EPSILON){o.normalize();const v=Math.acos(Fe(s[p-1].dot(s[p]),-1,1));r[p].applyMatrix4(l.makeRotationAxis(o,v))}a[p].crossVectors(s[p],r[p])}if(t===!0){let p=Math.acos(Fe(r[0].dot(r[e]),-1,1));p/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(p=-p);for(let v=1;v<=e;v++)r[v].applyMatrix4(l.makeRotationAxis(s[v],p*v)),a[v].crossVectors(s[v],r[v])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gl extends En{constructor(e=0,t=0,n=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new _e){const n=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Do.subVectors(s[0],s[1]).add(s[0]),c=Do);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return n.set(Io(o,l.x,c.x,u.x,d.x),Io(o,l.y,c.y,u.y,d.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t0)&&p.push(A,M,E),(f!==n-1||l0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new Ce().setHex(s.value);break;case"v2":this.uniforms[n].value=new _e().fromArray(s.value);break;case"v3":this.uniforms[n].value=new C().fromArray(s.value);break;case"v4":this.uniforms[n].value=new nt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Le().fromArray(s.value);break;case"m4":this.uniforms[n].value=new je().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class $h extends ln{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Qh extends It{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ce(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new _e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new on,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Xg extends Qh{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new _e(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Fe(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ce(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ce(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ce(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class qg extends It{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ce(16777215),this.specular=new Ce(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new _e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new on,this.combine=ks,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Yg extends It{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ce(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new _e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Zg extends It{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new _e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Jg extends It{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ce(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ce(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new _e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new on,this.combine=ks,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jh extends It{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Dc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class eu extends It{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Kg extends It{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ce(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Fn,this.normalScale=new _e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class $g extends Ol{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const wr={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(No(i)||(this.files[i]=e))},get:function(i){if(this.enabled!==!1&&!No(i))return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};function No(i){try{const e=i.slice(i.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class tu{constructor(e,t,n){const s=this;let r=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(u){o++,r===!1&&s.onStart!==void 0&&s.onStart(u,a,o),r=!0},this.itemEnd=function(u){a++,s.onProgress!==void 0&&s.onProgress(u,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(u){s.onError!==void 0&&s.onError(u)},this.resolveURL=function(u){return u=u.normalize("NFC"),l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){const d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=c.length;dp.start-v.start);let h=0;for(let p=1;p 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,Cu=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,Pu=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,Lu=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,Du=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,Iu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,Uu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Nu=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,Fu=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,Ou=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Bu=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,zu=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Vu=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Gu=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Hu=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,ku="gl_FragColor = linearToOutputTexel( gl_FragColor );",Wu=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,Xu=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,qu=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Yu=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Zu=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Ju=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ku=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,$u=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Qu=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,ju=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,ef=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,tf=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,nf=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,sf=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,rf=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,af=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,of=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,lf=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,cf=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,hf=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,uf=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,ff=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,df=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,pf=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,mf=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,gf=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,_f=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,vf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,xf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Mf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,Sf=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,yf=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,Ef=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,bf=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,Tf=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,Af=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,wf=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,Rf=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,Cf=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,Pf=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,Lf=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,Df=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,If=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,Uf=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,Nf=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,Ff=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,Of=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,Bf=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,zf=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,Vf=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,Gf=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,Hf=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,kf=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,Wf=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,Xf=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,qf=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Yf=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,Zf=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,Jf=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,Kf=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,$f=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,Qf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,jf=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,ed=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,td=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,nd=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,id=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,sd=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,rd=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,ad=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,od=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,ld=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,cd=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,hd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,ud=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,fd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,dd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const pd=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,md=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,gd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,_d=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,vd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,xd=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,Md=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,Sd=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,yd=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,Ed=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,bd=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,Td=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,Ad=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,wd=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rd=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Cd=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,Pd=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Ld=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Dd=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,Id=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,Ud=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,Nd=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Fd=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,Od=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Bd=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,zd=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Vd=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Gd=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Hd=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,kd=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Wd=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Xd=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,qd=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Yd=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,Oe={alphahash_fragment:du,alphahash_pars_fragment:pu,alphamap_fragment:mu,alphamap_pars_fragment:gu,alphatest_fragment:_u,alphatest_pars_fragment:vu,aomap_fragment:xu,aomap_pars_fragment:Mu,batching_pars_vertex:Su,batching_vertex:yu,begin_vertex:Eu,beginnormal_vertex:bu,bsdfs:Tu,iridescence_fragment:Au,bumpmap_pars_fragment:wu,clipping_planes_fragment:Ru,clipping_planes_pars_fragment:Cu,clipping_planes_pars_vertex:Pu,clipping_planes_vertex:Lu,color_fragment:Du,color_pars_fragment:Iu,color_pars_vertex:Uu,color_vertex:Nu,common:Fu,cube_uv_reflection_fragment:Ou,defaultnormal_vertex:Bu,displacementmap_pars_vertex:zu,displacementmap_vertex:Vu,emissivemap_fragment:Gu,emissivemap_pars_fragment:Hu,colorspace_fragment:ku,colorspace_pars_fragment:Wu,envmap_fragment:Xu,envmap_common_pars_fragment:qu,envmap_pars_fragment:Yu,envmap_pars_vertex:Zu,envmap_physical_pars_fragment:af,envmap_vertex:Ju,fog_vertex:Ku,fog_pars_vertex:$u,fog_fragment:Qu,fog_pars_fragment:ju,gradientmap_pars_fragment:ef,lightmap_pars_fragment:tf,lights_lambert_fragment:nf,lights_lambert_pars_fragment:sf,lights_pars_begin:rf,lights_toon_fragment:of,lights_toon_pars_fragment:lf,lights_phong_fragment:cf,lights_phong_pars_fragment:hf,lights_physical_fragment:uf,lights_physical_pars_fragment:ff,lights_fragment_begin:df,lights_fragment_maps:pf,lights_fragment_end:mf,lightprobes_pars_fragment:gf,logdepthbuf_fragment:_f,logdepthbuf_pars_fragment:vf,logdepthbuf_pars_vertex:xf,logdepthbuf_vertex:Mf,map_fragment:Sf,map_pars_fragment:yf,map_particle_fragment:Ef,map_particle_pars_fragment:bf,metalnessmap_fragment:Tf,metalnessmap_pars_fragment:Af,morphinstance_vertex:wf,morphcolor_vertex:Rf,morphnormal_vertex:Cf,morphtarget_pars_vertex:Pf,morphtarget_vertex:Lf,normal_fragment_begin:Df,normal_fragment_maps:If,normal_pars_fragment:Uf,normal_pars_vertex:Nf,normal_vertex:Ff,normalmap_pars_fragment:Of,clearcoat_normal_fragment_begin:Bf,clearcoat_normal_fragment_maps:zf,clearcoat_pars_fragment:Vf,iridescence_pars_fragment:Gf,opaque_fragment:Hf,packing:kf,premultiplied_alpha_fragment:Wf,project_vertex:Xf,dithering_fragment:qf,dithering_pars_fragment:Yf,roughnessmap_fragment:Zf,roughnessmap_pars_fragment:Jf,shadowmap_pars_fragment:Kf,shadowmap_pars_vertex:$f,shadowmap_vertex:Qf,shadowmask_pars_fragment:jf,skinbase_vertex:ed,skinning_pars_vertex:td,skinning_vertex:nd,skinnormal_vertex:id,specularmap_fragment:sd,specularmap_pars_fragment:rd,tonemapping_fragment:ad,tonemapping_pars_fragment:od,transmission_fragment:ld,transmission_pars_fragment:cd,uv_pars_fragment:hd,uv_pars_vertex:ud,uv_vertex:fd,worldpos_vertex:dd,background_vert:pd,background_frag:md,backgroundCube_vert:gd,backgroundCube_frag:_d,cube_vert:vd,cube_frag:xd,depth_vert:Md,depth_frag:Sd,distance_vert:yd,distance_frag:Ed,equirect_vert:bd,equirect_frag:Td,linedashed_vert:Ad,linedashed_frag:wd,meshbasic_vert:Rd,meshbasic_frag:Cd,meshlambert_vert:Pd,meshlambert_frag:Ld,meshmatcap_vert:Dd,meshmatcap_frag:Id,meshnormal_vert:Ud,meshnormal_frag:Nd,meshphong_vert:Fd,meshphong_frag:Od,meshphysical_vert:Bd,meshphysical_frag:zd,meshtoon_vert:Vd,meshtoon_frag:Gd,points_vert:Hd,points_frag:kd,shadow_vert:Wd,shadow_frag:Xd,sprite_vert:qd,sprite_frag:Yd},ce={common:{diffuse:{value:new Ce(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Le}},envmap:{envMap:{value:null},envMapRotation:{value:new Le},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Le}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Le}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Le},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Le},normalScale:{value:new _e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Le},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Le}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Le}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Le}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ce(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new Ce(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0},uvTransform:{value:new Le}},sprite:{diffuse:{value:new Ce(16777215)},opacity:{value:1},center:{value:new _e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}}},tn={basic:{uniforms:Rt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.fog]),vertexShader:Oe.meshbasic_vert,fragmentShader:Oe.meshbasic_frag},lambert:{uniforms:Rt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new Ce(0)},envMapIntensity:{value:1}}]),vertexShader:Oe.meshlambert_vert,fragmentShader:Oe.meshlambert_frag},phong:{uniforms:Rt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new Ce(0)},specular:{value:new Ce(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Oe.meshphong_vert,fragmentShader:Oe.meshphong_frag},standard:{uniforms:Rt([ce.common,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.roughnessmap,ce.metalnessmap,ce.fog,ce.lights,{emissive:{value:new Ce(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Oe.meshphysical_vert,fragmentShader:Oe.meshphysical_frag},toon:{uniforms:Rt([ce.common,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.gradientmap,ce.fog,ce.lights,{emissive:{value:new Ce(0)}}]),vertexShader:Oe.meshtoon_vert,fragmentShader:Oe.meshtoon_frag},matcap:{uniforms:Rt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,{matcap:{value:null}}]),vertexShader:Oe.meshmatcap_vert,fragmentShader:Oe.meshmatcap_frag},points:{uniforms:Rt([ce.points,ce.fog]),vertexShader:Oe.points_vert,fragmentShader:Oe.points_frag},dashed:{uniforms:Rt([ce.common,ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Oe.linedashed_vert,fragmentShader:Oe.linedashed_frag},depth:{uniforms:Rt([ce.common,ce.displacementmap]),vertexShader:Oe.depth_vert,fragmentShader:Oe.depth_frag},normal:{uniforms:Rt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,{opacity:{value:1}}]),vertexShader:Oe.meshnormal_vert,fragmentShader:Oe.meshnormal_frag},sprite:{uniforms:Rt([ce.sprite,ce.fog]),vertexShader:Oe.sprite_vert,fragmentShader:Oe.sprite_frag},background:{uniforms:{uvTransform:{value:new Le},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Oe.background_vert,fragmentShader:Oe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Le}},vertexShader:Oe.backgroundCube_vert,fragmentShader:Oe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Oe.cube_vert,fragmentShader:Oe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Oe.equirect_vert,fragmentShader:Oe.equirect_frag},distance:{uniforms:Rt([ce.common,ce.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Oe.distance_vert,fragmentShader:Oe.distance_frag},shadow:{uniforms:Rt([ce.lights,ce.fog,{color:{value:new Ce(0)},opacity:{value:1}}]),vertexShader:Oe.shadow_vert,fragmentShader:Oe.shadow_frag}};tn.physical={uniforms:Rt([tn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Le},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Le},clearcoatNormalScale:{value:new _e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Le},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Le},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Le},sheen:{value:0},sheenColor:{value:new Ce(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Le},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Le},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Le},transmissionSamplerSize:{value:new _e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Le},attenuationDistance:{value:0},attenuationColor:{value:new Ce(0)},specularColor:{value:new Ce(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Le},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Le},anisotropyVector:{value:new _e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Le}}]),vertexShader:Oe.meshphysical_vert,fragmentShader:Oe.meshphysical_frag};const As={r:0,b:0,g:0},Zd=new je,Zl=new Le;Zl.set(-1,0,0,0,1,0,0,0,1);function Jd(i,e,t,n,s,r){const a=new Ce(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function p(w){let A=w.isScene===!0?w.background:null;if(A&&A.isTexture){const M=w.backgroundBlurriness>0;A=e.get(A,M)}return A}function v(w){let A=!1;const M=p(w);M===null?g(a,o):M&&M.isColor&&(g(M,1),A=!0);const T=i.xr.getEnvironmentBlendMode();T==="additive"?t.buffers.color.setClear(0,0,0,1,r):T==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function S(w,A){const M=p(A);M&&(M.isCubeTexture||M.mapping===Ws)?(c===void 0&&(c=new yn(new Ki(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:Ti(tn.backgroundCube.uniforms),vertexShader:tn.backgroundCube.vertexShader,fragmentShader:tn.backgroundCube.fragmentShader,side:Lt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(T,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Zd.makeRotationFromEuler(A.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Zl),c.material.toneMapped=Ge.getTransfer(M.colorSpace)!==Ze,(u!==M||d!==M.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,u=M,d=M.version,h=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new yn(new qs(2,2),new ln({name:"BackgroundMaterial",uniforms:Ti(tn.background.uniforms),vertexShader:tn.background.vertexShader,fragmentShader:tn.background.fragmentShader,side:Nn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.toneMapped=Ge.getTransfer(M.colorSpace)!==Ze,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(u!==M||d!==M.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,u=M,d=M.version,h=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null))}function g(w,A){w.getRGB(As,Xl(i)),t.buffers.color.setClear(As.r,As.g,As.b,A,r)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(w,A=1){a.set(w),o=A,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(w){o=w,g(a,o)},render:v,addToRenderList:S,dispose:f}}function Kd(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=h(null);let r=s,a=!1;function o(P,N,X,Y,z){let W=!1;const H=d(P,Y,X,N);r!==H&&(r=H,c(r.object)),W=p(P,Y,X,z),W&&v(P,Y,X,z),z!==null&&e.update(z,i.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,M(P,N,X,Y),z!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(z).buffer))}function l(){return i.createVertexArray()}function c(P){return i.bindVertexArray(P)}function u(P){return i.deleteVertexArray(P)}function d(P,N,X,Y){const z=Y.wireframe===!0;let W=n[N.id];W===void 0&&(W={},n[N.id]=W);const H=P.isInstancedMesh===!0?P.id:0;let $=W[H];$===void 0&&($={},W[H]=$);let j=$[X.id];j===void 0&&(j={},$[X.id]=j);let he=j[z];return he===void 0&&(he=h(l()),j[z]=he),he}function h(P){const N=[],X=[],Y=[];for(let z=0;z=0){const pe=z[j];let ve=W[j];if(ve===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(ve=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(ve=P.instanceColor)),pe===void 0||pe.attribute!==ve||ve&&pe.data!==ve.data)return!0;H++}return r.attributesNum!==H||r.index!==Y}function v(P,N,X,Y){const z={},W=N.attributes;let H=0;const $=X.getAttributes();for(const j in $)if($[j].location>=0){let pe=W[j];pe===void 0&&(j==="instanceMatrix"&&P.instanceMatrix&&(pe=P.instanceMatrix),j==="instanceColor"&&P.instanceColor&&(pe=P.instanceColor));const ve={};ve.attribute=pe,pe&&pe.data&&(ve.data=pe.data),z[j]=ve,H++}r.attributes=z,r.attributesNum=H,r.index=Y}function S(){const P=r.newAttributes;for(let N=0,X=P.length;N=0){let he=z[$];if(he===void 0&&($==="instanceMatrix"&&P.instanceMatrix&&(he=P.instanceMatrix),$==="instanceColor"&&P.instanceColor&&(he=P.instanceColor)),he!==void 0){const pe=he.normalized,ve=he.itemSize,We=e.get(he);if(We===void 0)continue;const it=We.buffer,Xe=We.type,K=We.bytesPerElement,ie=Xe===i.INT||Xe===i.UNSIGNED_INT||he.gpuType===Aa;if(he.isInterleavedBufferAttribute){const ee=he.data,Pe=ee.stride,De=he.offset;if(ee.isInstancedInterleavedBuffer){for(let we=0;we0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ae("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ae("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),S=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),T=i.getParameter(i.MAX_SAMPLES),E=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:v,maxTextureSize:S,maxCubemapSize:g,maxAttributes:f,maxVertexUniforms:w,maxVaryings:A,maxFragmentUniforms:M,maxSamples:T,samples:E}}function jd(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new kn,o=new Le,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const p=d.length!==0||h||n!==0||s;return s=h,n=d.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,p){const v=d.clippingPlanes,S=d.clipIntersection,g=d.clipShadows,f=i.get(d);if(!s||v===null||v.length===0||r&&!g)r?u(null):c();else{const w=r?0:n,A=w*4;let M=f.clippingState||null;l.value=M,M=u(v,h,A,p);for(let T=0;T!==A;++T)M[T]=t[T];f.clippingState=M,this.numIntersection=S?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(d,h,p,v){const S=d!==null?d.length:0;let g=null;if(S!==0){if(g=l.value,v!==!0||g===null){const f=p+S*4,w=h.matrixWorldInverse;o.getNormalMatrix(w),(g===null||g.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Jo(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Zo(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?T:0,T,T),d.setRenderTarget(s),f&&d.render(S,l),d.render(e,l)}d.toneMapping=p,d.autoClear=h,e.background=w}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Zn||e.mapping===yi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Jo()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Zo());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;_i(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Fi)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rv-Un?n-v+Un:0),f=4*(this._cubeSize-S);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=v-t,_i(r,g,f,3*S,2*S),s.setRenderTarget(r),s.render(o,Fi),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=v-n,_i(e,g,f,3*S,2*S),s.setRenderTarget(e),s.render(o,Fi)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ve("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,p=this._sizeLods[n]-1,v=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Xn-1),S=r/v,g=isFinite(r)?1+Math.floor(u*S):Xn;g>Xn&&Ae(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Xn}`);const f=[];let w=0;for(let R=0;RA-Un?s-A+Un:0),E=4*(this._cubeSize-M);_i(t,T,E,3*M,2*M),l.setRenderTarget(t),l.render(d,Fi)}}function np(i){const e=[],t=[],n=[];let s=i;const r=i-Un+1+Wo.length;for(let a=0;ai-Un?l=Wo[a-i+Un-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,v=6,S=3,g=2,f=1,w=new Float32Array(S*v*p),A=new Float32Array(g*v*p),M=new Float32Array(f*v*p);for(let E=0;E2?0:-1,b=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];w.set(b,S*v*E),A.set(h,g*v*E);const D=[E,E,E,E,E,E];M.set(D,f*v*E)}const T=new Dt;T.setAttribute("position",new Vt(w,S)),T.setAttribute("uv",new Vt(A,g)),T.setAttribute("faceIndex",new Vt(M,f)),n.push(new yn(T,null)),s>Un&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Yo(i,e,t){const n=new rn(i,e,t);return n.texture.mapping=Ws,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function _i(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function ip(i,e,t){return new ln({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ep,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ys(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:_n,depthTest:!1,depthWrite:!1})}function sp(i,e,t){const n=new Float32Array(Xn),s=new C(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:Xn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Ys(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:_n,depthTest:!1,depthWrite:!1})}function Zo(){return new ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ys(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:_n,depthTest:!1,depthWrite:!1})}function Jo(){return new ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ys(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:_n,depthTest:!1,depthWrite:!1})}function Ys(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Jl extends rn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Bl(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Ki(5,5,5),r=new ln({name:"CubemapFromEquirect",uniforms:Ti(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Lt,blending:_n});r.uniforms.tEquirect.value=t;const a=new yn(s,r),o=t.minFilter;return t.minFilter===qn&&(t.minFilter=At),new lu(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}function rp(i){let e=new WeakMap,t=new WeakMap,n=null;function s(h,p=!1){return h==null?null:p?a(h):r(h)}function r(h){if(h&&h.isTexture){const p=h.mapping;if(p===$s||p===Qs)if(e.has(h)){const v=e.get(h).texture;return o(v,h.mapping)}else{const v=h.image;if(v&&v.height>0){const S=new Jl(v.height);return S.fromEquirectangularTexture(i,h),e.set(h,S),h.addEventListener("dispose",c),o(S.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const p=h.mapping,v=p===$s||p===Qs,S=p===Zn||p===yi;if(v||S){let g=t.get(h);const f=g!==void 0?g.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==f)return n===null&&(n=new qo(i)),g=v?n.fromEquirectangular(h,g):n.fromCubemap(h,g),g.texture.pmremVersion=h.pmremVersion,t.set(h,g),g.texture;if(g!==void 0)return g.texture;{const w=h.image;return v&&w&&w.height>0||S&&w&&l(w)?(n===null&&(n=new qo(i)),g=v?n.fromEquirectangular(h):n.fromCubemap(h),g.texture.pmremVersion=h.pmremVersion,t.set(h,g),h.addEventListener("dispose",u),g.texture):null}}}return h}function o(h,p){return p===$s?h.mapping=Zn:p===Qs&&(h.mapping=yi),h}function l(h){let p=0;const v=6;for(let S=0;S=65535?Dl:Ll)(h,1);g.version=S;const f=r.get(d);f&&e.remove(f),r.set(d,g)}function u(d){const h=r.get(d);if(h){const p=d.index;p!==null&&h.versione.maxTextureSize&&(T=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const E=new Float32Array(M*T*4*d),R=new Cl(E,M,T,d);R.type=nn,R.needsUpdate=!0;const _=A*4;for(let D=0;D + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new yn(l,c),d=new Ha(-1,1,1,-1,0,1);let h=null,p=null,v=!1,S,g=null,f=[],w=!1;this.setSize=function(A,M){a.setSize(A,M),o.setSize(A,M);for(let T=0;T0&&f[0].isRenderPass===!0;const M=a.width,T=a.height;for(let E=0;E0)return i;const s=e*t;let r=Ko[s];if(r===void 0&&(r=new Float32Array(s),Ko[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function _t(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=s.concat(r))}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function nl(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const sm=37297;let rm=0;function am(i,e){const t=i.split(` +`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return n.join(` +`)}const il=new Le;function om(i){Ge._getMatrix(il,Ge.workingColorSpace,i);const e=`mat3( ${il.elements.map(t=>t.toFixed(4))} )`;switch(Ge.getTransfer(i)){case Os:return[e,"LinearTransferOETF"];case Ze:return[e,"sRGBTransferOETF"];default:return Ae("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function sl(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+am(i.getShaderSource(e),o)}else return r}function lm(i,e){const t=om(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const cm={[dl]:"Linear",[pl]:"Reinhard",[ml]:"Cineon",[gl]:"ACESFilmic",[vl]:"AgX",[xl]:"Neutral",[_l]:"Custom"};function hm(i,e){const t=cm[e];return t===void 0?(Ae("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ws=new C;function um(){Ge.getLuminanceCoefficients(ws);const i=ws.x.toFixed(4),e=ws.y.toFixed(4),t=ws.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function fm(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(zi).join(` +`)}function dm(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` +`)}function pm(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Ta(i){return i.replace(mm,_m)}const gm=new Map;function _m(i,e){let t=Oe[e];if(t===void 0){const n=gm.get(e);if(n!==void 0)t=Oe[n],Ae('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Ta(t)}const vm=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ol(i){return i.replace(vm,xm)}function xm(i,e,t,n){let s="";for(let r=parseInt(e);r0&&(g+=` +`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(zi).join(` +`),f.length>0&&(f+=` +`)):(g=[ll(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(zi).join(` +`),f=[ll(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==sn?"#define TONE_MAPPING":"",t.toneMapping!==sn?Oe.tonemapping_pars_fragment:"",t.toneMapping!==sn?hm("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Oe.colorspace_pars_fragment,lm("linearToOutputTexel",t.outputColorSpace),um(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(zi).join(` +`)),a=Ta(a),a=rl(a,t),a=al(a,t),o=Ta(o),o=rl(o,t),o=al(o,t),a=ol(a),o=ol(o),t.isRawShaderMaterial!==!0&&(w=`#version 300 es +`,g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+g,f=["#define varying in",t.glslVersion===lo?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===lo?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+f);const A=w+g+a,M=w+f+o,T=nl(s,s.VERTEX_SHADER,A),E=nl(s,s.FRAGMENT_SHADER,M);s.attachShader(S,T),s.attachShader(S,E),t.index0AttributeName!==void 0?s.bindAttribLocation(S,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(S,0,"position"),s.linkProgram(S);function R(P){if(i.debug.checkShaderErrors){const N=s.getProgramInfoLog(S)||"",X=s.getShaderInfoLog(T)||"",Y=s.getShaderInfoLog(E)||"",z=N.trim(),W=X.trim(),H=Y.trim();let $=!0,j=!0;if(s.getProgramParameter(S,s.LINK_STATUS)===!1)if($=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,S,T,E);else{const he=sl(s,T,"vertex"),pe=sl(s,E,"fragment");Ve("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(S,s.VALIDATE_STATUS)+` + +Material Name: `+P.name+` +Material Type: `+P.type+` + +Program Info Log: `+z+` +`+he+` +`+pe)}else z!==""?Ae("WebGLProgram: Program Info Log:",z):(W===""||H==="")&&(j=!1);j&&(P.diagnostics={runnable:$,programLog:z,vertexShader:{log:W,prefix:g},fragmentShader:{log:H,prefix:f}})}s.deleteShader(T),s.deleteShader(E),_=new Is(s,S),b=pm(s,S)}let _;this.getUniforms=function(){return _===void 0&&R(this),_};let b;this.getAttributes=function(){return b===void 0&&R(this),b};let D=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=s.getProgramParameter(S,sm)),D},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=rm++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=T,this.fragmentShader=E,this}let Pm=0;class Lm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Dm(e),t.set(e,n)),n}}class Dm{constructor(e){this.id=Pm++,this.code=e,this.usedTimes=0}}function Im(i){return i===Jn||i===Us||i===Ns}function Um(i,e,t,n,s,r){const a=new Fa,o=new Lm,l=new Set,c=[],u=new Map,d=n.logarithmicDepthBuffer;let h=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(_){return l.add(_),_===0?"uv":`uv${_}`}function S(_,b,D,P,N,X){const Y=P.fog,z=N.geometry,W=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?P.environment:null,H=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,$=e.get(_.envMap||W,H),j=$&&$.mapping===Ws?$.image.height:null,he=p[_.type];_.precision!==null&&(h=n.getMaxPrecision(_.precision),h!==_.precision&&Ae("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead."));const pe=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,ve=pe!==void 0?pe.length:0;let We=0;z.morphAttributes.position!==void 0&&(We=1),z.morphAttributes.normal!==void 0&&(We=2),z.morphAttributes.color!==void 0&&(We=3);let it,Xe,K,ie;if(he){const xe=tn[he];it=xe.vertexShader,Xe=xe.fragmentShader}else{it=_.vertexShader,Xe=_.fragmentShader;const xe=o.getVertexShaderStage(_),rt=o.getFragmentShaderStage(_);o.update(_,xe,rt),K=xe.id,ie=rt.id}const ee=i.getRenderTarget(),Pe=i.state.buffers.depth.getReversed(),De=N.isInstancedMesh===!0,we=N.isBatchedMesh===!0,ot=!!_.map,ze=!!_.matcap,Ke=!!$,qe=!!_.aoMap,He=!!_.lightMap,ut=!!_.bumpMap&&_.wireframe===!1,pt=!!_.normalMap,xt=!!_.displacementMap,yt=!!_.emissiveMap,st=!!_.metalnessMap,ft=!!_.roughnessMap,I=_.anisotropy>0,Pt=_.clearcoat>0,Ye=_.dispersion>0,y=_.iridescence>0,m=_.sheen>0,F=_.transmission>0,V=I&&!!_.anisotropyMap,k=Pt&&!!_.clearcoatMap,te=Pt&&!!_.clearcoatNormalMap,se=Pt&&!!_.clearcoatRoughnessMap,q=y&&!!_.iridescenceMap,J=y&&!!_.iridescenceThicknessMap,re=m&&!!_.sheenColorMap,ye=m&&!!_.sheenRoughnessMap,le=!!_.specularMap,ae=!!_.specularColorMap,Te=!!_.specularIntensityMap,Re=F&&!!_.transmissionMap,Ie=F&&!!_.thicknessMap,L=!!_.gradientMap,ne=!!_.alphaMap,Z=_.alphaTest>0,oe=!!_.alphaHash,de=!!_.extensions;let Q=sn;_.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(Q=i.toneMapping);const Se={shaderID:he,shaderType:_.type,shaderName:_.name,vertexShader:it,fragmentShader:Xe,defines:_.defines,customVertexShaderID:K,customFragmentShaderID:ie,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:we,batchingColor:we&&N._colorsTexture!==null,instancing:De,instancingColor:De&&N.instanceColor!==null,instancingMorph:De&&N.morphTexture!==null,outputColorSpace:ee===null?i.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:Ge.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:ot,matcap:ze,envMap:Ke,envMapMode:Ke&&$.mapping,envMapCubeUVHeight:j,aoMap:qe,lightMap:He,bumpMap:ut,normalMap:pt,displacementMap:xt,emissiveMap:yt,normalMapObjectSpace:pt&&_.normalMapType===Ic,normalMapTangentSpace:pt&&_.normalMapType===Fn,packedNormalMap:pt&&_.normalMapType===Fn&&Im(_.normalMap.format),metalnessMap:st,roughnessMap:ft,anisotropy:I,anisotropyMap:V,clearcoat:Pt,clearcoatMap:k,clearcoatNormalMap:te,clearcoatRoughnessMap:se,dispersion:Ye,iridescence:y,iridescenceMap:q,iridescenceThicknessMap:J,sheen:m,sheenColorMap:re,sheenRoughnessMap:ye,specularMap:le,specularColorMap:ae,specularIntensityMap:Te,transmission:F,transmissionMap:Re,thicknessMap:Ie,gradientMap:L,opaque:_.transparent===!1&&_.blending===vi&&_.alphaToCoverage===!1,alphaMap:ne,alphaTest:Z,alphaHash:oe,combine:_.combine,mapUv:ot&&v(_.map.channel),aoMapUv:qe&&v(_.aoMap.channel),lightMapUv:He&&v(_.lightMap.channel),bumpMapUv:ut&&v(_.bumpMap.channel),normalMapUv:pt&&v(_.normalMap.channel),displacementMapUv:xt&&v(_.displacementMap.channel),emissiveMapUv:yt&&v(_.emissiveMap.channel),metalnessMapUv:st&&v(_.metalnessMap.channel),roughnessMapUv:ft&&v(_.roughnessMap.channel),anisotropyMapUv:V&&v(_.anisotropyMap.channel),clearcoatMapUv:k&&v(_.clearcoatMap.channel),clearcoatNormalMapUv:te&&v(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:se&&v(_.clearcoatRoughnessMap.channel),iridescenceMapUv:q&&v(_.iridescenceMap.channel),iridescenceThicknessMapUv:J&&v(_.iridescenceThicknessMap.channel),sheenColorMapUv:re&&v(_.sheenColorMap.channel),sheenRoughnessMapUv:ye&&v(_.sheenRoughnessMap.channel),specularMapUv:le&&v(_.specularMap.channel),specularColorMapUv:ae&&v(_.specularColorMap.channel),specularIntensityMapUv:Te&&v(_.specularIntensityMap.channel),transmissionMapUv:Re&&v(_.transmissionMap.channel),thicknessMapUv:Ie&&v(_.thicknessMap.channel),alphaMapUv:ne&&v(_.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(pt||I),vertexNormals:!!z.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!z.attributes.uv&&(ot||ne),fog:!!Y,useFog:_.fog===!0,fogExp2:!!Y&&Y.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||z.attributes.normal===void 0&&pt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Pe,skinning:N.isSkinnedMesh===!0,hasPositionAttribute:z.attributes.position!==void 0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:ve,morphTextureStride:We,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numLightProbeGrids:X.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:Q,decodeVideoTexture:ot&&_.map.isVideoTexture===!0&&Ge.getTransfer(_.map.colorSpace)===Ze,decodeVideoTextureEmissive:yt&&_.emissiveMap.isVideoTexture===!0&&Ge.getTransfer(_.emissiveMap.colorSpace)===Ze,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===pn,flipSided:_.side===Lt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:de&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(de&&_.extensions.multiDraw===!0||we)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Se.vertexUv1s=l.has(1),Se.vertexUv2s=l.has(2),Se.vertexUv3s=l.has(3),l.clear(),Se}function g(_){const b=[];if(_.shaderID?b.push(_.shaderID):(b.push(_.customVertexShaderID),b.push(_.customFragmentShaderID)),_.defines!==void 0)for(const D in _.defines)b.push(D),b.push(_.defines[D]);return _.isRawShaderMaterial===!1&&(f(b,_),w(b,_),b.push(i.outputColorSpace)),b.push(_.customProgramCacheKey),b.join()}function f(_,b){_.push(b.precision),_.push(b.outputColorSpace),_.push(b.envMapMode),_.push(b.envMapCubeUVHeight),_.push(b.mapUv),_.push(b.alphaMapUv),_.push(b.lightMapUv),_.push(b.aoMapUv),_.push(b.bumpMapUv),_.push(b.normalMapUv),_.push(b.displacementMapUv),_.push(b.emissiveMapUv),_.push(b.metalnessMapUv),_.push(b.roughnessMapUv),_.push(b.anisotropyMapUv),_.push(b.clearcoatMapUv),_.push(b.clearcoatNormalMapUv),_.push(b.clearcoatRoughnessMapUv),_.push(b.iridescenceMapUv),_.push(b.iridescenceThicknessMapUv),_.push(b.sheenColorMapUv),_.push(b.sheenRoughnessMapUv),_.push(b.specularMapUv),_.push(b.specularColorMapUv),_.push(b.specularIntensityMapUv),_.push(b.transmissionMapUv),_.push(b.thicknessMapUv),_.push(b.combine),_.push(b.fogExp2),_.push(b.sizeAttenuation),_.push(b.morphTargetsCount),_.push(b.morphAttributeCount),_.push(b.numDirLights),_.push(b.numPointLights),_.push(b.numSpotLights),_.push(b.numSpotLightMaps),_.push(b.numHemiLights),_.push(b.numRectAreaLights),_.push(b.numDirLightShadows),_.push(b.numPointLightShadows),_.push(b.numSpotLightShadows),_.push(b.numSpotLightShadowsWithMaps),_.push(b.numLightProbes),_.push(b.shadowMapType),_.push(b.toneMapping),_.push(b.numClippingPlanes),_.push(b.numClipIntersection),_.push(b.depthPacking)}function w(_,b){a.disableAll(),b.instancing&&a.enable(0),b.instancingColor&&a.enable(1),b.instancingMorph&&a.enable(2),b.matcap&&a.enable(3),b.envMap&&a.enable(4),b.normalMapObjectSpace&&a.enable(5),b.normalMapTangentSpace&&a.enable(6),b.clearcoat&&a.enable(7),b.iridescence&&a.enable(8),b.alphaTest&&a.enable(9),b.vertexColors&&a.enable(10),b.vertexAlphas&&a.enable(11),b.vertexUv1s&&a.enable(12),b.vertexUv2s&&a.enable(13),b.vertexUv3s&&a.enable(14),b.vertexTangents&&a.enable(15),b.anisotropy&&a.enable(16),b.alphaHash&&a.enable(17),b.batching&&a.enable(18),b.dispersion&&a.enable(19),b.batchingColor&&a.enable(20),b.gradientMap&&a.enable(21),b.packedNormalMap&&a.enable(22),b.vertexNormals&&a.enable(23),_.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),b.numLightProbeGrids>0&&a.enable(22),b.hasPositionAttribute&&a.enable(23),_.push(a.mask)}function A(_){const b=p[_.type];let D;if(b){const P=tn[b];D=Zh.clone(P.uniforms)}else D=_.uniforms;return D}function M(_,b){let D=u.get(b);return D!==void 0?++D.usedTimes:(D=new Cm(i,b,_,s),c.push(D),u.set(b,D)),D}function T(_){if(--_.usedTimes===0){const b=c.indexOf(_);c[b]=c[c.length-1],c.pop(),u.delete(_.cacheKey),_.destroy()}}function E(_){o.remove(_)}function R(){o.dispose()}return{getParameters:S,getProgramCacheKey:g,getUniforms:A,acquireProgram:M,releaseProgram:T,releaseShaderCache:E,programs:c,dispose:R}}function Nm(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function Fm(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function cl(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function hl(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(h){let p=0;return h.isInstancedMesh&&(p+=2),h.isSkinnedMesh&&(p+=1),p}function o(h,p,v,S,g,f){let w=i[e];return w===void 0?(w={id:h.id,object:h,geometry:p,material:v,materialVariant:a(h),groupOrder:S,renderOrder:h.renderOrder,z:g,group:f},i[e]=w):(w.id=h.id,w.object=h,w.geometry=p,w.material=v,w.materialVariant=a(h),w.groupOrder=S,w.renderOrder=h.renderOrder,w.z=g,w.group=f),e++,w}function l(h,p,v,S,g,f){const w=o(h,p,v,S,g,f);v.transmission>0?n.push(w):v.transparent===!0?s.push(w):t.push(w)}function c(h,p,v,S,g,f){const w=o(h,p,v,S,g,f);v.transmission>0?n.unshift(w):v.transparent===!0?s.unshift(w):t.unshift(w)}function u(h,p,v){t.length>1&&t.sort(h||Fm),n.length>1&&n.sort(p||cl),s.length>1&&s.sort(p||cl),v&&(t.reverse(),n.reverse(),s.reverse())}function d(){for(let h=e,p=i.length;h=r.length?(a=new hl,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Bm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new Ce};break;case"SpotLight":t={position:new C,direction:new C,color:new Ce,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new Ce,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new Ce,groundColor:new Ce};break;case"RectAreaLight":t={color:new Ce,position:new C,halfWidth:new C,halfHeight:new C};break}return i[e.id]=t,t}}}function zm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _e};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _e};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _e,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Vm=0;function Gm(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Hm(i){const e=new Bm,t=zm(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);const s=new C,r=new je,a=new je;function o(c){let u=0,d=0,h=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let p=0,v=0,S=0,g=0,f=0,w=0,A=0,M=0,T=0,E=0,R=0;c.sort(Gm);for(let b=0,D=c.length;b0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ce.LTC_FLOAT_1,n.rectAreaLTC2=ce.LTC_FLOAT_2):(n.rectAreaLTC1=ce.LTC_HALF_1,n.rectAreaLTC2=ce.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=d,n.ambient[2]=h;const _=n.hash;(_.directionalLength!==p||_.pointLength!==v||_.spotLength!==S||_.rectAreaLength!==g||_.hemiLength!==f||_.numDirectionalShadows!==w||_.numPointShadows!==A||_.numSpotShadows!==M||_.numSpotMaps!==T||_.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=S,n.rectArea.length=g,n.point.length=v,n.hemi.length=f,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=A,n.pointShadowMap.length=A,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=A,n.spotLightMatrix.length=M+T-E,n.spotLightMap.length=T,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=R,_.directionalLength=p,_.pointLength=v,_.spotLength=S,_.rectAreaLength=g,_.hemiLength=f,_.numDirectionalShadows=w,_.numPointShadows=A,_.numSpotShadows=M,_.numSpotMaps=T,_.numLightProbes=R,n.version=Vm++)}function l(c,u){let d=0,h=0,p=0,v=0,S=0;const g=u.matrixWorldInverse;for(let f=0,w=c.length;f=a.length?(o=new ul(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Wm=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Xm=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`,qm=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],Ym=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],fl=new je,Oi=new C,Ur=new C;function Zm(i,e,t){let n=new Zi;const s=new _e,r=new _e,a=new nt,o=new jh,l=new eu,c={},u=t.maxTextureSize,d={[Nn]:Lt,[Lt]:Nn,[pn]:pn},h=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new _e},radius:{value:4}},vertexShader:Wm,fragmentShader:Xm}),p=h.clone();p.defines.HORIZONTAL_PASS=1;const v=new Dt;v.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new yn(v,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Rs;let f=this.type;this.render=function(E,R,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||E.length===0)return;this.type===hc&&(Ae("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Rs);const b=i.getRenderTarget(),D=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),N=i.state;N.setBlending(_n),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);const X=f!==this.type;X&&R.traverse(function(Y){Y.material&&(Array.isArray(Y.material)?Y.material.forEach(z=>z.needsUpdate=!0):Y.material.needsUpdate=!0)});for(let Y=0,z=E.length;Yu||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/$.x),s.x=r.x*$.x,H.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/$.y),s.y=r.y*$.y,H.mapSize.y=r.y));const j=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=j,H.map===null||X===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===Bi){if(W.isPointLight){Ae("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new rn(s.x,s.y,{format:Jn,type:Mn,minFilter:At,magFilter:At,generateMipmaps:!1}),H.map.texture.name=W.name+".shadowMap",H.map.depthTexture=new bi(s.x,s.y,nn),H.map.depthTexture.name=W.name+".shadowMapDepth",H.map.depthTexture.format=Sn,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=mt,H.map.depthTexture.magFilter=mt}else W.isPointLight?(H.map=new Jl(s.x),H.map.depthTexture=new Ph(s.x,an)):(H.map=new rn(s.x,s.y),H.map.depthTexture=new bi(s.x,s.y,an)),H.map.depthTexture.name=W.name+".shadowMap",H.map.depthTexture.format=Sn,this.type===Rs?(H.map.depthTexture.compareFunction=j?Ia:Da,H.map.depthTexture.minFilter=At,H.map.depthTexture.magFilter=At):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=mt,H.map.depthTexture.magFilter=mt);H.camera.updateProjectionMatrix()}const he=H.map.isWebGLCubeRenderTarget?6:1;for(let pe=0;pe0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const N=D.uuid,X=R.uuid;let Y=c[N];Y===void 0&&(Y={},c[N]=Y);let z=Y[X];z===void 0&&(z=D.clone(),Y[X]=z,R.addEventListener("dispose",T)),D=z}if(D.visible=R.visible,D.wireframe=R.wireframe,b===Bi?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:d[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,_.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const N=i.properties.get(D);N.light=_}return D}function M(E,R,_,b,D){if(E.visible===!1)return;if(E.layers.test(R.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&D===Bi)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,E.matrixWorld);const X=e.update(E),Y=E.material;if(Array.isArray(Y)){const z=X.groups;for(let W=0,H=z.length;W=1):j.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(j)[1]),H=$>=2);let he=null,pe={};const ve=i.getParameter(i.SCISSOR_BOX),We=i.getParameter(i.VIEWPORT),it=new nt().fromArray(ve),Xe=new nt().fromArray(We);function K(L,ne,Z,oe){const de=new Uint8Array(4),Q=i.createTexture();i.bindTexture(L,Q),i.texParameteri(L,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(L,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Se=0;Se"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new _e,u=new WeakMap,d=new Set;let h;const p=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(y,m){return v?new OffscreenCanvas(y,m):Yi("canvas")}function g(y,m,F){let V=1;const k=Ye(y);if((k.width>F||k.height>F)&&(V=F/Math.max(k.width,k.height)),V<1)if(typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&y instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&y instanceof ImageBitmap||typeof VideoFrame<"u"&&y instanceof VideoFrame){const te=Math.floor(V*k.width),se=Math.floor(V*k.height);h===void 0&&(h=S(te,se));const q=m?S(te,se):h;return q.width=te,q.height=se,q.getContext("2d").drawImage(y,0,0,te,se),Ae("WebGLRenderer: Texture has been resized from ("+k.width+"x"+k.height+") to ("+te+"x"+se+")."),q}else return"data"in y&&Ae("WebGLRenderer: Image in DataTexture is too big ("+k.width+"x"+k.height+")."),y;return y}function f(y){return y.generateMipmaps}function w(y){i.generateMipmap(y)}function A(y){return y.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:y.isWebGL3DRenderTarget?i.TEXTURE_3D:y.isWebGLArrayRenderTarget||y.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(y,m,F,V,k,te=!1){if(y!==null){if(i[y]!==void 0)return i[y];Ae("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+y+"'")}let se;V&&(se=e.get("EXT_texture_norm16"),se||Ae("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let q=m;if(m===i.RED&&(F===i.FLOAT&&(q=i.R32F),F===i.HALF_FLOAT&&(q=i.R16F),F===i.UNSIGNED_BYTE&&(q=i.R8),F===i.UNSIGNED_SHORT&&se&&(q=se.R16_EXT),F===i.SHORT&&se&&(q=se.R16_SNORM_EXT)),m===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.R8UI),F===i.UNSIGNED_SHORT&&(q=i.R16UI),F===i.UNSIGNED_INT&&(q=i.R32UI),F===i.BYTE&&(q=i.R8I),F===i.SHORT&&(q=i.R16I),F===i.INT&&(q=i.R32I)),m===i.RG&&(F===i.FLOAT&&(q=i.RG32F),F===i.HALF_FLOAT&&(q=i.RG16F),F===i.UNSIGNED_BYTE&&(q=i.RG8),F===i.UNSIGNED_SHORT&&se&&(q=se.RG16_EXT),F===i.SHORT&&se&&(q=se.RG16_SNORM_EXT)),m===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RG8UI),F===i.UNSIGNED_SHORT&&(q=i.RG16UI),F===i.UNSIGNED_INT&&(q=i.RG32UI),F===i.BYTE&&(q=i.RG8I),F===i.SHORT&&(q=i.RG16I),F===i.INT&&(q=i.RG32I)),m===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RGB8UI),F===i.UNSIGNED_SHORT&&(q=i.RGB16UI),F===i.UNSIGNED_INT&&(q=i.RGB32UI),F===i.BYTE&&(q=i.RGB8I),F===i.SHORT&&(q=i.RGB16I),F===i.INT&&(q=i.RGB32I)),m===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(q=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(q=i.RGBA16UI),F===i.UNSIGNED_INT&&(q=i.RGBA32UI),F===i.BYTE&&(q=i.RGBA8I),F===i.SHORT&&(q=i.RGBA16I),F===i.INT&&(q=i.RGBA32I)),m===i.RGB&&(F===i.UNSIGNED_SHORT&&se&&(q=se.RGB16_EXT),F===i.SHORT&&se&&(q=se.RGB16_SNORM_EXT),F===i.UNSIGNED_INT_5_9_9_9_REV&&(q=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&(q=i.R11F_G11F_B10F)),m===i.RGBA){const J=te?Os:Ge.getTransfer(k);F===i.FLOAT&&(q=i.RGBA32F),F===i.HALF_FLOAT&&(q=i.RGBA16F),F===i.UNSIGNED_BYTE&&(q=J===Ze?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT&&se&&(q=se.RGBA16_EXT),F===i.SHORT&&se&&(q=se.RGBA16_SNORM_EXT),F===i.UNSIGNED_SHORT_4_4_4_4&&(q=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(q=i.RGB5_A1)}return(q===i.R16F||q===i.R32F||q===i.RG16F||q===i.RG32F||q===i.RGBA16F||q===i.RGBA32F)&&e.get("EXT_color_buffer_float"),q}function T(y,m){let F;return y?m===null||m===an||m===Xi?F=i.DEPTH24_STENCIL8:m===nn?F=i.DEPTH32F_STENCIL8:m===Wi&&(F=i.DEPTH24_STENCIL8,Ae("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):m===null||m===an||m===Xi?F=i.DEPTH_COMPONENT24:m===nn?F=i.DEPTH_COMPONENT32F:m===Wi&&(F=i.DEPTH_COMPONENT16),F}function E(y,m){return f(y)===!0||y.isFramebufferTexture&&y.minFilter!==mt&&y.minFilter!==At?Math.log2(Math.max(m.width,m.height))+1:y.mipmaps!==void 0&&y.mipmaps.length>0?y.mipmaps.length:y.isCompressedTexture&&Array.isArray(y.image)?m.mipmaps.length:1}function R(y){const m=y.target;m.removeEventListener("dispose",R),b(m),m.isVideoTexture&&u.delete(m),m.isHTMLTexture&&d.delete(m)}function _(y){const m=y.target;m.removeEventListener("dispose",_),P(m)}function b(y){const m=n.get(y);if(m.__webglInit===void 0)return;const F=y.source,V=p.get(F);if(V){const k=V[m.__cacheKey];k.usedTimes--,k.usedTimes===0&&D(y),Object.keys(V).length===0&&p.delete(F)}n.remove(y)}function D(y){const m=n.get(y);i.deleteTexture(m.__webglTexture);const F=y.source,V=p.get(F);delete V[m.__cacheKey],a.memory.textures--}function P(y){const m=n.get(y);if(y.depthTexture&&(y.depthTexture.dispose(),n.remove(y.depthTexture)),y.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(m.__webglFramebuffer[V]))for(let k=0;k=s.maxTextures&&Ae("WebGLTextures: Trying to use "+y+" texture units while this GPU supports only "+s.maxTextures),N+=1,y}function H(y){const m=[];return m.push(y.wrapS),m.push(y.wrapT),m.push(y.wrapR||0),m.push(y.magFilter),m.push(y.minFilter),m.push(y.anisotropy),m.push(y.internalFormat),m.push(y.format),m.push(y.type),m.push(y.generateMipmaps),m.push(y.premultiplyAlpha),m.push(y.flipY),m.push(y.unpackAlignment),m.push(y.colorSpace),m.join()}function $(y,m){const F=n.get(y);if(y.isVideoTexture&&I(y),y.isRenderTargetTexture===!1&&y.isExternalTexture!==!0&&y.version>0&&F.__version!==y.version){const V=y.image;if(V===null)Ae("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Ae("WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(F,y,m);return}}else y.isExternalTexture&&(F.__webglTexture=y.sourceTexture?y.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+m)}function j(y,m){const F=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&F.__version!==y.version){Pe(F,y,m);return}else y.isExternalTexture&&(F.__webglTexture=y.sourceTexture?y.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+m)}function he(y,m){const F=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&F.__version!==y.version){Pe(F,y,m);return}t.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+m)}function pe(y,m){const F=n.get(y);if(y.isCubeDepthTexture!==!0&&y.version>0&&F.__version!==y.version){De(F,y,m);return}t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+m)}const ve={[Wr]:i.REPEAT,[gn]:i.CLAMP_TO_EDGE,[Xr]:i.MIRRORED_REPEAT},We={[mt]:i.NEAREST,[Lc]:i.NEAREST_MIPMAP_NEAREST,[ji]:i.NEAREST_MIPMAP_LINEAR,[At]:i.LINEAR,[js]:i.LINEAR_MIPMAP_NEAREST,[qn]:i.LINEAR_MIPMAP_LINEAR},it={[Uc]:i.NEVER,[zc]:i.ALWAYS,[Nc]:i.LESS,[Da]:i.LEQUAL,[Fc]:i.EQUAL,[Ia]:i.GEQUAL,[Oc]:i.GREATER,[Bc]:i.NOTEQUAL};function Xe(y,m){if(m.type===nn&&e.has("OES_texture_float_linear")===!1&&(m.magFilter===At||m.magFilter===js||m.magFilter===ji||m.magFilter===qn||m.minFilter===At||m.minFilter===js||m.minFilter===ji||m.minFilter===qn)&&Ae("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(y,i.TEXTURE_WRAP_S,ve[m.wrapS]),i.texParameteri(y,i.TEXTURE_WRAP_T,ve[m.wrapT]),(y===i.TEXTURE_3D||y===i.TEXTURE_2D_ARRAY)&&i.texParameteri(y,i.TEXTURE_WRAP_R,ve[m.wrapR]),i.texParameteri(y,i.TEXTURE_MAG_FILTER,We[m.magFilter]),i.texParameteri(y,i.TEXTURE_MIN_FILTER,We[m.minFilter]),m.compareFunction&&(i.texParameteri(y,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(y,i.TEXTURE_COMPARE_FUNC,it[m.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(m.magFilter===mt||m.minFilter!==ji&&m.minFilter!==qn||m.type===nn&&e.has("OES_texture_float_linear")===!1)return;if(m.anisotropy>1||n.get(m).__currentAnisotropy){const F=e.get("EXT_texture_filter_anisotropic");i.texParameterf(y,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(m.anisotropy,s.getMaxAnisotropy())),n.get(m).__currentAnisotropy=m.anisotropy}}}function K(y,m){let F=!1;y.__webglInit===void 0&&(y.__webglInit=!0,m.addEventListener("dispose",R));const V=m.source;let k=p.get(V);k===void 0&&(k={},p.set(V,k));const te=H(m);if(te!==y.__cacheKey){k[te]===void 0&&(k[te]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),k[te].usedTimes++;const se=k[y.__cacheKey];se!==void 0&&(k[y.__cacheKey].usedTimes--,se.usedTimes===0&&D(m)),y.__cacheKey=te,y.__webglTexture=k[te].texture}return F}function ie(y,m,F){return Math.floor(Math.floor(y/F)/m)}function ee(y,m,F,V){const te=y.updateRanges;if(te.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,m.width,m.height,F,V,m.data);else{te.sort((ye,le)=>ye.start-le.start);let se=0;for(let ye=1;ye0){Re&&Ie&&t.texStorage2D(i.TEXTURE_2D,ne,le,Te[0].width,Te[0].height);for(let Z=0,oe=Te.length;Z0){const de=ko(ae.width,ae.height,m.format,m.type);for(const Q of m.layerUpdates){const Se=ae.data.subarray(Q*de/ae.data.BYTES_PER_ELEMENT,(Q+1)*de/ae.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,Q,ae.width,ae.height,1,re,Se)}m.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,ae.width,ae.height,J.depth,re,ae.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,Z,le,ae.width,ae.height,J.depth,0,ae.data,0,0);else Ae("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Re?L&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,Z,0,0,0,ae.width,ae.height,J.depth,re,ye,ae.data):t.texImage3D(i.TEXTURE_2D_ARRAY,Z,le,ae.width,ae.height,J.depth,0,re,ye,ae.data)}else{Re&&Ie&&t.texStorage2D(i.TEXTURE_2D,ne,le,Te[0].width,Te[0].height);for(let Z=0,oe=Te.length;Z0){const Z=ko(J.width,J.height,m.format,m.type);for(const oe of m.layerUpdates){const de=J.data.subarray(oe*Z/J.data.BYTES_PER_ELEMENT,(oe+1)*Z/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,oe,J.width,J.height,1,re,ye,de)}m.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,re,ye,J.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,le,J.width,J.height,J.depth,0,re,ye,J.data);else if(m.isData3DTexture)Re?(Ie&&t.texStorage3D(i.TEXTURE_3D,ne,le,J.width,J.height,J.depth),L&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,re,ye,J.data)):t.texImage3D(i.TEXTURE_3D,0,le,J.width,J.height,J.depth,0,re,ye,J.data);else if(m.isFramebufferTexture){if(Ie)if(Re)t.texStorage2D(i.TEXTURE_2D,ne,le,J.width,J.height);else{let Z=J.width,oe=J.height;for(let de=0;de>=1,oe>>=1}}else if(m.isHTMLTexture){if("texElementImage2D"in i){const Z=i.canvas;if(Z.hasAttribute("layoutsubtree")||Z.setAttribute("layoutsubtree","true"),J.parentNode!==Z){Z.appendChild(J),d.add(m),Z.onpaint=oe=>{const de=oe.changedElements;for(const Q of d)de.includes(Q.image)&&(Q.needsUpdate=!0)},Z.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,J);else{const de=i.RGBA,Q=i.RGBA,Se=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,de,Q,Se,J)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Te.length>0){if(Re&&Ie){const Z=Ye(Te[0]);t.texStorage2D(i.TEXTURE_2D,ne,le,Z.width,Z.height)}for(let Z=0,oe=Te.length;Z0&&oe++;const Q=Ye(le[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,oe,Ie,Q.width,Q.height)}for(let Q=0;Q<6;Q++)if(ye){L?Z&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,le[Q].width,le[Q].height,Te,Re,le[Q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,Ie,le[Q].width,le[Q].height,0,Te,Re,le[Q].data);for(let Se=0;Se>te),ae=Math.max(1,m.height>>te);k===i.TEXTURE_3D||k===i.TEXTURE_2D_ARRAY?t.texImage3D(k,te,J,le,ae,m.depth,0,se,q,null):t.texImage2D(k,te,J,le,ae,0,se,q,null)}t.bindFramebuffer(i.FRAMEBUFFER,y),ft(m)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,V,k,ye.__webglTexture,0,st(m)):(k===i.TEXTURE_2D||k>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&k<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,V,k,ye.__webglTexture,te),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ot(y,m,F){if(i.bindRenderbuffer(i.RENDERBUFFER,y),m.depthBuffer){const V=m.depthTexture,k=V&&V.isDepthTexture?V.type:null,te=T(m.stencilBuffer,k),se=m.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ft(m)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(m),te,m.width,m.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(m),te,m.width,m.height):i.renderbufferStorage(i.RENDERBUFFER,te,m.width,m.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,y)}else{const V=m.textures;for(let k=0;k{delete m.__boundDepthTexture,delete m.__depthDisposeCallback,V.removeEventListener("dispose",k)};V.addEventListener("dispose",k),m.__depthDisposeCallback=k}m.__boundDepthTexture=V}if(y.depthTexture&&!m.__autoAllocateDepthBuffer)if(F)for(let V=0;V<6;V++)ze(m.__webglFramebuffer[V],y,V);else{const V=y.texture.mipmaps;V&&V.length>0?ze(m.__webglFramebuffer[0],y,0):ze(m.__webglFramebuffer,y,0)}else if(F){m.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(t.bindFramebuffer(i.FRAMEBUFFER,m.__webglFramebuffer[V]),m.__webglDepthbuffer[V]===void 0)m.__webglDepthbuffer[V]=i.createRenderbuffer(),ot(m.__webglDepthbuffer[V],y,!1);else{const k=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=m.__webglDepthbuffer[V];i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,k,i.RENDERBUFFER,te)}}else{const V=y.texture.mipmaps;if(V&&V.length>0?t.bindFramebuffer(i.FRAMEBUFFER,m.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,m.__webglFramebuffer),m.__webglDepthbuffer===void 0)m.__webglDepthbuffer=i.createRenderbuffer(),ot(m.__webglDepthbuffer,y,!1);else{const k=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=m.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,k,i.RENDERBUFFER,te)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function qe(y,m,F){const V=n.get(y);m!==void 0&&we(V.__webglFramebuffer,y,y.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&Ke(y)}function He(y){const m=y.texture,F=n.get(y),V=n.get(m);y.addEventListener("dispose",_);const k=y.textures,te=y.isWebGLCubeRenderTarget===!0,se=k.length>1;if(se||(V.__webglTexture===void 0&&(V.__webglTexture=i.createTexture()),V.__version=m.version,a.memory.textures++),te){F.__webglFramebuffer=[];for(let q=0;q<6;q++)if(m.mipmaps&&m.mipmaps.length>0){F.__webglFramebuffer[q]=[];for(let J=0;J0){F.__webglFramebuffer=[];for(let q=0;q0&&ft(y)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let q=0;q0)for(let J=0;J0)for(let J=0;J0){if(ft(y)===!1){const m=y.textures,F=y.width,V=y.height;let k=i.COLOR_BUFFER_BIT;const te=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=n.get(y),q=m.length>1;if(q)for(let re=0;re0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,se.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,se.__webglFramebuffer);for(let re=0;re0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&m.__useRenderToTexture!==!1}function I(y){const m=a.render.frame;u.get(y)!==m&&(u.set(y,m),y.update())}function Pt(y,m){const F=y.colorSpace,V=y.format,k=y.type;return y.isCompressedTexture===!0||y.isVideoTexture===!0||F!==Fs&&F!==In&&(Ge.getTransfer(F)===Ze?(V!==Zt||k!==zt)&&Ae("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ve("WebGLTextures: Unsupported texture color space:",F)),m}function Ye(y){return typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement?(c.width=y.naturalWidth||y.width,c.height=y.naturalHeight||y.height):typeof VideoFrame<"u"&&y instanceof VideoFrame?(c.width=y.displayWidth,c.height=y.displayHeight):(c.width=y.width,c.height=y.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=X,this.getTextureUnits=Y,this.setTextureUnits=z,this.setTexture2D=$,this.setTexture2DArray=j,this.setTexture3D=he,this.setTextureCube=pe,this.rebindTextures=qe,this.setupRenderTarget=He,this.updateRenderTargetMipmap=ut,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ke,this.setupFrameBufferTexture=we,this.useMultisampledRTT=ft,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function $m(i,e){function t(n,s=In){let r;const a=Ge.getTransfer(s);if(n===zt)return i.UNSIGNED_BYTE;if(n===wa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ra)return i.UNSIGNED_SHORT_5_5_5_1;if(n===El)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===bl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Sl)return i.BYTE;if(n===yl)return i.SHORT;if(n===Wi)return i.UNSIGNED_SHORT;if(n===Aa)return i.INT;if(n===an)return i.UNSIGNED_INT;if(n===nn)return i.FLOAT;if(n===Mn)return i.HALF_FLOAT;if(n===Tl)return i.ALPHA;if(n===Al)return i.RGB;if(n===Zt)return i.RGBA;if(n===Sn)return i.DEPTH_COMPONENT;if(n===Yn)return i.DEPTH_STENCIL;if(n===wl)return i.RED;if(n===Ca)return i.RED_INTEGER;if(n===Jn)return i.RG;if(n===Pa)return i.RG_INTEGER;if(n===La)return i.RGBA_INTEGER;if(n===Cs||n===Ps||n===Ls||n===Ds)if(a===Ze)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Cs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ps)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ls)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ds)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Cs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ps)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ls)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ds)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===qr||n===Yr||n===Zr||n===Jr)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===qr)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Yr)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Zr)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Jr)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Kr||n===$r||n===Qr||n===jr||n===ea||n===Us||n===ta)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Kr||n===$r)return a===Ze?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Qr)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===jr)return r.COMPRESSED_R11_EAC;if(n===ea)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Us)return r.COMPRESSED_RG11_EAC;if(n===ta)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===na||n===ia||n===sa||n===ra||n===aa||n===oa||n===la||n===ca||n===ha||n===ua||n===fa||n===da||n===pa||n===ma)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===na)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ia)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===sa)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ra)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===aa)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===oa)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===la)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ca)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ha)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ua)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===fa)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===da)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===pa)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ma)return a===Ze?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ga||n===_a||n===va)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===ga)return a===Ze?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===_a)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===va)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===xa||n===Ma||n===Ns||n===Sa)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===xa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ma)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ns)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Sa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Xi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Qm=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,jm=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class eg{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new zl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new ln({vertexShader:Qm,fragmentShader:jm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new yn(new qs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class tg extends On{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,p=null,v=null;const S=typeof XRWebGLBinding<"u",g=new eg,f={},w=t.getContextAttributes();let A=null,M=null;const T=[],E=[],R=new _e;let _=null;const b=new Bt;b.viewport=new nt;const D=new Bt;D.viewport=new nt;const P=[b,D],N=new cu;let X=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let ie=T[K];return ie===void 0&&(ie=new rr,T[K]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(K){let ie=T[K];return ie===void 0&&(ie=new rr,T[K]=ie),ie.getGripSpace()},this.getHand=function(K){let ie=T[K];return ie===void 0&&(ie=new rr,T[K]=ie),ie.getHandSpace()};function z(K){const ie=E.indexOf(K.inputSource);if(ie===-1)return;const ee=T[ie];ee!==void 0&&(ee.update(K.inputSource,K.frame,c||a),ee.dispatchEvent({type:K.type,data:K.inputSource}))}function W(){s.removeEventListener("select",z),s.removeEventListener("selectstart",z),s.removeEventListener("selectend",z),s.removeEventListener("squeeze",z),s.removeEventListener("squeezestart",z),s.removeEventListener("squeezeend",z),s.removeEventListener("end",W),s.removeEventListener("inputsourceschange",H);for(let K=0;K=0&&(E[Pe]=null,T[Pe].disconnect(ee))}for(let ie=0;ie=E.length){E.push(ee),Pe=we;break}else if(E[we]===null){E[we]=ee,Pe=we;break}if(Pe===-1)break}const De=T[Pe];De&&De.connect(ee)}}const $=new C,j=new C;function he(K,ie,ee){$.setFromMatrixPosition(ie.matrixWorld),j.setFromMatrixPosition(ee.matrixWorld);const Pe=$.distanceTo(j),De=ie.projectionMatrix.elements,we=ee.projectionMatrix.elements,ot=De[14]/(De[10]-1),ze=De[14]/(De[10]+1),Ke=(De[9]+1)/De[5],qe=(De[9]-1)/De[5],He=(De[8]-1)/De[0],ut=(we[8]+1)/we[0],pt=ot*He,xt=ot*ut,yt=Pe/(-He+ut),st=yt*-He;if(ie.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(st),K.translateZ(yt),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),De[10]===-1)K.projectionMatrix.copy(ie.projectionMatrix),K.projectionMatrixInverse.copy(ie.projectionMatrixInverse);else{const ft=ot+yt,I=ze+yt,Pt=pt-st,Ye=xt+(Pe-st),y=Ke*ze/I*ft,m=qe*ze/I*ft;K.projectionMatrix.makePerspective(Pt,Ye,y,m,ft,I),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function pe(K,ie){ie===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(ie.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(s===null)return;let ie=K.near,ee=K.far;g.texture!==null&&(g.depthNear>0&&(ie=g.depthNear),g.depthFar>0&&(ee=g.depthFar)),N.near=D.near=b.near=ie,N.far=D.far=b.far=ee,(X!==N.near||Y!==N.far)&&(s.updateRenderState({depthNear:N.near,depthFar:N.far}),X=N.near,Y=N.far),N.layers.mask=K.layers.mask|6,b.layers.mask=N.layers.mask&-5,D.layers.mask=N.layers.mask&-3;const Pe=K.parent,De=N.cameras;pe(N,Pe);for(let we=0;we0&&(g.alphaTest.value=f.alphaTest);const w=e.get(f),A=w.envMap,M=w.envMapRotation;A&&(g.envMap.value=A,g.envMapRotation.value.setFromMatrix4(ng.makeRotationFromEuler(M)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(ec),g.reflectivity.value=f.reflectivity,g.ior.value=f.ior,g.refractionRatio.value=f.refractionRatio),f.lightMap&&(g.lightMap.value=f.lightMap,g.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,g.lightMapTransform)),f.aoMap&&(g.aoMap.value=f.aoMap,g.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,g.aoMapTransform))}function a(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform))}function o(g,f){g.dashSize.value=f.dashSize,g.totalSize.value=f.dashSize+f.gapSize,g.scale.value=f.scale}function l(g,f,w,A){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.size.value=f.size*w,g.scale.value=A*.5,f.map&&(g.map.value=f.map,t(f.map,g.uvTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function c(g,f){g.diffuse.value.copy(f.color),g.opacity.value=f.opacity,g.rotation.value=f.rotation,f.map&&(g.map.value=f.map,t(f.map,g.mapTransform)),f.alphaMap&&(g.alphaMap.value=f.alphaMap,t(f.alphaMap,g.alphaMapTransform)),f.alphaTest>0&&(g.alphaTest.value=f.alphaTest)}function u(g,f){g.specular.value.copy(f.specular),g.shininess.value=Math.max(f.shininess,1e-4)}function d(g,f){f.gradientMap&&(g.gradientMap.value=f.gradientMap)}function h(g,f){g.metalness.value=f.metalness,f.metalnessMap&&(g.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,g.metalnessMapTransform)),g.roughness.value=f.roughness,f.roughnessMap&&(g.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,g.roughnessMapTransform)),f.envMap&&(g.envMapIntensity.value=f.envMapIntensity)}function p(g,f,w){g.ior.value=f.ior,f.sheen>0&&(g.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),g.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(g.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,g.sheenColorMapTransform)),f.sheenRoughnessMap&&(g.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,g.sheenRoughnessMapTransform))),f.clearcoat>0&&(g.clearcoat.value=f.clearcoat,g.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(g.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,g.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(g.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Lt&&g.clearcoatNormalScale.value.negate())),f.dispersion>0&&(g.dispersion.value=f.dispersion),f.iridescence>0&&(g.iridescence.value=f.iridescence,g.iridescenceIOR.value=f.iridescenceIOR,g.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(g.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,g.iridescenceMapTransform)),f.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),f.transmission>0&&(g.transmission.value=f.transmission,g.transmissionSamplerMap.value=w.texture,g.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap&&(g.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,g.transmissionMapTransform)),g.thickness.value=f.thickness,f.thicknessMap&&(g.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=f.attenuationDistance,g.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(g.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(g.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=f.specularIntensity,g.specularColor.value.copy(f.specularColor),f.specularColorMap&&(g.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,g.specularColorMapTransform)),f.specularIntensityMap&&(g.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,g.specularIntensityMapTransform))}function v(g,f){f.matcap&&(g.matcap.value=f.matcap)}function S(g,f){const w=e.get(f).light;g.referencePosition.value.setFromMatrixPosition(w.matrixWorld),g.nearDistance.value=w.shadow.camera.near,g.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function sg(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,T){const E=T.program;n.uniformBlockBinding(M,E)}function c(M,T){let E=s[M.id];E===void 0&&(g(M),E=u(M),s[M.id]=E,M.addEventListener("dispose",w));const R=T.program;n.updateUBOMapping(M,R);const _=e.render.frame;r[M.id]!==_&&(h(M),r[M.id]=_)}function u(M){const T=d();M.__bindingPointIndex=T;const E=i.createBuffer(),R=M.__size,_=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,E),i.bufferData(i.UNIFORM_BUFFER,R,_),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,E),E}function d(){for(let M=0;M0&&(E+=R-_),M.__size=E,M.__cache={},this}function f(M){const T={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(T.boundary=4,T.storage=4):M.isVector2?(T.boundary=8,T.storage=8):M.isVector3||M.isColor?(T.boundary=16,T.storage=12):M.isVector4?(T.boundary=16,T.storage=16):M.isMatrix3?(T.boundary=48,T.storage=48):M.isMatrix4?(T.boundary=64,T.storage=64):M.isTexture?Ae("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(T.boundary=16,T.storage=M.byteLength):Ae("WebGLRenderer: Unsupported uniform value type.",M),T}function w(M){const T=M.target;T.removeEventListener("dispose",w);const E=a.indexOf(T.__bindingPointIndex);a.splice(E,1),i.deleteBuffer(s[T.id]),delete s[T.id],delete r[T.id]}function A(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:l,update:c,dispose:A}}const rg=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let en=null;function ag(){return en===null&&(en=new Ah(rg,16,16,Jn,Mn),en.name="DFG_LUT",en.minFilter=At,en.magFilter=At,en.wrapS=gn,en.wrapT=gn,en.generateMipmaps=!1,en.needsUpdate=!0),en}class u_{constructor(e={}){const{canvas:t=Gc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:p=zt}=e;this.isWebGLRenderer=!0;let v;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");v=n.getContextAttributes().alpha}else v=a;const S=p,g=new Set([La,Pa,Ca]),f=new Set([zt,an,Wi,Xi,wa,Ra]),w=new Uint32Array(4),A=new Int32Array(4),M=new C;let T=null,E=null;const R=[],_=[];let b=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=sn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let P=!1,N=null,X=null,Y=null,z=null;this._outputColorSpace=kt;let W=0,H=0,$=null,j=-1,he=null;const pe=new nt,ve=new nt;let We=null;const it=new Ce(0);let Xe=0,K=t.width,ie=t.height,ee=1,Pe=null,De=null;const we=new nt(0,0,K,ie),ot=new nt(0,0,K,ie);let ze=!1;const Ke=new Zi;let qe=!1,He=!1;const ut=new je,pt=new C,xt=new nt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let st=!1;function ft(){return $===null?ee:1}let I=n;function Pt(x,U){return t.getContext(x,U)}try{const x={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r185"),t.addEventListener("webglcontextlost",rt,!1),t.addEventListener("webglcontextrestored",et,!1),t.addEventListener("webglcontextcreationerror",Kt,!1),I===null){const U="webgl2";if(I=Pt(U,x),I===null)throw Pt(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(x){throw Ve("WebGLRenderer: "+x.message),x}let Ye,y,m,F,V,k,te,se,q,J,re,ye,le,ae,Te,Re,Ie,L,ne,Z,oe,de,Q;function Se(){Ye=new ap(I),Ye.init(),oe=new $m(I,Ye),y=new Qd(I,Ye,e,oe),m=new Jm(I,Ye),y.reversedDepthBuffer&&h&&m.buffers.depth.setReversed(!0),X=I.createFramebuffer(),Y=I.createFramebuffer(),z=I.createFramebuffer(),F=new cp(I),V=new Nm,k=new Km(I,Ye,m,V,y,oe,F),te=new rp(D),se=new fu(I),de=new Kd(I,se),q=new op(I,se,F,de),J=new up(I,q,se,de,F),L=new hp(I,y,k),Te=new jd(V),re=new Um(D,te,Ye,y,de,Te),ye=new ig(D,V),le=new Om,ae=new km(Ye),Ie=new Jd(D,te,m,J,v,l),Re=new Zm(D,J,y),Q=new sg(I,F,y,m),ne=new $d(I,Ye,F),Z=new lp(I,Ye,F),F.programs=re.programs,D.capabilities=y,D.extensions=Ye,D.properties=V,D.renderLists=le,D.shadowMap=Re,D.state=m,D.info=F}Se(),S!==zt&&(b=new dp(S,t.width,t.height,o,s,r));const xe=new tg(D,I);this.xr=xe,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const x=Ye.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Ye.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(x){x!==void 0&&(ee=x,this.setSize(K,ie,!1))},this.getSize=function(x){return x.set(K,ie)},this.setSize=function(x,U,G=!0){if(xe.isPresenting){Ae("WebGLRenderer: Can't change size while VR device is presenting.");return}K=x,ie=U,t.width=Math.floor(x*ee),t.height=Math.floor(U*ee),G===!0&&(t.style.width=x+"px",t.style.height=U+"px"),b!==null&&b.setSize(t.width,t.height),this.setViewport(0,0,x,U)},this.getDrawingBufferSize=function(x){return x.set(K*ee,ie*ee).floor()},this.setDrawingBufferSize=function(x,U,G){K=x,ie=U,ee=G,t.width=Math.floor(x*G),t.height=Math.floor(U*G),this.setViewport(0,0,x,U)},this.setEffects=function(x){if(S===zt){Ve("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let U=0;U{function fe(){if(O.forEach(function(ge){V.get(ge).currentProgram.isReady()&&O.delete(ge)}),O.size===0){B(x);return}setTimeout(fe,10)}Ye.get("KHR_parallel_shader_compile")!==null?fe():setTimeout(fe,10)})};let Js=null;function ic(x){Js&&Js(x)}function Ja(){Bn.stop()}function Ka(){Bn.start()}const Bn=new Yl;Bn.setAnimationLoop(ic),typeof self<"u"&&Bn.setContext(self),this.setAnimationLoop=function(x){Js=x,xe.setAnimationLoop(x),x===null?Bn.stop():Bn.start()},xe.addEventListener("sessionstart",Ja),xe.addEventListener("sessionend",Ka),this.render=function(x,U){if(U!==void 0&&U.isCamera!==!0){Ve("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;N!==null&&N.renderStart(x,U);const G=xe.enabled===!0&&xe.isPresenting===!0,O=b!==null&&($===null||G)&&b.begin(D,$);if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),xe.enabled===!0&&xe.isPresenting===!0&&(b===null||b.isCompositing()===!1)&&(xe.cameraAutoUpdate===!0&&xe.updateCamera(U),U=xe.getCamera()),x.isScene===!0&&x.onBeforeRender(D,x,U,$),E=ae.get(x,_.length),E.init(U),E.state.textureUnits=k.getTextureUnits(),_.push(E),ut.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ke.setFromProjectionMatrix(ut,Jt,U.reversedDepth),He=this.localClippingEnabled,qe=Te.init(this.clippingPlanes,He),T=le.get(x,R.length),T.init(),R.push(T),xe.enabled===!0&&xe.isPresenting===!0){const ge=D.xr.getDepthSensingMesh();ge!==null&&Ks(ge,U,-1/0,D.sortObjects)}Ks(x,U,0,D.sortObjects),T.finish(),D.sortObjects===!0&&T.sort(Pe,De,U.reversedDepth),st=xe.enabled===!1||xe.isPresenting===!1||xe.hasDepthSensing()===!1,st&&Ie.addToRenderList(T,x),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),qe===!0&&Te.beginShadows();const B=E.state.shadowsArray;if(Re.render(B,x,U),qe===!0&&Te.endShadows(),(O&&b.hasRenderPass())===!1){const ge=T.opaque,ue=T.transmissive;if(E.setupLights(),U.isArrayCamera){const Me=U.cameras;if(ue.length>0)for(let Ee=0,Ue=Me.length;Ee0&&Qa(ge,ue,x,U),st&&Ie.render(x),$a(T,x,U)}$!==null&&H===0&&(k.updateMultisampleRenderTarget($),k.updateRenderTargetMipmap($)),O&&b.end(D),x.isScene===!0&&x.onAfterRender(D,x,U),de.resetDefaultState(),j=-1,he=null,_.pop(),_.length>0?(E=_[_.length-1],k.setTextureUnits(E.state.textureUnits),qe===!0&&Te.setGlobalState(D.clippingPlanes,E.state.camera)):E=null,R.pop(),R.length>0?T=R[R.length-1]:T=null,N!==null&&N.renderEnd()};function Ks(x,U,G,O){if(x.visible===!1)return;if(x.layers.test(U.layers)){if(x.isGroup)G=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(U);else if(x.isLightProbeGrid)E.pushLightProbeGrid(x);else if(x.isLight)E.pushLight(x),x.castShadow&&E.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Ke.intersectsSprite(x)){O&&xt.setFromMatrixPosition(x.matrixWorld).applyMatrix4(ut);const ge=J.update(x),ue=x.material;ue.visible&&T.push(x,ge,ue,G,xt.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Ke.intersectsObject(x))){const ge=J.update(x),ue=x.material;if(O&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),xt.copy(x.boundingSphere.center)):(ge.boundingSphere===null&&ge.computeBoundingSphere(),xt.copy(ge.boundingSphere.center)),xt.applyMatrix4(x.matrixWorld).applyMatrix4(ut)),Array.isArray(ue)){const Me=ge.groups;for(let Ee=0,Ue=Me.length;Ee0&&$i(B,U,G),fe.length>0&&$i(fe,U,G),ge.length>0&&$i(ge,U,G),m.buffers.depth.setTest(!0),m.buffers.depth.setMask(!0),m.buffers.color.setMask(!0),m.setPolygonOffset(!1)}function Qa(x,U,G,O){if((G.isScene===!0?G.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[O.id]===void 0){const be=Ye.has("EXT_color_buffer_half_float")||Ye.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[O.id]=new rn(1,1,{generateMipmaps:!0,type:be?Mn:zt,minFilter:qn,samples:Math.max(4,y.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ge.workingColorSpace})}const fe=E.state.transmissionRenderTarget[O.id],ge=O.viewport||pe;fe.setSize(ge.z*D.transmissionResolutionScale,ge.w*D.transmissionResolutionScale);const ue=D.getRenderTarget(),Me=D.getActiveCubeFace(),Ee=D.getActiveMipmapLevel();D.setRenderTarget(fe),D.getClearColor(it),Xe=D.getClearAlpha(),Xe<1&&D.setClearColor(16777215,.5),D.clear(),st&&Ie.render(G);const Ue=D.toneMapping;D.toneMapping=sn;const Be=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),E.setupLightsView(O),qe===!0&&Te.setGlobalState(D.clippingPlanes,O),$i(x,G,O),k.updateMultisampleRenderTarget(fe),k.updateRenderTargetMipmap(fe),Ye.has("WEBGL_multisampled_render_to_texture")===!1){let be=!1;for(let Je=0,lt=U.length;Je0,O.currentProgram=Be,O.uniformsList=null,Be}function eo(x){if(x.uniformsList===null){const U=x.currentProgram.getUniforms();x.uniformsList=Is.seqWithValue(U.seq,x.uniforms)}return x.uniformsList}function to(x,U){const G=V.get(x);G.outputColorSpace=U.outputColorSpace,G.batching=U.batching,G.batchingColor=U.batchingColor,G.instancing=U.instancing,G.instancingColor=U.instancingColor,G.instancingMorph=U.instancingMorph,G.skinning=U.skinning,G.morphTargets=U.morphTargets,G.morphNormals=U.morphNormals,G.morphColors=U.morphColors,G.morphTargetsCount=U.morphTargetsCount,G.numClippingPlanes=U.numClippingPlanes,G.numIntersection=U.numClipIntersection,G.vertexAlphas=U.vertexAlphas,G.vertexTangents=U.vertexTangents,G.toneMapping=U.toneMapping}function sc(x,U){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let G=0,O=x.length;G0),be=!!G.morphAttributes.position,Je=!!G.morphAttributes.normal,lt=!!G.morphAttributes.color;let at=sn;O.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(at=D.toneMapping);const $e=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Et=$e!==void 0?$e.length:0,me=V.get(O),Ut=E.state.lights;if(qe===!0&&(He===!0||x!==he)){const tt=x===he&&O.id===j;Te.setState(O,x,tt)}let ke=!1;O.version===me.__version?(me.needsLights&&me.lightsStateVersion!==Ut.state.version||me.outputColorSpace!==ue||B.isBatchedMesh&&me.batching===!1||!B.isBatchedMesh&&me.batching===!0||B.isBatchedMesh&&me.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&me.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&me.instancing===!1||!B.isInstancedMesh&&me.instancing===!0||B.isSkinnedMesh&&me.skinning===!1||!B.isSkinnedMesh&&me.skinning===!0||B.isInstancedMesh&&me.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&me.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&me.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&me.instancingMorph===!1&&B.morphTexture!==null||me.envMap!==Ee||O.fog===!0&&me.fog!==fe||me.numClippingPlanes!==void 0&&(me.numClippingPlanes!==Te.numPlanes||me.numIntersection!==Te.numIntersection)||me.vertexAlphas!==Ue||me.vertexTangents!==Be||me.morphTargets!==be||me.morphNormals!==Je||me.morphColors!==lt||me.toneMapping!==at||me.morphTargetsCount!==Et||!!me.lightProbeGrid!=E.state.lightProbeGridArray.length>0)&&(ke=!0):(ke=!0,me.__version=O.version);let Gt=me.currentProgram;ke===!0&&(Gt=Qi(O,U,B),N&&O.isNodeMaterial&&N.onUpdateProgram(O,Gt,me));let Qt=!1,bn=!1,$n=!1;const Qe=Gt.getUniforms(),ct=me.uniforms;if(m.useProgram(Gt.program)&&(Qt=!0,bn=!0,$n=!0),O.id!==j&&(j=O.id,bn=!0),me.needsLights){const tt=sc(E.state.lightProbeGridArray,B);me.lightProbeGrid!==tt&&(me.lightProbeGrid=tt,bn=!0)}if(Qt||he!==x){m.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),Qe.setValue(I,"projectionMatrix",x.projectionMatrix),Qe.setValue(I,"viewMatrix",x.matrixWorldInverse);const An=Qe.map.cameraPosition;An!==void 0&&An.setValue(I,pt.setFromMatrixPosition(x.matrixWorld)),y.logarithmicDepthBuffer&&Qe.setValue(I,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&&Qe.setValue(I,"isOrthographic",x.isOrthographicCamera===!0),he!==x&&(he=x,bn=!0,$n=!0)}if(me.needsLights&&(Ut.state.directionalShadowMap.length>0&&Qe.setValue(I,"directionalShadowMap",Ut.state.directionalShadowMap,k),Ut.state.spotShadowMap.length>0&&Qe.setValue(I,"spotShadowMap",Ut.state.spotShadowMap,k),Ut.state.pointShadowMap.length>0&&Qe.setValue(I,"pointShadowMap",Ut.state.pointShadowMap,k)),B.isSkinnedMesh){Qe.setOptional(I,B,"bindMatrix"),Qe.setOptional(I,B,"bindMatrixInverse");const tt=B.skeleton;tt&&(tt.boneTexture===null&&tt.computeBoneTexture(),Qe.setValue(I,"boneTexture",tt.boneTexture,k))}B.isBatchedMesh&&(Qe.setOptional(I,B,"batchingTexture"),Qe.setValue(I,"batchingTexture",B._matricesTexture,k),Qe.setOptional(I,B,"batchingIdTexture"),Qe.setValue(I,"batchingIdTexture",B._indirectTexture,k),Qe.setOptional(I,B,"batchingColorTexture"),B._colorsTexture!==null&&Qe.setValue(I,"batchingColorTexture",B._colorsTexture,k));const Tn=G.morphAttributes;if((Tn.position!==void 0||Tn.normal!==void 0||Tn.color!==void 0)&&L.update(B,G,Gt),(bn||me.receiveShadow!==B.receiveShadow)&&(me.receiveShadow=B.receiveShadow,Qe.setValue(I,"receiveShadow",B.receiveShadow)),(O.isMeshStandardMaterial||O.isMeshLambertMaterial||O.isMeshPhongMaterial)&&O.envMap===null&&U.environment!==null&&(ct.envMapIntensity.value=U.environmentIntensity),ct.dfgLUT!==void 0&&(ct.dfgLUT.value=ag()),bn){if(Qe.setValue(I,"toneMappingExposure",D.toneMappingExposure),me.needsLights&&ac(ct,$n),fe&&O.fog===!0&&ye.refreshFogUniforms(ct,fe),ye.refreshMaterialUniforms(ct,O,ee,ie,E.state.transmissionRenderTarget[x.id]),me.needsLights&&me.lightProbeGrid){const tt=me.lightProbeGrid;ct.probesSH.value=tt.texture,ct.probesMin.value.copy(tt.boundingBox.min),ct.probesMax.value.copy(tt.boundingBox.max),ct.probesResolution.value.copy(tt.resolution)}Is.upload(I,eo(me),ct,k)}if(O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(Is.upload(I,eo(me),ct,k),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&&Qe.setValue(I,"center",B.center),Qe.setValue(I,"modelViewMatrix",B.modelViewMatrix),Qe.setValue(I,"normalMatrix",B.normalMatrix),Qe.setValue(I,"modelMatrix",B.matrixWorld),O.uniformsGroups!==void 0){const tt=O.uniformsGroups;for(let An=0,Qn=tt.length;An0&&k.useMultisampledRTT(x)===!1?O=V.get(x).__webglMultisampledFramebuffer:Array.isArray(Ee)?O=Ee[G]:O=Ee,pe.copy(x.viewport),ve.copy(x.scissor),We=x.scissorTest}else pe.copy(we).multiplyScalar(ee).floor(),ve.copy(ot).multiplyScalar(ee).floor(),We=ze;if(G!==0&&(O=X),m.bindFramebuffer(I.FRAMEBUFFER,O)&&m.drawBuffers(x,O),m.viewport(pe),m.scissor(ve),m.setScissorTest(We),B){const ue=V.get(x.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+U,ue.__webglTexture,G)}else if(fe){const ue=U;for(let Me=0;Me1&&I.readBuffer(I.COLOR_ATTACHMENT0+ue),!y.textureFormatReadable(Ue)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!y.textureTypeReadable(Be)){Ve("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=x.width-O&&G>=0&&G<=x.height-B&&I.readPixels(U,G,O,B,oe.convert(Ue),oe.convert(Be),fe)}finally{const Ee=$!==null?V.get($).__webglFramebuffer:null;m.bindFramebuffer(I.FRAMEBUFFER,Ee)}}},this.readRenderTargetPixelsAsync=async function(x,U,G,O,B,fe,ge,ue=0){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Me=V.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ge!==void 0&&(Me=Me[ge]),Me)if(U>=0&&U<=x.width-O&&G>=0&&G<=x.height-B){m.bindFramebuffer(I.FRAMEBUFFER,Me);const Ee=x.textures[ue],Ue=Ee.format,Be=Ee.type;if(x.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+ue),!y.textureFormatReadable(Ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!y.textureTypeReadable(Be))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const be=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,be),I.bufferData(I.PIXEL_PACK_BUFFER,fe.byteLength,I.STREAM_READ),I.readPixels(U,G,O,B,oe.convert(Ue),oe.convert(Be),0);const Je=$!==null?V.get($).__webglFramebuffer:null;m.bindFramebuffer(I.FRAMEBUFFER,Je);const lt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await Hc(I,lt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,be),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,fe),I.deleteBuffer(be),I.deleteSync(lt),fe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,U=null,G=0){const O=Math.pow(2,-G),B=Math.floor(x.image.width*O),fe=Math.floor(x.image.height*O),ge=U!==null?U.x:0,ue=U!==null?U.y:0;k.setTexture2D(x,0),I.copyTexSubImage2D(I.TEXTURE_2D,G,0,0,ge,ue,B,fe),m.unbindTexture()},this.copyTextureToTexture=function(x,U,G=null,O=null,B=0,fe=0){let ge,ue,Me,Ee,Ue,Be,be,Je,lt;const at=x.isCompressedTexture?x.mipmaps[fe]:x.image;if(G!==null)ge=G.max.x-G.min.x,ue=G.max.y-G.min.y,Me=G.isBox3?G.max.z-G.min.z:1,Ee=G.min.x,Ue=G.min.y,Be=G.isBox3?G.min.z:0;else{const ct=Math.pow(2,-B);ge=Math.floor(at.width*ct),ue=Math.floor(at.height*ct),x.isDataArrayTexture?Me=at.depth:x.isData3DTexture?Me=Math.floor(at.depth*ct):Me=1,Ee=0,Ue=0,Be=0}O!==null?(be=O.x,Je=O.y,lt=O.z):(be=0,Je=0,lt=0);const $e=oe.convert(U.format),Et=oe.convert(U.type);let me;U.isData3DTexture?(k.setTexture3D(U,0),me=I.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(k.setTexture2DArray(U,0),me=I.TEXTURE_2D_ARRAY):(k.setTexture2D(U,0),me=I.TEXTURE_2D),m.activeTexture(I.TEXTURE0),m.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,U.flipY),m.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),m.pixelStorei(I.UNPACK_ALIGNMENT,U.unpackAlignment);const Ut=m.getParameter(I.UNPACK_ROW_LENGTH),ke=m.getParameter(I.UNPACK_IMAGE_HEIGHT),Gt=m.getParameter(I.UNPACK_SKIP_PIXELS),Qt=m.getParameter(I.UNPACK_SKIP_ROWS),bn=m.getParameter(I.UNPACK_SKIP_IMAGES);m.pixelStorei(I.UNPACK_ROW_LENGTH,at.width),m.pixelStorei(I.UNPACK_IMAGE_HEIGHT,at.height),m.pixelStorei(I.UNPACK_SKIP_PIXELS,Ee),m.pixelStorei(I.UNPACK_SKIP_ROWS,Ue),m.pixelStorei(I.UNPACK_SKIP_IMAGES,Be);const $n=x.isDataArrayTexture||x.isData3DTexture,Qe=U.isDataArrayTexture||U.isData3DTexture;if(x.isDepthTexture){const ct=V.get(x),Tn=V.get(U),tt=V.get(ct.__renderTarget),An=V.get(Tn.__renderTarget);m.bindFramebuffer(I.READ_FRAMEBUFFER,tt.__webglFramebuffer),m.bindFramebuffer(I.DRAW_FRAMEBUFFER,An.__webglFramebuffer);for(let Qn=0;Qn + + + + + + + + + + diff --git a/internal/ui/assets/graph.js b/internal/ui/assets/graph.js deleted file mode 100644 index c70fdef..0000000 --- a/internal/ui/assets/graph.js +++ /dev/null @@ -1,225 +0,0 @@ -/* The graph, drawn the way the dashboard draws one. - * - * Node radius, label placement, link colour and width, the arrows and the - * midpoint edge labels are all the dashboard's, so a person who has seen the - * hosted graph recognises this one. Colours are concrete hex rather than the - * CSS custom properties, because the graph draws to a canvas and cannot - * resolve them. - */ -const COLOURS = { - repository: '#E20C18', - directory: '#9560f0', - file: '#3b82f6', - import: '#f59e0b', - function: '#4ade80', - method: '#2dd4bf', - class: '#c084fc', - struct: '#22d3ee', - interface: '#22d3ee', - enum: '#22d3ee', -} -const OTHER = '#a1a1aa' - -const LAYOUTS = [ - { id: 'force', label: 'Force', dag: null }, - { id: 'tree', label: 'Tree', dag: 'td' }, - { id: 'radial', label: 'Radial', dag: 'radialout' }, - { id: 'layered', label: 'Layered', dag: 'lr' }, -] - -/* A file's kind is its language and a symbol's kind is what the parser called - * it, so kind alone cannot tell a Python file from a Python function. The - * labels the index carries can, which is what this reads. */ -function groupOf(node) { - if (node.synthetic) return node.synthetic - const labels = node.labels || [] - if (labels.includes('File')) return 'file' - if (labels.includes('Import')) return 'import' - return (node.kind || '').toLowerCase() -} - -function colourOf(node) { - return COLOURS[groupOf(node)] || OTHER -} - -function shortName(name) { - return name && name.length > 28 ? `${name.slice(0, 27)}…` : name -} - -function canvasColour(name) { - return getComputedStyle(document.documentElement).getPropertyValue(name).trim() -} - -/* Files hold their symbols and their imports, and nothing holds the files, so - * drawing the index as it is stored scatters a repository into one island per - * file. The directories are already in every path; this reads them out and - * hangs the files off them, which is the difference between a repository and - * confetti. The nodes it adds are marked synthetic: they are how this view - * arranges what the index found, not something the index found. */ -function withFolders(data, repository) { - const root = { id: 'tree:', name: repository, kind: 'repository', synthetic: 'repository', path: '' } - const folders = new Map([['', root]]) - const links = [...data.links] - - const folderFor = (path) => { - if (folders.has(path)) return folders.get(path) - const cut = path.lastIndexOf('/', path.length - 2) - const parentPath = cut === -1 ? '' : path.slice(0, cut + 1) - const parent = folderFor(parentPath) - const folder = { - id: `tree:${path}`, - name: path.slice(parentPath.length).replace(/\/$/, ''), - kind: 'directory', - synthetic: 'directory', - path, - } - folders.set(path, folder) - links.push({ source: parent.id, target: folder.id, type: 'contains' }) - return folder - } - - for (const node of data.nodes) { - if (groupOf(node) !== 'file' || !node.path) continue - const cut = node.path.lastIndexOf('/') - const folder = folderFor(cut === -1 ? '' : node.path.slice(0, cut + 1)) - links.push({ source: folder.id, target: node.id, type: 'contains' }) - } - - return { nodes: [...folders.values(), ...data.nodes], links } -} - -class CodeGraph { - constructor(element, { onSelect } = {}) { - this.element = element - this.onSelect = onSelect || (() => {}) - this.graph = null - this.layout = 'force' - this.matching = null - this.selected = null - this.labelled = false - this.observer = new ResizeObserver(() => this.resize()) - this.observer.observe(element) - } - - destroy() { - this.observer.disconnect() - this.graph?._destructor?.() - this.graph = null - this.element.innerHTML = '' - } - - resize() { - if (!this.graph) return - this.graph.width(this.element.clientWidth).height(this.element.clientHeight) - } - - setLayout(id) { - this.layout = id - this.draw() - } - - highlight(term) { - const needle = term.trim().toLowerCase() - this.matching = needle - ? new Set(this.data.nodes - .filter((node) => node.name.toLowerCase().includes(needle) || - (node.path || '').toLowerCase().includes(needle)) - .map((node) => node.id)) - : null - this.repaint() - } - - select(node) { - this.selected = node ? node.id : null - this.repaint() - this.onSelect(node) - } - - repaint() { - if (this.graph) this.graph.nodeCanvasObject(this.paintNode) - } - - show(data) { - this.data = data - this.selected = null - this.draw() - } - - draw() { - const data = this.data - const dag = LAYOUTS.find((layout) => layout.id === this.layout).dag - // A drawing small enough to read gets its names at any zoom, as the hosted - // graph does. A large one would be soup, so there they wait for a zoom. - this.labelled = data.nodes.length <= 400 - - this.paintNode = (node, ctx, scale) => { - const dimmed = this.matching !== null && !this.matching.has(node.id) - const colour = colourOf(node) - ctx.globalAlpha = dimmed ? 0.15 : 1 - - ctx.beginPath() - ctx.arc(node.x, node.y, node.id === this.selected ? 6 : 4, 0, 2 * Math.PI) - ctx.fillStyle = colour - ctx.fill() - if (node.id === this.selected) { - ctx.lineWidth = 1.5 / scale - ctx.strokeStyle = canvasColour('--canvas-label') - ctx.stroke() - } - - if (this.labelled || scale > 1.4 || this.matching !== null) { - const size = Math.max(11 / scale, 2) - const heavy = groupOf(node) === 'repository' || groupOf(node) === 'file' - ctx.font = `${heavy ? 'bold ' : ''}${size}px Inter, sans-serif` - ctx.fillStyle = colour - ctx.textAlign = 'left' - ctx.textBaseline = 'middle' - ctx.fillText(shortName(node.name), node.x + 6, node.y) - } - ctx.globalAlpha = 1 - } - - if (!this.graph) { - this.graph = new ForceGraph(this.element) - this.graph - .backgroundColor('rgba(0,0,0,0)') - .nodeRelSize(4) - .nodeLabel((node) => `${node.name} · ${node.kind}`) - .nodePointerAreaPaint((node, colour, ctx) => { - ctx.fillStyle = colour - ctx.beginPath() - ctx.arc(node.x, node.y, 7, 0, 2 * Math.PI) - ctx.fill() - }) - .linkWidth(0.7) - .linkDirectionalArrowLength(3) - .linkDirectionalArrowRelPos(1) - .linkCanvasObjectMode(() => 'after') - .linkCanvasObject((link, ctx, scale) => { - const start = link.source - const end = link.target - if (!link.type || typeof start !== 'object' || typeof end !== 'object') return - if (!this.labelled && scale <= 1.4) return - const size = Math.max(9 / scale, 1.5) - ctx.font = `${size}px monospace` - ctx.fillStyle = canvasColour('--canvas-label') - ctx.textAlign = 'center' - ctx.textBaseline = 'middle' - ctx.fillText(link.type, (start.x + end.x) / 2, (start.y + end.y) / 2) - }) - .onNodeClick((node) => this.select(node)) - .onBackgroundClick(() => this.select(null)) - this.graph.onEngineStop(() => this.graph.zoomToFit(500, 40)) - } - - this.graph - .nodeCanvasObject(this.paintNode) - .linkColor(() => canvasColour('--canvas-link')) - .dagMode(dag) - .dagLevelDistance(dag ? 90 : 40) - .onDagError(() => undefined) - .width(this.element.clientWidth) - .height(this.element.clientHeight) - .graphData(data) - } -} diff --git a/internal/ui/assets/icons.js b/internal/ui/assets/icons.js deleted file mode 100644 index 5a5b092..0000000 --- a/internal/ui/assets/icons.js +++ /dev/null @@ -1,30 +0,0 @@ -/* The dashboard draws with lucide. These are the same glyphs, inlined, so the - * page needs nothing from a network it may not have. */ -const ICON_PATHS = { - ant: '', - boxes: '', - network: '', - lightbulb: '', - layout: '', - folder: '', - plus: '', - trash: '', - refresh: '', - sun: '', - moon: '', - x: '', - check: '', - chevronUp: '', - chevronRight: '', - loader: '', - file: '', - link: '', - pencil: '', - search: '', -} - -function icon(name, size = 16, extra = '') { - const paths = ICON_PATHS[name] || '' - return `${paths}` -} diff --git a/internal/ui/assets/index.html b/internal/ui/assets/index.html index 80d2c06..533e5be 100644 --- a/internal/ui/assets/index.html +++ b/internal/ui/assets/index.html @@ -1,35 +1,14 @@ - - -SourceAnt - - + + + + SourceAnt + + -
-
- - - - - -
-
- -
-
-
- -
- - - - - +
diff --git a/internal/ui/assets/styles.css b/internal/ui/assets/styles.css deleted file mode 100644 index 5e75fce..0000000 --- a/internal/ui/assets/styles.css +++ /dev/null @@ -1,919 +0,0 @@ -/* The tokens are the dashboard's, so the local app and the hosted one read as - one product. Dark is the default there and here; .light is the override. */ -:root, -.dark { - color-scheme: dark; - --background: 240 10% 3.9%; - --foreground: 0 0% 98%; - --card: 240 9% 7%; - --card-foreground: 0 0% 98%; - --popover: 240 9% 7%; - --primary: 357 89% 47%; - --primary-foreground: 0 0% 100%; - --secondary: 240 4% 16%; - --secondary-foreground: 0 0% 98%; - --muted: 240 5% 14%; - --muted-foreground: 240 5% 64.9%; - --accent: 240 4% 16%; - --accent-foreground: 0 0% 98%; - --destructive: 0 62.8% 50.6%; - --destructive-foreground: 0 0% 98%; - --success: 142 71% 45%; - --warning: 38 92% 50%; - --border: 240 6% 16%; - --input: 240 6% 16%; - --ring: 357 89% 47%; - --radius: 0.25rem; - --pillar-memory: 217 91% 60%; - --pillar-graph: 262 83% 66%; - --pillar-review: 142 71% 45%; - --pillar-tokens: 38 92% 50%; - --canvas-link: #52525b; - --canvas-label: #9ca3af; -} - -.light { - color-scheme: light; - --background: 240 20% 98%; - --foreground: 240 10% 10%; - --card: 0 0% 100%; - --card-foreground: 240 10% 10%; - --popover: 0 0% 100%; - --primary: 357 89% 47%; - --primary-foreground: 0 0% 100%; - --secondary: 240 10% 94%; - --secondary-foreground: 240 10% 20%; - --muted: 240 10% 94%; - --muted-foreground: 240 5% 45%; - --accent: 357 60% 96%; - --accent-foreground: 357 70% 40%; - --destructive: 0 84% 60%; - --destructive-foreground: 0 0% 100%; - --success: 142 70% 35%; - --warning: 38 92% 45%; - --border: 240 10% 90%; - --input: 240 10% 90%; - --ring: 357 89% 47%; - --pillar-memory: 217 91% 55%; - --pillar-graph: 262 83% 58%; - --pillar-review: 142 71% 40%; - --pillar-tokens: 38 92% 45%; - --canvas-link: #b4b4bd; - --canvas-label: #52525b; -} - -* { - box-sizing: border-box; - border-color: hsl(var(--border)); -} - -/* Anything given a display beats the browser's own rule for the hidden - attribute, so hiding has to say so louder than laying out does. */ -[hidden] { - display: none !important; -} - -html, -body { - height: 100%; -} - -body { - margin: 0; - display: flex; - flex-direction: column; - background: hsl(var(--background)); - color: hsl(var(--foreground)); - font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; - font-size: 14px; - -webkit-font-smoothing: antialiased; -} - -svg { - flex: none; -} - -/* Header, at the dashboard's 3rem with its blurred card background. */ -header.bar { - height: 3rem; - flex: none; - z-index: 40; - border-bottom: 1px solid hsl(var(--border)); - background: hsl(var(--card) / 0.8); - backdrop-filter: blur(4px); -} - -.bar-inner { - height: 100%; - display: flex; - align-items: center; - gap: 0.25rem; - padding: 0 1rem; - min-width: 0; -} - -.logo { - display: flex; - align-items: center; - gap: 0.5rem; - margin-right: 0.75rem; - font-weight: 600; - color: hsl(var(--foreground)); - text-decoration: none; - flex: none; -} - -.logo-mark { - width: 1.5rem; - height: 1.5rem; - display: grid; - place-items: center; - border-radius: var(--radius); - background: hsl(var(--primary)); - color: hsl(var(--primary-foreground)); -} - -.divider { - width: 1px; - height: 1rem; - background: hsl(var(--border)); - margin: 0 0.25rem; - flex: none; -} - -nav.tabs { - display: flex; - align-items: center; - gap: 0.125rem; - min-width: 0; - overflow-x: auto; - scrollbar-width: none; -} - -nav.tabs::-webkit-scrollbar { - display: none; -} - -nav.tabs a { - display: flex; - flex: none; - align-items: center; - gap: 0.375rem; - padding: 0.25rem 0.625rem; - border-radius: var(--radius); - font-size: 0.875rem; - color: hsl(var(--muted-foreground)); - text-decoration: none; - transition: background-color 0.15s, color 0.15s; -} - -nav.tabs a:hover { - background: hsl(var(--muted)); - color: hsl(var(--foreground)); -} - -nav.tabs a[aria-current="page"] { - background: hsl(var(--primary) / 0.1); - color: hsl(var(--primary)); - font-weight: 500; -} - -.spacer { - flex: 1; - min-width: 0; -} - -main { - flex: 1; - min-height: 0; - overflow-y: auto; -} - -.container { - max-width: 1400px; - margin: 0 auto; - padding: 1rem 1.5rem 1.5rem; - display: flex; - flex-direction: column; - min-height: 100%; -} - -/* A page that fills the space it is given needs a definite height to resolve - against, not a minimum, or it grows to its content instead. */ -.container.fills { - height: 100%; - min-height: 0; -} - -/* Page heading, matching the dashboard's icon tile and two lines. */ -.page-head { - display: flex; - flex-wrap: wrap; - align-items: flex-start; - justify-content: space-between; - gap: 1rem; - margin-bottom: 1.5rem; -} - -.page-title { - display: flex; - align-items: center; - gap: 0.75rem; -} - -.tile { - width: 2.75rem; - height: 2.75rem; - display: grid; - place-items: center; - border-radius: calc(var(--radius) + 2px); - flex: none; -} - -.tile.graph { - background: hsl(var(--pillar-graph) / 0.15); - color: hsl(var(--pillar-graph)); -} - -.tile.memory { - background: hsl(var(--pillar-memory) / 0.15); - color: hsl(var(--pillar-memory)); -} - -.tile.review { - background: hsl(var(--pillar-review) / 0.15); - color: hsl(var(--pillar-review)); -} - -.tile.tokens { - background: hsl(var(--pillar-tokens) / 0.15); - color: hsl(var(--pillar-tokens)); -} - -h1 { - font-size: 1.25rem; - font-weight: 600; - margin: 0; - line-height: 1.3; -} - -.sub { - margin: 0.15rem 0 0; - font-size: 0.875rem; - color: hsl(var(--muted-foreground)); -} - -/* Card */ -.card { - border: 1px solid hsl(var(--border)); - border-radius: 0.5rem; - background: hsl(var(--card)); - color: hsl(var(--card-foreground)); - box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); -} - -.card-pad { - padding: 1rem 1.25rem; -} - -.card + .card { - margin-top: 0.75rem; -} - -/* Button, mirroring the dashboard's variants. */ -.btn { - display: inline-flex; - align-items: center; - justify-content: center; - gap: 0.375rem; - white-space: nowrap; - height: 2.25rem; - padding: 0 1rem; - border: 0; - border-radius: var(--radius); - font: inherit; - font-size: 0.875rem; - font-weight: 500; - cursor: pointer; - background: hsl(var(--primary)); - color: hsl(var(--primary-foreground)); - box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); - transition: background-color 0.15s, color 0.15s; -} - -.btn:hover:not(:disabled) { - background: hsl(var(--primary) / 0.9); -} - -.btn:disabled { - opacity: 0.5; - pointer-events: none; -} - -.btn.outline { - background: hsl(var(--background)); - color: hsl(var(--foreground)); - border: 1px solid hsl(var(--input)); -} - -.btn.outline:hover:not(:disabled) { - background: hsl(var(--accent)); - color: hsl(var(--accent-foreground)); -} - -.btn.ghost { - background: none; - color: hsl(var(--muted-foreground)); - box-shadow: none; -} - -.btn.ghost:hover:not(:disabled) { - background: hsl(var(--accent)); - color: hsl(var(--accent-foreground)); -} - -.btn.destructive { - background: hsl(var(--destructive)); - color: hsl(var(--destructive-foreground)); -} - -.btn.sm { - height: 2rem; - padding: 0 0.75rem; - font-size: 0.75rem; -} - -.btn.icon { - width: 2.25rem; - padding: 0; -} - -/* Badge */ -.badge { - display: inline-flex; - align-items: center; - border: 1px solid transparent; - border-radius: 9999px; - padding: 0.125rem 0.625rem; - font-size: 0.75rem; - font-weight: 600; -} - -.badge.secondary { - background: hsl(var(--secondary)); - color: hsl(var(--secondary-foreground)); -} - -.badge.success { - background: hsl(var(--success) / 0.2); - color: hsl(var(--success)); -} - -.badge.warning { - background: hsl(var(--warning) / 0.2); - color: hsl(var(--warning)); -} - -.badge.glow { - border-color: hsl(var(--primary) / 0.3); - background: hsl(var(--primary) / 0.1); - color: hsl(var(--primary)); -} - -.badge.outline { - border-color: hsl(var(--border)); - color: hsl(var(--foreground)); -} - -/* Inputs */ -input[type="text"], -input[type="search"], -textarea, -select { - width: 100%; - font: inherit; - font-size: 0.875rem; - color: hsl(var(--foreground)); - background: hsl(var(--muted) / 0.5); - border: 1px solid hsl(var(--input)); - border-radius: var(--radius); - padding: 0.5rem 0.75rem; - outline: none; -} - -input:focus, -textarea:focus, -select:focus { - border-color: hsl(var(--primary) / 0.5); -} - -textarea { - resize: vertical; - min-height: 5rem; -} - -label.field { - display: block; - margin-bottom: 0.375rem; - font-size: 0.75rem; - font-weight: 500; - text-transform: uppercase; - letter-spacing: 0.05em; - color: hsl(var(--muted-foreground)); -} - -.field-row + .field-row { - margin-top: 1rem; -} - -.checkline { - display: inline-flex; - align-items: center; - gap: 0.375rem; - font-size: 0.75rem; - color: hsl(var(--muted-foreground)); - cursor: pointer; -} - -/* Segmented control */ -.segmented { - display: inline-flex; - gap: 0.125rem; - padding: 0.125rem; - background: hsl(var(--card)); - border: 1px solid hsl(var(--border)); - border-radius: calc(var(--radius) + 2px); -} - -.segmented button { - border: 0; - background: none; - padding: 0.25rem 0.75rem; - font: inherit; - font-size: 0.75rem; - font-weight: 500; - color: hsl(var(--muted-foreground)); - border-radius: var(--radius); - cursor: pointer; - transition: background-color 0.15s, color 0.15s; -} - -.segmented button[aria-pressed="true"] { - background: hsl(var(--primary) / 0.15); - color: hsl(var(--primary)); -} - -/* Lists */ -.rows { - display: flex; - flex-direction: column; -} - -.row { - display: flex; - align-items: center; - gap: 0.75rem; - padding: 0.875rem 1.25rem; - border-bottom: 1px solid hsl(var(--border)); -} - -.row:last-child { - border-bottom: 0; -} - -.row-main { - min-width: 0; - flex: 1; -} - -.row-title { - font-weight: 500; - overflow-wrap: anywhere; -} - -.row-sub { - margin-top: 0.15rem; - font-size: 0.75rem; - color: hsl(var(--muted-foreground)); - font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; - overflow-wrap: anywhere; -} - -.row-actions { - display: flex; - gap: 0.375rem; - flex: none; -} - -/* Card grid, as the dashboard lists repositories. */ -.grid-cards { - display: grid; - gap: 0.75rem; -} - -.item { - display: flex; - align-items: flex-start; - gap: 1rem; - padding: 1.25rem; -} - -.card.hoverable { - transition: border-color 0.2s, transform 0.2s; -} - -.card.hoverable:hover { - border-color: hsl(var(--primary) / 0.5); - transform: translateY(-2px); -} - -.item-icon { - width: 2.75rem; - height: 2.75rem; - display: grid; - place-items: center; - border-radius: 0.5rem; - flex: none; - background: hsl(var(--pillar-graph) / 0.15); - color: hsl(var(--pillar-graph)); -} - -.item-body { - flex: 1; - min-width: 0; -} - -.item-head { - display: flex; - align-items: center; - gap: 0.5rem; - margin-bottom: 0.25rem; - flex-wrap: wrap; -} - -.item-head h3 { - margin: 0; - font-size: 0.9375rem; - font-weight: 600; - overflow-wrap: anywhere; -} - -.item-path { - font-size: 0.8125rem; - color: hsl(var(--muted-foreground)); - font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; - overflow-wrap: anywhere; -} - -.item-meta { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: 0.25rem 1rem; - margin-top: 0.5rem; - font-size: 0.8125rem; - color: hsl(var(--muted-foreground)); -} - -.item-meta span { - display: inline-flex; - align-items: center; - gap: 0.375rem; -} - -.item-actions { - display: flex; - gap: 0.25rem; - flex: none; -} - -.summary { - margin: 0.25rem 0 0; - font-size: 0.875rem; - color: hsl(var(--muted-foreground)); - overflow-wrap: anywhere; -} - -.props { - margin: 0.5rem 0 0; - display: grid; - grid-template-columns: auto 1fr; - gap: 0.2rem 0.75rem; - font-size: 0.75rem; -} - -.props dt { - color: hsl(var(--muted-foreground)); -} - -.props dd { - margin: 0; - font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; - overflow-wrap: anywhere; -} - -.spin { - animation: spin 1s linear infinite; -} - -@keyframes spin { - to { - transform: rotate(360deg); - } -} - -/* Stats */ -.stats { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); - gap: 0.75rem; - margin-bottom: 1.5rem; -} - -.stat { - padding: 1rem 1.25rem; - display: flex; - flex-direction: column; - justify-content: space-between; -} - -.stat-label { - font-size: 0.75rem; - color: hsl(var(--muted-foreground)); -} - -.stat-value { - margin-top: 0.25rem; - font-size: 1.5rem; - font-weight: 600; - font-variant-numeric: tabular-nums; -} - -/* Empty state */ -.empty { - padding: 3rem 1.5rem; - text-align: center; - color: hsl(var(--muted-foreground)); -} - -.empty h2 { - margin: 0 0 0.5rem; - font-size: 1rem; - font-weight: 600; - color: hsl(var(--foreground)); -} - -.empty p { - margin: 0 auto 1rem; - max-width: 32rem; - font-size: 0.875rem; -} - -code { - font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; - font-size: 0.8125rem; - background: hsl(var(--muted)); - padding: 0.1rem 0.35rem; - border-radius: var(--radius); -} - -/* Graph stage */ -/* The graph fills what is left rather than growing to its canvas. - flex-basis 0 with min-height 0 is what stops a flex item being sized by its - content, which for a canvas is whatever height it was last given. */ -.stage { - position: relative; - flex: 1 1 0; - min-height: 0; - border: 1px solid hsl(var(--border)); - border-radius: 0.5rem; - background: hsl(var(--card)); - overflow: hidden; -} - -#canvas { - width: 100%; - height: 100%; -} - -.overlay { - position: absolute; - inset: 0; - display: grid; - place-items: center; - padding: 2rem; - text-align: center; - font-size: 0.875rem; - color: hsl(var(--muted-foreground)); - background: hsl(var(--card)); -} - -.details { - position: absolute; - top: 0.75rem; - right: 0.75rem; - width: min(20rem, calc(100% - 1.5rem)); - padding: 0.875rem 1rem; - background: hsl(var(--background) / 0.92); - backdrop-filter: blur(12px); - border: 1px solid hsl(var(--border)); - border-radius: calc(var(--radius) + 2px); -} - -.details h2 { - margin: 0 1.5rem 0.5rem 0; - font-size: 0.9375rem; - font-weight: 600; - overflow-wrap: anywhere; -} - -.details dl { - margin: 0; - display: grid; - grid-template-columns: auto 1fr; - gap: 0.25rem 0.75rem; - font-size: 0.75rem; -} - -.details dt { - color: hsl(var(--muted-foreground)); -} - -.details dd { - margin: 0; - font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; - overflow-wrap: anywhere; -} - -.details .btn.icon { - position: absolute; - top: 0.4rem; - right: 0.4rem; - width: 1.75rem; - height: 1.75rem; -} - -.legend { - display: flex; - flex-wrap: wrap; - gap: 0.5rem 1rem; -} - -.legend span { - display: inline-flex; - align-items: center; - gap: 0.5rem; - font-size: 0.75rem; - color: hsl(var(--muted-foreground)); -} - -.swatch { - width: 0.625rem; - height: 0.625rem; - border-radius: 2px; - flex: none; -} - -.toolbar { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: space-between; - gap: 0.75rem; - margin-bottom: 0.75rem; -} - -.toolbar-group { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: 0.75rem; -} - -.toolbar input[type="search"], -.toolbar select, -.page-head select { - width: auto; - min-width: 12rem; -} - -.foot { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: space-between; - gap: 1rem; - margin-top: 0.75rem; -} - -.tally { - font-size: 0.75rem; - color: hsl(var(--muted-foreground)); - font-variant-numeric: tabular-nums; -} - -/* Notices */ -.notice { - padding: 0.75rem 1rem; - margin-bottom: 1rem; - font-size: 0.8125rem; - border-radius: calc(var(--radius) + 2px); - border: 1px solid hsl(var(--warning) / 0.35); - background: hsl(var(--warning) / 0.1); -} - -.notice.bad { - border-color: hsl(var(--destructive) / 0.4); - background: hsl(var(--destructive) / 0.12); -} - -/* Modal */ -.scrim { - position: fixed; - inset: 0; - z-index: 50; - display: grid; - place-items: center; - padding: 1rem; - background: rgb(0 0 0 / 0.6); - backdrop-filter: blur(2px); -} - -.modal { - width: 100%; - max-width: 34rem; - max-height: 85vh; - overflow-y: auto; - padding: 1.25rem 1.5rem 1.5rem; - border: 1px solid hsl(var(--border)); - border-radius: 0.5rem; - background: hsl(var(--popover)); - box-shadow: 0 10px 30px rgb(0 0 0 / 0.35); -} - -.modal h2 { - margin: 0 0 1rem; - font-size: 1.125rem; - font-weight: 600; -} - -.modal-actions { - display: flex; - align-items: center; - gap: 0.5rem; - padding-top: 1.25rem; -} - -/* Folder picker */ -.crumbs { - display: flex; - align-items: center; - gap: 0.375rem; - margin-bottom: 0.5rem; - font-size: 0.75rem; - color: hsl(var(--muted-foreground)); - font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; - overflow-wrap: anywhere; -} - -.picker { - height: 16rem; - overflow-y: auto; - border: 1px solid hsl(var(--border)); - border-radius: var(--radius); - background: hsl(var(--muted) / 0.3); -} - -.picker button { - display: flex; - align-items: center; - gap: 0.5rem; - width: 100%; - padding: 0.5rem 0.75rem; - border: 0; - background: none; - font: inherit; - font-size: 0.8125rem; - color: hsl(var(--foreground)); - cursor: pointer; - text-align: left; -} - -.picker button:hover { - background: hsl(var(--accent)); -} - -.picker .marker { - margin-left: auto; - flex: none; -} - -.muted { - color: hsl(var(--muted-foreground)); -} - -.tight { - margin: 0.5rem 0 0; - font-size: 0.75rem; - color: hsl(var(--muted-foreground)); -} diff --git a/internal/ui/assets/vendor/force-graph.LICENSE b/internal/ui/assets/vendor/force-graph.LICENSE deleted file mode 100644 index a36ddd4..0000000 --- a/internal/ui/assets/vendor/force-graph.LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Vasco Asturiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/internal/ui/assets/vendor/force-graph.min.js b/internal/ui/assets/vendor/force-graph.min.js deleted file mode 100644 index a2ed925..0000000 --- a/internal/ui/assets/vendor/force-graph.min.js +++ /dev/null @@ -1,5 +0,0 @@ -// Version 1.51.4 force-graph - https://github.com/vasturiano/force-graph -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).ForceGraph=n()}(this,function(){"use strict";function n(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),f.hasOwnProperty(n)?{space:f[n],local:t}:t}function d(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===h&&n.documentElement.namespaceURI===h?n.createElement(t):n.createElementNS(e,t)}}function g(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function _(t){var n=p(t);return(n.local?g:d)(n)}function y(){}function v(t){return null==t?y:function(){return this.querySelector(t)}}function m(){return[]}function x(t){return null==t?m:function(){return this.querySelectorAll(t)}}function b(t){return function(){return function(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}(t.apply(this,arguments))}}function w(t){return function(){return this.matches(t)}}function k(t){return function(n){return n.matches(t)}}var M=Array.prototype.find;function A(){return this.firstElementChild}var z=Array.prototype.filter;function S(){return Array.from(this.children)}function C(t){return new Array(t.length)}function E(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function P(t,n,e,r,i,o){for(var a,u=0,s=n.length,l=o.length;un?1:t>=n?0:NaN}function R(t){return function(){this.removeAttribute(t)}}function D(t){return function(){this.removeAttributeNS(t.space,t.local)}}function I(t,n){return function(){this.setAttribute(t,n)}}function U(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function F(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function L(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function q(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function $(t){return function(){this.style.removeProperty(t)}}function B(t,n,e){return function(){this.style.setProperty(t,n,e)}}function H(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function V(t,n){return t.style.getPropertyValue(n)||q(t).getComputedStyle(t,null).getPropertyValue(n)}function X(t){return function(){delete this[t]}}function G(t,n){return function(){this[t]=n}}function Y(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function W(t){return t.trim().split(/^|\s+/)}function Z(t){return t.classList||new Q(t)}function Q(t){this._node=t,this._names=W(t.getAttribute("class")||"")}function K(t,n){for(var e=Z(t),r=-1,i=n.length;++r=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var xt=[null];function bt(t,n){this._groups=t,this._parents=n}function wt(){return new bt([[document.documentElement]],xt)}function kt(t){return"string"==typeof t?new bt([[document.querySelector(t)]],[document.documentElement]):new bt([[t]],xt)}function Mt(t,n){if(t=function(t){let n;for(;n=t.sourceEvent;)t=n;return t}(t),void 0===n&&(n=t.currentTarget),n){var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(n.getScreenCTM().inverse())).x,r.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}}return[t.pageX,t.pageY]}bt.prototype=wt.prototype={constructor:bt,select:function(t){"function"!=typeof t&&(t=v(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i=x&&(x=m+1);!(v=_[x])&&++x=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=T);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?$:"function"==typeof n?H:B)(t,n,null==e?"":e)):V(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?X:"function"==typeof n?Y:G)(t,n)):this.node()[t]},classed:function(t,n){var e=W(t+"");if(arguments.length<2){for(var r=Z(this.node()),i=-1,o=e.length;++i=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}(t+""),a=o.length;if(!(arguments.length<2)){for(u=n?_t:gt,r=0;r{}};function zt(){for(var t,n=0,e=arguments.length,r={};n=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})),a=-1,u=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++a0)for(var e,r,i=new Array(e),o=0;o()=>t;function It(t,{sourceEvent:n,subject:e,target:r,identifier:i,active:o,x:a,y:u,dx:s,dy:l,dispatch:c}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:s,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:c}})}function Ut(t){return!t.ctrlKey&&!t.button}function Ft(){return this.parentNode}function Lt(t,n){return null==n?{x:t.x,y:t.y}:n}function qt(){return navigator.maxTouchPoints||"ontouchstart"in this}function $t(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function Bt(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function Ht(){}It.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var Vt=.7,Xt=1/Vt,Gt="\\s*([+-]?\\d+)\\s*",Yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Zt=/^#([0-9a-f]{3,8})$/,Qt=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Kt=new RegExp(`^rgb\\(${Wt},${Wt},${Wt}\\)$`),Jt=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${Yt}\\)$`),tn=new RegExp(`^rgba\\(${Wt},${Wt},${Wt},${Yt}\\)$`),nn=new RegExp(`^hsl\\(${Yt},${Wt},${Wt}\\)$`),en=new RegExp(`^hsla\\(${Yt},${Wt},${Wt},${Yt}\\)$`),rn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function on(){return this.rgb().formatHex()}function an(){return this.rgb().formatRgb()}function un(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=Zt.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?sn(n):3===e?new hn(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?ln(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?ln(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=Qt.exec(t))?new hn(n[1],n[2],n[3],1):(n=Kt.exec(t))?new hn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=Jt.exec(t))?ln(n[1],n[2],n[3],n[4]):(n=tn.exec(t))?ln(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=nn.exec(t))?yn(n[1],n[2]/100,n[3]/100,1):(n=en.exec(t))?yn(n[1],n[2]/100,n[3]/100,n[4]):rn.hasOwnProperty(t)?sn(rn[t]):"transparent"===t?new hn(NaN,NaN,NaN,0):null}function sn(t){return new hn(t>>16&255,t>>8&255,255&t,1)}function ln(t,n,e,r){return r<=0&&(t=n=e=NaN),new hn(t,n,e,r)}function cn(t,n,e,r){return 1===arguments.length?function(t){return t instanceof Ht||(t=un(t)),t?new hn((t=t.rgb()).r,t.g,t.b,t.opacity):new hn}(t):new hn(t,n,e,null==r?1:r)}function hn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function fn(){return`#${_n(this.r)}${_n(this.g)}${_n(this.b)}`}function pn(){const t=dn(this.opacity);return`${1===t?"rgb(":"rgba("}${gn(this.r)}, ${gn(this.g)}, ${gn(this.b)}${1===t?")":`, ${t})`}`}function dn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function gn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function _n(t){return((t=gn(t))<16?"0":"")+t.toString(16)}function yn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new mn(t,n,e,r)}function vn(t){if(t instanceof mn)return new mn(t.h,t.s,t.l,t.opacity);if(t instanceof Ht||(t=un(t)),!t)return new mn;if(t instanceof mn)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,s=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e0&&s<1?0:a,new mn(a,u,s,t.opacity)}function mn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function xn(t){return(t=(t||0)%360)<0?t+360:t}function bn(t){return Math.max(0,Math.min(1,t||0))}function wn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}$t(Ht,un,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:on,formatHex:on,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return vn(this).formatHsl()},formatRgb:an,toString:an}),$t(hn,cn,Bt(Ht,{brighter(t){return t=null==t?Xt:Math.pow(Xt,t),new hn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Vt:Math.pow(Vt,t),new hn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new hn(gn(this.r),gn(this.g),gn(this.b),dn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:fn,formatHex:fn,formatHex8:function(){return`#${_n(this.r)}${_n(this.g)}${_n(this.b)}${_n(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:pn,toString:pn})),$t(mn,function(t,n,e,r){return 1===arguments.length?vn(t):new mn(t,n,e,null==r?1:r)},Bt(Ht,{brighter(t){return t=null==t?Xt:Math.pow(Xt,t),new mn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Vt:Math.pow(Vt,t),new mn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new hn(wn(t>=240?t-240:t+120,i,r),wn(t,i,r),wn(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new mn(xn(this.h),bn(this.s),bn(this.l),dn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=dn(this.opacity);return`${1===t?"hsl(":"hsla("}${xn(this.h)}, ${100*bn(this.s)}%, ${100*bn(this.l)}%${1===t?")":`, ${t})`}`}}));var kn=t=>()=>t;function Mn(t){return 1===(t=+t)?An:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):kn(isNaN(n)?e:n)}}function An(t,n){var e=n-t;return e?function(t,n){return function(e){return t+e*n}}(t,e):kn(isNaN(t)?n:t)}var zn=function t(n){var e=Mn(n);function r(t,n){var r=e((t=cn(t)).r,(n=cn(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=An(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function Sn(t,n){return t=+t,n=+n,function(e){return t*(1-e)+n*e}}var Cn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,En=new RegExp(Cn.source,"g");function Pn(t,n){var e,r,i,o=Cn.lastIndex=En.lastIndex=0,a=-1,u=[],s=[];for(t+="",n+="";(e=Cn.exec(t))&&(r=En.exec(n));)(i=r.index)>o&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,s.push({i:a,x:Sn(e,r)})),o=En.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Sn(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,s),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Sn(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,s),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:Sn(t,e)},{i:u-2,x:Sn(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,s),o=a=null,function(t){for(var n,e=-1,r=s.length;++e=0&&n._call.call(void 0,t),n=n._next;--$n}()}finally{$n=0,function(){var t,n,e=Fn,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Fn=n);Ln=t,ee(r)}(),Xn=0}}function ne(){var t=Yn.now(),n=t-Vn;n>1e3&&(Gn-=n,Vn=t)}function ee(t){$n||(Bn&&(Bn=clearTimeout(Bn)),t-Xn>24?(t<1/0&&(Bn=setTimeout(te,t-Yn.now()-Gn)),Hn&&(Hn=clearInterval(Hn))):(Hn||(Vn=Yn.now(),Hn=setInterval(ne,1e3)),$n=1,Wn(te)))}function re(t,n,e){var r=new Kn;return n=null==n?0:+n,r.restart(e=>{r.stop(),t(e+n)},n,e),r}Kn.prototype=Jn.prototype={constructor:Kn,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?Zn():+e)+(null==n?0:+n),this._next||Ln===this||(Ln?Ln._next=this:Fn=this,Ln=this),this._call=t,this._time=e,ee()},stop:function(){this._call&&(this._call=null,this._time=1/0,ee())}};var ie=zt("start","end","cancel","interrupt"),oe=[];function ae(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(t){e.state=1,e.timer.restart(a,e.delay,e.time),e.delay<=t&&a(t-e.delay)}function a(o){var l,c,h,f;if(1!==e.state)return s();for(l in i)if((f=i[l]).name===e.name){if(3===f.state)return re(a);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[l]):+l0)throw new Error("too late; already scheduled");return e}function se(t,n){var e=le(t,n);if(e.state>3)throw new Error("too late; already running");return e}function le(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function ce(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>2&&e.state<5,e.state=6,e.timer.stop(),e.on.call(r?"interrupt":"cancel",t,t.__data__,e.index,e.group),delete o[i]):a=!1;a&&delete t.__transition}}function he(t,n){var e,r;return function(){var i=se(this,t),o=i.tween;if(o!==e)for(var a=0,u=(r=e=o).length;a=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?ue:se;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var e=p(t),r="transform"===e?In:de;return this.attrTween(t,"function"==typeof n?(e.local?xe:me)(e,r,pe(this,"attr."+t,n)):null==n?(e.local?_e:ge)(e):(e.local?ve:ye)(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=p(t);return this.tween(e,(r.local?be:we)(r,n))},style:function(t,n,e){var r="transform"==(t+="")?Dn:de;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=V(this,t),a=(this.style.removeProperty(t),V(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,Ce(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=V(this,t),u=e(this),s=u+"";return null==u&&(this.style.removeProperty(t),s=u=V(this,t)),a===s?null:a===r&&s===i?o:(i=s,o=n(r=a,u))}}(t,r,pe(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var s=se(this,t),l=s.on,c=null==s.value[a]?o||(o=Ce(n)):void 0;l===e&&i===c||(r=(e=l).copy()).on(u,i=c),s.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=V(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(pe(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=le(this.node(),e).tween,o=0,a=i.length;o()=>t;function De(t,{sourceEvent:n,target:e,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ie(t,n,e){this.k=t,this.x=n,this.y=e}Ie.prototype={constructor:Ie,scale:function(t){return 1===t?this:new Ie(this.k*t,this.x,this.y)},translate:function(t,n){return 0===t&0===n?this:new Ie(this.k,this.x+this.k*t,this.y+this.k*n)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ue=new Ie(1,0,0);function Fe(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Ue;return t.__zoom}function Le(t){t.stopImmediatePropagation()}function qe(t){t.preventDefault(),t.stopImmediatePropagation()}function $e(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Be(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function He(){return this.__zoom||Ue}function Ve(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Xe(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ge(t,n,e){var r=t.invertX(n[0][0])-e[0][0],i=t.invertX(n[1][0])-e[1][0],o=t.invertY(n[0][1])-e[0][1],a=t.invertY(n[1][1])-e[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function Ye(){var t,n,e,r=$e,i=Be,o=Ge,a=Ve,u=Xe,s=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,h=qn,f=zt("start","zoom","end"),p=0,d=10;function g(t){t.property("__zoom",He).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",k).on("dblclick.zoom",M).filter(u).on("touchstart.zoom",A).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",S).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(t,n){return(n=Math.max(s[0],Math.min(s[1],n)))===t.k?t:new Ie(n,t.x,t.y)}function y(t,n,e){var r=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return r===t.x&&i===t.y?t:new Ie(t.k,r,i)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function m(t,n,e,r){t.on("start.zoom",function(){x(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).event(r).end()}).tween("zoom",function(){var t=this,o=arguments,a=x(t,o).event(r),u=i.apply(t,o),s=null==e?v(u):"function"==typeof e?e.apply(t,o):e,l=Math.max(u[1][0]-u[0][0],u[1][1]-u[0][1]),c=t.__zoom,f="function"==typeof n?n.apply(t,o):n,p=h(c.invert(s).concat(l/c.k),f.invert(s).concat(l/f.k));return function(t){if(1===t)t=f;else{var n=p(t),e=l/n[2];t=new Ie(e,s[0]-n[0]*e,s[1]-n[1]*e)}a.zoom(null,t)}})}function x(t,n,e){return!e&&t.__zooming||new b(t,n)}function b(t,n){this.that=t,this.args=n,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,n),this.taps=0}function w(t,...n){if(r.apply(this,arguments)){var e=x(this,n).event(t),i=this.__zoom,u=Math.max(s[0],Math.min(s[1],i.k*Math.pow(2,a.apply(this,arguments)))),c=Mt(t);if(e.wheel)e.mouse[0][0]===c[0]&&e.mouse[0][1]===c[1]||(e.mouse[1]=i.invert(e.mouse[0]=c)),clearTimeout(e.wheel);else{if(i.k===u)return;e.mouse=[c,i.invert(c)],ce(this),e.start()}qe(t),e.wheel=setTimeout(function(){e.wheel=null,e.end()},150),e.zoom("mouse",o(y(_(i,u),e.mouse[0],e.mouse[1]),e.extent,l))}}function k(t,...n){if(!e&&r.apply(this,arguments)){var i=t.currentTarget,a=x(this,n,!0).event(t),u=kt(t.view).on("mousemove.zoom",function(t){if(qe(t),!a.moved){var n=t.clientX-c,e=t.clientY-h;a.moved=n*n+e*e>p}a.event(t).zoom("mouse",o(y(a.that.__zoom,a.mouse[0]=Mt(t,i),a.mouse[1]),a.extent,l))},!0).on("mouseup.zoom",function(t){u.on("mousemove.zoom mouseup.zoom",null),Rt(t.view,a.moved),qe(t),a.event(t).end()},!0),s=Mt(t,i),c=t.clientX,h=t.clientY;Tt(t.view),Le(t),a.mouse=[s,this.__zoom.invert(s)],ce(this),a.start()}}function M(t,...n){if(r.apply(this,arguments)){var e=this.__zoom,a=Mt(t.changedTouches?t.changedTouches[0]:t,this),u=e.invert(a),s=e.k*(t.shiftKey?.5:2),h=o(y(_(e,s),a,u),i.apply(this,n),l);qe(t),c>0?kt(this).transition().duration(c).call(m,h,a,t):kt(this).call(g.transform,h,a,t)}}function A(e,...i){if(r.apply(this,arguments)){var o,a,u,s,l=e.touches,c=l.length,h=x(this,i,e.changedTouches.length===c).event(e);for(Le(e),a=0;a=n)&&(e=n);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(e=i)&&(e=i)}return e}function Je(t,n){let e;if(void 0===n)for(const n of t)null!=n&&(e>n||void 0===e&&n>=n)&&(e=n);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(e>i||void 0===e&&i>=i)&&(e=i)}return e}var tr="object"==typeof global&&global&&global.Object===Object&&global,nr="object"==typeof self&&self&&self.Object===Object&&self,er=tr||nr||Function("return this")(),rr=er.Symbol,ir=Object.prototype,or=ir.hasOwnProperty,ar=ir.toString,ur=rr?rr.toStringTag:void 0;var sr=Object.prototype.toString;var lr=rr?rr.toStringTag:void 0;function cr(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":lr&&lr in Object(t)?function(t){var n=or.call(t,ur),e=t[ur];try{t[ur]=void 0;var r=!0}catch(t){}var i=ar.call(t);return r&&(n?t[ur]=e:delete t[ur]),i}(t):function(t){return sr.call(t)}(t)}var hr=/\s/;var fr=/^\s+/;function pr(t){return t?t.slice(0,function(t){for(var n=t.length;n--&&hr.test(t.charAt(n)););return n}(t)+1).replace(fr,""):t}function dr(t){var n=typeof t;return null!=t&&("object"==n||"function"==n)}var gr=/^[-+]0x[0-9a-f]+$/i,_r=/^0b[01]+$/i,yr=/^0o[0-7]+$/i,vr=parseInt;function mr(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return null!=t&&"object"==typeof t}(t)&&"[object Symbol]"==cr(t)}(t))return NaN;if(dr(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=dr(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=pr(t);var e=_r.test(t);return e||yr.test(t)?vr(t.slice(2),e?2:8):gr.test(t)?NaN:+t}var xr=function(){return er.Date.now()},br=Math.max,wr=Math.min;function kr(t,n,e){var r,i,o,a,u,s,l=0,c=!1,h=!1,f=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(n){var e=r,o=i;return r=i=void 0,l=n,a=t.apply(o,e)}function d(t){var e=t-s;return void 0===s||e>=n||e<0||h&&t-l>=o}function g(){var t=xr();if(d(t))return _(t);u=setTimeout(g,function(t){var e=n-(t-s);return h?wr(e,o-(t-l)):e}(t))}function _(t){return u=void 0,f&&r?p(t):(r=i=void 0,a)}function y(){var t=xr(),e=d(t);if(r=arguments,i=this,s=t,e){if(void 0===u)return function(t){return l=t,u=setTimeout(g,n),c?p(t):a}(s);if(h)return clearTimeout(u),u=setTimeout(g,n),p(s)}return void 0===u&&(u=setTimeout(g,n)),a}return n=mr(n)||0,dr(e)&&(c=!!e.leading,o=(h="maxWait"in e)?br(mr(e.maxWait)||0,n):o,f="trailing"in e?!!e.trailing:f),y.cancel=function(){void 0!==u&&clearTimeout(u),l=0,r=s=i=u=void 0},y.flush=function(){return void 0===u?a:_(xr())},y}var Mr=Object.freeze({Linear:Object.freeze({None:function(t){return t},In:function(t){return t},Out:function(t){return t},InOut:function(t){return t}}),Quadratic:Object.freeze({In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}}),Cubic:Object.freeze({In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}}),Quartic:Object.freeze({In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}}),Quintic:Object.freeze({In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}}),Sinusoidal:Object.freeze({In:function(t){return 1-Math.sin((1-t)*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.sin(Math.PI*(.5-t)))}}),Exponential:Object.freeze({In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}}),Circular:Object.freeze({In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}}),Elastic:Object.freeze({In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(t){var n=1.70158;return 1===t?1:t*t*((n+1)*t-n)},Out:function(t){var n=1.70158;return 0===t?0:--t*t*((n+1)*t+n)+1},InOut:function(t){var n=2.5949095;return(t*=2)<1?t*t*((n+1)*t-n)*.5:.5*((t-=2)*t*((n+1)*t+n)+2)}}),Bounce:Object.freeze({In:function(t){return 1-Mr.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*Mr.Bounce.In(2*t):.5*Mr.Bounce.Out(2*t-1)+.5}}),generatePow:function(t){return void 0===t&&(t=4),t=(t=t1e4?1e4:t,{In:function(n){return Math.pow(n,t)},Out:function(n){return 1-Math.pow(1-n,t)},InOut:function(n){return n<.5?Math.pow(2*n,t)/2:(1-Math.pow(2-2*n,t))/2+.5}}}}),Ar=function(){return performance.now()},zr=function(){function t(){for(var t=[],n=0;n0;){this._tweensAddedDuringUpdate={};for(var r=0;r1?o(t[e],t[e-1],e-r):o(t[i],t[i+1>e?e:i+1],r-i)},Utils:{Linear:function(t,n,e){return(n-t)*e+t}}},Cr=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),Er=new zr,Pr=function(){function t(t,n){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Mr.Linear.None,this._interpolationFunction=Sr.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Cr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=t,"object"==typeof n?(this._group=n,n.add(this)):!0===n&&(this._group=Er,Er.add(this))}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.getDuration=function(){return this._duration},t.prototype.to=function(t,n){if(void 0===n&&(n=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=n<0?0:n,this},t.prototype.duration=function(t){return void 0===t&&(t=1e3),this._duration=t<0?0:t,this},t.prototype.dynamic=function(t){return void 0===t&&(t=!1),this._isDynamic=t,this},t.prototype.start=function(t,n){if(void 0===t&&(t=Ar()),void 0===n&&(n=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||n){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var i in this._valuesEnd)r[i]=this._valuesEnd[i];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,n)}return this},t.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},t.prototype._setupProperties=function(t,n,e,r,i){for(var o in e){var a=t[o],u=Array.isArray(a),s=u?"array":typeof a,l=!u&&Array.isArray(e[o]);if("undefined"!==s&&"function"!==s){if(l){if(0===(_=e[o]).length)continue;for(var c=[a],h=0,f=_.length;hs)return 1;var t=Math.trunc(a/u),n=a-t*u,e=Math.min(n/o._duration,1);return 0===e&&a===o._duration?1:e}(),c=this._easingFunction(l);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,c),this._onUpdateCallback&&this._onUpdateCallback(this._object,l),0===this._duration||a>=this._duration){if(this._repeat>0){var h=Math.min(Math.trunc((a-this._duration)/u)+1,this._repeat);for(i in isFinite(this._repeat)&&(this._repeat-=h),this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[i]||(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*h,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var f=0,p=this._chainedTweens.length;ft.length)&&(n=t.length);for(var e=0,r=Array(n);e1&&(e-=1),e<1/6?t+6*(n-t)*e:e<.5?n:e<2/3?t+(n-t)*(2/3-e)*6:t}if(t=ui(t,360),n=ui(n,100),e=ui(e,100),0===n)r=i=o=e;else{var u=e<.5?e*(1+n):e+n-e*n,s=2*e-u;r=a(s,u,t+1/3),i=a(s,u,t),o=a(s,u,t-1/3)}return{r:255*r,g:255*i,b:255*o}}(t.h,r,o),a=!0,u="hsl"),t.hasOwnProperty("a")&&(e=t.a));return e=ai(e),{ok:a,format:t.format||u,r:Math.min(255,Math.max(n.r,0)),g:Math.min(255,Math.max(n.g,0)),b:Math.min(255,Math.max(n.b,0)),a:e}}(t);this._originalInput=t,this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._roundA=Math.round(100*this._a)/100,this._format=n.format||e.format,this._gradientType=n.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=e.ok}function $r(t,n,e){t=ui(t,255),n=ui(n,255),e=ui(e,255);var r,i,o=Math.max(t,n,e),a=Math.min(t,n,e),u=(o+a)/2;if(o==a)r=i=0;else{var s=o-a;switch(i=u>.5?s/(2-o-a):s/(o+a),o){case t:r=(n-e)/s+(n>1)+720)%360;--n;)r.h=(r.h+i)%360,o.push(qr(r));return o}function ri(t,n){n=n||6;for(var e=qr(t).toHsv(),r=e.h,i=e.s,o=e.v,a=[],u=1/n;n--;)a.push(qr({h:r,s:i,v:o})),o=(o+u)%1;return a}qr.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,n,e,r=this.toRgb();return t=r.r/255,n=r.g/255,e=r.b/255,.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))},setAlpha:function(t){return this._a=ai(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=Br(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=Br(this._r,this._g,this._b),n=Math.round(360*t.h),e=Math.round(100*t.s),r=Math.round(100*t.v);return 1==this._a?"hsv("+n+", "+e+"%, "+r+"%)":"hsva("+n+", "+e+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=$r(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=$r(this._r,this._g,this._b),n=Math.round(360*t.h),e=Math.round(100*t.s),r=Math.round(100*t.l);return 1==this._a?"hsl("+n+", "+e+"%, "+r+"%)":"hsla("+n+", "+e+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return Hr(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,n,e,r,i){var o=[ci(Math.round(t).toString(16)),ci(Math.round(n).toString(16)),ci(Math.round(e).toString(16)),ci(fi(r))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*ui(this._r,255))+"%",g:Math.round(100*ui(this._g,255))+"%",b:Math.round(100*ui(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*ui(this._r,255))+"%, "+Math.round(100*ui(this._g,255))+"%, "+Math.round(100*ui(this._b,255))+"%)":"rgba("+Math.round(100*ui(this._r,255))+"%, "+Math.round(100*ui(this._g,255))+"%, "+Math.round(100*ui(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(oi[Hr(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var n="#"+Vr(this._r,this._g,this._b,this._a),e=n,r=this._gradientType?"GradientType = 1, ":"";if(t){var i=qr(t);e="#"+Vr(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+n+",endColorstr="+e+")"},toString:function(t){var n=!!t;t=t||this._format;var e=!1,r=this._a<1&&this._a>=0;return n||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(e=this.toRgbString()),"prgb"===t&&(e=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(e=this.toHexString()),"hex3"===t&&(e=this.toHexString(!0)),"hex4"===t&&(e=this.toHex8String(!0)),"hex8"===t&&(e=this.toHex8String()),"name"===t&&(e=this.toName()),"hsl"===t&&(e=this.toHslString()),"hsv"===t&&(e=this.toHsvString()),e||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return qr(this.toString())},_applyModification:function(t,n){var e=t.apply(null,[this].concat([].slice.call(n)));return this._r=e._r,this._g=e._g,this._b=e._b,this.setAlpha(e._a),this},lighten:function(){return this._applyModification(Wr,arguments)},brighten:function(){return this._applyModification(Zr,arguments)},darken:function(){return this._applyModification(Qr,arguments)},desaturate:function(){return this._applyModification(Xr,arguments)},saturate:function(){return this._applyModification(Gr,arguments)},greyscale:function(){return this._applyModification(Yr,arguments)},spin:function(){return this._applyModification(Kr,arguments)},_applyCombination:function(t,n){return t.apply(null,[this].concat([].slice.call(n)))},analogous:function(){return this._applyCombination(ei,arguments)},complement:function(){return this._applyCombination(Jr,arguments)},monochromatic:function(){return this._applyCombination(ri,arguments)},splitcomplement:function(){return this._applyCombination(ni,arguments)},triad:function(){return this._applyCombination(ti,[3])},tetrad:function(){return this._applyCombination(ti,[4])}},qr.fromRatio=function(t,n){if("object"==Ur(t)){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]="a"===r?t[r]:hi(t[r]));t=e}return qr(t,n)},qr.equals=function(t,n){return!(!t||!n)&&qr(t).toRgbString()==qr(n).toRgbString()},qr.random=function(){return qr.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},qr.mix=function(t,n,e){e=0===e?0:e||50;var r=qr(t).toRgb(),i=qr(n).toRgb(),o=e/100;return qr({r:(i.r-r.r)*o+r.r,g:(i.g-r.g)*o+r.g,b:(i.b-r.b)*o+r.b,a:(i.a-r.a)*o+r.a})}, -// =4.5;break;case"AAlarge":i=o>=3;break;case"AAAsmall":i=o>=7}return i},qr.mostReadable=function(t,n,e){var r,i,o,a,u=null,s=0;i=(e=e||{}).includeFallbackColors,o=e.level,a=e.size;for(var l=0;ls&&(s=r,u=qr(n[l]));return qr.isReadable(t,u,{level:o,size:a})||!i?u:(e.includeFallbackColors=!1,qr.mostReadable(t,["#fff","#000"],e))};var ii=qr.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},oi=qr.hexNames=function(t){var n={};for(var e in t)t.hasOwnProperty(e)&&(n[t[e]]=e);return n}(ii);function ai(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function ui(t,n){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var e=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=Math.min(n,Math.max(0,parseFloat(t))),e&&(t=parseInt(t*n,10)/100),Math.abs(t-n)<1e-6?1:t%n/parseFloat(n)}function si(t){return Math.min(1,Math.max(0,t))}function li(t){return parseInt(t,16)}function ci(t){return 1==t.length?"0"+t:""+t}function hi(t){return t<=1&&(t=100*t+"%"),t}function fi(t){return Math.round(255*parseFloat(t)).toString(16)}function pi(t){return li(t)/255}var di,gi,_i,yi=(gi="[\\s|\\(]+("+(di="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+di+")[,|\\s]+("+di+")\\s*\\)?",_i="[\\s|\\(]+("+di+")[,|\\s]+("+di+")[,|\\s]+("+di+")[,|\\s]+("+di+")\\s*\\)?",{CSS_UNIT:new RegExp(di),rgb:new RegExp("rgb"+gi),rgba:new RegExp("rgba"+_i),hsl:new RegExp("hsl"+gi),hsla:new RegExp("hsla"+_i),hsv:new RegExp("hsv"+gi),hsva:new RegExp("hsva"+_i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function vi(t){return!!yi.CSS_UNIT.exec(t)}function mi(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e0&&void 0!==arguments[0]?arguments[0]:6;!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),wi(this,Hi,void 0),wi(this,Vi,void 0),ki(Vi,this,n),this.reset()},[{key:"reset",value:function(){ki(Hi,this,["__reserved for background__"])}},{key:"register",value:function(t){if(bi(Hi,this).length>=Math.pow(2,24-bi(Vi,this)))return null;var n,e=bi(Hi,this).length,r=Bi(e,bi(Vi,this)),i=(n=e+(r<<24-bi(Vi,this)),"#".concat(Math.min(n,Math.pow(2,24)).toString(16).padStart(6,"0")));return bi(Hi,this).push(t),i}},{key:"lookup",value:function(t){if(!t)return null;var n="string"==typeof t?function(t){var n=qr(t).toRgb(),e=n.r,r=n.g,i=n.b;return $i(e,r,i)}(t):$i.apply(void 0,Ai(t));if(!n)return null;var e=n&Math.pow(2,24-bi(Vi,this))-1,r=n>>24-bi(Vi,this)&Math.pow(2,bi(Vi,this))-1;return Bi(e,bi(Vi,this))!==r||e>=bi(Hi,this).length?null:bi(Hi,this)[e]}}])}(),Gi={},Yi=[],Wi=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Zi=Array.isArray;function Qi(t,n){for(var e in n)t[e]=n[e];return t}function Ki(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Ji(t,n,e,r,i){var o={type:t,props:n,key:e,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==i?++Ei:i,__i:-1,__u:0};return null==i&&null!=Ci.vnode&&Ci.vnode(o),o}function to(t){return t.children}function no(t,n){this.props=t,this.context=n}function eo(t,n){if(null==n)return t.__?eo(t.__,t.__i+1):null;for(var e;nn&&Oi.sort(Ti),t=Oi.shift(),n=Oi.length,ro(t)}finally{Oi.length=ao.__r=0}}function uo(t,n,e,r,i,o,a,u,s,l,c){var h,f,p,d,g,_,y,v=r&&r.__k||Yi,m=n.length;for(s=so(e,n,v,s,m),h=0;h0?a=t.__k[o]=Ji(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,s=o+f,a.__=t,a.__b=t.__b+1,u=null,-1!=(l=a.__i=co(a,e,s,h))&&(h--,(u=e[l])&&(u.__u|=2)),null==u||null==u.__v?(-1==l&&(i>c?f--:is?f--:f++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o(c?1:0))for(i=e-1,o=e+1;i>=0||o=0?i--:o++])&&!(2&l.__u)&&u==l.key&&s==l.type)return a;return-1}function ho(t,n,e){"-"==n[0]?t.setProperty(n,null==e?"":e):t[n]=null==e?"":"number"!=typeof e||Wi.test(n)?e:e+"px"}function fo(t,n,e,r,i){var o,a;t:if("style"==n)if("string"==typeof e)t.style.cssText=e;else{if("string"==typeof r&&(t.style.cssText=r=""),r)for(n in r)e&&n in e||ho(t.style,n,"");if(e)for(n in e)r&&e[n]==r[n]||ho(t.style,n,e[n])}else if("o"==n[0]&&"n"==n[1])o=n!=(n=n.replace(Ui,"$1")),a=n.toLowerCase(),n=a in t||"onFocusOut"==n||"onFocusIn"==n?a.slice(2):n.slice(2),t.l||(t.l={}),t.l[n+o]=e,e?r?e[Ii]=r[Ii]:(e[Ii]=Fi,t.addEventListener(n,o?qi:Li,o)):t.removeEventListener(n,o?qi:Li,o);else{if("http://www.w3.org/2000/svg"==i)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&"popover"!=n&&n in t)try{t[n]=null==e?"":e;break t}catch(t){}"function"==typeof e||(null==e||!1===e&&"-"!=n[4]?t.removeAttribute(n):t.setAttribute(n,"popover"==n&&1==e?"":e))}}function po(t){return function(n){if(this.l){var e=this.l[n.type+t];if(null==n[Di])n[Di]=Fi++;else if(n[Di]0?t:Zi(t)?t.map(vo):Qi({},t)}function mo(t,n,e,r,i,o,a,u,s){var l,c,h,f,p,d,g,_=e.props||Gi,y=n.props,v=n.type;if("svg"==v?i="http://www.w3.org/2000/svg":"math"==v?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=o)for(l=0;l2&&(a.children=arguments.length>3?Si.call(arguments,2):e),"function"==typeof t&&null!=t.defaultProps)for(o in t.defaultProps)void 0===a[o]&&(a[o]=t.defaultProps[o]);return Ji(t,a,r,i,null)}(to,null,[t]),r||Gi,Gi,n.namespaceURI,r?null:n.firstChild?Si.call(n.childNodes):null,i,r?r.__e:n.firstChild,false,o),yo(i,t,o)}function Mo(t,n,e){var r,i,o,a,u=Qi({},t.props);for(o in t.type&&t.type.defaultProps&&(a=t.type.defaultProps),n)"key"==o?r=n[o]:"ref"==o?i=n[o]:u[o]=void 0===n[o]&&null!=a?a[o]:n[o];return arguments.length>2&&(u.children=arguments.length>3?Si.call(arguments,2):e),Ji(t.type,u,r||t.key,i||t.ref,null)}function Ao(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e2&&void 0!==arguments[2]?arguments[2]:{}).style,r=void 0===e?{}:e,i=kt(!!t&&"object"===Eo(t)&&!!t.node&&"function"==typeof t.node?t.node():t);"static"===i.style("position")&&i.style("position","relative"),n.tooltipEl=i.append("div").attr("class","float-tooltip-kap"),Object.entries(r).forEach(function(t){var e=Co(t,2),r=e[0],i=e[1];return n.tooltipEl.style(r,i)}),n.tooltipEl.style("left","-10000px").style("display","none");var o="tooltip-".concat(Math.round(1e12*Math.random()));n.mouseInside=!1,i.on("mousemove.".concat(o),function(t){n.mouseInside=!0;var e=Mt(t),r=i.node(),o=r.offsetWidth,a=r.offsetHeight,u=[null===n.offsetX||void 0===n.offsetX?"-".concat(e[0]/o*100,"%"):"number"==typeof n.offsetX?"calc(-50% + ".concat(n.offsetX,"px)"):n.offsetX,null===n.offsetY||void 0===n.offsetY?a>130&&a-e[1]<100?"calc(-100% - 6px)":"21px":"number"==typeof n.offsetY?n.offsetY<0?"calc(-100% - ".concat(Math.abs(n.offsetY),"px)"):"".concat(n.offsetY,"px"):n.offsetY];n.tooltipEl.style("left",e[0]+"px").style("top",e[1]+"px").style("transform","translate(".concat(u.join(","),")")),n.content&&n.tooltipEl.style("display","inline")}),i.on("mouseover.".concat(o),function(){n.mouseInside=!0,n.content&&n.tooltipEl.style("display","inline")}),i.on("mouseout.".concat(o),function(){n.mouseInside=!1,n.tooltipEl.style("display","none")})},update:function(t){var n,e;t.tooltipEl.style("display",t.content&&t.mouseInside?"inline":"none"),t.content?t.content instanceof HTMLElement?(t.tooltipEl.text(""),t.tooltipEl.append(function(){return t.content})):"string"==typeof t.content?t.tooltipEl.html(t.content):!function(t){return Pi(Mo(t))}(t.content)?(t.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",t.content,t.content.toString())):(t.tooltipEl.text(""),n=t.content,delete(e=t.tooltipEl.node()).__k,ko(Po(n),e)):t.tooltipEl.text("")}});function No(t,n,e){var r,i=1;function o(){var o,a,u=r.length,s=0,l=0,c=0;for(o=0;o=(i=(h+f)/2))?h=i:f=i,r=l,!(l=l[u=+a]))return r[u]=c,t;if(n===(o=+t._x.call(null,l.data)))return c.next=l,r?r[u]=c:t._root=c,t;do{r=r?r[u]=new Array(2):t._root=new Array(2),(a=n>=(i=(h+f)/2))?h=i:f=i}while((u=+a)===(s=+(o>=i)));return r[s]=l,r[u]=c,t}function To(t,n,e){this.node=t,this.x0=n,this.x1=e}function Ro(t){return t[0]}function Do(t,n){var e=new Io(null==n?Ro:n,NaN,NaN);return null==t?e:e.addAll(t)}function Io(t,n,e){this._x=t,this._x0=n,this._x1=e,this._root=void 0}function Uo(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var Fo=Do.prototype=Io.prototype;function Lo(t,n,e,r){if(isNaN(n)||isNaN(e))return t;var i,o,a,u,s,l,c,h,f,p=t._root,d={data:r},g=t._x0,_=t._y0,y=t._x1,v=t._y1;if(!p)return t._root=d,t;for(;p.length;)if((l=n>=(o=(g+y)/2))?g=o:y=o,(c=e>=(a=(_+v)/2))?_=a:v=a,i=p,!(p=p[h=c<<1|l]))return i[h]=d,t;if(u=+t._x.call(null,p.data),s=+t._y.call(null,p.data),n===u&&e===s)return d.next=p,i?i[h]=d:t._root=d,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(l=n>=(o=(g+y)/2))?g=o:y=o,(c=e>=(a=(_+v)/2))?_=a:v=a}while((h=c<<1|l)==(f=(s>=a)<<1|u>=o));return i[f]=p,i[h]=d,t}function qo(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function $o(t){return t[0]}function Bo(t){return t[1]}function Ho(t,n,e){var r=new Vo(null==n?$o:n,null==e?Bo:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Vo(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Xo(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}Fo.copy=function(){var t,n,e=new Io(this._x,this._x0,this._x1),r=this._root;if(!r)return e;if(!r.length)return e._root=Uo(r),e;for(t=[{source:r,target:e._root=new Array(2)}];r=t.pop();)for(var i=0;i<2;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(2)}):r.target[i]=Uo(n));return e},Fo.add=function(t){const n=+this._x.call(null,t);return jo(this.cover(n),n,t)},Fo.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,e=new Float64Array(n);let r=1/0,i=-1/0;for(let o,a=0;ai&&(i=o));if(r>i)return this;this.cover(r).cover(i);for(let r=0;rt||t>=e;)switch(i=+(ts||(i=o.x1)=h))&&(o=l[l.length-1],l[l.length-1]=l[l.length-1-a],l[l.length-1-a]=o)}else{var f=Math.abs(t-+this._x.call(null,c.data));f=(a=(h+f)/2))?h=a:f=a,n=c,!(c=c[s=+u]))return this;if(!c.length)break;n[s+1&1]&&(e=n,l=s)}for(;c.data!==t;)if(r=c,!(c=c.next))return this;return(i=c.next)&&delete c.next,r?(i?r.next=i:delete r.next,this):n?(i?n[s]=i:delete n[s],(c=n[0]||n[1])&&c===(n[1]||n[0])&&!c.length&&(e?e[l]=c:this._root=c),this):(this._root=i,this)},Fo.removeAll=function(t){for(var n=0,e=t.length;n=(a=(m+w)/2))?m=a:w=a,(p=e>=(u=(x+k)/2))?x=u:k=u,(d=r>=(s=(b+M)/2))?b=s:M=s,o=y,!(y=y[g=d<<2|p<<1|f]))return o[g]=v,t;if(l=+t._x.call(null,y.data),c=+t._y.call(null,y.data),h=+t._z.call(null,y.data),n===l&&e===c&&r===h)return v.next=y,o?o[g]=v:t._root=v,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(f=n>=(a=(m+w)/2))?m=a:w=a,(p=e>=(u=(x+k)/2))?x=u:k=u,(d=r>=(s=(b+M)/2))?b=s:M=s}while((g=d<<2|p<<1|f)==(_=(h>=s)<<2|(c>=u)<<1|l>=a));return o[_]=y,o[g]=v,t}function Wo(t,n,e,r,i,o,a){this.node=t,this.x0=n,this.y0=e,this.z0=r,this.x1=i,this.y1=o,this.z1=a}Go.copy=function(){var t,n,e=new Vo(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=Xo(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=Xo(n));return e},Go.add=function(t){const n=+this._x.call(null,t),e=+this._y.call(null,t);return Lo(this.cover(n,e),n,e,t)},Go.addAll=function(t){var n,e,r,i,o=t.length,a=new Array(o),u=new Array(o),s=1/0,l=1/0,c=-1/0,h=-1/0;for(e=0;ec&&(c=r),ih&&(h=i));if(s>c||l>h)return this;for(this.cover(s,l).cover(c,h),e=0;et||t>=i||r>n||n>=o;)switch(u=(nf||(o=s.y0)>p||(a=s.x1)=y)<<1|t>=_)&&(s=d[d.length-1],d[d.length-1]=d[d.length-1-l],d[d.length-1-l]=s)}else{var v=t-+this._x.call(null,g.data),m=n-+this._y.call(null,g.data),x=v*v+m*m;if(x=(u=(d+_)/2))?d=u:_=u,(c=a>=(s=(g+y)/2))?g=s:y=s,n=p,!(p=p[h=c<<1|l]))return this;if(!p.length)break;(n[h+1&3]||n[h+2&3]||n[h+3&3])&&(e=n,f=h)}for(;p.data!==t;)if(r=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,r?(i?r.next=i:delete r.next,this):n?(i?n[h]=i:delete n[h],(p=n[0]||n[1]||n[2]||n[3])&&p===(n[3]||n[2]||n[1]||n[0])&&!p.length&&(e?e[f]=p:this._root=p),this):(this._root=i,this)},Go.removeAll=function(t){for(var n=0,e=t.length;nMath.sqrt((t-r)**2+(n-i)**2+(e-o)**2);function Qo(t){return t[0]}function Ko(t){return t[1]}function Jo(t){return t[2]}function ta(t,n,e,r){var i=new na(null==n?Qo:n,null==e?Ko:e,null==r?Jo:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function na(t,n,e,r,i,o,a,u,s){this._x=t,this._y=n,this._z=e,this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=u,this._z1=s,this._root=void 0}function ea(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var ra=ta.prototype=na.prototype;function ia(t){return function(){return t}}function oa(t){return 1e-6*(t()-.5)}function aa(t){return t.index}function ua(t,n){var e=t.get(n);if(!e)throw new Error("node not found: "+n);return e}function sa(t){var n,e,r,i,o,a,u,s=aa,l=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},c=ia(30),h=1;function f(r){for(var o=0,s=t.length;o1&&(y=f.y+f.vy-c.y-c.vy||oa(u)),i>2&&(v=f.z+f.vz-c.z-c.vz||oa(u)),_*=p=((p=Math.sqrt(_*_+y*y+v*v))-e[g])/p*r*n[g],y*=p,v*=p,f.vx-=_*(d=a[g]),i>1&&(f.vy-=y*d),i>2&&(f.vz-=v*d),c.vx+=_*(d=1-d),i>1&&(c.vy+=y*d),i>2&&(c.vz+=v*d)}function p(){if(r){var i,u,l=r.length,c=t.length,h=new Map(r.map((t,n)=>[s(t,n,r),t]));for(i=0,o=new Array(l);i"function"==typeof t)||Math.random,i=n.find(t=>[1,2,3].includes(t))||2,p()},f.links=function(n){return arguments.length?(t=n,p(),f):t},f.id=function(t){return arguments.length?(s=t,f):s},f.iterations=function(t){return arguments.length?(h=+t,f):h},f.strength=function(t){return arguments.length?(l="function"==typeof t?t:ia(+t),d(),f):l},f.distance=function(t){return arguments.length?(c="function"==typeof t?t:ia(+t),g(),f):c},f}ra.copy=function(){var t,n,e=new na(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return e;if(!r.length)return e._root=ea(r),e;for(t=[{source:r,target:e._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(8)}):r.target[i]=ea(n));return e},ra.add=function(t){const n=+this._x.call(null,t),e=+this._y.call(null,t),r=+this._z.call(null,t);return Yo(this.cover(n,e,r),n,e,r,t)},ra.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const n=t.length,e=new Float64Array(n),r=new Float64Array(n),i=new Float64Array(n);let o=1/0,a=1/0,u=1/0,s=-1/0,l=-1/0,c=-1/0;for(let h,f,p,d,g=0;gs&&(s=f),pl&&(l=p),dc&&(c=d));if(o>s||a>l||u>c)return this;this.cover(o,a,u).cover(s,l,c);for(let o=0;ot||t>=a||i>n||n>=u||o>e||e>=s;)switch(c=(e_||(a=h.y0)>y||(u=h.z0)>v||(s=h.x1)=k)<<2|(n>=w)<<1|t>=b)&&(h=m[m.length-1],m[m.length-1]=m[m.length-1-f],m[m.length-1-f]=h)}else{var M=t-+this._x.call(null,x.data),A=n-+this._y.call(null,x.data),z=e-+this._z.call(null,x.data),S=M*M+A*A+z*z;if(S{if(!h.length)do{const o=h.data;Zo(t,n,e,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(h=h.next);return f>s||p>l||d>c||g=(s=(y+x)/2))?y=s:x=s,(f=a>=(l=(v+b)/2))?v=l:b=l,(p=u>=(c=(m+w)/2))?m=c:w=c,n=_,!(_=_[d=p<<2|f<<1|h]))return this;if(!_.length)break;(n[d+1&7]||n[d+2&7]||n[d+3&7]||n[d+4&7]||n[d+5&7]||n[d+6&7]||n[d+7&7])&&(e=n,g=d)}for(;_.data!==t;)if(r=_,!(_=_.next))return this;return(i=_.next)&&delete _.next,r?(i?r.next=i:delete r.next,this):n?(i?n[d]=i:delete n[d],(_=n[0]||n[1]||n[2]||n[3]||n[4]||n[5]||n[6]||n[7])&&_===(n[7]||n[6]||n[5]||n[4]||n[3]||n[2]||n[1]||n[0])&&!_.length&&(e?e[g]=_:this._root=_),this):(this._root=i,this)},ra.removeAll=function(t){for(var n=0,e=t.length;n(t=(1664525*t+1013904223)%la)/la}();function p(){d(),h.call("tick",e),i1&&(null==c.fy?c.y+=c.vy*=s:(c.y=c.fy,c.vy=0)),r>2&&(null==c.fz?c.z+=c.vz*=s:(c.z=c.fz,c.vz=0));return e}function g(){for(var n,e=0,i=t.length;e1&&isNaN(n.y)||r>2&&isNaN(n.z)){var o=10*(r>2?Math.cbrt(.5+e):r>1?Math.sqrt(.5+e):e),a=e*pa,u=e*da;1===r?n.x=o:2===r?(n.x=o*Math.cos(a),n.y=o*Math.sin(a)):(n.x=o*Math.sin(a)*Math.cos(u),n.y=o*Math.cos(a),n.z=o*Math.sin(a)*Math.sin(u))}(isNaN(n.vx)||r>1&&isNaN(n.vy)||r>2&&isNaN(n.vz))&&(n.vx=0,r>1&&(n.vy=0),r>2&&(n.vz=0))}}function _(n){return n.initialize&&n.initialize(t,f,r),n}return null==t&&(t=[]),g(),e={tick:d,restart:function(){return c.restart(p),e},stop:function(){return c.stop(),e},numDimensions:function(t){return arguments.length?(r=Math.min(3,Math.max(1,Math.round(t))),l.forEach(_),e):r},nodes:function(n){return arguments.length?(t=n,g(),l.forEach(_),e):t},alpha:function(t){return arguments.length?(i=+t,e):i},alphaMin:function(t){return arguments.length?(o=+t,e):o},alphaDecay:function(t){return arguments.length?(a=+t,e):+a},alphaTarget:function(t){return arguments.length?(u=+t,e):u},velocityDecay:function(t){return arguments.length?(s=1-t,e):1-s},randomSource:function(t){return arguments.length?(f=t,l.forEach(_),e):f},force:function(t,n){return arguments.length>1?(null==n?l.delete(t):l.set(t,_(n)),e):l.get(t)},find:function(){var n,e,i,o,a,u,s=Array.prototype.slice.call(arguments),l=s.shift()||0,c=(r>1?s.shift():null)||0,h=(r>2?s.shift():null)||0,f=s.shift()||1/0,p=0,d=t.length;for(f*=f,p=0;p1?(h.on(t,n),e):h.on(t)}}}function _a(){var t,n,e,r,i,o,a=ia(-30),u=1,s=1/0,l=.81;function c(r){var o,a=t.length,u=(1===n?Do(t,ca):2===n?Ho(t,ca,ha):3===n?ta(t,ca,ha,fa):null).visitAfter(f);for(i=r,o=0;o1&&(t.y=a/c),n>2&&(t.z=u/c)}else{(e=t).x=e.data.x,n>1&&(e.y=e.data.y),n>2&&(e.z=e.data.z);do{l+=o[e.data.index]}while(e=e.next)}t.value=l}function p(t,a,c,h,f){if(!t.value)return!0;var p=[c,h,f][n-1],d=t.x-e.x,g=n>1?t.y-e.y:0,_=n>2?t.z-e.z:0,y=p-a,v=d*d+g*g+_*_;if(y*y/l1&&0===g&&(v+=(g=oa(r))*g),n>2&&0===_&&(v+=(_=oa(r))*_),v1&&(e.vy+=g*t.value*i/v),n>2&&(e.vz+=_*t.value*i/v)),!0;if(!(t.length||v>=s)){(t.data!==e||t.next)&&(0===d&&(v+=(d=oa(r))*d),n>1&&0===g&&(v+=(g=oa(r))*g),n>2&&0===_&&(v+=(_=oa(r))*_),v1&&(e.vy+=g*y),n>2&&(e.vz+=_*y))}while(t=t.next)}}return c.initialize=function(e,...i){t=e,r=i.find(t=>"function"==typeof t)||Math.random,n=i.find(t=>[1,2,3].includes(t))||2,h()},c.strength=function(t){return arguments.length?(a="function"==typeof t?t:ia(+t),h(),c):a},c.distanceMin=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u)},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.theta=function(t){return arguments.length?(l=t*t,c):Math.sqrt(l)},c}const{abs:ya,cos:va,sin:ma,acos:xa,atan2:ba,sqrt:wa,pow:ka}=Math;function Ma(t){return t<0?-ka(-t,1/3):ka(t,1/3)}const Aa=Math.PI,za=2*Aa,Sa=Aa/2,Ca=Number.MAX_SAFE_INTEGER||9007199254740991,Ea=Number.MIN_SAFE_INTEGER||-9007199254740991,Pa={x:0,y:0,z:0},Oa={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(t,n){const e=n(t);let r=e.x*e.x+e.y*e.y;return void 0!==e.z&&(r+=e.z*e.z),wa(r)},compute:function(t,n,e){if(0===t)return n[0].t=0,n[0];const r=n.length-1;if(1===t)return n[r].t=1,n[r];const i=1-t;let o=n;if(0===r)return n[0].t=t,n[0];if(1===r){const n={x:i*o[0].x+t*o[1].x,y:i*o[0].y+t*o[1].y,t:t};return e&&(n.z=i*o[0].z+t*o[1].z),n}if(r<4){let n,a,u,s=i*i,l=t*t,c=0;2===r?(o=[o[0],o[1],o[2],Pa],n=s,a=i*t*2,u=l):3===r&&(n=s*i,a=s*t*3,u=i*l*3,c=t*l);const h={x:n*o[0].x+a*o[1].x+u*o[2].x+c*o[3].x,y:n*o[0].y+a*o[1].y+u*o[2].y+c*o[3].y,t:t};return e&&(h.z=n*o[0].z+a*o[1].z+u*o[2].z+c*o[3].z),h}const a=JSON.parse(JSON.stringify(n));for(;a.length>1;){for(let n=0;n1;i--,o--){const t=[];for(let e,i=0;io.x.min&&(n=o.x.min),e>o.y.min&&(e=o.y.min),r0&&(a.c1=n,a.c2=r,a.s1=t,a.s2=e,o.push(a))})}),o},makeshape:function(t,n,e){const r=n.points.length,i=t.points.length,o=Oa.makeline(n.points[r-1],t.points[0]),a=Oa.makeline(t.points[i-1],n.points[0]),u={startcap:o,forward:t,back:n,endcap:a,bbox:Oa.findbbox([o,t,n,a]),intersections:function(t){return Oa.shapeintersections(u,u.bbox,t,t.bbox,e)}};return u},getminmax:function(t,n,e){if(!e)return{min:0,max:0};let r,i,o=Ca,a=Ea;-1===e.indexOf(0)&&(e=[0].concat(e)),-1===e.indexOf(1)&&e.push(1);for(let u=0,s=e.length;ua&&(a=i[n]);return{min:o,mid:(o+a)/2,max:a,size:a-o}},align:function(t,n){const e=n.p1.x,r=n.p1.y,i=-ba(n.p2.y-r,n.p2.x-e);return t.map(function(t){return{x:(t.x-e)*va(i)-(t.y-r)*ma(i),y:(t.x-e)*ma(i)+(t.y-r)*va(i)}})},roots:function(t,n){n=n||{p1:{x:0,y:0},p2:{x:1,y:0}};const e=t.length-1,r=Oa.align(t,n),i=function(t){return 0<=t&&t<=1};if(2===e){const t=r[0].y,n=r[1].y,e=r[2].y,o=t-2*n+e;if(0!==o){const r=-wa(n*n-t*e),a=-t+n;return[-(r+a)/o,-(-r+a)/o].filter(i)}return n!==e&&0===o?[(2*n-e)/(2*n-2*e)].filter(i):[]}const o=r[0].y,a=r[1].y,u=r[2].y;let s=3*a-o-3*u+r[3].y,l=3*o-6*a+3*u,c=-3*o+3*a,h=o;if(Oa.approximately(s,0)){if(Oa.approximately(l,0))return Oa.approximately(c,0)?[]:[-h/c].filter(i);const t=wa(c*c-4*l*h),n=2*l;return[(t-c)/n,(-c-t)/n].filter(i)}l/=s,c/=s,h/=s;const f=(3*c-l*l)/3,p=f/3,d=(2*l*l*l-9*l*c+27*h)/27,g=d/2,_=g*g+p*p*p;let y,v,m,x,b;if(_<0){const t=-f/3,n=wa(t*t*t),e=-d/(2*n),r=xa(e<-1?-1:e>1?1:e),o=2*Ma(n);return m=o*va(r/3)-l/3,x=o*va((r+za)/3)-l/3,b=o*va((r+2*za)/3)-l/3,[m,x,b].filter(i)}if(0===_)return y=g<0?Ma(-g):-Ma(g),m=2*y-l/3,x=-y-l/3,[m,x].filter(i);{const t=wa(_);return y=Ma(-g+t),v=Ma(g+t),[y-v-l/3].filter(i)}},droots:function(t){if(3===t.length){const n=t[0],e=t[1],r=t[2],i=n-2*e+r;if(0!==i){const t=-wa(e*e-n*r),o=-n+e;return[-(t+o)/i,-(-t+o)/i]}return e!==r&&0===i?[(2*e-r)/(2*(e-r))]:[]}if(2===t.length){const n=t[0],e=t[1];return n!==e?[n/(n-e)]:[]}return[]},curvature:function(t,n,e,r,i){let o,a,u,s,l=0,c=0;const h=Oa.compute(t,n),f=Oa.compute(t,e),p=h.x*h.x+h.y*h.y;if(r?(o=wa(ka(h.y*f.z-f.y*h.z,2)+ka(h.z*f.x-f.z*h.x,2)+ka(h.x*f.y-f.x*h.y,2)),a=ka(p+h.z*h.z,1.5)):(o=h.x*f.y-h.y*f.x,a=ka(p,1.5)),0===o||0===a)return{k:0,r:0};if(l=o/a,c=a/o,!i){const i=Oa.curvature(t-.001,n,e,r,!0).k,o=Oa.curvature(t+.001,n,e,r,!0).k;s=(o-l+(l-i))/2,u=(ya(o-l)+ya(l-i))/2}return{k:l,r:c,dk:s,adk:u}},inflections:function(t){if(t.length<4)return[];const n=Oa.align(t,{p1:t[0],p2:t.slice(-1)[0]}),e=n[2].x*n[1].y,r=n[3].x*n[1].y,i=n[1].x*n[2].y,o=18*(-3*e+2*r+3*i-n[3].x*n[2].y),a=18*(3*e-r-3*i),u=18*(i-e);if(Oa.approximately(o,0)){if(!Oa.approximately(a,0)){let t=-u/a;if(0<=t&&t<=1)return[t]}return[]}const s=2*o;if(Oa.approximately(s,0))return[];const l=a*a-4*o*u;if(l<0)return[];const c=Math.sqrt(l);return[(c-a)/s,-(a+c)/s].filter(function(t){return 0<=t&&t<=1})},bboxoverlap:function(t,n){const e=["x","y"],r=e.length;for(let i,o,a,u,s=0;s=u)return!1;return!0},expandbox:function(t,n){n.x.mint.x.max&&(t.x.max=n.x.max),n.y.max>t.y.max&&(t.y.max=n.y.max),n.z&&n.z.max>t.z.max&&(t.z.max=n.z.max),t.x.mid=(t.x.min+t.x.max)/2,t.y.mid=(t.y.min+t.y.max)/2,t.z&&(t.z.mid=(t.z.min+t.z.max)/2),t.x.size=t.x.max-t.x.min,t.y.size=t.y.max-t.y.min,t.z&&(t.z.size=t.z.max-t.z.min)},pairiteration:function(t,n,e){const r=t.bbox(),i=n.bbox(),o=1e5,a=e||.5;if(r.x.size+r.y.sizek||k>M)&&(w+=za),w>M&&(b=M,M=w,w=b)):M4){if(1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");r=!0}}else if(6!==i&&8!==i&&9!==i&&12!==i&&1!==arguments.length)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const o=this._3d=!r&&(9===i||12===i)||t&&t[0]&&void 0!==t[0].z,a=this.points=[];for(let t=0,e=o?3:2;tt+ja(n.y),0)0}length(){return Oa.length(this.derivative.bind(this))}static getABC(t=2,n,e,r,i=.5){const o=Oa.projectionratio(i,t),a=1-o,u={x:o*n.x+a*r.x,y:o*n.y+a*r.y},s=Oa.abcratio(i,t);return{A:{x:e.x+(e.x-u.x)/s,y:e.y+(e.y-u.y)/s},B:e,C:u,S:n,E:r}}getABC(t,n){n=n||this.get(t);let e=this.points[0],r=this.points[this.order];return qa.getABC(this.order,e,n,r,t)}getLUT(t){if(this.verify(),t=t||100,this._lut.length===t+1)return this._lut;this._lut=[],t++,this._lut=[];for(let n,e,r=0;r1?1:h,s=this.compute(h),s.t=h,s.d=l,s}get(t){return this.compute(t)}point(t){return this.points[t]}compute(t){return this.ratios?Oa.computeWithRatios(t,this.points,this.ratios,this._3d):Oa.compute(t,this.points,this._3d,this.ratios)}raise(){const t=this.points,n=[t[0]],e=t.length;for(let r,i,o=1;o1;){e=[];for(let o,a=0,u=n.length-1;a=0&&t<=1}),n=n.concat(t[e].sort(Oa.numberSort))}.bind(this)),t.values=n.sort(Oa.numberSort).filter(function(t,e){return n.indexOf(t)===e}),t}bbox(){const t=this.extrema(),n={};return this.dims.forEach(function(e){n[e]=Oa.getminmax(this,e,t[e])}.bind(this)),n}overlaps(t){const n=this.bbox(),e=t.bbox();return Oa.bboxoverlap(n,e)}offset(t,n){if(void 0!==n){const e=this.get(t),r=this.normal(t),i={c:e,n:r,x:e.x+r.x*n,y:e.y+r.y*n};return this._3d&&(i.z=e.z+r.z*n),i}if(this._linear){const n=this.normal(0),e=this.points.map(function(e){const r={x:e.x+t*n.x,y:e.y+t*n.y};return e.z&&n.z&&(r.z=e.z+t*n.z),r});return[new qa(e)]}return this.reduce().map(function(n){return n._linear?n.offset(t)[0]:n.scale(t)})}simple(){if(3===this.order){const t=Oa.angle(this.points[0],this.points[3],this.points[1]),n=Oa.angle(this.points[0],this.points[3],this.points[2]);if(t>0&&n<0||t<0&&n>0)return!1}const t=this.normal(0),n=this.normal(1);let e=t.x*n.x+t.y*n.y;return this._3d&&(e+=t.z*n.z),ja(Ua(e))(1-i/r)*n+i/r*e);return new qa(this.points.map((n,e)=>({x:n.x+t.x*i[e],y:n.y+t.y*i[e]})))}scale(t){const n=this.order;let e=!1;if("function"==typeof t&&(e=t),e&&2===n)return this.raise().scale(e);const r=this.clockwise,i=this.points;if(this._linear)return this.translate(this.normal(0),e?e(0):t,e?e(1):t);const o=e?e(0):t,a=e?e(1):t,u=[this.offset(0,10),this.offset(1,10)],s=[],l=Oa.lli4(u[0],u[0].c,u[1],u[1].c);if(!l)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(t){const e=s[t*n]=Oa.copy(i[t*n]);e.x+=(t?a:o)*u[t].n.x,e.y+=(t?a:o)*u[t].n.y}),e?([0,1].forEach(function(o){if(2!==n||!o){var a=i[o+1],u={x:a.x-l.x,y:a.y-l.y},c=e?e((o+1)/n):t;e&&!r&&(c=-c);var h=Fa(u.x*u.x+u.y*u.y);u.x/=h,u.y/=h,s[o+1]={x:a.x+c*u.x,y:a.y+c*u.y}}}),new qa(s)):([0,1].forEach(t=>{if(2===n&&t)return;const e=s[t*n],r=this.derivative(t),o={x:e.x+r.x,y:e.y+r.y};s[t+1]=Oa.lli4(e,o,l,i[t+1])}),new qa(s))}outline(t,n,e,r){if(n=void 0===n?t:n,this._linear){const i=this.normal(0),o=this.points[0],a=this.points[this.points.length-1];let u,s,l;void 0===e&&(e=t,r=n),u={x:o.x+i.x*t,y:o.y+i.y*t},l={x:a.x+i.x*e,y:a.y+i.y*e},s={x:(u.x+l.x)/2,y:(u.y+l.y)/2};const c=[u,s,l];u={x:o.x-i.x*n,y:o.y-i.y*n},l={x:a.x-i.x*r,y:a.y-i.y*r},s={x:(u.x+l.x)/2,y:(u.y+l.y)/2};const h=[l,s,u],f=Oa.makeline(h[2],c[0]),p=Oa.makeline(c[2],h[0]),d=[f,new qa(c),p,new qa(h)];return new Na(d)}const i=this.reduce(),o=i.length,a=[];let u,s=[],l=0,c=this.length();const h=void 0!==e&&void 0!==r;function f(t,n,e,r,i){return function(o){const a=r/e,u=(r+i)/e,s=n-t;return Oa.map(o,0,1,t+a*s,t+u*s)}}i.forEach(function(i){const o=i.length();h?(a.push(i.scale(f(t,e,c,l,o))),s.push(i.scale(f(-n,-r,c,l,o)))):(a.push(i.scale(t)),s.push(i.scale(-n))),l+=o}),s=s.map(function(t){return u=t.points,u[3]?t.points=[u[3],u[2],u[1],u[0]]:t.points=[u[2],u[1],u[0]],t}).reverse();const p=a[0].points[0],d=a[o-1].points[a[o-1].points.length-1],g=s[o-1].points[s[o-1].points.length-1],_=s[0].points[0],y=Oa.makeline(g,p),v=Oa.makeline(d,_),m=[y].concat(a).concat([v]).concat(s);return new Na(m)}outlineshapes(t,n,e){n=n||t;const r=this.outline(t,n).curves,i=[];for(let t=1,n=r.length;t1,o.endcap.virtual=t{var o=this.get(t);return Oa.between(o.x,n,r)&&Oa.between(o.y,e,i)})}selfintersects(t){const n=this.reduce(),e=n.length-2,r=[];for(let i,o,a,u=0;u0&&(i=i.concat(n))}),i}arcs(t){return t=t||.5,this._iterate(t,[])}_error(t,n,e,r){const i=(r-e)/4,o=this.get(e+i),a=this.get(r-i),u=Oa.dist(t,n),s=Oa.dist(t,o),l=Oa.dist(t,a);return ja(s-u)+ja(l-u)}_iterate(t,n){let e,r=0,i=1;do{e=0,i=1;let o,a,u,s,l,c=this.get(r),h=!1,f=!1,p=i,d=1;do{if(f=h,s=u,p=(r+i)/2,o=this.get(p),a=this.get(i),u=Oa.getccenter(c,o,a),u.interval={start:r,end:i},h=this._error(u,c,r,i)<=t,l=f&&!h,l||(d=i),h){if(i>=1){if(u.interval.end=d=1,s=u,i>1){let t={x:u.x+u.r*Da(u.e),y:u.y+u.r*Ia(u.e)};u.e+=Oa.angle({x:u.x,y:u.y},t,this.get(1))}break}i+=(i-r)/2}else i=p}while(!l&&e++<100);if(e>=100)break;s=s||u,n.push(s),r=d}while(i<1);return n}}function $a(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],e=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=(n instanceof Array?n.length?n:[void 0]:[n]).map(function(t){return{keyAccessor:t,isProp:!(t instanceof Function)}}),o=t.reduce(function(t,n){var r=t,o=n;return i.forEach(function(t,n){var a,u=t.keyAccessor;if(t.isProp){var s=o,l=s[u],c=function(t,n){if(null==t)return{};var e,r,i=function(t,n){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(n.includes(r))continue;e[r]=t[r]}return e}(t,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r1&&void 0!==arguments[1]?arguments[1]:1;r===i.length?Object.keys(n).forEach(function(t){return n[t]=e(n[t])}):Object.values(n).forEach(function(n){return t(n,r+1)})}(o);var a=o;return r&&(a=[],function t(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.length===i.length?a.push({keys:e,vals:n}):Object.entries(n).forEach(function(n){var r=Ba(n,2),i=r[0],o=r[1];return t(o,[].concat(Ha(e),[i]))})}(o),n instanceof Array&&0===n.length&&1===a.length&&(a[0].keys=[])),a};function Ya(t,n){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(n).domain(t)}return this}const Wa=Symbol("implicit");var Za=function(t){for(var n=t.length/6|0,e=new Array(n),r=0;rt.cooldownTicks||new Date-t.startTickTime>t.cooldownTime||t.d3AlphaMin>0&&t.forceLayout.alpha()0){var a=Math.atan2(r.y-e.y,r.x-e.x),u=i*n,s={x:(e.x+r.x)/2+u*Math.cos(a-Math.PI/2),y:(e.y+r.y)/2+u*Math.sin(a-Math.PI/2)};t.__controlPoints=[s.x,s.y]}else{var l=70*n;t.__controlPoints=[r.x,r.y-l,r.x+l,r.y]}});var f=[],p=[],d=h;if(t.linkCanvasObject){var g=[],_=[];h.forEach(function(t){return({before:f,after:p,replace:g}[a(t)]||_).push(t)}),d=[].concat(s(f),p,_),f=f.concat(g)}l.save(),f.forEach(function(n){return t.linkCanvasObject(n,l,t.globalScale)}),l.restore();var y=Ga(d,[e,r,i]);l.save(),Object.entries(y).forEach(function(n){var e=u(n,2),r=e[0],o=e[1],a=r&&"undefined"!==r?r:"rgba(0,0,0,0.15)";Object.entries(o).forEach(function(n){var e=u(n,2),r=e[0],o=e[1],h=(r||1)/t.globalScale+c;Object.entries(o).forEach(function(t){var n=u(t,2);n[0];var e=n[1],r=i(e[0]);l.beginPath(),e.forEach(function(t){var n=t.source,e=t.target;if(n&&e&&n.hasOwnProperty("x")&&e.hasOwnProperty("x")){l.moveTo(n.x,n.y);var r=t.__controlPoints;r?l[2===r.length?"quadraticCurveTo":"bezierCurveTo"].apply(l,s(r).concat([e.x,e.y])):l.lineTo(e.x,e.y)}}),l.strokeStyle=a,l.lineWidth=h,l.setLineDash(r||[]),l.stroke()})})}),l.restore(),l.save(),p.forEach(function(n){return t.linkCanvasObject(n,l,t.globalScale)}),l.restore()}(),!t.isShadow&&(n=Ir(t.linkDirectionalArrowLength),r=Ir(t.linkDirectionalArrowRelPos),i=Ir(t.linkVisibility),o=Ir(t.linkDirectionalArrowColor||t.linkColor),a=Ir(t.nodeVal),(l=t.ctx).save(),t.graphData.links.filter(i).forEach(function(i){var u=n(i);if(u&&!(u<0)){var c=i.source,h=i.target;if(c&&h&&c.hasOwnProperty("x")&&h.hasOwnProperty("x")){var f=Math.sqrt(Math.max(0,a(c)||1))*t.nodeRelSize,p=Math.sqrt(Math.max(0,a(h)||1))*t.nodeRelSize,d=Math.min(1,Math.max(0,r(i))),g=o(i)||"rgba(0,0,0,0.28)",_=u/1.6/2,y=i.__controlPoints&&e(qa,[c.x,c.y].concat(s(i.__controlPoints),[h.x,h.y])),v=y?function(t){return y.get(t)}:function(t){return{x:c.x+(h.x-c.x)*t||0,y:c.y+(h.y-c.y)*t||0}},m=y?y.length():Math.sqrt(Math.pow(h.x-c.x,2)+Math.pow(h.y-c.y,2)),x=f+u+(m-f-p-u)*d,b=v(x/m),w=v((x-u)/m),k=v((x-.8*u)/m),M=Math.atan2(b.y-w.y,b.x-w.x)-Math.PI/2;l.beginPath(),l.moveTo(b.x,b.y),l.lineTo(w.x+_*Math.cos(M),w.y+_*Math.sin(M)),l.lineTo(k.x,k.y),l.lineTo(w.x-_*Math.cos(M),w.y-_*Math.sin(M)),l.fillStyle=g,l.fill()}}}),l.restore()),!t.isShadow&&function(){var n=Ir(t.linkDirectionalParticles),r=Ir(t.linkDirectionalParticleSpeed),i=Ir(t.linkDirectionalParticleOffset),o=Ir(t.linkDirectionalParticleWidth),a=Ir(t.linkVisibility),u=Ir(t.linkDirectionalParticleColor||t.linkColor),l=t.ctx;l.save(),t.graphData.links.filter(a).forEach(function(a){var c=n(a);if(a.hasOwnProperty("__photons")&&a.__photons.length){var h=a.source,f=a.target;if(h&&f&&h.hasOwnProperty("x")&&f.hasOwnProperty("x")){var p=r(a),d=Math.abs(i(a)),g=a.__photons||[],_=Math.max(0,o(a)/2)/Math.sqrt(t.globalScale),y=u(a)||"rgba(0,0,0,0.28)";l.fillStyle=y;var v=a.__controlPoints?e(qa,[h.x,h.y].concat(s(a.__controlPoints),[f.x,f.y])):null,m=0,x=!1;g.forEach(function(n){var e=!!n.__singleHop;if(n.hasOwnProperty("__progressRatio")||(n.__progressRatio=e?p<0?1:0:(m+d)/c),!e&&m++,n.__progressRatio+=p,n.__progressRatio>=1||n.__progressRatio<0){if(e)return void(x=!0);n.__progressRatio=n.__progressRatio%1,n.__progressRatio<0&&n.__progressRatio++}var r=n.__progressRatio,i=v?v.get(r):{x:h.x+(f.x-h.x)*r||0,y:h.y+(f.y-h.y)*r||0};t.linkDirectionalParticleCanvasObject?t.linkDirectionalParticleCanvasObject(i.x,i.y,a,l,t.globalScale):(l.beginPath(),l.arc(i.x,i.y,_,0,2*Math.PI,!1),l.fill())}),x&&(a.__photons=a.__photons.filter(function(t){return!t.__singleHop||t.__progressRatio<=1&&t.__progressRatio>=0}))}}}),l.restore()}(),function(){var n=Ir(t.nodeVisibility),e=Ir(t.nodeVal),r=Ir(t.nodeColor),i=Ir(t.nodeCanvasObjectMode),o=t.ctx,a=t.isShadow/t.globalScale,u=t.graphData.nodes.filter(n);o.save(),u.forEach(function(n){var u=i(n);if(!t.nodeCanvasObject||"before"!==u&&"replace"!==u||(t.nodeCanvasObject(n,o,t.globalScale),"replace"!==u)){var s=Math.sqrt(Math.max(0,e(n)||1))*t.nodeRelSize+a;o.beginPath(),o.arc(n.x,n.y,s,0,2*Math.PI,!1),o.fillStyle=r(n)||"rgba(31, 120, 180, 0.92)",o.fill(),t.nodeCanvasObject&&"after"===u&&t.nodeCanvasObject(n,t.ctx,t.globalScale)}else o.restore()}),o.restore()}(),this},emitParticle:function(t,n){return n&&(!n.__photons&&(n.__photons=[]),n.__photons.push({__singleHop:!0})),this}},stateInit:function(){return{forceLayout:ga().force("link",sa()).force("charge",_a()).force("center",No()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(t,n){n.ctx=t},update:function(t,n){t.engineRunning=!1,t.onUpdate(),null!==t.nodeAutoColorBy&&Ka(t.graphData.nodes,Ir(t.nodeAutoColorBy),t.nodeColor),null!==t.linkAutoColorBy&&Ka(t.graphData.links,Ir(t.linkAutoColorBy),t.linkColor),t.graphData.links.forEach(function(n){n.source=n[t.linkSource],n.target=n[t.linkTarget]}),t.forceLayout.stop().alpha(1).nodes(t.graphData.nodes);var e=t.forceLayout.force("link");e&&e.id(function(n){return n[t.nodeId]}).links(t.graphData.links);var i=t.dagMode&&function(t,n){var e=t.nodes,i=t.links,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=o.nodeFilter,c=void 0===a?function(){return!0}:a,h=o.onLoopError,f=void 0===h?function(t){throw"Invalid DAG structure! Found cycle in node path: ".concat(t.join(" -> "),".")}:h,p={};e.forEach(function(t){return p[n(t)]={data:t,out:[],depth:-1,skip:!c(t)}}),i.forEach(function(t){var e=t.source,r=t.target,i=s(e),o=s(r);if(!p.hasOwnProperty(i))throw"Missing source node with id: ".concat(i);if(!p.hasOwnProperty(o))throw"Missing target node with id: ".concat(o);var a=p[i],u=p[o];function s(t){return"object"===l(t)?n(t):t}a.out.push(u)});var d=[];return function t(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=function(){var o=e[a];if(-1!==r.indexOf(o)){var u=[].concat(s(r.slice(r.indexOf(o))),[o]).map(function(t){return n(t.data)});return d.some(function(t){return t.length===u.length&&t.every(function(t,n){return t===u[n]})})||(d.push(u),f(u)),1}i>o.depth&&(o.depth=i,t(o.out,[].concat(s(r),[o]),i+(o.skip?0:1)))},a=0,u=e.length;a1&&(c.vy+=f*g),o>2&&(c.vz+=p*g)}}function c(){if(i){var n,e=i.length;for(a=new Array(e),u=new Array(e),n=0;n[1,2,3].includes(t))||2,c()},l.strength=function(t){return arguments.length?(s="function"==typeof t?t:ia(+t),c(),l):s},l.radius=function(n){return arguments.length?(t="function"==typeof n?n:ia(+n),c(),l):t},l.x=function(t){return arguments.length?(n=+t,l):n},l.y=function(t){return arguments.length?(e=+t,l):e},l.z=function(t){return arguments.length?(r=+t,l):r},l}(function(n){var e=i[n[t.nodeId]]||-1;return("radialin"===t.dagMode?o-e:e)*a}).strength(function(n){return t.dagNodeFilter(n)?1:0}):null);for(var p=0;p0&&t.forceLayout.alpha()1?r-1:0),o=1;o1&&void 0!==arguments[1]?arguments[1]:0,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,r=arguments.length,i=new Array(r>3?r-3:0),o=3;o1&&void 0!==arguments[1]?arguments[1]:function(){return!0},e=Ir(t.nodeVal),r=function(n){return Math.sqrt(Math.max(0,e(n)||1))*t.nodeRelSize},i=t.graphData.nodes.filter(n).map(function(t){return{x:t.x,y:t.y,r:r(t)}});return i.length?{x:[Je(i,function(t){return t.x-t.r}),Ke(i,function(t){return t.x+t.r})],y:[Je(i,function(t){return t.y-t.r}),Ke(i,function(t){return t.y+t.r})]}:null},pauseAnimation:function(t){return t.animationFrameRequestId&&(cancelAnimationFrame(t.animationFrameRequestId),t.animationFrameRequestId=null),this},resumeAnimation:function(t){return t.animationFrameRequestId||this._animationCycle(),this},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},au),stateInit:function(){return{lastSetZoom:1,zoom:Ye(),forceGraph:new nu,shadowGraph:(new nu).cooldownTicks(0).nodeColor("__indexColor").linkColor("__indexColor").isShadow(!0),colorTracker:new Xi,tweenGroup:new zr}},init:function(t,n){var e=this;t.innerHTML="";var r=document.createElement("div");r.classList.add("force-graph-container"),r.style.position="relative",t.appendChild(r),n.canvas=document.createElement("canvas"),n.backgroundColor&&(n.canvas.style.background=n.backgroundColor),r.appendChild(n.canvas),n.shadowCanvas=document.createElement("canvas");var i=n.canvas.getContext("2d"),o=n.shadowCanvas.getContext("2d",{willReadFrequently:!0}),u={x:-1e12,y:-1e12},s=function(){var t=null,e=window.devicePixelRatio,r=u.x>0&&u.y>0?o.getImageData(u.x*e,u.y*e,1,1):null;return r&&(t=n.colorTracker.lookup(r.data)),t};kt(n.canvas).call(function(){var t,n,e,r,i=Ut,o=Ft,a=Lt,u=qt,s={},l=zt("start","drag","end"),c=0,h=0;function f(t){t.on("mousedown.drag",p).filter(u).on("touchstart.drag",_).on("touchmove.drag",y,Pt).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(a,u){if(!r&&i.call(this,a,u)){var s=m(this,o.call(this,a,u),a,u,"mouse");s&&(kt(a.view).on("mousemove.drag",d,Ot).on("mouseup.drag",g,Ot),Tt(a.view),Nt(a),e=!1,t=a.clientX,n=a.clientY,s("start",a))}}function d(r){if(jt(r),!e){var i=r.clientX-t,o=r.clientY-n;e=i*i+o*o>h}s.mouse("drag",r)}function g(t){kt(t.view).on("mousemove.drag mouseup.drag",null),Rt(t.view,e),jt(t),s.mouse("end",t)}function _(t,n){if(i.call(this,t,n)){var e,r,a=t.changedTouches,u=o.call(this,t,n),s=a.length;for(e=0;e=Math.sqrt(function(t){let n=0;for(let e of t)(e=+e)&&(n+=e);return n}(["x","y"].map(function(n){return Math.pow(t[n]-r[n],2)})))||(n.forceGraph.d3AlphaTarget(.3).resetCountdown(),n.isPointerDragging=!0,e.__dragged=!0,n.onNodeDrag(e,a))}).on("end",function(t){var e=t.subject,r=e.__initialDragPos,i={x:e.x-r.x,y:e.y-r.y};void 0===r.fx&&(e.fx=void 0),void 0===r.fy&&(e.fy=void 0),delete e.__initialDragPos,n.forceGraph.d3AlphaTarget()&&n.forceGraph.d3AlphaTarget(0).resetCountdown(),n.canvas.classList.remove("grabbable"),n.isPointerDragging=!1,e.__dragged&&(delete e.__dragged,n.onNodeDragEnd(e,i))})),n.zoom(n.zoom.__baseElem=kt(n.canvas)),n.zoom.__baseElem.on("dblclick.zoom",null),n.zoom.filter(function(t){return!t.button&&n.enableZoomPanInteraction&&("wheel"!==t.type||Ir(n.enableZoomInteraction)(t))&&("wheel"===t.type||Ir(n.enablePanInteraction)(t))}).on("zoom",function(t){var r=t.transform;[i,o].forEach(function(t){su(t),t.translate(r.x,r.y),t.scale(r.k,r.k)}),n.isPointerDragging=!0,n.onZoom&&n.onZoom(a(a({},r),e.centerAt())),n.needsRedraw=!0}).on("end",function(t){n.isPointerDragging=!1,n.onZoomEnd&&n.onZoomEnd(a(a({},t.transform),e.centerAt()))}),uu(n),n.forceGraph.onNeedsRedraw(function(){return n.needsRedraw=!0}).onFinishUpdate(function(){Fe(n.canvas).k===n.lastSetZoom&&n.graphData.nodes.length&&(n.zoom.scaleTo(n.zoom.__baseElem,n.lastSetZoom=4/Math.cbrt(n.graphData.nodes.length)),n.needsRedraw=!0)}),n.tooltip=new Oo(r),["pointermove","pointerdown"].forEach(function(t){return r.addEventListener(t,function(e){"pointerdown"===t&&(n.isPointerPressed=!0,n.pointerDownEvent=e),!n.isPointerDragging&&"pointermove"===e.type&&n.onBackgroundClick&&(e.pressure>0||n.isPointerPressed)&&("mouse"===e.pointerType||void 0===e.movementX||[e.movementX,e.movementY].some(function(t){return Math.abs(t)>1}))&&(n.isPointerDragging=!0);var i,o,a,s=(i=r.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,a=window.pageYOffset||document.documentElement.scrollTop,{top:i.top+a,left:i.left+o});u.x=e.pageX-s.left,u.y=e.pageY-s.top},{passive:!0})}),r.addEventListener("pointerup",function(t){if(n.isPointerPressed)if(n.isPointerPressed=!1,n.isPointerDragging)n.isPointerDragging=!1;else{var e=[t,n.pointerDownEvent];requestAnimationFrame(function(){if(0===t.button)if(n.hoverObj){var r=n["on".concat(n.hoverObj.type,"Click")];r&&r.apply(void 0,[n.hoverObj.d].concat(e))}else n.onBackgroundClick&&n.onBackgroundClick.apply(n,e);if(2===t.button)if(n.hoverObj){var i=n["on".concat(n.hoverObj.type,"RightClick")];i&&i.apply(void 0,[n.hoverObj.d].concat(e))}else n.onBackgroundRightClick&&n.onBackgroundRightClick.apply(n,e)})}},{passive:!0}),r.addEventListener("contextmenu",function(t){return!(n.onBackgroundRightClick||n.onNodeRightClick||n.onLinkRightClick)||(t.preventDefault(),!1)}),n.forceGraph(i),n.shadowGraph(o);var l=function(t,n,e){var r=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return dr(e)&&(r="leading"in e?!!e.leading:r,i="trailing"in e?!!e.trailing:i),kr(t,n,{leading:r,maxWait:n,trailing:i})}(function(){lu(o,n.width,n.height),n.shadowGraph.linkWidth(function(t){return Ir(n.linkWidth)(t)+n.linkHoverPrecision});var t=Fe(n.canvas);n.shadowGraph.globalScale(t.k).tickFrame()},800);n.flushShadowCanvas=l.flush,(this._animationCycle=function t(){var e=!n.autoPauseRedraw||!!n.needsRedraw||n.forceGraph.isEngineRunning()||n.graphData.links.some(function(t){return t.__photons&&t.__photons.length});if(n.needsRedraw=!1,n.enablePointerInteraction){var r=n.isPointerDragging?null:s();if(r!==n.hoverObj){var o=n.hoverObj,a=o?o.type:null,u=r?r.type:null;if(a&&a!==u){var c=n["on".concat(a,"Hover")];c&&c(null,o.d)}if(u){var h=n["on".concat(u,"Hover")];h&&h(r.d,a===u?o.d:null)}n.tooltip.content(r&&Ir(n["".concat(r.type.toLowerCase(),"Label")])(r.d)||null),n.canvas.classList[(r&&n["on".concat(u,"Click")]||!r&&n.onBackgroundClick)&&Ir(n.showPointerCursor)(null==r?void 0:r.d)?"add":"remove"]("clickable"),n.hoverObj=r}e&&l()}if(e){lu(i,n.width,n.height);var f=Fe(n.canvas).k;n.onRenderFramePre&&n.onRenderFramePre(i,f),n.forceGraph.globalScale(f).tickFrame(),n.onRenderFramePost&&n.onRenderFramePost(i,f)}n.tweenGroup.update(),n.animationFrameRequestId=requestAnimationFrame(t)})()},update:function(t){}});return cu}); diff --git a/internal/ui/ui_test.go b/internal/ui/ui_test.go index 1a8bbe4..f49c9ac 100644 --- a/internal/ui/ui_test.go +++ b/internal/ui/ui_test.go @@ -3,6 +3,7 @@ package ui import ( "net/http" "net/http/httptest" + "regexp" "strings" "testing" ) @@ -14,37 +15,49 @@ func fetch(t *testing.T, path string) *httptest.ResponseRecorder { return recorder } -// Everything the page pulls in has to be embedded, or the view is blank on a -// machine with no network and nobody finds out until it is opened. -func TestItServesEveryAssetThePageAsksFor(t *testing.T) { +// The page is built by Vite, so the names are hashed and change every build. +// What has to hold is that whatever the page asks for is embedded beside it: +// the agent serves a machine that may have no network, and a missing chunk +// there is a blank page nobody finds out about until it is opened. +func TestEverythingThePageAsksForIsEmbeddedBesideIt(t *testing.T) { page := fetch(t, "/") if page.Code != http.StatusOK { t.Fatalf("got %d for the page, want 200", page.Code) } - body := page.Body.String() - - for _, asset := range []string{ - "styles.css", "app.js", "icons.js", "graph.js", - "vendor/force-graph.min.js", "favicon.svg", - } { - if !strings.Contains(body, asset) { - t.Errorf("the page does not ask for %s", asset) - continue - } - if response := fetch(t, "/"+asset); response.Code != http.StatusOK { + + referenced := regexp.MustCompile(`(?:src|href)="\.?(/?assets/[^"]+|/?favicon\.svg)"`). + FindAllStringSubmatch(page.Body.String(), -1) + if len(referenced) < 2 { + t.Fatalf("the page asks for almost nothing, which means it did not build:\n%s", page.Body.String()) + } + + for _, match := range referenced { + asset := "/" + strings.TrimPrefix(match[1], "/") + if response := fetch(t, asset); response.Code != http.StatusOK { t.Errorf("got %d for %s, want 200", response.Code, asset) } } } -func TestTheGraphLibraryIsWholeRatherThanAStub(t *testing.T) { - response := fetch(t, "/vendor/force-graph.min.js") +func TestTheBuildCarriesItsOwnGraphLibraries(t *testing.T) { + page := fetch(t, "/") + entry := regexp.MustCompile(`src="\.?(/?assets/index-[^"]+\.js)"`). + FindStringSubmatch(page.Body.String()) + if entry == nil { + t.Fatal("the page has no entry script") + } - if response.Body.Len() < 100_000 { - t.Errorf("got %d bytes, want the whole library", response.Body.Len()) + body := fetch(t, "/"+strings.TrimPrefix(entry[1], "/")).Body.String() + + // Both renderers are pulled in dynamically, so the entry names their chunks + // rather than containing them. Either way nothing is fetched from a CDN. + for _, want := range []string{"force-graph", "3d-force-graph"} { + if !strings.Contains(body, want) { + t.Errorf("the entry script never reaches %s", want) + } } - if !strings.Contains(response.Body.String(), "ForceGraph") { - t.Error("the vendored file does not define ForceGraph") + if strings.Contains(body, "https://cdn") || strings.Contains(body, "unpkg.com") { + t.Error("the page fetches something from a CDN, which a machine with no network cannot") } } diff --git a/ui/index.html b/ui/index.html new file mode 100644 index 0000000..8fef4b4 --- /dev/null +++ b/ui/index.html @@ -0,0 +1,13 @@ + + + + + + + SourceAnt + + +
+ + + diff --git a/ui/package-lock.json b/ui/package-lock.json new file mode 100644 index 0000000..b08147d --- /dev/null +++ b/ui/package-lock.json @@ -0,0 +1,3466 @@ +{ + "name": "sourceant-agent-ui", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "sourceant-agent-ui", + "version": "0.1.0", + "dependencies": { + "@dicebear/collection": "^9.2.2", + "@dicebear/core": "^9.2.2", + "3d-force-graph": "^1.80.0", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "force-graph": "^1.51.4", + "lucide-vue-next": "^0.563.0", + "tailwind-merge": "^3.4.0", + "three-spritetext": "^1.10.0", + "vue": "^3.5.13", + "vue-router": "^4.5.0" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.2.1", + "autoprefixer": "^10.4.24", + "postcss": "^8.4.49", + "tailwindcss": "^3.4.17", + "vite": "^6.0.7" + } + }, + "node_modules/@alloc/quick-lru": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", + "integrity": "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@dicebear/adventurer": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/adventurer/-/adventurer-9.4.2.tgz", + "integrity": "sha512-jqYp834ZmGDA9HBBDQAdgF1O2UTCwHF4vVrktXWa2Dppp1JczPL5HnVOWsjtrLmXNn61Wd6OLmBb2e6rhzp3ig==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/adventurer-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/adventurer-neutral/-/adventurer-neutral-9.4.2.tgz", + "integrity": "sha512-5xgkG/mNL4j3Q4SJGQLBU/KnU90tng8Ze5ofThD+55wi0oeY/nSAUowg6UFCmHrktjifj/MEx3CQqbpcPWtfIA==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/avataaars": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/avataaars/-/avataaars-9.4.2.tgz", + "integrity": "sha512-3x9jKFkOkFSPmpTbt9xvhiU2E1GX7beCSsX0tXRUShj8x6+5Ks9yBRT1VlkySbnXrZ/GglADGg7vJ/D2uIx1Yw==", + "license": "See LICENSE file", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/avataaars-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/avataaars-neutral/-/avataaars-neutral-9.4.2.tgz", + "integrity": "sha512-/eNrp0YCNJRwQXqOloLm1+3Ss2C+pMpUQIGkbEnGsP1UK+13Ge80ggDDof1HpdqvG9HAZcKa7hnbG/0HSwyDSw==", + "license": "See LICENSE file", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/big-ears": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/big-ears/-/big-ears-9.4.2.tgz", + "integrity": "sha512-mNfz3ppNA7UBq0IO3nXCiV5pFPG7c1DfzRB0foNU2Wo1XXT8FIcSY2BvDlYqorZTOUOz7dHb0vx06hqvG0HP5w==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/big-ears-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/big-ears-neutral/-/big-ears-neutral-9.4.2.tgz", + "integrity": "sha512-M8Ozmzza4eY4hpLOYULgJxMYmBA0CsBnrE15/xw6LZkEREXnrX5z0NJsf8hUfdyF6BWZ+RBgzoiav32DAC5zcg==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/big-smile": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/big-smile/-/big-smile-9.4.2.tgz", + "integrity": "sha512-hmT5i7rcPPhStjZyg28pbIhdTnnMBzK3RObI0vKCpY30EFrzaPkkdDL6Ck5fAFBdvDIW1EpOJkenyR0XPmhgbQ==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/bottts": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/bottts/-/bottts-9.4.2.tgz", + "integrity": "sha512-tsx+dII7EFUCVA8URj66G1GqORCCVduCAx4dY2prEY2IeFianVpkntXuFsWZ9BBGx1NZFndvDith5oTwKMQPbQ==", + "license": "See LICENSE file", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/bottts-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/bottts-neutral/-/bottts-neutral-9.4.2.tgz", + "integrity": "sha512-kFNwWt6j+gzZ5n5Pz7WVwePubREAQOF8ZwWA9ztwVYDVMLnOChWbAofy5FED4j5md2MXFH2EgLCFCMr5K2BmIA==", + "license": "See LICENSE file", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/collection": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/collection/-/collection-9.4.2.tgz", + "integrity": "sha512-KArubv7if8H7j9sIfpDK2hJJqrdNVR5zMPAMOSpIU2JPyXx8TC9o5wsmXb8il5wOHgaS9Q/cla7jUNIiDD7Gsg==", + "license": "MIT", + "dependencies": { + "@dicebear/adventurer": "9.4.2", + "@dicebear/adventurer-neutral": "9.4.2", + "@dicebear/avataaars": "9.4.2", + "@dicebear/avataaars-neutral": "9.4.2", + "@dicebear/big-ears": "9.4.2", + "@dicebear/big-ears-neutral": "9.4.2", + "@dicebear/big-smile": "9.4.2", + "@dicebear/bottts": "9.4.2", + "@dicebear/bottts-neutral": "9.4.2", + "@dicebear/croodles": "9.4.2", + "@dicebear/croodles-neutral": "9.4.2", + "@dicebear/dylan": "9.4.2", + "@dicebear/fun-emoji": "9.4.2", + "@dicebear/glass": "9.4.2", + "@dicebear/icons": "9.4.2", + "@dicebear/identicon": "9.4.2", + "@dicebear/initials": "9.4.2", + "@dicebear/lorelei": "9.4.2", + "@dicebear/lorelei-neutral": "9.4.2", + "@dicebear/micah": "9.4.2", + "@dicebear/miniavs": "9.4.2", + "@dicebear/notionists": "9.4.2", + "@dicebear/notionists-neutral": "9.4.2", + "@dicebear/open-peeps": "9.4.2", + "@dicebear/personas": "9.4.2", + "@dicebear/pixel-art": "9.4.2", + "@dicebear/pixel-art-neutral": "9.4.2", + "@dicebear/rings": "9.4.2", + "@dicebear/shapes": "9.4.2", + "@dicebear/thumbs": "9.4.2", + "@dicebear/toon-head": "9.4.2" + }, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/core": { + "version": "9.4.3", + "resolved": "https://registry.npmjs.org/@dicebear/core/-/core-9.4.3.tgz", + "integrity": "sha512-9ITrQI57k3p5hKuU8HZJ1d0kPdrmTKEJDOdlKQ8CpaChbtmnD1R+dtWmNz5IesYThXM8F64pJ0ZvJ2rsY8Hciw==", + "license": "MIT", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@dicebear/croodles": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/croodles/-/croodles-9.4.2.tgz", + "integrity": "sha512-6VoO0JviIf7dKKMBTL/SMXxWhnXHaZuzufX90G0nXxS77ELG1YkGNMaZzawizN4C09Gbya2gJkozqrWiJN/aGw==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/croodles-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/croodles-neutral/-/croodles-neutral-9.4.2.tgz", + "integrity": "sha512-oG5IeUdtiYshQ89gkAVcl5w3xAEi5UZX2fTzIyelpBPCG176l7VuuFzlxi2umnB3E6LVHYy06DXvUo/p+rXB2Q==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/dylan": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/dylan/-/dylan-9.4.2.tgz", + "integrity": "sha512-1vQvRu9x9DrwFxhFaIU2rf0EUL04yDTbAt7fHyAjM0mEsKzTD4mRNf95tCRuavCoW6W48u7A/OY6jyIub6kxLQ==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/fun-emoji": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/fun-emoji/-/fun-emoji-9.4.2.tgz", + "integrity": "sha512-kqB6LPkdYCdEU/mwbyz34xLzoNUKL6ARcoo3fr5ASq9D6ZE07qIKybC3xv5+CPz7VmspJ1Q3c/VVWVMDRP7Twg==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/glass": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/glass/-/glass-9.4.2.tgz", + "integrity": "sha512-z5qUogHQ1b6UJ2zCqT848mU2U9DKbVDhiX6GPDjD7tYLisCCJVisH9p6WyNdHvflUd4SHkA6gRqVJIh2v2HnTA==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/icons": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/icons/-/icons-9.4.2.tgz", + "integrity": "sha512-QSMMz0NA03ypSGhXC8HQX8FSj8lYT+/5yqH+/N03OH2IjL0q7wwGZ7nqsrtlRp76O5WqMTwGfSbTUUYPjFr+Xw==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/identicon": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/identicon/-/identicon-9.4.2.tgz", + "integrity": "sha512-JVDSmZsv11mSWqwAktK5x9Bslht2xY3TFUn8xzu6slAYe1Z7hEXZ76eb+UJ6F4qEzdwZ7xPWzAS6Nb0Y3A0pww==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/initials": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/initials/-/initials-9.4.2.tgz", + "integrity": "sha512-yePuIUasmwtl9IrtB6rEzE/zb5fImKP/neW0CdcTC2MwLgMuP1GLHEGRgg1zI8exIh+PMv1YdLGyyUuRTE2Qpw==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/lorelei": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/lorelei/-/lorelei-9.4.2.tgz", + "integrity": "sha512-YMv6vnriW6VLFDsreKuOnUFFno6SRe7+7X7R7zPY0rZ+MaHX9V3jcioIG+1PSjIHEDfOLUHpr5vd1JBWv8y7UA==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/lorelei-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/lorelei-neutral/-/lorelei-neutral-9.4.2.tgz", + "integrity": "sha512-yspanTthA5vh6iCdeLzn6xZ4yYMYRcfcxblcgSvHTF1ut0bjAXtw5SXzZ6aJTrJWiHkzYOQuTOR6GVYiW80Q7w==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/micah": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/micah/-/micah-9.4.2.tgz", + "integrity": "sha512-e4D3W/OlChSsLo7Llwsy0J18vk0azJqF/uFoY+EKACCNHBc1HGNsqVvu2CTf+OWOA8wTyAK6UkjBN5p01r7D+g==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/miniavs": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/miniavs/-/miniavs-9.4.2.tgz", + "integrity": "sha512-wLwyFNNUnDRd3BbhSBhXR0XEpX8sG0/xDA5M/OkDoapLqZnnI48YLUSDd2N5QTAVMmcSEuZOYxkcnj7WW79vlg==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/notionists": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/notionists/-/notionists-9.4.2.tgz", + "integrity": "sha512-ZCySq+nxcD/x4xyYgytcj2N9uY3gxrL+qpnmOdp2BdA221KacVrxlsUPpIgEMqxS2rMmBQXfxg129Pzn4ycIpA==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/notionists-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/notionists-neutral/-/notionists-neutral-9.4.2.tgz", + "integrity": "sha512-AyD9kEfVxQUwDGf4Op059gVmYIOAkTKg3dtE9h9mEKP7zl/kMy5B67BFFOo7sB0mXCjzAegZ6ekGU02E8+hIHw==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/open-peeps": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/open-peeps/-/open-peeps-9.4.2.tgz", + "integrity": "sha512-i01tLgtp2g937T81sVeAOVlqsCtiTck/Kw20g7hN80+7xrXjOUepz2HPLy3HeiMjwjMGRy5o54kSd0/8Ht4Dqg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/personas": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/personas/-/personas-9.4.2.tgz", + "integrity": "sha512-NJlkvI5F5gugt6t2+7QrYNTwQC7+4IQZS3vG0dYk2BncxOHax0BuLovdSdiAesTL4ZkytFYIydWmKmV2/xcUwg==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/pixel-art": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/pixel-art/-/pixel-art-9.4.2.tgz", + "integrity": "sha512-peHf7oKICDgBZ8dUyj+txPnS7VZEWgvKE+xW4mNQqBt6dYZIjmva2shOVHn0b1JU+FDxMx3uIkWVixKdUq4WGg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/pixel-art-neutral": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/pixel-art-neutral/-/pixel-art-neutral-9.4.2.tgz", + "integrity": "sha512-9e9Lz554uQvWaXV2P17ss+hPa6rTyuAKBtB8zk8ECjHiZzIl61N/KcTVLZ4dILVZwj7gYriaLo16QEqvL2GJCg==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/rings": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/rings/-/rings-9.4.2.tgz", + "integrity": "sha512-Pc3ymWrRDQPJFNrbbLt7RJrzGvUuuxUiDkrfLhoVE+B6mZWEL1PC78DPbS1yUWYLErJOpJuM2GSwXmTbVjWf+g==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/shapes": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/shapes/-/shapes-9.4.2.tgz", + "integrity": "sha512-AFL6jAaiLztvcqyq+ds+lWZu6Vbp3PlGWhJeJRm842jxtiluJpl6r4f6nUXP2fdMz7MNpDzXfLooQK9E04NbUQ==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/thumbs": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/thumbs/-/thumbs-9.4.2.tgz", + "integrity": "sha512-ccWvDBqbkWS5uzHbsg5L6uML6vBfX7jT3J3jHCQksvz8haHItxTK02w+6e1UavZUsvza4lG5X/XY3eji3siJ4Q==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@dicebear/toon-head": { + "version": "9.4.2", + "resolved": "https://registry.npmjs.org/@dicebear/toon-head/-/toon-head-9.4.2.tgz", + "integrity": "sha512-lwFeSXyAnaKnCfMt9TiJwnD1cXQUGkey/0h6i/+4TVHVMCz5/Ri5u1ynovPNHy1SnBf858QwoXHkxilGLwQX/g==", + "license": "(MIT AND CC-BY-4.0)", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "@dicebear/core": "^9.0.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.1.tgz", + "integrity": "sha512-UZ8sUxPTiHWYX9QNdJedb1kDZSpS1t/VPWBWGSgqHNi9w3Cu6IXvu2mzbhiTiPvtrqgTQJ+zqiAq2iPIPilpaQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.1.tgz", + "integrity": "sha512-cQ4nFQABN5cDvDpbvJ7bMStCpnaVxynZrRMfUJYgxcIk9Sh54FIO1vtfkg0B69REjER77ioZ/ov+eAApx/KmLQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.1.tgz", + "integrity": "sha512-FQNqd1lRy/0QhDk3xeRIkSBiCpXCiDnZO3YLVdcDKN1UBiKToNftCzcXYNLshmPDUMlu2TdeS8tGcsU6f3YF1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.1.tgz", + "integrity": "sha512-pvD16V939D3CloK0+qikpGaxiPrDUXTe7Y5cWOMkMSy7m1cawa8EGy/kXYi/G/cKAC4HDAbSnzCIk1WmsoOKXg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.1.tgz", + "integrity": "sha512-pcFGeL2345VwdTnJhA6zLbew+YgWB0qBG2+dMtXjCicf6+rm6kO6cOoh5VnTe0ZMrMRgRyuHmCJxZWrIdzYuOw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.1.tgz", + "integrity": "sha512-mRJlqSRulVzcKq/LKA6ICSIc3K/l4fzlVn/gePn2nXIHy8seRi5z/eeRE0d/XMBxcMldiXtQTSpRj0tkkC3g8Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.1.tgz", + "integrity": "sha512-YDUNvVM85TI3g/1OpnqKP1h4NeW/j64DfWMf+G3M809xNk1bJSnpFp4sh83NpmVE5DXnkh8ULor4LTVZKoYLHw==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.1.tgz", + "integrity": "sha512-7Mcn71p9ZuQFAj+h+dhQXy/yeLePRS2yKRnmW1DijA9thKO5qap0GNOIQK4yQ6iP3SU0Mrb/yWo8h8vgRba8lw==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.1.tgz", + "integrity": "sha512-4YiLQTX6U4CSl0L9cluep9A9W6UmTfqBDc2/CH6wlu54pl4E7Jn3cOD8oxzvBDEGk/JMKgJ47C8g+radF7mwvg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.1.tgz", + "integrity": "sha512-2ra8F7w8OquwZN9z2/fKFnli69wa8PLwaVzRMIPGb13ByMJwC28Fbp8YcVGoUhlYMTt7j5j9bNgpysrN2UM+vw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.1.tgz", + "integrity": "sha512-Sy20ncyhjmBP0Ml+UvQbimjlk6VFgjW5uNP+qqwHB00mTE8Bl2C1TuHTlRwK2YoXeZbee5lP2XevBWVkAQAtSQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.1.tgz", + "integrity": "sha512-noITLp8oNjYliPnGWmLyelIHwULGqbHloQHGw1rtxbWhTuWooRpnZarZQJ1y9EUC4szuCusCc+HEpUtxpIwYvA==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.1.tgz", + "integrity": "sha512-hlxxXd+F1mWiAcaFR7Sv9ZQT6m6UfI8+Vy/kFJzztq2pDMU/0wZ9sish0iszNZvsQDo8Gc0i5yuFEOz5dDf6fA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.1.tgz", + "integrity": "sha512-EF7OpqQTQ/BvGqLzUi4rEHuagCV9MugAUXSHemwPW5vxZ75RR+jxO/2j95Ph2dalMpFHSVECjRoioHZgA9zOYA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.1.tgz", + "integrity": "sha512-wQO3JesW9PRkwlabQ27y7sPfVOOTLRG73I4F2UYHG5PXun3J9U3y+b7ezVKSYbsvSKGQ1k1cq8Qlun4C9kLt3w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.1.tgz", + "integrity": "sha512-ouAGwhO6wHRXdnOVCOsB0tRFkA7nhNB2Nwax6oECXN0YiN8EYUTBAOudADOB1PI+yDL61TeNx/u7MVCzksNbkQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.1.tgz", + "integrity": "sha512-q2R38Sn+1J8RxhfJ+T54wSWmyKXWec+9jgDfqO2AtArEqHO5R2aeayp5H5OYLr5UYDVGsVaZPEFUooMhYCdz5A==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.1.tgz", + "integrity": "sha512-gfI5T24WLLuFfSKw7Go/zDXjAAV0fny0swTaDv+WjK7vqcw4cRhFfdsyKL1n+ukI+ooBxn3bVQnyrn06WpI50w==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.1.tgz", + "integrity": "sha512-4h6XqthmB4Hspji84wvgk+ElodTsGj+dbZqHJHHtKxj4mYq0ANSEEPX9ys3moJueqsRjwpaJYH7874Itwnj2ow==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.1.tgz", + "integrity": "sha512-dlfCOa87o1VAYegLQ9EKilx2JCeRofiyPGhTCmqnuXZ6bMPiycO1rq1+sKoulAp7pGLIsTIw+1x5R+zgh5LhhA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.1.tgz", + "integrity": "sha512-cjkLbOlfcm3QGhMM1J5zaZjsw1GggbN6rw9UTSSRrPrR1KkcXnN7Uq9rPw34xImQ9VOY9GN+6u2Zj80B9ptkcw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.1.tgz", + "integrity": "sha512-Li1KdUnWGE4N3e1F/B4RTB1ms+nG4WBgjByO46pkeBVX/2UBsY53xf5vK9WygVmnH3RwncIST7lkSdLSY6P9lg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.1.tgz", + "integrity": "sha512-t4ZYOSoLTgwhuFMrmTMLx/+i1DQVK7HYqMc6kY46EApwi8X0nIVphzdNoThU3xt6n+N5urG1/gxBdCaKDLavfg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.1.tgz", + "integrity": "sha512-RgroPfMmKlD1RzSDxvwgcPiy2HNQKoYV7OmwIXDsk73uKW5t6B/V8KIy27SMv/FNXFo/oSBtWc9J0X7t91ezZg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.1.tgz", + "integrity": "sha512-at8QVep6S3h5Y6gSbdGU06bRY5WJkf6WUduM9YtvYMbYhB1MOFfUgc6kehitQXzOtMSaT70q7f9ydPhpqu821w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@tweenjs/tween.js": { + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-25.0.0.tgz", + "integrity": "sha512-XKLA6syeBUaPzx4j3qwMqzzq+V4uo72BnlbOjmuljLrRqdsd3qnzvZZoxvMHZ23ndsRS4aufU6JOZYpCbU6T1A==", + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "license": "MIT" + }, + "node_modules/@vitejs/plugin-vue": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.2.4.tgz", + "integrity": "sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "vite": "^5.0.0 || ^6.0.0", + "vue": "^3.2.25" + } + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.42.tgz", + "integrity": "sha512-2Ye1ilMtKXxl8qZUrQ5j0CdgenFp/HFQmta6rfRyfEsTG69L6Wk+tWuNoHYHMx9E8tF2Slvdg1FuwDvAXdy1LQ==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@vue/shared": "3.5.42", + "entities": "^7.0.1", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.42.tgz", + "integrity": "sha512-qbhQZEFmycr+ni/qyuccS4sucNN7VAbDfbkvNxWOX2VfgFm90MNs3/UhRNKoPMEIVn0F8gdlYjLPvqxHwHeQOA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-core": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.42.tgz", + "integrity": "sha512-fkCAFB4okcAANGMThboWnScp/gzWjU0ZSkVnjTIiplmMDq2uq0tIB3j+xVu4rhv5rvOgBySCysudmbMd6xRRqw==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@vue/compiler-core": "3.5.42", + "@vue/compiler-dom": "3.5.42", + "@vue/compiler-ssr": "3.5.42", + "@vue/shared": "3.5.42", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.21", + "postcss": "^8.5.19", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.42.tgz", + "integrity": "sha512-xmLk3wLkbizPAiLyomjgFFosf2ys9b5Ghb+oh/k2tnvipNz8OFrQOiTcWCzyK7MpBp9KkyGtfvgfLUivbmuGYA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/devtools-api": { + "version": "6.6.4", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz", + "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==", + "license": "MIT" + }, + "node_modules/@vue/reactivity": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.42.tgz", + "integrity": "sha512-TzNNfKpb7hDxbQltwAut8VDQA5YP+BuRlxntHUuRjyKwlMvmAPbs3unhCvieijifY6vFfVBwsS7wG/C7uq+bEQ==", + "license": "MIT", + "dependencies": { + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.42.tgz", + "integrity": "sha512-9uACtuHs7vJGkm5Bp3xu4xRDLFTIYy5DgxpToVjqGIAhAEKwQfsaLvKINhM6nFVp6bZPRFGdDqd1g52MqKsotA==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.42.tgz", + "integrity": "sha512-rsCmhiWLaRxGltLwhlCWyYkFn7WAbKRh0q17eZ1A6Dq6eqc2ACQ61IIryxz0LrsvCzHSilLA9JHovVwM8CNE2g==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.42", + "@vue/runtime-core": "3.5.42", + "@vue/shared": "3.5.42", + "csstype": "^3.2.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.42.tgz", + "integrity": "sha512-2++5dUyYS4gvo7xQXSECUDhB7TS0aOl5SeVfC5qSq1Jgfhjvegw1zqhwTIR3imZ+QYPJQw9gfcFvXGAjGZ7ajQ==", + "license": "MIT", + "dependencies": { + "@vue/compiler-ssr": "3.5.42", + "@vue/runtime-dom": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.42.tgz", + "integrity": "sha512-2rPxex1jQf4jvl9MOHl6YaXCPcrNqz/FstMOEh3QWY+/OME9nQTvl9WYeCwhW7AFjaR0SnngZGlp/wkR6rkI6g==", + "license": "MIT" + }, + "node_modules/3d-force-graph": { + "version": "1.80.0", + "resolved": "https://registry.npmjs.org/3d-force-graph/-/3d-force-graph-1.80.0.tgz", + "integrity": "sha512-tzI353gW1nXPpnC7VTa3JjMg+3cp77qOLUFO0vucPTfF+q5R6sQsNsIqVTbRIb7RSypn14nBa4yfkOe9ThxASw==", + "license": "MIT", + "dependencies": { + "accessor-fn": "1", + "kapsule": "^1.16", + "three": ">=0.179 <1", + "three-forcegraph": "1", + "three-render-objects": "^1.41" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/accessor-fn": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/accessor-fn/-/accessor-fn-1.5.3.tgz", + "integrity": "sha512-rkAofCwe/FvYFUlMB0v0gWmhqtfAtV1IUkdPbfhTUyYniu5LrC0A0UJkTH0Jv3S8SvwkmfuAlY+mQIJATdocMA==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true, + "license": "MIT" + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", + "dev": true, + "license": "MIT" + }, + "node_modules/autoprefixer": { + "version": "10.5.4", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.5.4.tgz", + "integrity": "sha512-MaU0U/za7N3r6brxD4YB/l4NSrFzLPlANv6wEuQVaIPlD3L4W9rFcQPbL/EilY9BHhHvhfcz3gInDLrEtWT4EA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/autoprefixer" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "browserslist": "^4.28.6", + "caniuse-lite": "^1.0.30001806", + "fraction.js": "^5.3.4", + "picocolors": "^1.1.1", + "postcss-value-parser": "^4.2.0" + }, + "bin": { + "autoprefixer": "bin/autoprefixer" + }, + "engines": { + "node": "^10 || ^12 || >=14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.20", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.20.tgz", + "integrity": "sha512-H0ulySigv6icDJ1F7SjtdCD6PrhTpdYCmP0CactWy1+ekh0AFd0o1Wn5T8b+hnTmdBx19u9yhL6wvCylXMY7zw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/bezier-js": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/bezier-js/-/bezier-js-6.1.4.tgz", + "integrity": "sha512-PA0FW9ZpcHbojUCMu28z9Vg/fNkwTj5YhusSAjHHDfHDGLxJ6YUKrAN2vk1fP2MMOxVw4Oko16FMlRGVBGqLKg==", + "license": "MIT", + "funding": { + "type": "individual", + "url": "https://github.com/Pomax/bezierjs/blob/master/FUNDING.md" + } + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.28.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz", + "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.12", + "caniuse-lite": "^1.0.30001809", + "electron-to-chromium": "^1.5.402", + "node-releases": "^2.0.53", + "update-browserslist-db": "^1.3.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/camelcase-css": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", + "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001810", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/canvas-color-tracker": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/canvas-color-tracker/-/canvas-color-tracker-1.3.2.tgz", + "integrity": "sha512-ryQkDX26yJ3CXzb3hxUVNlg1NKE4REc5crLBq661Nxzr8TNd236SaEf2ffYLXyI5tSABSeguHLqcVq4vf9L3Zg==", + "license": "MIT", + "dependencies": { + "tinycolor2": "^1.6.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/class-variance-authority": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz", + "integrity": "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==", + "license": "Apache-2.0", + "dependencies": { + "clsx": "^2.1.1" + }, + "funding": { + "url": "https://polar.sh/cva" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "license": "MIT", + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "license": "MIT" + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-binarytree": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/d3-binarytree/-/d3-binarytree-1.0.2.tgz", + "integrity": "sha512-cElUNH+sHu95L04m92pG73t2MEJXKu+GeKUN1TJkFsu93E5W8E9Sc3kHEGJKgenGvj19m6upSn2EunvMgMD2Yw==", + "license": "MIT" + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-force-3d": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/d3-force-3d/-/d3-force-3d-3.0.6.tgz", + "integrity": "sha512-4tsKHUPLOVkyfEffZo1v6sFHvGFwAIIjt/W8IThbp08DYAsXZck+2pSHEG5W1+gQgEvFLdZkYvmJAbRM2EzMnA==", + "license": "MIT", + "dependencies": { + "d3-binarytree": "1", + "d3-dispatch": "1 - 3", + "d3-octree": "1", + "d3-quadtree": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.2.tgz", + "integrity": "sha512-AJDdYOdnyRDV5b6ArilzCPPwc1ejkHcoyFarqlPqT7zRYjhavcT3uSrqcMvsgh2CgoPbK3RCwyHaVyxYcP2Arg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-octree": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/d3-octree/-/d3-octree-1.1.0.tgz", + "integrity": "sha512-F8gPlqpP+HwRPMO/8uOu5wjH110+6q4cgJvgJT6vlpy3BEaDIKlTZrgHKZSp/i1InRpVfh4puY/kvL6MxK930A==", + "license": "MIT" + }, + "node_modules/d3-quadtree": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz", + "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/data-bind-mapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/data-bind-mapper/-/data-bind-mapper-1.0.3.tgz", + "integrity": "sha512-QmU3lyEnbENQPo0M1F9BMu4s6cqNNp8iJA+b/HP2sSb7pf3dxwF3+EP1eO69rwBfH9kFJ1apmzrtogAmVt2/Xw==", + "license": "MIT", + "dependencies": { + "accessor-fn": "1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", + "dev": true, + "license": "MIT" + }, + "node_modules/electron-to-chromium": { + "version": "1.5.416", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.416.tgz", + "integrity": "sha512-K6bvB2BjnNrugtIih6ewlbBI9DXa976jIdiIlRLHhBoEI9a4JaQjjHyF+A1IQI543aQYR4LnmOrT/K5fZj0aPA==", + "dev": true, + "license": "ISC" + }, + "node_modules/entities": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", + "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fastq": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.2.tgz", + "integrity": "sha512-UpGiiODyCGprM8EPP6JodP6jC9Rws6TCuiDOD+nn0CJhR8guI3g/ozo4ugL0vJ+Yz1UtJuuRPqvQuybVOF1VQA==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/float-tooltip": { + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/float-tooltip/-/float-tooltip-1.7.5.tgz", + "integrity": "sha512-/kXzuDnnBqyyWyhDMH7+PfP8J/oXiAavGzcRxASOMRHFuReDtofizLLJsf7nnDLAfEaMW4pVWaXrAjtnglpEkg==", + "license": "MIT", + "dependencies": { + "d3-selection": "2 - 3", + "kapsule": "^1.16", + "preact": "10" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/force-graph": { + "version": "1.51.4", + "resolved": "https://registry.npmjs.org/force-graph/-/force-graph-1.51.4.tgz", + "integrity": "sha512-TdJ2KbkoiDQ7NIRx8IPGD0mAXXpLhamS7c+b7W98b0MHG7lphnda1VOQX/98UDTsttIAdH4TcP0l0MauSnLK8w==", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "bezier-js": "3 - 6", + "canvas-color-tracker": "^1.3", + "d3-array": "1 - 3", + "d3-drag": "2 - 3", + "d3-force-3d": "2 - 3", + "d3-scale": "1 - 4", + "d3-scale-chromatic": "1 - 3", + "d3-selection": "2 - 3", + "d3-zoom": "2 - 3", + "float-tooltip": "^1.7", + "index-array-by": "1", + "kapsule": "^1.16", + "lodash-es": "4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fraction.js": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-5.3.4.tgz", + "integrity": "sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/rawify" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/index-array-by": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/index-array-by/-/index-array-by-1.4.2.tgz", + "integrity": "sha512-SP23P27OUKzXWEC/TOyWlwLviofQkCSCKONnc62eItjp69yCZZPqDQtr3Pw5gJDnPeUMqExmKydNZaJO0FU9pw==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz", + "integrity": "sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/jiti": { + "version": "1.21.7", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz", + "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "bin/jiti.js" + } + }, + "node_modules/kapsule": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/kapsule/-/kapsule-1.16.3.tgz", + "integrity": "sha512-4+5mNNf4vZDSwPhKprKwz3330iisPrb08JyMgbsdFrimBCKNHecua/WBwvVg3n7vwx0C1ARjfhwIpbrbd9n5wg==", + "license": "MIT", + "dependencies": { + "lodash-es": "4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/lilconfig": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", + "integrity": "sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash-es": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz", + "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==", + "license": "MIT" + }, + "node_modules/lucide-vue-next": { + "version": "0.563.0", + "resolved": "https://registry.npmjs.org/lucide-vue-next/-/lucide-vue-next-0.563.0.tgz", + "integrity": "sha512-zsE/lCKtmaa7bGfhSpN84br1K9YoQ5pCN+2oKWjQQG3Lo6ufUUKBuHSjNFI6RvUevxaajNXb8XwFUKeTXG3sIA==", + "deprecated": "Package deprecated. Please use @lucide/vue instead.", + "license": "ISC", + "peerDependencies": { + "vue": ">=3.0.1" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.18", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz", + "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/ngraph.events": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ngraph.events/-/ngraph.events-1.4.0.tgz", + "integrity": "sha512-NeDGI4DSyjBNBRtA86222JoYietsmCXbs8CEB0dZ51Xeh4lhVl1y3wpWLumczvnha8sFQIW4E0vvVWwgmX2mGw==", + "license": "BSD-3-Clause" + }, + "node_modules/ngraph.forcelayout": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ngraph.forcelayout/-/ngraph.forcelayout-3.3.1.tgz", + "integrity": "sha512-MKBuEh1wujyQHFTW57y5vd/uuEOK0XfXYxm3lC7kktjJLRdt/KEKEknyOlc6tjXflqBKEuYBBcu7Ax5VY+S6aw==", + "license": "BSD-3-Clause", + "dependencies": { + "ngraph.events": "^1.0.0", + "ngraph.merge": "^1.0.0", + "ngraph.random": "^1.0.0" + } + }, + "node_modules/ngraph.graph": { + "version": "20.1.2", + "resolved": "https://registry.npmjs.org/ngraph.graph/-/ngraph.graph-20.1.2.tgz", + "integrity": "sha512-W/G3GBR3Y5UxMLHTUCPP9v+pbtpzwuAEIqP5oZV+9IwgxAIEZwh+Foc60iPc1idlnK7Zxu0p3puxAyNmDvBd0Q==", + "license": "BSD-3-Clause", + "dependencies": { + "ngraph.events": "^1.4.0" + } + }, + "node_modules/ngraph.merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ngraph.merge/-/ngraph.merge-1.0.0.tgz", + "integrity": "sha512-5J8YjGITUJeapsomtTALYsw7rFveYkM+lBj3QiYZ79EymQcuri65Nw3knQtFxQBU1r5iOaVRXrSwMENUPK62Vg==", + "license": "MIT" + }, + "node_modules/ngraph.random": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ngraph.random/-/ngraph.random-1.2.0.tgz", + "integrity": "sha512-4EUeAGbB2HWX9njd6bP6tciN6ByJfoaAvmVL9QTaZSeXrW46eNGA9GajiXiPBbvFqxUWFkEbyo6x5qsACUuVfA==", + "license": "BSD-3-Clause" + }, + "node_modules/node-releases": { + "version": "2.0.54", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz", + "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz", + "integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/polished": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/polished/-/polished-4.3.1.tgz", + "integrity": "sha512-OBatVyC/N7SCW/FaDHrSd+vn0o5cS855TOmYi4OkdWUMSJCET/xip//ch8xGUvtr3i44X9LVyWwQlRMTN3pwSA==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.17.8" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/postcss": { + "version": "8.5.26", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz", + "integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.17", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-import": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-15.1.0.tgz", + "integrity": "sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==", + "dev": true, + "license": "MIT", + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, + "node_modules/postcss-js": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.1.0.tgz", + "integrity": "sha512-oIAOTqgIo7q2EOwbhb8UalYePMvYoIeRY2YKntdpFQXNosSu3vLrniGgmH9OKs/qAkfoj5oB3le/7mINW1LCfw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "camelcase-css": "^2.0.1" + }, + "engines": { + "node": "^12 || ^14 || >= 16" + }, + "peerDependencies": { + "postcss": "^8.4.21" + } + }, + "node_modules/postcss-load-config": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-6.0.1.tgz", + "integrity": "sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "lilconfig": "^3.1.1" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "jiti": ">=1.21.0", + "postcss": ">=8.0.9", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + }, + "postcss": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/postcss-nested": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-6.2.0.tgz", + "integrity": "sha512-HQbt28KulC5AJzG+cZtj9kvKB93CFCdLvog1WFLf1D+xmMvPGlBstkpTEZfK5+AN9hfJocyBFCNiqyS48bpgzQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "postcss-selector-parser": "^6.1.1" + }, + "engines": { + "node": ">=12.0" + }, + "peerDependencies": { + "postcss": "^8.2.14" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.4.tgz", + "integrity": "sha512-bIoJLOmjCO1S9XdY/DcnR5hJxvrDir1PbGChrzXG3vw0/FOliy/fA3dmdhQ441kah4gKv+TwckGzex6wNS5cnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/preact": { + "version": "10.29.8", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.29.8.tgz", + "integrity": "sha512-ej2aVZ+vZ8WO7tvlQWRM9N63A0KzF9q4mWJfDUHgYaIofWY9hu74QdnQrjoPMmZi2/nZ5gN0bJCQF49xQqx09Q==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + }, + "peerDependencies": { + "preact-render-to-string": ">=5" + }, + "peerDependenciesMeta": { + "preact-render-to-string": { + "optional": true + } + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/read-cache": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.2.tgz", + "integrity": "sha512-/peqiBB/n07gQGLsWaHho3WfvUyRscw0gYTsEFMhrIe/nWLkYaf5SbKYjGYqtRV3aPwykJgF2VEMo1ac4bnsGA==", + "dev": true, + "license": "MIT" + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.12", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz", + "integrity": "sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "is-core-module": "^2.16.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "4.63.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.1.tgz", + "integrity": "sha512-3Df9jsstwhccuEfmAMi9l8XUh/GOkVObmFTU7CCVBysEbcOZLl84jCtaAZMcPiMz2EGKsATzQcU+Xr3n/wU6cg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.63.1", + "@rollup/rollup-android-arm64": "4.63.1", + "@rollup/rollup-darwin-arm64": "4.63.1", + "@rollup/rollup-darwin-x64": "4.63.1", + "@rollup/rollup-freebsd-arm64": "4.63.1", + "@rollup/rollup-freebsd-x64": "4.63.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.63.1", + "@rollup/rollup-linux-arm-musleabihf": "4.63.1", + "@rollup/rollup-linux-arm64-gnu": "4.63.1", + "@rollup/rollup-linux-arm64-musl": "4.63.1", + "@rollup/rollup-linux-loong64-gnu": "4.63.1", + "@rollup/rollup-linux-loong64-musl": "4.63.1", + "@rollup/rollup-linux-ppc64-gnu": "4.63.1", + "@rollup/rollup-linux-ppc64-musl": "4.63.1", + "@rollup/rollup-linux-riscv64-gnu": "4.63.1", + "@rollup/rollup-linux-riscv64-musl": "4.63.1", + "@rollup/rollup-linux-s390x-gnu": "4.63.1", + "@rollup/rollup-linux-x64-gnu": "4.63.1", + "@rollup/rollup-linux-x64-musl": "4.63.1", + "@rollup/rollup-openbsd-x64": "4.63.1", + "@rollup/rollup-openharmony-arm64": "4.63.1", + "@rollup/rollup-win32-arm64-msvc": "4.63.1", + "@rollup/rollup-win32-ia32-msvc": "4.63.1", + "@rollup/rollup-win32-x64-gnu": "4.63.1", + "@rollup/rollup-win32-x64-msvc": "4.63.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sucrase": { + "version": "3.35.1", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.1.tgz", + "integrity": "sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.2", + "commander": "^4.0.0", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "tinyglobby": "^0.2.11", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tailwind-merge": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.6.0.tgz", + "integrity": "sha512-uxL7qAVQriqRQPAyK3pj66VqskWqoZ37PW94jwOTwNfq/z9oyu1V+eqrZqtR2+fCiXdYOZe/Modt8GtvqNzu+w==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, + "node_modules/tailwindcss": { + "version": "3.4.19", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.19.tgz", + "integrity": "sha512-3ofp+LL8E+pK/JuPLPggVAIaEuhvIz4qNcf3nA1Xn2o/7fb7s/TYpHhwGDv1ZU3PkBluUVaF8PyCHcm48cKLWQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@alloc/quick-lru": "^5.2.0", + "arg": "^5.0.2", + "chokidar": "^3.6.0", + "didyoumean": "^1.2.2", + "dlv": "^1.1.3", + "fast-glob": "^3.3.2", + "glob-parent": "^6.0.2", + "is-glob": "^4.0.3", + "jiti": "^1.21.7", + "lilconfig": "^3.1.3", + "micromatch": "^4.0.8", + "normalize-path": "^3.0.0", + "object-hash": "^3.0.0", + "picocolors": "^1.1.1", + "postcss": "^8.4.47", + "postcss-import": "^15.1.0", + "postcss-js": "^4.0.1", + "postcss-load-config": "^4.0.2 || ^5.0 || ^6.0", + "postcss-nested": "^6.2.0", + "postcss-selector-parser": "^6.1.2", + "resolve": "^1.22.8", + "sucrase": "^3.35.0" + }, + "bin": { + "tailwind": "lib/cli.js", + "tailwindcss": "lib/cli.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/three": { + "version": "0.185.1", + "resolved": "https://registry.npmjs.org/three/-/three-0.185.1.tgz", + "integrity": "sha512-5aojFCXKwnjBRZvUnt3WFfEcvUJgkN5LlijRFN95hMy8WVkG4I0QNcJE+OuWvuJ0bOdStrbfXn0pkd6/QyiAlg==", + "license": "MIT" + }, + "node_modules/three-forcegraph": { + "version": "1.43.4", + "resolved": "https://registry.npmjs.org/three-forcegraph/-/three-forcegraph-1.43.4.tgz", + "integrity": "sha512-FtmiZP/T16ZQaHza3JDaDn0YTXFtg9e7pGnTeU8nzu0NNkx7MpWbF/GvmpbQsWHx3rukHtkRv1fTorLPB3FDEA==", + "license": "MIT", + "dependencies": { + "accessor-fn": "1", + "d3-array": "1 - 3", + "d3-force-3d": "2 - 3", + "d3-scale": "1 - 4", + "d3-scale-chromatic": "1 - 3", + "data-bind-mapper": "1", + "kapsule": "^1.16", + "ngraph.forcelayout": "3", + "ngraph.graph": "20", + "tinycolor2": "1" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.118.3" + } + }, + "node_modules/three-render-objects": { + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/three-render-objects/-/three-render-objects-1.42.0.tgz", + "integrity": "sha512-KYfkPrYGEbIK8ChFocWqOF1aAN80FBUBWVYB8mB2oBpVuVN+52FvvngVYB5ieFANQu7Rt21rPYZ/xKaAgVWWRQ==", + "license": "MIT", + "dependencies": { + "@tweenjs/tween.js": "18 - 25", + "accessor-fn": "1", + "float-tooltip": "^1.7", + "kapsule": "^1.16", + "polished": "4" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.179" + } + }, + "node_modules/three-spritetext": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/three-spritetext/-/three-spritetext-1.10.0.tgz", + "integrity": "sha512-t08iP1FCU1lQh8T5MmCpdijKgas8GDHJE0LqMGBuVu3xqMMpFnEZhTlih7FlxLPQizHIGoumUSpfOlY1GO/Tgg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "three": ">=0.86.0" + } + }, + "node_modules/tinycolor2": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz", + "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==", + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/update-browserslist-db": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz", + "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/vite": { + "version": "6.4.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.3.tgz", + "integrity": "sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vue": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.42.tgz", + "integrity": "sha512-4RyHQTbQvOPs3MfvUO1Sg0YRrKNnA0mAVtvpd12Tg1fKDN7OHBUl1IqSn8zGJjK9nI3NkNp8cgTpVrSZC5TTcA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.42", + "@vue/compiler-sfc": "3.5.42", + "@vue/runtime-dom": "3.5.42", + "@vue/server-renderer": "3.5.42", + "@vue/shared": "3.5.42" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/vue-router": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.6.4.tgz", + "integrity": "sha512-Hz9q5sa33Yhduglwz6g9skT8OBPii+4bFn88w6J+J4MfEo4KRRpmiNG/hHHkdbRFlLBOqxN8y8gf2Fb0MTUgVg==", + "license": "MIT", + "dependencies": { + "@vue/devtools-api": "^6.6.4" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "vue": "^3.5.0" + } + } + } +} diff --git a/ui/package.json b/ui/package.json new file mode 100644 index 0000000..0f05362 --- /dev/null +++ b/ui/package.json @@ -0,0 +1,34 @@ +{ + "name": "sourceant-agent-ui", + "version": "0.1.0", + "private": true, + "description": "The local SourceAnt view, served by the agent", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "lint": "eslint .", + "test": "vitest run" + }, + "dependencies": { + "3d-force-graph": "^1.80.0", + "@dicebear/collection": "^9.2.2", + "@dicebear/core": "^9.2.2", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "force-graph": "^1.51.4", + "lucide-vue-next": "^0.563.0", + "tailwind-merge": "^3.4.0", + "three-spritetext": "^1.10.0", + "vue": "^3.5.13", + "vue-router": "^4.5.0" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.2.1", + "autoprefixer": "^10.4.24", + "postcss": "^8.4.49", + "tailwindcss": "^3.4.17", + "vite": "^6.0.7" + } +} diff --git a/ui/postcss.config.js b/ui/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/ui/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/ui/public/favicon.svg b/ui/public/favicon.svg new file mode 100644 index 0000000..c08eff2 --- /dev/null +++ b/ui/public/favicon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ui/src/App.vue b/ui/src/App.vue new file mode 100644 index 0000000..dd487ab --- /dev/null +++ b/ui/src/App.vue @@ -0,0 +1,169 @@ + + + diff --git a/ui/src/api.js b/ui/src/api.js new file mode 100644 index 0000000..c1f1662 --- /dev/null +++ b/ui/src/api.js @@ -0,0 +1,39 @@ +/* Everything comes from the agent. It is the process that is always up and the + * one that knows where the indexer is listening. */ + +async function call(path, options = {}) { + const response = await fetch(path, { + ...options, + headers: options.body ? { 'Content-Type': 'application/json' } : undefined, + }) + const text = await response.text() + const body = text ? JSON.parse(text) : null + if (!response.ok) throw new Error(body?.error || `the agent answered ${response.status}`) + return body +} + +const query = (values) => + new URLSearchParams(Object.entries(values).filter(([, value]) => value !== '' && value !== false)) + +export const api = { + status: () => call('/health'), + + repositories: () => call('/api/repositories'), + addRepository: (path, name) => + call('/api/repositories', { method: 'POST', body: JSON.stringify({ path, name }) }), + dropRepository: (path) => + call(`/api/repositories?${query({ path })}`, { method: 'DELETE' }), + index: (repository = '', everything = false) => + call('/api/index', { method: 'POST', body: JSON.stringify({ repository, everything }) }), + + graph: (repository, { includeTests = false, pathPrefix = '' } = {}) => + call(`/api/graph?${query({ repository, include_tests: includeTests, path_prefix: pathPrefix })}`), + + knowledge: (repository) => call(`/api/knowledge?${query({ repository, limit: 100 })}`), + recordKnowledge: (item) => + call('/api/knowledge', { method: 'PUT', body: JSON.stringify(item) }), + forgetKnowledge: (repository, id) => + call(`/api/knowledge?${query({ repository, id })}`, { method: 'DELETE' }), + + browse: (path = '') => call(`/api/browse?${query({ path })}`), +} diff --git a/ui/src/assets/main.css b/ui/src/assets/main.css new file mode 100644 index 0000000..5a7314e --- /dev/null +++ b/ui/src/assets/main.css @@ -0,0 +1,163 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +@layer base { + :root, + .dark { + color-scheme: dark; + --background: 240 10% 3.9%; + --foreground: 0 0% 98%; + --card: 240 9% 7%; + --card-foreground: 0 0% 98%; + --popover: 240 9% 7%; + --popover-foreground: 0 0% 98%; + --primary: 357 89% 47%; + --primary-foreground: 0 0% 100%; + --secondary: 240 4% 16%; + --secondary-foreground: 0 0% 98%; + --muted: 240 5% 14%; + --muted-foreground: 240 5% 64.9%; + --accent: 240 4% 16%; + --accent-foreground: 0 0% 98%; + --destructive: 0 62.8% 50.6%; + --destructive-foreground: 0 0% 98%; + --success: 142 71% 45%; + --success-foreground: 0 0% 98%; + --warning: 38 92% 50%; + --warning-foreground: 0 0% 98%; + --border: 240 6% 16%; + --input: 240 6% 16%; + --ring: 357 89% 47%; + --radius: 0.25rem; + --brand: 357 89% 47%; + /* Capability pillar accents, shared with the marketing site */ + --pillar-memory: 217 91% 60%; + --pillar-graph: 262 83% 66%; + --pillar-review: 142 71% 45%; + --pillar-tokens: 38 92% 50%; + } + + .light { + color-scheme: light; + --background: 240 20% 98%; + --foreground: 240 10% 10%; + --card: 0 0% 100%; + --card-foreground: 240 10% 10%; + --popover: 0 0% 100%; + --popover-foreground: 240 10% 10%; + --primary: 357 89% 47%; + --primary-foreground: 0 0% 100%; + --secondary: 240 10% 94%; + --secondary-foreground: 240 10% 20%; + --muted: 240 10% 94%; + --muted-foreground: 240 5% 45%; + --accent: 357 60% 96%; + --accent-foreground: 357 70% 40%; + --destructive: 0 84% 60%; + --destructive-foreground: 0 0% 100%; + --success: 142 70% 35%; + --success-foreground: 0 0% 100%; + --warning: 38 92% 45%; + --warning-foreground: 0 0% 100%; + --border: 240 10% 90%; + --input: 240 10% 90%; + --ring: 357 89% 47%; + --brand: 357 89% 47%; + --pillar-memory: 217 91% 55%; + --pillar-graph: 262 83% 58%; + --pillar-review: 142 71% 40%; + --pillar-tokens: 38 92% 45%; + } +} + +@layer base { + * { + @apply border-border; + } + + body { + @apply bg-background text-foreground font-sans antialiased; + } + + html { + scroll-behavior: smooth; + } +} + +@layer components { + .gradient-text { + @apply bg-gradient-to-r from-primary via-purple-400 to-pink-400 bg-clip-text text-transparent; + } + + .light .gradient-text { + @apply from-purple-600 via-violet-600 to-pink-600; + } + + .gradient-border { + @apply relative; + } + + .gradient-border::before { + content: ''; + @apply absolute -inset-[1px] rounded-lg bg-gradient-to-r from-primary via-purple-500 to-pink-500 opacity-20; + } + + .glass { + @apply bg-background/80 backdrop-blur-xl; + } + + .light .glass { + @apply bg-background/90 backdrop-blur-xl border-b border-border/50; + } + + .glow { + box-shadow: 0 0 60px -15px hsl(var(--primary) / 0.3); + } + + .light .glow { + box-shadow: 0 0 60px -15px hsl(var(--primary) / 0.15); + } + + .glow-sm { + box-shadow: 0 0 30px -10px hsl(var(--primary) / 0.2); + } + + .light .glow-sm { + box-shadow: 0 0 30px -10px hsl(var(--primary) / 0.1); + } + + .text-brand { + color: hsl(var(--brand)); + } + + .bg-brand { + background-color: hsl(var(--brand)); + } + + .border-brand { + border-color: hsl(var(--brand)); + } +} + +@layer utilities { + .text-balance { + text-wrap: balance; + } + + .animate-delay-100 { + animation-delay: 100ms; + } + + .animate-delay-200 { + animation-delay: 200ms; + } + + .animate-delay-300 { + animation-delay: 300ms; + } + + .animate-delay-500 { + animation-delay: 500ms; + } +} diff --git a/ui/src/components/CodeGraph.vue b/ui/src/components/CodeGraph.vue new file mode 100644 index 0000000..e93e50e --- /dev/null +++ b/ui/src/components/CodeGraph.vue @@ -0,0 +1,182 @@ + + + diff --git a/ui/src/components/EmptyMachine.vue b/ui/src/components/EmptyMachine.vue new file mode 100644 index 0000000..df51b4c --- /dev/null +++ b/ui/src/components/EmptyMachine.vue @@ -0,0 +1,19 @@ + + + diff --git a/ui/src/components/FolderPicker.vue b/ui/src/components/FolderPicker.vue new file mode 100644 index 0000000..b0ca79f --- /dev/null +++ b/ui/src/components/FolderPicker.vue @@ -0,0 +1,112 @@ + + + diff --git a/ui/src/components/PageHead.vue b/ui/src/components/PageHead.vue new file mode 100644 index 0000000..57915ac --- /dev/null +++ b/ui/src/components/PageHead.vue @@ -0,0 +1,32 @@ + + + diff --git a/ui/src/components/ui/Avatar.vue b/ui/src/components/ui/Avatar.vue new file mode 100644 index 0000000..4b32c6d --- /dev/null +++ b/ui/src/components/ui/Avatar.vue @@ -0,0 +1,51 @@ + + + diff --git a/ui/src/components/ui/Badge.vue b/ui/src/components/ui/Badge.vue new file mode 100755 index 0000000..9e4adad --- /dev/null +++ b/ui/src/components/ui/Badge.vue @@ -0,0 +1,41 @@ + + + diff --git a/ui/src/components/ui/Button.vue b/ui/src/components/ui/Button.vue new file mode 100755 index 0000000..fcabd58 --- /dev/null +++ b/ui/src/components/ui/Button.vue @@ -0,0 +1,58 @@ + + + diff --git a/ui/src/components/ui/Card.vue b/ui/src/components/ui/Card.vue new file mode 100644 index 0000000..3f3df30 --- /dev/null +++ b/ui/src/components/ui/Card.vue @@ -0,0 +1,28 @@ + + + diff --git a/ui/src/components/ui/Logo.vue b/ui/src/components/ui/Logo.vue new file mode 100755 index 0000000..832ecc6 --- /dev/null +++ b/ui/src/components/ui/Logo.vue @@ -0,0 +1,49 @@ + + + diff --git a/ui/src/components/ui/Modal.vue b/ui/src/components/ui/Modal.vue new file mode 100755 index 0000000..ee64550 --- /dev/null +++ b/ui/src/components/ui/Modal.vue @@ -0,0 +1,73 @@ + + + diff --git a/ui/src/composables/useRepositories.js b/ui/src/composables/useRepositories.js new file mode 100644 index 0000000..d593460 --- /dev/null +++ b/ui/src/composables/useRepositories.js @@ -0,0 +1,29 @@ +import { ref } from 'vue' +import { api } from '~/api' + +/* One list of repositories for the whole app, and one choice of which is being + * looked at, so moving between pages does not lose it. */ +const repositories = ref([]) +const chosen = ref('') +const error = ref('') +const loading = ref(false) + +export function useRepositories() { + async function fetchRepositories() { + loading.value = true + try { + repositories.value = await api.repositories() + error.value = '' + } catch (problem) { + repositories.value = [] + error.value = `${problem.message}. Is sourceant-agent running?` + } finally { + loading.value = false + } + if (!repositories.value.some((item) => item.name === chosen.value)) { + chosen.value = repositories.value[0]?.name ?? '' + } + } + + return { repositories, chosen, error, loading, fetchRepositories } +} diff --git a/ui/src/composables/useTheme.js b/ui/src/composables/useTheme.js new file mode 100644 index 0000000..9a3faf7 --- /dev/null +++ b/ui/src/composables/useTheme.js @@ -0,0 +1,30 @@ +import { ref } from 'vue' + +const isDark = ref(true) + +function apply(dark) { + isDark.value = dark + document.documentElement.classList.toggle('dark', dark) + document.documentElement.classList.toggle('light', !dark) + try { + localStorage.setItem('sourceant-theme', dark ? 'dark' : 'light') + } catch { + // A browser that refuses storage still gets the theme, just not the memory. + } +} + +export function useTheme() { + return { + isDark, + toggleTheme: () => apply(!isDark.value), + restoreTheme: () => { + let stored = null + try { + stored = localStorage.getItem('sourceant-theme') + } catch { + stored = null + } + apply(stored !== 'light') + }, + } +} diff --git a/ui/src/lib/graph.js b/ui/src/lib/graph.js new file mode 100644 index 0000000..cd06244 --- /dev/null +++ b/ui/src/lib/graph.js @@ -0,0 +1,92 @@ +/* What a node is, what colour it draws in, and how a repository is arranged. + * + * Shared by the renderer and the page around it, so a legend and a drawing + * cannot disagree about what a colour means. */ + +export const COLOURS = { + repository: '#E20C18', + directory: '#9560f0', + file: '#3b82f6', + import: '#f59e0b', + function: '#4ade80', + method: '#2dd4bf', + class: '#c084fc', + struct: '#22d3ee', + interface: '#22d3ee', + enum: '#22d3ee', +} + +export const OTHER = '#a1a1aa' + +/* A file's kind is its language and a symbol's kind is what the parser called + * it, so kind alone cannot tell a Python file from a Python function. The + * labels the index carries can. */ +export function groupOf(node) { + if (node.synthetic) return node.synthetic + const labels = node.labels || [] + if (labels.includes('File')) return 'file' + if (labels.includes('Import')) return 'import' + return (node.kind || '').toLowerCase() +} + +export function colourFor(node) { + return COLOURS[groupOf(node)] || OTHER +} + +export function shortName(name) { + return name && name.length > 28 ? `${name.slice(0, 27)}…` : name +} + +/* Files hold their symbols and their imports, and nothing holds the files, so + * drawing the index as it is stored scatters a repository into one island per + * file. The directories are already in every path; this reads them out and + * hangs the files off them, which is the difference between a repository and + * confetti. The nodes it adds are marked synthetic: they are how this view + * arranges what the index found, not something the index found. */ +export function withFolders(data, repository) { + const root = { + id: 'tree:', + name: repository, + kind: 'repository', + synthetic: 'repository', + path: '', + } + const folders = new Map([['', root]]) + const links = [...data.links] + + const folderFor = (path) => { + if (folders.has(path)) return folders.get(path) + const cut = path.lastIndexOf('/', path.length - 2) + const parentPath = cut === -1 ? '' : path.slice(0, cut + 1) + const parent = folderFor(parentPath) + const folder = { + id: `tree:${path}`, + name: path.slice(parentPath.length).replace(/\/$/, ''), + kind: 'directory', + synthetic: 'directory', + path, + } + folders.set(path, folder) + links.push({ source: parent.id, target: folder.id, type: 'contains' }) + return folder + } + + for (const node of data.nodes) { + if (groupOf(node) !== 'file' || !node.path) continue + const cut = node.path.lastIndexOf('/') + const folder = folderFor(cut === -1 ? '' : node.path.slice(0, cut + 1)) + links.push({ source: folder.id, target: node.id, type: 'contains' }) + } + + return { nodes: [...folders.values(), ...data.nodes], links } +} + +/* The hosted graph's modes, and what each asks the layout for. 'zout' is a 3D + * layout, which is why every mode but the first renders in three dimensions. */ +export const MODES = [ + { id: '2d', label: '2D' }, + { id: 'tree', label: 'Tree' }, + { id: 'radial', label: 'Radial' }, + { id: 'layered', label: 'Layered' }, + { id: 'web', label: 'Force' }, +] diff --git a/ui/src/lib/utils.ts b/ui/src/lib/utils.ts new file mode 100755 index 0000000..d32b0fe --- /dev/null +++ b/ui/src/lib/utils.ts @@ -0,0 +1,6 @@ +import { type ClassValue, clsx } from 'clsx' +import { twMerge } from 'tailwind-merge' + +export function cn(...inputs: ClassValue[]) { + return twMerge(clsx(inputs)) +} diff --git a/ui/src/main.js b/ui/src/main.js new file mode 100644 index 0000000..79e8b7f --- /dev/null +++ b/ui/src/main.js @@ -0,0 +1,25 @@ +import { createApp } from 'vue' +import { createRouter, createWebHashHistory } from 'vue-router' +import App from '~/App.vue' +import Overview from '~/pages/Overview.vue' +import Graph from '~/pages/Graph.vue' +import Knowledge from '~/pages/Knowledge.vue' +import Repositories from '~/pages/Repositories.vue' +import SettingsPage from '~/pages/Settings.vue' +import '~/assets/main.css' + +// Hash history, because the agent serves one file and knows nothing about +// paths a router invented. +const router = createRouter({ + history: createWebHashHistory(), + routes: [ + { path: '/', component: Overview }, + { path: '/graph', component: Graph }, + { path: '/knowledge', component: Knowledge }, + { path: '/repositories', component: Repositories }, + { path: '/settings', component: SettingsPage }, + { path: '/:rest(.*)*', redirect: '/' }, + ], +}) + +createApp(App).use(router).mount('#app') diff --git a/ui/src/pages/Graph.vue b/ui/src/pages/Graph.vue new file mode 100644 index 0000000..332c542 --- /dev/null +++ b/ui/src/pages/Graph.vue @@ -0,0 +1,182 @@ + + + diff --git a/ui/src/pages/Knowledge.vue b/ui/src/pages/Knowledge.vue new file mode 100644 index 0000000..6b78dfe --- /dev/null +++ b/ui/src/pages/Knowledge.vue @@ -0,0 +1,211 @@ + + +