feat(workflows): test-run unsaved drafts and browse workflow version history

A test run pins a validated draft, runs with forge and push writes
suppressed and recorded per step, and is excluded from workflow stats.
The History tab lists revisions that changed a workflow, diffs them as
YAML and on the canvas, restores into the editor, and ties runs to the
revision they used.
This commit is contained in:
sam committed 2026-10-13 12:27:40 +11:00
1 parent b391e8a9bf
commit d54f4af11e
37 files changed
+677 -132

No files matched your search

+13 -4
View File
@@ -267,10 +267,7 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
Log: log,
Guardrails: dependencies.guardrails,
}
// pr-review reads the PR data the daemon prefetched into workDir.
if req.Task.Workflow == "pr-review" {
tc.PRSource = prsource.NewFromMount(filepath.Join(workDir, prsource.PrefetchDirName))
}
configureTaskContext(tc, workDir)
if req.Repo.PersistentStorage {
memory, readErr := readProjectMemory(storage.MemoryPath)
@@ -292,6 +289,18 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
}, nil
}
// configureTaskContext applies what the task's kind changes about its context:
// a test run writes nothing to a forge, and pr-review reads the PR data the
// daemon prefetched into workDir.
func configureTaskContext(tc *workflow.TaskContext, workDir string) {
if tc.Task.IsTestRun() {
workflow.SuppressForgeWrites(tc)
}
if tc.Task.Workflow == "pr-review" {
tc.PRSource = prsource.NewFromMount(filepath.Join(workDir, prsource.PrefetchDirName))
}
}
// CompilePinnedWorkflow compiles the definition the request carries. With
// none, it pins one from the shipped definitions onto req and req.Task.
func CompilePinnedWorkflow(req *taskrun.Request, steps *workflow.Manager) (workflow.Workflow, error) {
+2 -2
View File
@@ -15,7 +15,7 @@ import (
type Writer struct {
Enqueue func(
ctx context.Context,
owner, repo, title, body, workflow, identity, origin string,
owner, repo, title, body, workflow, identity, origin, draft string,
inputs map[string]any,
) (*workflow.Task, error)
}
@@ -25,7 +25,7 @@ func (a Writer) EnqueueChatTask(
owner, repo, title, body, workflow, identity, origin string,
inputs map[string]any,
) (int64, error) {
task, err := a.Enqueue(ctx, owner, repo, title, body, workflow, identity, origin, inputs)
task, err := a.Enqueue(ctx, owner, repo, title, body, workflow, identity, origin, "", inputs)
if err != nil {
return 0, err
}
+14 -1
View File
@@ -162,9 +162,22 @@ func (s *Server) Audit(ctx context.Context, request *pb.AuditRequest) (*pb.Audit
func (s *Server) Command(ctx context.Context, request *pb.CommandRequest) (*pb.CommandResponse, error) {
definition, ok := s.definitions[request.GetKind()]
if !ok || request.GetCommand() != "replace" {
command := request.GetCommand()
if !ok || (command != "replace" && command != "validate") {
return nil, status.Error(codes.NotFound, "resource or command not found")
}
if command == "validate" {
// The same checks a replace runs, without writing: a caller can learn
// that a document would be refused before it asks for the change.
value, err := definition.Decode(request.ValueJson)
if err == nil {
err = s.checkOrgWrite(ctx, requestOrg(ctx), request.Kind, value)
}
if err != nil {
return nil, mapError(err)
}
return &pb.CommandResponse{}, nil
}
if request.GetActor() == "" || request.GetSource() == "" || request.GetRequestId() == "" {
return nil, status.Error(codes.InvalidArgument, "actor, source, and request ID are required")
}
+15 -3
View File
@@ -3876,7 +3876,10 @@ type EnqueueChatTaskRequest struct {
// time: it has no binding provenance to stamp afterwards.
InputsJson string `protobuf:"bytes,7,opt,name=inputs_json,json=inputsJson,proto3" json:"inputs_json,omitempty"`
// origin names the conversation that created the task; empty for none.
Origin string `protobuf:"bytes,8,opt,name=origin,proto3" json:"origin,omitempty"`
Origin string `protobuf:"bytes,8,opt,name=origin,proto3" json:"origin,omitempty"`
// draft_yaml, when set, makes the task a test run of that unsaved
// definition: it is pinned to it and writes nothing to a forge.
DraftYaml string `protobuf:"bytes,9,opt,name=draft_yaml,json=draftYaml,proto3" json:"draft_yaml,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -3967,6 +3970,13 @@ func (x *EnqueueChatTaskRequest) GetOrigin() string {
return ""
}
func (x *EnqueueChatTaskRequest) GetDraftYaml() string {
if x != nil {
return x.DraftYaml
}
return ""
}
type EnqueueChatTaskResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
@@ -17901,7 +17911,7 @@ const file_state_v1_state_proto_rawDesc = "" +
"\x05tasks\x18\x01 \x03(\v2\x0e.state.v1.TaskR\x05tasks\"3\n" +
"\x18MarkOutcomePostedRequest\x12\x17\n" +
"\atask_id\x18\x01 \x01(\x03R\x06taskId\"\x1b\n" +
"\x19MarkOutcomePostedResponse\"\xdd\x01\n" +
"\x19MarkOutcomePostedResponse\"\xfc\x01\n" +
"\x16EnqueueChatTaskRequest\x12\x14\n" +
"\x05owner\x18\x01 \x01(\tR\x05owner\x12\x12\n" +
"\x04repo\x18\x02 \x01(\tR\x04repo\x12\x14\n" +
@@ -17911,7 +17921,9 @@ const file_state_v1_state_proto_rawDesc = "" +
"\bidentity\x18\x06 \x01(\tR\bidentity\x12\x1f\n" +
"\vinputs_json\x18\a \x01(\tR\n" +
"inputsJson\x12\x16\n" +
"\x06origin\x18\b \x01(\tR\x06origin\"=\n" +
"\x06origin\x18\b \x01(\tR\x06origin\x12\x1d\n" +
"\n" +
"draft_yaml\x18\t \x01(\tR\tdraftYaml\"=\n" +
"\x17EnqueueChatTaskResponse\x12\"\n" +
"\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\"\x12\n" +
"\x10ClaimNextRequest\"M\n" +
@@ -38,7 +38,7 @@ type TaskStore interface {
// poll, chat spawn, drain loop) do not acquire a binding-specific shape.
type TaskLifecycle interface {
EnqueueIssue(ctx context.Context, owner, repo string, number int, title, body, labels, identity string) (bool, error)
EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity, origin string, inputs map[string]any) (*task.Task, error)
EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity, origin, draft string, inputs map[string]any) (*task.Task, error)
ClaimNext(ctx context.Context) (*task.Task, error)
ClaimByIssue(ctx context.Context, owner, repo string, number int) (*task.Task, error)
Transition(ctx context.Context, taskID int64, from, to, detail string) error
+5
View File
@@ -223,6 +223,11 @@ func OpenPR(ctx context.Context, tc *TaskContext, body string) error {
if err != nil {
return err
}
if t.IsTestRun() {
// No PR exists to watch, so the run ends here rather than as pr_open.
tc.Outcome = Outcome{Status: StatusCompleted, Detail: "test run: no PR opened"}
return nil
}
t.PRNumber = num
tc.Outcome = Outcome{Status: StatusPROpen, Detail: fmt.Sprintf("PR #%d", num)}
// Capture again now that the PR number is known.
+14 -5
View File
@@ -80,7 +80,7 @@ type Task struct {
// and comment IDs are independent forge sequences, and one combined
// cursor would silently skip reviews once a larger comment ID landed.
ReviewCursor int64 `json:"review_cursor"`
// Source is "forge" or "chat". Chat tasks have a synthetic IssueNumber and
// Source is "forge", "chat" or "test". Chat tasks have a synthetic IssueNumber and
// skip forge operations.
Source string `json:"source"`
// Identity is the identity that started this task: a chat user, a
@@ -143,19 +143,28 @@ type Task struct {
UpdatedAt time.Time `json:"updated_at"`
}
// SourceForge and SourceChat are the valid values for Task.Source.
// SourceForge, SourceChat and SourceTest are the valid values for Task.Source.
// A test run is a chat-shaped task that runs an unsaved draft definition and
// writes nothing to a forge.
// Legacy rows and forge-polled tasks have Source == SourceForge (the
// zero value defaults there via the SQLite column default).
const (
SourceForge = "forge"
SourceChat = "chat"
SourceTest = "test"
)
// IsForgeBacked reports whether t corresponds to a real forge issue.
// Chat-spawned tasks (Source == SourceChat) have a synthetic
// IssueNumber and must not be used in forge label/comment/reply calls.
// Chat-spawned and test tasks have a synthetic IssueNumber and must not be
// used in forge label/comment/reply calls.
func (t Task) IsForgeBacked() bool {
return t.Source != SourceChat
return t.Source != SourceChat && t.Source != SourceTest
}
// IsTestRun reports whether t runs an operator's draft with forge writes
// suppressed.
func (t Task) IsTestRun() bool {
return t.Source == SourceTest
}
// EffectivePRNumber returns PRNumber, else the pr_number input, else 0.
+1
View File
@@ -43,4 +43,5 @@ const (
const (
SourceForge = task.SourceForge
SourceChat = task.SourceChat
SourceTest = task.SourceTest
)
+66
View File
@@ -0,0 +1,66 @@
package workflow
import (
"context"
"fmt"
"github.com/samcharles93/archie-core/internal/events"
)
// SuppressForgeWrites makes tc skip every forge and push write, recording
// each as a forge_suppressed event on the step that attempted it. A test run
// uses it so an operator's draft cannot touch a repository.
func SuppressForgeWrites(tc *TaskContext) {
tc.Forge = suppressedForge{Forger: tc.Forge, tc: tc}
tc.Trees = suppressedTrees{Trees: tc.Trees, tc: tc}
}
// suppress records one skipped write.
func (tc *TaskContext) suppress(action string) {
tc.Emit(events.KindForgeSuppressed, tc.Stage, action, nil)
}
type suppressedForge struct {
Forger
tc *TaskContext
}
func (f suppressedForge) CloseIssue(_ context.Context, owner, repo string, number int, _ string) error {
f.tc.suppress(fmt.Sprintf("Would close issue %s/%s#%d", owner, repo, number))
return nil
}
func (f suppressedForge) CreatePR(_ context.Context, owner, repo, title, head, base, _ string) (int, error) {
f.tc.suppress(fmt.Sprintf("Would open PR %q in %s/%s from %s into %s", title, owner, repo, head, base))
return 0, nil
}
func (f suppressedForge) LinkBranch(_ context.Context, owner, repo string, number int, branch string) error {
f.tc.suppress(fmt.Sprintf("Would link %s to %s/%s#%d", branch, owner, repo, number))
return nil
}
func (f suppressedForge) CreateReviewComments(_ context.Context, owner, repo string, number int, _ string, comments []ReviewComment) error {
f.tc.suppress(fmt.Sprintf("Would post %d review comments on %s/%s#%d", len(comments), owner, repo, number))
return nil
}
func (f suppressedForge) Comment(_ context.Context, owner, repo string, number int, body string) (int64, error) {
f.tc.suppress(fmt.Sprintf("Would comment on %s/%s#%d: %s", owner, repo, number, body))
return 0, nil
}
func (f suppressedForge) ReplyToReview(_ context.Context, owner, repo string, number int, _ int64, body string) error {
f.tc.suppress(fmt.Sprintf("Would reply to a review on %s/%s#%d: %s", owner, repo, number, body))
return nil
}
type suppressedTrees struct {
Trees
tc *TaskContext
}
func (t suppressedTrees) Push(_ context.Context, _, branch string) error {
t.tc.suppress(fmt.Sprintf("Would push branch %s", branch))
return nil
}
+43
View File
@@ -0,0 +1,43 @@
package workflow
import (
"context"
"testing"
"github.com/samcharles93/archie-core/internal/events"
)
// TestSuppressForgeWritesSkipsEveryWrite pins that a test run reaches neither
// the forge nor a push: the embedded nil Forger and Trees panic if any call
// falls through, and each skipped write is recorded as an event.
func TestSuppressForgeWritesSkipsEveryWrite(t *testing.T) {
bus := events.NewBus()
sub := bus.Subscribe(16)
defer sub.Close()
tc := &TaskContext{Task: &Task{Source: SourceTest, Owner: "o", Repo: "r"}, Bus: bus, Stage: "open-pr"}
SuppressForgeWrites(tc)
ctx := context.Background()
writes := map[string]func() error{
"close": func() error { return tc.Forge.CloseIssue(ctx, "o", "r", 1, "") },
"pr": func() error { _, err := tc.Forge.CreatePR(ctx, "o", "r", "t", "h", "b", ""); return err },
"link": func() error { return tc.Forge.LinkBranch(ctx, "o", "r", 1, "br") },
"review": func() error { return tc.Forge.CreateReviewComments(ctx, "o", "r", 1, "", nil) },
"comment": func() error { _, err := tc.Forge.Comment(ctx, "o", "r", 1, "hi"); return err },
"reply": func() error { return tc.Forge.ReplyToReview(ctx, "o", "r", 1, 2, "hi") },
"push": func() error { return tc.Trees.Push(ctx, "dir", "br") },
}
for name, write := range writes {
if err := write(); err != nil {
t.Fatalf("%s: %v", name, err)
}
select {
case event := <-sub.C:
if event.Kind != events.KindForgeSuppressed || event.Stage != "open-pr" || event.Detail == "" {
t.Fatalf("%s recorded %+v", name, event)
}
default:
t.Fatalf("%s was not recorded", name)
}
}
}
+8 -5
View File
@@ -22,11 +22,14 @@ const (
// KindToolCall marks one completed tool invocation during an agent stage
// run. Only emitted for runners that execute in the same process as their
// tools; see agentexec.ToolCallReporter.
KindToolCall = "tool_call" // data: tool, failed
KindParked = "parked" // data: reason
KindOutcome = "outcome" // data: status, detail
KindPRMerged = "pr_merged"
KindPRRejected = "pr_rejected"
KindToolCall = "tool_call" // data: tool, failed
// KindForgeSuppressed records a forge or push write a test run skipped.
// detail: what it would have done.
KindForgeSuppressed = "forge_suppressed"
KindParked = "parked" // data: reason
KindOutcome = "outcome" // data: status, detail
KindPRMerged = "pr_merged"
KindPRRejected = "pr_rejected"
// KindPRClosed records archie closing a task's PR when the task is rejected.
KindPRClosed = "pr_closed" // data: pr_number
// KindPRMergeRequested records an operator merging a task's PR from
+3
View File
@@ -190,6 +190,9 @@ func (s *Server) authorize(identity string, target Target, permission string) er
!strings.EqualFold(task.Owner, target.Owner) || !strings.EqualFold(task.Repo, target.Repo) {
return errors.New("forge request is outside its run's repository")
}
if task.IsTestRun() {
return errors.New("forge writes are suppressed in a test run")
}
name := workflow.PackageOf(task.WorkflowDefinitionYAML)
if name == "" {
return nil
@@ -186,6 +186,7 @@ SELECT workflow, stage,
COUNT(*) FILTER (WHERE (data::jsonb ->> 'error') IS NOT NULL)::int AS errors
FROM events
WHERE kind = 'stage_finish' AND ($1::text IS NULL OR org_id = $1)
AND task_id NOT IN (SELECT id FROM tasks WHERE source = 'test')
GROUP BY workflow, stage
ORDER BY workflow, stage
`
@@ -336,7 +337,7 @@ SELECT workflow,
AVG(iterations)::float8 AS avg_steps,
SUM(tokens_used)::bigint AS total_tokens
FROM tasks
WHERE workflow <> '' AND ($1::text IS NULL OR org_id = $1)
WHERE workflow <> '' AND source <> 'test' AND ($1::text IS NULL OR org_id = $1)
GROUP BY workflow
ORDER BY COUNT(*) DESC
`
@@ -391,24 +391,28 @@ func (q *Queries) EnqueueIssue(ctx context.Context, arg EnqueueIssueParams) (int
const insertChatTask = `-- name: InsertChatTask :one
WITH number AS (
INSERT INTO chat_issue_numbers (owner, repo, last_number)
VALUES ($1, $2, $10::bigint + 1)
VALUES ($1, $2, $12::bigint + 1)
ON CONFLICT (owner, repo) DO UPDATE SET last_number = chat_issue_numbers.last_number + 1
RETURNING last_number
)
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs, origin)
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs, origin, workflow_definition_yaml, workflow_definition_digest)
SELECT
$1, $2, number.last_number,
$3, $4, 'chat', $5, 'chat', $6,
owner_org.id,
$3, $4, 'chat', $5,
CASE WHEN $6::text = '' THEN 'chat' ELSE 'test' END,
$7,
$8
owner_org.id,
$8,
$9,
$6::text,
$10::text
FROM number, (SELECT COALESCE(
(SELECT a.org_id FROM org_agents a WHERE a.identity_id = $6),
(SELECT m.org_id FROM memberships m WHERE m.identity_id = $6
(SELECT a.org_id FROM org_agents a WHERE a.identity_id = $7),
(SELECT m.org_id FROM memberships m WHERE m.identity_id = $7
ORDER BY m.created_at, m.org_id, m.workspace_id NULLS LAST LIMIT 1),
'org-sys'
) AS id) AS owner_org
WHERE $9::text IS NULL OR owner_org.id = $9
WHERE $11::text IS NULL OR owner_org.id = $11
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, outcome_posted
`
@@ -418,9 +422,11 @@ type InsertChatTaskParams struct {
Title string
Body string
Workflow string
DraftYaml string
Identity string
Inputs string
Origin string
DraftDigest string
ScopeOrg pgtype.Text
FallbackIssueNumber int64
}
@@ -435,6 +441,8 @@ type InsertChatTaskParams struct {
// StampTaskBinding adds only the provenance.
// The task runs in its identity's org; a caller confined to another org
// inserts nothing, so it cannot start work under an identity it does not own.
// A non-empty draft_yaml makes the task a test run: it is pinned to that
// definition and its source is 'test'.
func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams) (Task, error) {
row := q.db.QueryRow(ctx, insertChatTask,
arg.Owner,
@@ -442,9 +450,11 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
arg.Title,
arg.Body,
arg.Workflow,
arg.DraftYaml,
arg.Identity,
arg.Inputs,
arg.Origin,
arg.DraftDigest,
arg.ScopeOrg,
arg.FallbackIssueNumber,
)
@@ -49,7 +49,7 @@ SELECT workflow,
AVG(iterations)::float8 AS avg_steps,
SUM(tokens_used)::bigint AS total_tokens
FROM tasks
WHERE workflow <> '' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
WHERE workflow <> '' AND source <> 'test' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
GROUP BY workflow
ORDER BY COUNT(*) DESC;
@@ -60,6 +60,7 @@ SELECT workflow, stage,
COUNT(*) FILTER (WHERE (data::jsonb ->> 'error') IS NOT NULL)::int AS errors
FROM events
WHERE kind = 'stage_finish' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
AND task_id NOT IN (SELECT id FROM tasks WHERE source = 'test')
GROUP BY workflow, stage
ORDER BY workflow, stage;
@@ -67,19 +67,25 @@ SELECT status, count(*)::int AS count FROM tasks WHERE (sqlc.narg(scope_org)::te
-- StampTaskBinding adds only the provenance.
-- The task runs in its identity's org; a caller confined to another org
-- inserts nothing, so it cannot start work under an identity it does not own.
-- A non-empty draft_yaml makes the task a test run: it is pinned to that
-- definition and its source is 'test'.
WITH number AS (
INSERT INTO chat_issue_numbers (owner, repo, last_number)
VALUES (sqlc.arg(owner), sqlc.arg(repo), sqlc.arg(fallback_issue_number)::bigint + 1)
ON CONFLICT (owner, repo) DO UPDATE SET last_number = chat_issue_numbers.last_number + 1
RETURNING last_number
)
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs, origin)
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs, origin, workflow_definition_yaml, workflow_definition_digest)
SELECT
sqlc.arg(owner), sqlc.arg(repo), number.last_number,
sqlc.arg(title), sqlc.arg(body), 'chat', sqlc.arg(workflow), 'chat', sqlc.arg(identity),
sqlc.arg(title), sqlc.arg(body), 'chat', sqlc.arg(workflow),
CASE WHEN sqlc.arg(draft_yaml)::text = '' THEN 'chat' ELSE 'test' END,
sqlc.arg(identity),
owner_org.id,
sqlc.arg(inputs),
sqlc.arg(origin)
sqlc.arg(origin),
sqlc.arg(draft_yaml)::text,
sqlc.arg(draft_digest)::text
FROM number, (SELECT COALESCE(
(SELECT a.org_id FROM org_agents a WHERE a.identity_id = sqlc.arg(identity)),
(SELECT m.org_id FROM memberships m WHERE m.identity_id = sqlc.arg(identity)
+14 -4
View File
@@ -156,11 +156,11 @@ func (s *Store) EnqueueIssue(ctx context.Context, owner, repo string, number int
// EnqueueChatTask inserts a queued chat task with a store-allocated synthetic
// issue number. origin names the conversation that created it, if any.
func (s *Store) EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity, origin string, inputs map[string]any) (*workflow.Task, error) {
return insertChatTask(ctx, s.queries(), owner, repo, title, body, wf, identity, origin, inputs)
func (s *Store) EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity, origin, draft string, inputs map[string]any) (*workflow.Task, error) {
return insertChatTask(ctx, s.queries(), owner, repo, title, body, wf, identity, origin, draft, inputs)
}
func insertChatTask(ctx context.Context, q *postgresdb.Queries, owner, repo, title, body, wf, identity, origin string, inputs map[string]any) (*workflow.Task, error) {
func insertChatTask(ctx context.Context, q *postgresdb.Queries, owner, repo, title, body, wf, identity, origin, draft string, inputs map[string]any) (*workflow.Task, error) {
encoded, err := task.EncodeInputs(inputs)
if err != nil {
return nil, err
@@ -170,6 +170,8 @@ func insertChatTask(ctx context.Context, q *postgresdb.Queries, owner, repo, tit
Owner: owner, Repo: repo, Title: title, Body: body, Workflow: wf, Identity: identity,
Inputs: encoded,
Origin: origin,
DraftYaml: draft,
DraftDigest: draftDigest(draft),
FallbackIssueNumber: syntheticIssueNumberBase - 1,
})
if errors.Is(err, pgx.ErrNoRows) {
@@ -181,6 +183,14 @@ func insertChatTask(ctx context.Context, q *postgresdb.Queries, owner, repo, tit
return taskFromRow(t), nil
}
// draftDigest pins a test run's definition; no draft has no digest.
func draftDigest(draft string) string {
if draft == "" {
return ""
}
return workflow.DigestDefinition(draft)
}
// EnqueueBindingTask claims the dispatch ledger row for the capture's
// delivery, inserts the task, stamps its binding provenance and records the
// task on the ledger row in one transaction. A concurrent claim of the same
@@ -204,7 +214,7 @@ func (s *Store) EnqueueBindingTask(ctx context.Context, owner, repo, title, body
if n == 0 {
return nil, fmt.Errorf("store: claim binding dispatch: capture %q not found", captureID)
}
t, err := insertChatTask(ctx, q, owner, repo, title, body, wf, identity, "", inputs)
t, err := insertChatTask(ctx, q, owner, repo, title, body, wf, identity, "", "", inputs)
if err != nil {
return nil, err
}
+2 -2
View File
@@ -101,12 +101,12 @@ func (c *Client) MarkOutcomePosted(ctx context.Context, taskID int64) error {
return unmapError(err)
}
func (c *Client) EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity, origin string, inputs map[string]any) (*task.Task, error) {
func (c *Client) EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity, origin, draft string, inputs map[string]any) (*task.Task, error) {
encoded, err := task.EncodeInputs(inputs)
if err != nil {
return nil, err
}
r, err := c.client.EnqueueChatTask(ctx, &pb.EnqueueChatTaskRequest{Owner: owner, Repo: repo, Title: title, Body: body, Workflow: wf, Identity: identity, InputsJson: encoded, Origin: origin})
r, err := c.client.EnqueueChatTask(ctx, &pb.EnqueueChatTaskRequest{Owner: owner, Repo: repo, Title: title, Body: body, Workflow: wf, Identity: identity, InputsJson: encoded, Origin: origin, DraftYaml: draft})
if err != nil {
return nil, unmapError(err)
}
+1 -1
View File
@@ -234,7 +234,7 @@ func (s *server) EnqueueChatTask(ctx context.Context, r *pb.EnqueueChatTaskReque
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
t, err := s.deps.Tasks.EnqueueChatTask(ctx, r.Owner, r.Repo, r.Title, r.Body, r.Workflow, r.Identity, r.Origin, inputs)
t, err := s.deps.Tasks.EnqueueChatTask(ctx, r.Owner, r.Repo, r.Title, r.Body, r.Workflow, r.Identity, r.Origin, r.DraftYaml, inputs)
if err != nil {
return nil, s.logErr("EnqueueChatTask", err)
}
+61 -7
View File
@@ -9,8 +9,12 @@ import (
"net/http"
"strings"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
controlpb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
"github.com/samcharles93/archie-core/internal/domain/org"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/events"
)
@@ -55,6 +59,10 @@ type workRequest struct {
// declaration before the task is admitted, so a request that could only
// fail at the workflow's first stage is refused here instead
Inputs map[string]any `json:"inputs"`
// Draft is an unsaved definition of Workflow to test-run instead of the
// stored one. The stored definition is untouched and the run writes
// nothing to a forge.
Draft string `json:"draft"`
}
func (s *Server) handleWorkRequest(w http.ResponseWriter, r *http.Request) {
@@ -86,13 +94,9 @@ func (s *Server) handleWorkRequest(w http.ResponseWriter, r *http.Request) {
http.Error(w, "identity, workflow, title, and instructions are required", http.StatusBadRequest)
return
}
iface, enabled, err := s.enabledWorkflowInterface(r.Context(), request.Workflow)
iface, code, err := s.workRequestInterface(r.Context(), request)
if err != nil {
http.Error(w, "workflow definitions unavailable", http.StatusServiceUnavailable)
return
}
if !enabled {
http.Error(w, "workflow is not enabled", http.StatusConflict)
http.Error(w, err.Error(), code)
return
}
if err := iface.CheckInputs(request.Inputs); err != nil {
@@ -104,7 +108,7 @@ func (s *Server) handleWorkRequest(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), status)
return
}
created, err := s.Store.EnqueueChatTask(r.Context(), owner, repo, request.Title, request.Instructions, request.Workflow, request.Identity, "", request.Inputs)
created, err := s.Store.EnqueueChatTask(r.Context(), owner, repo, request.Title, request.Instructions, request.Workflow, request.Identity, "", request.Draft, request.Inputs)
if err != nil {
s.logf("work request enqueue failed", "err", err)
http.Error(w, "work request rejected", http.StatusBadRequest)
@@ -115,6 +119,56 @@ func (s *Server) handleWorkRequest(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"ok": true, "task_id": created.ID})
}
// workRequestInterface returns the interface a request runs against: the
// draft's when it carries one, else the stored definition's. The workflow must
// be defined and enabled either way.
func (s *Server) workRequestInterface(ctx context.Context, request workRequest) (task.WorkflowInterface, int, error) {
iface, enabled, err := s.enabledWorkflowInterface(ctx, request.Workflow)
switch {
case err != nil:
return iface, http.StatusServiceUnavailable, errors.New("workflow definitions unavailable")
case !enabled:
return iface, http.StatusConflict, errors.New("workflow is not enabled")
case request.Draft != "":
return s.checkDraft(ctx, request.Workflow, request.Draft)
}
return iface, 0, nil
}
// checkDraft refuses a draft a save of the same document would refuse, and
// returns the interface the draft declares.
func (s *Server) checkDraft(ctx context.Context, id, draft string) (task.WorkflowInterface, int, error) {
if declared, err := workflow.DefinitionID(draft); err != nil || declared != id {
return task.WorkflowInterface{}, http.StatusBadRequest, errors.New("the draft must be a definition of the workflow being run")
}
collection, err := s.workflowCollection(ctx)
if err != nil {
return task.WorkflowInterface{}, http.StatusServiceUnavailable, errors.New("workflow definitions unavailable")
}
replaced := collection.Definitions[:0:0]
for _, entry := range collection.Definitions {
if entry.ID == id {
entry.YAML = draft
}
replaced = append(replaced, entry)
}
value, err := json.Marshal(task.WorkflowDefinitionCollection{Definitions: replaced})
if err != nil {
return task.WorkflowInterface{}, http.StatusInternalServerError, err
}
if _, err := s.ControlPlane.Command(ctx, &controlpb.CommandRequest{Kind: workflowDefinitionsKind, Command: "validate", ValueJson: value}); err != nil {
if status.Code(err) == codes.InvalidArgument {
return task.WorkflowInterface{}, http.StatusBadRequest, errors.New(status.Convert(err).Message())
}
return task.WorkflowInterface{}, http.StatusServiceUnavailable, errors.New("workflow definitions unavailable")
}
iface, err := task.ParseWorkflowInterface(draft)
if err != nil {
return task.WorkflowInterface{}, http.StatusBadRequest, err
}
return iface, 0, nil
}
// workRequestRepository checks a requested "owner/name" against the
// workflow's repository mode and the configured repositories, and returns it
// split. A workflow that takes none refuses one; one that requires it refuses
+3
View File
@@ -61,6 +61,9 @@ func publishable(ctx context.Context, runs Runs, token, identity string) (*workf
!worktree.ValidCoordinates(task.Owner, task.Repo, task.IssueNumber) {
return nil, errors.New("worktree publication grant is invalid")
}
if task.IsTestRun() {
return nil, errors.New("pushes are suppressed in a test run")
}
return task, nil
}
+3
View File
@@ -696,6 +696,9 @@ message EnqueueChatTaskRequest {
string inputs_json = 7;
// origin names the conversation that created the task; empty for none.
string origin = 8;
// draft_yaml, when set, makes the task a test run of that unsaved
// definition: it is pinned to it and writes nothing to a forge.
string draft_yaml = 9;
}
message EnqueueChatTaskResponse { Task task = 1; }
+1 -1
View File
@@ -1 +1 @@
.vue-flow{z-index:0;direction:ltr;width:100%;height:100%;position:relative;overflow:hidden}.vue-flow__container{width:100%;height:100%;position:absolute;top:0;left:0}.vue-flow__pane{z-index:1}.vue-flow__pane.draggable{cursor:grab}.vue-flow__pane.selection{cursor:pointer}.vue-flow__pane.dragging{cursor:grabbing}.vue-flow__transformationpane{transform-origin:0 0;z-index:2;pointer-events:none}.vue-flow__viewport{z-index:4;overflow:clip}.vue-flow__selection{z-index:6}.vue-flow__edge-labels{pointer-events:none;-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute}.vue-flow__nodesselection-rect:focus,.vue-flow__nodesselection-rect:focus-visible{outline:none}.vue-flow .vue-flow__edges{pointer-events:none;overflow:visible}.vue-flow__edge-path,.vue-flow__connection-path{stroke:#b1b1b7;stroke-width:1px;fill:none}.vue-flow__edge{pointer-events:visibleStroke;cursor:pointer}.vue-flow__edge.animated path{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.vue-flow__edge.animated path.vue-flow__edge-interaction{stroke-dasharray:none;animation:none}.vue-flow__edge.inactive{pointer-events:none}.vue-flow__edge.selected,.vue-flow__edge:focus,.vue-flow__edge:focus-visible{outline:none}.vue-flow__edge.selected .vue-flow__edge-path,.vue-flow__edge:focus .vue-flow__edge-path,.vue-flow__edge:focus-visible .vue-flow__edge-path{stroke:#555}.vue-flow__edge-textwrapper{pointer-events:all}.vue-flow__edge-textbg{fill:#fff}.vue-flow__edge-text{pointer-events:none;-webkit-user-select:none;user-select:none}.vue-flow__connection{pointer-events:none}.vue-flow__connection .animated{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.vue-flow__connectionline{z-index:1001}.vue-flow__nodes{pointer-events:none;transform-origin:0 0}.vue-flow__node{-webkit-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default;position:absolute}.vue-flow__node.draggable{cursor:grab;pointer-events:all}.vue-flow__node.draggable.dragging{cursor:grabbing}.vue-flow__nodesselection{z-index:3;transform-origin:0 0;pointer-events:none}.vue-flow__nodesselection-rect{pointer-events:all;cursor:grab;position:absolute}.vue-flow__nodesselection-rect.dragging{cursor:grabbing}.vue-flow__handle{pointer-events:none;min-width:5px;min-height:5px;position:absolute}.vue-flow__handle.connectable{pointer-events:all;cursor:crosshair}.vue-flow__handle-bottom{bottom:0;left:50%;transform:translate(-50%,50%)}.vue-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.vue-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.vue-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.vue-flow__edgeupdater{cursor:move;pointer-events:all}.vue-flow__panel{z-index:5;margin:15px;position:absolute}.vue-flow__panel.top{top:0}.vue-flow__panel.bottom{bottom:0}.vue-flow__panel.left{left:0}.vue-flow__panel.right{right:0}.vue-flow__panel.center{left:50%;transform:translate(-50%)}@keyframes dashdraw{0%{stroke-dashoffset:10px}}.vue-flow__controls{box-shadow:0 0 2px 1px #00000014}.vue-flow__controls-button{box-sizing:content-box;cursor:pointer;-webkit-user-select:none;user-select:none;background:#fefefe;border:none;border-bottom:1px solid #eee;justify-content:center;align-items:center;width:16px;height:16px;padding:5px;display:flex}.vue-flow__controls-button svg{width:100%;max-width:12px;max-height:12px}.vue-flow__controls-button:hover{background:#f4f4f4}.vue-flow__controls-button:disabled{pointer-events:none}.vue-flow__controls-button:disabled svg{fill-opacity:.4}.workflow-flow-edge path{stroke:var(--color-muted-foreground);stroke-width:1.5px}.workflow-flow-edge.trace-ok path{stroke:var(--color-ok)}.workflow-flow-edge.trace-failed path{stroke:var(--color-danger)}.workflow-flow-edge.trace-interrupted path{stroke:var(--color-warn)}.workflow-flow-edge.trace-running path{stroke:var(--color-info);stroke-dasharray:6 4;animation:.8s linear infinite edge-trace}@keyframes edge-trace{to{stroke-dashoffset:-10px}}@media (prefers-reduced-motion:reduce){.workflow-flow-edge.trace-running path,.step-running{animation:none}}.workflow-data-edge path{stroke:var(--color-primary);stroke-dasharray:5 4;stroke-width:1.25px}@keyframes step-running{50%{box-shadow:0 0 0 4px color-mix(in oklab, var(--color-info) 30%, transparent)}}.step-running{animation:1.6s ease-in-out infinite step-running}.workflow-canvas .vue-flow__controls{box-shadow:none}.workflow-canvas .vue-flow__controls-button{background:var(--color-card);border-color:var(--color-border);fill:var(--color-foreground)}.workflow-canvas .vue-flow__controls-button:hover{background:var(--color-secondary)}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reLine truncated
.vue-flow{z-index:0;direction:ltr;width:100%;height:100%;position:relative;overflow:hidden}.vue-flow__container{width:100%;height:100%;position:absolute;top:0;left:0}.vue-flow__pane{z-index:1}.vue-flow__pane.draggable{cursor:grab}.vue-flow__pane.selection{cursor:pointer}.vue-flow__pane.dragging{cursor:grabbing}.vue-flow__transformationpane{transform-origin:0 0;z-index:2;pointer-events:none}.vue-flow__viewport{z-index:4;overflow:clip}.vue-flow__selection{z-index:6}.vue-flow__edge-labels{pointer-events:none;-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute}.vue-flow__nodesselection-rect:focus,.vue-flow__nodesselection-rect:focus-visible{outline:none}.vue-flow .vue-flow__edges{pointer-events:none;overflow:visible}.vue-flow__edge-path,.vue-flow__connection-path{stroke:#b1b1b7;stroke-width:1px;fill:none}.vue-flow__edge{pointer-events:visibleStroke;cursor:pointer}.vue-flow__edge.animated path{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.vue-flow__edge.animated path.vue-flow__edge-interaction{stroke-dasharray:none;animation:none}.vue-flow__edge.inactive{pointer-events:none}.vue-flow__edge.selected,.vue-flow__edge:focus,.vue-flow__edge:focus-visible{outline:none}.vue-flow__edge.selected .vue-flow__edge-path,.vue-flow__edge:focus .vue-flow__edge-path,.vue-flow__edge:focus-visible .vue-flow__edge-path{stroke:#555}.vue-flow__edge-textwrapper{pointer-events:all}.vue-flow__edge-textbg{fill:#fff}.vue-flow__edge-text{pointer-events:none;-webkit-user-select:none;user-select:none}.vue-flow__connection{pointer-events:none}.vue-flow__connection .animated{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.vue-flow__connectionline{z-index:1001}.vue-flow__nodes{pointer-events:none;transform-origin:0 0}.vue-flow__node{-webkit-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default;position:absolute}.vue-flow__node.draggable{cursor:grab;pointer-events:all}.vue-flow__node.draggable.dragging{cursor:grabbing}.vue-flow__nodesselection{z-index:3;transform-origin:0 0;pointer-events:none}.vue-flow__nodesselection-rect{pointer-events:all;cursor:grab;position:absolute}.vue-flow__nodesselection-rect.dragging{cursor:grabbing}.vue-flow__handle{pointer-events:none;min-width:5px;min-height:5px;position:absolute}.vue-flow__handle.connectable{pointer-events:all;cursor:crosshair}.vue-flow__handle-bottom{bottom:0;left:50%;transform:translate(-50%,50%)}.vue-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.vue-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.vue-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.vue-flow__edgeupdater{cursor:move;pointer-events:all}.vue-flow__panel{z-index:5;margin:15px;position:absolute}.vue-flow__panel.top{top:0}.vue-flow__panel.bottom{bottom:0}.vue-flow__panel.left{left:0}.vue-flow__panel.right{right:0}.vue-flow__panel.center{left:50%;transform:translate(-50%)}@keyframes dashdraw{0%{stroke-dashoffset:10px}}.vue-flow__controls{box-shadow:0 0 2px 1px #00000014}.vue-flow__controls-button{box-sizing:content-box;cursor:pointer;-webkit-user-select:none;user-select:none;background:#fefefe;border:none;border-bottom:1px solid #eee;justify-content:center;align-items:center;width:16px;height:16px;padding:5px;display:flex}.vue-flow__controls-button svg{width:100%;max-width:12px;max-height:12px}.vue-flow__controls-button:hover{background:#f4f4f4}.vue-flow__controls-button:disabled{pointer-events:none}.vue-flow__controls-button:disabled svg{fill-opacity:.4}.workflow-flow-edge path{stroke:var(--color-muted-foreground);stroke-width:1.5px}.workflow-flow-edge.trace-ok path{stroke:var(--color-ok)}.workflow-flow-edge.trace-failed path{stroke:var(--color-danger)}.workflow-flow-edge.trace-interrupted path{stroke:var(--color-warn)}.workflow-flow-edge.trace-running path{stroke:var(--color-info);stroke-dasharray:6 4;animation:.8s linear infinite edge-trace}@keyframes edge-trace{to{stroke-dashoffset:-10px}}@media (prefers-reduced-motion:reduce){.workflow-flow-edge.trace-running path,.step-running{animation:none}}.workflow-data-edge path{stroke:var(--color-primary);stroke-dasharray:5 4;stroke-width:1.25px}@keyframes step-running{50%{box-shadow:0 0 0 4px color-mix(in oklab, var(--color-info) 30%, transparent)}}.step-running{animation:1.6s ease-in-out infinite step-running}.workflow-canvas .vue-flow__controls{box-shadow:none}.workflow-canvas .vue-flow__controls-button{background:var(--color-card);border-color:var(--color-border);fill:var(--color-foreground)}.workflow-canvas .vue-flow__controls-button:hover{background:var(--color-secondary)}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reLine truncated
+71 -69
View File
@@ -1,68 +1,68 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentProfilesPage.js","assets/HistoryLink.js","assets/PageHeader.js","assets/alert.js","assets/CredentialBindingsPage.js","assets/PlaybooksPage.js","assets/HarnessPage.js","assets/HarnessPage.css","assets/NotFoundPage.js"])))=>i.map(i=>d[i]);
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as ee,Z as T,_ as te,a as E,b as ne,c as D,d as re,et as O,f as ie,g as ae,h as k,i as oe,j as se,k as ce,l as le,m as ue,n as de,nt as fe,o as pe,p as me,q as he,r as ge,rt as _e,s as ve,t as ye,tt as be,u as xe,v as Se,w as Ce,x as we,y as Te,z as Ee}from"./HistoryLink.js";import{$ as De,A,B as Oe,C as ke,Ct as Ae,D as j,Dn as je,En as Me,Ft as Ne,It as Pe,Jt as M,Kt as Fe,Mt as Ie,O as N,Pt as Le,Qn as P,R as Re,Rt as ze,Sn as Be,St as F,Tn as Ve,Tt as He,Ut as I,V as Ue,Wt as We,X as Ge,Xt as Ke,Y as qe,Zt as Je,_ as L,_n as Ye,_t as Xe,an as Ze,at as Qe,b as R,bn as $e,d as et,dn as tt,er as nt,et as rt,ht as z,it,kn as B,lt as V,mn as at,nr as H,nt as ot,on as st,pn as ct,pt as lt,rn as ut,s as U,t as dt,tr as ft,tt as W,v as G,vn as pt,wn as mt,x as K,xt as q,y as J,yn as Y,zt as ht}from"./PageHeader.js";import{E as gt,G as _t,J as vt,K as yt,S as bt,T as xt,Y as St,_ as Ct,a as wt,c as Tt,d as Et,f as Dt,h as Ot,i as kt,k as At,l as jt,m as Mt,n as Nt,o as X,p as Pt,q as Ft,r as It,s as Lt,t as Rt,u as zt,v as Z,w as Q,y as Bt}from"./alert.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Vt=xt({name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]}),Ht=xt({name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]}),Ut=xt({name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]}),Wt=xt({name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]}),Gt=xt({name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]}),Kt=xt({name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]}),qt=xt({name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]}),Jt=xt({name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]}),Yt=xt({name:`braces`,size:24,node:[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]],aliases:[`curly-braces`]}),Xt=xt({name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]}),Zt=xt({name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]}),Qt=xt({name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]}),$t=xt({name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]}),en=xt({name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]}),tn=xt({name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]}),nn=xt({name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]}),rn=xt({name:`circle-dot`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]}),an=xt({name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.8 Line truncated
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as w,Y as ee,Z as T,_ as te,a as E,b as ne,c as D,d as re,et as O,f as ie,g as ae,h as k,i as oe,j as se,k as ce,l as le,m as ue,n as de,nt as fe,o as pe,p as me,q as he,r as ge,rt as _e,s as ve,t as ye,tt as be,u as xe,v as Se,w as Ce,x as we,y as Te,z as Ee}from"./HistoryLink.js";import{$ as De,A,B as Oe,C as ke,Ct as Ae,D as j,Dn as je,En as Me,Ft as Ne,It as Pe,Jt as M,Kt as Fe,Mt as Ie,O as N,Pt as Le,Qn as P,R as Re,Rt as ze,Sn as Be,St as F,Tn as Ve,Tt as He,Ut as I,V as Ue,Wt as We,X as Ge,Xt as Ke,Y as qe,Zt as Je,_ as L,_n as Ye,_t as Xe,an as Ze,at as Qe,b as R,bn as $e,d as et,dn as tt,er as nt,et as rt,ht as z,it,kn as B,lt as V,mn as at,nr as H,nt as ot,on as st,pn as ct,pt as lt,rn as ut,s as U,t as dt,tr as ft,tt as W,v as G,vn as pt,wn as mt,x as K,xt as q,y as J,yn as Y,zt as ht}from"./PageHeader.js";import{E as gt,G as _t,J as vt,K as yt,S as bt,T as xt,Y as St,_ as Ct,a as wt,c as Tt,d as Et,f as Dt,h as Ot,i as kt,k as At,l as jt,m as Mt,n as Nt,o as X,p as Pt,q as Ft,r as It,s as Lt,t as Rt,u as zt,v as Z,w as Q,y as Bt}from"./alert.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Vt=xt({name:`arrow-down`,size:24,node:[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]}),Ht=xt({name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]}),Ut=xt({name:`arrow-up-down`,size:24,node:[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]}),Wt=xt({name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]}),Gt=xt({name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]}),Kt=xt({name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]}),qt=xt({name:`book-open`,size:24,node:[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]}),Jt=xt({name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]}),Yt=xt({name:`braces`,size:24,node:[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]],aliases:[`curly-braces`]}),Xt=xt({name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]}),Zt=xt({name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]}),Qt=xt({name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]}),$t=xt({name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]}),en=xt({name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]}),tn=xt({name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]}),nn=xt({name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]}),rn=xt({name:`circle-dot`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]}),an=xt({name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.8 Line truncated
`);d=n.pop()||``;for(let e of n){let t=e.split(`
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(ur.value=n.session_id),n.type===`delta`&&(o+=n.text,hr.value=hr.value?{...hr.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],hr.value=hr.value?{...hr.value,tools:a}:null),n.type===`ask`&&n.ask&&(clearTimeout(l),hr.value=hr.value?{...hr.value,ask:n.ask}: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`);dr.value=[...dr.value,{from:`assistant`,text:o,tool_calls:a}],hr.value=null,pr.value=`Ready`,await Ar()}catch(e){let t=e;t.name===`AbortError`&&!c?(hr.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},pr.value=`Stopped`):(hr.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?rr(r):void 0,isRetry:i},pr.value=`Error. Retry available.`)}finally{clearTimeout(l),sr=null,Or=null,mr.value=!1}}function Ur(){pr.value=`Stopping…`,ur.value&&Z.chatCancel(ur.value).catch(()=>{}),kr()}function Wr(){V(()=>{Ar().catch(e=>{pr.value=e.message||`Chat unavailable`})}),lt(()=>{kr()})}async function Gr(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));await Hr({textOverride:`🎤 Voice message`,voice:{data:btoa(n),mime_type:e.type||`audio/webm`}})}var Kr=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],qr=A({__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)=>(z(),K(`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":B(ar),onClick:i[0]||=e=>n(`toggle`)},[G(`span`,{"aria-hidden":`true`,class:P(r(!e.open))},[N(B(vn),{size:22})],2),G(`span`,{"aria-hidden":`true`,class:P(r(e.open))},[N(B(qn),{size:22})],2)],8,Kr))}});function Jr(e){return typeof e==`string`?`'${e}'`:new Qr().serialize(e)}var Yr=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Xr=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Yr.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Zr(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&&Xr[n]?Xr[n]:n+128,s=a<128&&Xr[a]?Xr[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 Qr=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Zr(e,t):n===`number`&&r===`number`?e-t:Zr(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(Zr),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.$ArrayLine truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(dr.value=n.session_id),n.type===`delta`&&(o+=n.text,gr.value=gr.value?{...gr.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],gr.value=gr.value?{...gr.value,tools:a}:null),n.type===`ask`&&n.ask&&(clearTimeout(l),gr.value=gr.value?{...gr.value,ask:n.ask}: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`);fr.value=[...fr.value,{from:`assistant`,text:o,tool_calls:a}],gr.value=null,mr.value=`Ready`,await jr()}catch(e){let t=e;t.name===`AbortError`&&!c?(gr.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},mr.value=`Stopped`):(gr.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?ir(r):void 0,isRetry:i},mr.value=`Error. Retry available.`)}finally{clearTimeout(l),cr=null,kr=null,hr.value=!1}}function Wr(){mr.value=`Stopping…`,dr.value&&Z.chatCancel(dr.value).catch(()=>{}),Ar()}function Gr(){V(()=>{jr().catch(e=>{mr.value=e.message||`Chat unavailable`})}),lt(()=>{Ar()})}async function Kr(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));await Ur({textOverride:`🎤 Voice message`,voice:{data:btoa(n),mime_type:e.type||`audio/webm`}})}var qr=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Jr=A({__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)=>(z(),K(`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":B(or),onClick:i[0]||=e=>n(`toggle`)},[G(`span`,{"aria-hidden":`true`,class:P(r(!e.open))},[N(B(yn),{size:22})],2),G(`span`,{"aria-hidden":`true`,class:P(r(e.open))},[N(B(Jn),{size:22})],2)],8,qr))}});function Yr(e){return typeof e==`string`?`'${e}'`:new $r().serialize(e)}var Xr=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Zr=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Xr.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Qr(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&&Zr[n]?Zr[n]:n+128,s=a<128&&Zr[a]?Zr[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 $r=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Qr(e,t):n===`number`&&r===`number`?e-t:Qr(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(Qr),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.$ArrayLine truncated
- a positive number
- less than the value passed to \`max\` (or ${qs} if no \`max\` prop is set)
- less than the value passed to \`max\` (or ${Js} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`),null)}function Qs(e){return Xs(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 \`${qs}\`.`),qs)}var $s=A({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:qs},getValueLabel:{type:Function,required:!1,default:(e,t)=>Xs(e)?`${Math.round(e/t*qs)}%`: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;p();let i=x(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=x(n,`max`,r,{passive:n.max===void 0});I(()=>i.value,async e=>{let t=Zs(e,n.max);t!==e&&(await ot(),i.value=t)},{immediate:!0}),I(()=>n.max,e=>{let t=Qs(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=L(()=>ii(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return Ys({modelValue:i,max:a,progressState:o}),(t,n)=>(z(),J(B(Mt),{"as-child":e.asChild,as:e.as,"aria-valuemax":B(a),"aria-valuemin":0,"aria-valuenow":Xs(B(i))?B(i):void 0,"aria-valuetext":e.getValueText?.(B(i),B(a)),"aria-label":e.getValueLabel(B(i),B(a)),role:`progressbar`,"data-state":o.value,"data-value":B(i)??void 0,"data-max":B(a)},{default:M(()=>[F(t.$slots,`default`,{modelValue:B(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),ec=A({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=Js();return p(),(e,r)=>(z(),J(B(Mt),W(t,{"data-state":B(n).progressState.value,"data-value":B(n).modelValue?.value??void 0,"data-max":B(n).max.value}),{default:M(()=>[F(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),tc=`radio.select`;function nc(e,t,n){_(tc,n,{originalEvent:e,value:t})}var rc=A({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=x(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=Me(n),{forwardRef:o,currentElement:s}=p(),c=mi(s),l=hi(),u=L(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||nc(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(t,n)=>(z(),K(U,null,[N(B(Mt),W({id:e.id,ref:B(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":B(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":B(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:B(a),required:e.required,name:e.name},{...B(l),...t.$attrs},{onClick:St(d,[`stop`])}),{default:M(()=>[F(t.$slots,`default`,{checked:B(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),B(c)&&e.name?(z(),J(B(Ia),W({key:0,type:`radio`,tabindex:`-1`,value:B(a),checked:!!B(i),name:e.name,disabled:e.disabled,required:e.required},B(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):R(`v-if`,!0)],64))}}),[ic,ac]=O(`RadioGroupRoot`),oc=A({__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}=p(),s=x(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:c,loop:l,orientation:u,name:d,required:f,dir:m}=Me(n),h=o(m),g=mi(a);return ac({modelValue:s,changeModelValue:e=>{s.value=e},disabled:c,loop:l,orientation:u,name:d?.value,required:f}),(t,n)=>(z(),J(B(bo),{"as-child":``,orientation:B(u),dir:B(h),loop:B(l)},{default:M(()=>[N(B(Mt),{ref:B(i),role:`radiogroup`,"data-disabled":B(c)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":B(u),"aria-required":B(f),dir:B(h)},{default:M(()=>[F(t.$slots,`default`,{modelValue:B(s)}),B(g)&&B(d)?(z(),J(B(Ia),{key:0,required:B(f),disabled:B(c),value:B(s),name:B(d)},null,8,[`required`,`disabled`,`value`,`name`])):R(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[sc,cc]=O(`RadioGroupItem`),lc=A({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:null,requirLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:jd(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>jd(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=Nd(c),u=e+1<n.length?Nd(n[e+1]):null;if(l&&u&&Pd(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=Nd(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>jd(e)),rows:r.map(e=>e.map(e=>jd(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:jd(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])}else c.startsWith(`>`)?(o(),s(),t.push({kind:`blockquote`,inline:jd(c.replace(/^>\s?/,``))})):r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function Nd(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 Pd(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Fd={class:`[overflow-wrap:anywhere]`},Id={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},Ld={class:`font-mono text-[0.85em]`},Rd={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},zd={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Bd={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Vd={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Hd={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Ud={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Wd={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Gd={key:8,class:`mb-2.5 last:mb-0`},Kd=A({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=L(()=>Md(t.text));return(e,t)=>(z(),K(`div`,Fd,[(z(!0),K(U,null,q(n.value,(e,t)=>(z(),K(U,{key:t},[e.kind===`pre`?(z(),K(`pre`,Id,[G(`code`,Ld,H(e.code),1)])):e.kind===`table`?(z(),K(`table`,Rd,[G(`thead`,null,[G(`tr`,null,[(z(!0),K(U,null,q(e.head,(e,t)=>(z(),K(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[N(kd,{inline:e},null,8,[`inline`])]))),128))])]),G(`tbody`,null,[(z(!0),K(U,null,q(e.rows,(e,t)=>(z(),K(`tr`,{key:t},[(z(!0),K(U,null,q(e,(e,t)=>(z(),K(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[N(kd,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(z(),K(`blockquote`,zd,[N(kd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(z(),K(`h1`,Bd,[N(kd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(z(),K(`h2`,Vd,[N(kd,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(z(),K(`h3`,Hd,[N(kd,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(z(),K(`ul`,Ud,[(z(!0),K(U,null,q(e.items,(e,t)=>(z(),K(`li`,{key:t},[N(kd,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(z(),K(`ol`,Wd,[(z(!0),K(U,null,q(e.items,(e,t)=>(z(),K(`li`,{key:t},[N(kd,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(z(),K(`p`,Gd,[N(kd,{inline:e.inline},null,8,[`inline`])])):R(``,!0)],64))),128))]))}}),qd={class:`truncate`},Jd=A({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=Ae(`RouterLink`);return z(),J(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-md 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:M(()=>[N(B(Wt),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),G(`span`,qd,H(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Yd={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Xd={class:`font-semibold text-foreground`},Zd={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Qd=A({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=L(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=L(()=>t.tool.parameters||t.tool.Parameters||``),i=L(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=L(()=>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?(z(),J(Jd,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(z(),K(`div`,Yd,[N(B(Kn),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),G(`span`,Xd,H(n.value),1),r.value?(z(),K(`code`,Zd,H(r.value),1)):R(``,!0),G(`span`,{class:P(B(Q)(`text-fg-muted`,i.value&&`text-danger`))},H(a.value),3)]))}}),$d={key:0,class:`mb-2 grid gap-0.5 text-xs`},ef={key:1,class:`mb-2 flex flex-wrap gap-1.5`},tf={key:3,class:`whitespace-pre-wrap`},nf=A({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(z(),K(`div`,{class:P([`flex`,e.assistant?`justify-start`:`justify-end`])},[G(`div`,{class:P(B(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?(z(),K(`div`,$d,[(z(!0),K(U,null,q(e.tools,(t,n)=>(z(),J(Qd,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):R(``,!0),e.media.length?(z(),K(`div`,ef,[(z(!0),K(U,null,q(e.media,(e,t)=>(z(),J(Sd,{key:t,attachment:e},null,8,[`attachment`]))),128))])):R(``,!0),e.assistant?(z(),J(Kd,{key:2,text:e.text},null,8,[`text`])):(z(),K(`div`,tf,H(e.text),1)),F(t.$slots,`default`)],2)],2))}}),rf={class:`text-sm`},af={class:`font-medium`},of={key:0,class:`mt-1 text-fg-muted`},sf={key:1,class:`mt-2 flex flex-wrap gap-2`},cf=A({__name:`ChatChooLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>G_?`${n.slice(0,G_).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var q_=[`title`],J_=A({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=qg(),a=L(()=>i.taskIDFor(n.event)),o=L(()=>K_(n.event));function s(){a.value>0&&r(`open`,a.value)}let c=L(()=>n.event.at?Eg(n.event.at):`—`);return(e,t)=>(z(),J(B(H_),{class:P(a.value>0?`cursor-pointer`:``),role:a.value>0?`link`:void 0,tabindex:a.value>0?0:void 0,title:a.value>0?`Open task details`:void 0,onClick:s,onKeydown:[vt(St(s,[`prevent`]),[`enter`]),vt(St(s,[`prevent`]),[`space`])]},{default:M(()=>[N(B($),{class:`font-medium`},{default:M(()=>[j(H(n.event.kind||n.event.type||`event`),1)]),_:1}),N(B($),{class:`font-mono`},{default:M(()=>[j(H(a.value>0?`#${a.value}`:`—`),1)]),_:1}),N(B($),{class:`w-[55%] max-w-0`},{default:M(()=>[G(`span`,{class:`block truncate`,title:o.value.truncated?o.value.full:void 0},H(o.value.text),9,q_)]),_:1}),N(B($),null,{default:M(()=>[j(H(c.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),Y_=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function X_(e){return(Number(e?.task_id)||0)>0}function Z_(e,t){return t===`tasks`?X_(e):t!==`system`||!X_(e)}function Q_(e,t){return e.filter(e=>Z_(e,t))}function $_(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function ev(e,t){return`${e}:${t??0}`}function tv(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=ev(K_(n).text,r),a=t[t.length-1];a&&a.key===i?(a.count+=1,a.events.push(n)):t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var nv={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},rv={class:`max-h-[28rem] overflow-y-auto`},iv=[`aria-expanded`,`aria-label`,`onClick`],av=[`title`],ov=A({__name:`LiveActivityCard`,setup(e){let t=sp(),{activity:n}=_e(ue()),r=Y(`all`),i=L(()=>Q_(n.value,r.value)),a=L(()=>$_(i.value.length,r.value)),o=Ye(new Set),s=L(()=>tv(i.value));function c(e){o.has(e)?o.delete(e):o.add(e)}function l(e){return o.has(e.key)}function u(e){return K_(e.representative)}function d(e){return e.representative.at?Eg(e.representative.at):`—`}function f(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(z(),J(B(yg),null,{default:M(()=>[N(B(wg),null,{default:M(()=>[N(B(Tg),null,{default:M(()=>[...t[1]||=[j(`Live activity`,-1)]]),_:1}),N(B(bg),{class:`flex items-center gap-2`},{default:M(()=>[N(B(I_),{type:`single`,variant:`outline`,size:`sm`,"model-value":r.value,"aria-label":`Filter activity`,"onUpdate:modelValue":t[0]||=e=>{e&&(r.value=e)}},{default:M(()=>[(z(!0),K(U,null,q(B(Y_),e=>(z(),J(B(R_),{key:e.value,value:e.value},{default:M(()=>[j(H(e.label),1)]),_:2},1032,[`value`]))),128))]),_:1},8,[`model-value`])]),_:1})]),_:1}),N(B(xg),null,{default:M(()=>[G(`div`,nv,[G(`div`,rv,[N(B(B_),null,{default:M(()=>[N(B(W_),{class:`sticky top-0 z-10 bg-card`},{default:M(()=>[N(B(H_),null,{default:M(()=>[N(B(U_),null,{default:M(()=>[...t[2]||=[j(`Event`,-1)]]),_:1}),N(B(U_),null,{default:M(()=>[...t[3]||=[j(`Task`,-1)]]),_:1}),N(B(U_),null,{default:M(()=>[...t[4]||=[j(`Detail`,-1)]]),_:1}),N(B(U_),null,{default:M(()=>[...t[5]||=[j(`When`,-1)]]),_:1})]),_:1})]),_:1}),N(B(V_),null,{default:M(()=>[i.value.length?R(``,!0):(z(),J(B(H_),{key:0},{default:M(()=>[N(B($),{colspan:`4`},{default:M(()=>[N(B(ug),null,{default:M(()=>[N(B(pg),null,{default:M(()=>[N(B(gg),null,{default:M(()=>[j(H(a.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),i.value.length?(z(!0),K(U,{key:1},q(s.value,e=>(z(),K(U,{key:e.key},[e.count===1?(z(),J(J_,{key:0,event:e.representative,onOpen:f},null,8,[`event`])):(z(),K(U,{key:1},[N(B(H_),{class:P(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&&f(e.taskID),onKeydown:[vt(St(t=>e.taskID>0&&f(e.taskID),[`prevent`]),[`enter`]),vt(St(t=>e.taskID>0&&f(e.taskID),[`prevent`]),[`space`])]},{default:M(()=>[N(B($),{class:`font-medium`},{default:M(()=>[G(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":l(e),"aria-label":`${l(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:St(t=>c(e.key),[`stop`])},[l(e)?(z(),J(B(Qt),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(z(),J(B($t),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),j(` `+H(e.label)+` `,1),N(B(kt),{variant:`idle`},{default:M(()=>[j(`×`+H(e.count),1)]),_:2},1024)],8,iv)]),_:2},1024),N(B($),{class:`font-mono`},{default:M(()=>[j(H(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),N(B($),{class:`w-[55%] max-w-0`},{default:M(()=>[G(`span`,{class:`block truncate`,title:u(e).truncated?u(e).full:void 0},H(u(e).text),9,av)]),_:2},1024),N(B($),null,{default:M(()=>[j(H(d(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydowLine 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 fy(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 py(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 my(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 hy(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 gy=Y([]),_y=Y([]),vy=Y(!0),yy=Y(null),by=Y(null),xy=Y(!1),Sy=Y(null);async function Cy(){try{let e=await Z.eventTypes(uy().workspace);vy.value=e.enabled!==!1,gy.value=e.event_types||[],_y.value=e.proposals||[],yy.value=null}catch(e){yy.value=e.message||String(e)}}function wy(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function Ty(e){Sy.value=null,by.value=e}function Ey(e){let t=Py.value.find(t=>String(t.id)===e.sample_id);Ty({mode:`proposal`,id:null,source:e.source,name:``,rule:wy(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function Dy(e=``){Ty({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function Oy(e){Ty({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:wy(e.rule),headersText:``,body:``,exampleHeaders:{}})}function ky(){by.value=null}async function Ay(){let e=by.value;if(e){xy.value=!0;try{if(e.mode===`edit`&&e.id)await Z.eventTypeUpdate(e.id,{name:e.name,rule:hy(e.rule)});else{let t=e.mode===`paste`?dy(e.headersText):e.exampleHeaders;await Z.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:hy(e.rule),example:{headers:t,body:e.body}})}by.value=null,await Cy()}catch(e){Sy.value=e.message||String(e)}finally{xy.value=!1}}}var jy=Y(null);async function My(){let e=jy.value;if(jy.value=null,e)try{await Z.eventTypeDelete(e.id),await Cy()}catch(e){yy.value=e.message||String(e)}}var Ny=100,Py=Y([]),Fy=Y(!0),Iy=Y(null),Ly=Y(!0),Ry=Y(null);async function zy(){try{let e=await Z.captures(Ny);Fy.value=e.enabled!==!1,Py.value=e.captures||[],Iy.value=null}catch(e){Iy.value=e.message||String(e)}finally{Ly.value=!1}}function By(e){let t=Py.value.find(t=>t.id===e);return t&&(Ry.value=t),!!t}function Vy(){Py.value.length&&(Ry.value=Py.value[0])}function Hy(){me(`captures`,()=>{zy(),Cy()})}var Uy=A({__name:`Tabs`,props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:n}){let r=e,i=n,a=Dt(r,`class`),o=t(a,i);return(e,t)=>(z(),J(B($c),W({"data-slot":`tabs`,"data-orientation":B(o).orientation||`horizontal`},B(o),{class:B(Q)(`gap-2 group/tabs flex data-horizontal:flex-col`,r.class)}),{default:M(t=>[F(e.$slots,`default`,nt(Oe(t)))]),_:3},16,[`data-orientation`,`class`]))}}),Wy=A({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Dt(t,`class`);return(e,r)=>(z(),J(B(nl),W({"data-slot":`tabs-content`,class:B(Q)(`text-sm flex-1 outline-none`,t.class)},B(n)),{default:M(()=>[F(e.$slots,`default`)]),_:3},16,[`class`]))}}),Gy=A({__name:`TabsList`,props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},variant:{default:`default`}},setup(e){let t=e,n=Dt(t,`class`,`variant`);return(r,i)=>(z(),J(B(rl),W({"data-slot":`tabs-list`,"data-variant":e.variant},B(n),{class:B(Q)(B(qy)({variant:e.variant}),t.class)}),{default:M(()=>[F(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),Ky=A({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Dt(t,`class`),r=se(n);return(e,n)=>(z(),J(B(il),W({"data-slot":`tabs-trigger`,class:B(Q)(`gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*=size-])]:size-4 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointerLine truncated
`)}};jL.defaultYaml={explicit:!1,version:`1.2`},jL.defaultTags={"!!":`tag:yaml.org,2002:`};function ML(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 NL(e){let t=new Set;return wL(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function PL(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function FL(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=NL(e);let a=PL(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(gL(t.node)||vL(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 IL(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=IL(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=IL(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=IL(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=IL(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function LL(e,t,n){if(Array.isArray(e))return e.map((e,t)=>LL(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!bL(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 RL=class{constructor(e){Object.defineProperty(this,dL,{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(!pL(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=LL(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?IL(i,{"":o},``,o):o}},zL=class extends RL{constructor(e){super(aL),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=[],wL(e,{Node:(e,t)=>{(fL(t)||bL(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||=(LL(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=BL(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(ML(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 BL(e,t,n){if(fL(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(vL(t)){let r=0;for(let i of t.items){let t=BL(e,i,n);t>r&&(r=t)}return r}if(hL(t)){let r=BL(e,t.key,n),i=BL(e,t.value,n);return Math.max(r,i)}return 1}var VL=e=>!e||typeof e!=`function`&&typeof e!=`object`,HL=class extends RL{constructor(e){super(lL),this.value=e}toJSON(e,t){return t?.keep?this.value:LL(this.value,e,t)}toString(){return String(this.value)}};HL.BLOCK_FOLDED=`BLOCK_FOLDED`,HL.BLOCK_LITERAL=`BLOCK_LITERAL`,HL.PLAIN=`PLAIN`,HL.QUOTE_DOUBLE=`QUOTE_DOUBLE`,HL.QUOTE_SINGLE=`QUOTE_SINGLE`;var UL=`tag:yaml.org,2002:`;function WL(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 GL(e,t,n){if(pL(e)&&(e=e.contents),yL(e))return e;if(hL(e)){let t=n.schema[sL].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 zL(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=UL+t.slice(2));let l=WL(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new HL(e);return c&&(c.node=t),t Line truncated
`)?XL(n,t):n.includes(`
Defaulting to \`null\`.`),null)}function $s(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 \`${Js}\`.`),Js)}var ec=A({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:Js},getValueLabel:{type:Function,required:!1,default:(e,t)=>Zs(e)?`${Math.round(e/t*Js)}%`: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;p();let i=x(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=x(n,`max`,r,{passive:n.max===void 0});I(()=>i.value,async e=>{let t=Qs(e,n.max);t!==e&&(await ot(),i.value=t)},{immediate:!0}),I(()=>n.max,e=>{let t=$s(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=L(()=>ai(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return Xs({modelValue:i,max:a,progressState:o}),(t,n)=>(z(),J(B(Mt),{"as-child":e.asChild,as:e.as,"aria-valuemax":B(a),"aria-valuemin":0,"aria-valuenow":Zs(B(i))?B(i):void 0,"aria-valuetext":e.getValueText?.(B(i),B(a)),"aria-label":e.getValueLabel(B(i),B(a)),role:`progressbar`,"data-state":o.value,"data-value":B(i)??void 0,"data-max":B(a)},{default:M(()=>[F(t.$slots,`default`,{modelValue:B(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),tc=A({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=Ys();return p(),(e,r)=>(z(),J(B(Mt),W(t,{"data-state":B(n).progressState.value,"data-value":B(n).modelValue?.value??void 0,"data-max":B(n).max.value}),{default:M(()=>[F(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),nc=`radio.select`;function rc(e,t,n){_(nc,n,{originalEvent:e,value:t})}var ic=A({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=x(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=Me(n),{forwardRef:o,currentElement:s}=p(),c=hi(s),l=gi(),u=L(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||rc(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(t,n)=>(z(),K(U,null,[N(B(Mt),W({id:e.id,ref:B(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":B(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":B(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:B(a),required:e.required,name:e.name},{...B(l),...t.$attrs},{onClick:St(d,[`stop`])}),{default:M(()=>[F(t.$slots,`default`,{checked:B(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),B(c)&&e.name?(z(),J(B(La),W({key:0,type:`radio`,tabindex:`-1`,value:B(a),checked:!!B(i),name:e.name,disabled:e.disabled,required:e.required},B(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):R(`v-if`,!0)],64))}}),[ac,oc]=O(`RadioGroupRoot`),sc=A({__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}=p(),s=x(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:c,loop:l,orientation:u,name:d,required:f,dir:m}=Me(n),h=o(m),g=hi(a);return oc({modelValue:s,changeModelValue:e=>{s.value=e},disabled:c,loop:l,orientation:u,name:d?.value,required:f}),(t,n)=>(z(),J(B(xo),{"as-child":``,orientation:B(u),dir:B(h),loop:B(l)},{default:M(()=>[N(B(Mt),{ref:B(i),role:`radiogroup`,"data-disabled":B(c)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":B(u),"aria-required":B(f),dir:B(h)},{default:M(()=>[F(t.$slots,`default`,{modelValue:B(s)}),B(g)&&B(d)?(z(),J(B(La),{key:0,required:B(f),disabled:B(c),value:B(s),name:B(d)},null,8,[`required`,`disabled`,`value`,`name`])):R(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[cc,lc]=O(`RadioGroupItem`),uc=A({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:null,requirLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:Md(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>Md(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=Pd(c),u=e+1<n.length?Pd(n[e+1]):null;if(l&&u&&Fd(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=Pd(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>Md(e)),rows:r.map(e=>e.map(e=>Md(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:Md(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])}else c.startsWith(`>`)?(o(),s(),t.push({kind:`blockquote`,inline:Md(c.replace(/^>\s?/,``))})):r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function Pd(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 Fd(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Id={class:`[overflow-wrap:anywhere]`},Ld={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},Rd={class:`font-mono text-[0.85em]`},zd={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},Bd={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Vd={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Hd={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Ud={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Wd={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Gd={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Kd={key:8,class:`mb-2.5 last:mb-0`},qd=A({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=L(()=>Nd(t.text));return(e,t)=>(z(),K(`div`,Id,[(z(!0),K(U,null,q(n.value,(e,t)=>(z(),K(U,{key:t},[e.kind===`pre`?(z(),K(`pre`,Ld,[G(`code`,Rd,H(e.code),1)])):e.kind===`table`?(z(),K(`table`,zd,[G(`thead`,null,[G(`tr`,null,[(z(!0),K(U,null,q(e.head,(e,t)=>(z(),K(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[N(Ad,{inline:e},null,8,[`inline`])]))),128))])]),G(`tbody`,null,[(z(!0),K(U,null,q(e.rows,(e,t)=>(z(),K(`tr`,{key:t},[(z(!0),K(U,null,q(e,(e,t)=>(z(),K(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[N(Ad,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(z(),K(`blockquote`,Bd,[N(Ad,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(z(),K(`h1`,Vd,[N(Ad,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(z(),K(`h2`,Hd,[N(Ad,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(z(),K(`h3`,Ud,[N(Ad,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(z(),K(`ul`,Wd,[(z(!0),K(U,null,q(e.items,(e,t)=>(z(),K(`li`,{key:t},[N(Ad,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(z(),K(`ol`,Gd,[(z(!0),K(U,null,q(e.items,(e,t)=>(z(),K(`li`,{key:t},[N(Ad,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(z(),K(`p`,Kd,[N(Ad,{inline:e.inline},null,8,[`inline`])])):R(``,!0)],64))),128))]))}}),Jd={class:`truncate`},Yd=A({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=Ae(`RouterLink`);return z(),J(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-md 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:M(()=>[N(B(Wt),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),G(`span`,Jd,H(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Xd={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Zd={class:`font-semibold text-foreground`},Qd={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},$d=A({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=L(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=L(()=>t.tool.parameters||t.tool.Parameters||``),i=L(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=L(()=>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?(z(),J(Yd,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(z(),K(`div`,Xd,[N(B(qn),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),G(`span`,Zd,H(n.value),1),r.value?(z(),K(`code`,Qd,H(r.value),1)):R(``,!0),G(`span`,{class:P(B(Q)(`text-fg-muted`,i.value&&`text-danger`))},H(a.value),3)]))}}),ef={key:0,class:`mb-2 grid gap-0.5 text-xs`},tf={key:1,class:`mb-2 flex flex-wrap gap-1.5`},nf={key:3,class:`whitespace-pre-wrap`},rf=A({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(z(),K(`div`,{class:P([`flex`,e.assistant?`justify-start`:`justify-end`])},[G(`div`,{class:P(B(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?(z(),K(`div`,ef,[(z(!0),K(U,null,q(e.tools,(t,n)=>(z(),J($d,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):R(``,!0),e.media.length?(z(),K(`div`,tf,[(z(!0),K(U,null,q(e.media,(e,t)=>(z(),J(Cd,{key:t,attachment:e},null,8,[`attachment`]))),128))])):R(``,!0),e.assistant?(z(),J(qd,{key:2,text:e.text},null,8,[`text`])):(z(),K(`div`,nf,H(e.text),1)),F(t.$slots,`default`)],2)],2))}}),af={class:`text-sm`},of={class:`font-medium`},sf={key:0,class:`mt-1 text-fg-muted`},cf={key:1,class:`mt-2 flex flex-wrap gap-2`},lf=A({__name:`ChatChooLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>K_?`${n.slice(0,K_).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var J_=[`title`],Y_=A({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=Jg(),a=L(()=>i.taskIDFor(n.event)),o=L(()=>q_(n.event));function s(){a.value>0&&r(`open`,a.value)}let c=L(()=>n.event.at?Dg(n.event.at):`—`);return(e,t)=>(z(),J(B(U_),{class:P(a.value>0?`cursor-pointer`:``),role:a.value>0?`link`:void 0,tabindex:a.value>0?0:void 0,title:a.value>0?`Open task details`:void 0,onClick:s,onKeydown:[vt(St(s,[`prevent`]),[`enter`]),vt(St(s,[`prevent`]),[`space`])]},{default:M(()=>[N(B($),{class:`font-medium`},{default:M(()=>[j(H(n.event.kind||n.event.type||`event`),1)]),_:1}),N(B($),{class:`font-mono`},{default:M(()=>[j(H(a.value>0?`#${a.value}`:`—`),1)]),_:1}),N(B($),{class:`w-[55%] max-w-0`},{default:M(()=>[G(`span`,{class:`block truncate`,title:o.value.truncated?o.value.full:void 0},H(o.value.text),9,J_)]),_:1}),N(B($),null,{default:M(()=>[j(H(c.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),X_=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function Z_(e){return(Number(e?.task_id)||0)>0}function Q_(e,t){return t===`tasks`?Z_(e):t!==`system`||!Z_(e)}function $_(e,t){return e.filter(e=>Q_(e,t))}function ev(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function tv(e,t){return`${e}:${t??0}`}function nv(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=tv(q_(n).text,r),a=t[t.length-1];a&&a.key===i?(a.count+=1,a.events.push(n)):t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var rv={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},iv={class:`max-h-[28rem] overflow-y-auto`},av=[`aria-expanded`,`aria-label`,`onClick`],ov=[`title`],sv=A({__name:`LiveActivityCard`,setup(e){let t=cp(),{activity:n}=_e(ue()),r=Y(`all`),i=L(()=>$_(n.value,r.value)),a=L(()=>ev(i.value.length,r.value)),o=Ye(new Set),s=L(()=>nv(i.value));function c(e){o.has(e)?o.delete(e):o.add(e)}function l(e){return o.has(e.key)}function u(e){return q_(e.representative)}function d(e){return e.representative.at?Dg(e.representative.at):`—`}function f(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(z(),J(B(bg),null,{default:M(()=>[N(B(Tg),null,{default:M(()=>[N(B(Eg),null,{default:M(()=>[...t[1]||=[j(`Live activity`,-1)]]),_:1}),N(B(xg),{class:`flex items-center gap-2`},{default:M(()=>[N(B(L_),{type:`single`,variant:`outline`,size:`sm`,"model-value":r.value,"aria-label":`Filter activity`,"onUpdate:modelValue":t[0]||=e=>{e&&(r.value=e)}},{default:M(()=>[(z(!0),K(U,null,q(B(X_),e=>(z(),J(B(z_),{key:e.value,value:e.value},{default:M(()=>[j(H(e.label),1)]),_:2},1032,[`value`]))),128))]),_:1},8,[`model-value`])]),_:1})]),_:1}),N(B(Sg),null,{default:M(()=>[G(`div`,rv,[G(`div`,iv,[N(B(V_),null,{default:M(()=>[N(B(G_),{class:`sticky top-0 z-10 bg-card`},{default:M(()=>[N(B(U_),null,{default:M(()=>[N(B(W_),null,{default:M(()=>[...t[2]||=[j(`Event`,-1)]]),_:1}),N(B(W_),null,{default:M(()=>[...t[3]||=[j(`Task`,-1)]]),_:1}),N(B(W_),null,{default:M(()=>[...t[4]||=[j(`Detail`,-1)]]),_:1}),N(B(W_),null,{default:M(()=>[...t[5]||=[j(`When`,-1)]]),_:1})]),_:1})]),_:1}),N(B(H_),null,{default:M(()=>[i.value.length?R(``,!0):(z(),J(B(U_),{key:0},{default:M(()=>[N(B($),{colspan:`4`},{default:M(()=>[N(B(dg),null,{default:M(()=>[N(B(mg),null,{default:M(()=>[N(B(_g),null,{default:M(()=>[j(H(a.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),i.value.length?(z(!0),K(U,{key:1},q(s.value,e=>(z(),K(U,{key:e.key},[e.count===1?(z(),J(Y_,{key:0,event:e.representative,onOpen:f},null,8,[`event`])):(z(),K(U,{key:1},[N(B(U_),{class:P(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&&f(e.taskID),onKeydown:[vt(St(t=>e.taskID>0&&f(e.taskID),[`prevent`]),[`enter`]),vt(St(t=>e.taskID>0&&f(e.taskID),[`prevent`]),[`space`])]},{default:M(()=>[N(B($),{class:`font-medium`},{default:M(()=>[G(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":l(e),"aria-label":`${l(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:St(t=>c(e.key),[`stop`])},[l(e)?(z(),J(B(Qt),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(z(),J(B($t),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),j(` `+H(e.label)+` `,1),N(B(kt),{variant:`idle`},{default:M(()=>[j(`×`+H(e.count),1)]),_:2},1024)],8,av)]),_:2},1024),N(B($),{class:`font-mono`},{default:M(()=>[j(H(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),N(B($),{class:`w-[55%] max-w-0`},{default:M(()=>[G(`span`,{class:`block truncate`,title:u(e).truncated?u(e).full:void 0},H(u(e).text),9,ov)]),_:2},1024),N(B($),null,{default:M(()=>[j(H(d(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydowLine 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 py(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 my(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 hy(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 gy(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 _y=Y([]),vy=Y([]),yy=Y(!0),by=Y(null),xy=Y(null),Sy=Y(!1),Cy=Y(null);async function wy(){try{let e=await Z.eventTypes(dy().workspace);yy.value=e.enabled!==!1,_y.value=e.event_types||[],vy.value=e.proposals||[],by.value=null}catch(e){by.value=e.message||String(e)}}function Ty(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function Ey(e){Cy.value=null,xy.value=e}function Dy(e){let t=Fy.value.find(t=>String(t.id)===e.sample_id);Ey({mode:`proposal`,id:null,source:e.source,name:``,rule:Ty(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function Oy(e=``){Ey({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function ky(e){Ey({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:Ty(e.rule),headersText:``,body:``,exampleHeaders:{}})}function Ay(){xy.value=null}async function jy(){let e=xy.value;if(e){Sy.value=!0;try{if(e.mode===`edit`&&e.id)await Z.eventTypeUpdate(e.id,{name:e.name,rule:gy(e.rule)});else{let t=e.mode===`paste`?fy(e.headersText):e.exampleHeaders;await Z.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:gy(e.rule),example:{headers:t,body:e.body}})}xy.value=null,await wy()}catch(e){Cy.value=e.message||String(e)}finally{Sy.value=!1}}}var My=Y(null);async function Ny(){let e=My.value;if(My.value=null,e)try{await Z.eventTypeDelete(e.id),await wy()}catch(e){by.value=e.message||String(e)}}var Py=100,Fy=Y([]),Iy=Y(!0),Ly=Y(null),Ry=Y(!0),zy=Y(null);async function By(){try{let e=await Z.captures(Py);Iy.value=e.enabled!==!1,Fy.value=e.captures||[],Ly.value=null}catch(e){Ly.value=e.message||String(e)}finally{Ry.value=!1}}function Vy(e){let t=Fy.value.find(t=>t.id===e);return t&&(zy.value=t),!!t}function Hy(){Fy.value.length&&(zy.value=Fy.value[0])}function Uy(){me(`captures`,()=>{By(),wy()})}var Wy=A({__name:`Tabs`,props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:n}){let r=e,i=n,a=Dt(r,`class`),o=t(a,i);return(e,t)=>(z(),J(B(el),W({"data-slot":`tabs`,"data-orientation":B(o).orientation||`horizontal`},B(o),{class:B(Q)(`gap-2 group/tabs flex data-horizontal:flex-col`,r.class)}),{default:M(t=>[F(e.$slots,`default`,nt(Oe(t)))]),_:3},16,[`data-orientation`,`class`]))}}),Gy=A({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Dt(t,`class`);return(e,r)=>(z(),J(B(rl),W({"data-slot":`tabs-content`,class:B(Q)(`text-sm flex-1 outline-none`,t.class)},B(n)),{default:M(()=>[F(e.$slots,`default`)]),_:3},16,[`class`]))}}),Ky=A({__name:`TabsList`,props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},variant:{default:`default`}},setup(e){let t=e,n=Dt(t,`class`,`variant`);return(r,i)=>(z(),J(B(il),W({"data-slot":`tabs-list`,"data-variant":e.variant},B(n),{class:B(Q)(B(Jy)({variant:e.variant}),t.class)}),{default:M(()=>[F(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),qy=A({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=Dt(t,`class`),r=se(n);return(e,n)=>(z(),J(B(al),W({"data-slot":`tabs-trigger`,class:B(Q)(`gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*=size-])]:size-4 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointerLine truncated
`)}};PL.defaultYaml={explicit:!1,version:`1.2`},PL.defaultTags={"!!":`tag:yaml.org,2002:`};function FL(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 IL(e){let t=new Set;return DL(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function LL(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function RL(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=IL(e);let a=LL(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(yL(t.node)||xL(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 zL(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=zL(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=zL(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=zL(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=zL(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function BL(e,t,n){if(Array.isArray(e))return e.map((e,t)=>BL(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!CL(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 VL=class{constructor(e){Object.defineProperty(this,mL,{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(!gL(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=BL(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?zL(i,{"":o},``,o):o}},HL=class extends VL{constructor(e){super(cL),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=[],DL(e,{Node:(e,t)=>{(hL(t)||CL(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||=(BL(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=UL(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(FL(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 UL(e,t,n){if(hL(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(xL(t)){let r=0;for(let i of t.items){let t=UL(e,i,n);t>r&&(r=t)}return r}if(vL(t)){let r=UL(e,t.key,n),i=UL(e,t.value,n);return Math.max(r,i)}return 1}var WL=e=>!e||typeof e!=`function`&&typeof e!=`object`,GL=class extends VL{constructor(e){super(fL),this.value=e}toJSON(e,t){return t?.keep?this.value:BL(this.value,e,t)}toString(){return String(this.value)}};GL.BLOCK_FOLDED=`BLOCK_FOLDED`,GL.BLOCK_LITERAL=`BLOCK_LITERAL`,GL.PLAIN=`PLAIN`,GL.QUOTE_DOUBLE=`QUOTE_DOUBLE`,GL.QUOTE_SINGLE=`QUOTE_SINGLE`;var KL=`tag:yaml.org,2002:`;function qL(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 JL(e,t,n){if(gL(e)&&(e=e.contents),SL(e))return e;if(vL(e)){let t=n.schema[uL].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 HL(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=KL+t.slice(2));let l=qL(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new GL(e);return c&&(c.node=t),t Line truncated
`)?$L(n,t):n.includes(`
`)?`
`+XL(n,t):(e.endsWith(` `)?``:` `)+n,QL=`flow`,$L=`block`,eR=`quoted`;function tR(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=nR(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=nR(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`+$L(n,t):(e.endsWith(` `)?``:` `)+n,tR=`flow`,nR=`block`,rR=`quoted`;function iR(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=aR(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=aR(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 nR(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 rR=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),iR=e=>/^(%|---|\.\.\.)/m.test(e);function aR(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 oR(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(iR(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 aR(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 oR=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),sR=e=>/^(%|---|\.\.\.)/m.test(e);function cR(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 lR(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(sR(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:tR(o,a,eR,rR(t,!1))}function sR(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return oR(e,t);let n=t.indent||(iR(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:tR(r,n,QL,rR(t,!1))}function cR(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=oR;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?sR:i&&!t?oR:n?sR:oR}return r(e,t)}var lR;try{lR=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:iR(o,a,rR,oR(t,!1))}function uR(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return lR(e,t);let n=t.indent||(sR(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:iR(r,n,tR,oR(t,!1))}function dR(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=lR;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?uR:i&&!t?lR:n?uR:lR}return r(e,t)}var fR;try{fR=RegExp(`(^|(?<!
))
+(?!
|$)`,`g`)}catch{lR=/\n+(?!\n|$)/g}function uR({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 cR(n,r);let l=r.indent||(r.forceBlockIndent||iR(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===HL.BLOCK_FOLDED?!1:t===HL.BLOCK_LITERAL||!aR(n,c,l.length);if(!n)return u?`|
|$)`,`g`)}catch{fR=/\n+(?!\n|$)/g}function pR({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 dR(n,r);let l=r.indent||(r.forceBlockIndent||sR(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===GL.BLOCK_FOLDED?!1:t===GL.BLOCK_LITERAL||!cR(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(lR,`$&${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(fR,`$&${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=rR(r,!0);o!==`folded`&&t!==HL.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=tR(`${v}${e}${p}`,l,$L,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function dR(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 cR(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?cR(a,t):uR(e,t,n,r);if(!s&&!u&&i!==HL.PLAIN&&a.includes(`
`))return uR(e,t,n,r);if(iR(a)){if(c===``)return t.forceBlockIndent=!0,uR(e,t,n,r);if(s&&c===l)return cR(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 cR(a,t)}return s?d:tR(d,c,QL,rR(t,!1))}function fR(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!==HL.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=HL.QUOTE_DOUBLE);let c=e=>{switch(e){case HL.BLOCK_FOLDED:case HL.BLOCK_LITERAL:return i||a?cR(o.value,t):uR(o,t,n,r);case HL.QUOTE_DOUBLE:return oR(o.value,t);case HL.QUOTE_SINGLE:return sR(o.value,t);case HL.PLAIN:return dR(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 pR(e,t){let n=Object.assign({blockQuote:!0,commentString:YL,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 mR(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(gL(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 hR(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(gL(e)||vL(e))&&e.anchor;a&&ML(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 gR(e,t,n,r){if(hL(e))return e.toString(t,n,r);if(fL(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=yL(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=mR(t.doc.schema.tags,a);let o=hR(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):gL(a)?fR(a,t,n,r):a.toString(t,n,r);return o?gL(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function _R({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=yL(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(vL(e)||!yL(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||vL(e)||(gL(e)?e.type===HL.BLOCK_FOLDED||e.type===HL.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=gR(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+=ZL(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=ZL(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=ZL(g,n.indent,l(f))));let _,v,y;yL(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&&gL(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&_L(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=gR(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${XL(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=oR(r,!0);o!==`folded`&&t!==GL.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=iR(`${v}${e}${p}`,l,nR,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function mR(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 dR(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?dR(a,t):pR(e,t,n,r);if(!s&&!u&&i!==GL.PLAIN&&a.includes(`
`))return pR(e,t,n,r);if(sR(a)){if(c===``)return t.forceBlockIndent=!0,pR(e,t,n,r);if(s&&c===l)return dR(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 dR(a,t)}return s?d:iR(d,c,tR,oR(t,!1))}function hR(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!==GL.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=GL.QUOTE_DOUBLE);let c=e=>{switch(e){case GL.BLOCK_FOLDED:case GL.BLOCK_LITERAL:return i||a?dR(o.value,t):pR(o,t,n,r);case GL.QUOTE_DOUBLE:return lR(o.value,t);case GL.QUOTE_SINGLE:return uR(o.value,t);case GL.PLAIN:return mR(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 gR(e,t){let n=Object.assign({blockQuote:!0,commentString:QL,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 _R(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(yL(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 vR(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(yL(e)||xL(e))&&e.anchor;a&&FL(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 yR(e,t,n,r){if(vL(e))return e.toString(t,n,r);if(hL(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=SL(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=_R(t.doc.schema.tags,a);let o=vR(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):yL(a)?hR(a,t,n,r):a.toString(t,n,r);return o?yL(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function bR({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=SL(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(xL(e)||!SL(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||xL(e)||(yL(e)?e.type===GL.BLOCK_FOLDED||e.type===GL.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=yR(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+=eR(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=eR(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=eR(g,n.indent,l(f))));let _,v,y;SL(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&&yL(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&bL(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=yR(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${$L(e,n.indent)}`}x===``&&!n.inFlow?S===`
`&&y&&(S=`
`):S+=`\n${n.indent}`}else if(!p&&vL(t)){let e=x[0],r=x.indexOf(`
`):S+=`\n${n.indent}`}else if(!p&&xL(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+=ZL(g,n.indent,l(y)):h&&i&&i(),g}function vR(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var yR=`<<`,bR={identify:e=>e===yR||typeof e==`symbol`&&e.description===yR,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new HL(Symbol(yR)),{addToJSMap:SR}),stringify:()=>yR},xR=(e,t)=>(bR.identify(t)||gL(t)&&(!t.type||t.type===HL.PLAIN)&&bR.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===bR.tag&&e.default);function SR(e,t,n){let r=wR(e,n);if(_L(r))for(let n of r.items)CR(e,t,n);else if(Array.isArray(r))for(let n of r)CR(e,t,n);else CR(e,t,r)}function CR(e,t,n){let r=wR(e,n);if(!mL(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 wR(e,t){return e&&fL(t)?t.resolve(e.doc,e):t}function TR(e,t,{key:n,value:r}){if(yL(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(xR(e,n))SR(e,t,r);else{let i=LL(n,``,e);if(t instanceof Map)t.set(i,LL(r,i,e));else if(t instanceof Set)t.add(i);else{let a=ER(n,i,e),o=LL(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function ER(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(yL(e)&&n?.doc){let t=pR(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)+`..."`),vR(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 DR(e,t,n){return new OR(GL(e,void 0,n),GL(t,void 0,n))}var OR=class e{constructor(e,t=null){Object.defineProperty(this,dL,{value:cL}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return yL(n)&&(n=n.clone(t)),yL(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return TR(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?_R(this,e,t,n):JSON.stringify(this)}};function kR(e,t,n){return(t.inFlow??e.flow?jR:AR)(e,t,n)}function AR({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(yL(i))!d&&i.spaceBefore&&f.push(``),MR(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(hL(i)){let e=yL(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),MR(n,f,e.commentBefore,d))}d=!1;let s=gR(i,u,()=>o=null,()=>d=!0);o&&(s+=ZL(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+=eR(g,n.indent,l(y)):h&&i&&i(),g}function xR(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var SR=`<<`,CR={identify:e=>e===SR||typeof e==`symbol`&&e.description===SR,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new GL(Symbol(SR)),{addToJSMap:TR}),stringify:()=>SR},wR=(e,t)=>(CR.identify(t)||yL(t)&&(!t.type||t.type===GL.PLAIN)&&CR.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===CR.tag&&e.default);function TR(e,t,n){let r=DR(e,n);if(bL(r))for(let n of r.items)ER(e,t,n);else if(Array.isArray(r))for(let n of r)ER(e,t,n);else ER(e,t,r)}function ER(e,t,n){let r=DR(e,n);if(!_L(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 DR(e,t){return e&&hL(t)?t.resolve(e.doc,e):t}function OR(e,t,{key:n,value:r}){if(SL(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(wR(e,n))TR(e,t,r);else{let i=BL(n,``,e);if(t instanceof Map)t.set(i,BL(r,i,e));else if(t instanceof Set)t.add(i);else{let a=kR(n,i,e),o=BL(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function kR(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(SL(e)&&n?.doc){let t=gR(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)+`..."`),xR(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 AR(e,t,n){return new jR(JL(e,void 0,n),JL(t,void 0,n))}var jR=class e{constructor(e,t=null){Object.defineProperty(this,mL,{value:dL}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return SL(n)&&(n=n.clone(t)),SL(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return OR(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?bR(this,e,t,n):JSON.stringify(this)}};function MR(e,t,n){return(t.inFlow??e.flow?PR:NR)(e,t,n)}function NR({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(SL(i))!d&&i.spaceBefore&&f.push(``),FR(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(vL(i)){let e=SL(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),FR(n,f,e.commentBefore,d))}d=!1;let s=yR(i,u,()=>o=null,()=>d=!0);o&&(s+=eR(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+=`
`+XL(l(e),c),s&&s()):d&&o&&o(),p}function jR({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(yL(i))i.spaceBefore&&d.push(``),MR(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(hL(i)){let e=yL(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),MR(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=yL(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=gR(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+=ZL(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 MR({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=XL(t(r),e);n.push(i.trimStart())}}function NR(e,t){let n=gL(t)?t.value:t;for(let r of e)if(hL(r)&&(r.key===t||r.key===n||gL(r.key)&&r.key.value===n))return r}var PR=class extends JL{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(sL,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(DR(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=hL(e)?e:!e||typeof e!=`object`||!(`key`in e)?new OR(e,e?.value):new OR(e.key,e.value);let r=NR(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);gL(r.value)&&VL(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=NR(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=NR(this.items,e)?.value;return(!t&&gL(n)?n.value:n)??void 0}has(e){return!!NR(this.items,e)}set(e,t){this.add(new OR(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)TR(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!hL(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})),kR(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},FR={collection:`map`,default:!0,nodeClass:PR,tag:`tag:yaml.org,2002:map`,resolve(e,t){return mL(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>PR.from(e,t,n)},IR=class extends JL{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(uL,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=LR(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=LR(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&gL(r)?r.value:r}has(e){let t=LR(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=LR(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];gL(r)&&VL(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(LL(e,String(r++),t));return n}toString(e,t,n){return e?kR(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(GL(a,void 0,n))}}return i}};function LR(e){let t=gL(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var RR={collection:`seq`,default:!0,nodeClass:IR,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return _L(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>IR.from(e,t,n)},zR={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),fR(e,t,n,r)}},BR={identify:e=>e==null,createNode:()=>new HL(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new HL(null),stringify:({source:e},t)=>typeof e==`string`&&BR.test.test(e)?e:t.options.nullStr},VR={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new HL(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&VR.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function HR({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 UR={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:HR},WR={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 fR({comment:e,type:t,value:s},r,i,a)}};function iz(e,t){if(_L(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!hL(r)){if(mL(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new OR(new HL(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]=hL(r)?r:new OR(r)}}else t(`Expected a sequence for this tag`);return e}function az(e,t,n){let{replacer:r}=n,i=new IR(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(DR(o,s,n))}return i}var oz={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:iz,createNode:az},sz=class e extends IR{constructor(){super(),this.add=PR.prototype.add.bind(this),this.delete=PR.prototype.delete.bind(this),this.get=PR.prototype.get.bind(this),this.has=PR.prototype.has.bind(this),this.set=PR.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(hL(e)?(r=LL(e.key,``,t),i=LL(e.value,r,t)):r=LL(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=az(e,t,n),i=new this;return i.items=r.items,i}};sz.tag=`tag:yaml.org,2002:omap`;var cz={collection:`seq`,identify:e=>e instanceof Map,nodeClass:sz,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=iz(e,t),r=[];for(let{key:e}of n.items)gL(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new sz,n)},createNode:(e,t,n)=>sz.from(e,t,n)};function lz({value:e,source:t},n){return t&&(e?uz:dz).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var uz={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 HL(!0),stringify:lz},dz={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 HL(!1),stringify:lz},fz={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:HR},pz={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():HR(e)}},mz={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 HL(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:HR},hz=e=>typeof e==`bigint`||Number.isInteger(e);function gz(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 _z(e,t,n){let{value:r}=e;if(hz(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return HR(e)}var vz={identify:hz,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>gz(e,2,2,n),stringify:e=>_z(e,2,`0b`)},yz={identify:hz,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>gz(e,1,8,n),stringify:e=>_z(e,8,`0`)},bz={identify:hz,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>gz(e,0,10,n),stringify:HR},xz={identify:hz,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>gz(e,2,16,n),stringify:e=>_z(e,16,`0x`)},Sz=class e extends PR{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=hL(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new OR(e.key,null):new OR(e,null),NR(this.items,t.key)||this.items.push(t)}get(e,t){let n=NR(this.items,e);return!t&&hL(n)?gL(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=NR(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new OR(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(XL(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(XL(a(t),``)))}return n.join(`
`+$L(l(e),c),s&&s()):d&&o&&o(),p}function PR({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(SL(i))i.spaceBefore&&d.push(``),FR(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(vL(i)){let e=SL(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),FR(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=SL(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=yR(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+=eR(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 FR({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=$L(t(r),e);n.push(i.trimStart())}}function IR(e,t){let n=yL(t)?t.value:t;for(let r of e)if(vL(r)&&(r.key===t||r.key===n||yL(r.key)&&r.key.value===n))return r}var LR=class extends ZL{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(uL,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(AR(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=vL(e)?e:!e||typeof e!=`object`||!(`key`in e)?new jR(e,e?.value):new jR(e.key,e.value);let r=IR(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);yL(r.value)&&WL(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=IR(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=IR(this.items,e)?.value;return(!t&&yL(n)?n.value:n)??void 0}has(e){return!!IR(this.items,e)}set(e,t){this.add(new jR(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)OR(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!vL(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})),MR(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},RR={collection:`map`,default:!0,nodeClass:LR,tag:`tag:yaml.org,2002:map`,resolve(e,t){return _L(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>LR.from(e,t,n)},zR=class extends ZL{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(pL,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=BR(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=BR(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&yL(r)?r.value:r}has(e){let t=BR(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=BR(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];yL(r)&&WL(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(BL(e,String(r++),t));return n}toString(e,t,n){return e?MR(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(JL(a,void 0,n))}}return i}};function BR(e){let t=yL(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var VR={collection:`seq`,default:!0,nodeClass:zR,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return bL(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>zR.from(e,t,n)},HR={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),hR(e,t,n,r)}},UR={identify:e=>e==null,createNode:()=>new GL(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new GL(null),stringify:({source:e},t)=>typeof e==`string`&&UR.test.test(e)?e:t.options.nullStr},WR={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new GL(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&WR.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function GR({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 KR={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:GR},qR={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 hR({comment:e,type:t,value:s},r,i,a)}};function sz(e,t){if(bL(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!vL(r)){if(_L(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new jR(new GL(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]=vL(r)?r:new jR(r)}}else t(`Expected a sequence for this tag`);return e}function cz(e,t,n){let{replacer:r}=n,i=new zR(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(AR(o,s,n))}return i}var lz={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:sz,createNode:cz},uz=class e extends zR{constructor(){super(),this.add=LR.prototype.add.bind(this),this.delete=LR.prototype.delete.bind(this),this.get=LR.prototype.get.bind(this),this.has=LR.prototype.has.bind(this),this.set=LR.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(vL(e)?(r=BL(e.key,``,t),i=BL(e.value,r,t)):r=BL(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=cz(e,t,n),i=new this;return i.items=r.items,i}};uz.tag=`tag:yaml.org,2002:omap`;var dz={collection:`seq`,identify:e=>e instanceof Map,nodeClass:uz,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=sz(e,t),r=[];for(let{key:e}of n.items)yL(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new uz,n)},createNode:(e,t,n)=>uz.from(e,t,n)};function fz({value:e,source:t},n){return t&&(e?pz:mz).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var pz={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 GL(!0),stringify:fz},mz={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 GL(!1),stringify:fz},hz={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:GR},gz={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():GR(e)}},_z={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 GL(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:GR},vz=e=>typeof e==`bigint`||Number.isInteger(e);function yz(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 bz(e,t,n){let{value:r}=e;if(vz(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return GR(e)}var xz={identify:vz,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>yz(e,2,2,n),stringify:e=>bz(e,2,`0b`)},Sz={identify:vz,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>yz(e,1,8,n),stringify:e=>bz(e,8,`0`)},Cz={identify:vz,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>yz(e,0,10,n),stringify:GR},wz={identify:vz,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>yz(e,2,16,n),stringify:e=>bz(e,16,`0x`)},Tz=class e extends LR{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=vL(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new jR(e.key,null):new jR(e,null),IR(this.items,t.key)||this.items.push(t)}get(e,t){let n=IR(this.items,e);return!t&&vL(n)?yL(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=IR(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new jR(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($L(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($L(a(t),``)))}return n.join(`
`)+`
`}var Lz=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,dL,{value:oL});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 jL({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[dL]:{value:oL}});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=yL(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){Rz(this.contents)&&this.contents.add(e)}addIn(e,t){Rz(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=NL(this);e.anchor=!t||n.has(t)?PL(t||`a`,n):t}return new zL(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}=FL(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=GL(e,l,p);return o&&vL(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new OR(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return Rz(this.contents)?this.contents.delete(e):!1}deleteIn(e){return qL(e)?this.contents!=null&&(this.contents=null,!0):Rz(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return vL(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return qL(e)?!t&&gL(this.contents)?this.contents.value:this.contents:vL(this.contents)?this.contents.getIn(e,t):void 0}has(e){return vL(this.contents)?this.contents.has(e):!1}hasIn(e){return qL(e)?this.contents!==void 0:vL(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=KL(this.schema,[e],t):Rz(this.contents)&&this.contents.set(e,t)}setIn(e,t){qL(e)?this.contents=t:this.contents==null?this.contents=KL(this.schema,Array.from(e),t):Rz(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 jL({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 jL({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 Fz(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=LL(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`?IL(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 Iz(this,e)}};function Rz(e){if(vL(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var zz=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},Bz=class extends zz{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},Vz=class extends zz{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},Hz=(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 Uz(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 Wz(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(Wz(t.key)||Wz(t.value))return!0}return!1;default:return!0}}function Gz(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&Wz(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function Kz(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||gL(e)&&gL(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var qz=`All mapping items must start at the same column`;function Jz({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??PR)(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=Uz(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`,qz)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||Wz(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`,qz);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&Gz(r.indent,u,i),n.atKey=!1,Kz(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=Uz(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&&Gz(r.indent,f,i),s=c.range[2];let l=new OR(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 OR(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 Yz({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??IR)(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=Uz(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&&Gz(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function Xz(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 Zz=`Block collections are not allowed within flow collections`,Qz=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function $z({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?PR:IR))(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=Uz(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&&Wz(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];hL(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],Qz(m)&&i(r.range,`BLOCK_IN_FLOW`,Zz)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);Qz(f)&&i(g.range,`BLOCK_IN_FLOW`,Zz),n.atKey=!1;let _=Uz(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?Qz(m)&&i(v.range,`BLOCK_IN_FLOW`,Zz):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new OR(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;Kz(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new PR(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=Xz(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 eB(e,t,n,r,i,a){let o=n.type===`block-map`?Jz(e,t,n,r,a):n.type===`block-seq`?Yz(e,t,n,r,a):$z(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function tB(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===PR.tagName&&s===`map`||o===IR.tagName&&s===`seq`)return eB(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),eB(e,t,n,i,o)}let l=eB(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=yL(u)?u:new HL(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function nB(e,t,n){let r=t.offset,i=rB(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?HL.BLOCK_FOLDED:HL.BLOCK_LITERAL,o=t.source?iB(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 Bz=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,mL,{value:lL});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 PL({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[mL]:{value:lL}});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=SL(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){Vz(this.contents)&&this.contents.add(e)}addIn(e,t){Vz(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=IL(this);e.anchor=!t||n.has(t)?LL(t||`a`,n):t}return new HL(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}=RL(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=JL(e,l,p);return o&&xL(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new jR(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return Vz(this.contents)?this.contents.delete(e):!1}deleteIn(e){return XL(e)?this.contents!=null&&(this.contents=null,!0):Vz(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return xL(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return XL(e)?!t&&yL(this.contents)?this.contents.value:this.contents:xL(this.contents)?this.contents.getIn(e,t):void 0}has(e){return xL(this.contents)?this.contents.has(e):!1}hasIn(e){return XL(e)?this.contents!==void 0:xL(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=YL(this.schema,[e],t):Vz(this.contents)&&this.contents.set(e,t)}setIn(e,t){XL(e)?this.contents=t:this.contents==null?this.contents=YL(this.schema,Array.from(e),t):Vz(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 PL({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 PL({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 Rz(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=BL(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`?zL(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 zz(this,e)}};function Vz(e){if(xL(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var Hz=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},Uz=class extends Hz{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},Wz=class extends Hz{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},Gz=(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 Kz(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 qz(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(qz(t.key)||qz(t.value))return!0}return!1;default:return!0}}function Jz(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&qz(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function Yz(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||yL(e)&&yL(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var Xz=`All mapping items must start at the same column`;function Zz({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??LR)(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=Kz(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`,Xz)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||qz(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`,Xz);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&Jz(r.indent,u,i),n.atKey=!1,Yz(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=Kz(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&&Jz(r.indent,f,i),s=c.range[2];let l=new jR(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 jR(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 Qz({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??zR)(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=Kz(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&&Jz(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function $z(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 eB=`Block collections are not allowed within flow collections`,tB=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function nB({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?LR:zR))(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=Kz(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&&qz(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];vL(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],tB(m)&&i(r.range,`BLOCK_IN_FLOW`,eB)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);tB(f)&&i(g.range,`BLOCK_IN_FLOW`,eB),n.atKey=!1;let _=Kz(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?tB(m)&&i(v.range,`BLOCK_IN_FLOW`,eB):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new jR(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;Yz(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new LR(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=$z(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 rB(e,t,n,r,i,a){let o=n.type===`block-map`?Zz(e,t,n,r,a):n.type===`block-seq`?Qz(e,t,n,r,a):nB(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function iB(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===LR.tagName&&s===`map`||o===zR.tagName&&s===`seq`)return rB(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),rB(e,t,n,i,o)}let l=rB(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=SL(u)?u:new GL(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function aB(e,t,n){let r=t.offset,i=oB(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?GL.BLOCK_FOLDED:GL.BLOCK_LITERAL,o=t.source?sB(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===HL.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===GL.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`):t.length>c||r[0]===` `?(f===` `?f=`
`:!p&&f===`
`&&(f=`
@@ -75,59 +75,59 @@ $&`).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 rB({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 iB(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 aB(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=HL.PLAIN,c=oB(a,l);break;case`single-quoted-scalar`:s=HL.QUOTE_SINGLE,c=sB(a,l);break;case`double-quoted-scalar`:s=HL.QUOTE_DOUBLE,c=lB(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=Xz(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function oB(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}`),cB(e)}function sB(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),cB(e.slice(1,-1)).replace(/''/g,`'`)}function cB(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 oB({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 sB(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 cB(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=GL.PLAIN,c=lB(a,l);break;case`single-quoted-scalar`:s=GL.QUOTE_SINGLE,c=uB(a,l);break;case`double-quoted-scalar`:s=GL.QUOTE_DOUBLE,c=fB(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=$z(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function lB(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}`),dB(e)}function uB(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),dB(e.slice(1,-1)).replace(/''/g,`'`)}function dB(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 lB(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 fB(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}=uB(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=dB[i];if(a)n+=a;else if(i===`
`){let{fold:t,offset:i}=pB(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=mB[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+=fB(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+=hB(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 uB(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 pB(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 dB={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function fB(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 pB(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?nB(e,t,r):aB(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[lL]:c?mB(e.schema,i,c,n,r):t.type===`scalar`?hB(e,i,t,r):e.schema[lL];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=gL(a)?a:new HL(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new HL(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 mB(e,t,n,r,i){if(n===`!`)return e[lL];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[lL])}function hB({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[lL];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[lL];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 gB(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 _B={composeNode:vB,composeEmptyNode:yB};function vB(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=bB(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=pB(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=tB(_B,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??=yB(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&&(!gL(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 yB(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=pB(e,{type:`scalar`,offset:gB(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 bB({options:e},{offset:t,source:n,end:r},i){let a=new zL(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=Xz(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function xB(e,t,{offset:n,start:r,value:i,end:a},o){let s=new Lz(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=Uz(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?vB(c,i,l,o):yB(c,l.end,r,null,l,o);let u=s.contents.range[2],d=Xz(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function SB(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 CB(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 mB={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function hB(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 gB(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?aB(e,t,r):cB(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[fL]:c?_B(e.schema,i,c,n,r):t.type===`scalar`?vB(e,i,t,r):e.schema[fL];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=yL(a)?a:new GL(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new GL(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 _B(e,t,n,r,i){if(n===`!`)return e[fL];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[fL])}function vB({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[fL];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[fL];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 yB(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 bB={composeNode:xB,composeEmptyNode:SB};function xB(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=CB(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=gB(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=iB(bB,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??=SB(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&&(!yL(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 SB(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=gB(e,{type:`scalar`,offset:yB(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 CB({options:e},{offset:t,source:n,end:r},i){let a=new HL(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=$z(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function wB(e,t,{offset:n,start:r,value:i,end:a},o){let s=new Bz(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=Kz(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?xB(c,i,l,o):SB(c,l.end,r,null,l,o);let u=s.contents.range[2],d=$z(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function TB(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 EB(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 wB=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=SB(e);r?this.warnings.push(new Vz(i,t,n)):this.errors.push(new Bz(i,t,n))},this.directives=new jL({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=CB(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(vL(i)&&!i.flow&&i.items.length>0){let e=i.items[0];hL(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:CB(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=SB(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=xB(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 Bz(SB(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 Bz(SB(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=Xz(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 Bz(SB(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 Lz(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}}},TB=Symbol(`break visit`),EB=Symbol(`skip children`),DB=Symbol(`remove item`);function OB(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),kB(Object.freeze([]),e,t)}OB.BREAK=TB,OB.SKIP=EB,OB.REMOVE=DB,OB.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},OB.parentCollection=(e,t)=>{let n=OB.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 kB(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=kB(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===TB)return TB;else r===DB&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function AB(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 DB=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=TB(e);r?this.warnings.push(new Wz(i,t,n)):this.errors.push(new Uz(i,t,n))},this.directives=new PL({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=EB(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(xL(i)&&!i.flow&&i.items.length>0){let e=i.items[0];vL(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:EB(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=TB(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=wB(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 Uz(TB(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 Uz(TB(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=$z(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 Uz(TB(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 Bz(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}}},OB=Symbol(`break visit`),kB=Symbol(`skip children`),AB=Symbol(`remove item`);function jB(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),MB(Object.freeze([]),e,t)}jB.BREAK=OB,jB.SKIP=kB,jB.REMOVE=AB,jB.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},jB.parentCollection=(e,t)=>{let n=jB.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 MB(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=MB(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===OB)return OB;else r===AB&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function NB(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 jB(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var MB=new Set(`0123456789ABCDEFabcdef`),NB=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),PB=new Set(`,[]{}`),FB=new Set(` ,[]{}
\r `),IB=e=>!e||FB.has(e),LB=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 PB(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var FB=new Set(`0123456789ABCDEFabcdef`),IB=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),LB=new Set(`,[]{}`),RB=new Set(` ,[]{}
\r `),zB=e=>!e||RB.has(e),BB=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===`...`)&&jB(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===`...`)&&jB(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&&!jB(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===`:`)&&jB(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(IB),`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(`...`))&&jB(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(IB),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||jB(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===`...`)&&PB(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===`...`)&&PB(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&&!PB(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===`:`)&&PB(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(zB),`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(`...`))&&PB(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(zB),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||PB(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=>jB(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=>PB(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(jB(r)||e&&PB.has(r))break;t=n}else if(jB(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(PB(r)||e&&LB.has(r))break;t=n}else if(PB(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`?(n+=1,r=`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&PB.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&PB.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(IB),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(jB(n)||t&&PB.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(;!jB(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(NB.has(t))t=this.buffer[++e];else if(t===`%`&&MB.has(this.buffer[e+1])&&MB.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&&LB.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&LB.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(zB),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(PB(n)||t&&LB.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(;!PB(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(IB.has(t))t=this.buffer[++e];else if(t===`%`&&FB.has(this.buffer[e+1])&&FB.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)}},RB=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 zB(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function BB(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 VB(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 HB(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 UB(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 WB(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 GB(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!zB(t.start,`explicit-key-ind`)&&!zB(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,VB(t.value)?t.value.end?WB(t.value.end,t.sep):t.value.end=t.sep:WB(t.start,t.sep),delete t.sep)}var KB=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 LB,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=AB(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})}else{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`&&GB(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&&BB(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.in 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)}},VB=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 HB(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function UB(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 WB(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 GB(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 KB(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 qB(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 JB(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!HB(t.start,`explicit-key-ind`)&&!HB(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,WB(t.value)?t.value.end?qB(t.value.end,t.sep):t.value.end=t.sep:qB(t.start,t.sep),delete t.sep)}var YB=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 BB,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=NB(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})}else{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`&&JB(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&&UB(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.in 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)){WB(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(zB(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=UB(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(zB(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(VB(t.key)&&!zB(t.sep,`newline`)){let e=UB(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]}):zB(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&&!zB(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)){WB(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||zB(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)){qB(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(HB(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=KB(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(HB(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(WB(t.key)&&!HB(t.sep,`newline`)){let e=KB(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]}):HB(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&&!HB(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)){qB(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||HB(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=UB(HB(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=UB(HB(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 qB(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new RB||null,prettyErrors:t}}function JB(e,t={}){let{lineCounter:n,prettyErrors:r}=qB(t),i=new KB(n?.addNewLine),a=new wB(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 Bz(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Hz(e,n)),o.warnings.forEach(Hz(e,n))),o}function YB(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=JB(e,n);if(!i)return null;if(i.warnings.forEach(e=>vR(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function XB(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return pL(e)&&!r?e.toString(n):new Lz(e,r,n).toString(n)}var ZB=e=>typeof e==`object`&&!!e&&!Array.isArray(e),QB=e=>ZB(e)?Object.entries(e).map(([e,t])=>[e,Array.isArray(t)?t:[]]):[];function $B(e){if(ZB(e)){if(ZB(e.parallel))return{kind:`parallel`,base:[`parallel`],branches:QB(e.parallel)};if(ZB(e.switch))return{kind:`switch`,base:[`switch`,`cases`],on:typeof e.switch.on==`string`?e.switch.on:``,branches:QB(e.switch.cases)}}}function eV(e){return e.slice(2).includes(`parallel`)}function tV(e,t){let n=JB(e).getIn(t,!0);if(mL(n))return n.toJSON()}function nV(e,t,n){let r=JB(e);return r.setIn(t,r.createNode(pV(n))),r.toString()}function rV(e,t,n){let r=JB(e),i=t.slice(0,-1),a=eV(i);if(a&&![`agent.run`,`workflow.call`].includes(n))throw Error(`Branches allow only read-only agents and workflow calls.`);let o=r.getIn(i,!0);if(_L(o)||(r.setIn(i,r.createNode([])),o=r.getIn(i,!0)),!_L(o))return{source:e,path:[]};let s=Math.min(Math.max(Number(t.at(-1))+1,0),o.items.length),c=n===`parallel`?{parallel:{"branch-1":[],"branch-2":[]}}:n===`switch`?{switch:{on:``,cases:{true:[],default:[]}}}:{type:n,...a&&n===`agent.run`?{settings:{read_only:!0}}:{}};return o.items.splice(s,0,r.createNode(c)),{source:r.toString(),path:[...i,s]}}function iV(e,t){if(t===`switch`){if(!e||e.includes(`/`))throw Error(`A case is the value it matches, without a slash.`)}else if(!/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(e))throw Error(`Use a lowercase branch name with letters, digits, dots or dashes.`)}function aV(e,t){let n=e.getIn(t,!0),r=$B(mL(n)?n.toJSON():void 0),i=r?e.getIn([...t,...r.base],!0):void 0;if(!r||!mL(i))throw Error(`This step has no branches.`);return{kind:r.kind,branches:i}}function oV(e,t,n){let r=JB(e),{kind:i,branches:a}=aV(r,t);if(iV(n,i),a.has(n))throw Error(`Branch ${n} already exists.`);return a.set(n,r.createNode([])),r.toString()}function sV(e,t,n,r){let i=JB(e),{kind:a,branches:o}=aV(i,t);if(iV(r,a),n!==r&&o.has(r))throw Error(`Branch ${r} already exists.`);let s=o.items.find(e=>gL(e.key)&&e.key.value===n);if(!s||!gL(s.key))throw Error(`Branch ${n} does not exist.`);return s.key.value=r,i.toString()}function cV(e,t,n){let r=JB(e),{kind:i,branches:a}=aV(r,t);if(i===`parallel`&&a.items.length<=2)throw Error(`Parallel needs at least two branches.`);if(a.items.length<=1)throw Error(`A switch needs at least one case.`);return Line truncated
`).find(e=>e.trim())?.trim()}}function DV(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(CV)].map(e=>e[1]))]}function OV(e){let t=JB(e).toJS(),n=wV(t)&&Array.isArray(t.steps)?t.steps:[],r=[],i=[],a=new Map,o=[],s=new Set,c=`start`;r.push({id:c,type:`step`,position:{x:0,y:0},data:{kind:`start`,key:`start`,title:`Starts when`,type:``,detail:``}});let l=[c],u=1,d=new Map,f=e=>{let t=d.get(e)??0;return d.set(e,t+1),t},p=(e,t,n,i,s,c,l,u)=>{let d=wV(e)?e:{},p=$B(d),m=p?.kind??(typeof d.type==`string`?d.type:``),h=wV(d.settings)?d.settings:{},g=typeof d.id==`string`?d.id:``,_=`step-${t}`,v=s?`${s}/${g||m}`:g||m;r.push({id:_,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:g||t,title:g||SV(m),type:m,role:gV(m),step:l?.length===2?String(Number(l[1])+1).padStart(2,`0`):void 0,detail:p?.on?`on ${p.on.replace(/^steps\./,``)}`:TV(m,h),summary:EV(h),when:typeof d.when==`string`?d.when:void 0,retry:wV(d.retry)&&typeof d.retry.attempts==`number`?d.retry.attempts:void 0,continues:d.on_failure===`continue`,branch:s,lane:u,path:l,stage:v,occurrence:f(v),...c?{resume:c}:{}}}),g&&a.set(g,_);let y=p?.on?`{{ ${p.on} }}`:``;for(let e of DV([d.settings,y],d.when))o.push({from:e,to:_});return _},m=(e,t,n)=>{e.forEach((r,a)=>i.push({id:`flow-${r}-${t}`,source:r,target:t,kind:`flow`,...s.has(r)?{otherwise:!0}:{},insertAfter:a===e.length-1?n:void 0}))};for(let[e,t]of n.entries()){let n=$B(t);if(n){let{kind:i,base:a,branches:o}=n,c=p(t,String(e+1),0,u*yV,void 0,void 0,[`steps`,e]);m(l,c,[`steps`,e-1]),u++;let d=wV(t)&&typeof t.id==`string`?t.id:i,f=i===`switch`&&!o.some(([e])=>e==="default"),h=o.length+ +!!f,g=[],_=0;o.forEach(([t,n],o)=>{let s=(o-(h-1)/2)*bV,l=[c],f=[`steps`,e,...a,t];n.forEach((n,r)=>{let a=p(n,`${e+1}-${t}-${r+1}`,s,(u+r)*yV,t,d,[...f,r],i);m(l,a,[...f,r-1]),l=[a]}),_=Math.max(_,n.length);let v=`add-${e}-${t}`;r.push({id:v,type:`add`,position:{x:s+104,y:(u+n.length)*yV},data:{kind:`step`,key:v,title:``,type:``,detail:``,branch:t,lane:i,insertAfter:[...f,n.length-1]}}),m(l,v),g.push(v)});let v=(Math.max(_,1)+1)*yV-24;o.forEach(([t],n)=>{let a=(n-(h-1)/2)*bV;r.push({id:`lane-${e}-${t}`,type:`lane`,position:{x:a-12,y:u*yV-40},style:{width:`264px`,height:`${v}px`},zIndex:-1,data:{kind:`step`,key:t,title:t,type:``,detail:``,lane:i}})}),f&&(g.push(c),s.add(c)),l=g,u+=Math.max(_,1)+1;continue}let i=p(t,String(e+1),0,u*yV,void 0,void 0,[`steps`,e]);m(l,i,[`steps`,e-1]),l=[i],u++}r.push({id:`add-end`,type:`add`,position:{x:104,y:u*yV-24},data:{kind:`step`,key:`add`,title:``,type:``,detail:``,insertAfter:[`steps`,n.length-1]}}),m(l,`add-end`);for(let{from:e,to:t}of o){let n=a.get(e);n&&(i.some(e=>e.kind===`flow`&&e.source===n&&e.target===t)||i.push({id:`data-${n}-${t}`,source:n,target:t,kind:`data`,label:e,offset:24+14*i.filter(e=>e.kind===`data`).length,sourceHandle:`data-out`,targetHandle:`data-in`}))}return{nodes:r,edges:i}}var kV={agent:Jt,command:Ln,repo:dn,gate:Nn,forge:yn,human:Hn,review:ln,workflow:Gn},AV={agent:`Agents`,command:`Commands`,repo:`Repository`,gate:`Checks`,forge:`Issues and PRs`,human:`People`,review:`Review`,workflow:`Flow`};function jV(e){return e===`parallel`?dn:e===`switch`?Fn:kV[e.split(`.`)[0]]??Gn}function MV(e){return Object.keys(AV).map(t=>({title:AV[t],icon:kV[t],types:e.filter(e=>e.split(`.`)[0]===t)})).filter(e=>e.types.length)}function NV(e){return Object.entries(e?.inputs??{}).map(([e,t])=>({name:e,type:t.type,required:t.required===!0})).sort((e,t)=>e.name.localeCompare(t.name))}function PV(e,t){return e.filter(e=>e.required&&!(t[e.name]??``).trim()).map(e=>e.name)}function FV(e,t){switch(t){case`number`:{let t=e.trim();return t!==``&&!Number.isNaN(Number(t))?Number(t):e}case`bool`:return e===`true`||e!==`false`&&e;case`string`:return e;default:try{return JSON.parse(e)}catch{return e}}}function IV(e,t){let n={};for(let r of e){let e=t[r.name];e!==void 0&&e!==``&&(n[r.name]=FV(e,r.type))}return n}var LV=A({__name:`WorkflowPicker`,props:{value:{},workflows:{},label:{}},emits:[`pick`],setup(e,{emit:t}){let n=t;return(t,r)=>(z(),J(B(Ml),{"model-value":e.value||void 0,"onUpdate:modelValue":r[0]||=e=>n(`pick`,String(e))},{default:M(()=>[N(B(zl),{"aria-label":e.label},{default:M(()=>[N(B(Bl),{placeholder:`Choose workflow`})]),_:1},8,[`aria-label`]),N(B(Nl),null,{default:M(()=>[e.value&&!e.workflows.some(t=>t.id===e.value)?(z(),J(B(Il),{key:0,value:e.value,disabled:``},{default:M(()=>[j(H(e.value)+` (unavailable)`,1)]),_:1},8,[`value`])):R(``,!0),(z(!0),K(U,null,q(e.workflows,e=>(z(),J(B(Il),{key:e.id,value:e.id},{default:M(()=>[j(H(e.id),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`model-value`]))}});function RV(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function zV(e,t=[]){let n=JB(e),r=n.errors[0];if(r)return{ok:!1,message:$V(r.message),line:r.linePos?.[0]?.line};let i=n.toJS();if(!eH(i))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let a=typeof i.id==`stLine truncated
`).map((e,t)=>({number:t+1,text:e,tokens:YV(e)}))}var qV=/^(\s*)(-\s+)?/,JV=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function YV(e){let{code:t,comment:n}=XV(e),r=ZV(t);return n&&r.push({text:n,kind:`comment`}),r}function XV(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t)r===t&&(t=``);else if(r===`"`||r===`'`)t=r;else if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function ZV(e){if(!e)return[];let t=[],n=qV.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=JV.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,...QV(i[4]??``)]):[...t,...QV(r)]}function QV(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 $V(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function eH(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tH(e){return typeof e==`string`&&e.trim()!==``}var nH={class:`flex h-full w-[24rem] flex-col border-l border-border bg-card shadow-xl`},rH={class:`flex items-center gap-2.5 border-b border-border px-4 py-3`},iH={class:`flex size-8 shrink-0 items-center justify-center rounded-md bg-secondary text-primary`},aH={class:`min-w-0 flex-1`},oH={class:`truncate font-mono text-[11px] text-fg-subtle`},sH={class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`},cH={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},lH={key:1,class:`space-y-3`},uH={key:0,class:`block space-y-1.5`},dH={id:`switch-on`},fH=[`value`],pH={class:`text-xs font-medium text-muted-foreground`},mH={class:`flex items-center gap-2`},hH={key:1,role:`alert`,class:`text-xs text-danger`},gH={key:2,class:`space-y-1.5`},_H=[`title`],vH={key:4,class:`flex flex-wrap items-center gap-1 pt-0.5`},yH={key:3,class:`divide-y divide-border rounded-md border border-border`},bH=[`title`],xH={key:0,class:`space-y-3`},SH={class:`text-[13px]`},CH={key:0,class:`text-danger`},wH={class:`ml-2 text-xs text-fg-subtle`},TH={key:1,class:`space-y-3`},EH={class:`text-[13px]`},DH={class:`ml-2 text-xs text-fg-subtle`},OH=[`title`],kH={key:0,class:`text-xs text-danger`},AH={class:`space-y-2`},jH={class:`divide-y divide-border rounded-md border border-border`},MH={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},NH={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},PH={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},FH={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},IH={class:`flex items-center border-t border-border px-4 py-2.5`},LH=A({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{},workflows:{},modelAliases:{}},emits:[`update:yaml`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=L(()=>tV(n.yaml,n.path)??{}),a=L(()=>$B(i.value)),o=L(()=>a.value?.kind??(typeof i.value.type==`string`?i.value.type:``)),s=L(()=>a.value?.branches.map(([e])=>e)??[]),c=L(()=>o.value===`parallel`?2:1);function l(e){r(`update:yaml`,nV(n.yaml,n.path,{...i.value,switch:{...i.value.switch,on:e}}))}let u=Y(``),d=Y(``);function f(e,t,i=``){try{let a=e===`add`?oV(n.yaml,n.path,t):e===`rename`?sV(n.yaml,n.path,t,i):cV(n.yaml,n.path,t);r(`update:yaml`,a),u.value=``,d.value=``}catch(e){d.value=String(e.message)}}let p=L(()=>n.vocabulary.find(e=>e.name===o.value)),m=L(()=>typeof i.value.settings==`object`&&i.value.settings!==null?i.value.settings:{}),h=L(()=>fV(n.yaml,n.path)),g=L(()=>p.value?.settings&&i.value.settings?WV(i.value.settings,p.value.settings,`settings`):``),_=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],v=/mission|body|detail|plan|rules/;function y(e,t){return[`workflow.call`,`workflow.handoff`].includes(o.value)&&e===`workflow`||o.value===`human.approve`&&e===`then`?`workflow`:o.value===`agent.run`&&e===`model`?`select`:t.type===`string`?t.enum?`select`:v.test(e)?`text`:`line`:t.type===`boolean`?`boolean`:t.type===`integer`||t.type===`number`?`number`:t.type===`array`&&t.items?.type===`string`?`lines`:`yaml`}let b=L(()=>{let e=Object.entries(p.value?.settings?.properties??{}).filter(([e])=>o.value!==`workflow.call`||![`inputs`,`outputs`].includes(e)).map(([e,t])=>({key:e,schema:t,kind:y(e,t),options:o.value===`agent.run`&&e===`model`?n.modelAliases:t.enum??[]})),t=e.filter(e=>_.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>_.indexOf(e.key)-_.indexOf(t.key))[0],r=e.filter(e=>e!==t);return{lead:t,compact:r.filter(e=>[`workflow`,`select`,`line`,`number`,`boolean`].includes(e.kind)),long:r.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}});function x(e){let{id:t,type:i,...a}=e;r(`update:yaml`,nV(n.yaml,n.path,{id:t,type:i,...a}))}function S(e,t){x({...i.value,[e]:t})}function C(e){S(`retry`,{...i.value.retry,...e})}function w(e,t){let n={...m.value,[e]:t};o.value===`workflow.call`&&e===`wait`&&t!==!0&&delete n.outputs,x({...i.value,settings:n})}function ee(e,t){let n={...m.value,[e]:t};o.value===`workflow.call`&&t!==m.value[e]&&(delete n.inputs,delete n.outputs),x({...i.value,settings:n})}let T=L(()=>n.workflows.find(e=>e.id===m.value.workflow)),te=L(()=>Object.entries(mV(T.value?.yaml??``,`inputs`)??{})),E=L(()=>Object.entries(mV(T.value?.yaml??``,`outputs`)??{})),ne=L(()=>Object.entries(mV(n.yaml,`inputs`)??{})),D=L(()=>Object.entries(mV(n.yaml,`outputs`)??{})),re=L(()=>m.value.inputs??{}),O=L(()=>m.value.outputs??{}),ie=e=>typeof e==`string`&&e.startsWith(`inputs.`),ae=e=>re.value[e]===void 0?``:String(re.value[e]);function oe(e,t,n){w(`inputs`,{...re.value,[e]:t===``?void 0:ie(t)?t:FV(t,n??`string`)})}let se=Y(null);function ce(e,t){let n=se.value??b.value.lead?.key;if(!n)return;let r=typeof m.value[n]==`string`?m.value[n]:``,i=`{{ steps.${e}.${t} }}`;w(n,r?`${r.trimEnd()} ${i}`:i)}let le=Y({});function ue(e,t){try{w(e,t.trim()?YB(t):void 0),le.value={...le.value,[e]:``}}catch(t){le.valu Line truncated
`)[0]}}}let de=e=>e===void 0?``:XB(e).trimEnd(),fe=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),pe=e=>typeof m.value[e]==`string`?m.value[e]:``;return(t,n)=>(z(),K(`aside`,nH,[G(`header`,rH,[G(`span`,iH,[(z(),J(He(B(jV)(o.value)),{class:`size-4`}))]),G(`div`,aH,[N(B(k),{"model-value":i.value.id??``,class:`h-7 truncate border-transparent px-1 font-medium shadow-none hover:border-input dark:bg-transparent`,placeholder:B(SV)(o.value),"aria-label":`Step id`,"onUpdate:modelValue":n[0]||=e=>S(`id`,String(e))},null,8,[`model-value`,`placeholder`]),G(`div`,oH,H(o.value),1)]),N(B(X),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,onClick:n[1]||=e=>r(`close`)},{default:M(()=>[N(B(qn))]),_:1})]),G(`div`,sH,[g.value?(z(),K(`p`,cH,H(g.value),1)):R(``,!0),a.value?(z(),K(`section`,lH,[o.value===`switch`?(z(),K(`label`,uH,[n[18]||=G(`span`,{class:`text-xs font-medium text-muted-foreground`,title:`The value whose case runs; a case named default runs when none matches`},`Switch on`,-1),N(B(k),{"model-value":a.value.on,class:`font-mono`,placeholder:`steps.assess.result.fit`,list:`switch-on`,onChange:n[2]||=e=>l(e.target.value.trim())},null,8,[`model-value`]),G(`datalist`,dH,[(z(!0),K(U,null,q(h.value,e=>(z(),K(`option`,{key:e,value:`steps.${e}.result.`},null,8,fH))),128))])])):R(``,!0),G(`div`,pH,H(o.value===`switch`?`Cases`:`Branches`),1),(z(!0),K(U,null,q(s.value,e=>(z(),K(`div`,{key:e,class:`flex items-center gap-2`},[N(B(k),{"model-value":e,class:P(o.value===`switch`&&`font-mono`),"aria-label":`${o.value===`switch`?`Case`:`Branch`} ${e}`,onChange:t=>f(`rename`,e,t.target.value.trim())},null,8,[`model-value`,`class`,`aria-label`,`onChange`]),N(B(X),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e}`,disabled:s.value.length<=c.value,onClick:t=>f(`delete`,e)},{default:M(()=>[N(B(zn))]),_:1},8,[`aria-label`,`disabled`,`onClick`])]))),128)),G(`div`,mH,[N(B(k),{modelValue:u.value,"onUpdate:modelValue":n[3]||=e=>u.value=e,"aria-label":o.value===`switch`?`New case value`:`New branch name`,placeholder:o.value===`switch`?`Value, or default`:`Branch name`,onKeydown:n[4]||=vt(St(e=>f(`add`,u.value.trim()),[`prevent`]),[`enter`])},null,8,[`modelValue`,`aria-label`,`placeholder`]),N(B(X),{type:`button`,size:`icon-sm`,variant:`outline`,"aria-label":o.value===`switch`?`Add case`:`Add branch`,disabled:!u.value.trim(),onClick:n[5]||=e=>f(`add`,u.value.trim())},{default:M(()=>[N(B(En))]),_:1},8,[`aria-label`,`disabled`])]),d.value?(z(),K(`p`,hH,H(d.value),1)):R(``,!0)])):R(``,!0),b.value.lead?(z(),K(`section`,gH,[G(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:b.value.lead.schema.description},[j(H(fe(b.value.lead.key,b.value.lead.schema))+` `,1),b.value.lead.schema.description?(z(),J(B(an),{key:0,class:`size-3 text-fg-subtle`})):R(``,!0)],8,_H),b.value.lead.kind===`workflow`?(z(),J(LV,{key:0,value:pe(b.value.lead.key),workflows:e.workflows,label:fe(b.value.lead.key,b.value.lead.schema),onPick:n[6]||=e=>ee(b.value.lead.key,e)},null,8,[`value`,`workflows`,`label`])):b.value.lead.kind===`select`?(z(),J(B(jI),{key:1,size:`sm`,class:`w-full`,"model-value":pe(b.value.lead.key),"onUpdate:modelValue":n[7]||=e=>w(b.value.lead.key,String(e)||void 0)},{default:M(()=>[N(B(MI),{value:``},{default:M(()=>[...n[19]||=[j(`Default`,-1)]]),_:1}),(z(!0),K(U,null,q(b.value.lead.options,e=>(z(),J(B(MI),{key:e,value:e},{default:M(()=>[j(H(e),1)]),_:2},1032,[`value`]))),128))]),_:1},8,[`model-value`])):b.value.lead.kind===`text`?(z(),J(B(ru),{key:2,"model-value":pe(b.value.lead.key),class:`min-h-40 text-[13px] leading-relaxed`,onFocus:n[8]||=e=>se.value=b.value.lead.key,"onUpdate:modelValue":n[9]||=e=>w(b.value.lead.key,String(e))},null,8,[`model-value`])):(z(),J(B(k),{key:3,"model-value":pe(b.value.lead.key),onFocus:n[10]||=e=>se.value=b.value.lead.key,"onUpdate:modelValue":n[11]||=e=>w(b.value.lead.key,String(e))},null,8,[`model-value`])),h.value.length&&b.value.lead.kind!==`select`?(z(),K(`div`,vH,[n[20]||=G(`span`,{class:`text-[11px] text-fg-subtle`},`Insert`,-1),(z(!0),K(U,null,q(h.value,e=>(z(),K(U,{key:e},[N(B(X),{type:`button`,variant:`outline`,size:`xs`,class:`font-mono`,onClick:t=>ce(e,`summary`)},{default:M(()=>[j(H(e),1)]),_:2},1032,[`onClick`]),N(B(X),{type:`button`,variant:`outline`,size:`xs`,class:`font-mono`,onClick:t=>ce(e,`result`)},{default:M(()=>[j(H(e)+`.result`,1)]),_:2},1032,[`onClick`])],64))),128))])):R(``,!0)])):R(``,!0),b.value.compact.length?(z(),K(`section`,yH,[(z(!0),K(U,null,q(b.value.compact,t=>(z(),K(`div`,{key:t.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[G(`span`,{class:`flex flex-1 items-center gap-1 text-[13px]`,title:t.schema.description},[j(H(fe(t.key,t.schema))+` `,1),t.schema.description?(z(),J(B(an),{key:0,class:`size-3 text-fg-subtle`})):R(``,!0)],8,bH),t.kind===`workflow`?(z(),J(LV,{key:0,class:`max-w-48`,value:pe(t.key),workflows:e.workflows,label:fe(t.key,t.schema),onPick:e=>ee(t.key,e)},null,8,[`vLine 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=KB(GB(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=KB(GB(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 XB(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new VB||null,prettyErrors:t}}function ZB(e,t={}){let{lineCounter:n,prettyErrors:r}=XB(t),i=new YB(n?.addNewLine),a=new DB(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 Uz(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Gz(e,n)),o.warnings.forEach(Gz(e,n))),o}function QB(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=ZB(e,n);if(!i)return null;if(i.warnings.forEach(e=>xR(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function $B(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return gL(e)&&!r?e.toString(n):new Bz(e,r,n).toString(n)}var eV=e=>typeof e==`object`&&!!e&&!Array.isArray(e),tV=e=>eV(e)?Object.entries(e).map(([e,t])=>[e,Array.isArray(t)?t:[]]):[];function nV(e){if(eV(e)){if(eV(e.parallel))return{kind:`parallel`,base:[`parallel`],branches:tV(e.parallel)};if(eV(e.switch))return{kind:`switch`,base:[`switch`,`cases`],on:typeof e.switch.on==`string`?e.switch.on:``,branches:tV(e.switch.cases)}}}function rV(e){return e.slice(2).includes(`parallel`)}function iV(e,t){let n=ZB(e).getIn(t,!0);if(_L(n))return n.toJSON()}function aV(e,t,n){let r=ZB(e);return r.setIn(t,r.createNode(gV(n))),r.toString()}function oV(e,t,n){let r=ZB(e),i=t.slice(0,-1),a=rV(i);if(a&&![`agent.run`,`workflow.call`].includes(n))throw Error(`Branches allow only read-only agents and workflow calls.`);let o=r.getIn(i,!0);if(bL(o)||(r.setIn(i,r.createNode([])),o=r.getIn(i,!0)),!bL(o))return{source:e,path:[]};let s=Math.min(Math.max(Number(t.at(-1))+1,0),o.items.length),c=n===`parallel`?{parallel:{"branch-1":[],"branch-2":[]}}:n===`switch`?{switch:{on:``,cases:{true:[],default:[]}}}:{type:n,...a&&n===`agent.run`?{settings:{read_only:!0}}:{}};return o.items.splice(s,0,r.createNode(c)),{source:r.toString(),path:[...i,s]}}function sV(e,t){if(t===`switch`){if(!e||e.includes(`/`))throw Error(`A case is the value it matches, without a slash.`)}else if(!/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/.test(e))throw Error(`Use a lowercase branch name with letters, digits, dots or dashes.`)}function cV(e,t){let n=e.getIn(t,!0),r=nV(_L(n)?n.toJSON():void 0),i=r?e.getIn([...t,...r.base],!0):void 0;if(!r||!_L(i))throw Error(`This step has no branches.`);return{kind:r.kind,branches:i}}function lV(e,t,n){let r=ZB(e),{kind:i,branches:a}=cV(r,t);if(sV(n,i),a.has(n))throw Error(`Branch ${n} already exists.`);return a.set(n,r.createNode([])),r.toString()}function uV(e,t,n,r){let i=ZB(e),{kind:a,branches:o}=cV(i,t);if(sV(r,a),n!==r&&o.has(r))throw Error(`Branch ${r} already exists.`);let s=o.items.find(e=>yL(e.key)&&e.key.value===n);if(!s||!yL(s.key))throw Error(`Branch ${n} does not exist.`);return s.key.value=r,i.toString()}function dV(e,t,n){let r=ZB(e),{kind:i,branches:a}=cV(r,t);if(i===`parallel`&&a.items.length<=2)throw Error(`Parallel needs at least two branches.`);if(a.items.length<=1)throw Error(`A switch needs at least one case.`);return Line truncated
`).find(e=>e.trim())?.trim()}}function AV(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(EV)].map(e=>e[1]))]}function jV(e){let t=ZB(e).toJS(),n=DV(t)&&Array.isArray(t.steps)?t.steps:[],r=[],i=[],a=new Map,o=[],s=new Set,c=`start`;r.push({id:c,type:`step`,position:{x:0,y:0},data:{kind:`start`,key:`start`,title:`Starts when`,type:``,detail:``}});let l=[c],u=1,d=new Map,f=e=>{let t=d.get(e)??0;return d.set(e,t+1),t},p=(e,t,n,i,s,c,l,u)=>{let d=DV(e)?e:{},p=nV(d),m=p?.kind??(typeof d.type==`string`?d.type:``),h=DV(d.settings)?d.settings:{},g=typeof d.id==`string`?d.id:``,_=`step-${t}`,v=s?`${s}/${g||m}`:g||m;r.push({id:_,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:g||t,title:g||TV(m),type:m,role:yV(m),step:l?.length===2?String(Number(l[1])+1).padStart(2,`0`):void 0,detail:p?.on?`on ${p.on.replace(/^steps\./,``)}`:OV(m,h),summary:kV(h),when:typeof d.when==`string`?d.when:void 0,retry:DV(d.retry)&&typeof d.retry.attempts==`number`?d.retry.attempts:void 0,continues:d.on_failure===`continue`,branch:s,lane:u,path:l,stage:v,occurrence:f(v),...c?{resume:c}:{}}}),g&&a.set(g,_);let y=p?.on?`{{ ${p.on} }}`:``;for(let e of AV([d.settings,y],d.when))o.push({from:e,to:_});return _},m=(e,t,n)=>{e.forEach((r,a)=>i.push({id:`flow-${r}-${t}`,source:r,target:t,kind:`flow`,...s.has(r)?{otherwise:!0}:{},insertAfter:a===e.length-1?n:void 0}))};for(let[e,t]of n.entries()){let n=nV(t);if(n){let{kind:i,base:a,branches:o}=n,c=p(t,String(e+1),0,u*SV,void 0,void 0,[`steps`,e]);m(l,c,[`steps`,e-1]),u++;let d=DV(t)&&typeof t.id==`string`?t.id:i,f=i===`switch`&&!o.some(([e])=>e==="default"),h=o.length+ +!!f,g=[],_=0;o.forEach(([t,n],o)=>{let s=(o-(h-1)/2)*CV,l=[c],f=[`steps`,e,...a,t];n.forEach((n,r)=>{let a=p(n,`${e+1}-${t}-${r+1}`,s,(u+r)*SV,t,d,[...f,r],i);m(l,a,[...f,r-1]),l=[a]}),_=Math.max(_,n.length);let v=`add-${e}-${t}`;r.push({id:v,type:`add`,position:{x:s+104,y:(u+n.length)*SV},data:{kind:`step`,key:v,title:``,type:``,detail:``,branch:t,lane:i,insertAfter:[...f,n.length-1]}}),m(l,v),g.push(v)});let v=(Math.max(_,1)+1)*SV-24;o.forEach(([t],n)=>{let a=(n-(h-1)/2)*CV;r.push({id:`lane-${e}-${t}`,type:`lane`,position:{x:a-12,y:u*SV-40},style:{width:`264px`,height:`${v}px`},zIndex:-1,data:{kind:`step`,key:t,title:t,type:``,detail:``,lane:i}})}),f&&(g.push(c),s.add(c)),l=g,u+=Math.max(_,1)+1;continue}let i=p(t,String(e+1),0,u*SV,void 0,void 0,[`steps`,e]);m(l,i,[`steps`,e-1]),l=[i],u++}r.push({id:`add-end`,type:`add`,position:{x:104,y:u*SV-24},data:{kind:`step`,key:`add`,title:``,type:``,detail:``,insertAfter:[`steps`,n.length-1]}}),m(l,`add-end`);for(let{from:e,to:t}of o){let n=a.get(e);n&&(i.some(e=>e.kind===`flow`&&e.source===n&&e.target===t)||i.push({id:`data-${n}-${t}`,source:n,target:t,kind:`data`,label:e,offset:24+14*i.filter(e=>e.kind===`data`).length,sourceHandle:`data-out`,targetHandle:`data-in`}))}return{nodes:r,edges:i}}var MV={agent:Jt,command:Rn,repo:fn,gate:Pn,forge:bn,human:Un,review:ln,workflow:Kn},NV={agent:`Agents`,command:`Commands`,repo:`Repository`,gate:`Checks`,forge:`Issues and PRs`,human:`People`,review:`Review`,workflow:`Flow`};function PV(e){return e===`parallel`?fn:e===`switch`?In:MV[e.split(`.`)[0]]??Kn}function FV(e){return Object.keys(NV).map(t=>({title:NV[t],icon:MV[t],types:e.filter(e=>e.split(`.`)[0]===t)})).filter(e=>e.types.length)}function IV(e){return Object.entries(e?.inputs??{}).map(([e,t])=>({name:e,type:t.type,required:t.required===!0})).sort((e,t)=>e.name.localeCompare(t.name))}function LV(e,t){return e.filter(e=>e.required&&!(t[e.name]??``).trim()).map(e=>e.name)}function RV(e,t){switch(t){case`number`:{let t=e.trim();return t!==``&&!Number.isNaN(Number(t))?Number(t):e}case`bool`:return e===`true`||e!==`false`&&e;case`string`:return e;default:try{return JSON.parse(e)}catch{return e}}}function zV(e,t){let n={};for(let r of e){let e=t[r.name];e!==void 0&&e!==``&&(n[r.name]=RV(e,r.type))}return n}var BV=A({__name:`WorkflowPicker`,props:{value:{},workflows:{},label:{}},emits:[`pick`],setup(e,{emit:t}){let n=t;return(t,r)=>(z(),J(B(Nl),{"model-value":e.value||void 0,"onUpdate:modelValue":r[0]||=e=>n(`pick`,String(e))},{default:M(()=>[N(B(Bl),{"aria-label":e.label},{default:M(()=>[N(B(Vl),{placeholder:`Choose workflow`})]),_:1},8,[`aria-label`]),N(B(Pl),null,{default:M(()=>[e.value&&!e.workflows.some(t=>t.id===e.value)?(z(),J(B(Ll),{key:0,value:e.value,disabled:``},{default:M(()=>[j(H(e.value)+` (unavailable)`,1)]),_:1},8,[`value`])):R(``,!0),(z(!0),K(U,null,q(e.workflows,e=>(z(),J(B(Ll),{key:e.id,value:e.id},{default:M(()=>[j(H(e.id),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`model-value`]))}});function VV(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function HV(e,t=[]){let n=ZB(e),r=n.errors[0];if(r)return{ok:!1,message:nH(r.message),line:r.linePos?.[0]?.line};let i=n.toJS();if(!rH(i))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let a=typeof i.id==`stLine truncated
`).map((e,t)=>({number:t+1,text:e,tokens:QV(e)}))}var XV=/^(\s*)(-\s+)?/,ZV=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function QV(e){let{code:t,comment:n}=$V(e),r=eH(t);return n&&r.push({text:n,kind:`comment`}),r}function $V(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t)r===t&&(t=``);else if(r===`"`||r===`'`)t=r;else if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function eH(e){if(!e)return[];let t=[],n=XV.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=ZV.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,...tH(i[4]??``)]):[...t,...tH(r)]}function tH(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 nH(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function rH(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iH(e){return typeof e==`string`&&e.trim()!==``}var aH={class:`flex h-full w-[24rem] flex-col border-l border-border bg-card shadow-xl`},oH={class:`flex items-center gap-2.5 border-b border-border px-4 py-3`},sH={class:`flex size-8 shrink-0 items-center justify-center rounded-md bg-secondary text-primary`},cH={class:`min-w-0 flex-1`},lH={class:`truncate font-mono text-[11px] text-fg-subtle`},uH={class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`},dH={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},fH={key:1,class:`space-y-3`},pH={key:0,class:`block space-y-1.5`},mH={id:`switch-on`},hH=[`value`],gH={class:`text-xs font-medium text-muted-foreground`},_H={class:`flex items-center gap-2`},vH={key:1,role:`alert`,class:`text-xs text-danger`},yH={key:2,class:`space-y-1.5`},bH=[`title`],xH={key:4,class:`flex flex-wrap items-center gap-1 pt-0.5`},SH={key:3,class:`divide-y divide-border rounded-md border border-border`},CH=[`title`],wH={key:0,class:`space-y-3`},TH={class:`text-[13px]`},EH={key:0,class:`text-danger`},DH={class:`ml-2 text-xs text-fg-subtle`},OH={key:1,class:`space-y-3`},kH={class:`text-[13px]`},AH={class:`ml-2 text-xs text-fg-subtle`},jH=[`title`],MH={key:0,class:`text-xs text-danger`},NH={class:`space-y-2`},PH={class:`divide-y divide-border rounded-md border border-border`},FH={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},IH={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},LH={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},RH={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},zH={class:`flex items-center border-t border-border px-4 py-2.5`},BH=A({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{},workflows:{},modelAliases:{}},emits:[`update:yaml`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=L(()=>iV(n.yaml,n.path)??{}),a=L(()=>nV(i.value)),o=L(()=>a.value?.kind??(typeof i.value.type==`string`?i.value.type:``)),s=L(()=>a.value?.branches.map(([e])=>e)??[]),c=L(()=>o.value===`parallel`?2:1);function l(e){r(`update:yaml`,aV(n.yaml,n.path,{...i.value,switch:{...i.value.switch,on:e}}))}let u=Y(``),d=Y(``);function f(e,t,i=``){try{let a=e===`add`?lV(n.yaml,n.path,t):e===`rename`?uV(n.yaml,n.path,t,i):dV(n.yaml,n.path,t);r(`update:yaml`,a),u.value=``,d.value=``}catch(e){d.value=String(e.message)}}let p=L(()=>n.vocabulary.find(e=>e.name===o.value)),m=L(()=>typeof i.value.settings==`object`&&i.value.settings!==null?i.value.settings:{}),h=L(()=>hV(n.yaml,n.path)),g=L(()=>p.value?.settings&&i.value.settings?qV(i.value.settings,p.value.settings,`settings`):``),_=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],v=/mission|body|detail|plan|rules/;function y(e,t){return[`workflow.call`,`workflow.handoff`].includes(o.value)&&e===`workflow`||o.value===`human.approve`&&e===`then`?`workflow`:o.value===`agent.run`&&e===`model`?`select`:t.type===`string`?t.enum?`select`:v.test(e)?`text`:`line`:t.type===`boolean`?`boolean`:t.type===`integer`||t.type===`number`?`number`:t.type===`array`&&t.items?.type===`string`?`lines`:`yaml`}let b=L(()=>{let e=Object.entries(p.value?.settings?.properties??{}).filter(([e])=>o.value!==`workflow.call`||![`inputs`,`outputs`].includes(e)).map(([e,t])=>({key:e,schema:t,kind:y(e,t),options:o.value===`agent.run`&&e===`model`?n.modelAliases:t.enum??[]})),t=e.filter(e=>_.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>_.indexOf(e.key)-_.indexOf(t.key))[0],r=e.filter(e=>e!==t);return{lead:t,compact:r.filter(e=>[`workflow`,`select`,`line`,`number`,`boolean`].includes(e.kind)),long:r.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}});function x(e){let{id:t,type:i,...a}=e;r(`update:yaml`,aV(n.yaml,n.path,{id:t,type:i,...a}))}function S(e,t){x({...i.value,[e]:t})}function C(e){S(`retry`,{...i.value.retry,...e})}function w(e,t){let n={...m.value,[e]:t};o.value===`workflow.call`&&e===`wait`&&t!==!0&&delete n.outputs,x({...i.value,settings:n})}function ee(e,t){let n={...m.value,[e]:t};o.value===`workflow.call`&&t!==m.value[e]&&(delete n.inputs,delete n.outputs),x({...i.value,settings:n})}let T=L(()=>n.workflows.find(e=>e.id===m.value.workflow)),te=L(()=>Object.entries(_V(T.value?.yaml??``,`inputs`)??{})),E=L(()=>Object.entries(_V(T.value?.yaml??``,`outputs`)??{})),ne=L(()=>Object.entries(_V(n.yaml,`inputs`)??{})),D=L(()=>Object.entries(_V(n.yaml,`outputs`)??{})),re=L(()=>m.value.inputs??{}),O=L(()=>m.value.outputs??{}),ie=e=>typeof e==`string`&&e.startsWith(`inputs.`),ae=e=>re.value[e]===void 0?``:String(re.value[e]);function oe(e,t,n){w(`inputs`,{...re.value,[e]:t===``?void 0:ie(t)?t:RV(t,n??`string`)})}let se=Y(null);function ce(e,t){let n=se.value??b.value.lead?.key;if(!n)return;let r=typeof m.value[n]==`string`?m.value[n]:``,i=`{{ steps.${e}.${t} }}`;w(n,r?`${r.trimEnd()} ${i}`:i)}let le=Y({});function ue(e,t){try{w(e,t.trim()?QB(t):void 0),le.value={...le.value,[e]:``}}catch(t){le.valu Line truncated
`)[0]}}}let de=e=>e===void 0?``:$B(e).trimEnd(),fe=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),pe=e=>typeof m.value[e]==`string`?m.value[e]:``;return(t,n)=>(z(),K(`aside`,aH,[G(`header`,oH,[G(`span`,sH,[(z(),J(He(B(PV)(o.value)),{class:`size-4`}))]),G(`div`,cH,[N(B(k),{"model-value":i.value.id??``,class:`h-7 truncate border-transparent px-1 font-medium shadow-none hover:border-input dark:bg-transparent`,placeholder:B(TV)(o.value),"aria-label":`Step id`,"onUpdate:modelValue":n[0]||=e=>S(`id`,String(e))},null,8,[`model-value`,`placeholder`]),G(`div`,lH,H(o.value),1)]),N(B(X),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,onClick:n[1]||=e=>r(`close`)},{default:M(()=>[N(B(Jn))]),_:1})]),G(`div`,uH,[g.value?(z(),K(`p`,dH,H(g.value),1)):R(``,!0),a.value?(z(),K(`section`,fH,[o.value===`switch`?(z(),K(`label`,pH,[n[18]||=G(`span`,{class:`text-xs font-medium text-muted-foreground`,title:`The value whose case runs; a case named default runs when none matches`},`Switch on`,-1),N(B(k),{"model-value":a.value.on,class:`font-mono`,placeholder:`steps.assess.result.fit`,list:`switch-on`,onChange:n[2]||=e=>l(e.target.value.trim())},null,8,[`model-value`]),G(`datalist`,mH,[(z(!0),K(U,null,q(h.value,e=>(z(),K(`option`,{key:e,value:`steps.${e}.result.`},null,8,hH))),128))])])):R(``,!0),G(`div`,gH,H(o.value===`switch`?`Cases`:`Branches`),1),(z(!0),K(U,null,q(s.value,e=>(z(),K(`div`,{key:e,class:`flex items-center gap-2`},[N(B(k),{"model-value":e,class:P(o.value===`switch`&&`font-mono`),"aria-label":`${o.value===`switch`?`Case`:`Branch`} ${e}`,onChange:t=>f(`rename`,e,t.target.value.trim())},null,8,[`model-value`,`class`,`aria-label`,`onChange`]),N(B(X),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e}`,disabled:s.value.length<=c.value,onClick:t=>f(`delete`,e)},{default:M(()=>[N(B(Bn))]),_:1},8,[`aria-label`,`disabled`,`onClick`])]))),128)),G(`div`,_H,[N(B(k),{modelValue:u.value,"onUpdate:modelValue":n[3]||=e=>u.value=e,"aria-label":o.value===`switch`?`New case value`:`New branch name`,placeholder:o.value===`switch`?`Value, or default`:`Branch name`,onKeydown:n[4]||=vt(St(e=>f(`add`,u.value.trim()),[`prevent`]),[`enter`])},null,8,[`modelValue`,`aria-label`,`placeholder`]),N(B(X),{type:`button`,size:`icon-sm`,variant:`outline`,"aria-label":o.value===`switch`?`Add case`:`Add branch`,disabled:!u.value.trim(),onClick:n[5]||=e=>f(`add`,u.value.trim())},{default:M(()=>[N(B(Dn))]),_:1},8,[`aria-label`,`disabled`])]),d.value?(z(),K(`p`,vH,H(d.value),1)):R(``,!0)])):R(``,!0),b.value.lead?(z(),K(`section`,yH,[G(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:b.value.lead.schema.description},[j(H(fe(b.value.lead.key,b.value.lead.schema))+` `,1),b.value.lead.schema.description?(z(),J(B(an),{key:0,class:`size-3 text-fg-subtle`})):R(``,!0)],8,bH),b.value.lead.kind===`workflow`?(z(),J(BV,{key:0,value:pe(b.value.lead.key),workflows:e.workflows,label:fe(b.value.lead.key,b.value.lead.schema),onPick:n[6]||=e=>ee(b.value.lead.key,e)},null,8,[`value`,`workflows`,`label`])):b.value.lead.kind===`select`?(z(),J(B(MI),{key:1,size:`sm`,class:`w-full`,"model-value":pe(b.value.lead.key),"onUpdate:modelValue":n[7]||=e=>w(b.value.lead.key,String(e)||void 0)},{default:M(()=>[N(B(NI),{value:``},{default:M(()=>[...n[19]||=[j(`Default`,-1)]]),_:1}),(z(!0),K(U,null,q(b.value.lead.options,e=>(z(),J(B(NI),{key:e,value:e},{default:M(()=>[j(H(e),1)]),_:2},1032,[`value`]))),128))]),_:1},8,[`model-value`])):b.value.lead.kind===`text`?(z(),J(B(iu),{key:2,"model-value":pe(b.value.lead.key),class:`min-h-40 text-[13px] leading-relaxed`,onFocus:n[8]||=e=>se.value=b.value.lead.key,"onUpdate:modelValue":n[9]||=e=>w(b.value.lead.key,String(e))},null,8,[`model-value`])):(z(),J(B(k),{key:3,"model-value":pe(b.value.lead.key),onFocus:n[10]||=e=>se.value=b.value.lead.key,"onUpdate:modelValue":n[11]||=e=>w(b.value.lead.key,String(e))},null,8,[`model-value`])),h.value.length&&b.value.lead.kind!==`select`?(z(),K(`div`,xH,[n[20]||=G(`span`,{class:`text-[11px] text-fg-subtle`},`Insert`,-1),(z(!0),K(U,null,q(h.value,e=>(z(),K(U,{key:e},[N(B(X),{type:`button`,variant:`outline`,size:`xs`,class:`font-mono`,onClick:t=>ce(e,`summary`)},{default:M(()=>[j(H(e),1)]),_:2},1032,[`onClick`]),N(B(X),{type:`button`,variant:`outline`,size:`xs`,class:`font-mono`,onClick:t=>ce(e,`result`)},{default:M(()=>[j(H(e)+`.result`,1)]),_:2},1032,[`onClick`])],64))),128))])):R(``,!0)])):R(``,!0),b.value.compact.length?(z(),K(`section`,SH,[(z(!0),K(U,null,q(b.value.compact,t=>(z(),K(`div`,{key:t.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[G(`span`,{class:`flex flex-1 items-center gap-1 text-[13px]`,title:t.schema.description},[j(H(fe(t.key,t.schema))+` `,1),t.schema.description?(z(),J(B(an),{key:0,class:`size-3 text-fg-subtle`})):R(``,!0)],8,CH),t.kind===`workflow`?(z(),J(BV,{key:0,class:`max-w-48`,value:pe(t.key),workflows:e.workflows,label:fe(t.key,t.schema),onPick:e=>ee(t.key,e)},null,8,[`vLine truncated
`):``,class:`min-h-16 font-mono text-xs`,placeholder:`One per line`,"onUpdate:modelValue":t=>w(e.key,String(t).split(`
`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(z(),K(U,{key:2},[N(B(ru),{"model-value":de(m.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>ue(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),le.value[e.key]?(z(),K(`span`,kH,H(le.value[e.key]),1)):R(``,!0)],64))]))),128)),G(`section`,AH,[n[37]||=G(`div`,{class:`text-xs font-medium text-muted-foreground`},`Flow`,-1),G(`div`,jH,[G(`label`,MH,[n[31]||=G(`span`,{class:`flex-1 text-[13px]`},`Run only when`,-1),N(B(k),{class:`h-7 w-48 font-mono text-xs`,placeholder:`always`,"model-value":i.value.when??``,"onUpdate:modelValue":n[12]||=e=>S(`when`,String(e))},null,8,[`model-value`])]),G(`label`,NH,[n[34]||=G(`span`,{class:`flex-1 text-[13px]`},`If it fails`,-1),N(B(jI),{size:`sm`,"model-value":i.value.on_failure??``,"onUpdate:modelValue":n[13]||=e=>S(`on_failure`,String(e)||void 0)},{default:M(()=>[N(B(MI),{value:``},{default:M(()=>[...n[32]||=[j(`Park the task`,-1)]]),_:1}),N(B(MI),{value:`continue`},{default:M(()=>[...n[33]||=[j(`Continue`,-1)]]),_:1})]),_:1},8,[`model-value`])]),G(`label`,PH,[n[35]||=G(`span`,{class:`flex-1 text-[13px]`},`Attempts`,-1),N(B(k),{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-7 w-20 text-right text-[13px]`,"model-value":i.value.retry?.attempts??``,"onUpdate:modelValue":n[14]||=e=>C({attempts:String(e)===``?void 0:Number(String(e))})},null,8,[`model-value`])]),G(`label`,FH,[n[36]||=G(`span`,{class:`flex-1 text-[13px]`},`Retry backoff`,-1),N(B(Ch),{"model-value":i.value.retry?.backoff??``,units:[`s`,`m`,`h`],"onUpdate:modelValue":n[15]||=e=>C({backoff:e||void 0})},null,8,[`model-value`])])])])]),G(`footer`,IH,[N(B(X),{type:`button`,variant:`ghost`,size:`sm`,class:`text-danger`,onClick:n[16]||=e=>r(`remove`)},{default:M(()=>[N(B(zn)),n[38]||=j(`Delete step`,-1)]),_:1}),N(B(X),{type:`button`,size:`sm`,class:`ml-auto`,onClick:n[17]||=e=>r(`close`)},{default:M(()=>[...n[39]||=[j(`Done`,-1)]]),_:1})])]))}}),RH=`repository_path`;function zH(e,t,n){let r=[];for(let[n,i]of e){let e=t[n];e?.from===`path`&&e.path.trim()&&r.push({name:n,path:e.path.trim(),type:i.type??`string`,required:i.required===!0})}return n.trim()&&r.push({name:RH,path:n.trim(),type:`string`,required:!0}),r}function BH(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function VH(e,t,n){let r=[];for(let[i,a]of e){let e=t[i],o=a.type??`string`;if(!(e&&(e.from===`path`?e.path.trim():e.value!==``))){a.required&&r.push(`${i} is required`);continue}if(e.from===`path`){let e=n?.failures?.find(e=>e.field_name===i);e&&r.push(`${i}: ${e.reason}`);continue}let s=BH(ab(e.value,o));o!==`any`&&s!==o&&r.push(`${i} is ${o}, but ${JSON.stringify(e.value)} is not`)}return n?.failures?.some(e=>e.field_name===`repository_path`)&&r.push(`the repository path does not resolve`),r}function HH(e,t){let n={};for(let[r,i]of e){let e=t[r];e?.from===`path`&&e.path.trim()?n[r]={param:r}:e?.from===`value`&&e.value!==``&&(n[r]={value:ab(e.value,i.type??`string`)})}return n}function UH(e,t){let n=e=>t.find(t=>t.name===e)?.path??``,r={};for(let[t,i]of Object.entries(e.inputs??{}))r[t]=i.param?{from:`path`,path:n(i.param),value:``}:{from:`value`,path:``,value:typeof i.value==`string`?i.value:JSON.stringify(i.value)};return{rows:r,repositoryPath:n(e.repo_param)}}function WH(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...WH(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...WH(n,r)]}):[]}function GH(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function KH(e){try{let t=JSON.parse(e.headers??`{}`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t)]))}catch{return{}}}function qH(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var JH={class:`flex h-full flex-col`},YH={class:`flex items-center gap-2 border-b border-border px-4 py-3`},XH={class:`min-w-0 flex-1 truncate text-sm font-medium`},ZH={key:0,class:`flex flex-1 items-center justify-center`},QH={class:`space-y-1.5`},$H={key:1,class:`space-y-1.5`},eU=[`title`],tU={class:`space-y-1.5`},nU={id:`bind-paths`},rU=[`value`],iU={class:`divide-y divide-border rounded-md border border-border`},aU={class:`flex items-center gap-1.5 text-xs`},oU={class:`font-mono`},sU={class:`text-fg-subtle`},cU={key:0,class:`text-danger`,title:`Required`},lU={key:2,class:`text-xs text-danger`},uU=[`title`],dU={key:0,class:`space-y-1 px-3 py-2`},fU={key:0,class:`text-xs text-danger`},pU={key:1,class:`truncate font-mono text-xs text-success`},mU={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},hU={class:`space-y-2`},gU={key:0,role:`alert`,class:`text-xs text-danger`},_U={key:1,class:`text-xs text-fg-subtle`},vU={class:`flex gap-2`},yU=`__new__`,bU=A({__name:`BindEvent`,props:{yaml:{},binding:{}},emits:[`back`,`saved`],setup(e,{emit:t}){let n=e,r=t,i= Line truncated
`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(z(),K(U,{key:2},[N(B(iu),{"model-value":de(m.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>ue(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),le.value[e.key]?(z(),K(`span`,MH,H(le.value[e.key]),1)):R(``,!0)],64))]))),128)),G(`section`,NH,[n[37]||=G(`div`,{class:`text-xs font-medium text-muted-foreground`},`Flow`,-1),G(`div`,PH,[G(`label`,FH,[n[31]||=G(`span`,{class:`flex-1 text-[13px]`},`Run only when`,-1),N(B(k),{class:`h-7 w-48 font-mono text-xs`,placeholder:`always`,"model-value":i.value.when??``,"onUpdate:modelValue":n[12]||=e=>S(`when`,String(e))},null,8,[`model-value`])]),G(`label`,IH,[n[34]||=G(`span`,{class:`flex-1 text-[13px]`},`If it fails`,-1),N(B(MI),{size:`sm`,"model-value":i.value.on_failure??``,"onUpdate:modelValue":n[13]||=e=>S(`on_failure`,String(e)||void 0)},{default:M(()=>[N(B(NI),{value:``},{default:M(()=>[...n[32]||=[j(`Park the task`,-1)]]),_:1}),N(B(NI),{value:`continue`},{default:M(()=>[...n[33]||=[j(`Continue`,-1)]]),_:1})]),_:1},8,[`model-value`])]),G(`label`,LH,[n[35]||=G(`span`,{class:`flex-1 text-[13px]`},`Attempts`,-1),N(B(k),{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-7 w-20 text-right text-[13px]`,"model-value":i.value.retry?.attempts??``,"onUpdate:modelValue":n[14]||=e=>C({attempts:String(e)===``?void 0:Number(String(e))})},null,8,[`model-value`])]),G(`label`,RH,[n[36]||=G(`span`,{class:`flex-1 text-[13px]`},`Retry backoff`,-1),N(B(wh),{"model-value":i.value.retry?.backoff??``,units:[`s`,`m`,`h`],"onUpdate:modelValue":n[15]||=e=>C({backoff:e||void 0})},null,8,[`model-value`])])])])]),G(`footer`,zH,[N(B(X),{type:`button`,variant:`ghost`,size:`sm`,class:`text-danger`,onClick:n[16]||=e=>r(`remove`)},{default:M(()=>[N(B(Bn)),n[38]||=j(`Delete step`,-1)]),_:1}),N(B(X),{type:`button`,size:`sm`,class:`ml-auto`,onClick:n[17]||=e=>r(`close`)},{default:M(()=>[...n[39]||=[j(`Done`,-1)]]),_:1})])]))}}),VH=`repository_path`;function HH(e,t,n){let r=[];for(let[n,i]of e){let e=t[n];e?.from===`path`&&e.path.trim()&&r.push({name:n,path:e.path.trim(),type:i.type??`string`,required:i.required===!0})}return n.trim()&&r.push({name:VH,path:n.trim(),type:`string`,required:!0}),r}function UH(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function WH(e,t,n){let r=[];for(let[i,a]of e){let e=t[i],o=a.type??`string`;if(!(e&&(e.from===`path`?e.path.trim():e.value!==``))){a.required&&r.push(`${i} is required`);continue}if(e.from===`path`){let e=n?.failures?.find(e=>e.field_name===i);e&&r.push(`${i}: ${e.reason}`);continue}let s=UH(ob(e.value,o));o!==`any`&&s!==o&&r.push(`${i} is ${o}, but ${JSON.stringify(e.value)} is not`)}return n?.failures?.some(e=>e.field_name===`repository_path`)&&r.push(`the repository path does not resolve`),r}function GH(e,t){let n={};for(let[r,i]of e){let e=t[r];e?.from===`path`&&e.path.trim()?n[r]={param:r}:e?.from===`value`&&e.value!==``&&(n[r]={value:ob(e.value,i.type??`string`)})}return n}function KH(e,t){let n=e=>t.find(t=>t.name===e)?.path??``,r={};for(let[t,i]of Object.entries(e.inputs??{}))r[t]=i.param?{from:`path`,path:n(i.param),value:``}:{from:`value`,path:``,value:typeof i.value==`string`?i.value:JSON.stringify(i.value)};return{rows:r,repositoryPath:n(e.repo_param)}}function qH(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...qH(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...qH(n,r)]}):[]}function JH(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function YH(e){try{let t=JSON.parse(e.headers??`{}`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t)]))}catch{return{}}}function XH(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var ZH={class:`flex h-full flex-col`},QH={class:`flex items-center gap-2 border-b border-border px-4 py-3`},$H={class:`min-w-0 flex-1 truncate text-sm font-medium`},eU={key:0,class:`flex flex-1 items-center justify-center`},tU={class:`space-y-1.5`},nU={key:1,class:`space-y-1.5`},rU=[`title`],iU={class:`space-y-1.5`},aU={id:`bind-paths`},oU=[`value`],sU={class:`divide-y divide-border rounded-md border border-border`},cU={class:`flex items-center gap-1.5 text-xs`},lU={class:`font-mono`},uU={class:`text-fg-subtle`},dU={key:0,class:`text-danger`,title:`Required`},fU={key:2,class:`text-xs text-danger`},pU=[`title`],mU={key:0,class:`space-y-1 px-3 py-2`},hU={key:0,class:`text-xs text-danger`},gU={key:1,class:`truncate font-mono text-xs text-success`},_U={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},vU={class:`space-y-2`},yU={key:0,role:`alert`,class:`text-xs text-danger`},bU={key:1,class:`text-xs text-fg-subtle`},xU={class:`flex gap-2`},SU=`__new__`,CU=A({__name:`BindEvent`,props:{yaml:{},binding:{}},emits:[`back`,`saved`],setup(e,{emit:t}){let n=e,r=t,i= Line truncated
`).replace(`
`,`
+`).split(`
`).map(e=>e.trim().toLowerCase());if(i.length===1)return e.toLowerCase()===t.toLowerCase();r||n.add(e.toLowerCase());let a=i.every((e,t)=>n.has(e)&&Array.from(n.values())[t]===i[t]);return r&&n.delete(e.toLowerCase()),a}function XX(e,t){return n=>{if(!n.code&&!n.key)return!1;let r=ZX(n.code,e);return Array.isArray(e)?e.some(e=>YX(n[r],e,t,n.type===`keyup`)):YX(n[r],e,t,n.type===`keyup`)}}function ZX(e,t){return t.includes(e)?`code`:`key`}function QX(e,t){let n=L(()=>je(t?.target)??KX),r=Be(je(e)===!0),i=!1,a=new Set,o=c(je(e));I(()=>je(e),(e,t)=>{typeof t==`boolean`&&typeof e!=`boolean`&&s(),o=c(e)},{immediate:!0}),WW([`blur`,`contextmenu`],s),KW((...e)=>o(...e),e=>{let n=je(t?.actInsideInputWithModifier)??!0,a=je(t?.preventDefault)??!1;if(i=JX(e),(!i||i&&!n)&&qX(e))return;let o=e.composedPath?.call(e)?.[0]||e.target,s=o?.nodeName===`BUTTON`||o?.nodeName===`A`;!a&&(i||!s)&&e.preventDefault(),r.value=!0},{eventName:`keydown`,target:n}),KW((...e)=>o(...e),e=>{let n=je(t?.actInsideInputWithModifier)??!0;if(r.value){if((!i||i&&!n)&&qX(e))return;i=!1,r.value=!1}},{eventName:`keyup`,target:n});function s(){i=!1,a.clear(),r.value=je(e)===!0}function c(e){return e===null?(s(),()=>!1):typeof e==`boolean`?(s(),r.value=e,()=>!1):Array.isArray(e)||typeof e==`string`?XX(e,a):e}return r}var $X=`vue-flow__node-desc`,eZ=`vue-flow__edge-desc`,tZ=`vue-flow__aria-live`,nZ=[`Enter`,` `,`Escape`],rZ={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};function iZ(e){return{...e.computedPosition||{x:0,y:0},width:e.dimensions.width||0,height:e.dimensions.height||0}}function aZ(e,t){let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)}function oZ(e){return{width:e.offsetWidth,height:e.offsetHeight}}function sZ(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function cZ(e,t){return{x:sZ(e.x,t[0][0],t[1][0]),y:sZ(e.y,t[0][1],t[1][1])}}function lZ(e){let t=e.getRootNode();return`elementFromPoint`in t?t:window.document}function uZ(e){return e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e}function dZ(e){return e&&typeof e==`object`&&`id`in e&&`position`in e&&!uZ(e)}function fZ(e){return dZ(e)&&`computedPosition`in e}function pZ(e){return!Number.isNaN(e)&&Number.isFinite(e)}function mZ(e){return pZ(e.width)&&pZ(e.height)&&pZ(e.x)&&pZ(e.y)}function hZ(e,t,n){let r={id:e.id.toString(),type:e.type??`default`,dimensions:ct({width:0,height:0}),computedPosition:ct({z:0,...e.position}),handleBounds:{source:[],target:[]},draggable:void 0,selectable:void 0,connectable:void 0,focusable:void 0,selected:!1,dragging:!1,resizing:!1,initialized:!1,isParent:!1,position:{x:0,y:0},data:MQ(e.data)?e.data:{},events:ct(MQ(e.events)?e.events:{})};return Object.assign(t??r,e,{id:e.id.toString(),parentNode:n})}function gZ(e,t,n){let r={id:e.id.toString(),type:e.type??t?.type??`default`,source:e.source.toString(),target:e.target.toString(),sourceHandle:e.sourceHandle?.toString(),targetHandle:e.targetHandle?.toString(),updatable:e.updatable??n?.updatable,selectable:e.selectable??n?.selectable,focusable:e.focusable??n?.focusable,data:MQ(e.data)?e.data:{},events:ct(MQ(e.events)?e.events:{}),label:e.label??``,interactionWidth:e.interactionWidth??n?.interactionWidth,...n??{}};return Object.assign(t??r,e,{id:e.id.toString()})}function _Z(e,t,n,r){let i=typeof e==`string`?e:e.id,a=new Set,o=r===`source`?`target`:`source`;for(let e of n)e[o]===i&&a.add(e[r]);return t.filter(e=>a.has(e.id))}function vZ(...e){if(e.length===3){let[t,n,r]=e;return _Z(t,n,r,`target`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>uZ(e)&&e.source===r).map(e=>n.find(t=>dZ(t)&&t.id===e.target))}function yZ(...e){if(e.length===3){let[t,n,r]=e;return _Z(t,n,r,`source`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>uZ(e)&&e.target===r).map(e=>n.find(t=>dZ(t)&&t.id===e.source))}function bZ({source:e,sourceHandle:t,target:n,targetHandle:r}){return`vueflow__edge-${e}${t??``}-${n}${r??``}`}function xZ(e,t){return t.some(t=>uZ(t)&&t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle))}function SZ({x:e,y:t},{x:n,y:r,zoom:i}){return{x:e*i+n,y:t*i+r}}function CZ({x:e,y:t},{x:n,y:r,zoom:i},a=!1,o=[1,1]){let s={x:(e-n)/i,y:(t-r)/i};return a?hQ(s,o):s}function wZ(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function TZ({x:e,y:t,width:n,height:r}){return{x:e,y:t,x2:e+n,y2:t+r}}function EZ({x:e,y:t,x2:n,y2:r}){return{x:e,y:t,width:n-e,height:r-t}}function DZ(e){let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};for(let n=0;n<e.length;n++){let r=e[n];t=wZ(t,TZ({...r.computedPosition,...r.dimensions}))}return EZ(t)}function OZ(e,t,n={x:0,y:0,zoom:1},r=!1,i=!1){let a={...CZ(t,n),width:t.width/n.zoom,height:t.height/n.zoom},o=[];for(let t of e){let{dimensions:e,selectable:n=!0,hidden:s= Line truncated
`).map(e=>e.trim().toLowerCase());if(i.length===1)return e.toLowerCase()===t.toLowerCase();r||n.add(e.toLowerCase());let a=i.every((e,t)=>n.has(e)&&Array.from(n.values())[t]===i[t]);return r&&n.delete(e.toLowerCase()),a}function $X(e,t){return n=>{if(!n.code&&!n.key)return!1;let r=eZ(n.code,e);return Array.isArray(e)?e.some(e=>QX(n[r],e,t,n.type===`keyup`)):QX(n[r],e,t,n.type===`keyup`)}}function eZ(e,t){return t.includes(e)?`code`:`key`}function tZ(e,t){let n=L(()=>je(t?.target)??YX),r=Be(je(e)===!0),i=!1,a=new Set,o=c(je(e));I(()=>je(e),(e,t)=>{typeof t==`boolean`&&typeof e!=`boolean`&&s(),o=c(e)},{immediate:!0}),qW([`blur`,`contextmenu`],s),YW((...e)=>o(...e),e=>{let n=je(t?.actInsideInputWithModifier)??!0,a=je(t?.preventDefault)??!1;if(i=ZX(e),(!i||i&&!n)&&XX(e))return;let o=e.composedPath?.call(e)?.[0]||e.target,s=o?.nodeName===`BUTTON`||o?.nodeName===`A`;!a&&(i||!s)&&e.preventDefault(),r.value=!0},{eventName:`keydown`,target:n}),YW((...e)=>o(...e),e=>{let n=je(t?.actInsideInputWithModifier)??!0;if(r.value){if((!i||i&&!n)&&XX(e))return;i=!1,r.value=!1}},{eventName:`keyup`,target:n});function s(){i=!1,a.clear(),r.value=je(e)===!0}function c(e){return e===null?(s(),()=>!1):typeof e==`boolean`?(s(),r.value=e,()=>!1):Array.isArray(e)||typeof e==`string`?$X(e,a):e}return r}var nZ=`vue-flow__node-desc`,rZ=`vue-flow__edge-desc`,iZ=`vue-flow__aria-live`,aZ=[`Enter`,` `,`Escape`],oZ={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};function sZ(e){return{...e.computedPosition||{x:0,y:0},width:e.dimensions.width||0,height:e.dimensions.height||0}}function cZ(e,t){let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)}function lZ(e){return{width:e.offsetWidth,height:e.offsetHeight}}function uZ(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function dZ(e,t){return{x:uZ(e.x,t[0][0],t[1][0]),y:uZ(e.y,t[0][1],t[1][1])}}function fZ(e){let t=e.getRootNode();return`elementFromPoint`in t?t:window.document}function pZ(e){return e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e}function mZ(e){return e&&typeof e==`object`&&`id`in e&&`position`in e&&!pZ(e)}function hZ(e){return mZ(e)&&`computedPosition`in e}function gZ(e){return!Number.isNaN(e)&&Number.isFinite(e)}function _Z(e){return gZ(e.width)&&gZ(e.height)&&gZ(e.x)&&gZ(e.y)}function vZ(e,t,n){let r={id:e.id.toString(),type:e.type??`default`,dimensions:ct({width:0,height:0}),computedPosition:ct({z:0,...e.position}),handleBounds:{source:[],target:[]},draggable:void 0,selectable:void 0,connectable:void 0,focusable:void 0,selected:!1,dragging:!1,resizing:!1,initialized:!1,isParent:!1,position:{x:0,y:0},data:FQ(e.data)?e.data:{},events:ct(FQ(e.events)?e.events:{})};return Object.assign(t??r,e,{id:e.id.toString(),parentNode:n})}function yZ(e,t,n){let r={id:e.id.toString(),type:e.type??t?.type??`default`,source:e.source.toString(),target:e.target.toString(),sourceHandle:e.sourceHandle?.toString(),targetHandle:e.targetHandle?.toString(),updatable:e.updatable??n?.updatable,selectable:e.selectable??n?.selectable,focusable:e.focusable??n?.focusable,data:FQ(e.data)?e.data:{},events:ct(FQ(e.events)?e.events:{}),label:e.label??``,interactionWidth:e.interactionWidth??n?.interactionWidth,...n??{}};return Object.assign(t??r,e,{id:e.id.toString()})}function bZ(e,t,n,r){let i=typeof e==`string`?e:e.id,a=new Set,o=r===`source`?`target`:`source`;for(let e of n)e[o]===i&&a.add(e[r]);return t.filter(e=>a.has(e.id))}function xZ(...e){if(e.length===3){let[t,n,r]=e;return bZ(t,n,r,`target`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>pZ(e)&&e.source===r).map(e=>n.find(t=>mZ(t)&&t.id===e.target))}function SZ(...e){if(e.length===3){let[t,n,r]=e;return bZ(t,n,r,`source`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>pZ(e)&&e.target===r).map(e=>n.find(t=>mZ(t)&&t.id===e.source))}function CZ({source:e,sourceHandle:t,target:n,targetHandle:r}){return`vueflow__edge-${e}${t??``}-${n}${r??``}`}function wZ(e,t){return t.some(t=>pZ(t)&&t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle))}function TZ({x:e,y:t},{x:n,y:r,zoom:i}){return{x:e*i+n,y:t*i+r}}function EZ({x:e,y:t},{x:n,y:r,zoom:i},a=!1,o=[1,1]){let s={x:(e-n)/i,y:(t-r)/i};return a?vQ(s,o):s}function DZ(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function OZ({x:e,y:t,width:n,height:r}){return{x:e,y:t,x2:e+n,y2:t+r}}function kZ({x:e,y:t,x2:n,y2:r}){return{x:e,y:t,width:n-e,height:r-t}}function AZ(e){let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};for(let n=0;n<e.length;n++){let r=e[n];t=DZ(t,OZ({...r.computedPosition,...r.dimensions}))}return kZ(t)}function jZ(e,t,n={x:0,y:0,zoom:1},r=!1,i=!1){let a={...EZ(t,n),width:t.width/n.zoom,height:t.height/n.zoom},o=[];for(let t of e){let{dimensions:e,selectable:n=!0,hidden:s= Line truncated
Node: ${e}`,NODE_NOT_FOUND:e=>`Node not found
Node: ${e}`,NODE_MISSING_PARENT:(e,t)=>`Node is missing a parent
Node: ${e}
@@ -147,4 +147,6 @@ Edge: ${e}
Source: ${t}
Target: ${n}`,EDGE_ORPHANED:e=>`Edge was orphaned (suddenly missing source or target) and has been removed
Edge: ${e}`,EDGE_NOT_FOUND:e=>`Edge not found
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},lQ=class extends Error{constructor(e,...t){super(cQ[e]?.call(cQ,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function uQ(e){return`clientX`in e}function dQ(e){return`sourceEvent`in e}function fQ(e,t){let n=uQ(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var pQ=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function mQ(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function hQ(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var gQ=()=>!0;function _Q(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function vQ(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())aZ(i,iZ(e))>0&&r.push(e);return r}var yQ=250;function bQ(e,t,n,r){let i=[],a=1/0,o=vQ(e,n,t+yQ);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=rQ(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function xQ(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=gQ},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=fQ(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=SQ(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===VX.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=TQ(t,e,a,p,n,!0)}return b}function SQ(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function CQ(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function wQ(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function TQ(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===VX.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...rQ(o,c,c.position,!0)}:c}var EQ={[RX.Left]:RX.Right,[RX.Right]:RX.Left,[RX.Top]:RX.Bottom,[RX.Bottom]:RX.Top},DQ=[`production`,`prod`];function OQ(e,...t){kQ()&&console.warn(`[Vue Flow]: ${e}`,...t)}function kQ(){return!DQ.includes(`production`)}function AQ(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...oZ(t)}}):null}function jQ(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),ot(()=>{o.blur()})):n([e])}function MQ(e){return B(e)!==void 0}function NQ(e,t,n,r){if(!e||!e.source||!e.target)return n(new lQ(sQ.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=uZ(e)?e:{...e,id:bZ(e)},i=gZ(i,void 0,r),!xZ(i,t)&&i}function PQ(e,t,n,r,i){if(!t.source||!t.target)return i(new lQ(sQ.EDGE_INVALID,e.id)),!1;if(!n)return i(new lQ(sQ.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?bZ(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function FQ(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!dZ(o)){n(new lQ(sQ.NODE_INVALID,o?.id));continue}let s=hZ(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new lQ(sQ.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function IQ(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function LQ(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;IQ(`source`,o,`${r}-${a}--Line truncated
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},fQ=class extends Error{constructor(e,...t){super(dQ[e]?.call(dQ,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function pQ(e){return`clientX`in e}function mQ(e){return`sourceEvent`in e}function hQ(e,t){let n=pQ(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var gQ=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function _Q(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function vQ(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var yQ=()=>!0;function bQ(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function xQ(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())cZ(i,sZ(e))>0&&r.push(e);return r}var SQ=250;function CQ(e,t,n,r){let i=[],a=1/0,o=xQ(e,n,t+SQ);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=oQ(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function wQ(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=yQ},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=hQ(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=TQ(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===WX.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=OQ(t,e,a,p,n,!0)}return b}function TQ(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function EQ(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function DQ(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function OQ(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===WX.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...oQ(o,c,c.position,!0)}:c}var kQ={[VX.Left]:VX.Right,[VX.Right]:VX.Left,[VX.Top]:VX.Bottom,[VX.Bottom]:VX.Top},AQ=[`production`,`prod`];function jQ(e,...t){MQ()&&console.warn(`[Vue Flow]: ${e}`,...t)}function MQ(){return!AQ.includes(`production`)}function NQ(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...lZ(t)}}):null}function PQ(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),ot(()=>{o.blur()})):n([e])}function FQ(e){return B(e)!==void 0}function IQ(e,t,n,r){if(!e||!e.source||!e.target)return n(new fQ(uQ.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=pZ(e)?e:{...e,id:CZ(e)},i=yZ(i,void 0,r),!wZ(i,t)&&i}function LQ(e,t,n,r,i){if(!t.source||!t.target)return i(new fQ(uQ.EDGE_INVALID,e.id)),!1;if(!n)return i(new fQ(uQ.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?CZ(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function RQ(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!mZ(o)){n(new fQ(uQ.NODE_INVALID,o?.id));continue}let s=vZ(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new fQ(uQ.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function zQ(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function BQ(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;zQ(`source`,o,`${r}-${a}--Line truncated
`),r=t.split(`
`),i=Array.from({length:n.length+1},()=>Array(r.length+1).fill(0));for(let e=n.length-1;e>=0;e--)for(let t=r.length-1;t>=0;t--)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0;for(;o<n.length&&s<r.length;)n[o]===r[s]?(a.push({kind:`same`,text:n[o++]}),s++):i[o+1][s]>=i[o][s+1]?a.push({kind:`del`,text:n[o++]}):a.push({kind:`add`,text:r[s++]});for(;o<n.length;)a.push({kind:`del`,text:n[o++]});for(;s<r.length;)a.push({kind:`add`,text:r[s++]});return a}function r2(e){let t=ZB(e).toJS(),n=new Map;for(let r of jV(e).nodes){let{kind:e,path:i,stage:a,occurrence:o}=r.data;if(r.type!==`step`||e!==`step`||!i||a===void 0)continue;let s=t;for(let e of i)s=s?.[e];n.set(`${a}#${o??0}`,{node:r.id,signature:JSON.stringify(s??null)})}return n}function i2(e,t,n){let r=r2(e),i=r2(t),a={};for(let[e,t]of r){let r=i.get(e);r?r.signature!==t.signature&&(a[t.node]=`changed`):a[t.node]=n}return a}var a2={class:`grid h-[calc(100dvh-17rem)] min-h-[26rem] grid-cols-[18rem_1fr] gap-3`},o2={class:`min-h-0 divide-y divide-border overflow-y-auto rounded-lg border border-border`,"aria-label":`Revisions`},s2=[`aria-current`,`onClick`],c2={class:`flex items-center gap-2 text-sm`},l2={class:`font-mono text-xs text-fg-subtle`},u2=[`title`],d2={key:0,class:`px-3 py-2 text-sm text-muted-foreground`},f2={key:0,class:`flex min-h-0 flex-col gap-2`},p2={class:`flex items-center gap-2`},m2={class:`text-xs text-muted-foreground`},h2={key:0,class:`rounded-lg border border-border p-4 text-sm text-muted-foreground`},g2={key:1,class:`min-h-0 flex-1 overflow-auto rounded-lg border border-border py-2 font-mono text-[13px] leading-6`},_2={class:`inline-block w-4 select-none text-fg-subtle`},v2={key:2,class:`grid min-h-0 flex-1 grid-cols-2 gap-3`},y2={class:`flex min-h-0 flex-col gap-1`},b2={class:`text-xs font-medium text-muted-foreground`},x2={class:`min-h-0 flex-1`},S2={class:`flex min-h-0 flex-col gap-1`},C2={class:`min-h-0 flex-1`},w2=A({__name:`WorkflowHistory`,props:rt({revisions:{},current:{},error:{}},{selected:{default:0},selectedModifiers:{},mode:{default:`yaml`},modeModifiers:{}}),emits:rt([`restore`],[`update:selected`,`update:mode`]),setup(e,{emit:t}){let n=e,r=t,i=Pe(e,`selected`),a=Pe(e,`mode`);I(()=>n.revisions,e=>{e.some(e=>e.version===i.value)||(i.value=(e.find(e=>e.yaml!==n.current)??e[0])?.version??0)},{immediate:!0});let o=L(()=>n.revisions.find(e=>e.version===i.value)),s=L(()=>o.value?.yaml??null),c=L(()=>s.value===null?[]:n2(s.value,n.current)),l=L(()=>s.value!==null&&s.value===n.current),u=L(()=>s.value===null?{}:i2(s.value,n.current,`removed`)),d=L(()=>s.value===null?{}:i2(n.current,s.value,`added`)),f={added:`default`,edited:`secondary`,removed:`destructive`};return(t,n)=>(z(),K(`div`,a2,[G(`ol`,o2,[(z(!0),K(U,null,q(e.revisions,e=>(z(),K(`li`,{key:e.version},[G(`button`,{type:`button`,class:P([`block w-full px-3 py-2 text-left hover:bg-secondary`,e.version===i.value&&`bg-secondary`]),"aria-current":e.version===i.value,onClick:t=>i.value=e.version},[G(`span`,c2,[G(`span`,l2,`v`+H(e.version),1),N(B(kt),{variant:f[e.change]},{default:M(()=>[j(H(e.change),1)]),_:2},1032,[`variant`])]),G(`span`,{class:`mt-0.5 block truncate text-xs text-muted-foreground`,title:e.at},H(e.actor||`unknown`)+` · `+H(e.source||`unknown`)+` · `+H(B(Dg)(e.at)),9,u2)],10,s2)]))),128)),e.revisions.length?R(``,!0):(z(),K(`li`,d2,H(e.error||`No recorded changes`),1))]),o.value?(z(),K(`div`,f2,[G(`div`,p2,[N(B(Wy),{modelValue:a.value,"onUpdate:modelValue":n[0]||=e=>a.value=e},{default:M(()=>[N(B(Ky),null,{default:M(()=>[N(B(qy),{value:`yaml`},{default:M(()=>[...n[2]||=[j(`YAML`,-1)]]),_:1}),N(B(qy),{value:`canvas`},{default:M(()=>[...n[3]||=[j(`Canvas`,-1)]]),_:1})]),_:1})]),_:1},8,[`modelValue`]),G(`span`,m2,H(l.value?`Same as the current definition`:`Compared with the current definition`),1),N(B(X),{type:`button`,size:`sm`,variant:`outline`,class:`ml-auto`,disabled:s.value===null||l.value,title:s.value===null?`This revision removed the workflow`:void 0,onClick:n[1]||=e=>r(`restore`,s.value)},{default:M(()=>[N(B(An),{"data-icon":`inline-start`}),n[4]||=j(` Restore this version`,-1)]),_:1},8,[`disabled`,`title`])]),s.value===null?(z(),K(`p`,h2,`This revision removed the workflow.`)):a.value===`yaml`?(z(),K(`pre`,g2,[G(`code`,null,[(z(!0),K(U,null,q(c.value,(e,t)=>(z(),K(`span`,{key:t,class:P([`block min-h-6 px-3 whitespace-pre-wrap`,{"bg-ok/10":e.kind===`add`,"bg-danger/10 text-danger":e.kind===`del`}])},[G(`span`,_2,H(e.kind===`add`?`+`:e.kind===`del`?`-`:``),1),j(H(e.text),1)],2))),128))])])):(z(),K(`div`,v2,[G(`div`,y2,[G(`span`,b2,`v`+H(o.value.version),1),G(`div`,x2,[N(Q0,{yaml:s.value,marks:u.value},null,8,[`yaml`,`marks`])])]),G(`div`,S2,[n[5]||=G(`span`,{class:`text-xs font-medium text-muted-foreground`},`Current`,-1),G(`div`,C2,[N(Q0,{yaml:e.current,marks:d.value},null,8,[`yaml`,`marks`])])])]))])):R(``,!0)]))}}),T2=`workflow-definitions`;function E2(e){let t=pe(),n=Y([]),r=Y(``);async function i(){try{n.value=await t.hist Line truncated
+6 -2
View File
@@ -27,7 +27,10 @@ import {
} from "@/workflows/work-request";
/** Starting work enters Archie's normal admitted task queue, not a side door. */
const props = defineProps<{ /** Starts this workflow, with no chooser. */ workflow?: string }>();
const props = defineProps<{
/** Starts this workflow, with no chooser. */ workflow?: string;
/** An unsaved definition of `workflow` to test-run instead of the stored one. */ draft?: string;
}>();
const emit = defineEmits<{ started: [taskId: number]; cancel: [] }>();
const uid = useId();
@@ -97,6 +100,7 @@ async function submit() {
title: title.value.trim(),
instructions: instructions.value,
inputs: inputValues(declared.value, inputText.value),
...(props.draft ? { draft: props.draft } : {}),
});
emit("started", result.task_id);
} catch (err) {
@@ -201,7 +205,7 @@ async function submit() {
<div class="flex items-center gap-2 border-t border-border pt-4">
<span class="mr-auto text-xs text-fg-subtle"><Kbd>⌘</Kbd> <Kbd>↵</Kbd> to start</span>
<Button type="button" variant="ghost" @click="emit('cancel')">Cancel</Button>
<Button type="submit" :disabled="!ready || submitting"><Spinner v-if="submitting" data-icon="inline-start" />Start task</Button>
<Button type="submit" :disabled="!ready || submitting"><Spinner v-if="submitting" data-icon="inline-start" />{{ props.draft ? "Start test" : "Start task" }}</Button>
</div>
</form>
</template>
+5 -2
View File
@@ -19,6 +19,8 @@ export interface Task {
park_reason?: string;
tokens_used?: number;
workflow?: string;
/** The exact definition the run pinned. */
workflow_definition_yaml?: string;
attempt?: number;
/** The branch this task pushed, if any. A retry that continues pushed work
* resumes it; the retry dialog disables that mode when it is empty. */
@@ -91,7 +93,7 @@ const title = computed(() => props.task.title || "untitled task");
// Chat-sourced work has no forge issue behind it, so there is no page to open
// and the number stands on its own.
const issueHref = computed(() => {
if (props.task.source === "chat") return "";
if (props.task.source === "chat" || props.task.source === "test") return "";
if (!props.task.issue_url || !props.task.issue_number) return "";
return props.task.issue_url;
});
@@ -144,7 +146,7 @@ function open() {
@keydown.stop
>#{{ props.task.issue_number }}</a
>
<template v-else-if="props.task.source !== 'chat'">#{{ props.task.issue_number }}</template>
<template v-else-if="props.task.source !== 'chat' && props.task.source !== 'test'">#{{ props.task.issue_number }}</template>
</TableCell>
<!--
The floor belongs on the link, not the cell: a table cell ignores
@@ -161,6 +163,7 @@ function open() {
>
{{ title }}
</RouterLink>
<Badge v-if="props.task.source === 'test'" variant="outline" class="ml-2" title="Ran an unsaved draft; forge writes were skipped">Test</Badge>
</TableCell>
<TableCell>
<span class="inline-flex items-center gap-1">
+1 -1
View File
@@ -167,7 +167,7 @@ function forgeLink(id: string): string {
return props.task.pr_url && props.task.pr_number ? props.task.pr_url : "";
}
if (id === "open_issue") {
if (props.task.source === "chat" || !props.task.issue_number) return "";
if (props.task.source === "chat" || props.task.source === "test" || !props.task.issue_number) return "";
return props.task.issue_url ?? "";
}
return "";
+1 -1
View File
@@ -88,7 +88,7 @@ const showRepo = computed(() => {
// Chat tasks carry a placeholder issue number, so the column goes when no
// visible row names a real issue.
const showIssue = computed(() =>
visible.value.some((task) => task.source !== "chat" && task.issue_number),
visible.value.some((task) => task.source !== "chat" && task.source !== "test" && task.issue_number),
);
const state = computed<"loading" | "error" | "empty" | "no-match">(() => {
+17 -6
View File
@@ -1,12 +1,17 @@
<script setup lang="ts">
import { ref } from "vue";
import { Play } from "@lucide/vue";
import { FlaskConical, Play } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import NewTaskForm from "@/tasks/NewTaskForm.vue";
defineProps<{ workflow: string; disabled?: boolean }>();
defineProps<{
workflow: string;
disabled?: boolean;
/** The unsaved definition to test-run; absent runs the stored one. */
draft?: string;
}>();
const emit = defineEmits<{ started: [taskId: number] }>();
const open = ref(false);
@@ -19,14 +24,20 @@ function started(taskId: number): void {
<template>
<Dialog v-model:open="open">
<DialogTrigger as-child>
<Button type="button" size="sm" variant="outline" :disabled="disabled" :title="disabled ? 'Save your changes first' : undefined">
<Play data-icon="inline-start" /> Run</Button>
<Button
type="button"
size="sm"
variant="outline"
:disabled="disabled"
:title="draft !== undefined ? 'Run this draft once without touching the forge' : disabled ? 'Save your changes first' : undefined"
>
<component :is="draft !== undefined ? FlaskConical : Play" data-icon="inline-start" /> {{ draft !== undefined ? "Test" : "Run" }}</Button>
</DialogTrigger>
<DialogContent class="sm:max-w-[640px]">
<DialogHeader>
<DialogTitle>Run {{ workflow }}</DialogTitle>
<DialogTitle>{{ draft !== undefined ? "Test" : "Run" }} {{ workflow }}</DialogTitle>
</DialogHeader>
<NewTaskForm v-if="open" :workflow="workflow" @started="started" @cancel="open = false" />
<NewTaskForm v-if="open" :workflow="workflow" :draft="draft" @started="started" @cancel="open = false" />
</DialogContent>
</Dialog>
</template>
+8
View File
@@ -16,8 +16,15 @@ const STATE_CLASSES: Record<string, string> = {
skipped: "border-dashed border-muted-foreground/60",
};
const MARK_CLASSES: Record<string, string> = {
added: "border-ok ring-2 ring-ok/40",
removed: "border-danger ring-2 ring-danger/40",
changed: "border-warn ring-2 ring-warn/40",
};
const stateClass = computed(() => {
if (props.data.kind === "start") return "border-primary/60";
if (props.data.mark) return MARK_CLASSES[props.data.mark];
return STATE_CLASSES[props.data.run?.status ?? ""] ?? "border-border";
});
@@ -58,6 +65,7 @@ function duration(ms?: number): string {
<span v-if="data.step" class="font-mono text-[11px] text-fg-subtle">{{ data.step }}</span>
<span class="truncate text-sm font-medium" :title="data.title">{{ data.title }}</span>
</div>
<div v-if="data.mark" class="text-[11px] font-medium" :class="{ 'text-ok': data.mark === 'added', 'text-danger': data.mark === 'removed', 'text-warn': data.mark === 'changed' }">{{ data.mark === "added" ? "Added" : data.mark === "removed" ? "Removed" : "Changed" }}</div>
<div v-if="data.type && data.title !== stepTitle(data.type)" class="truncate font-mono text-[11px] text-fg-subtle">{{ data.type }}</div>
<ul v-if="data.kind === 'start' && data.triggers?.length" class="mt-1 space-y-0.5">
<li v-for="trigger in data.triggers" :key="trigger.kind + trigger.label" class="flex items-center gap-1.5 text-xs" :title="trigger.detail">
+7
View File
@@ -81,6 +81,7 @@ const activity = computed(() => events.value.filter((event) => {
if (event.data?.step_id != null) return Number(event.data.step_id) === props.stage.id;
return names.value.has(event.stage ?? "") && inWindow(event.at);
}).sort((a, b) => String(a.at ?? "").localeCompare(String(b.at ?? ""))));
const suppressed = computed(() => activity.value.filter((event) => event.kind === "forge_suppressed"));
const groups = computed(() => {
const agents = props.stage.agents ?? [];
const branches = new Set(["", ...agents.map((agent) => agent.name.includes("/") ? agent.name.split("/")[0]! : ""), ...activity.value.map((event) => String(event.data?.branch ?? ""))]);
@@ -128,6 +129,12 @@ const scopedLogs = computed(() => logs.value ? { ...logs.value, entries: (logs.v
<p v-if="group.reports.length" class="text-xs text-muted-foreground">{{ group.reports.map((report) => describeTimelineEvent(report).detail).filter(Boolean).join(' · ') }}</p>
<p v-else-if="group.agents.length" class="text-xs text-muted-foreground">{{ group.agents.reduce((sum, agent) => sum + agent.tokens_used, 0).toLocaleString() }} tokens recorded</p>
</section>
<section v-if="suppressed.length" class="space-y-1">
<h3 class="text-xs font-medium text-muted-foreground" title="This was a test run, so these writes were skipped">Skipped in test run</h3>
<ul class="divide-y divide-border rounded-md border border-border">
<li v-for="(event, i) in suppressed" :key="i" class="px-3 py-2 text-xs break-words whitespace-pre-wrap">{{ event.detail }}</li>
</ul>
</section>
<section class="space-y-3">
<h3 class="text-xs font-medium text-muted-foreground">Captured changes</h3>
<p v-if="changesError" role="alert" class="text-danger">{{ changesError }}</p>
+6 -1
View File
@@ -36,6 +36,8 @@ const props = defineProps<{
types?: string[];
/** The watched run is parked, so its steps offer to restart it. */
restartable?: boolean;
/** Steps that differ from the definition being compared, by node id. */
marks?: Record<string, "added" | "removed" | "changed">;
}>();
const emit = defineEmits<{
edit: [StepPath];
@@ -66,6 +68,8 @@ const nodes = computed(() =>
const drop = Math.max(0, (props.triggers?.length ?? 0) - 2) * 18;
if (drop) node = { ...node, position: { ...node.position, y: node.position.y + drop } };
if (node.type === "lane") return node;
const mark = props.marks?.[node.id];
if (mark) node = { ...node, data: { ...node.data, mark } };
return JSON.stringify(node.data.path ?? null) === selectedKey.value && props.selected
? { ...node, data: { ...node.data, selected: true } }
: node;
@@ -113,13 +117,14 @@ function place(store?: VueFlowStore): void {
const width = container.value?.clientWidth ?? 800;
const height = container.value?.clientHeight ?? 560;
// Scroll only when the furthest step reached would be out of view.
const reached = graph.value.nodes.filter((node) => node.data.run).at(-1);
const reached = graph.value.nodes.find((node) => props.marks?.[node.id]) ?? graph.value.nodes.filter((node) => node.data.run).at(-1);
const below = reached && 24 + (reached.position.y + 180) * ZOOM > height;
const y = below ? height / 3 - reached.position.y * ZOOM : 24;
void flow.setViewport({ x: width / 2 - NODE_WIDTH / 2, y, zoom: ZOOM }, { duration: animate ? 300 : 0 });
}
watch(() => graph.value.nodes.filter((node) => node.data.run).length, () => place());
watch(() => props.marks, () => place());
// The right-click menu opens at the pointer, for the step under it or for the
// canvas itself.
+29 -1
View File
@@ -32,6 +32,9 @@ import WorkflowSettings from "./WorkflowSettings.vue";
import RunWorkflowButton from "./RunWorkflowButton.vue";
import TaskRowActions from "@/tasks/TaskRowActions.vue";
import WorkflowCanvas from "./WorkflowCanvas.vue";
import WorkflowHistory from "./WorkflowHistory.vue";
import { useWorkflowHistory } from "./workflow-history";
import { revisionOfRun, type WorkflowRevision } from "./workflow-revisions";
import { deleteStep, duplicateStep, insertStep, moveStep, type StepPath } from "./workflow-edit";
import { useWorkflowRuns } from "./workflow-runs";
import { useWorkflowTriggers } from "./workflow-triggers";
@@ -102,6 +105,25 @@ async function restartFrom(from: string): Promise<void> {
}
const { triggers, reload: reloadTriggers } = useWorkflowTriggers(selected);
const { revisions, error: historyError } = useWorkflowHistory(selected);
const historyRevision = ref(0);
const historyMode = ref("yaml");
// The revision a run used, matched by the definition it pinned.
function runRevision(run?: { workflow_definition_yaml?: string; created_at?: string }): WorkflowRevision | undefined {
return run ? revisionOfRun(revisions.value, run.workflow_definition_yaml, run.created_at) : undefined;
}
const watchedRevision = computed(() => runRevision(watchedRun.value));
function openRevision(version: number): void {
historyRevision.value = version;
view.value = "history";
}
// A restored version is an unsaved edit: nothing is written until Save.
function restoreRevision(restored: string): void {
yaml.value = restored;
selectedStep.value = null;
view.value = "canvas";
}
// Canvas edits are edits to the YAML; a newly placed step opens for editing.
const stepTypeNames = computed(() => vocabulary.value.map((info) => info.name));
function insertAt(after: StepPath, type: string): void {
@@ -225,6 +247,7 @@ function syncScroll(event: Event): void {
<TabsList>
<TabsTrigger value="canvas">Canvas</TabsTrigger>
<TabsTrigger value="yaml">YAML</TabsTrigger>
<TabsTrigger v-if="stored !== undefined" value="history">History</TabsTrigger>
<TabsTrigger v-if="$slots.performance" value="performance">Performance</TabsTrigger>
<TabsTrigger v-if="$slots.runs" value="runs">Runs <span class="ml-1 font-mono text-xs text-fg-subtle">{{ runsCount ?? 0 }}</span></TabsTrigger>
</TabsList>
@@ -238,11 +261,12 @@ function syncScroll(event: Event): void {
>
<NativeSelectOption value="">Definition only</NativeSelectOption>
<NativeSelectOption v-for="run in runs" :key="run.id" :value="String(run.id)">{{
[`Run #${run.id}`, run.title, run.status].filter(Boolean).join(" · ")
[`${run.source === "test" ? "Test" : "Run"} #${run.id}`, run.title, run.status, runRevision(run) ? `v${runRevision(run)!.version}` : ""].filter(Boolean).join(" · ")
}}</NativeSelectOption>
</NativeSelect>
<template v-if="watchedRun">
<RouterLink :to="`/tasks/${watchedRun.id}`" class="shrink-0 px-1 text-xs text-muted-foreground hover:text-foreground hover:underline">Open</RouterLink>
<button v-if="watchedRevision" type="button" class="shrink-0 px-1 font-mono text-xs text-muted-foreground hover:text-foreground hover:underline" title="Open the version this run used" @click="openRevision(watchedRevision.version)">v{{ watchedRevision.version }}</button>
<TaskRowActions :task="watchedRun" class="shrink-0" @done="refresh" />
</template>
</div>
@@ -263,6 +287,7 @@ function syncScroll(event: Event): void {
<DropdownMenuItem variant="destructive" @select="confirmDelete = true"><Trash2 />Delete workflow</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<RunWorkflowButton v-if="stored !== undefined" :workflow="selected" :draft="yaml" :disabled="!parsed.ok" @started="(id) => { view = 'canvas'; void follow(id); }" />
<RunWorkflowButton v-if="stored !== undefined" :workflow="selected" :disabled="dirty" @started="(id) => { view = 'canvas'; void follow(id); }" />
<Button type="submit" size="sm" :disabled="state.saving || !parsed.ok || !dirty">
<Spinner v-if="state.saving" data-icon="inline-start" />Save</Button>
@@ -332,6 +357,9 @@ function syncScroll(event: Event): void {
</Transition>
</div>
</TabsContent>
<TabsContent value="history">
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" @restore="restoreRevision" />
</TabsContent>
<TabsContent value="performance" class="grid gap-4"><slot name="performance" /></TabsContent>
<TabsContent value="runs"><slot name="runs" /></TabsContent>
<TabsContent value="yaml">
+82
View File
@@ -0,0 +1,82 @@
<script setup lang="ts">
import { computed, watch } from "vue";
import { RotateCcw } from "@lucide/vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { ago } from "@/lib/format";
import WorkflowCanvas from "./WorkflowCanvas.vue";
import { lineDiff, stepMarks, type WorkflowRevision } from "./workflow-revisions";
const props = defineProps<{ revisions: WorkflowRevision[]; current: string; error?: string }>();
const emit = defineEmits<{ restore: [yaml: string] }>();
const selected = defineModel<number>("selected", { default: 0 });
const mode = defineModel<string>("mode", { default: "yaml" });
watch(
() => props.revisions,
(revisions) => {
if (revisions.some((revision) => revision.version === selected.value)) return;
// Open on the newest version that differs from what is open now.
selected.value = (revisions.find((revision) => revision.yaml !== props.current) ?? revisions[0])?.version ?? 0;
},
{ immediate: true },
);
const revision = computed(() => props.revisions.find((candidate) => candidate.version === selected.value));
const then = computed(() => revision.value?.yaml ?? null);
const diff = computed(() => (then.value === null ? [] : lineDiff(then.value, props.current)));
const identical = computed(() => then.value !== null && then.value === props.current);
const thenMarks = computed(() => (then.value === null ? {} : stepMarks(then.value, props.current, "removed")));
const nowMarks = computed(() => (then.value === null ? {} : stepMarks(props.current, then.value, "added")));
const CHANGE_VARIANTS = { added: "default", edited: "secondary", removed: "destructive" } as const;
</script>
<template>
<div class="grid h-[calc(100dvh-17rem)] min-h-[26rem] grid-cols-[18rem_1fr] gap-3">
<ol class="min-h-0 divide-y divide-border overflow-y-auto rounded-lg border border-border" aria-label="Revisions">
<li v-for="item in revisions" :key="item.version">
<button
type="button"
class="block w-full px-3 py-2 text-left hover:bg-secondary"
:class="item.version === selected && 'bg-secondary'"
:aria-current="item.version === selected"
@click="selected = item.version"
>
<span class="flex items-center gap-2 text-sm">
<span class="font-mono text-xs text-fg-subtle">v{{ item.version }}</span>
<Badge :variant="CHANGE_VARIANTS[item.change]">{{ item.change }}</Badge>
</span>
<span class="mt-0.5 block truncate text-xs text-muted-foreground" :title="item.at">{{ item.actor || "unknown" }} · {{ item.source || "unknown" }} · {{ ago(item.at) }}</span>
</button>
</li>
<li v-if="!revisions.length" class="px-3 py-2 text-sm text-muted-foreground">{{ error || "No recorded changes" }}</li>
</ol>
<div v-if="revision" class="flex min-h-0 flex-col gap-2">
<div class="flex items-center gap-2">
<Tabs v-model="mode"><TabsList><TabsTrigger value="yaml">YAML</TabsTrigger><TabsTrigger value="canvas">Canvas</TabsTrigger></TabsList></Tabs>
<span class="text-xs text-muted-foreground">{{ identical ? "Same as the current definition" : "Compared with the current definition" }}</span>
<Button type="button" size="sm" variant="outline" class="ml-auto" :disabled="then === null || identical" :title="then === null ? 'This revision removed the workflow' : undefined" @click="emit('restore', then!)">
<RotateCcw data-icon="inline-start" /> Restore this version</Button>
</div>
<p v-if="then === null" class="rounded-lg border border-border p-4 text-sm text-muted-foreground">This revision removed the workflow.</p>
<pre v-else-if="mode === 'yaml'" class="min-h-0 flex-1 overflow-auto rounded-lg border border-border py-2 font-mono text-[13px] leading-6"><code><span
v-for="(line, i) in diff"
:key="i"
class="block min-h-6 px-3 whitespace-pre-wrap"
:class="{ 'bg-ok/10': line.kind === 'add', 'bg-danger/10 text-danger': line.kind === 'del' }"
><span class="inline-block w-4 select-none text-fg-subtle">{{ line.kind === "add" ? "+" : line.kind === "del" ? "-" : "" }}</span>{{ line.text }}</span></code></pre>
<div v-else class="grid min-h-0 flex-1 grid-cols-2 gap-3">
<div class="flex min-h-0 flex-col gap-1">
<span class="text-xs font-medium text-muted-foreground">v{{ revision.version }}</span>
<div class="min-h-0 flex-1"><WorkflowCanvas :yaml="then" :marks="thenMarks" /></div>
</div>
<div class="flex min-h-0 flex-col gap-1">
<span class="text-xs font-medium text-muted-foreground">Current</span>
<div class="min-h-0 flex-1"><WorkflowCanvas :yaml="current" :marks="nowMarks" /></div>
</div>
</div>
</div>
</div>
</template>
+2
View File
@@ -38,6 +38,8 @@ export interface StepNodeData {
* names the parallel step it belongs to here. */
resume?: string;
run?: StageRun;
/** How the step differs from the definition it is compared with. */
mark?: "added" | "removed" | "changed";
/** Where the step lives in the YAML document, for editing it. */
path?: (string | number)[];
selected?: boolean;
+26
View File
@@ -0,0 +1,26 @@
import { computed, ref, watch, type Ref } from "vue";
import { useSettingsStore, type ResourceRevision } from "@/stores/settings";
import { workflowRevisions } from "./workflow-revisions";
const KIND = "workflow-definitions";
/** The history of workflow `id`, kept current as the definitions change. */
export function useWorkflowHistory(id: Ref<string>) {
const store = useSettingsStore();
const all = ref<ResourceRevision[]>([]);
const error = ref("");
async function reload(): Promise<void> {
try {
all.value = await store.history(KIND);
error.value = "";
} catch (err) {
error.value = err instanceof Error ? err.message : "Could not load history";
}
}
watch(() => store.stateFor(KIND).resource?.version, () => void reload(), { immediate: true });
const revisions = computed(() => workflowRevisions(id.value, all.value));
return { revisions, error, reload };
}
+115
View File
@@ -0,0 +1,115 @@
import { parseDocument } from "yaml";
import type { ResourceRevision } from "../stores/settings.ts";
import { workflowGraph } from "./workflow-graph.ts";
/** One revision of the definitions that changed a single workflow. */
export interface WorkflowRevision {
version: number;
change: "added" | "edited" | "removed";
/** The workflow's YAML at this revision; null when the revision removed it. */
yaml: string | null;
actor: string;
source: string;
at?: string;
}
function entryYaml(value: unknown, id: string): string | null {
const definitions = (value as { definitions?: { id: string; yaml: string }[] } | null)?.definitions;
return definitions?.find((entry) => entry.id === id)?.yaml ?? null;
}
/**
* The revisions in which workflow `id` was added, edited or removed, newest
* first. All workflows share one resource, so a revision that left this one's
* YAML as it was is not part of its history.
*/
export function workflowRevisions(id: string, revisions: ResourceRevision[]): WorkflowRevision[] {
const changes: WorkflowRevision[] = [];
let previous: string | null = null;
for (const revision of [...revisions].sort((a, b) => a.version - b.version)) {
const yaml = entryYaml(revision.value, id);
if (yaml !== previous) {
changes.push({
version: revision.version,
change: yaml === null ? "removed" : previous === null ? "added" : "edited",
yaml,
actor: revision.actor,
source: revision.source,
at: revision.at,
});
}
previous = yaml;
}
return changes.reverse();
}
/**
* The revision a run used: the newest one holding the YAML the run pinned that
* was already in place when the run was created. A test run pins a draft that
* no revision holds.
*/
export function revisionOfRun(revisions: WorkflowRevision[], pinned?: string, createdAt?: string): WorkflowRevision | undefined {
if (!pinned) return undefined;
const matches = revisions.filter((revision) => revision.yaml === pinned);
const created = createdAt ? Date.parse(createdAt) : NaN;
return matches.find((revision) => !revision.at || Number.isNaN(created) || Date.parse(revision.at) <= created) ?? matches.at(-1);
}
export interface DiffLine {
kind: "same" | "add" | "del";
text: string;
}
/** A line diff from `before` to `after`: `del` lines are only in `before`. */
export function lineDiff(before: string, after: string): DiffLine[] {
const a = before.split("\n");
const b = after.split("\n");
const lcs: number[][] = Array.from({ length: a.length + 1 }, () => new Array<number>(b.length + 1).fill(0));
for (let i = a.length - 1; i >= 0; i--)
for (let j = b.length - 1; j >= 0; j--)
lcs[i]![j] = a[i] === b[j] ? lcs[i + 1]![j + 1]! + 1 : Math.max(lcs[i + 1]![j]!, lcs[i]![j + 1]!);
const out: DiffLine[] = [];
let i = 0;
let j = 0;
while (i < a.length && j < b.length) {
if (a[i] === b[j]) out.push({ kind: "same", text: a[i++]! }), j++;
else if (lcs[i + 1]![j]! >= lcs[i]![j + 1]!) out.push({ kind: "del", text: a[i++]! });
else out.push({ kind: "add", text: b[j++]! });
}
while (i < a.length) out.push({ kind: "del", text: a[i++]! });
while (j < b.length) out.push({ kind: "add", text: b[j++]! });
return out;
}
export type Mark = "added" | "removed" | "changed";
function stepsOf(source: string): Map<string, { node: string; signature: string }> {
const value: unknown = parseDocument(source).toJS();
const steps = new Map<string, { node: string; signature: string }>();
for (const node of workflowGraph(source).nodes) {
const { kind, path, stage, occurrence } = node.data;
if (node.type !== "step" || kind !== "step" || !path || stage === undefined) continue;
let at: unknown = value;
for (const part of path) at = (at as Record<string | number, unknown> | undefined)?.[part];
steps.set(`${stage}#${occurrence ?? 0}`, { node: node.id, signature: JSON.stringify(at ?? null) });
}
return steps;
}
/**
* Marks the steps of `source` that differ from `other`, by canvas node id. A
* step `other` lacks is marked `missing`: "removed" when `source` is the older
* definition, "added" when it is the newer.
*/
export function stepMarks(source: string, other: string, missing: "added" | "removed"): Record<string, Mark> {
const here = stepsOf(source);
const there = stepsOf(other);
const marks: Record<string, Mark> = {};
for (const [identity, step] of here) {
const counterpart = there.get(identity);
if (!counterpart) marks[step.node] = missing;
else if (counterpart.signature !== step.signature) marks[step.node] = "changed";
}
return marks;
}