refactor(channels): webhook and email run only as extensions; their channel settings go

This commit is contained in:
sam committed 2026-10-04 17:04:21 +11:00
1 parent 34f502c08b
commit b24c4d884d
16 files changed
+99 -1073

No files matched your search

+3 -26
View File
@@ -173,32 +173,9 @@ class = "ollama"
# update_check_command = ["/usr/local/bin/archie-update-check"]
# update_install_command = ["/usr/local/bin/archie-update-install"]
# Inbound email as a chat channel, via SMTP. Empty listen_addr disables it.
# [chat.email]
# listen_addr = "0.0.0.0:2525" # inbound SMTP server
# relay_addr = "smtp.example.com:587" # outbound relay for replies
# Generic inbound webhook gateway: external services push messages into
# chat for LLM processing. This is a distinct surface from
# [forge].webhook_addr (forge issue events) and [capture] (unbound event
# storage for later binding) -- three different inbound HTTP concerns that
# happen to share the word "webhook".
# webhook_addr = "0.0.0.0:8646" # under [chat], not [chat.telegram]
#
# [chat.webhook] configures the single route the gateway serves. Every
# field is optional; an absent section runs with the pre-existing
# behaviour: path "/webhook", no signature validation, raw body as message
# text, no reply.
# [chat.webhook]
# path = "/webhook"
# secret = { engine = "bws", key = "CHAT_WEBHOOK_SECRET" } # verifies
# # X-Hub-Signature-256 on inbound payloads. Empty (the default) accepts
# # any unsigned POST -- set this to make the gateway actually verify
# # what it claims to.
# template = "issue.title" # dot-notation extraction of the message text
# # from the JSON payload. Empty uses the raw body.
# deliver_to = "origin" # "origin" writes the reply as the HTTP
# # response; empty (the default) sends no reply.
# Email and the generic inbound webhook are archipelago channel extensions
# (channels/email, channels/webhook): install, accept and enable them from the
# Extensions page, with their settings there.
# Per-(channel, sender) inbound rate limiting, shared by every chat channel:
# Telegram keys by numeric user ID, email by SMTP from address, webhook by
+1 -2
View File
@@ -11,8 +11,7 @@ import (
// user id, an SMTP from address). The dashboard ("web") has one bearer token,
// not users, and a webhook carries no per-caller identity at all: its route path
// is a source, not a person, and never enters SenderID
// (internal/channels/webhook/webhook.go -- it travels in the transport-only
// Inbound.BudgetKey instead). Treating a URL or a shared token as an identity
// (it travels in the transport-only Inbound.BudgetKey instead). Treating a URL or a shared token as an identity
// would give it the same standing as a real user, which the read path's
// isolation guarantee depends on never happening.
//
-86
View File
@@ -4,18 +4,14 @@ import (
"context"
"fmt"
"log/slog"
"net"
"slices"
"strconv"
"sync"
"sync/atomic"
"time"
"github.com/samcharles93/archie-core/internal/channels"
"github.com/samcharles93/archie-core/internal/channels/email"
"github.com/samcharles93/archie-core/internal/channels/status"
"github.com/samcharles93/archie-core/internal/channels/telegram"
"github.com/samcharles93/archie-core/internal/channels/webhook"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/applystatus"
"github.com/samcharles93/archie-core/internal/domain/health"
@@ -158,20 +154,6 @@ func composeChannels(ctx context.Context, d deps) ([]*channelInstance, error) {
}
instances = append(instances, instance)
}
if d.Config.Email.ListenAddr != "" {
instance, err := composeEmail(d)
if err != nil {
return nil, err
}
instances = append(instances, instance)
}
if d.Config.WebhookAddr != "" {
instance, err := composeWebhook(d)
if err != nil {
return nil, err
}
instances = append(instances, instance)
}
for _, instance := range d.ExtensionChannels {
if slices.ContainsFunc(instances, func(have *channelInstance) bool { return have.name == instance.name }) {
d.Log.Warn("channel extension skipped: a built-in channel has the same name", "channel", instance.name)
@@ -206,46 +188,6 @@ func composeTelegram(ctx context.Context, d deps) (*channelInstance, error) {
return &channelInstance{name: "telegram", channel: ch, rebuild: build}, nil
}
func composeEmail(d deps) (*channelInstance, error) {
build := func(cfg ResolvedConfig) (channels.Channel, error) {
if cfg.Email.ListenAddr == "" {
return nil, nil
}
em := email.New(cfg.Email.ListenAddr, cfg.Email.RelayAddr, d.Log)
if err := em.ValidateConfig(map[string]any{
"listen_addr": cfg.Email.ListenAddr,
"relay_addr": cfg.Email.RelayAddr,
}); err != nil {
return nil, fmt.Errorf("chat.email config invalid: %w", err)
}
return em, nil
}
ch, err := build(d.Config)
if err != nil {
return nil, err
}
return &channelInstance{name: "email", channel: ch, rebuild: build}, nil
}
func composeWebhook(d deps) (*channelInstance, error) {
build := func(cfg ResolvedConfig) (channels.Channel, error) {
if cfg.WebhookAddr == "" {
return nil, nil
}
host, port := parseListenAddr(cfg.WebhookAddr, "0.0.0.0", 8644)
wh := webhook.New(host, port, webhookRoutes(cfg.Webhook, cfg.WebhookSecret), d.Log)
if err := wh.ValidateConfig(map[string]any{"host": host, "port": port}); err != nil {
return nil, fmt.Errorf("chat.webhook config invalid: %w", err)
}
return wh, nil
}
ch, err := build(d.Config)
if err != nil {
return nil, err
}
return &channelInstance{name: "webhook", channel: ch, rebuild: build}, nil
}
// telegramValidateConfigMap builds the map Gateway.ValidateConfig expects
// from the typed config.
func telegramValidateConfigMap(cfg config.TelegramConfig) map[string]any {
@@ -256,34 +198,6 @@ func telegramValidateConfigMap(cfg config.TelegramConfig) map[string]any {
return m
}
func webhookRoutes(route config.WebhookRoute, secretValue string) []webhook.RouteConfig {
path := route.Path
if path == "" {
path = "/webhook"
}
return []webhook.RouteConfig{{
Path: path,
Secret: secretValue,
Template: route.Template,
DeliverTo: route.DeliverTo,
}}
}
func parseListenAddr(addr, defaultHost string, defaultPort int) (string, int) {
if addr == "" {
return defaultHost, defaultPort
}
host, portStr, err := net.SplitHostPort(addr)
if err != nil {
return defaultHost, defaultPort
}
port, err := strconv.Atoi(portStr)
if err != nil {
return defaultHost, defaultPort
}
return host, port
}
// Start launches the configured messaging channels.
func (s *Service) Start(ctx context.Context) error {
s.mu.Lock()
+2 -30
View File
@@ -17,10 +17,6 @@ type ResolvedConfig struct {
Options Options
TelegramToken string
Telegram config.TelegramConfig
Email config.EmailConfig
Webhook config.WebhookRoute
WebhookSecret string
WebhookAddr string
// WorkDir, BotUser and HealthURL are not channel transport settings. They
// locate this identity's release-announcement and update-report state
// files, and give the update installer the daemon health endpoint to poll
@@ -35,9 +31,6 @@ type projection struct {
gateway ServiceTarget
stateStore ServiceTarget
telegram config.TelegramConfig
email config.EmailConfig
webhook config.WebhookRoute
webhookAddr string
workDir string
botUser string
healthURL string
@@ -69,9 +62,6 @@ func Resolve(o Options, log *slog.Logger) (ResolvedConfig, error) {
return ResolvedConfig{
Options: o,
Telegram: proj.telegram,
Email: proj.email,
Webhook: proj.webhook,
WebhookAddr: proj.webhookAddr,
WorkDir: proj.workDir,
BotUser: proj.botUser,
HealthURL: proj.healthURL,
@@ -98,9 +88,6 @@ func project(cfg config.Config) projection {
},
stateStore: ServiceTarget{Target: cfg.Services.Get(config.ServiceNameState).Target, Token: cfg.Services.Get(config.ServiceNameState).TargetToken},
telegram: cfg.Chat.Telegram,
email: cfg.Chat.Email,
webhook: cfg.Chat.Webhook,
webhookAddr: cfg.Chat.WebhookAddr,
workDir: cfg.WorkDir,
botUser: cfg.BotUser,
healthURL: cfg.Health.URL(),
@@ -143,27 +130,12 @@ func resolveTelegramToken(cfg config.TelegramConfig, secrets *secret.Registry) (
return secrets.Resolve(cfg.Token)
}
func resolveWebhookSecret(route config.WebhookRoute, secrets *secret.Registry) (string, error) {
if route.Secret != (secret.SecretRef{}) {
return secrets.Resolve(route.Secret)
}
return "", nil
}
// resolveTokens fills the channel credentials from the file configuration. An
// unresolvable webhook secret is not fatal: the route still serves, with
// signature validation off, which is what it did before a secret was ever
// configurable. It is logged so the degradation is visible.
func (c *ResolvedConfig) resolveTokens(secrets *secret.Registry, log *slog.Logger) error {
// resolveTokens fills the channel credentials from the file configuration.
func (c *ResolvedConfig) resolveTokens(secrets *secret.Registry) error {
token, err := resolveTelegramToken(c.Telegram, secrets)
if err != nil {
return fmt.Errorf("resolve telegram token: %w", err)
}
c.TelegramToken = token
c.WebhookSecret, err = resolveWebhookSecret(c.Webhook, secrets)
if err != nil {
log.Error("webhook secret unresolvable; starting with signature validation disabled",
"engine", c.Webhook.Secret.Engine, "key", c.Webhook.Secret.Key, "err", err)
}
return nil
}
+3 -33
View File
@@ -45,8 +45,7 @@ func (s *Service) reconcileOnce(ctx context.Context) error {
return err
}
layered, version, err := s.settingsSource.RuntimeChatConfig(ctx, config.ChatConfig{
Telegram: base.Telegram, Email: base.Email, Webhook: base.Webhook,
WebhookAddr: base.WebhookAddr, ShowToolCalls: base.ShowToolCalls,
Telegram: base.Telegram, ShowToolCalls: base.ShowToolCalls,
})
if err != nil {
return err
@@ -76,19 +75,13 @@ func (s *Service) reconcileOnce(ctx context.Context) error {
// (the startup rule, config.go resolveTelegramToken).
func resolveChatSecrets(base ResolvedConfig, layered config.ChatConfig, secrets *secret.Registry) (ResolvedConfig, error) {
next := base
next.Telegram, next.Email, next.Webhook = layered.Telegram, layered.Email, layered.Webhook
next.WebhookAddr, next.ShowToolCalls = layered.WebhookAddr, layered.ShowToolCalls
next.Telegram, next.ShowToolCalls = layered.Telegram, layered.ShowToolCalls
token, err := resolveTelegramToken(layered.Telegram, secrets)
if err != nil {
return next, fmt.Errorf("resolve database telegram token: %w", err)
}
next.TelegramToken = token
webhookSecret, err := resolveWebhookSecret(layered.Webhook, secrets)
if err != nil {
return next, fmt.Errorf("resolve database webhook secret: %w", err)
}
next.WebhookSecret = webhookSecret
return next, nil
}
@@ -134,7 +127,7 @@ func (s *Service) applyShowToolCalls(show bool) {
}
// pinProcessBindings holds the values a running process cannot change in place:
// the listen addresses it already bound, and the set of channels it composed.
// the set of channels it composed.
// The returned configuration keeps the running value for each, and the returned
// problems name what the operator changed and when it takes effect.
func pinProcessBindings(current, next ResolvedConfig) (ResolvedConfig, []string) {
@@ -145,23 +138,6 @@ func pinProcessBindings(current, next ResolvedConfig) (ResolvedConfig, []string)
problems = append(problems, "chat.telegram enabled/disabled; takes effect on restart")
effective.Telegram, effective.TelegramToken = current.Telegram, current.TelegramToken
}
if (current.Email.ListenAddr != "") != (next.Email.ListenAddr != "") {
problems = append(problems, "chat.email enabled/disabled; takes effect on restart")
effective.Email = current.Email
}
if (current.WebhookAddr != "") != (next.WebhookAddr != "") {
problems = append(problems, "chat.webhook enabled/disabled; takes effect on restart")
effective.Webhook, effective.WebhookAddr, effective.WebhookSecret = current.Webhook, current.WebhookAddr, current.WebhookSecret
}
if current.Email.ListenAddr != "" && next.Email.ListenAddr != current.Email.ListenAddr {
problems = append(problems, "chat.email.listen_addr changed; takes effect on restart")
effective.Email.ListenAddr = current.Email.ListenAddr
}
if current.WebhookAddr != "" && next.WebhookAddr != current.WebhookAddr {
problems = append(problems, "chat.webhook_addr changed; takes effect on restart")
effective.WebhookAddr = current.WebhookAddr
}
return effective, problems
}
@@ -175,12 +151,6 @@ func channelChanges(current, next ResolvedConfig) []string {
(current.TelegramToken != next.TelegramToken || !slices.Equal(current.Telegram.AllowedUserIDs, next.Telegram.AllowedUserIDs)) {
changed = append(changed, "telegram")
}
if current.Email.ListenAddr != "" && current.Email.RelayAddr != next.Email.RelayAddr {
changed = append(changed, "email")
}
if current.WebhookAddr != "" && (current.Webhook != next.Webhook || current.WebhookSecret != next.WebhookSecret) {
changed = append(changed, "webhook")
}
return changed
}
+3 -7
View File
@@ -60,7 +60,7 @@ func Run(ctx context.Context, o Options) error {
extensions := extension.Source{Query: controlPlaneClient, Packages: stateStore}
defer superviseSecretEngines(ctx, extensions, secrets, reporter, log)()
chatSettings, channelVersion, settingsErr := controlPlaneClient.RuntimeChatConfig(ctx, config.ChatConfig{
Telegram: cfg.Telegram, Email: cfg.Email, Webhook: cfg.Webhook, WebhookAddr: cfg.WebhookAddr, ShowToolCalls: cfg.ShowToolCalls,
Telegram: cfg.Telegram, ShowToolCalls: cfg.ShowToolCalls,
})
if settingsErr != nil {
return fmt.Errorf("load channel settings: %w", settingsErr)
@@ -68,15 +68,11 @@ func Run(ctx context.Context, o Options) error {
reporter.Report(ctx, controlplanerpc.ChannelSettingsKind, channelVersion, nil)
go reporter.Run(ctx)
go presence.Run(ctx, presence.Messaging, servicekit.Build(), stateStore, health, log)
cfg.Telegram, cfg.Email, cfg.Webhook, cfg.WebhookAddr, cfg.ShowToolCalls = chatSettings.Telegram, chatSettings.Email, chatSettings.Webhook, chatSettings.WebhookAddr, chatSettings.ShowToolCalls
cfg.Telegram, cfg.ShowToolCalls = chatSettings.Telegram, chatSettings.ShowToolCalls
cfg.TelegramToken, settingsErr = resolveTelegramToken(chatSettings.Telegram, secrets)
if settingsErr != nil {
return fmt.Errorf("resolve database telegram token: %w", settingsErr)
}
cfg.WebhookSecret, settingsErr = resolveWebhookSecret(chatSettings.Webhook, secrets)
if settingsErr != nil {
return fmt.Errorf("resolve database webhook secret: %w", settingsErr)
}
extensionChannels = openExtensionChannels(ctx, extensions, secrets, log)
settings = messaging.NewSettingsCommand(messagingControlPlane{client: stateStore.ControlPlane()}).WithIdentities(stateStore)
channelStatusStore, presenceStore = stateStore, stateStore
@@ -84,7 +80,7 @@ func Run(ctx context.Context, o Options) error {
}
if cfg.Options.StateStore.Target == "" {
if err := cfg.resolveTokens(secrets, log); err != nil {
if err := cfg.resolveTokens(secrets); err != nil {
return err
}
}
@@ -120,7 +120,7 @@ func telegramReloader(o Options, secrets *secret.Registry, log *slog.Logger) fun
if err != nil {
return fmt.Errorf("reload config: %w", err)
}
if err := reloaded.resolveTokens(secrets, log); err != nil {
if err := reloaded.resolveTokens(secrets); err != nil {
return fmt.Errorf("reload config: %w", err)
}
if reloaded.TelegramToken == "" {
+6 -14
View File
@@ -10,12 +10,10 @@ import (
// Aliases for the channel-settings document defined in controlplanerpc.
type (
channelSettings = controlplanerpc.ChannelSettings
telegramSettings = controlplanerpc.TelegramSettings
webhookChannelSettings = controlplanerpc.WebhookChannelSettings
emailSettings = controlplanerpc.EmailSettings
rateLimitSettings = controlplanerpc.RateLimitSettings
channelDuration = controlplanerpc.ChannelDuration
channelSettings = controlplanerpc.ChannelSettings
telegramSettings = controlplanerpc.TelegramSettings
rateLimitSettings = controlplanerpc.RateLimitSettings
channelDuration = controlplanerpc.ChannelDuration
)
// ChannelSettingsKind is re-exported so the store-backed side and its callers
@@ -26,11 +24,8 @@ func seedChannels(cfg config.Config) any {
chat := cfg.Chat
return channelSettings{
Operator: chat.Operator, Workspace: chat.Workspace, UnrestrictedFilesystem: chat.UnrestrictedFilesystem, ShowToolCalls: chat.ShowToolCalls, MaxSteps: chat.MaxSteps, Models: chat.Models,
Email: emailSettings{ListenAddr: chat.Email.ListenAddr, RelayAddr: chat.Email.RelayAddr},
WebhookAddr: chat.WebhookAddr,
Telegram: telegramSettings{AllowedUserIDs: chat.Telegram.AllowedUserIDs, Token: chat.Telegram.Token, CredentialConfigured: chat.Telegram.Token != (config.SecretRef{})},
Webhook: webhookChannelSettings{Path: chat.Webhook.Path, Secret: chat.Webhook.Secret, CredentialConfigured: chat.Webhook.Secret != (config.SecretRef{}), Template: chat.Webhook.Template, DeliverTo: chat.Webhook.DeliverTo},
RateLimit: rateLimitSettings{Window: channelDuration(chat.RateLimit.Window), MaxRequests: chat.RateLimit.MaxRequests},
Telegram: telegramSettings{AllowedUserIDs: chat.Telegram.AllowedUserIDs, Token: chat.Telegram.Token, CredentialConfigured: chat.Telegram.Token != (config.SecretRef{})},
RateLimit: rateLimitSettings{Window: channelDuration(chat.RateLimit.Window), MaxRequests: chat.RateLimit.MaxRequests},
}
}
@@ -39,9 +34,6 @@ func validateChannels(input []byte) error {
if settings.MaxSteps < 0 || settings.RateLimit.MaxRequests < 0 || settings.RateLimit.Window < 0 {
return fmt.Errorf("channel limits must not be negative")
}
if settings.Webhook.DeliverTo != "" && settings.Webhook.DeliverTo != "origin" {
return fmt.Errorf("webhook deliver_to must be empty or origin")
}
return nil
})
}
-388
View File
@@ -1,388 +0,0 @@
// Package email receives email over SMTP and replies through an SMTP relay.
package email
import (
"bufio"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"log/slog"
"net"
"net/smtp"
"strings"
"sync"
"github.com/samcharles93/archie-core/internal/channels"
"github.com/samcharles93/archie-core/internal/domain/messaging"
)
// Gateway is an email gateway that receives inbound messages via SMTP
// and sends replies via SMTP relay.
type Gateway struct {
ListenAddr string // e.g. ":2525" or "127.0.0.1:2525"
// Relay is the SMTP relay for outbound replies (host:port).
RelayAddr string
// RelayUser is the SMTP AUTH username. Empty = no auth.
RelayUser string
// RelayPass is the SMTP AUTH password.
RelayPass string
// AllowedDomains restricts inbound senders. Empty = all allowed.
AllowedDomains []string
log *slog.Logger
client messaging.ChatContract
mu sync.Mutex
ln net.Listener
}
// New returns an unstarted Gateway.
func New(listenAddr, relayAddr string, log *slog.Logger) *Gateway {
if listenAddr == "" {
listenAddr = ":2525"
}
return &Gateway{
ListenAddr: listenAddr,
RelayAddr: relayAddr,
log: log.With("component", "gateway-email"),
}
}
func (g *Gateway) Name() string { return "email" }
// Start begins listening for SMTP connections. Blocks until ctx is
// cancelled.
func (g *Gateway) Start(ctx context.Context, client messaging.ChatContract, lifecycle channels.Lifecycle) error {
lifecycle.ReportStarting()
g.mu.Lock()
g.client = client
g.mu.Unlock()
lc := net.ListenConfig{}
ln, err := lc.Listen(ctx, "tcp", g.ListenAddr)
if err != nil {
return fmt.Errorf("email: listen %s: %w", g.ListenAddr, err)
}
g.mu.Lock()
g.ln = ln
g.mu.Unlock()
g.log.Info("email gateway listening", "addr", g.ListenAddr)
lifecycle.ReportRunning()
go func() {
<-ctx.Done()
_ = ln.Close()
}()
for {
conn, err := ln.Accept()
if err != nil {
if ctx.Err() != nil {
return nil //nolint:nilerr // Accept failed because the listener was closed by context cancellation, which is a clean shutdown, not a failure
}
g.log.Error("email accept", "err", err)
continue
}
go g.handleSMTP(ctx, conn)
}
}
// Stop shuts down the listener.
func (g *Gateway) Stop(ctx context.Context) error {
g.mu.Lock()
ln := g.ln
g.mu.Unlock()
if ln != nil {
return ln.Close()
}
return nil
}
// handleSMTP processes one SMTP session.
func (g *Gateway) handleSMTP(ctx context.Context, conn net.Conn) {
defer func() { _ = conn.Close() }()
r := bufio.NewReader(conn)
w := bufio.NewWriter(conn)
write := func(code int, msg string) {
_, _ = fmt.Fprintf(w, "%d %s\r\n", code, msg)
_ = w.Flush()
}
readLine := func() (string, error) {
line, err := r.ReadString('\n')
if err != nil {
return "", err
}
return strings.TrimRight(line, "\r\n"), nil
}
write(220, "archie email gateway ready")
var mailFrom, rcptTo string
var dataBuf strings.Builder
inData := false
for {
line, err := readLine()
if err != nil {
return
}
switch {
case inData:
if line == "." {
// End of DATA — process the message.
g.processMessage(ctx, mailFrom, rcptTo, dataBuf.String())
write(250, "OK: message accepted")
return
}
if strings.HasPrefix(line, "..") {
line = line[1:]
}
dataBuf.WriteString(line)
dataBuf.WriteString("\r\n")
case strings.HasPrefix(strings.ToUpper(line), "MAIL FROM:"):
mailFrom = extractAddr(line)
write(250, "OK")
case strings.HasPrefix(strings.ToUpper(line), "RCPT TO:"):
rcptTo = extractAddr(line)
write(250, "OK")
case strings.HasPrefix(strings.ToUpper(line), "DATA"):
write(354, "Start mail input; end with <CRLF>.<CRLF>")
inData = true
case strings.HasPrefix(strings.ToUpper(line), "QUIT"):
write(221, "Bye")
return
case strings.HasPrefix(strings.ToUpper(line), "EHLO"), strings.HasPrefix(strings.ToUpper(line), "HELO"):
write(250, "OK")
default:
write(500, "Unrecognized command")
}
}
}
// extractAddr pulls the email address from an SMTP command line like
// "MAIL FROM:<user@example.com>" or "RCPT TO:<user@example.com>".
func extractAddr(line string) string {
start := strings.IndexByte(line, '<')
end := strings.LastIndexByte(line, '>')
if start >= 0 && end > start {
return strings.TrimSpace(line[start+1 : end])
}
return strings.TrimSpace(line)
}
// processMessage extracts text from the raw email and routes it through
// the messaging chat contract. Replies are sent back via SMTP.
func (g *Gateway) processMessage(ctx context.Context, from, to, raw string) {
g.mu.Lock()
client := g.client
g.mu.Unlock()
if client == nil {
g.log.Warn("email received before gateway started")
return
}
// Extract plain text body: everything after the first blank line
// following Content-Type or headers.
text := extractBody(raw)
msg := messaging.Inbound{
Message: messaging.Message{
ConversationID: messaging.ConversationID{ChannelID: to},
Sender: from,
SenderID: from,
Role: messaging.RoleUser,
Text: text,
},
// The frontend names the channel it carries, which is how the Gateway
// learns it is serving email rather than whatever it calls itself.
Platform: "email",
}
reply, err := client.Route(ctx, msg)
if err != nil {
g.log.Error("email route", "err", err, "from", from)
return
}
if reply.Text != "" && g.RelayAddr != "" {
if err := g.sendReply(from, to, reply.Text); err != nil {
g.log.Error("email reply", "err", err, "to", from)
}
}
}
// extractBody pulls the plain text body from a raw email.
func extractBody(raw string) string {
// Find the message body: after headers (blank line).
parts := strings.SplitN(raw, "\r\n\r\n", 2)
if len(parts) < 2 {
parts = strings.SplitN(raw, "\n\n", 2)
}
if len(parts) < 2 {
return strings.TrimSpace(raw)
}
headers := parts[0]
body := parts[1]
// If multipart, look for the text/plain section.
if strings.Contains(strings.ToLower(headers), "content-type: multipart") {
if text := extractMultipartText(headers, body); text != "" {
return text
}
}
// Non-multipart: strip trailing SMTP dots.
return strings.TrimSpace(body)
}
// extractMultipartText looks for a text/plain section within a multipart
// body. Returns the trimmed text body or an empty string when not found.
func extractMultipartText(headers, body string) string {
idx := strings.Index(strings.ToLower(headers), "boundary=")
if idx < 0 {
return ""
}
boundary := extractBoundary(headers[idx:])
if boundary == "" {
return ""
}
sections := strings.SplitSeq(body, "--"+boundary)
for sec := range sections {
if !strings.Contains(strings.ToLower(sec), "content-type: text/plain") {
continue
}
if parts := strings.SplitN(sec, "\r\n\r\n", 2); len(parts) == 2 {
return strings.TrimSpace(strings.TrimRight(parts[1], "\r\n-"))
}
if parts := strings.SplitN(sec, "\n\n", 2); len(parts) == 2 {
return strings.TrimSpace(strings.TrimRight(parts[1], "\n-"))
}
}
return ""
}
func extractBoundary(line string) string {
// boundary="xxx" or boundary=xxx
line = strings.TrimPrefix(line, "boundary=")
line = strings.TrimSpace(line)
line = strings.Trim(line, "\"")
// Stop at semicolon or whitespace.
if idx := strings.IndexAny(line, " ;\r\n"); idx >= 0 {
return line[:idx]
}
return line
}
// sendReply delivers a reply to the original sender via SMTP relay.
func (g *Gateway) sendReply(to, from, text string) error {
msg := fmt.Sprintf("From: %s\r\nTo: %s\r\nSubject: Re: %s\r\n\r\n%s",
from, to, truncateSubject(text), text)
var auth smtp.Auth
if g.RelayUser != "" {
host, _, _ := net.SplitHostPort(g.RelayAddr)
auth = smtp.PlainAuth("", g.RelayUser, g.RelayPass, host)
}
// Try TLS first, fall back to plain.
c, err := smtp.Dial(g.RelayAddr)
if err != nil {
return fmt.Errorf("dial relay: %w", err)
}
defer func() { _ = c.Close() }()
if ok, _ := c.Extension("STARTTLS"); ok {
tlsCfg := &tls.Config{ServerName: serverName(g.RelayAddr)}
if err := c.StartTLS(tlsCfg); err != nil {
return fmt.Errorf("starttls: %w", err)
}
}
if auth != nil {
if err := c.Auth(auth); err != nil {
g.log.Warn("email relay auth failed", "err", err)
}
}
if err := c.Mail(from); err != nil {
return fmt.Errorf("mail from: %w", err)
}
if err := c.Rcpt(to); err != nil {
return fmt.Errorf("rcpt to: %w", err)
}
wc, err := c.Data()
if err != nil {
return fmt.Errorf("data: %w", err)
}
_, err = io.WriteString(wc, msg)
if err != nil {
return fmt.Errorf("write: %w", err)
}
return wc.Close()
}
func serverName(addr string) string {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return "localhost"
}
return host
}
func truncateSubject(text string) string {
if len(text) > 60 {
return text[:57] + "..."
}
return text
}
// ConfigSchema returns the JSON Schema for the email channel config.
func (g *Gateway) ConfigSchema() json.RawMessage {
return json.RawMessage(`{
"type": "object",
"required": ["listen_addr"],
"properties": {
"listen_addr": {
"type": "string",
"description": "Host:port for the inbound SMTP server (e.g. :2525)"
},
"relay_addr": {
"type": "string",
"description": "SMTP relay for outbound replies"
},
"relay_user": {
"type": "string",
"description": "SMTP AUTH username"
},
"relay_pass": {
"type": "string",
"description": "SMTP AUTH password"
}
}
}`)
}
// ValidateConfig checks the email channel configuration.
func (g *Gateway) ValidateConfig(cfg map[string]any) error {
if cfg == nil {
return fmt.Errorf("email config is required")
}
if addr, _ := cfg["listen_addr"].(string); addr == "" {
return fmt.Errorf("email.listen_addr is required")
}
return nil
}
// Compile-time guard.
var _ channels.Channel = (*Gateway)(nil)
-278
View File
@@ -1,278 +0,0 @@
// Package webhook implements gateway.Gateway for inbound HTTP webhooks.
// External services push messages into archie-core's gateway for LLM
// processing. Outbound delivery is not supported (deliver-only mode).
package webhook
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"log/slog"
"net"
"net/http"
"strings"
"sync"
"time"
"github.com/samcharles93/archie-core/internal/channels"
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/webhookguard"
)
// Gateway is a deliver-only webhook gateway. It listens for HTTP POST
// requests, validates their HMAC signatures, and routes the extracted
// text through the messaging ChatContract for LLM processing.
type Gateway struct {
Host string
Port int
Routes []RouteConfig
log *slog.Logger
server *http.Server
client messaging.ChatContract
mu sync.Mutex
}
// RouteConfig defines one webhook endpoint.
type RouteConfig struct {
// Path is the URL path (e.g. "/github").
Path string
// Secret is the HMAC-SHA256 secret for payload validation.
// Empty = no validation.
Secret string
// Template extracts the message text from the JSON payload.
// Uses dot-notation: "issue.title" or "comment.body".
// Empty = use the raw body as message text.
Template string
// DeliverTo routes replies: "origin" (HTTP response) or empty (no reply).
DeliverTo string
}
// New returns an unstarted Gateway. Call Start to begin listening.
func New(host string, port int, routes []RouteConfig, log *slog.Logger) *Gateway {
if host == "" {
host = "0.0.0.0"
}
return &Gateway{
Host: host,
Port: port,
Routes: routes,
log: log.With("component", "gateway-webhook"),
}
}
func (g *Gateway) Name() string { return "webhook" }
// Start begins listening on the configured host:port. Blocks until ctx
// is cancelled.
func (g *Gateway) Start(ctx context.Context, client messaging.ChatContract, lifecycle channels.Lifecycle) error {
lifecycle.ReportStarting()
g.mu.Lock()
g.client = client
mux := http.NewServeMux()
for i := range g.Routes {
route := g.Routes[i] // capture
mux.HandleFunc(route.Path, g.handleWebhook(&route))
}
addr := fmt.Sprintf("%s:%d", g.Host, g.Port)
g.server = &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: 5 * time.Second}
server := g.server
g.mu.Unlock()
lc := net.ListenConfig{}
ln, err := lc.Listen(ctx, "tcp", addr)
if err != nil {
return fmt.Errorf("webhook: listen: %w", err)
}
g.log.Info("webhook gateway listening", "addr", addr)
lifecycle.ReportRunning()
go func() {
<-ctx.Done()
shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second)
defer cancel()
_ = server.Shutdown(shutdownCtx)
}()
err = server.Serve(ln)
if err != nil && !errors.Is(err, http.ErrServerClosed) {
return fmt.Errorf("webhook: listen: %w", err)
}
return nil
}
// Stop gracefully shuts down the HTTP server.
func (g *Gateway) Stop(ctx context.Context) error {
g.mu.Lock()
server := g.server
g.mu.Unlock()
if server == nil {
return nil
}
return server.Shutdown(ctx)
}
// WebhookHandler returns the HTTP handler for testing.
func (g *Gateway) WebhookHandler() http.Handler {
mux := http.NewServeMux()
for i := range g.Routes {
route := g.Routes[i]
mux.HandleFunc(route.Path, g.handleWebhook(&route))
}
return mux
}
// handleWebhook returns an http.HandlerFunc for one route.
func (g *Gateway) handleWebhook(route *RouteConfig) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
body, err := io.ReadAll(io.LimitReader(r.Body, 1<<20)) // 1 MB
if err != nil {
g.log.Error("webhook read body", "err", err)
http.Error(w, "read error", http.StatusBadRequest)
return
}
// HMAC validation.
if route.Secret != "" {
sig := r.Header.Get("X-Hub-Signature-256")
if sig == "" {
sig = r.Header.Get("X-Signature-256")
}
if !webhookguard.VerifyHMAC(body, sig, route.Secret) {
g.log.Warn("webhook invalid signature", "path", route.Path)
http.Error(w, "invalid signature", http.StatusUnauthorized)
return
}
}
// Extract message text.
text := extractText(body, route.Template)
if text == "" {
http.Error(w, "empty message", http.StatusBadRequest)
return
}
// Route through the chat contract.
g.mu.Lock()
client := g.client
g.mu.Unlock()
if client == nil {
http.Error(w, "not started", http.StatusServiceUnavailable)
return
}
msg := messaging.Inbound{
Message: messaging.Message{
ConversationID: messaging.ConversationID{ChannelID: route.Path},
Sender: "webhook",
// A webhook has no per-caller identity, so SenderID stays
// empty: consumers read it as a person
// (internal/app/archied/chat_identity.go, sessioncurator),
// and a route path must never become a user identity
Role: messaging.RoleUser,
Text: text,
},
// The route is still this message's source for inbound rate
// limiting, so it travels in the transport-only BudgetKey
// rather than borrowing the identity field.
BudgetKey: route.Path,
Platform: "webhook",
}
reply, err := client.Route(r.Context(), msg)
if err != nil {
g.log.Error("webhook route", "err", err, "path", route.Path)
http.Error(w, "route error", http.StatusInternalServerError)
return
}
// A rate-limited delivery answers 429 so the source retries.
if reply.RateLimited {
http.Error(w, "rate limited", http.StatusTooManyRequests)
return
}
if route.DeliverTo == "origin" && reply.Text != "" {
w.Header().Set("Content-Type", "text/plain")
_, _ = w.Write([]byte(reply.Text))
} else {
w.WriteHeader(http.StatusAccepted)
}
}
}
// ConfigSchema returns the JSON Schema for the webhook channel config.
func (g *Gateway) ConfigSchema() json.RawMessage {
return json.RawMessage(`{
"type": "object",
"required": ["host", "port"],
"properties": {
"host": {
"type": "string",
"description": "Listen address (e.g. 0.0.0.0)"
},
"port": {
"type": "integer",
"description": "Listen port (e.g. 8644)"
},
"routes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": { "type": "string" },
"secret": { "type": "string" },
"template": { "type": "string" }
}
}
}
}
}`)
}
// ValidateConfig checks the webhook channel configuration.
func (g *Gateway) ValidateConfig(cfg map[string]any) error {
if cfg == nil {
return fmt.Errorf("webhook config is required")
}
if host, _ := cfg["host"].(string); host == "" {
return fmt.Errorf("webhook.host is required")
}
return nil
}
// Compile-time guard.
var _ channels.Channel = (*Gateway)(nil)
// extractText pulls a value from a JSON body using dot-notation path.
// "issue.title" → body["issue"]["title"]. Empty path = raw body.
func extractText(body []byte, path string) string {
if path == "" {
return strings.TrimSpace(string(body))
}
var data map[string]any
if err := json.Unmarshal(body, &data); err != nil {
return strings.TrimSpace(string(body))
}
parts := strings.Split(path, ".")
var current any = data
for _, p := range parts {
m, ok := current.(map[string]any)
if !ok {
return ""
}
current = m[p]
}
if s, ok := current.(string); ok {
return strings.TrimSpace(s)
}
return ""
}
-12
View File
@@ -1,7 +1,5 @@
package config
import "strings"
// ChatFrontEnd is one conversational front-end [chat] can enable. ID is its
// stable identifier.
type ChatFrontEnd struct {
@@ -19,16 +17,6 @@ func (c ChatConfig) FrontEnds() []ChatFrontEnd {
Name: "Telegram",
Configured: c.Telegram.Token != (SecretRef{}),
},
{
ID: "email",
Name: "Email",
Configured: strings.TrimSpace(c.Email.ListenAddr) != "",
},
{
ID: "webhook",
Name: "Webhook gateway",
Configured: strings.TrimSpace(c.WebhookAddr) != "",
},
}
}
+1 -37
View File
@@ -934,14 +934,7 @@ type ChatConfig struct {
// Models is the optional interactive-chat model catalog. When empty,
// chat falls back to the distinct model references assigned to workflow
// roles in the top-level [models] table.
Models []string `toml:"models" yaml:"models"`
// Email configures the inbound email gateway via SMTP.
Email EmailConfig `toml:"email" yaml:"email"`
// WebhookAddr is the host:port for the inbound webhook gateway.
// Empty disables the webhook gateway.
WebhookAddr string `toml:"webhook_addr" yaml:"webhook_addr"`
// Webhook configures the inbound webhook route.
Webhook WebhookRoute `toml:"webhook" yaml:"webhook"`
Models []string `toml:"models" yaml:"models"`
Telegram TelegramConfig `toml:"telegram" yaml:"telegram"`
// RateLimit budgets inbound messages per channel and sender. Off unless set.
// Seeds the channel-settings resource.
@@ -982,35 +975,6 @@ type TelegramConfig struct {
UpdateInstallCommand []string `toml:"update_install_command" yaml:"update_install_command"`
}
// EmailConfig configures the inbound email channel via SMTP.
type EmailConfig struct {
// ListenAddr is the host:port for the inbound SMTP server.
// Empty disables the email channel.
ListenAddr string `toml:"listen_addr" yaml:"listen_addr"`
// RelayAddr is the SMTP relay for outbound replies.
RelayAddr string `toml:"relay_addr" yaml:"relay_addr"`
}
// WebhookRoute configures the inbound webhook gateway's single route.
// Every field is optional: an absent [chat.webhook] section runs the
// gateway exactly as before this existed -- default path, no signature
// validation, raw body as message text, no reply.
type WebhookRoute struct {
// Path is the URL path the gateway listens on. Empty means "/webhook".
Path string `toml:"path" yaml:"path"`
// Secret is the HMAC-SHA256 secret validating inbound payloads. Empty
// (the zero SecretRef) disables signature validation, so any unsigned
// POST is accepted -- set this to make the gateway actually verify
// what it claims to.
Secret SecretRef `toml:"secret" yaml:"secret"`
// Template extracts the message text from the JSON payload via
// dot-notation (e.g. "issue.title"). Empty uses the raw body.
Template string `toml:"template" yaml:"template"`
// DeliverTo routes replies: "origin" sends the reply back as the HTTP
// response; empty sends no reply.
DeliverTo string `toml:"deliver_to" yaml:"deliver_to"`
}
// Notify configures outbound notifications (n8n webhook → email etc.).
type Notify struct {
// Webhook receives JSON POSTs for events that need a human. Empty disables.
@@ -83,8 +83,7 @@ func RuntimeChatConfigFrom(ctx context.Context, reader ResourceReader, base conf
check, install := base.Telegram.UpdateCheckCommand, base.Telegram.UpdateInstallCommand
out = config.ChatConfig{
Operator: settings.Operator, ShowToolCalls: settings.ShowToolCalls, MaxSteps: settings.MaxSteps,
Models: settings.Models, Email: config.EmailConfig{ListenAddr: settings.Email.ListenAddr, RelayAddr: settings.Email.RelayAddr}, WebhookAddr: settings.WebhookAddr,
Webhook: config.WebhookRoute{Path: settings.Webhook.Path, Secret: settings.Webhook.Secret, Template: settings.Webhook.Template, DeliverTo: settings.Webhook.DeliverTo},
Models: settings.Models,
Telegram: config.TelegramConfig{AllowedUserIDs: settings.Telegram.AllowedUserIDs, Token: settings.Telegram.Token, UpdateCheckCommand: check, UpdateInstallCommand: install},
RateLimit: config.RateLimitConfig{Window: time.Duration(settings.RateLimit.Window), MaxRequests: settings.RateLimit.MaxRequests},
UnrestrictedFilesystem: settings.UnrestrictedFilesystem, Workspace: settings.Workspace,
@@ -12,17 +12,14 @@ import (
// ChannelSettings is the channel-settings resource document, with
// snake_case JSON keys.
type ChannelSettings struct {
Operator string `json:"operator"`
ShowToolCalls bool `json:"show_tool_calls"`
MaxSteps int `json:"max_steps"`
Models []string `json:"models"`
Email EmailSettings `json:"email"`
WebhookAddr string `json:"webhook_addr"`
Webhook WebhookChannelSettings `json:"webhook"`
Telegram TelegramSettings `json:"telegram"`
RateLimit RateLimitSettings `json:"rate_limit"`
UnrestrictedFilesystem bool `json:"unrestricted_filesystem"`
Workspace string `json:"workspace"`
Operator string `json:"operator"`
ShowToolCalls bool `json:"show_tool_calls"`
MaxSteps int `json:"max_steps"`
Models []string `json:"models"`
Telegram TelegramSettings `json:"telegram"`
RateLimit RateLimitSettings `json:"rate_limit"`
UnrestrictedFilesystem bool `json:"unrestricted_filesystem"`
Workspace string `json:"workspace"`
}
type TelegramSettings struct {
@@ -31,39 +28,9 @@ type TelegramSettings struct {
CredentialConfigured bool `json:"credential_configured"`
}
type WebhookChannelSettings struct {
Path string `json:"path"`
Secret config.SecretRef `json:"secret_ref"`
CredentialConfigured bool `json:"credential_configured"`
Template string `json:"template"`
DeliverTo string `json:"deliver_to"`
}
// EmailSettings is the email object. It reads the Go-cased keys an earlier
// revision stored as well as its own, because json tags alone would not: the
// decoder's case-insensitive fallback compares whole keys, so "ListenAddr"
// never matches "listen_addr".
type EmailSettings struct {
ListenAddr string `json:"listen_addr"`
RelayAddr string `json:"relay_addr"`
}
func (e *EmailSettings) UnmarshalJSON(data []byte) error {
type document EmailSettings
var decoded document
err := DecodeRenamingLegacyKeys(data, map[string]string{
"ListenAddr": "listen_addr",
"RelayAddr": "relay_addr",
}, &decoded)
if err != nil {
return err
}
*e = EmailSettings(decoded)
return nil
}
// RateLimitSettings is the inbound rate-limit object, and it reads the Go-cased
// keys for the reason EmailSettings does.
// keys: the decoder's case-insensitive fallback compares whole keys, so "MaxRequests"
// never matches "max_requests".
type RateLimitSettings struct {
Window ChannelDuration `json:"window"`
MaxRequests int `json:"max_requests"`
+66 -66
View File
@@ -2,73 +2,73 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HarnessPage.js"
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var r={},i=[],a=()=>{},o=()=>!1,s=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),c=e=>e.startsWith(`onUpdate:`),l=Object.assign,u=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},d=Object.prototype.hasOwnProperty,f=(e,t)=>d.call(e,t),p=Array.isArray,m=e=>w(e)===`[object Map]`,h=e=>w(e)===`[object Set]`,g=e=>w(e)===`[object Date]`,_=e=>w(e)===`[object RegExp]`,v=e=>typeof e==`function`,y=e=>typeof e==`string`,b=e=>typeof e==`symbol`,x=e=>typeof e==`object`&&!!e,S=e=>(x(e)||v(e))&&v(e.then)&&v(e.catch),C=Object.prototype.toString,w=e=>C.call(e),ee=e=>w(e).slice(8,-1),te=e=>w(e)===`[object Object]`,ne=e=>y(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,re=n(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ie=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},ae=/-\w/g,oe=ie(e=>e.replace(ae,e=>e.slice(1).toUpperCase())),se=/\B([A-Z])/g,ce=ie(e=>e.replace(se,`-$1`).toLowerCase()),le=ie(e=>e.charAt(0).toUpperCase()+e.slice(1)),ue=ie(e=>e?`on${le(e)}`:``),T=(e,t)=>!Object.is(e,t),de=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},fe=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},pe=e=>{let t=parseFloat(e);return isNaN(t)?e:t},me=e=>{let t=y(e)?Number(e):NaN;return isNaN(t)?e:t},he,ge=()=>he||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},_e=n(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function ve(e){if(p(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=y(r)?Se(r):ve(r);if(i)for(let e in i)t[e]=i[e]}return t}if(y(e)||x(e))return e}var ye=/;(?![^(]*\))/g,be=/:([^]+)/,xe=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function Se(e){let t={};return e.replace(xe,e=>e.startsWith(`/*`)?``:e).split(ye).forEach(e=>{if(e){let n=e.split(be);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function E(e){let t=``;if(y(e))t=e;else if(p(e))for(let n=0;n<e.length;n++){let r=E(e[n]);r&&(t+=r+` `)}else if(x(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function Ce(e){if(!e)return null;let{class:t,style:n}=e;return t&&!y(t)&&(e.class=E(t)),n&&(e.style=ve(n)),e}var we=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,Te=n(we);we+``;function Ee(e){return!!e||e===``}function De(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=je(e[i],t[i],n);return r}function Oe(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&je(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function ke(e,t,n){let r=m(e),i=m(t);if(r||i||(r=h(e),i=h(t),r||i))return r&&i?Oe(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!je(e[r],t[r],n))return!1}return String(e)===String(t)}function Ae(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function je(e,t,n){if(e===t)return!0;let r=g(e),i=g(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=b(e),i=b(t),r||i?e===t:(r=p(e),i=p(t),r||i?r&&i?Ae(e,t,n,De):!1:(r=x(e),i=x(t),r||i?!r||!i?!1:Ae(e,t,n,ke):String(e)===String(t))))}function Me(e,t){return e.findIndex(e=>je(e,t))}var Ne=e=>!!(e&&e.__v_isRef===!0),D=e=>y(e)?e:e==null?``:p(e)||x(e)&&(e.toString===C||!v(e.toString))?Ne(e)?D(e.value):JSON.stringify(e,Pe,2):String(e),Pe=(e,t)=>Ne(t)?Pe(e,t.value):m(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[Fe(t,r)+` =>`]=n,e),{})}:h(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>Fe(e))}:b(t)?Fe(t):x(t)&&!p(t)&&!te(t)?String(t):t,Fe=(e,t=``)=>b(e)?`Symbol(${e.description??t})`:e;function Ie(e){return e==null?`initial`:tyLine truncated
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
`)&&(ki(e,0)||yi(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||s(a)&&!re(a)||a[0]===`.`||t&&!re(a)||u&&u.includes(a)){if(Ei(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&cn(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&Ms(x,n,t),h&&wr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&cs(()=>{x&&Ms(x,n,t),l&&g.enter(e),h&&wr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=ks(d[t]),g=h.type===ds;e?(g&&!u&&t+1<p&&ks(d[t+1]).type===ds&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,ki(r,1)||yi()),n(null,h,r,null,o,s,Si(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&Ci(f)&&f.data===`]`?a(t.anchor=f):(yi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(ji(e,t)||yi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,Si(d),s),r&&(r.vnode.el=t.el,xo(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&Ci(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var Ti=new Set([`src`,`srcset`,`href`,`poster`]);function Ei(e,t,n){return Ti.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var Di=`data-allow-mismatch`,Oi={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function ki(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(Di);)e=e.parentElement;return Ai(e&&e.getAttribute(Di),t)}function Ai(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(Oi[t])}}function ji(e,t){return ki(e.parentElement,1)||Mi(e)||Ni(t)}function Mi(e){return e.nodeType===1&&Ai(e.getAttribute(Di),1)}function Ni({props:e}){let t=e&&e[Di];return typeof t==`string`&&Ai(t,1)}var Pi=ge().requestIdleCallback||(e=>setTimeout(e,1)),Fi=ge().cancelIdleCallback||(e=>clearTimeout(e)),Ii=(e=1e4)=>t=>{let n=Pi(t,{timeout:e});return()=>Fi(n)};function Li(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var Ri=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(Li(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},zi=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},Bi=(e=[])=>(t,n)=>{y(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Vi(e,t){if(Ci(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(Ci(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Hi=e=>!!e.type.__asyncLoader;function Ui(e){v(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return M({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Vi(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=Is;if(fi(e),u)return()=>Wi(u,e);let t=t=>{l=null,Xn(t,e,13,!r)};if(s&&e.suspense||Us)return p().then(t=>()=>Wi(t,e)).catch(e=>(t(e),()=>r?V(r,{error:e}):null));let a=O(!1),c=O(),d=O(!!i),f,m;return oa(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&Gi(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Wi(u,e);if(c.value&&r)return V(r,{error:c.value});if(n&& Line truncated
`))),e[Wl]=Vl(i);let a=r||i.props&&i.props.type===`number`;cl(e,t?`change`:`input`,t=>{t.target.composing||e[Wl](Kl(e.value,n,a))}),(n||a)&&cl(e,`change`,()=>{e.value=Kl(e.value,n,a)}),t||(cl(e,`compositionstart`,Hl),cl(e,`compositionend`,Ul),cl(e,`change`,Ul))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[Gl];delete e[Gl],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Wl](Kl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Wl]=Vl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?pe(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Jl={deep:!0,created(e,t,n){e[Wl]=Vl(n),cl(e,`change`,()=>{let t=e._modelValue,n=eu(e),r=e.checked,i=e[Wl];if(p(t)){let e=Me(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(tu(e,r))})},mounted:Yl,beforeUpdate(e,t,n){e[Wl]=Vl(n),Yl(e,t,n)}};function Yl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=Me(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=je(t,tu(e,!0))}e.checked!==i&&(e.checked=i)}var Xl={created(e,{value:t},n){e.checked=je(t,n.props.value),e[Wl]=Vl(n),cl(e,`change`,()=>{e[Wl](eu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Wl]=Vl(r),t!==n&&(e.checked=je(t,r.props.value))}},Zl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,cl(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?pe(eu(e)):eu(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Wl](i)}finally{ar(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Wl]=Vl(r)},mounted(e,{value:t}){$l(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Wl]=Vl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!Ql(t,n[1],n[0]))&&$l(e,t)}};function Ql(e,t,n){if(!n||p(e))return je(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function $l(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=eu(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Me(t,o)>-1}else a.selected=t.has(o)}else if(je(eu(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function eu(e){return`_value`in e?e._value:e.value}function tu(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var nu={created(e,t,n){iu(e,t,n,null,`created`)},mounted(e,t,n){iu(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){iu(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){iu(e,t,n,r,`updated`)}};function ru(e,t){switch(e){case`SELECT`:return Zl;case`TEXTAREA`:return ql;default:switch(t){case`checkbox`:return Jl;case`radio`:return Xl;default:return ql}}}function iu(e,t,n,r,i){let a=ru(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function au(){ql.getSSRProps=({value:e})=>({value:e}),Xl.getSSRProps=({value:e},t)=>{if(t.props&&je(t.props.value,e))return{checked:!0}},Jl.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&Me(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},nu.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=ru(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var ou=[`ctrl`,`shift`,`alt`,`meta`],su={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)=>ou.some(n=>e[`${n}Key`]&&!t.includes(n))},cu=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=su[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},lu={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},uu=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=ce(n.key);if(t.some(e=>e===r||lu[e]===r))return e(n)}))},du=l({patchProp:bl},bc),fu,pu=!1;function mu(){return fu||=Vo(du)}function hu(){return fu=pu?fu:Ho(du),pu=!0,fu}var gu=((...e)=>{mu().render(...e)}),_u=((...e)=>{hu().hydrate(...e)}),vu=((...e)=>{let t=mu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=xu(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,bu(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),yu=(( Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var qp;function Jp(e){qp=e}var Yp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Xp(e){let t=e instanceof Yp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Zp(e,t){let n=await fetch(e,t);if(qp?.(n.status===401),!n.ok)throw new Yp(await Kp(n),n.status);return n}async function Qp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Wp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Zp(e,s);return a?await c.json():void 0}var q={health:()=>Qp(`/health/detailed`),services:()=>Qp(`/api/services`),policies:()=>Qp(`/api/access/policies`),putPolicy:e=>Qp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Qp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),summary:()=>Qp(`/api/summary`),tasks:()=>Qp(`/api/tasks`),taskMeta:()=>Qp(`/api/task-meta`),task:e=>Qp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Qp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Qp(`/api/tasks/${encodeURIComponent(e)}/changes`+Gp(t)),taskDebug:(e,t)=>Qp(`/api/tasks/${encodeURIComponent(e)}/debug`+Gp(t)),taskAction:(e,t,n)=>Qp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Qp(`/api/setup`),capabilities:()=>Qp(`/api/capabilities`),workflows:()=>Qp(`/api/workflows`),workflowEnabled:(e,t)=>Qp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Qp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Qp(`/api/skills`),channels:()=>Qp(`/api/channels`),curators:()=>Qp(`/api/curators`),channelReload:e=>Qp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Qp(`/api/config`),logs:e=>Qp(`/api/logs`+Gp(e)),taskLogs:(e,t)=>Qp(`/api/tasks/${encodeURIComponent(e)}/logs`+Gp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Qp(`/api/version`),updateSnapshot:()=>Qp(`/api/chat/update`),updateInstall:e=>Qp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Qp(`/api/captures`+Gp({limit:e})),eventTypes:()=>Qp(`/api/event-types`),eventTypeCreate:e=>Qp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Qp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Qp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Qp(`/api/mappings`),mappingCreate:e=>Qp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Qp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Qp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Qp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Qp(`/api/bindings`),bindingCreate:e=>Qp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Qp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Qp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Qp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),harnessBindings:()=>Qp(`/api/harness/bindings`),sources:()=>Qp(`/api/sources`),sourceCreate:e=>Qp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Qp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Qp(`/api/sources/${encodeURIComponent(e)}/approve-unsigned`,{method:`POST`}),sourceSecret:e=>Qp(`/api/sources/${encodeURIComponent(e)}/secret`,{method:`POST`}),chatSessions:()=>Qp(`/api/chat/sessions`),chatMessages:e=>Qp(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Qp(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Qp(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Qp(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Up(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Qp(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Qp(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Qp(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Qp(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Zp(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function $p(e,t,n=``,r=!1){let i=new EventSource(Hp(n,r));return i.onopen=()=>t(`liLine truncated
`))),e[Wl]=Vl(i);let a=r||i.props&&i.props.type===`number`;cl(e,t?`change`:`input`,t=>{t.target.composing||e[Wl](Kl(e.value,n,a))}),(n||a)&&cl(e,`change`,()=>{e.value=Kl(e.value,n,a)}),t||(cl(e,`compositionstart`,Hl),cl(e,`compositionend`,Ul),cl(e,`change`,Ul))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[Gl];delete e[Gl],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Wl](Kl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Wl]=Vl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?pe(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Jl={deep:!0,created(e,t,n){e[Wl]=Vl(n),cl(e,`change`,()=>{let t=e._modelValue,n=eu(e),r=e.checked,i=e[Wl];if(p(t)){let e=Me(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(tu(e,r))})},mounted:Yl,beforeUpdate(e,t,n){e[Wl]=Vl(n),Yl(e,t,n)}};function Yl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=Me(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=je(t,tu(e,!0))}e.checked!==i&&(e.checked=i)}var Xl={created(e,{value:t},n){e.checked=je(t,n.props.value),e[Wl]=Vl(n),cl(e,`change`,()=>{e[Wl](eu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Wl]=Vl(r),t!==n&&(e.checked=je(t,r.props.value))}},Zl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,cl(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?pe(eu(e)):eu(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Wl](i)}finally{ar(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Wl]=Vl(r)},mounted(e,{value:t}){$l(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Wl]=Vl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!Ql(t,n[1],n[0]))&&$l(e,t)}};function Ql(e,t,n){if(!n||p(e))return je(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function $l(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=eu(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Me(t,o)>-1}else a.selected=t.has(o)}else if(je(eu(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function eu(e){return`_value`in e?e._value:e.value}function tu(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var nu={created(e,t,n){iu(e,t,n,null,`created`)},mounted(e,t,n){iu(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){iu(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){iu(e,t,n,r,`updated`)}};function ru(e,t){switch(e){case`SELECT`:return Zl;case`TEXTAREA`:return ql;default:switch(t){case`checkbox`:return Jl;case`radio`:return Xl;default:return ql}}}function iu(e,t,n,r,i){let a=ru(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function au(){ql.getSSRProps=({value:e})=>({value:e}),Xl.getSSRProps=({value:e},t)=>{if(t.props&&je(t.props.value,e))return{checked:!0}},Jl.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&Me(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},nu.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=ru(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var ou=[`ctrl`,`shift`,`alt`,`meta`],su={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)=>ou.some(n=>e[`${n}Key`]&&!t.includes(n))},cu=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=su[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},lu={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},uu=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=ce(n.key);if(t.some(e=>e===r||lu[e]===r))return e(n)}))},du=l({patchProp:bl},bc),fu,pu=!1;function mu(){return fu||=Vo(du)}function hu(){return fu=pu?fu:Ho(du),pu=!0,fu}var gu=((...e)=>{mu().render(...e)}),_u=((...e)=>{hu().hydrate(...e)}),vu=((...e)=>{let t=mu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=xu(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,bu(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),yu=(( Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Wp;function Gp(e){Wp=e}var Kp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function qp(e){let t=e instanceof Kp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Jp(e,t){let n=await fetch(e,t);if(Wp?.(n.status===401),!n.ok)throw new Kp(await Up(n),n.status);return n}async function Yp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Vp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Jp(e,s);return a?await c.json():void 0}var J={health:()=>Yp(`/health/detailed`),services:()=>Yp(`/api/services`),policies:()=>Yp(`/api/access/policies`),putPolicy:e=>Yp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Yp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),summary:()=>Yp(`/api/summary`),tasks:()=>Yp(`/api/tasks`),taskMeta:()=>Yp(`/api/task-meta`),task:e=>Yp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Yp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Yp(`/api/tasks/${encodeURIComponent(e)}/changes`+Hp(t)),taskDebug:(e,t)=>Yp(`/api/tasks/${encodeURIComponent(e)}/debug`+Hp(t)),taskAction:(e,t,n)=>Yp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Yp(`/api/setup`),capabilities:()=>Yp(`/api/capabilities`),workflows:()=>Yp(`/api/workflows`),workflowEnabled:(e,t)=>Yp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Yp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Yp(`/api/skills`),channels:()=>Yp(`/api/channels`),curators:()=>Yp(`/api/curators`),channelReload:e=>Yp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Yp(`/api/config`),logs:e=>Yp(`/api/logs`+Hp(e)),taskLogs:(e,t)=>Yp(`/api/tasks/${encodeURIComponent(e)}/logs`+Hp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Yp(`/api/version`),updateSnapshot:()=>Yp(`/api/chat/update`),updateInstall:e=>Yp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Yp(`/api/captures`+Hp({limit:e})),eventTypes:()=>Yp(`/api/event-types`),eventTypeCreate:e=>Yp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Yp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Yp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Yp(`/api/mappings`),mappingCreate:e=>Yp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Yp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Yp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Yp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Yp(`/api/bindings`),bindingCreate:e=>Yp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Yp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Yp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Yp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),harnessBindings:()=>Yp(`/api/harness/bindings`),sources:()=>Yp(`/api/sources`),sourceCreate:e=>Yp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Yp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Yp(`/api/sources/${encodeURIComponent(e)}/approve-unsigned`,{method:`POST`}),sourceSecret:e=>Yp(`/api/sources/${encodeURIComponent(e)}/secret`,{method:`POST`}),chatSessions:()=>Yp(`/api/chat/sessions`),chatMessages:e=>Yp(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Yp(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Yp(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Yp(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Bp(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Yp(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatDangerous:()=>Yp(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Yp(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Yp(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Jp(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Xp(e,t,n=``,r=!1){let i=new EventSource(zp(n,r));return i.onopen=()=>t(`liLine truncated
`);u=r.pop()||``;for(let e of r){let t=e.split(`
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(mm.value=n.session_id),n.type===`delta`&&(o+=n.text,ym.value=ym.value?{...ym.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],ym.value=ym.value?{...ym.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);hm.value=[...hm.value,{from:`assistant`,text:o,tool_calls:a}],ym.value=null,_m.value=`Ready`,await Pm()}catch(e){let t=e;t.name===`AbortError`&&!c?(ym.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},_m.value=`Stopped`):(ym.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?lm(r):void 0,isRetry:i},_m.value=`Error — retry available`)}finally{clearTimeout(l),Mm=null,vm.value=!1}}function qm(){_m.value=`Stopping…`,mm.value&&q.chatCancel(mm.value).catch(()=>{}),Nm()}function Jm(){N(()=>{Pm().catch(e=>{_m.value=e.message||`Chat unavailable`})}),oa(()=>{Nm()})}var Ym=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Xm=M({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return K(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(L(),R(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":k(dm),onClick:i[0]||=e=>n(`toggle`)},[B(`span`,{"aria-hidden":`true`,class:E(r(!e.open))},[V(k(Bd),{size:22})],2),B(`span`,{"aria-hidden":`true`,class:E(r(e.open))},[V(k(lf),{size:22})],2)],8,Ym))}});function Zm(e){return typeof e==`string`?`'${e}'`:new th().serialize(e)}var Qm=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,$m=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Qm.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function eh(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&$m[n]?$m[n]:n+128,s=a<128&&$m[a]?$m[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var th=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?eh(e,t):n===`number`&&r===`number`?e-t:eh(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(eh),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`]) Line truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(dm.value=n.session_id),n.type===`delta`&&(o+=n.text,gm.value=gm.value?{...gm.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],gm.value=gm.value?{...gm.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);fm.value=[...fm.value,{from:`assistant`,text:o,tool_calls:a}],gm.value=null,mm.value=`Ready`,await jm()}catch(e){let t=e;t.name===`AbortError`&&!c?(gm.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},mm.value=`Stopped`):(gm.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?om(r):void 0,isRetry:i},mm.value=`Error — retry available`)}finally{clearTimeout(l),km=null,hm.value=!1}}function Wm(){mm.value=`Stopping…`,dm.value&&J.chatCancel(dm.value).catch(()=>{}),Am()}function Gm(){N(()=>{jm().catch(e=>{mm.value=e.message||`Chat unavailable`})}),oa(()=>{Am()})}var Km=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],qm=M({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return q(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(L(),R(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":k(cm),onClick:i[0]||=e=>n(`toggle`)},[B(`span`,{"aria-hidden":`true`,class:E(r(!e.open))},[V(k(Rd),{size:22})],2),B(`span`,{"aria-hidden":`true`,class:E(r(e.open))},[V(k(sf),{size:22})],2)],8,Km))}});function Jm(e){return typeof e==`string`?`'${e}'`:new Qm().serialize(e)}var Ym=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Xm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Ym.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Zm(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Xm[n]?Xm[n]:n+128,s=a<128&&Xm[a]?Xm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var Qm=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Zm(e,t):n===`number`&&r===`number`?e-t:Zm(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Zm),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`]) Line truncated
`)].join(`
`))}return()=>i.value||r.value||o.value?rc(t.default({present:o.value})[0],{ref:e=>{let t=Nh(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),Qg=M({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=Yh(n.default()),r=e.findIndex(e=>e.type!==fs);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?W(t,i.props):t,o=Ds({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),$g=[`area`,`img`,`input`],Y=M({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&$g.includes(r)?()=>rc(r,t):r===`template`?()=>rc(Qg,t,{default:n.default}):()=>rc(e.as,t,{default:n.default})}});function e_(){let e=O();return{primitiveElement:e,currentElement:G(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Nh(e))}}var[t_,n_]=oh(`CollapsibleRoot`),r_=M({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=Jh(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=En(r);return n_({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),J(),(e,t)=>(L(),z(k(Y),{as:e.as,"as-child":r.asChild,"data-state":k(i)?`open`:`closed`,"data-disabled":k(a)?``:void 0},{default:A(()=>[F(e.$slots,`default`,{open:k(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),i_=M({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=t_();i.contentId||=Vg(void 0,`reka-collapsible-content`);let a=O(),{forwardRef:o,currentElement:s}=J(),c=O(0),l=O(0),u=G(()=>i.open.value),d=O(u.value),f=O();j(()=>[u.value,a.value?.present],async()=>{await ar();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=G(()=>d.value&&i.open.value);return N(()=>{requestAnimationFrame(()=>{d.value=!1})}),Ph(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(L(),z(k(Zg),{ref_key:`presentRef`,ref:a,present:e.forceMount||k(i).open.value,"force-mount":!0},{default:A(({present:t})=>[V(k(Y),W(e.$attrs,{id:k(i).contentId,ref:k(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:k(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:k(i).open.value?`open`:`closed`,"data-disabled":k(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:A(()=>[!k(i).unmountOnHide.value||t?F(e.$slots,`default`,{key:0}):U(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),a_=M({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;J();let n=t_();return(e,r)=>(L(),z(k(Y),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":k(n).contentId,"aria-expanded":k(n).open.value,"data-state":k(n).open.value?`open`:`closed`,"data-disabled":k(n).disabled?.value?``:void 0,disabled:k(n).disabled?.value,onClick:k(n).onOpenToggle},{default:A(()=>[F(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function o_({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function s_({type:e,defaultValue:t,modelValue:n}){return e||o_({type:e,defaultValue:t,modelValue:n})}function c_({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function l_(e,t){let n=G(()=>s_(e)),r=Jh(e,`modelValue`,t,{defaultValue:c_(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=nh(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(uh(t,e)){let n=t.findIndex(t=>nh(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:G(()=>n.value===`single`)}}var[u_,d_]=oh(`AccordionRoot`),f_=M({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:!1,def Line truncated
`))}return()=>i.value||r.value||o.value?rc(t.default({present:o.value})[0],{ref:e=>{let t=Ah(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),Yg=M({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=Kh(n.default()),r=e.findIndex(e=>e.type!==fs);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?W(t,i.props):t,o=Ds({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Xg=[`area`,`img`,`input`],X=M({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Xg.includes(r)?()=>rc(r,t):r===`template`?()=>rc(Yg,t,{default:n.default}):()=>rc(e.as,t,{default:n.default})}});function Zg(){let e=O();return{primitiveElement:e,currentElement:G(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Ah(e))}}var[Qg,$g]=rh(`CollapsibleRoot`),e_=M({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=Gh(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=En(r);return $g({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Y(),(e,t)=>(L(),z(k(X),{as:e.as,"as-child":r.asChild,"data-state":k(i)?`open`:`closed`,"data-disabled":k(a)?``:void 0},{default:A(()=>[F(e.$slots,`default`,{open:k(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),t_=M({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=Qg();i.contentId||=Rg(void 0,`reka-collapsible-content`);let a=O(),{forwardRef:o,currentElement:s}=Y(),c=O(0),l=O(0),u=G(()=>i.open.value),d=O(u.value),f=O();j(()=>[u.value,a.value?.present],async()=>{await ar();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=G(()=>d.value&&i.open.value);return N(()=>{requestAnimationFrame(()=>{d.value=!1})}),jh(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(L(),z(k(Jg),{ref_key:`presentRef`,ref:a,present:e.forceMount||k(i).open.value,"force-mount":!0},{default:A(({present:t})=>[V(k(X),W(e.$attrs,{id:k(i).contentId,ref:k(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:k(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:k(i).open.value?`open`:`closed`,"data-disabled":k(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:A(()=>[!k(i).unmountOnHide.value||t?F(e.$slots,`default`,{key:0}):U(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),n_=M({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Y();let n=Qg();return(e,r)=>(L(),z(k(X),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":k(n).contentId,"aria-expanded":k(n).open.value,"data-state":k(n).open.value?`open`:`closed`,"data-disabled":k(n).disabled?.value?``:void 0,disabled:k(n).disabled?.value,onClick:k(n).onOpenToggle},{default:A(()=>[F(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function r_({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function i_({type:e,defaultValue:t,modelValue:n}){return e||r_({type:e,defaultValue:t,modelValue:n})}function a_({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function o_(e,t){let n=G(()=>i_(e)),r=Gh(e,`modelValue`,t,{defaultValue:a_(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=$m(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(sh(t,e)){let n=t.findIndex(t=>$m(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:G(()=>n.value===`single`)}}var[s_,c_]=rh(`AccordionRoot`),l_=M({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:!1,def Line truncated
- a positive number
- less than the value passed to \`max\` (or ${IS} if no \`max\` prop is set)
- less than the value passed to \`max\` (or ${NS} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`),null)}function VS(e){return zS(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${IS}\`.`),IS)}var HS=M({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:IS},getValueLabel:{type:Function,required:!1,default:(e,t)=>zS(e)?`${Math.round(e/t*IS)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;J();let i=Jh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Jh(n,`max`,r,{passive:n.max===void 0});j(()=>i.value,async e=>{let t=BS(e,n.max);t!==e&&(await ar(),i.value=t)},{immediate:!0}),j(()=>n.max,e=>{let t=VS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=G(()=>lh(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return RS({modelValue:i,max:a,progressState:o}),(e,t)=>(L(),z(k(Y),{"as-child":e.asChild,as:e.as,"aria-valuemax":k(a),"aria-valuemin":0,"aria-valuenow":zS(k(i))?k(i):void 0,"aria-valuetext":e.getValueText?.(k(i),k(a)),"aria-label":e.getValueLabel(k(i),k(a)),role:`progressbar`,"data-state":o.value,"data-value":k(i)??void 0,"data-max":k(a)},{default:A(()=>[F(e.$slots,`default`,{modelValue:k(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),US=M({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=LS();return J(),(e,r)=>(L(),z(k(Y),W(t,{"data-state":k(n).progressState.value,"data-value":k(n).modelValue?.value??void 0,"data-max":k(n).max.value}),{default:A(()=>[F(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),WS=`radio.select`;function GS(e,t,n){ch(WS,n,{originalEvent:e,value:t})}var KS=M({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=Jh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=En(n),{forwardRef:o,currentElement:s}=J(),c=yg(s),l=Sg(),u=G(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||GS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(L(),R(I,null,[V(k(Y),W({id:e.id,ref:k(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":k(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":k(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:k(a),required:e.required,name:e.name},{...k(l),...e.$attrs},{onClick:cu(d,[`stop`])}),{default:A(()=>[F(e.$slots,`default`,{checked:k(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),k(c)&&e.name?(L(),z(k(Ev),W({key:0,type:`radio`,tabindex:`-1`,value:k(a),checked:!!k(i),name:e.name,disabled:e.disabled,required:e.required},k(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):U(`v-if`,!0)],64))}}),[qS,JS]=oh(`RadioGroupRoot`),YS=M({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=J(),o=Jh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=En(n),p=mg(f),m=yg(a);return JS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(L(),z(k(cx),{"as-child":``,orientation:k(l),dir:k(p),loop:k(c)},{default:A(()=>[V(k(Y),{ref:k(i),role:`radiogroup`,"data-disabled":k(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":k(l),"aria-required":k(d),dir:k(p)},{default:A(()=>[F(e.$slots,`default`,{modelValue:k(o)}),k(m)&&k(u)?(L(),z(k(Ev),{key:0,required:k(d),disabled:k(s),value:k(o),name:k(u)},null,8,[`required`,`disabled`,`value`,`name`])):U(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[XS,ZS]=oh(`RadioGroupItem`),QS=M({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:null,reLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:qE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>qE(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=YE(c),u=e+1<n.length?YE(n[e+1]):null;if(l&&u&&XE(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=YE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>qE(e)),rows:r.map(e=>e.map(e=>qE(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:qE(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:qE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function YE(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function XE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var ZE={class:`[overflow-wrap:anywhere]`},QE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},$E={class:`font-mono text-[0.85em]`},eD={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},tD={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},nD={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},rD={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},iD={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},aD={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},oD={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},sD={key:8,class:`mb-2.5 last:mb-0`},cD=M({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>JE(t.text));return(e,t)=>(L(),R(`div`,ZE,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,QE,[B(`code`,$E,D(e.code),1)])):e.kind===`table`?(L(),R(`table`,eD,[B(`thead`,null,[B(`tr`,null,[(L(!0),R(I,null,P(e.head,(e,t)=>(L(),R(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[V(GE,{inline:e},null,8,[`inline`])]))),128))])]),B(`tbody`,null,[(L(!0),R(I,null,P(e.rows,(e,t)=>(L(),R(`tr`,{key:t},[(L(!0),R(I,null,P(e,(e,t)=>(L(),R(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[V(GE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,tD,[V(GE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,nD,[V(GE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,rD,[V(GE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,iD,[V(GE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,aD,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(GE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,oD,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(GE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,sD,[V(GE,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),lD={class:`truncate`},uD=M({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=pa(`RouterLink`);return L(),z(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:A(()=>[V(k(yd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),B(`span`,lD,D(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),dD={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},fD={class:`font-semibold text-foreground`},pD={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},mD=M({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=G(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=G(()=>t.tool.parameters||t.tool.Parameters||``),i=G(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=G(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(L(),z(uD,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,dD,[V(k(cf),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,fD,D(n.value),1),r.value?(L(),R(`code`,pD,D(r.value),1)):U(``,!0),B(`span`,{class:E(k(K)(`text-fg-muted`,i.value&&`text-danger`))},D(a.value),3)]))}}),hD={key:0,class:`mb-2 grid gap-0.5 text-xs`},gD={key:1,class:`mb-2 flex flex-wrap gap-1.5`},_D={key:3,class:`whitespace-pre-wrap`},vD=M({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),R(`div`,{class:E([`flex`,e.assistant?`justify-start`:`justify-end`])},[B(`div`,{class:E(k(K)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(L(),R(`div`,hD,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(mD,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.media.length?(L(),R(`div`,gD,[(L(!0),R(I,null,P(e.media,(e,t)=>(L(),z(RE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):U(``,!0),e.assistant?(L(),z(cD,{key:2,text:e.text},null,8,[`text`])):(L(),R(`div`,_D,D(e.text),1)),F(t.$slots,`default`)],2)],2))}}),yD={class:`w-full self-center justify-self-center py-6 text-center`},bD={class:`grid gap-2`},xD=[`onClick`],SD=M({__name:`ChatEmptyState`,emits:[`proLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>WM?`${n.slice(0,WM).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var KM=[`title`],qM=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>yM(n.event)),a=G(()=>GM(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?Dj(n.event.at):`—`);return(e,t)=>(L(),z(k(HM),{class:E(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[uu(cu(o,[`prevent`]),[`enter`]),uu(cu(o,[`prevent`]),[`space`])]},{default:A(()=>[V(k(Q),{class:`font-medium`},{default:A(()=>[H(D(n.event.kind||n.event.type||`event`),1)]),_:1}),V(k(Q),{class:`font-mono`},{default:A(()=>[H(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,KM)]),_:1}),V(k(Q),null,{default:A(()=>[H(D(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),JM=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function YM(e){return(Number(e?.task_id)||0)>0}function XM(e,t){return t===`tasks`?YM(e):t!==`system`||!YM(e)}function ZM(e,t){return e.filter(e=>XM(e,t))}function QM(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function $M(e,t){return`${e}:${t??0}`}function eN(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=$M(GM(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var tN={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},nN={class:`max-h-[28rem] overflow-y-auto`},rN=[`aria-expanded`,`aria-label`,`onClick`],iN=[`title`],aN=M({__name:`LiveActivityCard`,setup(e){let t=GD(),{activity:n,streamKind:r,streamState:i}=id(AA()),a=O(`all`),o=G(()=>ZM(n.value,a.value)),s=G(()=>QM(o.value.length,a.value)),c=nn(new Set),l=G(()=>eN(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return GM(e.representative)}function p(e){return e.representative.at?Dj(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(k(bj),null,{default:A(()=>[V(k(Tj),null,{default:A(()=>[V(k(Ej),null,{default:A(()=>[...t[1]||=[H(`Live activity`,-1)]]),_:1}),V(k(xj),{class:`flex items-center gap-2`},{default:A(()=>[V(k(nA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:k(JM)},null,8,[`modelValue`,`options`]),V(k(_j),{variant:k(r)},{default:A(()=>[H(D(k(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(k(Sj),null,{default:A(()=>[B(`div`,tN,[B(`div`,nN,[V(k(BM),null,{default:A(()=>[V(k(UM),{class:`sticky top-0 z-10 bg-card`},{default:A(()=>[V(k(HM),null,{default:A(()=>[V(k($),null,{default:A(()=>[...t[2]||=[H(`Event`,-1)]]),_:1}),V(k($),null,{default:A(()=>[...t[3]||=[H(`Task`,-1)]]),_:1}),V(k($),null,{default:A(()=>[...t[4]||=[H(`Detail`,-1)]]),_:1}),V(k($),null,{default:A(()=>[...t[5]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(k(VM),null,{default:A(()=>[o.value.length?U(``,!0):(L(),z(k(HM),{key:0},{default:A(()=>[V(k(Q),{colspan:`4`},{default:A(()=>[V(k(lj),null,{default:A(()=>[V(k(fj),null,{default:A(()=>[V(k(hj),null,{default:A(()=>[H(D(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(L(!0),R(I,{key:1},P(l.value,e=>(L(),R(I,{key:e.key},[e.count===1?(L(),z(qM,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(L(),R(I,{key:1},[V(k(HM),{class:E(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[uu(cu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),uu(cu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:A(()=>[V(k(Q),{class:`font-medium`},{default:A(()=>[B(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:cu(t=>u(e.key),[`stop`])},[d(e)?(L(),z(k(Cd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(L(),z(k(wd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),H(` `+D(e.label)+` `,1),V(k(_j),{variant:`idle`},{default:A(()=>[H(`×`+D(e.count),1)]),_:2},1024)],8,rN)]),_:2},1024),V(k(Q),{class:`font-mono`},{default:A(()=>[H(D(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),V(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[B(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},D(f(e).text),9,iN)]),_:2},1024),V(k(Q),null,{default:A(()=>[H(D(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(L(!0),R(I,{key:0},P(e.events,(t,n)=>(L(),z(qM,{key:`${e.key}:${n}`,event:t,onOpen: Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function SP(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function CP(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function wP(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function TP(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var EP=O([]),DP=O([]),OP=O(!0),kP=O(null),AP=O(null),jP=O(!1),MP=O(null);async function NP(){try{let e=await q.eventTypes();OP.value=e.enabled!==!1,EP.value=e.event_types||[],DP.value=e.proposals||[],kP.value=null}catch(e){kP.value=e.message||String(e)}}function PP(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function FP(e){MP.value=null,AP.value=e}function IP(e){let t=WP.value.find(t=>String(t.id)===e.sample_id);FP({mode:`proposal`,id:null,source:e.source,name:``,rule:PP(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function LP(e=``){FP({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function RP(e){FP({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:PP(e.rule),headersText:``,body:``,exampleHeaders:{}})}function zP(){AP.value=null}async function BP(){let e=AP.value;if(e){jP.value=!0;try{if(e.mode===`edit`&&e.id)await q.eventTypeUpdate(e.id,{name:e.name,rule:TP(e.rule)});else{let t=e.mode===`paste`?xP(e.headersText):e.exampleHeaders;await q.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:TP(e.rule),example:{headers:t,body:e.body}})}AP.value=null,await NP()}catch(e){MP.value=e.message||String(e)}finally{jP.value=!1}}}var VP=O(null);async function HP(){let e=VP.value;if(VP.value=null,e)try{await q.eventTypeDelete(e.id),await NP()}catch(e){kP.value=e.message||String(e)}}var UP=100,WP=O([]),GP=O(!0),KP=O(null),qP=O(!0),JP=O(null);async function YP(){try{let e=await q.captures(UP);GP.value=e.enabled!==!1,WP.value=e.captures||[],KP.value=null}catch(e){KP.value=e.message||String(e)}finally{qP.value=!1}}function XP(e){let t=WP.value.find(t=>t.id===e);return t&&(JP.value=t),!!t}function ZP(){WP.value.length&&(JP.value=WP.value[0])}function QP(){jA(`captures`,()=>{YP(),NP()})}var $P=`archie.theme`,eF=`archie.density`,tF=`archie.motion`,nF=`archie.tooltips`;function rF(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function iF(e,t){try{localStorage.setItem(e,t)}catch{}}function aF(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var oF=rd(`appearance`,()=>{let e=O(rF($P,[`system`,`dark`,`light`],`dark`)),t=O(rF(eF,[`comfortable`,`compact`],`comfortable`)),n=O(rF(tF,[`system`,`reduced`],`system`)),r=O(rF(nF,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=aF(e.value)}function o(t){e.value=t,a(),iF($P,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,iF(eF,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,iF(tF,e)}function l(e){r.value=e,iF(nF,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),sF=M({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=xg(n,t),{tooltipsEnabled:i}=id(oF());return(e,t)=>(L(),z(k(hw),W({"data-slot":`tooltip`},k(r),{disabled:n.disabled||!k(i)}),{default:A(t=>[F(e.$slots,`default`,Ce(Es(t)))]),_:3},16,[`disabled`]))}}),cF=M({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=xg(Fw(n,`class`),r);return(e,t)=>(L(),z(k(yw),null,{default:A( Line truncated
`)}};SJ.defaultYaml={explicit:!1,version:`1.2`},SJ.defaultTags={"!!":`tag:yaml.org,2002:`};function CJ(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function wJ(e){let t=new Set;return hJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function TJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function EJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=wJ(e);let a=TJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(sJ(t.node)||lJ(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function DJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=DJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=DJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=DJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=DJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function OJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>OJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!dJ(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var kJ=class{constructor(e){Object.defineProperty(this,nJ,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!iJ(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=OJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?DJ(i,{"":o},``,o):o}},AJ=class extends kJ{constructor(e){super(Xq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],hJ(e,{Node:(e,t)=>{(rJ(t)||dJ(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(OJ(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=jJ(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(CJ(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function jJ(e,t,n){if(rJ(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(lJ(t)){let r=0;for(let i of t.items){let t=jJ(e,i,n);t>r&&(r=t)}return r}if(oJ(t)){let r=jJ(e,t.key,n),i=jJ(e,t.value,n);return Math.max(r,i)}return 1}var MJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,NJ=class extends kJ{constructor(e){super(eJ),this.value=e}toJSON(e,t){return t?.keep?this.value:OJ(this.value,e,t)}toString(){return String(this.value)}};NJ.BLOCK_FOLDED=`BLOCK_FOLDED`,NJ.BLOCK_LITERAL=`BLOCK_LITERAL`,NJ.PLAIN=`PLAIN`,NJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,NJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var PJ=`tag:yaml.org,2002:`;function FJ(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function IJ(e,t,n){if(iJ(e)&&(e=e.contents),uJ(e))return e;if(oJ(e)){let t=n.schema[Qq].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new AJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=PJ+t.slice(2));let l=FJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new NJ(e);return c&&(c.node=t),t Line truncated
`)?VJ(n,t):n.includes(`
Defaulting to \`null\`.`),null)}function RS(e){return IS(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${NS}\`.`),NS)}var zS=M({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:NS},getValueLabel:{type:Function,required:!1,default:(e,t)=>IS(e)?`${Math.round(e/t*NS)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;Y();let i=Gh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Gh(n,`max`,r,{passive:n.max===void 0});j(()=>i.value,async e=>{let t=LS(e,n.max);t!==e&&(await ar(),i.value=t)},{immediate:!0}),j(()=>n.max,e=>{let t=RS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=G(()=>oh(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return FS({modelValue:i,max:a,progressState:o}),(e,t)=>(L(),z(k(X),{"as-child":e.asChild,as:e.as,"aria-valuemax":k(a),"aria-valuemin":0,"aria-valuenow":IS(k(i))?k(i):void 0,"aria-valuetext":e.getValueText?.(k(i),k(a)),"aria-label":e.getValueLabel(k(i),k(a)),role:`progressbar`,"data-state":o.value,"data-value":k(i)??void 0,"data-max":k(a)},{default:A(()=>[F(e.$slots,`default`,{modelValue:k(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),BS=M({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=PS();return Y(),(e,r)=>(L(),z(k(X),W(t,{"data-state":k(n).progressState.value,"data-value":k(n).modelValue?.value??void 0,"data-max":k(n).max.value}),{default:A(()=>[F(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),VS=`radio.select`;function HS(e,t,n){ah(VS,n,{originalEvent:e,value:t})}var US=M({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=Gh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=En(n),{forwardRef:o,currentElement:s}=Y(),c=gg(s),l=yg(),u=G(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||HS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(L(),R(I,null,[V(k(X),W({id:e.id,ref:k(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":k(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":k(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:k(a),required:e.required,name:e.name},{...k(l),...e.$attrs},{onClick:cu(d,[`stop`])}),{default:A(()=>[F(e.$slots,`default`,{checked:k(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),k(c)&&e.name?(L(),z(k(Cv),W({key:0,type:`radio`,tabindex:`-1`,value:k(a),checked:!!k(i),name:e.name,disabled:e.disabled,required:e.required},k(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):U(`v-if`,!0)],64))}}),[WS,GS]=rh(`RadioGroupRoot`),KS=M({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Y(),o=Gh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=En(n),p=dg(f),m=gg(a);return GS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(L(),z(k(ax),{"as-child":``,orientation:k(l),dir:k(p),loop:k(c)},{default:A(()=>[V(k(X),{ref:k(i),role:`radiogroup`,"data-disabled":k(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":k(l),"aria-required":k(d),dir:k(p)},{default:A(()=>[F(e.$slots,`default`,{modelValue:k(o)}),k(m)&&k(u)?(L(),z(k(Cv),{key:0,required:k(d),disabled:k(s),value:k(o),name:k(u)},null,8,[`required`,`disabled`,`value`,`name`])):U(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[qS,JS]=rh(`RadioGroupItem`),YS=M({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:null,reLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:WE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>WE(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=KE(c),u=e+1<n.length?KE(n[e+1]):null;if(l&&u&&qE(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=KE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>WE(e)),rows:r.map(e=>e.map(e=>WE(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:WE(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:WE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function KE(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function qE(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var JE={class:`[overflow-wrap:anywhere]`},YE={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},XE={class:`font-mono text-[0.85em]`},ZE={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},QE={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},$E={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},eD={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},tD={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},nD={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},rD={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},iD={key:8,class:`mb-2.5 last:mb-0`},aD=M({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>GE(t.text));return(e,t)=>(L(),R(`div`,JE,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,YE,[B(`code`,XE,D(e.code),1)])):e.kind===`table`?(L(),R(`table`,ZE,[B(`thead`,null,[B(`tr`,null,[(L(!0),R(I,null,P(e.head,(e,t)=>(L(),R(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[V(HE,{inline:e},null,8,[`inline`])]))),128))])]),B(`tbody`,null,[(L(!0),R(I,null,P(e.rows,(e,t)=>(L(),R(`tr`,{key:t},[(L(!0),R(I,null,P(e,(e,t)=>(L(),R(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[V(HE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,QE,[V(HE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,$E,[V(HE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,eD,[V(HE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,tD,[V(HE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,nD,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(HE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,rD,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(HE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,iD,[V(HE,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),oD={class:`truncate`},sD=M({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=pa(`RouterLink`);return L(),z(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:A(()=>[V(k(yd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),B(`span`,oD,D(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),cD={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},lD={class:`font-semibold text-foreground`},uD={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},dD=M({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=G(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=G(()=>t.tool.parameters||t.tool.Parameters||``),i=G(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=G(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(L(),z(sD,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,cD,[V(k(of),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,lD,D(n.value),1),r.value?(L(),R(`code`,uD,D(r.value),1)):U(``,!0),B(`span`,{class:E(k(q)(`text-fg-muted`,i.value&&`text-danger`))},D(a.value),3)]))}}),fD={key:0,class:`mb-2 grid gap-0.5 text-xs`},pD={key:1,class:`mb-2 flex flex-wrap gap-1.5`},mD={key:3,class:`whitespace-pre-wrap`},hD=M({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),R(`div`,{class:E([`flex`,e.assistant?`justify-start`:`justify-end`])},[B(`div`,{class:E(k(q)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(L(),R(`div`,fD,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(dD,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.media.length?(L(),R(`div`,pD,[(L(!0),R(I,null,P(e.media,(e,t)=>(L(),z(FE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):U(``,!0),e.assistant?(L(),z(aD,{key:2,text:e.text},null,8,[`text`])):(L(),R(`div`,mD,D(e.text),1)),F(t.$slots,`default`)],2)],2))}}),gD={class:`w-full self-center justify-self-center py-6 text-center`},_D={class:`grid gap-2`},vD=[`onClick`],yD=M({__name:`ChatEmptyState`,emits:[`proLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>HM?`${n.slice(0,HM).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var WM=[`title`],GM=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>gM(n.event)),a=G(()=>UM(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?wj(n.event.at):`—`);return(e,t)=>(L(),z(k(BM),{class:E(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[uu(cu(o,[`prevent`]),[`enter`]),uu(cu(o,[`prevent`]),[`space`])]},{default:A(()=>[V(k(Q),{class:`font-medium`},{default:A(()=>[H(D(n.event.kind||n.event.type||`event`),1)]),_:1}),V(k(Q),{class:`font-mono`},{default:A(()=>[H(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,WM)]),_:1}),V(k(Q),null,{default:A(()=>[H(D(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),KM=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function qM(e){return(Number(e?.task_id)||0)>0}function JM(e,t){return t===`tasks`?qM(e):t!==`system`||!qM(e)}function YM(e,t){return e.filter(e=>JM(e,t))}function XM(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function ZM(e,t){return`${e}:${t??0}`}function QM(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=ZM(UM(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var $M={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},eN={class:`max-h-[28rem] overflow-y-auto`},tN=[`aria-expanded`,`aria-label`,`onClick`],nN=[`title`],rN=M({__name:`LiveActivityCard`,setup(e){let t=HD(),{activity:n,streamKind:r,streamState:i}=id(DA()),a=O(`all`),o=G(()=>YM(n.value,a.value)),s=G(()=>XM(o.value.length,a.value)),c=nn(new Set),l=G(()=>QM(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return UM(e.representative)}function p(e){return e.representative.at?wj(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(k(_j),null,{default:A(()=>[V(k(Sj),null,{default:A(()=>[V(k(Cj),null,{default:A(()=>[...t[1]||=[H(`Live activity`,-1)]]),_:1}),V(k(vj),{class:`flex items-center gap-2`},{default:A(()=>[V(k(IM),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:k(KM)},null,8,[`modelValue`,`options`]),V(k(mj),{variant:k(r)},{default:A(()=>[H(D(k(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(k(yj),null,{default:A(()=>[B(`div`,$M,[B(`div`,eN,[V(k(RM),null,{default:A(()=>[V(k(VM),{class:`sticky top-0 z-10 bg-card`},{default:A(()=>[V(k(BM),null,{default:A(()=>[V(k($),null,{default:A(()=>[...t[2]||=[H(`Event`,-1)]]),_:1}),V(k($),null,{default:A(()=>[...t[3]||=[H(`Task`,-1)]]),_:1}),V(k($),null,{default:A(()=>[...t[4]||=[H(`Detail`,-1)]]),_:1}),V(k($),null,{default:A(()=>[...t[5]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(k(zM),null,{default:A(()=>[o.value.length?U(``,!0):(L(),z(k(BM),{key:0},{default:A(()=>[V(k(Q),{colspan:`4`},{default:A(()=>[V(k(oj),null,{default:A(()=>[V(k(lj),null,{default:A(()=>[V(k(fj),null,{default:A(()=>[H(D(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(L(!0),R(I,{key:1},P(l.value,e=>(L(),R(I,{key:e.key},[e.count===1?(L(),z(GM,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(L(),R(I,{key:1},[V(k(BM),{class:E(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[uu(cu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),uu(cu(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:A(()=>[V(k(Q),{class:`font-medium`},{default:A(()=>[B(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:cu(t=>u(e.key),[`stop`])},[d(e)?(L(),z(k(Cd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(L(),z(k(wd),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),H(` `+D(e.label)+` `,1),V(k(mj),{variant:`idle`},{default:A(()=>[H(`×`+D(e.count),1)]),_:2},1024)],8,tN)]),_:2},1024),V(k(Q),{class:`font-mono`},{default:A(()=>[H(D(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),V(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[B(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},D(f(e).text),9,nN)]),_:2},1024),V(k(Q),null,{default:A(()=>[H(D(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(L(!0),R(I,{key:0},P(e.events,(t,n)=>(L(),z(GM,{key:`${e.key}:${n}`,event:t,onOpen: Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function bP(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function xP(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function SP(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function CP(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var wP=O([]),TP=O([]),EP=O(!0),DP=O(null),OP=O(null),kP=O(!1),AP=O(null);async function jP(){try{let e=await J.eventTypes();EP.value=e.enabled!==!1,wP.value=e.event_types||[],TP.value=e.proposals||[],DP.value=null}catch(e){DP.value=e.message||String(e)}}function MP(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function NP(e){AP.value=null,OP.value=e}function PP(e){let t=HP.value.find(t=>String(t.id)===e.sample_id);NP({mode:`proposal`,id:null,source:e.source,name:``,rule:MP(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function FP(e=``){NP({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function IP(e){NP({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:MP(e.rule),headersText:``,body:``,exampleHeaders:{}})}function LP(){OP.value=null}async function RP(){let e=OP.value;if(e){kP.value=!0;try{if(e.mode===`edit`&&e.id)await J.eventTypeUpdate(e.id,{name:e.name,rule:CP(e.rule)});else{let t=e.mode===`paste`?yP(e.headersText):e.exampleHeaders;await J.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:CP(e.rule),example:{headers:t,body:e.body}})}OP.value=null,await jP()}catch(e){AP.value=e.message||String(e)}finally{kP.value=!1}}}var zP=O(null);async function BP(){let e=zP.value;if(zP.value=null,e)try{await J.eventTypeDelete(e.id),await jP()}catch(e){DP.value=e.message||String(e)}}var VP=100,HP=O([]),UP=O(!0),WP=O(null),GP=O(!0),KP=O(null);async function qP(){try{let e=await J.captures(VP);UP.value=e.enabled!==!1,HP.value=e.captures||[],WP.value=null}catch(e){WP.value=e.message||String(e)}finally{GP.value=!1}}function JP(e){let t=HP.value.find(t=>t.id===e);return t&&(KP.value=t),!!t}function YP(){HP.value.length&&(KP.value=HP.value[0])}function XP(){OA(`captures`,()=>{qP(),jP()})}var ZP=`archie.theme`,QP=`archie.density`,$P=`archie.motion`,eF=`archie.tooltips`;function tF(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function nF(e,t){try{localStorage.setItem(e,t)}catch{}}function rF(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var iF=rd(`appearance`,()=>{let e=O(tF(ZP,[`system`,`dark`,`light`],`dark`)),t=O(tF(QP,[`comfortable`,`compact`],`comfortable`)),n=O(tF($P,[`system`,`reduced`],`system`)),r=O(tF(eF,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=rF(e.value)}function o(t){e.value=t,a(),nF(ZP,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,nF(QP,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,nF($P,e)}function l(e){r.value=e,nF(eF,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),aF=M({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=vg(n,t),{tooltipsEnabled:i}=id(iF());return(e,t)=>(L(),z(k(fw),W({"data-slot":`tooltip`},k(r),{disabled:n.disabled||!k(i)}),{default:A(t=>[F(e.$slots,`default`,Ce(Es(t)))]),_:3},16,[`disabled`]))}}),oF=M({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=vg(Mw(n,`class`),r);return(e,t)=>(L(),z(k(gw),null,{default:A( Line truncated
`)}};bJ.defaultYaml={explicit:!1,version:`1.2`},bJ.defaultTags={"!!":`tag:yaml.org,2002:`};function xJ(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function SJ(e){let t=new Set;return pJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function CJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function wJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=SJ(e);let a=CJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(aJ(t.node)||sJ(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function TJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=TJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=TJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=TJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=TJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function EJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>EJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!lJ(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var DJ=class{constructor(e){Object.defineProperty(this,eJ,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!nJ(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=EJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?TJ(i,{"":o},``,o):o}},OJ=class extends DJ{constructor(e){super(Jq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],pJ(e,{Node:(e,t)=>{(tJ(t)||lJ(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(EJ(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=kJ(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(xJ(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function kJ(e,t,n){if(tJ(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(sJ(t)){let r=0;for(let i of t.items){let t=kJ(e,i,n);t>r&&(r=t)}return r}if(iJ(t)){let r=kJ(e,t.key,n),i=kJ(e,t.value,n);return Math.max(r,i)}return 1}var AJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,jJ=class extends DJ{constructor(e){super(Qq),this.value=e}toJSON(e,t){return t?.keep?this.value:EJ(this.value,e,t)}toString(){return String(this.value)}};jJ.BLOCK_FOLDED=`BLOCK_FOLDED`,jJ.BLOCK_LITERAL=`BLOCK_LITERAL`,jJ.PLAIN=`PLAIN`,jJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,jJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var MJ=`tag:yaml.org,2002:`;function NJ(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function PJ(e,t,n){if(nJ(e)&&(e=e.contents),cJ(e))return e;if(iJ(e)){let t=n.schema[Xq].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new OJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=MJ+t.slice(2));let l=NJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new jJ(e);return c&&(c.node=t),t Line truncated
`)?zJ(n,t):n.includes(`
`)?`
`+VJ(n,t):(e.endsWith(` `)?``:` `)+n,UJ=`flow`,WJ=`block`,GJ=`quoted`;function KJ(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=qJ(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
`)n===`block`&&(h=qJ(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`+zJ(n,t):(e.endsWith(` `)?``:` `)+n,VJ=`flow`,HJ=`block`,UJ=`quoted`;function WJ(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=GJ(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
`)n===`block`&&(h=GJ(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function qJ(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
`);r=t,i=t+1,a=e[i]}return r}var JJ=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),YJ=e=>/^(%|---|\.\.\.)/m.test(e);function XJ(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function ZJ(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(YJ(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function GJ(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
`);r=t,i=t+1,a=e[i]}return r}var KJ=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),qJ=e=>/^(%|---|\.\.\.)/m.test(e);function JJ(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function YJ(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(qJ(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:KJ(o,a,GJ,JJ(t,!1))}function QJ(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return ZJ(e,t);let n=t.indent||(YJ(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:KJ(r,n,UJ,JJ(t,!1))}function $J(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=ZJ;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?QJ:i&&!t?ZJ:n?QJ:ZJ}return r(e,t)}var eY;try{eY=RegExp(`(^|(?<!
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:WJ(o,a,UJ,KJ(t,!1))}function XJ(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return YJ(e,t);let n=t.indent||(qJ(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:WJ(r,n,VJ,KJ(t,!1))}function ZJ(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=YJ;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?XJ:i&&!t?YJ:n?XJ:YJ}return r(e,t)}var QJ;try{QJ=RegExp(`(^|(?<!
))
+(?!
|$)`,`g`)}catch{eY=/\n+(?!\n|$)/g}function tY({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return $J(n,r);let l=r.indent||(r.forceBlockIndent||YJ(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===NJ.BLOCK_FOLDED?!1:t===NJ.BLOCK_LITERAL||!XJ(n,c,l.length);if(!n)return u?`|
|$)`,`g`)}catch{QJ=/\n+(?!\n|$)/g}function $J({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return ZJ(n,r);let l=r.indent||(r.forceBlockIndent||qJ(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===jJ.BLOCK_FOLDED?!1:t===jJ.BLOCK_LITERAL||!JJ(n,c,l.length);if(!n)return u?`|
`:`>
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
`&&(p=p.slice(0,-1)),p.replace(eY,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
`&&(p=p.slice(0,-1)),p.replace(QJ,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=JJ(r,!0);o!==`folded`&&t!==NJ.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=KJ(`${v}${e}${p}`,l,WJ,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function nY(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
`)||u&&/[[\]{},]/.test(a))return $J(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?$J(a,t):tY(e,t,n,r);if(!s&&!u&&i!==NJ.PLAIN&&a.includes(`
`))return tY(e,t,n,r);if(YJ(a)){if(c===``)return t.forceBlockIndent=!0,tY(e,t,n,r);if(s&&c===l)return $J(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return $J(a,t)}return s?d:KJ(d,c,UJ,JJ(t,!1))}function rY(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==NJ.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=NJ.QUOTE_DOUBLE);let c=e=>{switch(e){case NJ.BLOCK_FOLDED:case NJ.BLOCK_LITERAL:return i||a?$J(o.value,t):tY(o,t,n,r);case NJ.QUOTE_DOUBLE:return ZJ(o.value,t);case NJ.QUOTE_SINGLE:return QJ(o.value,t);case NJ.PLAIN:return nY(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function iY(e,t){let n=Object.assign({blockQuote:!0,commentString:BJ,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function aY(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(sJ(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function oY(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(sJ(e)||lJ(e))&&e.anchor;a&&CJ(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function sY(e,t,n,r){if(oJ(e))return e.toString(t,n,r);if(rJ(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=uJ(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=aY(t.doc.schema.tags,a);let o=oY(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):sJ(a)?rY(a,t,n,r):a.toString(t,n,r);return o?sJ(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function cY({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=uJ(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(lJ(e)||!uJ(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||lJ(e)||(sJ(e)?e.type===NJ.BLOCK_FOLDED||e.type===NJ.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=sY(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=HJ(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=HJ(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=HJ(g,n.indent,l(f))));let _,v,y;uJ(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&sJ(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&cJ(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=sY(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${VJ(e,n.indent)}`}x===``&&!n.inFlow?S===`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=KJ(r,!0);o!==`folded`&&t!==jJ.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=WJ(`${v}${e}${p}`,l,HJ,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function eY(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
`)||u&&/[[\]{},]/.test(a))return ZJ(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?ZJ(a,t):$J(e,t,n,r);if(!s&&!u&&i!==jJ.PLAIN&&a.includes(`
`))return $J(e,t,n,r);if(qJ(a)){if(c===``)return t.forceBlockIndent=!0,$J(e,t,n,r);if(s&&c===l)return ZJ(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return ZJ(a,t)}return s?d:WJ(d,c,VJ,KJ(t,!1))}function tY(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==jJ.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=jJ.QUOTE_DOUBLE);let c=e=>{switch(e){case jJ.BLOCK_FOLDED:case jJ.BLOCK_LITERAL:return i||a?ZJ(o.value,t):$J(o,t,n,r);case jJ.QUOTE_DOUBLE:return YJ(o.value,t);case jJ.QUOTE_SINGLE:return XJ(o.value,t);case jJ.PLAIN:return eY(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function nY(e,t){let n=Object.assign({blockQuote:!0,commentString:RJ,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function rY(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(aJ(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function iY(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(aJ(e)||sJ(e))&&e.anchor;a&&xJ(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function aY(e,t,n,r){if(iJ(e))return e.toString(t,n,r);if(tJ(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=cJ(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=rY(t.doc.schema.tags,a);let o=iY(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):aJ(a)?tY(a,t,n,r):a.toString(t,n,r);return o?aJ(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function oY({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=cJ(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(sJ(e)||!cJ(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||sJ(e)||(aJ(e)?e.type===jJ.BLOCK_FOLDED||e.type===jJ.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=aY(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=BJ(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=BJ(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=BJ(g,n.indent,l(f))));let _,v,y;cJ(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&aJ(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&oJ(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=aY(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${zJ(e,n.indent)}`}x===``&&!n.inFlow?S===`
`&&y&&(S=`
`):S+=`\n${n.indent}`}else if(!p&&lJ(t)){let e=x[0],r=x.indexOf(`
`):S+=`\n${n.indent}`}else if(!p&&sJ(t)){let e=x[0],r=x.indexOf(`
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=HJ(g,n.indent,l(y)):h&&i&&i(),g}function lY(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var uY=`<<`,dY={identify:e=>e===uY||typeof e==`symbol`&&e.description===uY,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new NJ(Symbol(uY)),{addToJSMap:pY}),stringify:()=>uY},fY=(e,t)=>(dY.identify(t)||sJ(t)&&(!t.type||t.type===NJ.PLAIN)&&dY.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===dY.tag&&e.default);function pY(e,t,n){let r=hY(e,n);if(cJ(r))for(let n of r.items)mY(e,t,n);else if(Array.isArray(r))for(let n of r)mY(e,t,n);else mY(e,t,r)}function mY(e,t,n){let r=hY(e,n);if(!aJ(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function hY(e,t){return e&&rJ(t)?t.resolve(e.doc,e):t}function gY(e,t,{key:n,value:r}){if(uJ(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(fY(e,n))pY(e,t,r);else{let i=OJ(n,``,e);if(t instanceof Map)t.set(i,OJ(r,i,e));else if(t instanceof Set)t.add(i);else{let a=_Y(n,i,e),o=OJ(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function _Y(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(uJ(e)&&n?.doc){let t=iY(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),lY(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function vY(e,t,n){return new yY(IJ(e,void 0,n),IJ(t,void 0,n))}var yY=class e{constructor(e,t=null){Object.defineProperty(this,nJ,{value:$q}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return uJ(n)&&(n=n.clone(t)),uJ(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return gY(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?cY(this,e,t,n):JSON.stringify(this)}};function bY(e,t,n){return(t.inFlow??e.flow?SY:xY)(e,t,n)}function xY({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(uJ(i))!d&&i.spaceBefore&&f.push(``),CY(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(oJ(i)){let e=uJ(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),CY(n,f,e.commentBefore,d))}d=!1;let s=sY(i,u,()=>o=null,()=>d=!0);o&&(s+=HJ(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=BJ(g,n.indent,l(y)):h&&i&&i(),g}function sY(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var cY=`<<`,lY={identify:e=>e===cY||typeof e==`symbol`&&e.description===cY,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new jJ(Symbol(cY)),{addToJSMap:dY}),stringify:()=>cY},uY=(e,t)=>(lY.identify(t)||aJ(t)&&(!t.type||t.type===jJ.PLAIN)&&lY.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===lY.tag&&e.default);function dY(e,t,n){let r=pY(e,n);if(oJ(r))for(let n of r.items)fY(e,t,n);else if(Array.isArray(r))for(let n of r)fY(e,t,n);else fY(e,t,r)}function fY(e,t,n){let r=pY(e,n);if(!rJ(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function pY(e,t){return e&&tJ(t)?t.resolve(e.doc,e):t}function mY(e,t,{key:n,value:r}){if(cJ(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(uY(e,n))dY(e,t,r);else{let i=EJ(n,``,e);if(t instanceof Map)t.set(i,EJ(r,i,e));else if(t instanceof Set)t.add(i);else{let a=hY(n,i,e),o=EJ(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function hY(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(cJ(e)&&n?.doc){let t=nY(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),sY(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function gY(e,t,n){return new _Y(PJ(e,void 0,n),PJ(t,void 0,n))}var _Y=class e{constructor(e,t=null){Object.defineProperty(this,eJ,{value:Zq}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return cJ(n)&&(n=n.clone(t)),cJ(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return mY(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?oY(this,e,t,n):JSON.stringify(this)}};function vY(e,t,n){return(t.inFlow??e.flow?bY:yY)(e,t,n)}function yY({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(cJ(i))!d&&i.spaceBefore&&f.push(``),xY(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(iJ(i)){let e=cJ(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),xY(n,f,e.commentBefore,d))}d=!1;let s=aY(i,u,()=>o=null,()=>d=!0);o&&(s+=BJ(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
`}}return e?(p+=`
`+VJ(l(e),c),s&&s()):d&&o&&o(),p}function SY({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(uJ(i))i.spaceBefore&&d.push(``),CY(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(oJ(i)){let e=uJ(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),CY(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=uJ(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=sY(i,c,()=>a=null);l||=d.length>u||o.includes(`
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=HJ(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function CY({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=VJ(t(r),e);n.push(i.trimStart())}}function wY(e,t){let n=sJ(t)?t.value:t;for(let r of e)if(oJ(r)&&(r.key===t||r.key===n||sJ(r.key)&&r.key.value===n))return r}var TY=class extends zJ{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Qq,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(vY(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=oJ(e)?e:!e||typeof e!=`object`||!(`key`in e)?new yY(e,e?.value):new yY(e.key,e.value);let r=wY(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);sJ(r.value)&&MJ(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=wY(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=wY(this.items,e)?.value;return(!t&&sJ(n)?n.value:n)??void 0}has(e){return!!wY(this.items,e)}set(e,t){this.add(new yY(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)gY(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!oJ(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),bY(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},EY={collection:`map`,default:!0,nodeClass:TY,tag:`tag:yaml.org,2002:map`,resolve(e,t){return aJ(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>TY.from(e,t,n)},DY=class extends zJ{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(tJ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=OY(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=OY(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&sJ(r)?r.value:r}has(e){let t=OY(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=OY(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];sJ(r)&&MJ(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(OJ(e,String(r++),t));return n}toString(e,t,n){return e?bY(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(IJ(a,void 0,n))}}return i}};function OY(e){let t=sJ(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var kY={collection:`seq`,default:!0,nodeClass:DY,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return cJ(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>DY.from(e,t,n)},AY={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),rY(e,t,n,r)}},jY={identify:e=>e==null,createNode:()=>new NJ(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new NJ(null),stringify:({source:e},t)=>typeof e==`string`&&jY.test.test(e)?e:t.options.nullStr},MY={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new NJ(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&MY.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function NY({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var PY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:NY},FY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),string Line truncated
`:` `)}return rY({comment:e,type:t,value:s},r,i,a)}};function YY(e,t){if(cJ(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!oJ(r)){if(aJ(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new yY(new NJ(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=oJ(r)?r:new yY(r)}}else t(`Expected a sequence for this tag`);return e}function XY(e,t,n){let{replacer:r}=n,i=new DY(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(vY(o,s,n))}return i}var ZY={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:YY,createNode:XY},QY=class e extends DY{constructor(){super(),this.add=TY.prototype.add.bind(this),this.delete=TY.prototype.delete.bind(this),this.get=TY.prototype.get.bind(this),this.has=TY.prototype.has.bind(this),this.set=TY.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(oJ(e)?(r=OJ(e.key,``,t),i=OJ(e.value,r,t)):r=OJ(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=XY(e,t,n),i=new this;return i.items=r.items,i}};QY.tag=`tag:yaml.org,2002:omap`;var $Y={collection:`seq`,identify:e=>e instanceof Map,nodeClass:QY,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=YY(e,t),r=[];for(let{key:e}of n.items)sJ(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new QY,n)},createNode:(e,t,n)=>QY.from(e,t,n)};function eX({value:e,source:t},n){return t&&(e?tX:nX).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var tX={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new NJ(!0),stringify:eX},nX={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new NJ(!1),stringify:eX},rX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:NY},iX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():NY(e)}},aX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new NJ(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:NY},oX=e=>typeof e==`bigint`||Number.isInteger(e);function sX(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function cX(e,t,n){let{value:r}=e;if(oX(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return NY(e)}var lX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>sX(e,2,2,n),stringify:e=>cX(e,2,`0b`)},uX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>sX(e,1,8,n),stringify:e=>cX(e,8,`0`)},dX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>sX(e,0,10,n),stringify:NY},fX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>sX(e,2,16,n),stringify:e=>cX(e,16,`0x`)},pX=class e extends TY{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=oJ(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new yY(e.key,null):new yY(e,null),wY(this.items,t.key)||this.items.push(t)}get(e,t){let n=wY(this.items,e);return!t&&oJ(n)?sJ(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=wY(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new yY(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return s Line truncated
`)?(n.push(`...`),n.push(VJ(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(VJ(a(t),``)))}return n.join(`
`+zJ(l(e),c),s&&s()):d&&o&&o(),p}function bY({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(cJ(i))i.spaceBefore&&d.push(``),xY(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(iJ(i)){let e=cJ(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),xY(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=cJ(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=aY(i,c,()=>a=null);l||=d.length>u||o.includes(`
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=BJ(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function xY({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=zJ(t(r),e);n.push(i.trimStart())}}function SY(e,t){let n=aJ(t)?t.value:t;for(let r of e)if(iJ(r)&&(r.key===t||r.key===n||aJ(r.key)&&r.key.value===n))return r}var CY=class extends LJ{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Xq,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(gY(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=iJ(e)?e:!e||typeof e!=`object`||!(`key`in e)?new _Y(e,e?.value):new _Y(e.key,e.value);let r=SY(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);aJ(r.value)&&AJ(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=SY(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=SY(this.items,e)?.value;return(!t&&aJ(n)?n.value:n)??void 0}has(e){return!!SY(this.items,e)}set(e,t){this.add(new _Y(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)mY(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!iJ(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),vY(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},wY={collection:`map`,default:!0,nodeClass:CY,tag:`tag:yaml.org,2002:map`,resolve(e,t){return rJ(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>CY.from(e,t,n)},TY=class extends LJ{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super($q,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=EY(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=EY(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&aJ(r)?r.value:r}has(e){let t=EY(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=EY(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];aJ(r)&&AJ(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(EJ(e,String(r++),t));return n}toString(e,t,n){return e?vY(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(PJ(a,void 0,n))}}return i}};function EY(e){let t=aJ(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var DY={collection:`seq`,default:!0,nodeClass:TY,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return oJ(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>TY.from(e,t,n)},OY={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),tY(e,t,n,r)}},kY={identify:e=>e==null,createNode:()=>new jJ(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new jJ(null),stringify:({source:e},t)=>typeof e==`string`&&kY.test.test(e)?e:t.options.nullStr},AY={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new jJ(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&AY.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function jY({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var MY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:jY},NY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),string Line truncated
`:` `)}return tY({comment:e,type:t,value:s},r,i,a)}};function qY(e,t){if(oJ(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!iJ(r)){if(rJ(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new _Y(new jJ(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=iJ(r)?r:new _Y(r)}}else t(`Expected a sequence for this tag`);return e}function JY(e,t,n){let{replacer:r}=n,i=new TY(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(gY(o,s,n))}return i}var YY={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:qY,createNode:JY},XY=class e extends TY{constructor(){super(),this.add=CY.prototype.add.bind(this),this.delete=CY.prototype.delete.bind(this),this.get=CY.prototype.get.bind(this),this.has=CY.prototype.has.bind(this),this.set=CY.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(iJ(e)?(r=EJ(e.key,``,t),i=EJ(e.value,r,t)):r=EJ(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=JY(e,t,n),i=new this;return i.items=r.items,i}};XY.tag=`tag:yaml.org,2002:omap`;var ZY={collection:`seq`,identify:e=>e instanceof Map,nodeClass:XY,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=qY(e,t),r=[];for(let{key:e}of n.items)aJ(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new XY,n)},createNode:(e,t,n)=>XY.from(e,t,n)};function QY({value:e,source:t},n){return t&&(e?$Y:eX).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var $Y={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new jJ(!0),stringify:QY},eX={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new jJ(!1),stringify:QY},tX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:jY},nX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():jY(e)}},rX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new jJ(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:jY},iX=e=>typeof e==`bigint`||Number.isInteger(e);function aX(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function oX(e,t,n){let{value:r}=e;if(iX(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return jY(e)}var sX={identify:iX,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>aX(e,2,2,n),stringify:e=>oX(e,2,`0b`)},cX={identify:iX,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>aX(e,1,8,n),stringify:e=>oX(e,8,`0`)},lX={identify:iX,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>aX(e,0,10,n),stringify:jY},uX={identify:iX,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>aX(e,2,16,n),stringify:e=>oX(e,16,`0x`)},dX=class e extends CY{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=iJ(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new _Y(e.key,null):new _Y(e,null),SY(this.items,t.key)||this.items.push(t)}get(e,t){let n=SY(this.items,e);return!t&&iJ(n)?aJ(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=SY(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new _Y(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return s Line truncated
`)?(n.push(`...`),n.push(zJ(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(zJ(a(t),``)))}return n.join(`
`)+`
`}var OX=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,nJ,{value:Zq});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new SJ({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[nJ]:{value:Zq}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=uJ(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){kX(this.contents)&&this.contents.add(e)}addIn(e,t){kX(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=wJ(this);e.anchor=!t||n.has(t)?TJ(t||`a`,n):t}return new AJ(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=EJ(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=IJ(e,l,p);return o&&lJ(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new yY(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return kX(this.contents)?this.contents.delete(e):!1}deleteIn(e){return RJ(e)?this.contents!=null&&(this.contents=null,!0):kX(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return lJ(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return RJ(e)?!t&&sJ(this.contents)?this.contents.value:this.contents:lJ(this.contents)?this.contents.getIn(e,t):void 0}has(e){return lJ(this.contents)?this.contents.has(e):!1}hasIn(e){return RJ(e)?this.contents!==void 0:lJ(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=LJ(this.schema,[e],t):kX(this.contents)&&this.contents.set(e,t)}setIn(e,t){RJ(e)?this.contents=t:this.contents==null?this.contents=LJ(this.schema,Array.from(e),t):kX(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new SJ({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new SJ({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new EX(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=OJ(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?DJ(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return DX(this,e)}};function kX(e){if(lJ(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var AX=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},jX=class extends AX{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},MX=class extends AX{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},NX=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function PX(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function FX(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(FX(t.key)||FX(t.value))return!0}return!1;default:return!0}}function IX(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&FX(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function LX(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||sJ(e)&&sJ(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var RX=`All mapping items must start at the same column`;function zX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??TY)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=PX(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,RX)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||FX(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,RX);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&IX(r.indent,u,i),n.atKey=!1,LX(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=PX(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&IX(r.indent,f,i),s=c.range[2];let l=new yY(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let e=new yY(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function BX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??DY)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=PX(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&IX(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function VX(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var HX=`Block collections are not allowed within flow collections`,UX=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function WX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?TY:DY))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=PX(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&FX(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];oJ(t)&&(t=t.value??t.key),t.comment?t.comment+=`
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],UX(m)&&i(r.range,`BLOCK_IN_FLOW`,HX)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);UX(f)&&i(g.range,`BLOCK_IN_FLOW`,HX),n.atKey=!1;let _=PX(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?UX(m)&&i(v.range,`BLOCK_IN_FLOW`,HX):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new yY(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;LX(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new TY(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=VX(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function GX(e,t,n,r,i,a){let o=n.type===`block-map`?zX(e,t,n,r,a):n.type===`block-seq`?BX(e,t,n,r,a):WX(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function KX(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===TY.tagName&&s===`map`||o===DY.tagName&&s===`seq`)return GX(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),GX(e,t,n,i,o)}let l=GX(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=uJ(u)?u:new NJ(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function qX(e,t,n){let r=t.offset,i=JX(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?NJ.BLOCK_FOLDED:NJ.BLOCK_LITERAL,o=t.source?YX(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
`}var EX=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,eJ,{value:Yq});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new bJ({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[eJ]:{value:Yq}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=cJ(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){DX(this.contents)&&this.contents.add(e)}addIn(e,t){DX(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=SJ(this);e.anchor=!t||n.has(t)?CJ(t||`a`,n):t}return new OJ(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=wJ(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=PJ(e,l,p);return o&&sJ(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new _Y(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return DX(this.contents)?this.contents.delete(e):!1}deleteIn(e){return IJ(e)?this.contents!=null&&(this.contents=null,!0):DX(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return sJ(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return IJ(e)?!t&&aJ(this.contents)?this.contents.value:this.contents:sJ(this.contents)?this.contents.getIn(e,t):void 0}has(e){return sJ(this.contents)?this.contents.has(e):!1}hasIn(e){return IJ(e)?this.contents!==void 0:sJ(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=FJ(this.schema,[e],t):DX(this.contents)&&this.contents.set(e,t)}setIn(e,t){IJ(e)?this.contents=t:this.contents==null?this.contents=FJ(this.schema,Array.from(e),t):DX(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new bJ({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new bJ({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new wX(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=EJ(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?TJ(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return TX(this,e)}};function DX(e){if(sJ(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var OX=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},kX=class extends OX{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},AX=class extends OX{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},jX=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function MX(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function NX(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(NX(t.key)||NX(t.value))return!0}return!1;default:return!0}}function PX(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&NX(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function FX(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||aJ(e)&&aJ(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var IX=`All mapping items must start at the same column`;function LX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??CY)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=MX(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,IX)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||NX(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,IX);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&PX(r.indent,u,i),n.atKey=!1,FX(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=MX(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&PX(r.indent,f,i),s=c.range[2];let l=new _Y(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let e=new _Y(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function RX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??TY)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=MX(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&PX(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function zX(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var BX=`Block collections are not allowed within flow collections`,VX=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function HX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?CY:TY))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=MX(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&NX(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];iJ(t)&&(t=t.value??t.key),t.comment?t.comment+=`
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],VX(m)&&i(r.range,`BLOCK_IN_FLOW`,BX)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);VX(f)&&i(g.range,`BLOCK_IN_FLOW`,BX),n.atKey=!1;let _=MX(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?VX(m)&&i(v.range,`BLOCK_IN_FLOW`,BX):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new _Y(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;FX(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new CY(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=zX(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function UX(e,t,n,r,i,a){let o=n.type===`block-map`?LX(e,t,n,r,a):n.type===`block-seq`?RX(e,t,n,r,a):HX(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function WX(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===CY.tagName&&s===`map`||o===TY.tagName&&s===`seq`)return UX(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),UX(e,t,n,i,o)}let l=UX(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=cJ(u)?u:new jJ(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function GX(e,t,n){let r=t.offset,i=KX(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?jJ.BLOCK_FOLDED:jJ.BLOCK_LITERAL,o=t.source?qX(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===NJ.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===jJ.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`):t.length>c||r[0]===` `?(f===` `?f=`
`:!p&&f===`
`&&(f=`
@@ -81,47 +81,47 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
`+o[e][0].slice(c);d[d.length-1]!==`
`&&(d+=`
`);break;default:d+=`
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function JX({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function YX(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function XX(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=NJ.PLAIN,c=ZX(a,l);break;case`single-quoted-scalar`:s=NJ.QUOTE_SINGLE,c=QX(a,l);break;case`double-quoted-scalar`:s=NJ.QUOTE_DOUBLE,c=eZ(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=VX(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function ZX(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),$X(e)}function QX(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),$X(e.slice(1,-1)).replace(/''/g,`'`)}function $X(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function KX({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function qX(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function JX(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=jJ.PLAIN,c=YX(a,l);break;case`single-quoted-scalar`:s=jJ.QUOTE_SINGLE,c=XX(a,l);break;case`double-quoted-scalar`:s=jJ.QUOTE_DOUBLE,c=QX(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=zX(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function YX(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),ZX(e)}function XX(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),ZX(e.slice(1,-1)).replace(/''/g,`'`)}function ZX(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
`?a+=o:o=`
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function eZ(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function QX(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
`){if(i===`
`){let{fold:t,offset:i}=tZ(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=nZ[i];if(a)n+=a;else if(i===`
`){let{fold:t,offset:i}=$X(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=eZ[i];if(a)n+=a;else if(i===`
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=rZ(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=tZ(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
`&&(a!==`\r`||e[r+2]!==`
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function tZ(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function $X(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
`||r===`\r`)&&(r!==`\r`||e[t+2]===`
`);)r===`
`&&(n+=`
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var nZ={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function rZ(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function iZ(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?qX(e,t,r):XX(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[eJ]:c?aZ(e.schema,i,c,n,r):t.type===`scalar`?oZ(e,i,t,r):e.schema[eJ];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=sJ(a)?a:new NJ(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new NJ(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function aZ(e,t,n,r,i){if(n===`!`)return e[eJ];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[eJ])}function oZ({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[eJ];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[eJ];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function sZ(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var cZ={composeNode:lZ,composeEmptyNode:uZ};function lZ(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=dZ(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=iZ(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=KX(cZ,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=uZ(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!sJ(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function uZ(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=iZ(e,{type:`scalar`,offset:sZ(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function dZ({options:e},{offset:t,source:n,end:r},i){let a=new AJ(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=VX(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function fZ(e,t,{offset:n,start:r,value:i,end:a},o){let s=new OX(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=PX(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?lZ(c,i,l,o):uZ(c,l.end,r,null,l,o);let u=s.contents.range[2],d=VX(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function pZ(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function mZ(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var eZ={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function tZ(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function nZ(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?GX(e,t,r):JX(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[Qq]:c?rZ(e.schema,i,c,n,r):t.type===`scalar`?iZ(e,i,t,r):e.schema[Qq];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=aJ(a)?a:new jJ(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new jJ(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function rZ(e,t,n,r,i){if(n===`!`)return e[Qq];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[Qq])}function iZ({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[Qq];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[Qq];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function aZ(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var oZ={composeNode:sZ,composeEmptyNode:cZ};function sZ(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=lZ(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=nZ(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=WX(oZ,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=cZ(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!aJ(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function cZ(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=nZ(e,{type:`scalar`,offset:aZ(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function lZ({options:e},{offset:t,source:n,end:r},i){let a=new OJ(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=zX(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function uZ(e,t,{offset:n,start:r,value:i,end:a},o){let s=new EX(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=MX(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?sZ(c,i,l,o):cZ(c,l.end,r,null,l,o);let u=s.contents.range[2],d=zX(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function dZ(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function fZ(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
`:`
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var hZ=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=pZ(e);r?this.warnings.push(new MX(i,t,n)):this.errors.push(new jX(i,t,n))},this.directives=new SJ({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=mZ(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(lJ(i)&&!i.flow&&i.items.length>0){let e=i.items[0];oJ(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:mZ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=pZ(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=fZ(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new jX(pZ(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new jX(pZ(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=VX(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new jX(pZ(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new OX(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},gZ=Symbol(`break visit`),_Z=Symbol(`skip children`),vZ=Symbol(`remove item`);function yZ(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),bZ(Object.freeze([]),e,t)}yZ.BREAK=gZ,yZ.SKIP=_Z,yZ.REMOVE=vZ,yZ.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},yZ.parentCollection=(e,t)=>{let n=yZ.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function bZ(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=bZ(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===gZ)return gZ;else r===vZ&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function xZ(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var pZ=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=dZ(e);r?this.warnings.push(new AX(i,t,n)):this.errors.push(new kX(i,t,n))},this.directives=new bJ({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=fZ(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(sJ(i)&&!i.flow&&i.items.length>0){let e=i.items[0];iJ(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:fZ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=dZ(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=uZ(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new kX(dZ(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new kX(dZ(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=zX(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new kX(dZ(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new EX(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},mZ=Symbol(`break visit`),hZ=Symbol(`skip children`),gZ=Symbol(`remove item`);function _Z(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),vZ(Object.freeze([]),e,t)}_Z.BREAK=mZ,_Z.SKIP=hZ,_Z.REMOVE=gZ,_Z.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},_Z.parentCollection=(e,t)=>{let n=_Z.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function vZ(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=vZ(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===mZ)return mZ;else r===gZ&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function yZ(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
`:case`\r
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function SZ(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var CZ=new Set(`0123456789ABCDEFabcdef`),wZ=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),TZ=new Set(`,[]{}`),EZ=new Set(` ,[]{}
\r `),DZ=e=>!e||EZ.has(e),OZ=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function bZ(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var xZ=new Set(`0123456789ABCDEFabcdef`),SZ=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),CZ=new Set(`,[]{}`),wZ=new Set(` ,[]{}
\r `),TZ=e=>!e||wZ.has(e),EZ=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
`||t===`\r`&&this.buffer[e+1]===`
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
`||!t&&!this.atEnd)return e+n+1}return t===`
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&SZ(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&SZ(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!SZ(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&SZ(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(DZ),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&SZ(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(DZ),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||SZ(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&bZ(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&bZ(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!bZ(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&bZ(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(TZ),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&bZ(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(TZ),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||bZ(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>SZ(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>bZ(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
`)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(SZ(r)||e&&TZ.has(r))break;t=n}else if(SZ(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(bZ(r)||e&&CZ.has(r))break;t=n}else if(bZ(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`?(n+=1,r=`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&TZ.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&TZ.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(DZ),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(SZ(n)||t&&TZ.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!SZ(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(wZ.has(t))t=this.buffer[++e];else if(t===`%`&&CZ.has(this.buffer[e+1])&&CZ.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&CZ.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&CZ.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(TZ),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(bZ(n)||t&&CZ.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!bZ(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(SZ.has(t))t=this.buffer[++e];else if(t===`%`&&xZ.has(this.buffer[e+1])&&xZ.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},kZ=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function AZ(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function jZ(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function MZ(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function NZ(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function PZ(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function FZ(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function IZ(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!AZ(t.start,`explicit-key-ind`)&&!AZ(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,MZ(t.value)?t.value.end?FZ(t.value.end,t.sep):t.value.end=t.sep:FZ(t.start,t.sep),delete t.sep)}var LZ=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new OZ,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=xZ(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&IZ(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&jZ(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.i Line truncated
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},DZ=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function OZ(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function kZ(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function AZ(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function jZ(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function MZ(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function NZ(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function PZ(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!OZ(t.start,`explicit-key-ind`)&&!OZ(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,AZ(t.value)?t.value.end?NZ(t.value.end,t.sep):t.value.end=t.sep:NZ(t.start,t.sep),delete t.sep)}var FZ=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new EZ,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=yZ(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&PZ(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&kZ(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.i Line truncated
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){FZ(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(AZ(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=PZ(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(AZ(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(MZ(t.key)&&!AZ(t.sep,`newline`)){let e=PZ(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):AZ(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!AZ(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){FZ(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||AZ(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.ite Line truncated
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){NZ(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(OZ(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=MZ(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(OZ(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(AZ(t.key)&&!OZ(t.sep,`newline`)){let e=MZ(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):OZ(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!OZ(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){NZ(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||OZ(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.ite Line truncated
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=PZ(NZ(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=PZ(NZ(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function RZ(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new kZ||null,prettyErrors:t}}function zZ(e,t={}){let{lineCounter:n,prettyErrors:r}=RZ(t),i=new LZ(n?.addNewLine),a=new hZ(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new jX(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(NX(e,n)),o.warnings.forEach(NX(e,n))),o}function BZ(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function VZ(e){let t=zZ(e),n=t.errors[0];if(n)return{ok:!1,message:XZ(n.message),line:n.linePos?.[0]?.line};let r=t.toJS();if(!ZZ(r))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let i=typeof r.id==`string`?r.id.trim():``;if(!i)return{ok:!1,message:`workflow id is required`};let a=r.steps;if(a==null||a===``)return{ok:!1,message:`workflow ${i} has no steps`};if(!Array.isArray(a))return{ok:!1,message:`workflow ${i}: steps must be a list`};if(!a.length)return{ok:!1,message:`workflow ${i} has no steps`};let o=[];for(let[e,t]of a.entries()){if(!ZZ(t)||!QZ(t.type))return{ok:!1,message:`workflow ${i} step ${e+1} needs a type`};o.push({index:e+1,type:t.type.trim()})}return{ok:!0,id:i,steps:o}}function HZ(e){switch(e){case`key`:return`text-fg-muted`;case`string`:return`text-ok`;case`comment`:case`punct`:return`text-fg-subtle`;default:return`text-foreground`}}function UZ(e){return e.split(`
`).map((e,t)=>({number:t+1,text:e,tokens:KZ(e)}))}var WZ=/^(\s*)(-\s+)?/,GZ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function KZ(e){let{code:t,comment:n}=qZ(e),r=JZ(t);return n&&r.push({text:n,kind:`comment`}),r}function qZ(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t){r===t&&(t=``);continue}if(r===`"`||r===`'`){t=r;continue}if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function JZ(e){if(!e)return[];let t=[],n=WZ.exec(e);n?.[1]&&t.push({text:n[1],kind:`plain`}),n?.[2]&&t.push({text:n[2],kind:`punct`});let r=e.slice(n?.[0].length??0);if(!r)return t;let i=GZ.exec(r);return i?(t.push({text:i[1]??``,kind:`key`}),t.push({text:i[2]??`:`,kind:`punct`}),i[3]&&t.push({text:i[3],kind:`plain`}),[...t,...YZ(i[4]??``)]):[...t,...YZ(r)]}function YZ(e){if(!e)return[];let t=/^("[^"]*"?|'[^']*'?)([\s\S]*)$/.exec(e);if(!t)return[{text:e,kind:`plain`}];let n=[{text:t[1]??``,kind:`string`}];return t[2]&&n.push({text:t[2],kind:`plain`}),n}function XZ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function ZZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function QZ(e){return typeof e==`string`&&e.trim()!==``}var $Z={class:`space-y-1.5`},eQ={class:`space-y-1.5`},tQ={class:`flex h-9 flex-nowrap items-center gap-1.5 overflow-hidden`,role:`list`,"aria-label":`Steps`},nQ=[`title`],rQ={key:1,class:`text-xs text-fg-subtle`},iQ={class:`space-y-1.5`},aQ={class:`flex items-baseline gap-2`},oQ={class:`relative overflow-hidden rounded-lg border border-input font-mono text-[13px] leading-6 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`},sQ={"aria-hidden":`true`,class:`pointer-events-none absolute inset-y-0 left-0 w-11 select-none overflow-hidden border-r border-border bg-secondary/40 py-3 text-right`},cQ={"aria-hidden":`true`,class:`pointer-events-none absolute inset-0 overflow-hidden py-3 pr-3 pl-14 break-words whitespace-pre-wrap`},lQ={key:0,class:`text-sm text-danger`,role:`alert`},uQ={class:`flex flex-wrap items-center gap-2 border-t border-border pt-4`},dQ={key:0,class:`mr-auto font-mono text-xs text-fg-subtle`},fQ=M({__name:`WorkflowEditor`,props:{selected:{required:!0},selectedModifiers:{}},emits:[`update:selected`],setup(e){let t=ZA(),n=G(()=>t.stateFor(`workflow-definitions`)),r=G(()=>n.value.resource?.value??{definitions:[]}),i=G(()=>t.shippedWorkflows()),a=so(e,`selected`),o=O(``),s=O(``),c=O(``),l=G(()=>i.value.definitions.find(e=>e.id===o.value));function u(e){let t=r.value.definitions.find(t=>t.id===e);o.value=t?.id??e,s.value=t?.yaml??`id: ${e}\nsteps:\n - type: `,c.value=``}j(a,u,{immediate:!0}),j(r,()=>{s.value||u(a.value)});async function d(e){return c.value=``,t.replace(`workflow-definitions`,e)}async function f(){let e=o.value.trim();if(!e){c.value=`Workflow ID is required.`;return}let t=a.value,n=r.value;t&&t!==e&&(n=YA(n,t)),await d(JA(n,{id:e,yaml:s.value}))&&(a.value=e)}async function p(){a.value&&await d(YA(r.value,a.value))&&(a.value=``,o.value=``,s.value=``)}async function m(){l.value&&await d(JA(r.value,KA(l.value)))}let h=G(()=>VZ(s.value)),g=G(()=>h.value.ok?h.value.steps:[]),_=G(()=>UZ(s.value)),v=O(0);function y(e){v.value=e.target.scrollTop}return(e,t)=>(L(),R(`form`,{class:`space-y-4`,onSubmit:cu(f,[`prevent`])},[B(`div`,$Z,[V(k(_T),{for:`workflow-id`},{default:A(()=>[...t[2]||=[H(`ID`,-1)]]),_:1}),V(k(Z),{id:`workflow-id`,modelValue:o.value,"onUpdate:modelValue":t[0]||=e=>o.value=e,name:`workflow-id`,required:``,autocomplete:`off`,class:`max-w-sm font-mono`},null,8,[`modelValue`])]),B(`div`,eQ,[t[3]||=B(`span`,{class:`text-sm leading-none font-medium`},`Steps`,-1),B(`div`,tQ,[g.value.length?(L(!0),R(I,{key:0},P(g.value,(e,t)=>(L(),R(I,{key:e.index},[B(`span`,{role:`listitem`,class:`shrink-0 rounded border border-border bg-secondary px-2 py-0.5 font-mono text-xs`,title:e.type},D(e.type),9,nQ),t<g.value.length-1?(L(),z(k(vd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":`true`})):U(``,!0)],64))),128)):(L(),R(`span`,rQ,`No steps yet`))])]),B(`div`,iQ,[B(`div`,aQ,[V(k(_T),{for:`workflow-yaml`},{default:A(()=>[...t[4]||=[H(`YAML`,-1)]]),_:1}),B(`span`,{class:E([`ml-auto text-xs`,h.value.ok?`text-ok`:`text-danger`]),role:`status`},D(h.value.ok?`✓`:`✕`)+` `+D(k(BZ)(h.value)),3)]),B(`div`,oQ,[B(`div`,sQ,[B(`div`,{style:ve(`transform:translateY(${-v.value}px)`)},[(L(!0),R(I,null,P(_.value,e=>(L(),R(`div`,{key:e.number,class:`min-h-6 pr-2 text-fg-subtle`},D(e.number),1))),128))],4)]),B(`div`,cQ,[B(`div`,{style:ve(`transform:translateY(${-v.value}px)`)},[(L(!0),R(I,null,P(_.value,e=>(L(),R(`div`,{key:e.number,class:`min-h-6`},[(L(!0),R(I,null,P(e.tokens,(e,t)=>(L(),R(`span`,{key:t,class:E(k(HZ)(e.kind))},D(e.text),3))),128))]))),128))],4)]),V(k(OT),{id:`workflow-yaml`,modelValue:s.value,"onUpdate:modelValue":t[1]||=e=>s.value=e,name:`workflow-yaml`,required:``,class:`relative min-h-96 resize-y rounded-none border-0 bg-transparent py-3 pr-3 pl-14 text-[13px] leading-6 text-transparent caret-foreground shadow-none md:text-[13px] focus-visible:ring-0`,spellcheck:`false`,onScroll:y},null,8,[`modelValue`])])]),c.value||n.value.error?(L(),R(`p`,lQ,D(c.value||n.value.error),1)):U(``,!0),B(`div`,uQ,[n.value.resource?(L(),R(`span`,dQ,`Version `+D(n.value.resource.version),1)):U(``,!0),a.value?(L(),z(k(X),{key:1,type:`button`,variant:`ghost`,class:`text-danger`,onClick:p},{default:A(()=>[V(k(nf)),t[5]||=H(` Remove`,-1)]),_:1})):U(``,!0),l.value?(L(),z(k(X),{key:2,type:`button`,variant:`outline`,onClick:m},{default:A(()=>[V(k(Yd)),t[6]||=H(` Restore this workflow`,-1)]),_:1})):U(``,!0),V(k(X),{type:`submit`,disabled:n.value.saving||!h.value.ok},{default:A(()=>[n.value.saving?(L(),z(k(CF),{key:0,"data-icon":`inline-start`})):U(``,!0),t[7]||=H(` Validate & save`,-1)]),_:1},8,[`disabled`])])],32))}});function pQ(e,t){let n=new Map((e||[]).map(e=>[e.workflow,e])),r=[],i=new Set;for(let e of t||[])i.add(e.id),r.push({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0,completed:0}});for(let t of e||[])i.has(t.workflow)||r Line truncated
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=MZ(jZ(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=MZ(jZ(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function IZ(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new DZ||null,prettyErrors:t}}function LZ(e,t={}){let{lineCounter:n,prettyErrors:r}=IZ(t),i=new FZ(n?.addNewLine),a=new pZ(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new kX(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(jX(e,n)),o.warnings.forEach(jX(e,n))),o}function RZ(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function zZ(e){let t=LZ(e),n=t.errors[0];if(n)return{ok:!1,message:JZ(n.message),line:n.linePos?.[0]?.line};let r=t.toJS();if(!YZ(r))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let i=typeof r.id==`string`?r.id.trim():``;if(!i)return{ok:!1,message:`workflow id is required`};let a=r.steps;if(a==null||a===``)return{ok:!1,message:`workflow ${i} has no steps`};if(!Array.isArray(a))return{ok:!1,message:`workflow ${i}: steps must be a list`};if(!a.length)return{ok:!1,message:`workflow ${i} has no steps`};let o=[];for(let[e,t]of a.entries()){if(!YZ(t)||!XZ(t.type))return{ok:!1,message:`workflow ${i} step ${e+1} needs a type`};o.push({index:e+1,type:t.type.trim()})}return{ok:!0,id:i,steps:o}}function BZ(e){switch(e){case`key`:return`text-fg-muted`;case`string`:return`text-ok`;case`comment`:case`punct`:return`text-fg-subtle`;default:return`text-foreground`}}function VZ(e){return e.split(`
`).map((e,t)=>({number:t+1,text:e,tokens:WZ(e)}))}var HZ=/^(\s*)(-\s+)?/,UZ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function WZ(e){let{code:t,comment:n}=GZ(e),r=KZ(t);return n&&r.push({text:n,kind:`comment`}),r}function GZ(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t){r===t&&(t=``);continue}if(r===`"`||r===`'`){t=r;continue}if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function KZ(e){if(!e)return[];let t=[],n=HZ.exec(e);n?.[1]&&t.push({text:n[1],kind:`plain`}),n?.[2]&&t.push({text:n[2],kind:`punct`});let r=e.slice(n?.[0].length??0);if(!r)return t;let i=UZ.exec(r);return i?(t.push({text:i[1]??``,kind:`key`}),t.push({text:i[2]??`:`,kind:`punct`}),i[3]&&t.push({text:i[3],kind:`plain`}),[...t,...qZ(i[4]??``)]):[...t,...qZ(r)]}function qZ(e){if(!e)return[];let t=/^("[^"]*"?|'[^']*'?)([\s\S]*)$/.exec(e);if(!t)return[{text:e,kind:`plain`}];let n=[{text:t[1]??``,kind:`string`}];return t[2]&&n.push({text:t[2],kind:`plain`}),n}function JZ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function YZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function XZ(e){return typeof e==`string`&&e.trim()!==``}var ZZ={class:`space-y-1.5`},QZ={class:`space-y-1.5`},$Z={class:`flex h-9 flex-nowrap items-center gap-1.5 overflow-hidden`,role:`list`,"aria-label":`Steps`},eQ=[`title`],tQ={key:1,class:`text-xs text-fg-subtle`},nQ={class:`space-y-1.5`},rQ={class:`flex items-baseline gap-2`},iQ={class:`relative overflow-hidden rounded-lg border border-input font-mono text-[13px] leading-6 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50`},aQ={"aria-hidden":`true`,class:`pointer-events-none absolute inset-y-0 left-0 w-11 select-none overflow-hidden border-r border-border bg-secondary/40 py-3 text-right`},oQ={"aria-hidden":`true`,class:`pointer-events-none absolute inset-0 overflow-hidden py-3 pr-3 pl-14 break-words whitespace-pre-wrap`},sQ={key:0,class:`text-sm text-danger`,role:`alert`},cQ={class:`flex flex-wrap items-center gap-2 border-t border-border pt-4`},lQ={key:0,class:`mr-auto font-mono text-xs text-fg-subtle`},uQ=M({__name:`WorkflowEditor`,props:{selected:{required:!0},selectedModifiers:{}},emits:[`update:selected`],setup(e){let t=JA(),n=G(()=>t.stateFor(`workflow-definitions`)),r=G(()=>n.value.resource?.value??{definitions:[]}),i=G(()=>t.shippedWorkflows()),a=so(e,`selected`),o=O(``),s=O(``),c=O(``),l=G(()=>i.value.definitions.find(e=>e.id===o.value));function u(e){let t=r.value.definitions.find(t=>t.id===e);o.value=t?.id??e,s.value=t?.yaml??`id: ${e}\nsteps:\n - type: `,c.value=``}j(a,u,{immediate:!0}),j(r,()=>{s.value||u(a.value)});async function d(e){return c.value=``,t.replace(`workflow-definitions`,e)}async function f(){let e=o.value.trim();if(!e){c.value=`Workflow ID is required.`;return}let t=a.value,n=r.value;t&&t!==e&&(n=KA(n,t)),await d(GA(n,{id:e,yaml:s.value}))&&(a.value=e)}async function p(){a.value&&await d(KA(r.value,a.value))&&(a.value=``,o.value=``,s.value=``)}async function m(){l.value&&await d(GA(r.value,UA(l.value)))}let h=G(()=>zZ(s.value)),g=G(()=>h.value.ok?h.value.steps:[]),_=G(()=>VZ(s.value)),v=O(0);function y(e){v.value=e.target.scrollTop}return(e,t)=>(L(),R(`form`,{class:`space-y-4`,onSubmit:cu(f,[`prevent`])},[B(`div`,ZZ,[V(k(mT),{for:`workflow-id`},{default:A(()=>[...t[2]||=[H(`ID`,-1)]]),_:1}),V(k(Fk),{id:`workflow-id`,modelValue:o.value,"onUpdate:modelValue":t[0]||=e=>o.value=e,name:`workflow-id`,required:``,autocomplete:`off`,class:`max-w-sm font-mono`},null,8,[`modelValue`])]),B(`div`,QZ,[t[3]||=B(`span`,{class:`text-sm leading-none font-medium`},`Steps`,-1),B(`div`,$Z,[g.value.length?(L(!0),R(I,{key:0},P(g.value,(e,t)=>(L(),R(I,{key:e.index},[B(`span`,{role:`listitem`,class:`shrink-0 rounded border border-border bg-secondary px-2 py-0.5 font-mono text-xs`,title:e.type},D(e.type),9,eQ),t<g.value.length-1?(L(),z(k(vd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":`true`})):U(``,!0)],64))),128)):(L(),R(`span`,tQ,`No steps yet`))])]),B(`div`,nQ,[B(`div`,rQ,[V(k(mT),{for:`workflow-yaml`},{default:A(()=>[...t[4]||=[H(`YAML`,-1)]]),_:1}),B(`span`,{class:E([`ml-auto text-xs`,h.value.ok?`text-ok`:`text-danger`]),role:`status`},D(h.value.ok?`✓`:`✕`)+` `+D(k(RZ)(h.value)),3)]),B(`div`,iQ,[B(`div`,aQ,[B(`div`,{style:ve(`transform:translateY(${-v.value}px)`)},[(L(!0),R(I,null,P(_.value,e=>(L(),R(`div`,{key:e.number,class:`min-h-6 pr-2 text-fg-subtle`},D(e.number),1))),128))],4)]),B(`div`,oQ,[B(`div`,{style:ve(`transform:translateY(${-v.value}px)`)},[(L(!0),R(I,null,P(_.value,e=>(L(),R(`div`,{key:e.number,class:`min-h-6`},[(L(!0),R(I,null,P(e.tokens,(e,t)=>(L(),R(`span`,{key:t,class:E(k(BZ)(e.kind))},D(e.text),3))),128))]))),128))],4)]),V(k(TT),{id:`workflow-yaml`,modelValue:s.value,"onUpdate:modelValue":t[1]||=e=>s.value=e,name:`workflow-yaml`,required:``,class:`relative min-h-96 resize-y rounded-none border-0 bg-transparent py-3 pr-3 pl-14 text-[13px] leading-6 text-transparent caret-foreground shadow-none md:text-[13px] focus-visible:ring-0`,spellcheck:`false`,onScroll:y},null,8,[`modelValue`])])]),c.value||n.value.error?(L(),R(`p`,sQ,D(c.value||n.value.error),1)):U(``,!0),B(`div`,cQ,[n.value.resource?(L(),R(`span`,lQ,`Version `+D(n.value.resource.version),1)):U(``,!0),a.value?(L(),z(k(Z),{key:1,type:`button`,variant:`ghost`,class:`text-danger`,onClick:p},{default:A(()=>[V(k(ef)),t[5]||=H(` Remove`,-1)]),_:1})):U(``,!0),l.value?(L(),z(k(Z),{key:2,type:`button`,variant:`outline`,onClick:m},{default:A(()=>[V(k(qd)),t[6]||=H(` Restore this workflow`,-1)]),_:1})):U(``,!0),V(k(Z),{type:`submit`,disabled:n.value.saving||!h.value.ok},{default:A(()=>[n.value.saving?(L(),z(k(xF),{key:0,"data-icon":`inline-start`})):U(``,!0),t[7]||=H(` Validate & save`,-1)]),_:1},8,[`disabled`])])],32))}});function dQ(e,t){let n=new Map((e||[]).map(e=>[e.workflow,e])),r=[],i=new Set;for(let e of t||[])i.add(e.id),r.push({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0,completed:0}});for(let t of e||[])i.has(t.workflow)|| Line truncated
+2 -48
View File
@@ -2,7 +2,7 @@
import HistoryLink from "@/settings/HistoryLink.vue";
import { computed, onMounted, reactive, ref } from "vue";
import { storeToRefs } from "pinia";
import { Globe, Mail, Send } from "@lucide/vue";
import { Send } from "@lucide/vue";
import PageHeader from "@/base/PageHeader.vue";
import { Button } from "@/components/ui/button";
@@ -15,7 +15,6 @@ import {
NumberFieldIncrement,
NumberFieldInput,
} from "@/components/ui/number-field";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SettingRow } from "@/components/ui/setting-row";
import { StatusPill } from "@/components/ui/status-pill";
import { Switch } from "@/components/ui/switch";
@@ -42,9 +41,6 @@ interface ChannelSettings {
show_tool_calls: boolean;
max_steps: number;
models: string[] | null;
email: { listen_addr: string; relay_addr: string };
webhook_addr: string;
webhook: { path: string; secret_ref: SecretRef; credential_configured: boolean; template: string; deliver_to: string };
telegram: { allowed_user_ids: number[] | null; token_ref: SecretRef; credential_configured: boolean };
rate_limit: { window: string; max_requests: number };
unrestricted_filesystem: boolean;
@@ -90,16 +86,12 @@ function statusOf(id: string) {
// daemon applies when it decides what to start.
const configured = computed(() => ({
telegram: !!chat.value?.telegram.token_ref.key,
email: !!chat.value?.email.listen_addr,
webhook: !!chat.value?.webhook_addr,
}));
const opened = reactive({ telegram: false, email: false, webhook: false });
const opened = reactive({ telegram: false });
const shown = (id: keyof typeof opened) => configured.value[id] || opened[id];
const channels = [
{ id: "telegram", title: "Telegram", icon: Send },
{ id: "email", title: "Email", icon: Mail },
{ id: "webhook", title: "Webhook", icon: Globe },
] as const;
const allowedUsers = computed({
@@ -115,10 +107,6 @@ const models = computed({
if (chat.value) chat.value.models = list;
},
});
const replyModes = [
{ value: "", label: "No reply" },
{ value: "origin", label: "HTTP response" },
];
</script>
<template>
@@ -174,40 +162,6 @@ const replyModes = [
</TagsInput>
</SettingRow>
</template>
<template v-else-if="channel.id === 'email'">
<SettingRow label="Listen address" for="em-listen" hint="Empty disables email.">
<Input id="em-listen" v-model="chat.email.listen_addr" class="max-w-sm font-mono" placeholder=":2525" />
</SettingRow>
<SettingRow label="Relay address" for="em-relay">
<Input id="em-relay" v-model="chat.email.relay_addr" class="max-w-sm font-mono" />
</SettingRow>
</template>
<template v-else>
<SettingRow label="Listen address" for="wh-addr" hint="Empty disables the webhook.">
<Input id="wh-addr" v-model="chat.webhook_addr" class="max-w-sm font-mono" placeholder=":8686" />
</SettingRow>
<SettingRow label="Path" for="wh-path">
<Input id="wh-path" v-model="chat.webhook.path" class="max-w-sm font-mono" placeholder="/webhook" />
</SettingRow>
<SettingRow label="Message field" for="wh-template" hint="Dot path. Empty: whole body.">
<Input id="wh-template" v-model="chat.webhook.template" class="max-w-sm font-mono" placeholder="issue.title" />
</SettingRow>
<SettingRow label="Replies">
<SegmentedControl v-model="chat.webhook.deliver_to" label="Replies" :options="replyModes" />
</SettingRow>
<SettingRow
label="Signing secret"
hint="Unset accepts unsigned requests."
:tone="chat.webhook.secret_ref.key ? 'default' : 'danger'"
>
<SecretRefField
v-model="chat.webhook.secret_ref"
id-prefix="wh-secret"
/>
</SettingRow>
</template>
</div>
</section>