even-keel 0.3.0-rc.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,30 +4,90 @@ All notable changes to Even Keel are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [Unreleased]
7
+ ## [0.3.0] - 2026-11-16
8
+
9
+ 0.3 needs neither a tracker account nor git to start: a built-in tracker, projects without git, a demo on the first start and a project wizard that clones or creates the repository. Sessions get Even Keel's own tasks server for every tracker, Forgejo issues join the trackers, Claude Code runs on Amazon Bedrock, Google Vertex AI and Microsoft Foundry, and OpenCode on an OpenRouter key. The page gains an event log, a chat window per task and a README badge of the chain.
10
+
11
+ ### Added
12
+
13
+ - **A built-in tracker.** Tasks are kept in Even Keel's own database, with no account or token; it is the first choice of the tracker in the setup and the project wizard. A task's card edits it in place: title, description (a Preview and a Markdown editor), status, labels, milestone, links, parent and subtasks, deletion. An edit is saved when you leave the field and kept as a browser draft until it lands; an edit that crossed another opens a window with the difference. Screenshots and files pasted or dropped into a description become attachments the session gets. The card's journal keeps the agents' reports with their model, the sessions' questions, your answers and your notes. A ghost row at the end of each chain group and on top of the backlog adds a task.
14
+ - **Moving a built-in project to a real tracker.** **Move to another tracker** in the project's Tracker settings says what the tracker cannot hold, copies the open tasks with their statuses, parents, links, attachments and journal, and goes on after a refusal or a restart. **Switch** then moves the project there in the same chain order; the old tasks are marked with the key they moved to, and `/stats` counts their sessions under the new keys.
15
+ - **Projects without git.** A project can be a plain folder: its tasks share it, write their files there and close when the session ends its answer with the `TASK DONE` mark. Sessions are refused git there, each task gets its own handoff note, and a session still idle in the folder is stopped before the next task starts. The setup's Git step first asks **Use git?**, and the answer is the default of new projects. **Turn on git** on the Repository tab makes the folder a repository with the work so far in its first commit; a folder that became a repository by itself gets a band offering it.
16
+ - **A demo on the first start.** With no project yet, **Watch the demo** takes a small project on the built-in tracker through three tasks in about two minutes: one waits for another, one asks you a question in the chat. The agent is a script, so no account is used and nothing is spent. It runs with or without git, as the setup's Git step answered and git is there, and stays out of the statistics; the project wizard's **Remove the demo** removes it once your project is added.
17
+ - **The project wizard clones or creates the repository.** One field, **Folder or repository address**, takes an address to clone (the remote is asked at once and its branches are offered), a checkout already on the machine, a folder without git to make a repository of, a path that is not there yet, or a bare name for a new folder in Even Keel's projects folder. **Add project** opens a window with each step's progress: the clone with its percent and Git LFS files, the first commit, the project, Claude Code's trust and the packages, with **Retry** and with **Cancel**, which removes only what Even Keel made. A refused sign-in, an unknown SSH host key or a cut network is one line saying what to do; a missing name and e-mail for commits gets **Set them**, which asks for both over the page.
18
+ - **Even Keel's own tasks server** (`tasks@even-keel`) for every tracker: Huly, GitHub, Linear, Jira, GitLab, Forgejo, the built-in one and a project's feeds. Its five tools read and write tasks with links, parents, labels, milestones, estimates, components and attachments; nothing can be deleted through them. `task_read` downloads a task's files into `.temp/task-files`, `task_update` changes several tasks in one call, and a create cut off by a crash is found again by its marker instead of filed twice. A project you add gets the package on; the page warns when the tracker's own MCP server is on beside it. A session you start by hand gets the same tools through the `tasks` plugin.
19
+ - **Forgejo, Gitea and Codeberg issues as a tracker**, with the `forgejo` plugin and its `forgejo:task` skill: labels, milestones and blocking links come from the repository. On an organization's repository a token without `read:organization` still reads the tasks, and the project page says what sessions lose and which scope to add; a token without the issue scope is named as such, not as revoked.
20
+ - **Claude Code on Amazon Bedrock, Google Vertex AI and Microsoft Foundry.** **Add account** → **Cloud** takes the cloud's credentials (a profile, a key, or the environment of the user Even Keel runs as); the account runs through the Agent SDK and shows its spend and region.
21
+ - **OpenCode on an OpenRouter key**, with any of OpenRouter's models in a task's run. The account row shows the key's real spend, what is left of the key's own limit and the account's balance; `/stats` counts a session's real spend, with the estimate by price in a tip.
22
+ - **More limits are read:** OpenCode Go's subscription limits and Copilot's AI credits on their account rows, and a model's own week (Fable on Max, Ultra and Team) beside the account's. When that week is spent, the next task on its model waits for it to open while a task on another model goes on.
23
+ - **The event log**, **Log** in the header: launches, stops, settings changes, questions, limits, a red main, carry conflicts, a paused chain, package problems and moves between trackers, kept for 3000 entries and filtered by level, category and project. A new event shows as a toast for 12 seconds in sight, with a bar of the time left and a pause under the pointer, and the header counts the unread ones.
24
+ - **A chat window per task.** It has the task's head, a status line with the context ring and the model and effort of the last answer, a slash button and a panel with the description, attachments and comments; it outlives a handoff and Done and keeps a draft per task. **Accept as answer** closes a task with its session's last message. A reply to a session whose cache went cold first asks whether to start a new session with it, send it anyway or cancel. A session whose turn has ended while its background command runs says so instead of "working".
25
+ - **A README badge of a project's chain**: an SVG of what runs, what is done and the milestone's progress, pushed to a Cloudflare Worker you deploy from the `even-keel-badge` package. The project's **README badge** dialog sets it up with a preview and a still PNG for sites that take no SVG. Task titles pass a filter of private data and can be translated into English through your LiteLLM endpoint, and sessions give the badge a short status line.
26
+ - **The CI panel by push:** a row per workflow with its median time, history by push, each run's event and who pushed, a busy runner, and what the chain waits for. A red main gets one automatic rerun of its failed jobs before a fix session (`ci.rerunFailed`, on by default), and a run failed only because no runner took its jobs leaves the commit unchecked, not red.
27
+ - **Milestone order by hand** in a project's tracker window. Without one, milestones go by the tracker's own position, then date, then version, and Jira's versions by release date, as on its Releases page.
28
+ - **An automatic copy of the state database**, daily and before every schema step. Each copy is checked by a trial restore and includes the attachments; the newest 14 are kept (**Settings** → **Backups**, `backup.dir`, `backup.keep`).
29
+ - **Hotkeys:** Ctrl+Enter runs the chain, a double click opens a card, and the **Hotkeys** window in the gear menu changes them.
30
+ - Codex and OpenCode get an auto-compaction window of their own, set in the Agent card.
31
+ - The backlog panel searches its tasks, shows them 50 at a time with each task's run beside its key, and orders them newest first, oldest first or by priority. The project feed has a parents view, and a task's card lists a parent's subtasks on any tracker and the replies of a comment's thread.
32
+ - Notices take **Got it** and **Don't show again**; Settings → **Notices** turns back on what was turned off.
33
+ - A Claude setting changed right in an account folder's `settings.json` is kept: a band asks whether to make it shared, keep it for that account only or discard it.
34
+ - The ⋯ menu of an account row offers **Replace key** for a working key too.
35
+ - **`even-keel install`, `even-keel update` and the first install from `npx` print the page's address** once the page answers, taken from `EVEN_KEEL_HOST`/`EVEN_KEEL_PORT` of the environment and the data folder's `.env`. If the page has not answered after 30 s, they say where the log is instead. The first install from `npx` then opens the page in the browser. On Linux it does that only on a desktop with a display, never over SSH.
8
36
 
9
37
  ### Changed
10
38
 
11
- - **What a task runs on is set on its card, not by a tracker label.** A task's run — provider, model and effort — is kept by Even Keel: the card's **Runs on** picks it, and a session can set it through the tasks server's `run` field of `tasks_create` and `task_update`. The effort is new: Claude Code's `low` to `max` and Codex's `minimal` to `xhigh`; empty passes none. Labels `<Provider> | <model>` are no longer read. The update moves the run label of each open task into its run once, in the projects that had run labels on; the labels stay in the tracker. The setting `modelLabels` is removed.
39
+ - **What a task runs on is set on its card, not by a tracker label.** A task's run — provider, model and effort — is kept by Even Keel: the card's **Runs on** picks it, and a session can set it through the tasks server's `run` field of `tasks_create` and `task_update`. The effort is new: Claude Code's `low` to `max`, Codex's `minimal` to `xhigh`, OpenCode's variant and Copilot's reasoning effort; empty passes none. Labels `<Provider> | <model>` are no longer read. The update moves the run label of each open task into its run once, in the projects that had run labels on; the labels stay in the tracker. The setting `modelLabels` is removed.
12
40
  - **OpenCode keeps a model for each provider it signs in to.** Switching OpenCode's account to one on another sign-in (ChatGPT, an Anthropic key, OpenRouter, Copilot, Go, the free models) and back no longer loses the model you set: the model field shows the one of the account's sign-in and says which it is, in the settings of Even Keel and of a project. In the config `models.opencode` becomes `models.opencode/<provider>`; the update moves yours by its model's prefix. On a task's card, picking another provider and back brings back the model you typed for it.
13
-
14
41
  - **No label is kept out of the chain by default.** `chain.excludedLabels` starts empty and the built-in tracker no longer offers `Manual`: name the label you mark your own tasks with in the chain rules. An installation that relied on the default keeps `Manual` in its shared list after the update, so the same tasks stay out.
15
42
  - **The main branch field offers the repository's branches, and saving another branch switches the main checkout to it**, in a project's settings and in the wizard that adds one: a branch the repository lacks is created from where the checkout stands, one only on a remote is taken from there, and the line under the field says which before you save. The wizard fills in the checkout's current branch and no longer refuses a branch the repository lacks. A checkout switched by hand is shown in the settings and on the chain's card, with buttons to make its branch the main one or to put the folder back, instead of only when a task fails to start.
16
- - **The `checkpoint` plugin is now `agent-bridge`.** The first start after the update replaces `checkpoint@even-keel` with `agent-bridge@even-keel` in every project; a task already running keeps the old plugin until it ends. Let running tasks reach Done before you update: a task carried across the update on the old plugin was not tried through a handoff or a second restart. If you installed `checkpoint` into your own Claude Code by hand, uninstall it as [setup](docs/guide/setup.md#plugins) says.
43
+ - **The `checkpoint` plugin is now `agent-bridge`, always on, with no switches**: handoffs, chat messages mid-turn, the merge check and the badge's status line run on its hooks. The first start after the update replaces `checkpoint@even-keel` with `agent-bridge@even-keel` in every project; a task already running keeps the old plugin until it ends. Let running tasks reach Done before you update: a task carried across the update on the old plugin was not tried through a handoff or a second restart. If you installed `checkpoint` into your own Claude Code by hand, uninstall it as [setup](docs/guide/setup.md#plugins) says.
17
44
  - **A page tab open over the update may need a reload.** Page commands now answer only `{ok:true}`. A tab opened before the update reloads itself once the new service answers, but one held by an open dialog or a field you are typing in waits, and a command sent from it before the reload leaves it broken: reload it by hand.
45
+ - **Packages leave the tools page.** Their catalog is in Settings → **Packages**, and a project's packages open from the first button of its **Sessions** tab; the chat of a working session points there with a button.
46
+ - **A tracker profile turned off reaches nothing of its host**, and **Start** goes only by tasks read since the tracker answered. A tracker that does not answer is named on the project page, the home card and over the archive, and the page's calls to it fail at once instead of after the whole timeout.
47
+ - **A paused chain's toast and band say what happened, then the cause and one advice**, and messages name paths from the project folder.
48
+ - A CLI on a version Even Keel was not checked against is an entry of the event log instead of a banner. A provider on **Checked** whose copy you downloaded once fetches each newer checked version by itself.
49
+ - At most one free ChatGPT account may be signed in across Codex and OpenCode: a different second free account is refused, and one added before is held. Paid plans have no limit.
50
+ - A waiting session whose question is open in the chat has its cache kept warm too.
51
+ - A permission question shows the agent's description of the call, a long call's head and tail, and several commands marked; its tracker comment shows the call.
52
+ - The theme is **System**, **Light** or **Dark**, kept per browser; **System**, the default, follows the device.
53
+ - The page is laid out anew: the header's account card and work block, the project's head with its chain status and buttons in one block, a state strip under the chain's icon buttons and a one-line head on a phone, row actions that slide out on hover, project cards whose bars stand level, one **Open in…** button for several trackers, the task card's side panel in three zones, dialog refusals beside their buttons and code blocks that wrap long lines.
54
+ - `/stats` hides test projects by default (**Show test projects**), prices a model the config does not price from the models.dev catalogue, and gives MiniMax models a family of their own.
55
+ - The service is lighter on an idle machine: the state database is vacuumed, only changed chain rows are rewritten, and the page's live state is compressed.
56
+ - The guide is a page per area with an index, and its setup follows a new user's path.
57
+ - Even Keel has a new mark: a sloop with a mast and a narrow green fin keel.
18
58
 
19
59
  ### Security
20
60
 
21
61
  - **A chain session's request to Even Keel's own address is refused.** Even Keel lets a request from its own machine through without the page's token, so a session under someone else's text could change Protection, answer a question for you or create a task in another project with a plain `curl`. The new Protection group **Requests to Even Keel's address**, on by default, makes the `agent-bridge` plugin (1.2.0) refuse a shell command that sends such a request, on every agent. It is a pattern, not isolation: a script the session wrote gets past it. Turn it off for a project whose tasks work with Even Keel's API.
22
62
  - **The page takes a request only from its own origin, port included.** Before, the `Origin` check compared only the name, so a page on another port of an allowed name — a project's dev server on `localhost`, another service on your tailnet name — could post commands to Even Keel: start a chain, answer a session, add an MCP server. Now `Origin` must match the request's `Host` with its port, and a `POST` to `/api/` must be `Content-Type: application/json` (415 otherwise). A script posting to the API without that header has to add it.
23
63
  - **An MCP server's whole dependency tree is pinned, and npm runs no install scripts.** A server started as `npx -y <package>@<range>` keeps its npm lock file next to its install, so two installs of one version run the same code; an update that changes a dependency says how many in a notice and lists them in the log. Install scripts of the package and its dependencies no longer run as the service's user: a package that needs them gets the **Install scripts** switch in its details. A server started any other way (`uvx`, `docker run`, `npx` without `-y`) shows "version not pinned" in its row. The new installs happen at a package's next update or check; one already installed keeps running as it was.
64
+ - **An outsider's issue on a public GitHub, GitLab or Forgejo repository enters the chain only with an entry label**: one of your required labels or `even-keel: approved`, which **Into the chain** puts on. An issue an outsider changed after the label stays out until you label it again; outsiders' comments stay on the card without reaching the session, and the tasks server hides their unlabelled issues. A public repository without required labels, or an issue template that puts an entry label on, gets a warning band.
65
+ - **Sessions, task commands and MCP servers get nothing of Even Keel's `.env`**: not the page token, Tally's passwords or the badge's secret. A package setting that holds a credential never reaches the page either.
66
+ - **The page cannot be embedded in a frame**, sends no referrer and allows scripts and connections only from its own origin. A reverse proxy must keep these response headers.
67
+ - **In pull request mode the description is read only from a file inside the task's folder**, never `.env` or anything under `.git`, and up to 64 KiB; a refused note pauses the chain before the push.
68
+ - An MCP server's error no longer carries its keys or tokens into the gateway's answer and the log.
24
69
 
25
70
  ### Fixed
26
71
 
27
- - **A project's lone `AGENTS.md` is no longer in a Claude session's context twice.** Claude Code reads the file by itself, so Even Keel stopped appending it to the system prompt; the same text reached every turn twice before.
28
- - **A project's lone `AGENTS.md` reaches a Claude session again when a `CLAUDE.md` lies in a folder above the checkout**, such as `~/.claude/CLAUDE.md` for a checkout in your home folder. Claude Code skips the file then, so Even Keel appends it to the system prompt in that case only.
29
- - The Forgejo plugin's `forgejo:task` skill loads again: its description is quoted, so the skill's frontmatter parses and chain sessions on Forgejo, Gitea and Codeberg projects get the skill (plugin 0.1.1). A test now parses the frontmatter of every bundled skill.
72
+ - **A project's lone `AGENTS.md` reaches a Claude session once, not twice.** Claude Code reads the file by itself, so Even Keel no longer appends it to the system prompt, except when a `CLAUDE.md` lies in a folder above the checkout (such as `~/.claude/CLAUDE.md` for a checkout in your home folder): Claude Code skips the file then.
73
+ - **Claude's Protection rules against deleting a remote branch with a colon refspec and against `rm -rf C:`/`D:` now match**: they are written `:**`, which Claude Code reads as a pattern, instead of `:*`.
74
+ - **Codex applies the project's Protection rules**: Even Keel marks the project's folder as trusted in the account's `config.toml` before each turn, since Codex reads the rules only in a trusted folder.
75
+ - **Pull request mode: a session that asks you a question no longer has its task closed unanswered.** It now ends that turn without the `PULL REQUEST` line, so the chain waits for your answer. Before, a session could put the line under its question, and the task closed on an empty branch.
30
76
  - **`npx even-keel` on macOS and Linux says what to do when npm cannot write its global folder**, as with Node from the nodejs.org installer, whose folder under `/usr/local` belongs to root: it installs nothing and prints the commands that move the folder into your home, also after an `EACCES` of npm itself. It refuses to run as root, since the service would then be installed for root.
77
+ - A task closed by a merged pull request, a pull request with nothing to open, a `NO CHANGES` mark or **Accept as answer** goes to the done status you chose, as a merge does.
78
+ - A Huly reply with a file reaches the session with its file: a reply goes to the session once two polls read it alike, and the files of Huly comments and thread replies download.
79
+ - After Done the chat shows the last session to the end of its turn.
80
+ - A session no longer waits for its background command after a `CHECKPOINT:` or `PULL REQUEST:` mark.
81
+ - A task released while the tracker was being read is kept and cleaned up after Done, and a worktree folder still held after Done is tried again, also after a restart.
82
+ - A turn that outlives SIGTERM is killed with SIGKILL, and on Windows a stopped session's leftover processes are looked for again after it exits.
83
+ - Claude Code and OpenCode installed from npm are found even when their postinstall did not run.
84
+ - `install.sh` on Linux without systemd writes no unit: it says why and how to run Even Keel without a service.
85
+ - An update no longer waits for a chain held by a limit whose reset is more than a minute away.
86
+ - A start while another process still holds the state database waits for it instead of failing.
87
+ - A session's context window is kept over a restart.
88
+ - `/stats` waits under many reads at once instead of failing.
89
+ - An answer cut at the length limit closes the code block it was cut inside.
90
+ - A pause on a refused pull request note no longer tells you to fix access.
31
91
 
32
92
  ## [0.2.4] - 2026-11-11
33
93
 
package/README.md CHANGED
@@ -23,7 +23,7 @@ On Windows: `npx.cmd even-keel`. It installs Even Keel and sets it up as a servi
23
23
 
24
24
  Open `http://localhost:4747`: a short setup, a wizard that adds a project, then **Start** — the chain takes its first task.
25
25
 
26
- **Needs** Node.js 24 and an agent's CLI with an account; git is recommended; a tracker is optional — without one the tasks live in the built-in one. In full: [What it needs](docs/guide/setup.md#what-it-needs).
26
+ **Needs** Node.js 24 or newer and an agent's CLI with an account; git is recommended; a tracker is optional — without one the tasks live in the built-in one. In full: [What it needs](docs/guide/setup.md#what-it-needs).
27
27
 
28
28
  **Sessions don't ask you before each tool call:** read [Before you run it](#before-you-run-it) first.
29
29
 
@@ -71,7 +71,7 @@ Parallel agents decide on their own what an unfinished task will look like, hand
71
71
 
72
72
  ## Before you run it
73
73
 
74
- - **Even Keel depends on undocumented behaviour of the agents' CLIs**, none of it a public API. Last checked against **Claude Code 2.1.319**, **codex-cli 0.167.0**, **OpenCode 1.19.5** and **Copilot CLI 1.0.106**; the page warns when yours is another version and can run sessions on the checked one instead. A CLI update may break a part of Even Keel until it is adapted — please open an issue when it does. Details: [setup](docs/guide/setup.md#the-clis-it-depends-on).
74
+ - **Even Keel depends on undocumented behaviour of the agents' CLIs**, none of it a public API. Last checked against **Claude Code 2.1.325**, **codex-cli 0.169.0**, **OpenCode 1.19.5** and **Copilot CLI 1.0.112**; the page warns when yours is another version and can run sessions on the checked one instead. A CLI update may break a part of Even Keel until it is adapted — please open an issue when it does. Details: [setup](docs/guide/setup.md#the-clis-it-depends-on).
75
75
  - **Your subscription, the providers' terms.** A project runs on one account per provider, and a spent limit is waited out, never got round by switching accounts. Even Keel does not share, pool or resell access. Each agent's sessions fall under its provider's terms, listed below.
76
76
  - **Sessions don't ask you before each tool call** (Claude in auto mode, Codex with `--approve-for-me` or, if you choose, with no sandbox). Protection refuses destructive commands; set up any other permissions and hooks in your agents' settings before you start a chain. Whoever writes a task's text steers its session: read [whose text a session reads and what it may do](docs/guide/security.md) before a chain runs on a public repository.
77
77
  - **Your sign-in stays with the CLIs.** Even Keel reads only expiry dates, the e-mail and the plan; tokens are never copied or sent anywhere. An API key you add goes only to its own provider.
@@ -25,7 +25,7 @@ import { SDK_KIND } from './sdk/registry.js';
25
25
  import { fetchSdk, sdkModuleIn, sdkVersionOf } from './sdk/release.js';
26
26
  import { trustFolder } from './trust.js';
27
27
  /** The version the README's "Before you run it" names; raised after the live run of each release (`docs/releases.md`). */
28
- const CHECKED = '2.1.319';
28
+ const CHECKED = '2.1.325';
29
29
  /** Even Keel's folder of SDK sessions in `state/` and of the SDK's copies in `state/cli/`. */
30
30
  export const CLAUDE_SDK = 'claude-sdk';
31
31
  const SDK_TRANSPORT = 'sdk';
@@ -0,0 +1,72 @@
1
+ // What the `even-keel` command says after install and update: the page's address, once the page answers (EKR-111).
2
+ import { posix, win32 } from 'node:path';
3
+ import { listenOf, localUrlOf } from './config.js';
4
+ /** The address the service listens on, by the rules of `listenOf`: a wrong port is its error, not a throw. */
5
+ export function pageAddressOf(env) {
6
+ try {
7
+ return { url: localUrlOf(listenOf(env)) };
8
+ }
9
+ catch (error) {
10
+ return { error: error instanceof Error ? error.message : String(error) };
11
+ }
12
+ }
13
+ /** Where the service writes its log: the user journal of the systemd unit on Linux, the file in the data folder elsewhere. */
14
+ export function pageLogOf(platform, home) {
15
+ if (platform === 'linux')
16
+ return 'journalctl --user -u even-keel';
17
+ return (platform === 'win32' ? win32 : posix).join(home, 'logs', 'even-keel.log');
18
+ }
19
+ export function pageMessageOf(state) {
20
+ switch (state.kind) {
21
+ case 'ready':
22
+ return `Open ${state.url}`;
23
+ case 'silent':
24
+ return `The page at ${state.url} does not answer yet. Log: ${state.log}`;
25
+ case 'noService':
26
+ return `Once Even Keel runs, its page is at ${state.url}`;
27
+ case 'unknown':
28
+ return `The address of the page is unknown: ${state.error}`;
29
+ }
30
+ }
31
+ /**
32
+ * Whether the CLI opens the page itself: only at the first install from npx and once the page answered, never by SSH,
33
+ * and on Linux only with a display to open it on.
34
+ */
35
+ export function opensBrowser(at) {
36
+ if (!at.firstInstall || !at.responded)
37
+ return false;
38
+ const ssh = Boolean(at.env.SSH_CONNECTION || at.env.SSH_TTY);
39
+ if (at.platform === 'win32')
40
+ return true;
41
+ if (at.platform === 'darwin')
42
+ return !ssh;
43
+ if (at.platform === 'linux')
44
+ return !ssh && Boolean(at.env.DISPLAY || at.env.WAYLAND_DISPLAY);
45
+ return false;
46
+ }
47
+ /** The command that opens `url` in the default browser; `null` — none known for the platform. */
48
+ export function browserCommandOf(platform, url) {
49
+ if (platform === 'win32')
50
+ return ['cmd', ['/c', 'start', '', url]];
51
+ if (platform === 'darwin')
52
+ return ['open', [url]];
53
+ if (platform === 'linux')
54
+ return ['xdg-open', [url]];
55
+ return null;
56
+ }
57
+ /** Asks `url` until it answers with any status or `timeoutMs` passes: whether it answered. */
58
+ export async function waitForPage(url, { request, now, sleep, timeoutMs = 30_000, intervalMs = 1_000 }) {
59
+ const until = now() + timeoutMs;
60
+ for (;;) {
61
+ try {
62
+ await request(url);
63
+ return true;
64
+ }
65
+ catch {
66
+ // Not up yet.
67
+ }
68
+ if (now() >= until)
69
+ return false;
70
+ await sleep(Math.min(intervalMs, until - now()));
71
+ }
72
+ }
package/dist/src/cli.js CHANGED
@@ -6,6 +6,7 @@ import { homedir, userInfo } from 'node:os';
6
6
  import { join } from 'node:path';
7
7
  import { hostArgsOf, hostDirOf, installAutostart, quitHost, registeredAutostart, uninstallAutostart } from './autostart.js';
8
8
  import { commandOf, noServiceManagerCode, serviceScriptOf, updateTargetOf } from './cli-args.js';
9
+ import { browserCommandOf, opensBrowser, pageAddressOf, pageLogOf, pageMessageOf, waitForPage } from './cli-page.js';
9
10
  import { home, loadEnv, root, source } from './locations.js';
10
11
  import { accountsRoot } from './account/homes.js';
11
12
  import { removeAccountSettingsGuards } from './account/settingsGuard.js';
@@ -24,20 +25,72 @@ const usage = `usage: even-keel [command]
24
25
  data folder: ${home}`;
25
26
  const { name, version: installedVersion } = installed(root);
26
27
  const command = commandOf(process.argv.slice(2));
27
- /** `explained` — an exit code after which the command has already said why: this process exits with it, adding nothing. */
28
- function run(command, what, explained) {
29
- const error = attempt(command, what, explained);
28
+ /**
29
+ * `explained` — an exit code after which the command has already said why: this process exits with it, adding nothing
30
+ * but what `beforeExit` prints.
31
+ */
32
+ function run(command, what, explained, beforeExit) {
33
+ const error = attempt(command, what, explained, beforeExit);
30
34
  if (error !== null)
31
35
  fail(error);
32
36
  }
33
- function attempt([program, ...args], what, explained) {
37
+ function attempt([program, ...args], what, explained, beforeExit) {
34
38
  const result = spawnSync(program, args, { stdio: 'inherit', windowsHide: true, shell: process.platform === 'win32' && program === 'npm' });
35
39
  if (result.error !== undefined)
36
40
  return `${what}: ${result.error.message}`;
37
- if (explained !== undefined && result.status === explained)
41
+ if (explained !== undefined && result.status === explained) {
42
+ beforeExit?.();
38
43
  process.exit(explained);
44
+ }
39
45
  return result.status === 0 ? null : `${what} failed with code ${result.status}`;
40
46
  }
47
+ /** Any HTTP answer of the page, whatever its status; a refused or hung connection rejects. */
48
+ const pageWait = {
49
+ request: async (url) => {
50
+ const response = await fetch(url, { redirect: 'manual', signal: AbortSignal.timeout(2_000) });
51
+ await response.body?.cancel();
52
+ },
53
+ now: () => Date.now(),
54
+ sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
55
+ };
56
+ /**
57
+ * The page's address from the data folder's `.env`. Read only after the service is installed: `install.sh` writes the
58
+ * listen variables of its environment into the unit, and `.env`'s must not get there.
59
+ */
60
+ function pageAddress() {
61
+ loadEnv();
62
+ return pageAddressOf(process.env);
63
+ }
64
+ /** Once the service is started: waits up to 30 s for its page and says where it is. Whether the page answered. */
65
+ async function announcePage() {
66
+ const address = pageAddress();
67
+ if ('error' in address) {
68
+ console.log(pageMessageOf({ kind: 'unknown', error: address.error }));
69
+ return false;
70
+ }
71
+ const answered = await waitForPage(address.url, pageWait);
72
+ console.log(pageMessageOf(answered ? { kind: 'ready', url: address.url } : { kind: 'silent', url: address.url, log: pageLogOf(process.platform, home) }));
73
+ return answered;
74
+ }
75
+ /** Linux without a systemd user manager: no service to wait for, only where its page will be. */
76
+ function announceNoService() {
77
+ const address = pageAddress();
78
+ console.log(pageMessageOf('error' in address ? { kind: 'unknown', error: address.error } : { kind: 'noService', url: address.url }));
79
+ }
80
+ /** Opens the page in the default browser; a failure is silent, the address is already printed. */
81
+ function openBrowser(url) {
82
+ const command = browserCommandOf(process.platform, url);
83
+ if (command === null)
84
+ return;
85
+ try {
86
+ const child = spawn(command[0], command[1], { detached: true, stdio: 'ignore', windowsHide: true });
87
+ child.on('error', () => { });
88
+ child.unref();
89
+ }
90
+ catch {
91
+ // No opener here.
92
+ }
93
+ }
41
94
  function fail(message) {
42
95
  console.error(`even-keel: ${message}`);
43
96
  process.exit(1);
@@ -89,18 +142,30 @@ async function installGlobally() {
89
142
  const { error, stderr } = await attemptKeepingErrors(npm('install', '--global', `${name}@${installedVersion}`, '--no-audit', '--no-fund'), 'npm install --global');
90
143
  if (error !== null)
91
144
  fail(posix && isAccessError(stderr) ? `${error}\n${npmPrefixAdvice(modules, process.env.SHELL, npx)}` : error);
145
+ // The global copy waits for the page and prints its address; the browser opens only at this first install.
92
146
  run([process.execPath, join(modules, name, 'dist', 'src', 'cli.js'), 'install'], 'even-keel install', noServiceManagerCode);
147
+ const address = pageAddress();
148
+ if ('error' in address)
149
+ return;
150
+ const responded = await waitForPage(address.url, { ...pageWait, timeoutMs: 0 });
151
+ if (opensBrowser({ platform: process.platform, env: process.env, firstInstall: true, responded }))
152
+ openBrowser(address.url);
93
153
  }
94
- function service(action) {
154
+ async function service(action) {
95
155
  if (process.platform === 'win32') {
96
156
  if (action === 'install')
97
- autostart();
157
+ await autostart();
98
158
  else
99
159
  removeWindows();
100
160
  }
101
161
  else {
102
162
  const [program, args] = serviceScriptOf(process.platform, root, action);
103
- run([program, ...args], `service/${action}`, action === 'install' ? noServiceManagerCode : undefined);
163
+ if (action === 'install') {
164
+ run([program, ...args], 'service/install', noServiceManagerCode, announceNoService);
165
+ await announcePage();
166
+ }
167
+ else
168
+ run([program, ...args], 'service/uninstall');
104
169
  }
105
170
  if (action === 'uninstall') {
106
171
  loadEnv();
@@ -115,7 +180,7 @@ function windowsService() {
115
180
  return query.status === 0 ? query.stdout : null;
116
181
  }
117
182
  /** One Even Keel per machine: the service of `install.ps1` would take the same port. */
118
- function autostart() {
183
+ async function autostart() {
119
184
  if (windowsService() !== null)
120
185
  fail('the Windows service EvenKeel is installed: remove it first with service\\uninstall.ps1 from PowerShell 7 as administrator');
121
186
  if (source === 'git') {
@@ -135,6 +200,7 @@ function autostart() {
135
200
  catch (error) {
136
201
  fail(error instanceof Error ? error.message : String(error));
137
202
  }
203
+ await announcePage();
138
204
  }
139
205
  function removeWindows() {
140
206
  const registered = registeredAutostart();
@@ -188,7 +254,7 @@ function distTags() {
188
254
  fail(`npm view gave no dist-tags: ${stdout}`);
189
255
  }
190
256
  /** The page's button waits for the chains first; this does not, it is for a service that is down or a page out of reach. */
191
- function update(version) {
257
+ async function update(version) {
192
258
  if (source === 'git')
193
259
  fail('this is a git checkout: update it with git pull, or with the button on the page');
194
260
  const prefix = globalPrefixOf(root, process.platform);
@@ -200,14 +266,25 @@ function update(version) {
200
266
  return;
201
267
  }
202
268
  const control = installedService();
203
- if (control !== null)
269
+ if (control !== null) {
270
+ console.log('even-keel: stopping the service');
204
271
  run(control.stop, 'stopping the service');
272
+ }
273
+ console.log(`even-keel: updating ${installedVersion} to ${target}`);
205
274
  // A failed install leaves the version that was there: the service starts again either way.
206
275
  const error = attempt(npm('install', '--global', '--prefix', prefix, `${name}@${target}`, '--no-audit', '--no-fund'), 'npm install --global');
207
- if (control !== null)
276
+ if (control !== null) {
277
+ console.log('even-keel: starting the service');
208
278
  run(control.start, 'starting the service');
209
- if (error !== null)
279
+ }
280
+ if (error !== null) {
281
+ console.error(`even-keel: ${installedVersion} stays`);
210
282
  fail(error);
283
+ }
284
+ if (control === null)
285
+ console.log(`even-keel: updated to ${target}; no service of this install, so none was started`);
286
+ else
287
+ await announcePage();
211
288
  }
212
289
  switch (command.command) {
213
290
  case 'help':
@@ -225,12 +302,12 @@ switch (command.command) {
225
302
  if (fromNpxCache(root))
226
303
  await installGlobally();
227
304
  else
228
- service('install');
305
+ await service('install');
229
306
  break;
230
307
  case 'uninstall':
231
- service('uninstall');
308
+ await service('uninstall');
232
309
  break;
233
310
  case 'update':
234
- update(command.version);
311
+ await update(command.version);
235
312
  break;
236
313
  }
@@ -1,2 +1,2 @@
1
1
  /** Raised after the live run of each release (`docs/releases.md`). */
2
- export const CODEX_CHECKED = '0.167.0';
2
+ export const CODEX_CHECKED = '0.169.0';
@@ -18,7 +18,7 @@ import { foldEvents } from './transcript.js';
18
18
  import { withTurnError } from './errors.js';
19
19
  const HISTORY_FEED = 5_000;
20
20
  /** The version the README's "Before you run it" names; raised after the live run of each release (`docs/releases.md`). */
21
- const CHECKED = '1.0.106';
21
+ const CHECKED = '1.0.112';
22
22
  /**
23
23
  * GitHub Copilot CLI through `copilot -p … --output-format json`: a turn is a detached process, as Codex's is; a session
24
24
  * lives between turns in Even Keel's registry and the account folder's `session-state/<id>/events.jsonl`
Binary file
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DescriptionEditor-DUSwRGCZ.js","assets/rolldown-runtime-XKyaHtl9.js","assets/blocks-CiOz7u_W.js","assets/blocks-Dx3DACiG.css","assets/react-dom-DiYkIXNS.js","assets/lib-DnFFmOv9.js","assets/hooks-CgKVeUg8.js","assets/accountParts-CNUeXPYn.js","assets/secret-CmK85pY6.js","assets/secret-DldsC74x.css","assets/accountParts-tFRVownp.css","assets/overview-0NAogPYB.js","assets/rules-DLe7kZM5.js","assets/Select-NXi_Bsw-.js","assets/Select-CYemy5Na.css","assets/rules-Bgil4ZBp.css","assets/packageGroups-6mYiV3fk.js","assets/overview-B7iEgjQD.css","assets/useFileDrop-CEn6qZnh.js","assets/description-C-o9LBbp.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ei as t,Jn as n,Lr as r,Ot as i,Pr as a,Rr as o,Sr as s,Ti as c,Xt as l,an as u,en as d,ki as f,o as p,pi as m,s as h,ui as g,v as _,vr as v,xi as y,y as b}from"./blocks-CiOz7u_W.js";import{et as x,p as S,u as C}from"./lib-DnFFmOv9.js";import{a as w,s as T}from"./rules-DLe7kZM5.js";import{t as E}from"./Select-NXi_Bsw-.js";import{T as D,_ as O,f as k,g as A,h as j,n as M,o as N,r as P,t as F,v as I,x as L,y as R}from"./useHeightGlide-BPjzH9PL.js";import{S as z,a as B,c as ee,i as V,o as te,r as H,s as ne,t as U}from"./cardDrafts-DDpQR0kq.js";import{c as re,i as ie,l as W,o as ae,s as oe,t as se,u as ce}from"./cardSide-DEslYiM-.js";/* empty css */var G=e(f(),1),le=1.5;function ue(e,t){let n=e??null,r=t??null;return n===null&&r===null?null:{estimate:S(n===null?null:n*60),time:S(r),over:n!==null&&r!==null&&r>n*60*le}}function de(e,t){return e.category===`UnStarted`&&t.category===`ToDo`?`ready`:(e.category===`ToDo`||e.category===`Active`)&&t.category===`UnStarted`?`unready`:`edit`}var K=e=>e.category===`Won`||e.category===`Lost`;function fe(e,t,n){return n===e.id?c(`builtin.selfLink`,{task:e.id}):(t===`blocks`?e.blocks:t===`blockedBy`?e.blockedBy:e.related).some(e=>e.id===n)?c(`builtin.linkExists`,{task:e.id,other:n}):null}function pe(e,t,n){return t===`blockedBy`?{task:n,other:e,kind:`blocks`}:{task:e,other:n,kind:t}}function me(e,t,n){return n===e?c(`builtin.selfParent`,{task:e}):t.some(e=>e.id===n)?c(`builtin.parentCycle`,{task:e,parent:n}):null}function he(e,t){let n=e=>{let n=t.indexOf(e);return n<0?2**53-1:n},r=e=>Number(e.slice(e.lastIndexOf(`-`)+1));return[...e].sort((e,t)=>n(e.id)-n(t.id)||r(e.id)-r(t.id))}function ge(e,t,n){let r=(e,t)=>e.trim().toLocaleLowerCase()===t.trim().toLocaleLowerCase(),i=e.filter(e=>!t.some(t=>r(t,e.name))).map(e=>({...e,create:!1})),a=n.trim();return a===``||e.some(e=>r(e.name,a))||t.some(e=>r(e,a))?i:[...i,{name:a,builtin:!1,create:!0}]}function _e(e,t){return!w(e,{milestone:{label:t,targetDate:null}})}function ve(e,t){return e.filter(e=>!K(e.status)&&(e.milestone??null)?.toLocaleLowerCase()!==t?.toLocaleLowerCase())}function ye(e,t){return e?.code===`builtin.conflict`?{field:e.params.field,theirs:e.params.current,mine:t}:null}function be(e,t,n){return t?c(`builtin.removeBusy`,{task:e,why:`current`}):n?c(`builtin.removeBusy`,{task:e,why:`live`}):null}var q=o(),xe=150;function J({item:e,onOpen:t}){if(e.moved===void 0)return(0,q.jsx)(Se,{item:e,onOpen:t});let{key:n,url:r}=e.moved;return(0,q.jsxs)(`span`,{className:`task-card__moved-ref`,children:[(0,q.jsx)(Se,{item:e,onOpen:t}),(0,q.jsxs)(`span`,{className:`task-card__moved`,children:[y.transfer.movedTo,` `,r===null?n:(0,q.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,children:n})]})]})}function Se({item:e,onOpen:t}){return(0,q.jsxs)(`button`,{type:`button`,className:`task-card__ref task-card__ref--${e.status.category}`,title:e.status.name,onClick:()=>t(e.id),children:[(0,q.jsx)(`span`,{className:`task-card__status task-card__status--${e.status.category} task-card__status--bare`,children:(0,q.jsx)(`span`,{className:`task-card__dot`})}),(0,q.jsx)(`span`,{className:`task-card__ref-key`,children:e.id}),(0,q.jsx)(`span`,{className:`task-card__ref-title`,children:e.title})]})}function Ce({project:e,label:t,refusal:n,onPick:i,onClose:a,focus:o=!0}){let{query:s}=r(),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)([]),f=(0,G.useRef)(null);return(0,G.useEffect)(()=>{o&&f.current?.querySelector(`input`)?.focus()},[o]),(0,G.useEffect)(()=>{let t=!0,n=setTimeout(()=>{s(`builtin/search`,{text:c,project:e}).then(e=>t&&d(e),()=>t&&d([]))},xe);return()=>{t=!1,clearTimeout(n)}},[c,e]),(0,q.jsx)(`div`,{ref:f,className:`task-card__search`,children:(0,q.jsx)(b,{error:n,wide:!0,children:(0,q.jsx)(T,{className:`task-card__field`,label:t,placeholder:y.card.edit.findTask,value:c,options:u.map(e=>({value:e.id,label:e.moved===void 0?e.title:`${e.title} · ${y.transfer.movedTo} ${e.moved.key}`})),invalid:n!==null,onChange:l,onPick:i,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a())}})})})}function we({card:e,editor:t,onOpen:n}){let[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(`blocks`),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(null);(0,G.useEffect)(()=>{r&&u.current?.querySelector(`button`)?.focus()},[r]);let d=[...e.blockedBy,...e.blocks,...e.related];if(d.length===0&&t===null)return null;let f={"--ref-key":`${Math.max(0,...d.map(e=>e.id.length))}ch`},p=async n=>{let r=fe(e,o,n)??await t.run(`query`,`builtin/relate`,pe(e.id,o,n));l(r),r===null&&a(!1)},m=(n,r)=>t===null?void 0:()=>void t.call(`query`,`builtin/unrelate`,pe(e.id,n,r));return(0,q.jsxs)(`div`,{className:`task-card__relations`,style:f,children:[(0,q.jsx)(Y,{title:y.card.blockedBy,items:e.blockedBy,onOpen:n,onRemove:e=>m(`blockedBy`,e)}),(0,q.jsx)(Y,{title:y.card.blocks,items:e.blocks,onOpen:n,onRemove:e=>m(`blocks`,e)}),(0,q.jsx)(Y,{title:y.card.related,items:e.related,onOpen:n,onRemove:e=>m(`relates`,e)}),t!==null&&(r?(0,q.jsxs)(`div`,{ref:u,className:`task-card__link-add`,children:[(0,q.jsx)(E,{className:`task-card__field`,label:y.card.edit.linkKind,value:o,options:[`blocks`,`blockedBy`,`relates`].map(e=>({value:e,label:y.card.edit.kinds[e]})),onChange:e=>{s(e),l(null)}}),(0,q.jsx)(Ce,{project:null,label:y.card.edit.addLink,refusal:c,onPick:e=>void p(e),onClose:()=>{a(!1),l(null)},focus:!1})]}):(0,q.jsxs)(`button`,{type:`button`,className:`task-card__ghost`,onClick:()=>a(!0),children:[(0,q.jsx)(i,{}),y.card.edit.addLink]}))]})}function Y({title:e,items:t,onOpen:n,onRemove:r}){return t.length===0?null:(0,q.jsxs)(`section`,{className:`task-card__group`,children:[(0,q.jsxs)(`h3`,{className:`task-card__heading`,children:[e,` `,(0,q.jsx)(`span`,{className:`task-card__count`,children:t.length})]}),(0,q.jsx)(`ul`,{className:`task-card__refs`,children:t.map(e=>{let t=r(e.id);return(0,q.jsxs)(`li`,{className:t===void 0?void 0:`task-card__ref-row`,children:[(0,q.jsx)(J,{item:e,onOpen:n}),t!==void 0&&(0,q.jsx)(X,{label:y.card.edit.unlink(e.id),onPress:t})]},e.id)})})]})}function X({label:e,onPress:t,disabled:n=!1}){return(0,q.jsx)(`button`,{type:`button`,className:`task-card__remove`,"aria-label":e,title:e,disabled:n,onClick:t,children:`×`})}function Te(e){let[t,n]=(0,G.useState)(null);return(0,G.useEffect)(()=>{t!==null&&t.from!==e&&n(null)},[e,t]),{shown:t!==null&&t.from===e?t.to:e,hold:t=>n({from:e,to:t}),release:()=>n(null)}}function Ee(e){let t=(0,G.useRef)(e);t.current=e,(0,G.useEffect)(()=>{let e=()=>document.visibilityState===`hidden`&&t.current(`hidden`),n=()=>t.current(`hidden`);return document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,n),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,n),t.current(`unmount`)}},[])}var Z=g(e=>new Intl.DateTimeFormat(e,{day:`numeric`,month:`short`,year:`numeric`}));function De({card:e,editor:t}){let[n,r]=(0,G.useState)(null),i=(0,G.useRef)(null),a=e=>{i.current=e,r(e)},o=Te(e.title),s=async(n,r,i)=>{o.hold(r);let a=await t.edit(`title`,n,r,{...i,kept:!0,task:e.id});return a!==`landed`&&o.release(),a},c=async()=>{let e=i.current?.trim()??``;a(null),e!==``&&e!==o.shown&&await s(o.shown,e,{keepalive:!0})};Ee(()=>void c());let l=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{if(l.current)return;l.current=!0;let n=H(V(t.project,e.id,`title`),e.title);if(n===null)return U(t.project,e.id,`title`);s(n.from,n.to,{}).then(e=>e===`refused`&&a(n.to))},[]),n===null?(0,q.jsx)(`h2`,{className:`task-card__title`,children:(0,q.jsx)(`button`,{type:`button`,className:`task-card__title-edit`,title:y.card.edit.titleHint,onClick:()=>a(o.shown),children:o.shown})}):(0,q.jsx)(`h2`,{className:`task-card__title`,children:(0,q.jsx)(`input`,{className:`task-card__title-input`,autoComplete:`off`,"aria-label":y.card.edit.title,value:n,autoFocus:!0,disabled:t.busy,onChange:e=>a(e.target.value),onKeyDown:n=>{n.key===`Enter`?(n.preventDefault(),c()):n.key===`Escape`&&(n.preventDefault(),n.stopPropagation(),U(t.project,e.id,`title`),a(null))},onBlur:()=>void c()})})}function Oe({status:e}){return(0,q.jsx)(`span`,{className:`task-card__status task-card__status--${e.category} task-card__status--bare`,children:(0,q.jsx)(`span`,{className:`task-card__dot`})})}function ke({card:e,editor:t,refused:n,live:r}){let i=e.status,a=e=>{let t=de(i,e);if(t===`unready`&&r)return y.card.edit.liveBacklog;if(t===`ready`&&n!==null)return y.chain.readyRefused(m(n))};return(0,q.jsx)(E,{className:`task-card__status-pick task-card__status--${i.category}`,label:y.card.edit.status,value:i.name,disabled:t.busy,options:e.edit.statuses.map(e=>({value:e.name,label:e.name,icon:(0,q.jsx)(Oe,{status:e}),unavailable:a(e)})),onChange:n=>{let r=e.edit.statuses.find(e=>e.name===n);if(r===void 0||r.name===i.name)return;let a=de(i,r);a===`edit`?t.edit(`status`,i.name,r.name):t.call(`command`,a===`ready`?`task/ready`:`task/unready`,{task:e.id})}})}function Ae({card:e,editor:t}){return(0,q.jsx)(E,{className:`task-card__field task-card__field--quiet`,label:y.card.priority,value:e.priority,disabled:t.busy,options:v.map(e=>({value:e,label:y.card.priorities[e],icon:(0,q.jsx)(D,{priority:e})})),onChange:n=>n!==e.priority&&void t.edit(`priority`,e.priority,n)})}var Q=(e,t)=>(e??``).toLocaleLowerCase()===(t??``).toLocaleLowerCase();function je({card:e,editor:t}){let n=e.milestone?.label??null,[r,i]=(0,G.useState)(n??``),[a,o]=(0,G.useState)(null);(0,G.useEffect)(()=>i(n??``),[n]);let s=e.milestones?.choices??[],c=r.trim(),l=s.map(e=>({value:e.label,label:e.targetDate?y.card.due(Z().format(e.targetDate)):void 0}));c!==``&&!s.some(e=>Q(e.label,c))&&l.push({value:c,label:y.card.edit.newMilestone});let u=async r=>{let a=r.trim()===``?null:r.trim();if(Q(a,n))return i(n??``);let s=ve(e.subtasks??[],a);if(await t.edit(`milestone`,n,a)!==`landed`)return i(n??``);s.length>0&&o({to:a,children:s})},d=async()=>{let e=a;o(null);for(let n of e.children)await t.run(`query`,`builtin/edit`,{task:n.id,field:`milestone`,from:n.milestone,to:e.to})},f=s.find(e=>Q(e.label,n));return(0,q.jsxs)(`div`,{className:`task-card__milestone`,children:[(0,q.jsxs)(`div`,{className:`task-card__field-row`,children:[(0,q.jsx)(T,{className:`task-card__field task-card__field--quiet`,label:y.card.milestone,placeholder:y.card.noMilestone,value:r,options:l,disabled:t.busy,onChange:i,onPick:e=>void u(e),onKeyDown:e=>{e.key===`Enter`&&u(r)}}),n!==null&&(0,q.jsx)(X,{label:y.card.edit.clearMilestone,disabled:t.busy,onPress:()=>void u(``)})]}),f?.targetDate?(0,q.jsx)(`small`,{children:y.card.due(Z().format(f.targetDate))}):null,n!==null&&_e(e.edit.milestoneRules,n)&&(0,q.jsx)(`p`,{className:`task-card__run-note task-card__run-note--warn`,children:y.card.edit.foreignMilestone}),a!==null&&(0,q.jsx)(C,{title:y.card.edit.carryTitle,question:y.card.edit.carryQuestion(a.children.length,a.to),confirm:y.card.edit.carry,cancel:y.card.edit.carryNo,busy:t.busy,safe:!0,onConfirm:()=>void d(),onClose:()=>o(null)})]})}function Me({card:e,editor:t,roleText:n}){let[r,i]=(0,G.useState)(``),a=e.labels.map(e=>e.name),o=ge(e.edit.labels,a,r).map(e=>({value:e.name,label:e.create?y.card.edit.newLabel:e.builtin?y.card.edit.meanings[e.name.toLocaleLowerCase()]:void 0})),s=async n=>{let r=n.trim();r===``||a.some(e=>Q(e,r))||await t.call(`query`,`builtin/labels`,{task:e.id,add:[r]})&&i(``)};return(0,q.jsxs)(`div`,{className:`task-card__labels`,children:[e.labels.length>0&&(0,q.jsx)(`ul`,{className:`task-card__chips`,children:e.labels.map(r=>(0,q.jsxs)(`li`,{className:`${r.role===null?`tag`:`chip task-card__chip--${r.role}`} task-card__chip-edit`,title:r.role===null?void 0:n(r.role),children:[r.name,(0,q.jsx)(X,{label:y.card.edit.removeLabel(r.name),disabled:t.busy,onPress:()=>void t.call(`query`,`builtin/labels`,{task:e.id,remove:[r.name]})})]},r.name))}),(0,q.jsx)(T,{className:`task-card__field`,label:y.card.edit.addLabel,placeholder:y.card.edit.addLabel,value:r,options:o,disabled:t.busy,onChange:i,onPick:e=>void s(e),onKeyDown:e=>{e.key===`Enter`&&s(r)}})]})}function Ne({ancestors:e,onOpen:t}){return e.length===0?null:(0,q.jsx)(`nav`,{className:`task-card__path`,"aria-label":y.card.edit.path,children:(0,q.jsx)(`ol`,{children:e.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,className:`task-card__path-step`,title:e.title,onClick:()=>t(e.id),children:[(0,q.jsx)(`span`,{className:`task-card__ref-key`,children:e.id}),(0,q.jsx)(`span`,{className:`task-card__path-title`,children:e.title})]})},e.id))})})}function Pe({card:e,project:t,editor:n,onOpen:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),c=e.parent?.id??null,l=()=>{a(!1),s(null)},u=async t=>{let r=me(e.id,e.subtasks??[],t);if(r!==null)return s(r);if(t===c)return l();let i=await n.run(`query`,`builtin/edit`,{task:e.id,field:`parent`,from:c,to:t});i===null?l():s(i)};return i?(0,q.jsx)(Ce,{project:t,label:y.card.edit.changeParent,refusal:o,onPick:e=>void u(e),onClose:l}):e.parent===null?(0,q.jsx)(`button`,{type:`button`,className:`task-card__ghost task-card__ghost--inline`,onClick:()=>a(!0),children:y.card.edit.setParent}):(0,q.jsxs)(`div`,{className:`task-card__parent`,children:[(0,q.jsxs)(`div`,{className:`task-card__ref-row`,children:[(0,q.jsx)(J,{item:e.parent,onOpen:r}),(0,q.jsx)(X,{label:y.card.edit.dropParent,disabled:n.busy,onPress:()=>void n.edit(`parent`,c,null)})]}),(0,q.jsx)(`button`,{type:`button`,className:`task-card__ghost`,disabled:n.busy,onClick:()=>a(!0),children:y.card.edit.changeParent})]})}function Fe({card:e,project:t,adding:n,inWork:i,onOpen:a}){let{state:o}=r(),s=e.subtasks??[],c=n!==null&&!K(e.status)?n:null;if(s.length===0&&c===null)return null;let l=o?.chain.projects[t]?.order??[],u=s.filter(e=>K(e.status)).length;return(0,q.jsxs)(`section`,{className:`task-card__section`,children:[(0,q.jsx)(`h3`,{className:`task-card__heading`,children:y.card.edit.subtasks(u,s.length)}),s.length>0&&(0,q.jsx)(`ul`,{className:`task-card__refs task-card__subtasks`,children:he(s,l).map(e=>(0,q.jsxs)(`li`,{className:`task-card__subtask`,children:[(0,q.jsx)(J,{item:e,onOpen:a}),(0,q.jsx)(`span`,{className:`task-card__subtask-status task-card__status--${e.status.category}`,children:e.status.name})]},e.id))}),c!==null&&(0,q.jsx)(Ie,{card:c.card,project:t,editor:c.editor,confirmFirst:i&&s.length===0})]})}function Ie({card:e,project:t,editor:n,confirmFirst:r}){let[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),d=async r=>{let i=await n.run(`query`,`builtin/create`,{project:t,title:r,parent:e.id,milestone:e.milestone?.label??null,status:`Todo`});u(i),i===null&&o(``)};return a===null?(0,q.jsxs)(`button`,{type:`button`,className:`task-card__ghost`,onClick:()=>o(``),children:[(0,q.jsx)(i,{}),y.card.edit.addSubtask]}):(0,q.jsxs)(`div`,{className:`task-card__add`,children:[(0,q.jsx)(`input`,{className:`task-card__field`,autoComplete:`off`,"aria-label":y.card.edit.subtaskTitle,placeholder:y.card.edit.subtaskTitle,value:a,autoFocus:!0,disabled:n.busy,"aria-invalid":l!==null||void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=a?.trim()??``;if(t===``)return;r?c(!0):d(t)}else e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),o(null),u(null))}}),l!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(l)}),s&&(0,q.jsx)(C,{title:y.card.edit.firstTitle,question:y.card.edit.firstQuestion(e.id),confirm:y.card.edit.firstConfirm,cancel:y.card.edit.cancel,busy:n.busy,safe:!0,onConfirm:()=>{c(!1),d(a.trim())},onClose:()=>c(!1)})]})}function Le(e){return{provider:e?.provider??``,model:e?.model??``,effort:e?.effort??``}}function Re(e,t){return s[e===``?t:e]??[]}function ze(e,t,n,r={}){return t===e.provider?e:{provider:t,model:r[t]??``,effort:Re(t,n).includes(e.effort)?e.effort:``}}function Be(e,t){return t.provider===``||e[t.provider]===t.model?e:{...e,[t.provider]:t.model}}function Ve(e,t){let n=t.model.trim(),r={provider:t.provider===``?null:t.provider,model:t.provider===``||n===``?null:n,effort:t.effort===``?null:t.effort};return z(e,r)?null:r}function He({task:e,live:t,onChanged:i}){let{state:o}=r(),{send:s,sending:c,failure:l}=a(),u=n(o,e),f=o?.runs?.[u]?.[e],p=Le(f),[h,g]=(0,G.useState)(p),[_,v]=(0,G.useState)({});(0,G.useEffect)(()=>g(p),[`${p.provider}|${p.model}|${p.effort}`]);let b=o?.config.shared,S=o?.config.projects[u],C=S?.provider??b?.provider??``,w=h.provider===``?``:(S?.accounts[h.provider]||b?.accounts[h.provider])??``,D=P([w]),O=N(o?.account,w),A=h.provider===``?``:d(S?.models??{},h.provider,O)||d(b?.models??{},h.provider,O)||y.settings.cliDefault,j=e=>{let t=Be(_,h);v(t),g(ze(h,e,C,t))},F=Ve(f,h),I=x(o?.account??null,[p.provider,h.provider]),L=Re(h.provider,C),R=()=>{F===null||c||s(`task/run`,{task:e,...F}).then(e=>e&&i())};return(0,q.jsxs)(`div`,{className:`task-card__prop task-card__prop--wide`,children:[(0,q.jsxs)(`dt`,{className:`task-card__prop-head`,children:[y.card.run.title,F!==null&&(0,q.jsx)(`button`,{type:`button`,className:`button button--small task-card__run-save`,disabled:c,onClick:R,children:y.card.run.save})]}),(0,q.jsxs)(`dd`,{className:`task-card__run`,children:[(0,q.jsx)(E,{className:`task-card__field`,label:y.card.run.provider,value:h.provider,options:[{value:``,label:y.card.run.asProject(k(C))},...I.map(e=>({value:e,label:k(e)}))],disabled:c,onChange:j}),h.provider!==``&&(0,q.jsx)(T,{className:`task-card__field`,label:y.card.run.model,value:h.model,options:M(D,w),placeholder:y.card.run.modelAsProject(A),disabled:c,onChange:e=>g({...h,model:e}),onKeyDown:e=>{e.key===`Enter`&&R()}}),L.length>0&&(0,q.jsx)(E,{className:`task-card__field`,label:y.card.run.effort,value:h.effort,options:[{value:``,label:y.card.run.effortNone},...L.map(e=>({value:e,label:y.card.run.effortOf(e)}))],disabled:c,onChange:e=>g({...h,effort:e})}),t&&F!==null&&(0,q.jsx)(`p`,{className:`task-card__run-note`,children:y.card.run.live}),l!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(l)})]})]})}function Ue(e,n,i){let{command:a,query:o}=r(),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),p=async(e,n,r,s)=>{c(!0);try{return await(e===`command`?a(n,r):o(n,r,s)),i(),null}catch(e){return t(e)}finally{c(!1)}},m=async(e,t,n)=>{u(null);let r=await p(e,t,n);return u(r),r===null},h=async(t,r,i,a={})=>{u(null);let o=a.task??n,s=a.kept===!0?t:null;s!==null&&B(e,o,s,{from:r??``,to:i??``});let c=await p(`query`,`builtin/edit`,{task:o,field:t,from:r,to:i},{keepalive:a.keepalive});if(c===null)return s!==null&&U(e,o,s),`landed`;let l=ye(c,i);return l===null?(u(c),`refused`):(f({...l,task:o,kept:s!==null,keep:()=>{f(null),h(t,l.theirs,i,{kept:s!==null,task:o})}}),`conflict`)};return{project:e,busy:s,failure:l,conflict:d,run:p,call:m,edit:h,settle:()=>{d?.kept===!0&&U(e,d.task,d.field),f(null),i()},reload:i}}var We=(0,G.lazy)(()=>j(()=>import(`./DescriptionEditor-DUSwRGCZ.js`).then(e=>({default:e.DescriptionEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function Ge({task:e,text:t,editor:n,render:i}){let[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),{state:m,attach:h}=r(),g=(0,G.useRef)(null),_=Te(t),v=_.shown,b=()=>{p(null),o({start:v,text:v,revision:0})},x=()=>{o(null),p(null)},S=()=>{U(n.project,e,`description`),x()},C=async(t,r,i)=>{if(r===t)return x();p(null),B(n.project,e,`description`,{from:t,to:r});let a=await n.run(`query`,`builtin/edit`,{task:e,field:`description`,from:t,to:r},{keepalive:i!==void 0});if(a===null)return U(n.project,e,`description`),c(null),_.hold(r),i===`hidden`?o(e=>e===null?e:{...e,start:r}):x();let s=ye(a,r);c(s===null?null:{theirs:s.theirs??``,mine:r}),s===null&&p(a)};Ee(e=>{a!==null&&a.text!==a.start&&g.current!==a.text&&(g.current=a.text,C(a.start,a.text,e))});let w=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{if(w.current)return;w.current=!0;let r=H(V(n.project,e,`description`),t);if(r===null)return U(n.project,e,`description`);o({start:r.from,text:r.to,revision:0}),C(r.from,r.to)},[]),(0,q.jsxs)(`section`,{className:`task-card__section`,children:[a===null?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`description__head`,children:[(0,q.jsx)(`h3`,{className:`task-card__heading`,children:y.card.description}),(0,q.jsx)(l,{tip:y.card.edit.describe.editTip,inline:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`task-card__ghost description__edit`,onClick:b,children:y.card.edit.describe.edit})})]}),(0,q.jsx)(`div`,{className:`description__view`,onDoubleClick:b,children:v.trim()===``?(0,q.jsx)(`p`,{className:`placeholder`,children:y.card.noDescription}):i(v)})]}):(0,q.jsx)(G.Suspense,{fallback:(0,q.jsx)(ne,{busy:!0,label:y.card.loading,fit:`block`,children:null}),children:(0,q.jsx)(We,{start:a.start,text:a.text,revision:a.revision,busy:n.busy,failure:f,limit:(m?.config.shared.attachmentLimit??25)*1024*1024,onText:e=>o(t=>t===null?t:{...t,text:e}),onUpload:async t=>{let r=await h(e,t);return n.reload(),r},onSave:()=>void C(a.start,a.text),onClose:S})}),u!==null&&(0,q.jsx)(Ke,{text:u,canPutBack:a!==null&&a.text!==u,onPutBack:()=>o(e=>e===null?e:{...e,text:u,revision:e.revision+1})}),s!==null&&(0,q.jsx)(qe,{theirs:s.theirs,mine:s.mine,busy:n.busy,onKeep:()=>void C(s.theirs,s.mine),onTake:()=>{U(n.project,e,`description`),d(s.mine),o(e=>({start:s.theirs,text:s.theirs,revision:(e?.revision??0)+1})),c(null),n.settle()}})]})}function Ke({text:e,canPutBack:t,onPutBack:n}){let[r,i]=(0,G.useState)(!1),a=typeof navigator<`u`&&navigator.clipboard!==void 0,o=(0,G.useRef)(void 0);return(0,G.useEffect)(()=>()=>clearTimeout(o.current),[]),(0,q.jsxs)(`div`,{className:`description__kept`,children:[(0,q.jsxs)(`div`,{className:`description__kept-head`,children:[(0,q.jsx)(`strong`,{children:y.card.edit.describe.mine}),(0,q.jsx)(`span`,{className:`description__hint`,children:y.card.edit.describe.mineHint}),(0,q.jsx)(`span`,{className:`description__spacer`}),a&&(0,q.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>void navigator.clipboard.writeText(e).then(()=>{i(!0),clearTimeout(o.current),o.current=setTimeout(()=>i(!1),2e3)}),children:r?y.card.edit.describe.copied:y.card.edit.describe.copy}),t&&(0,q.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:n,children:y.card.edit.describe.putBack})]}),(0,q.jsx)(`pre`,{className:`description__kept-text`,children:e})]})}function qe({theirs:e,mine:t,busy:n,onKeep:r,onTake:i}){let a=(0,G.useRef)(null),o=_(a,i),s=(0,G.useId)(),c=I(e,t),l=c.filter(e=>e.kind===`removed`||e.kind===`changed`).length;return(0,G.useEffect)(()=>{a.current?.open===!1&&a.current.showModal()},[]),(0,q.jsx)(`dialog`,{ref:a,className:`add-package description__conflict`,"aria-labelledby":s,onCancel:e=>{e.preventDefault(),e.stopPropagation(),i()},...o,children:(0,q.jsxs)(`div`,{className:`add-package__frame`,children:[(0,q.jsx)(`header`,{className:`add-package__head`,children:(0,q.jsx)(`h2`,{id:s,className:`add-package__title`,children:y.card.edit.describe.conflictTitle})}),(0,q.jsxs)(`div`,{className:`add-package__body`,children:[(0,q.jsx)(`p`,{className:`add-package__question`,children:y.card.edit.describe.overwritten(l)}),(0,q.jsx)(`p`,{className:`description__hint`,children:y.card.edit.describe.conflictLegend}),(0,q.jsx)(`div`,{className:`description__diff`,role:`document`,"aria-label":y.card.edit.describe.conflictTitle,tabIndex:0,children:(0,q.jsx)(O,{lines:c})})]}),(0,q.jsxs)(`footer`,{className:`add-package__foot`,children:[(0,q.jsx)(`span`,{className:`add-package__spacer`}),(0,q.jsx)(`button`,{type:`button`,className:`button`,disabled:n,onClick:i,children:y.card.edit.takeNew}),(0,q.jsx)(`button`,{type:`button`,className:`button button--primary`,disabled:n,onClick:r,children:y.card.edit.keepMine})]})]})})}var Je=new Set([`question`,`excluded`]);function Ye({task:e,project:n,link:i,tracker:a,refused:o,work:s,live:c,onOpen:l,onClose:d}){let{card:f,state:p}=r(),[h,g]=(0,G.useState)(()=>ae(n,e)),[v,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(0),[C,w]=(0,G.useState)(!1),T=d,E=(0,G.useRef)(null),D=(0,G.useRef)(null),O=_(E,T),k=()=>S(e=>e+1),A=Ue(n,e,k),j=h?.edit==null?null:h,M=p!==null&&u(p.chain,n)?.current?.task===e,N=h===void 0&&v===null,P=ee(N),I=N||P!==`done`;F(D,I?null:h?.id??e);let L=JSON.stringify(p?.tasks.filter(t=>t.project===n&&(t.id===e||t.parent===e))??null),z=(0,G.useRef)(L);(0,G.useEffect)(()=>{z.current!==L&&(z.current=L,j!==null&&k())},[L]),(0,G.useEffect)(()=>{E.current?.open===!1&&E.current.showModal(),D.current?.focus()},[]);let B=(0,G.useRef)({project:n,task:e});return(0,G.useEffect)(()=>{(B.current.project!==n||B.current.task!==e)&&(B.current={project:n,task:e},g(ae(n,e)))},[n,e]),(0,G.useEffect)(()=>{let r=!0;return b(null),f(e).then(t=>{oe(n,e,t),r&&g(t)},e=>r&&b(t(e))),()=>{r=!1}},[n,e,x]),(0,q.jsxs)(`dialog`,{ref:E,className:`task-card`,"data-restorable":!0,"aria-label":e,onCancel:e=>{e.preventDefault(),T()},...O,children:[(0,q.jsxs)(`div`,{ref:D,className:`task-card__frame${I?` task-card__frame--reading`:``}`,tabIndex:-1,children:[(0,q.jsxs)(`header`,{className:`task-card__head`,children:[(0,q.jsx)(`span`,{className:`task-card__key`,children:e}),j===null?h!=null&&(0,q.jsx)(re,{status:h.status}):(0,q.jsx)(ke,{card:j,editor:A,refused:o,live:c}),(0,q.jsx)(`span`,{className:`task-card__spacer`}),j!==null&&(0,q.jsx)(R,{label:y.card.edit.more,items:[{label:y.card.edit.remove,danger:!0,problem:Xe(be(e,M,c)),pick:()=>w(!0)}]}),i!==null&&j===null&&(0,q.jsxs)(`a`,{href:i,className:`task-card__link`,target:`_blank`,rel:`noreferrer`,children:[y.card.openIn(a),` `,(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]}),(0,q.jsx)(`button`,{type:`button`,className:`task-card__close`,"aria-label":y.card.close,title:y.card.close,onClick:T,children:`×`})]}),(0,q.jsx)(`div`,{className:`task-card__body`,children:I?(0,q.jsx)(te,{phase:P===`done`?`in`:P,label:y.card.loading,fit:`fill`}):(0,q.jsxs)(q.Fragment,{children:[v!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(v)}),h===null&&(0,q.jsx)(`p`,{className:`placeholder task-card__empty`,children:y.card.none}),h!=null&&(0,q.jsx)(et,{card:h,project:n,editor:j===null?null:A,inWork:M||c,refused:o,work:s,live:c,onOpen:l,onChanged:k})]})})]}),A.conflict!==null&&(0,q.jsx)(Qe,{editor:A,conflict:A.conflict}),C&&j!==null&&(0,q.jsx)($e,{card:j,editor:A,onClose:()=>w(!1),onRemoved:()=>{w(!1),d()}})]})}var Xe=e=>e===null?void 0:m(e);function Ze(e,t){return t===null||t===``?y.card.edit.empty:e===`priority`&&t in y.card.priorities?y.card.priorities[t]:t}function Qe({editor:e,conflict:t}){return(0,q.jsx)(C,{title:y.card.edit.conflictTitle,question:y.card.edit.conflictQuestion(y.card.edit.fields[t.field]??t.field,Ze(t.field,t.theirs),Ze(t.field,t.mine)),confirm:y.card.edit.keepMine,cancel:y.card.edit.takeNew,busy:e.busy,safe:!0,onConfirm:t.keep,onClose:e.settle})}function $e({card:e,editor:t,onClose:n,onRemoved:r}){let[i,a]=(0,G.useState)(null);return(0,q.jsx)(C,{title:y.card.edit.removeTitle(e.id),question:y.card.edit.removeQuestion((e.subtasks??[]).map(e=>e.id).join(`, `)),confirm:y.card.edit.removeConfirm,cancel:y.card.edit.cancel,busy:t.busy,failure:i===null?void 0:m(i),onConfirm:()=>void t.run(`query`,`builtin/delete`,{task:e.id}).then(e=>e===null?r():a(e)),onClose:n})}function et({card:e,project:t,editor:n,inWork:i,refused:o,work:s,live:c,onOpen:u,onChanged:d}){let{send:f,sending:g,failure:_}=a(),{state:v}=r(),b=e=>y.card.roles[e],x=ce(u,e.attachments),S=e.labels.filter(e=>Je.has(e.role)),C=e.labels.filter(e=>e.role!==null&&!Je.has(e.role)),w=n!==null&&e.edit!==null?{card:e,editor:n}:null,T=ue(e.estimate,e.activeS);return(0,q.jsxs)(q.Fragment,{children:[w!==null&&(0,q.jsx)(Ne,{ancestors:w.card.edit.ancestors,onOpen:u}),w===null?(0,q.jsx)(`h2`,{className:`task-card__title`,children:e.title}):(0,q.jsx)(De,{card:e,editor:w.editor},`title:${e.id}`),(0,q.jsxs)(`div`,{className:`task-card__layout`,children:[(0,q.jsxs)(`div`,{className:`task-card__main`,children:[(S.length>0||e.requires.length>0||s!==null)&&(0,q.jsxs)(`div`,{className:`task-card__callouts`,children:[s!==null&&(0,q.jsxs)(`div`,{className:`task-card__callout task-card__callout--work`,children:[(0,q.jsx)(`strong`,{children:y.card.work}),L(s).map(e=>(0,q.jsx)(`span`,{className:`task-card__work-line`,children:e},e)),(0,q.jsx)(`span`,{className:`task-card__work-fix`,children:y.chain.work.fix})]}),S.map(e=>(0,q.jsxs)(`p`,{className:`task-card__callout task-card__callout--${e.role}`,children:[(0,q.jsx)(`strong`,{children:e.name}),(0,q.jsx)(`span`,{children:y.card.roles[e.role]})]},e.name)),e.requires.length>0&&(0,q.jsx)(`p`,{className:`task-card__callout task-card__callout--question`,children:(0,q.jsx)(`span`,{children:y.card.requires(e.requires.join(`, `))})})]}),w===null?(0,q.jsxs)(`section`,{className:`task-card__section`,children:[(0,q.jsx)(`h3`,{className:`task-card__heading`,children:y.card.description}),e.description.trim()===``?(0,q.jsx)(`p`,{className:`placeholder`,children:y.card.noDescription}):(0,q.jsx)(W,{components:x,children:e.description})]}):(0,q.jsx)(Ge,{task:e.id,text:e.description,editor:w.editor,render:e=>(0,q.jsx)(W,{components:x,children:e})},`description:${e.id}`),(0,q.jsx)(Fe,{card:e,project:t,adding:w,inWork:i,onOpen:u}),(0,q.jsx)(se,{task:e.id,comments:e.comments,editor:w?.editor??null,render:e=>(0,q.jsx)(W,{components:x,children:e})},`journal:${e.id}`)]}),(0,q.jsxs)(`aside`,{className:`task-card__side`,children:[e.ready&&w===null&&(0,q.jsx)(nt,{hint:y.card.readyHint,problem:o===null?null:y.chain.readyRefused(m(o)),children:(0,q.jsx)(`button`,{type:`button`,className:`button button--primary`,disabled:g||o!==null,onClick:()=>void f(`task/ready`,{task:e.id}).then(e=>e&&d()),children:y.card.ready})}),e.unready&&!c&&w===null&&(0,q.jsx)(nt,{hint:y.card.unreadyHint,problem:null,children:(0,q.jsx)(`button`,{type:`button`,className:`button`,disabled:g,onClick:()=>void f(`task/unready`,{task:e.id}).then(e=>e&&d()),children:y.card.unready})}),_!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(_)}),w?.editor.failure!=null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(w.editor.failure)}),T!==null&&(0,q.jsxs)(h,{className:`task-card__facts`,children:[(0,q.jsx)(p,{label:y.card.estimate,children:(0,q.jsx)(`dd`,{children:T.estimate})}),(0,q.jsx)(p,{label:y.card.time,tone:T.over?`warn`:`ok`,children:(0,q.jsx)(`dd`,{children:(0,q.jsx)(l,{tip:y.card.timeTip,inline:!0,focusable:!0,children:T.time})})})]}),(0,q.jsxs)(`dl`,{className:`task-card__props`,children:[(0,q.jsx)($,{name:y.card.priority,children:w===null?(0,q.jsxs)(`span`,{className:`task-card__priority task-card__priority--${e.priority}`,children:[(0,q.jsx)(D,{priority:e.priority}),y.card.priorities[e.priority]]}):(0,q.jsx)(Ae,{card:e,editor:w.editor})}),(0,q.jsx)($,{name:y.card.milestone,children:w===null?e.milestones===null?e.milestone===null?(0,q.jsx)(`span`,{className:`task-card__none`,children:y.card.noMilestone}):(0,q.jsxs)(`span`,{className:`task-card__milestone`,children:[e.milestone.label,e.milestone.targetDate?(0,q.jsx)(`small`,{children:y.card.due(Z().format(e.milestone.targetDate))}):null]}):(0,q.jsx)(tt,{task:e.id,pick:e.milestones,onChanged:d}):(0,q.jsx)(je,{card:w.card,editor:w.editor})}),(0,q.jsx)(He,{task:e.id,live:c,onChanged:d}),w===null?e.parent!==null&&(0,q.jsx)($,{name:y.card.parent,children:(0,q.jsx)(J,{item:e.parent,onOpen:u})}):(0,q.jsx)($,{name:y.card.parent,wide:w.card.parent!==null,children:(0,q.jsx)(Pe,{card:w.card,project:t,editor:w.editor,onOpen:u})}),(e.labels.length>0||w!==null)&&(0,q.jsxs)($,{name:y.card.labels,wide:!0,children:[w===null?(0,q.jsx)(`ul`,{className:`task-card__chips`,children:e.labels.map(e=>(0,q.jsx)(`li`,{className:e.role===null?`tag`:`chip task-card__chip--${e.role}`,title:e.role===null?void 0:b(e.role),children:e.name},e.name))}):(0,q.jsx)(Me,{card:w.card,editor:w.editor,roleText:b}),C.length>0&&(0,q.jsx)(`ul`,{className:`task-card__roles`,children:C.map(e=>(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`strong`,{children:e.name}),` — `,b(e.role)]},e.name))})]})]}),e.attachments.length>0&&(0,q.jsx)(ie,{task:e.id,items:e.attachments,editor:w?.editor??null}),(0,q.jsx)(we,{card:e,editor:w?.editor??null,onOpen:u})]})]})]})}function tt({task:e,pick:t,onChanged:n}){let{send:r,sending:i,failure:o}=a(),[s,c]=(0,G.useState)(t.current??``);(0,G.useEffect)(()=>c(t.current??``),[t.current]);let l=t.choices.find(e=>e.id===s),u=[{value:``,label:y.card.noMilestone},...t.choices.map(e=>({value:e.id,label:e.label}))];return(0,q.jsxs)(`div`,{className:`task-card__milestone`,children:[(0,q.jsx)(E,{className:`task-card__milestone-pick`,label:y.card.milestone,value:s,options:u,disabled:i,onChange:i=>{c(i),r(`task/milestone`,{task:e,milestone:i===``?null:i}).then(e=>e?n():c(t.current??``))}}),l?.targetDate?(0,q.jsx)(`small`,{children:y.card.due(Z().format(l.targetDate))}):null,o!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(o)})]})}function nt({hint:e,problem:t,children:n}){return(0,q.jsxs)(`div`,{className:`task-card__ready`,children:[(0,q.jsx)(A,{action:n,label:y.card.actionHelp,tip:e}),t!==null&&(0,q.jsx)(`p`,{className:`task-card__hint`,children:t})]})}function $({name:e,children:t,wide:n=!1}){return(0,q.jsxs)(`div`,{className:`task-card__prop${n?` task-card__prop--wide`:``}`,children:[(0,q.jsx)(`dt`,{children:e}),(0,q.jsx)(`dd`,{children:t})]})}export{Ye as TaskCard};
2
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ei as t,Jn as n,Lr as r,Ot as i,Pr as a,Rr as o,Sr as s,Ti as c,Xt as l,an as u,en as d,ki as f,o as p,pi as m,s as h,ui as g,v as _,vr as v,xi as y,y as b}from"./blocks-CiOz7u_W.js";import{et as x,p as S,u as C}from"./lib-DnFFmOv9.js";import{a as w,s as T}from"./rules-DLe7kZM5.js";import{t as E}from"./Select-NXi_Bsw-.js";import{T as D,_ as O,f as k,g as A,h as j,n as M,o as N,r as P,t as F,v as I,x as L,y as R}from"./useHeightGlide-BPjzH9PL.js";import{S as z,a as B,c as ee,i as V,o as te,r as H,s as ne,t as U}from"./cardDrafts-CyzO-ro7.js";import{c as re,i as ie,l as W,o as ae,s as oe,t as se,u as ce}from"./cardSide-CSmytank.js";/* empty css */var G=e(f(),1),le=1.5;function ue(e,t){let n=e??null,r=t??null;return n===null&&r===null?null:{estimate:S(n===null?null:n*60),time:S(r),over:n!==null&&r!==null&&r>n*60*le}}function de(e,t){return e.category===`UnStarted`&&t.category===`ToDo`?`ready`:(e.category===`ToDo`||e.category===`Active`)&&t.category===`UnStarted`?`unready`:`edit`}var K=e=>e.category===`Won`||e.category===`Lost`;function fe(e,t,n){return n===e.id?c(`builtin.selfLink`,{task:e.id}):(t===`blocks`?e.blocks:t===`blockedBy`?e.blockedBy:e.related).some(e=>e.id===n)?c(`builtin.linkExists`,{task:e.id,other:n}):null}function pe(e,t,n){return t===`blockedBy`?{task:n,other:e,kind:`blocks`}:{task:e,other:n,kind:t}}function me(e,t,n){return n===e?c(`builtin.selfParent`,{task:e}):t.some(e=>e.id===n)?c(`builtin.parentCycle`,{task:e,parent:n}):null}function he(e,t){let n=e=>{let n=t.indexOf(e);return n<0?2**53-1:n},r=e=>Number(e.slice(e.lastIndexOf(`-`)+1));return[...e].sort((e,t)=>n(e.id)-n(t.id)||r(e.id)-r(t.id))}function ge(e,t,n){let r=(e,t)=>e.trim().toLocaleLowerCase()===t.trim().toLocaleLowerCase(),i=e.filter(e=>!t.some(t=>r(t,e.name))).map(e=>({...e,create:!1})),a=n.trim();return a===``||e.some(e=>r(e.name,a))||t.some(e=>r(e,a))?i:[...i,{name:a,builtin:!1,create:!0}]}function _e(e,t){return!w(e,{milestone:{label:t,targetDate:null}})}function ve(e,t){return e.filter(e=>!K(e.status)&&(e.milestone??null)?.toLocaleLowerCase()!==t?.toLocaleLowerCase())}function ye(e,t){return e?.code===`builtin.conflict`?{field:e.params.field,theirs:e.params.current,mine:t}:null}function be(e,t,n){return t?c(`builtin.removeBusy`,{task:e,why:`current`}):n?c(`builtin.removeBusy`,{task:e,why:`live`}):null}var q=o(),xe=150;function J({item:e,onOpen:t}){if(e.moved===void 0)return(0,q.jsx)(Se,{item:e,onOpen:t});let{key:n,url:r}=e.moved;return(0,q.jsxs)(`span`,{className:`task-card__moved-ref`,children:[(0,q.jsx)(Se,{item:e,onOpen:t}),(0,q.jsxs)(`span`,{className:`task-card__moved`,children:[y.transfer.movedTo,` `,r===null?n:(0,q.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,children:n})]})]})}function Se({item:e,onOpen:t}){return(0,q.jsxs)(`button`,{type:`button`,className:`task-card__ref task-card__ref--${e.status.category}`,title:e.status.name,onClick:()=>t(e.id),children:[(0,q.jsx)(`span`,{className:`task-card__status task-card__status--${e.status.category} task-card__status--bare`,children:(0,q.jsx)(`span`,{className:`task-card__dot`})}),(0,q.jsx)(`span`,{className:`task-card__ref-key`,children:e.id}),(0,q.jsx)(`span`,{className:`task-card__ref-title`,children:e.title})]})}function Ce({project:e,label:t,refusal:n,onPick:i,onClose:a,focus:o=!0}){let{query:s}=r(),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)([]),f=(0,G.useRef)(null);return(0,G.useEffect)(()=>{o&&f.current?.querySelector(`input`)?.focus()},[o]),(0,G.useEffect)(()=>{let t=!0,n=setTimeout(()=>{s(`builtin/search`,{text:c,project:e}).then(e=>t&&d(e),()=>t&&d([]))},xe);return()=>{t=!1,clearTimeout(n)}},[c,e]),(0,q.jsx)(`div`,{ref:f,className:`task-card__search`,children:(0,q.jsx)(b,{error:n,wide:!0,children:(0,q.jsx)(T,{className:`task-card__field`,label:t,placeholder:y.card.edit.findTask,value:c,options:u.map(e=>({value:e.id,label:e.moved===void 0?e.title:`${e.title} · ${y.transfer.movedTo} ${e.moved.key}`})),invalid:n!==null,onChange:l,onPick:i,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a())}})})})}function we({card:e,editor:t,onOpen:n}){let[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(`blocks`),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(null);(0,G.useEffect)(()=>{r&&u.current?.querySelector(`button`)?.focus()},[r]);let d=[...e.blockedBy,...e.blocks,...e.related];if(d.length===0&&t===null)return null;let f={"--ref-key":`${Math.max(0,...d.map(e=>e.id.length))}ch`},p=async n=>{let r=fe(e,o,n)??await t.run(`query`,`builtin/relate`,pe(e.id,o,n));l(r),r===null&&a(!1)},m=(n,r)=>t===null?void 0:()=>void t.call(`query`,`builtin/unrelate`,pe(e.id,n,r));return(0,q.jsxs)(`div`,{className:`task-card__relations`,style:f,children:[(0,q.jsx)(Y,{title:y.card.blockedBy,items:e.blockedBy,onOpen:n,onRemove:e=>m(`blockedBy`,e)}),(0,q.jsx)(Y,{title:y.card.blocks,items:e.blocks,onOpen:n,onRemove:e=>m(`blocks`,e)}),(0,q.jsx)(Y,{title:y.card.related,items:e.related,onOpen:n,onRemove:e=>m(`relates`,e)}),t!==null&&(r?(0,q.jsxs)(`div`,{ref:u,className:`task-card__link-add`,children:[(0,q.jsx)(E,{className:`task-card__field`,label:y.card.edit.linkKind,value:o,options:[`blocks`,`blockedBy`,`relates`].map(e=>({value:e,label:y.card.edit.kinds[e]})),onChange:e=>{s(e),l(null)}}),(0,q.jsx)(Ce,{project:null,label:y.card.edit.addLink,refusal:c,onPick:e=>void p(e),onClose:()=>{a(!1),l(null)},focus:!1})]}):(0,q.jsxs)(`button`,{type:`button`,className:`task-card__ghost`,onClick:()=>a(!0),children:[(0,q.jsx)(i,{}),y.card.edit.addLink]}))]})}function Y({title:e,items:t,onOpen:n,onRemove:r}){return t.length===0?null:(0,q.jsxs)(`section`,{className:`task-card__group`,children:[(0,q.jsxs)(`h3`,{className:`task-card__heading`,children:[e,` `,(0,q.jsx)(`span`,{className:`task-card__count`,children:t.length})]}),(0,q.jsx)(`ul`,{className:`task-card__refs`,children:t.map(e=>{let t=r(e.id);return(0,q.jsxs)(`li`,{className:t===void 0?void 0:`task-card__ref-row`,children:[(0,q.jsx)(J,{item:e,onOpen:n}),t!==void 0&&(0,q.jsx)(X,{label:y.card.edit.unlink(e.id),onPress:t})]},e.id)})})]})}function X({label:e,onPress:t,disabled:n=!1}){return(0,q.jsx)(`button`,{type:`button`,className:`task-card__remove`,"aria-label":e,title:e,disabled:n,onClick:t,children:`×`})}function Te(e){let[t,n]=(0,G.useState)(null);return(0,G.useEffect)(()=>{t!==null&&t.from!==e&&n(null)},[e,t]),{shown:t!==null&&t.from===e?t.to:e,hold:t=>n({from:e,to:t}),release:()=>n(null)}}function Ee(e){let t=(0,G.useRef)(e);t.current=e,(0,G.useEffect)(()=>{let e=()=>document.visibilityState===`hidden`&&t.current(`hidden`),n=()=>t.current(`hidden`);return document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,n),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,n),t.current(`unmount`)}},[])}var Z=g(e=>new Intl.DateTimeFormat(e,{day:`numeric`,month:`short`,year:`numeric`}));function De({card:e,editor:t}){let[n,r]=(0,G.useState)(null),i=(0,G.useRef)(null),a=e=>{i.current=e,r(e)},o=Te(e.title),s=async(n,r,i)=>{o.hold(r);let a=await t.edit(`title`,n,r,{...i,kept:!0,task:e.id});return a!==`landed`&&o.release(),a},c=async()=>{let e=i.current?.trim()??``;a(null),e!==``&&e!==o.shown&&await s(o.shown,e,{keepalive:!0})};Ee(()=>void c());let l=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{if(l.current)return;l.current=!0;let n=H(V(t.project,e.id,`title`),e.title);if(n===null)return U(t.project,e.id,`title`);s(n.from,n.to,{}).then(e=>e===`refused`&&a(n.to))},[]),n===null?(0,q.jsx)(`h2`,{className:`task-card__title`,children:(0,q.jsx)(`button`,{type:`button`,className:`task-card__title-edit`,title:y.card.edit.titleHint,onClick:()=>a(o.shown),children:o.shown})}):(0,q.jsx)(`h2`,{className:`task-card__title`,children:(0,q.jsx)(`input`,{className:`task-card__title-input`,autoComplete:`off`,"aria-label":y.card.edit.title,value:n,autoFocus:!0,disabled:t.busy,onChange:e=>a(e.target.value),onKeyDown:n=>{n.key===`Enter`?(n.preventDefault(),c()):n.key===`Escape`&&(n.preventDefault(),n.stopPropagation(),U(t.project,e.id,`title`),a(null))},onBlur:()=>void c()})})}function Oe({status:e}){return(0,q.jsx)(`span`,{className:`task-card__status task-card__status--${e.category} task-card__status--bare`,children:(0,q.jsx)(`span`,{className:`task-card__dot`})})}function ke({card:e,editor:t,refused:n,live:r}){let i=e.status,a=e=>{let t=de(i,e);if(t===`unready`&&r)return y.card.edit.liveBacklog;if(t===`ready`&&n!==null)return y.chain.readyRefused(m(n))};return(0,q.jsx)(E,{className:`task-card__status-pick task-card__status--${i.category}`,label:y.card.edit.status,value:i.name,disabled:t.busy,options:e.edit.statuses.map(e=>({value:e.name,label:e.name,icon:(0,q.jsx)(Oe,{status:e}),unavailable:a(e)})),onChange:n=>{let r=e.edit.statuses.find(e=>e.name===n);if(r===void 0||r.name===i.name)return;let a=de(i,r);a===`edit`?t.edit(`status`,i.name,r.name):t.call(`command`,a===`ready`?`task/ready`:`task/unready`,{task:e.id})}})}function Ae({card:e,editor:t}){return(0,q.jsx)(E,{className:`task-card__field task-card__field--quiet`,label:y.card.priority,value:e.priority,disabled:t.busy,options:v.map(e=>({value:e,label:y.card.priorities[e],icon:(0,q.jsx)(D,{priority:e})})),onChange:n=>n!==e.priority&&void t.edit(`priority`,e.priority,n)})}var Q=(e,t)=>(e??``).toLocaleLowerCase()===(t??``).toLocaleLowerCase();function je({card:e,editor:t}){let n=e.milestone?.label??null,[r,i]=(0,G.useState)(n??``),[a,o]=(0,G.useState)(null);(0,G.useEffect)(()=>i(n??``),[n]);let s=e.milestones?.choices??[],c=r.trim(),l=s.map(e=>({value:e.label,label:e.targetDate?y.card.due(Z().format(e.targetDate)):void 0}));c!==``&&!s.some(e=>Q(e.label,c))&&l.push({value:c,label:y.card.edit.newMilestone});let u=async r=>{let a=r.trim()===``?null:r.trim();if(Q(a,n))return i(n??``);let s=ve(e.subtasks??[],a);if(await t.edit(`milestone`,n,a)!==`landed`)return i(n??``);s.length>0&&o({to:a,children:s})},d=async()=>{let e=a;o(null);for(let n of e.children)await t.run(`query`,`builtin/edit`,{task:n.id,field:`milestone`,from:n.milestone,to:e.to})},f=s.find(e=>Q(e.label,n));return(0,q.jsxs)(`div`,{className:`task-card__milestone`,children:[(0,q.jsxs)(`div`,{className:`task-card__field-row`,children:[(0,q.jsx)(T,{className:`task-card__field task-card__field--quiet`,label:y.card.milestone,placeholder:y.card.noMilestone,value:r,options:l,disabled:t.busy,onChange:i,onPick:e=>void u(e),onKeyDown:e=>{e.key===`Enter`&&u(r)}}),n!==null&&(0,q.jsx)(X,{label:y.card.edit.clearMilestone,disabled:t.busy,onPress:()=>void u(``)})]}),f?.targetDate?(0,q.jsx)(`small`,{children:y.card.due(Z().format(f.targetDate))}):null,n!==null&&_e(e.edit.milestoneRules,n)&&(0,q.jsx)(`p`,{className:`task-card__run-note task-card__run-note--warn`,children:y.card.edit.foreignMilestone}),a!==null&&(0,q.jsx)(C,{title:y.card.edit.carryTitle,question:y.card.edit.carryQuestion(a.children.length,a.to),confirm:y.card.edit.carry,cancel:y.card.edit.carryNo,busy:t.busy,safe:!0,onConfirm:()=>void d(),onClose:()=>o(null)})]})}function Me({card:e,editor:t,roleText:n}){let[r,i]=(0,G.useState)(``),a=e.labels.map(e=>e.name),o=ge(e.edit.labels,a,r).map(e=>({value:e.name,label:e.create?y.card.edit.newLabel:e.builtin?y.card.edit.meanings[e.name.toLocaleLowerCase()]:void 0})),s=async n=>{let r=n.trim();r===``||a.some(e=>Q(e,r))||await t.call(`query`,`builtin/labels`,{task:e.id,add:[r]})&&i(``)};return(0,q.jsxs)(`div`,{className:`task-card__labels`,children:[e.labels.length>0&&(0,q.jsx)(`ul`,{className:`task-card__chips`,children:e.labels.map(r=>(0,q.jsxs)(`li`,{className:`${r.role===null?`tag`:`chip task-card__chip--${r.role}`} task-card__chip-edit`,title:r.role===null?void 0:n(r.role),children:[r.name,(0,q.jsx)(X,{label:y.card.edit.removeLabel(r.name),disabled:t.busy,onPress:()=>void t.call(`query`,`builtin/labels`,{task:e.id,remove:[r.name]})})]},r.name))}),(0,q.jsx)(T,{className:`task-card__field`,label:y.card.edit.addLabel,placeholder:y.card.edit.addLabel,value:r,options:o,disabled:t.busy,onChange:i,onPick:e=>void s(e),onKeyDown:e=>{e.key===`Enter`&&s(r)}})]})}function Ne({ancestors:e,onOpen:t}){return e.length===0?null:(0,q.jsx)(`nav`,{className:`task-card__path`,"aria-label":y.card.edit.path,children:(0,q.jsx)(`ol`,{children:e.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,className:`task-card__path-step`,title:e.title,onClick:()=>t(e.id),children:[(0,q.jsx)(`span`,{className:`task-card__ref-key`,children:e.id}),(0,q.jsx)(`span`,{className:`task-card__path-title`,children:e.title})]})},e.id))})})}function Pe({card:e,project:t,editor:n,onOpen:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),c=e.parent?.id??null,l=()=>{a(!1),s(null)},u=async t=>{let r=me(e.id,e.subtasks??[],t);if(r!==null)return s(r);if(t===c)return l();let i=await n.run(`query`,`builtin/edit`,{task:e.id,field:`parent`,from:c,to:t});i===null?l():s(i)};return i?(0,q.jsx)(Ce,{project:t,label:y.card.edit.changeParent,refusal:o,onPick:e=>void u(e),onClose:l}):e.parent===null?(0,q.jsx)(`button`,{type:`button`,className:`task-card__ghost task-card__ghost--inline`,onClick:()=>a(!0),children:y.card.edit.setParent}):(0,q.jsxs)(`div`,{className:`task-card__parent`,children:[(0,q.jsxs)(`div`,{className:`task-card__ref-row`,children:[(0,q.jsx)(J,{item:e.parent,onOpen:r}),(0,q.jsx)(X,{label:y.card.edit.dropParent,disabled:n.busy,onPress:()=>void n.edit(`parent`,c,null)})]}),(0,q.jsx)(`button`,{type:`button`,className:`task-card__ghost`,disabled:n.busy,onClick:()=>a(!0),children:y.card.edit.changeParent})]})}function Fe({card:e,project:t,adding:n,inWork:i,onOpen:a}){let{state:o}=r(),s=e.subtasks??[],c=n!==null&&!K(e.status)?n:null;if(s.length===0&&c===null)return null;let l=o?.chain.projects[t]?.order??[],u=s.filter(e=>K(e.status)).length;return(0,q.jsxs)(`section`,{className:`task-card__section`,children:[(0,q.jsx)(`h3`,{className:`task-card__heading`,children:y.card.edit.subtasks(u,s.length)}),s.length>0&&(0,q.jsx)(`ul`,{className:`task-card__refs task-card__subtasks`,children:he(s,l).map(e=>(0,q.jsxs)(`li`,{className:`task-card__subtask`,children:[(0,q.jsx)(J,{item:e,onOpen:a}),(0,q.jsx)(`span`,{className:`task-card__subtask-status task-card__status--${e.status.category}`,children:e.status.name})]},e.id))}),c!==null&&(0,q.jsx)(Ie,{card:c.card,project:t,editor:c.editor,confirmFirst:i&&s.length===0})]})}function Ie({card:e,project:t,editor:n,confirmFirst:r}){let[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),d=async r=>{let i=await n.run(`query`,`builtin/create`,{project:t,title:r,parent:e.id,milestone:e.milestone?.label??null,status:`Todo`});u(i),i===null&&o(``)};return a===null?(0,q.jsxs)(`button`,{type:`button`,className:`task-card__ghost`,onClick:()=>o(``),children:[(0,q.jsx)(i,{}),y.card.edit.addSubtask]}):(0,q.jsxs)(`div`,{className:`task-card__add`,children:[(0,q.jsx)(`input`,{className:`task-card__field`,autoComplete:`off`,"aria-label":y.card.edit.subtaskTitle,placeholder:y.card.edit.subtaskTitle,value:a,autoFocus:!0,disabled:n.busy,"aria-invalid":l!==null||void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=a?.trim()??``;if(t===``)return;r?c(!0):d(t)}else e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),o(null),u(null))}}),l!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(l)}),s&&(0,q.jsx)(C,{title:y.card.edit.firstTitle,question:y.card.edit.firstQuestion(e.id),confirm:y.card.edit.firstConfirm,cancel:y.card.edit.cancel,busy:n.busy,safe:!0,onConfirm:()=>{c(!1),d(a.trim())},onClose:()=>c(!1)})]})}function Le(e){return{provider:e?.provider??``,model:e?.model??``,effort:e?.effort??``}}function Re(e,t){return s[e===``?t:e]??[]}function ze(e,t,n,r={}){return t===e.provider?e:{provider:t,model:r[t]??``,effort:Re(t,n).includes(e.effort)?e.effort:``}}function Be(e,t){return t.provider===``||e[t.provider]===t.model?e:{...e,[t.provider]:t.model}}function Ve(e,t){let n=t.model.trim(),r={provider:t.provider===``?null:t.provider,model:t.provider===``||n===``?null:n,effort:t.effort===``?null:t.effort};return z(e,r)?null:r}function He({task:e,live:t,onChanged:i}){let{state:o}=r(),{send:s,sending:c,failure:l}=a(),u=n(o,e),f=o?.runs?.[u]?.[e],p=Le(f),[h,g]=(0,G.useState)(p),[_,v]=(0,G.useState)({});(0,G.useEffect)(()=>g(p),[`${p.provider}|${p.model}|${p.effort}`]);let b=o?.config.shared,S=o?.config.projects[u],C=S?.provider??b?.provider??``,w=h.provider===``?``:(S?.accounts[h.provider]||b?.accounts[h.provider])??``,D=P([w]),O=N(o?.account,w),A=h.provider===``?``:d(S?.models??{},h.provider,O)||d(b?.models??{},h.provider,O)||y.settings.cliDefault,j=e=>{let t=Be(_,h);v(t),g(ze(h,e,C,t))},F=Ve(f,h),I=x(o?.account??null,[p.provider,h.provider]),L=Re(h.provider,C),R=()=>{F===null||c||s(`task/run`,{task:e,...F}).then(e=>e&&i())};return(0,q.jsxs)(`div`,{className:`task-card__prop task-card__prop--wide`,children:[(0,q.jsxs)(`dt`,{className:`task-card__prop-head`,children:[y.card.run.title,F!==null&&(0,q.jsx)(`button`,{type:`button`,className:`button button--small task-card__run-save`,disabled:c,onClick:R,children:y.card.run.save})]}),(0,q.jsxs)(`dd`,{className:`task-card__run`,children:[(0,q.jsx)(E,{className:`task-card__field`,label:y.card.run.provider,value:h.provider,options:[{value:``,label:y.card.run.asProject(k(C))},...I.map(e=>({value:e,label:k(e)}))],disabled:c,onChange:j}),h.provider!==``&&(0,q.jsx)(T,{className:`task-card__field`,label:y.card.run.model,value:h.model,options:M(D,w),placeholder:y.card.run.modelAsProject(A),disabled:c,onChange:e=>g({...h,model:e}),onKeyDown:e=>{e.key===`Enter`&&R()}}),L.length>0&&(0,q.jsx)(E,{className:`task-card__field`,label:y.card.run.effort,value:h.effort,options:[{value:``,label:y.card.run.effortNone},...L.map(e=>({value:e,label:y.card.run.effortOf(e)}))],disabled:c,onChange:e=>g({...h,effort:e})}),t&&F!==null&&(0,q.jsx)(`p`,{className:`task-card__run-note`,children:y.card.run.live}),l!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(l)})]})]})}function Ue(e,n,i){let{command:a,query:o}=r(),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),p=async(e,n,r,s)=>{c(!0);try{return await(e===`command`?a(n,r):o(n,r,s)),i(),null}catch(e){return t(e)}finally{c(!1)}},m=async(e,t,n)=>{u(null);let r=await p(e,t,n);return u(r),r===null},h=async(t,r,i,a={})=>{u(null);let o=a.task??n,s=a.kept===!0?t:null;s!==null&&B(e,o,s,{from:r??``,to:i??``});let c=await p(`query`,`builtin/edit`,{task:o,field:t,from:r,to:i},{keepalive:a.keepalive});if(c===null)return s!==null&&U(e,o,s),`landed`;let l=ye(c,i);return l===null?(u(c),`refused`):(f({...l,task:o,kept:s!==null,keep:()=>{f(null),h(t,l.theirs,i,{kept:s!==null,task:o})}}),`conflict`)};return{project:e,busy:s,failure:l,conflict:d,run:p,call:m,edit:h,settle:()=>{d?.kept===!0&&U(e,d.task,d.field),f(null),i()},reload:i}}var We=(0,G.lazy)(()=>j(()=>import(`./DescriptionEditor-DUSwRGCZ.js`).then(e=>({default:e.DescriptionEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])));function Ge({task:e,text:t,editor:n,render:i}){let[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),{state:m,attach:h}=r(),g=(0,G.useRef)(null),_=Te(t),v=_.shown,b=()=>{p(null),o({start:v,text:v,revision:0})},x=()=>{o(null),p(null)},S=()=>{U(n.project,e,`description`),x()},C=async(t,r,i)=>{if(r===t)return x();p(null),B(n.project,e,`description`,{from:t,to:r});let a=await n.run(`query`,`builtin/edit`,{task:e,field:`description`,from:t,to:r},{keepalive:i!==void 0});if(a===null)return U(n.project,e,`description`),c(null),_.hold(r),i===`hidden`?o(e=>e===null?e:{...e,start:r}):x();let s=ye(a,r);c(s===null?null:{theirs:s.theirs??``,mine:r}),s===null&&p(a)};Ee(e=>{a!==null&&a.text!==a.start&&g.current!==a.text&&(g.current=a.text,C(a.start,a.text,e))});let w=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{if(w.current)return;w.current=!0;let r=H(V(n.project,e,`description`),t);if(r===null)return U(n.project,e,`description`);o({start:r.from,text:r.to,revision:0}),C(r.from,r.to)},[]),(0,q.jsxs)(`section`,{className:`task-card__section`,children:[a===null?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`description__head`,children:[(0,q.jsx)(`h3`,{className:`task-card__heading`,children:y.card.description}),(0,q.jsx)(l,{tip:y.card.edit.describe.editTip,inline:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`task-card__ghost description__edit`,onClick:b,children:y.card.edit.describe.edit})})]}),(0,q.jsx)(`div`,{className:`description__view`,onDoubleClick:b,children:v.trim()===``?(0,q.jsx)(`p`,{className:`placeholder`,children:y.card.noDescription}):i(v)})]}):(0,q.jsx)(G.Suspense,{fallback:(0,q.jsx)(ne,{busy:!0,label:y.card.loading,fit:`block`,children:null}),children:(0,q.jsx)(We,{start:a.start,text:a.text,revision:a.revision,busy:n.busy,failure:f,limit:(m?.config.shared.attachmentLimit??25)*1024*1024,onText:e=>o(t=>t===null?t:{...t,text:e}),onUpload:async t=>{let r=await h(e,t);return n.reload(),r},onSave:()=>void C(a.start,a.text),onClose:S})}),u!==null&&(0,q.jsx)(Ke,{text:u,canPutBack:a!==null&&a.text!==u,onPutBack:()=>o(e=>e===null?e:{...e,text:u,revision:e.revision+1})}),s!==null&&(0,q.jsx)(qe,{theirs:s.theirs,mine:s.mine,busy:n.busy,onKeep:()=>void C(s.theirs,s.mine),onTake:()=>{U(n.project,e,`description`),d(s.mine),o(e=>({start:s.theirs,text:s.theirs,revision:(e?.revision??0)+1})),c(null),n.settle()}})]})}function Ke({text:e,canPutBack:t,onPutBack:n}){let[r,i]=(0,G.useState)(!1),a=typeof navigator<`u`&&navigator.clipboard!==void 0,o=(0,G.useRef)(void 0);return(0,G.useEffect)(()=>()=>clearTimeout(o.current),[]),(0,q.jsxs)(`div`,{className:`description__kept`,children:[(0,q.jsxs)(`div`,{className:`description__kept-head`,children:[(0,q.jsx)(`strong`,{children:y.card.edit.describe.mine}),(0,q.jsx)(`span`,{className:`description__hint`,children:y.card.edit.describe.mineHint}),(0,q.jsx)(`span`,{className:`description__spacer`}),a&&(0,q.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>void navigator.clipboard.writeText(e).then(()=>{i(!0),clearTimeout(o.current),o.current=setTimeout(()=>i(!1),2e3)}),children:r?y.card.edit.describe.copied:y.card.edit.describe.copy}),t&&(0,q.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:n,children:y.card.edit.describe.putBack})]}),(0,q.jsx)(`pre`,{className:`description__kept-text`,children:e})]})}function qe({theirs:e,mine:t,busy:n,onKeep:r,onTake:i}){let a=(0,G.useRef)(null),o=_(a,i),s=(0,G.useId)(),c=I(e,t),l=c.filter(e=>e.kind===`removed`||e.kind===`changed`).length;return(0,G.useEffect)(()=>{a.current?.open===!1&&a.current.showModal()},[]),(0,q.jsx)(`dialog`,{ref:a,className:`add-package description__conflict`,"aria-labelledby":s,onCancel:e=>{e.preventDefault(),e.stopPropagation(),i()},...o,children:(0,q.jsxs)(`div`,{className:`add-package__frame`,children:[(0,q.jsx)(`header`,{className:`add-package__head`,children:(0,q.jsx)(`h2`,{id:s,className:`add-package__title`,children:y.card.edit.describe.conflictTitle})}),(0,q.jsxs)(`div`,{className:`add-package__body`,children:[(0,q.jsx)(`p`,{className:`add-package__question`,children:y.card.edit.describe.overwritten(l)}),(0,q.jsx)(`p`,{className:`description__hint`,children:y.card.edit.describe.conflictLegend}),(0,q.jsx)(`div`,{className:`description__diff`,role:`document`,"aria-label":y.card.edit.describe.conflictTitle,tabIndex:0,children:(0,q.jsx)(O,{lines:c})})]}),(0,q.jsxs)(`footer`,{className:`add-package__foot`,children:[(0,q.jsx)(`span`,{className:`add-package__spacer`}),(0,q.jsx)(`button`,{type:`button`,className:`button`,disabled:n,onClick:i,children:y.card.edit.takeNew}),(0,q.jsx)(`button`,{type:`button`,className:`button button--primary`,disabled:n,onClick:r,children:y.card.edit.keepMine})]})]})})}var Je=new Set([`question`,`excluded`]);function Ye({task:e,project:n,link:i,tracker:a,refused:o,work:s,live:c,onOpen:l,onClose:d}){let{card:f,state:p}=r(),[h,g]=(0,G.useState)(()=>ae(n,e)),[v,b]=(0,G.useState)(null),[x,S]=(0,G.useState)(0),[C,w]=(0,G.useState)(!1),T=d,E=(0,G.useRef)(null),D=(0,G.useRef)(null),O=_(E,T),k=()=>S(e=>e+1),A=Ue(n,e,k),j=h?.edit==null?null:h,M=p!==null&&u(p.chain,n)?.current?.task===e,N=h===void 0&&v===null,P=ee(N),I=N||P!==`done`;F(D,I?null:h?.id??e);let L=JSON.stringify(p?.tasks.filter(t=>t.project===n&&(t.id===e||t.parent===e))??null),z=(0,G.useRef)(L);(0,G.useEffect)(()=>{z.current!==L&&(z.current=L,j!==null&&k())},[L]),(0,G.useEffect)(()=>{E.current?.open===!1&&E.current.showModal(),D.current?.focus()},[]);let B=(0,G.useRef)({project:n,task:e});return(0,G.useEffect)(()=>{(B.current.project!==n||B.current.task!==e)&&(B.current={project:n,task:e},g(ae(n,e)))},[n,e]),(0,G.useEffect)(()=>{let r=!0;return b(null),f(e).then(t=>{oe(n,e,t),r&&g(t)},e=>r&&b(t(e))),()=>{r=!1}},[n,e,x]),(0,q.jsxs)(`dialog`,{ref:E,className:`task-card`,"data-restorable":!0,"aria-label":e,onCancel:e=>{e.preventDefault(),T()},...O,children:[(0,q.jsxs)(`div`,{ref:D,className:`task-card__frame${I?` task-card__frame--reading`:``}`,tabIndex:-1,children:[(0,q.jsxs)(`header`,{className:`task-card__head`,children:[(0,q.jsx)(`span`,{className:`task-card__key`,children:e}),j===null?h!=null&&(0,q.jsx)(re,{status:h.status}):(0,q.jsx)(ke,{card:j,editor:A,refused:o,live:c}),(0,q.jsx)(`span`,{className:`task-card__spacer`}),j!==null&&(0,q.jsx)(R,{label:y.card.edit.more,items:[{label:y.card.edit.remove,danger:!0,problem:Xe(be(e,M,c)),pick:()=>w(!0)}]}),i!==null&&j===null&&(0,q.jsxs)(`a`,{href:i,className:`task-card__link`,target:`_blank`,rel:`noreferrer`,children:[y.card.openIn(a),` `,(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]}),(0,q.jsx)(`button`,{type:`button`,className:`task-card__close`,"aria-label":y.card.close,title:y.card.close,onClick:T,children:`×`})]}),(0,q.jsx)(`div`,{className:`task-card__body`,children:I?(0,q.jsx)(te,{phase:P===`done`?`in`:P,label:y.card.loading,fit:`fill`}):(0,q.jsxs)(q.Fragment,{children:[v!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(v)}),h===null&&(0,q.jsx)(`p`,{className:`placeholder task-card__empty`,children:y.card.none}),h!=null&&(0,q.jsx)(et,{card:h,project:n,editor:j===null?null:A,inWork:M||c,refused:o,work:s,live:c,onOpen:l,onChanged:k})]})})]}),A.conflict!==null&&(0,q.jsx)(Qe,{editor:A,conflict:A.conflict}),C&&j!==null&&(0,q.jsx)($e,{card:j,editor:A,onClose:()=>w(!1),onRemoved:()=>{w(!1),d()}})]})}var Xe=e=>e===null?void 0:m(e);function Ze(e,t){return t===null||t===``?y.card.edit.empty:e===`priority`&&t in y.card.priorities?y.card.priorities[t]:t}function Qe({editor:e,conflict:t}){return(0,q.jsx)(C,{title:y.card.edit.conflictTitle,question:y.card.edit.conflictQuestion(y.card.edit.fields[t.field]??t.field,Ze(t.field,t.theirs),Ze(t.field,t.mine)),confirm:y.card.edit.keepMine,cancel:y.card.edit.takeNew,busy:e.busy,safe:!0,onConfirm:t.keep,onClose:e.settle})}function $e({card:e,editor:t,onClose:n,onRemoved:r}){let[i,a]=(0,G.useState)(null);return(0,q.jsx)(C,{title:y.card.edit.removeTitle(e.id),question:y.card.edit.removeQuestion((e.subtasks??[]).map(e=>e.id).join(`, `)),confirm:y.card.edit.removeConfirm,cancel:y.card.edit.cancel,busy:t.busy,failure:i===null?void 0:m(i),onConfirm:()=>void t.run(`query`,`builtin/delete`,{task:e.id}).then(e=>e===null?r():a(e)),onClose:n})}function et({card:e,project:t,editor:n,inWork:i,refused:o,work:s,live:c,onOpen:u,onChanged:d}){let{send:f,sending:g,failure:_}=a(),{state:v}=r(),b=e=>y.card.roles[e],x=ce(u,e.attachments),S=e.labels.filter(e=>Je.has(e.role)),C=e.labels.filter(e=>e.role!==null&&!Je.has(e.role)),w=n!==null&&e.edit!==null?{card:e,editor:n}:null,T=ue(e.estimate,e.activeS);return(0,q.jsxs)(q.Fragment,{children:[w!==null&&(0,q.jsx)(Ne,{ancestors:w.card.edit.ancestors,onOpen:u}),w===null?(0,q.jsx)(`h2`,{className:`task-card__title`,children:e.title}):(0,q.jsx)(De,{card:e,editor:w.editor},`title:${e.id}`),(0,q.jsxs)(`div`,{className:`task-card__layout`,children:[(0,q.jsxs)(`div`,{className:`task-card__main`,children:[(S.length>0||e.requires.length>0||s!==null)&&(0,q.jsxs)(`div`,{className:`task-card__callouts`,children:[s!==null&&(0,q.jsxs)(`div`,{className:`task-card__callout task-card__callout--work`,children:[(0,q.jsx)(`strong`,{children:y.card.work}),L(s).map(e=>(0,q.jsx)(`span`,{className:`task-card__work-line`,children:e},e)),(0,q.jsx)(`span`,{className:`task-card__work-fix`,children:y.chain.work.fix})]}),S.map(e=>(0,q.jsxs)(`p`,{className:`task-card__callout task-card__callout--${e.role}`,children:[(0,q.jsx)(`strong`,{children:e.name}),(0,q.jsx)(`span`,{children:y.card.roles[e.role]})]},e.name)),e.requires.length>0&&(0,q.jsx)(`p`,{className:`task-card__callout task-card__callout--question`,children:(0,q.jsx)(`span`,{children:y.card.requires(e.requires.join(`, `))})})]}),w===null?(0,q.jsxs)(`section`,{className:`task-card__section`,children:[(0,q.jsx)(`h3`,{className:`task-card__heading`,children:y.card.description}),e.description.trim()===``?(0,q.jsx)(`p`,{className:`placeholder`,children:y.card.noDescription}):(0,q.jsx)(W,{components:x,children:e.description})]}):(0,q.jsx)(Ge,{task:e.id,text:e.description,editor:w.editor,render:e=>(0,q.jsx)(W,{components:x,children:e})},`description:${e.id}`),(0,q.jsx)(Fe,{card:e,project:t,adding:w,inWork:i,onOpen:u}),(0,q.jsx)(se,{task:e.id,comments:e.comments,editor:w?.editor??null,render:e=>(0,q.jsx)(W,{components:x,children:e})},`journal:${e.id}`)]}),(0,q.jsxs)(`aside`,{className:`task-card__side`,children:[e.ready&&w===null&&(0,q.jsx)(nt,{hint:y.card.readyHint,problem:o===null?null:y.chain.readyRefused(m(o)),children:(0,q.jsx)(`button`,{type:`button`,className:`button button--primary`,disabled:g||o!==null,onClick:()=>void f(`task/ready`,{task:e.id}).then(e=>e&&d()),children:y.card.ready})}),e.unready&&!c&&w===null&&(0,q.jsx)(nt,{hint:y.card.unreadyHint,problem:null,children:(0,q.jsx)(`button`,{type:`button`,className:`button`,disabled:g,onClick:()=>void f(`task/unready`,{task:e.id}).then(e=>e&&d()),children:y.card.unready})}),_!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(_)}),w?.editor.failure!=null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(w.editor.failure)}),T!==null&&(0,q.jsxs)(h,{className:`task-card__facts`,children:[(0,q.jsx)(p,{label:y.card.estimate,children:(0,q.jsx)(`dd`,{children:T.estimate})}),(0,q.jsx)(p,{label:y.card.time,tone:T.over?`warn`:`ok`,children:(0,q.jsx)(`dd`,{children:(0,q.jsx)(l,{tip:y.card.timeTip,inline:!0,focusable:!0,children:T.time})})})]}),(0,q.jsxs)(`dl`,{className:`task-card__props`,children:[(0,q.jsx)($,{name:y.card.priority,children:w===null?(0,q.jsxs)(`span`,{className:`task-card__priority task-card__priority--${e.priority}`,children:[(0,q.jsx)(D,{priority:e.priority}),y.card.priorities[e.priority]]}):(0,q.jsx)(Ae,{card:e,editor:w.editor})}),(0,q.jsx)($,{name:y.card.milestone,children:w===null?e.milestones===null?e.milestone===null?(0,q.jsx)(`span`,{className:`task-card__none`,children:y.card.noMilestone}):(0,q.jsxs)(`span`,{className:`task-card__milestone`,children:[e.milestone.label,e.milestone.targetDate?(0,q.jsx)(`small`,{children:y.card.due(Z().format(e.milestone.targetDate))}):null]}):(0,q.jsx)(tt,{task:e.id,pick:e.milestones,onChanged:d}):(0,q.jsx)(je,{card:w.card,editor:w.editor})}),(0,q.jsx)(He,{task:e.id,live:c,onChanged:d}),w===null?e.parent!==null&&(0,q.jsx)($,{name:y.card.parent,children:(0,q.jsx)(J,{item:e.parent,onOpen:u})}):(0,q.jsx)($,{name:y.card.parent,wide:w.card.parent!==null,children:(0,q.jsx)(Pe,{card:w.card,project:t,editor:w.editor,onOpen:u})}),(e.labels.length>0||w!==null)&&(0,q.jsxs)($,{name:y.card.labels,wide:!0,children:[w===null?(0,q.jsx)(`ul`,{className:`task-card__chips`,children:e.labels.map(e=>(0,q.jsx)(`li`,{className:e.role===null?`tag`:`chip task-card__chip--${e.role}`,title:e.role===null?void 0:b(e.role),children:e.name},e.name))}):(0,q.jsx)(Me,{card:w.card,editor:w.editor,roleText:b}),C.length>0&&(0,q.jsx)(`ul`,{className:`task-card__roles`,children:C.map(e=>(0,q.jsxs)(`li`,{children:[(0,q.jsx)(`strong`,{children:e.name}),` — `,b(e.role)]},e.name))})]})]}),e.attachments.length>0&&(0,q.jsx)(ie,{task:e.id,items:e.attachments,editor:w?.editor??null}),(0,q.jsx)(we,{card:e,editor:w?.editor??null,onOpen:u})]})]})]})}function tt({task:e,pick:t,onChanged:n}){let{send:r,sending:i,failure:o}=a(),[s,c]=(0,G.useState)(t.current??``);(0,G.useEffect)(()=>c(t.current??``),[t.current]);let l=t.choices.find(e=>e.id===s),u=[{value:``,label:y.card.noMilestone},...t.choices.map(e=>({value:e.id,label:e.label}))];return(0,q.jsxs)(`div`,{className:`task-card__milestone`,children:[(0,q.jsx)(E,{className:`task-card__milestone-pick`,label:y.card.milestone,value:s,options:u,disabled:i,onChange:i=>{c(i),r(`task/milestone`,{task:e,milestone:i===``?null:i}).then(e=>e?n():c(t.current??``))}}),l?.targetDate?(0,q.jsx)(`small`,{children:y.card.due(Z().format(l.targetDate))}):null,o!==null&&(0,q.jsx)(`p`,{className:`notice notice--error`,children:m(o)})]})}function nt({hint:e,problem:t,children:n}){return(0,q.jsxs)(`div`,{className:`task-card__ready`,children:[(0,q.jsx)(A,{action:n,label:y.card.actionHelp,tip:e}),t!==null&&(0,q.jsx)(`p`,{className:`task-card__hint`,children:t})]})}function $({name:e,children:t,wide:n=!1}){return(0,q.jsxs)(`div`,{className:`task-card__prop${n?` task-card__prop--wide`:``}`,children:[(0,q.jsx)(`dt`,{children:e}),(0,q.jsx)(`dd`,{children:t})]})}export{Ye as TaskCard};