@rubytech/create-maxy-code 0.1.502 → 0.1.503

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.
Files changed (24) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/PLUGIN.md +1 -0
  3. package/payload/platform/plugins/admin/hooks/__tests__/quote-engine-gate.test.sh +98 -0
  4. package/payload/platform/plugins/admin/hooks/quote-engine-gate.sh +68 -0
  5. package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +6 -0
  6. package/payload/platform/scripts/lib/provision-account-dir.sh +2 -1
  7. package/payload/platform/services/telegram-channel/dist/instructions.js +2 -2
  8. package/payload/platform/services/telegram-channel/dist/instructions.js.map +1 -1
  9. package/payload/platform/services/webchat-channel/dist/instructions.js +2 -2
  10. package/payload/platform/services/webchat-channel/dist/instructions.js.map +1 -1
  11. package/payload/platform/services/whatsapp-channel/dist/notification.js +2 -2
  12. package/payload/platform/services/whatsapp-channel/dist/notification.js.map +1 -1
  13. package/payload/server/public/assets/{calendar-D0qIvLUR.js → calendar-B8ujkn_K.js} +1 -1
  14. package/payload/server/public/assets/{chat-geSkx0j2.js → chat-lQXd6gsM.js} +1 -1
  15. package/payload/server/public/assets/{operator-DejfJlvi.js → operator-Bf3hP3qo.js} +1 -1
  16. package/payload/server/public/assets/{page-DomkejEB.js → page-Bs24tO-C.js} +1 -1
  17. package/payload/server/public/assets/{public-Be_Galv6.js → public-DZHPsyKX.js} +1 -1
  18. package/payload/server/public/assets/skills-y-h0P9rC.js +1 -0
  19. package/payload/server/public/calendar.html +1 -1
  20. package/payload/server/public/chat.html +2 -2
  21. package/payload/server/public/operator.html +2 -2
  22. package/payload/server/public/public.html +2 -2
  23. package/payload/server/public/skills.html +1 -1
  24. package/payload/server/public/assets/skills-D9nWOqoz.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-maxy-code",
3
- "version": "0.1.502",
3
+ "version": "0.1.503",
4
4
  "description": "Install Maxy — AI for Productive People",
5
5
  "bin": {
6
6
  "create-maxy-code": "./dist/index.js"
@@ -189,6 +189,7 @@ Tools are available via the `admin` MCP server.
189
189
  ## Hooks
190
190
 
191
191
  - `hooks/quote-render-gate.sh` — **PreToolUse matcher=`mcp__plugin_browser_browser__browser-pdf-save`.** Makes the deterministic quote-render path the only route a client-facing quote PDF can reach a customer. Blocks (exit 2) a `browser-pdf-save` whose output path is a client-quote artefact (`memory/users/<phone>/documents/quote-<jobId>.pdf` or `…-breakdown.pdf`) when no render receipt exists at `quoting/jobs/<jobId>/render-receipt.json` — the receipt `quote-render` writes only after its reconcile / margin-leak / link-liveness gates all pass. A hand-authored quote (the SiteDesk 2026-07-14 bypass: `Write` HTML → `browser-pdf-save`, `quote-render` never called, an internal back-test caveat naming another client folded into the free-text region) has no receipt, so the print is refused rather than delivered. **Block message:** `Blocked: this client quote was not produced by the quote-render tool, so its fixed layout and the reconcile, margin-leak and link-liveness gates never ran. Run quote-render for this job (it files the document and its receipt), then print the client HTML path it returns to PDF.` **Log line** (stderr, on a block): `[quote-render] op=bypass jobId=<jobId> detail=client quote PDF has no render receipt` (or `reason=bad-jobid` when the filename does not resolve to a job). Every non-quote PDF — brochures, invoices, the admin-scope internal view — and the deterministic path itself (receipt present) pass at exit 0. **Fail-open** on an uninspectable call (tty / empty stdin / no `python3`): `browser-pdf-save` is a general-purpose tool and the agent never controls this hook's stdin, so failing open opens no bypass while never bricking unrelated PDFs.
192
+ - `hooks/quote-engine-gate.sh` — **PreToolUse matcher=`Bash`** (a third command on the same `Bash` matcher as `archive-ingest-surface-gate` and `fs-schema-guard-bash-pre`, any exit 2 blocks). Makes the deterministic `quote-engine-run` / `quote-render` tools the only route the account's persisted quoting scripts can run. Blocks (exit 2) a `Bash` `command` that executes `quoting/engine.mjs` or `quoting/render.mjs` directly — the pricing and render scripts must run through their MCP tools, which apply the reconcile / margin-leak / link-liveness gates and write the figures and render receipts. A hand-run `node quoting/engine.mjs` (the SiteDesk 2026-07-25 bypass: a repricing dispatched to content-producer that ran the engine by hand and re-rendered off the deterministic path) skips all of that, so it is refused. It fires only on an execution (a JS runtime invoking the script, or the script run at command position); a read or inspect of the file (`cat`/`grep`/`git diff quoting/engine.mjs`) and every unrelated `Bash` command pass at exit 0. A `mode=verify` reproduction is gated too — it must also run through `quote-engine-run`, so a hand-run `node quoting/engine.mjs mode=verify` is refused. Known fail-open gap (accepted, consistent with the soft posture): a `cd quoting && node engine.mjs` drops the `quoting/` prefix and is not matched. **Block message:** `Blocked: the quoting engine and render scripts must run through their tools, not directly. Use the quote-engine-run tool to price a job (it files the figures) and the quote-render tool to produce the documents (it files them behind the reconcile, margin-leak and link-liveness gates). Running quoting/engine.mjs or quoting/render.mjs by hand skips those gates and files no receipt.` **Log line** (stderr, on a block): `[quote-engine] op=bypass reason=direct-script-exec`. **Fail-open** on an uninspectable call (tty / empty stdin / no `python3`): `Bash` is a general-purpose tool and the agent never controls this hook's stdin, so failing open opens no bypass while never bricking unrelated commands.
192
193
  - `hooks/preference-consult-gate.sh` — **PreToolUse gate on customer-facing document deliverables.** Registered against `mcp__plugin_browser_browser__browser-pdf-save` (a second command on the same matcher as `quote-render-gate`, either exit 2 blocks) and against the email/Outlook send tools plus `SendUserFile`. It fires only in the document-deliverable shape: a `browser-pdf-save` or `SendUserFile` whose path is under `memory/users/<phone>/documents/` (or a `SendUserFile` of a `.pdf`/`.html`/`.docx`), and `email-send`/`email-reply`/`email-draft-send`/`outlook-mail-send`/`outlook-mail-reply`/`outlook-draft-send` carrying a non-empty `attachments`. For a gated call it reads the session transcript (`transcript_path`) and blocks (exit 2) when no `profile-read` tool call ran after the last user message, because the account's layer-2 `Preference` records (signature policy, header, naming, styling) were not consulted this turn, the exact miss that dropped a customer signature on a delivered document. **Block message:** `Blocked: this customer document is about to go out without the account's saved preferences being checked this turn. Those records hold the signature, header, naming and styling rules. Run profile-read for this account, apply anything relevant, then send again.` **Log line** (stderr): `[preference-gate] op=bypass tool=<name> detail=no profile-read this turn` on a block, `op=allow tool=<name> consulted=true` on an allowed document deliverable. Every non-document tool/shape, and every casual channel reply or plain-text email, passes at exit 0. **Fail-open** on an uninspectable call (tty / empty stdin / no `python3` / transcript missing or unreadable). Scope decision: the gate fires on document deliverables only, not on every send, so it never blocks routine chat. The standing reconcile counterpart for stranded `output/` deliverables is filed as a follow-up task.
193
194
  - `hooks/quote-render-pdf-conformance.sh` — **PostToolUse matcher=`mcp__plugin_browser_browser__browser-pdf-save`.** The PDF-time companion to the PreToolUse `quote-render-gate`: the HTML gates run inside `quote-render` before the receipt, but the two PDF-only conformance checks cannot, because the PDF does not exist until `browser-pdf-save` runs. For a gated client-quote PDF (`memory/users/<phone>/documents/quote-<jobId>.pdf` or `…-breakdown.pdf`) whose render receipt names the source HTML, it blocks (exit 2) when the printed PDF's `/URI` annotation count is below the source HTML's absolute-link count (a rasterised or flattened print that dropped links) or when an embedded `https://` link does not answer 200 (a Sign-Online link a pending redeploy would 404). The offline `/URI`-count check runs first and short-circuits, so a link-loss regression never depends on the network. **Block message:** `Blocked: the printed quote PDF is missing links the document declared, or an embedded link is not live (…). Do not send it. If a Sign-Online link is not live yet, deploy the signing page first; then re-render and re-print so the PDF carries every link the document declares.` **Log line** (stderr, on a block): `[quote-render] op=bypass jobId=<jobId> reason=pdf-link-conformance detail=<uri-count …|link <url> -> <code>>`. Every non-quote PDF, and any call with no receipt (the PreToolUse gate owns that block), passes at exit 0. **Fail-open** on an uninspectable call (tty / empty stdin / no `python3` / receipt or PDF absent). **Reach on upgrade:** `provision-account-dir.sh` writes this PostToolUse matcher only at account-provision time, so accounts provisioned before it landed keep a stale matcher and need a settings backfill (tracked as a follow-up task), the same reach limit the AskUserQuestion carrier gate hit.
194
195
  - `hooks/webfetch-preflight.mjs` — short-circuits WebFetch on JS-SPA shells with a structured `WEBFETCH_CANNOT_READ_JS_SPA` error so the agent surfaces a loud failure to the owner instead of paying the 60s extraction timeout. Fail-open on any internal error.
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env bash
2
+ # Regression test for quote-engine-gate.sh.
3
+ #
4
+ # The gate is a PreToolUse hook on Bash. It refuses a Bash command that runs the
5
+ # persisted quoting engine or render script directly (quoting/engine.mjs or
6
+ # quoting/render.mjs), because those scripts must run only through the
7
+ # deterministic quote-engine-run / quote-render MCP tools (which apply the gates
8
+ # and write receipts). A mode=verify engine run and every unrelated command pass.
9
+ #
10
+ # Covers:
11
+ # A. Bash running quoting/engine.mjs → BLOCKED (exit 2)
12
+ # B. Bash running quoting/render.mjs → BLOCKED
13
+ # C. engine.mjs run with mode=verify by hand → BLOCKED (verify runs through the tool too)
14
+ # D. engine.mjs run with a `# mode=verify` tail → BLOCKED (no token-anywhere escape)
15
+ # E. unrelated Bash (ls quoting) → ALLOWED
16
+ # F. a quote-engine-run MCP tool call → ALLOWED (not Bash)
17
+ # G. empty stdin → ALLOWED (fail-open)
18
+ # H. a non-Bash tool → ALLOWED (matcher defence-in-depth)
19
+ # I. a block emits the op=bypass fault line
20
+ # J. reading the script (cat) is not execution → ALLOWED
21
+ # K. grepping the script is not execution → ALLOWED
22
+ # L. the script run at command position → BLOCKED
23
+
24
+ set -u
25
+
26
+ HOOK="$(cd "$(dirname "$0")/.." && pwd)/quote-engine-gate.sh"
27
+ if [[ ! -x "$HOOK" ]]; then
28
+ echo "FAIL: $HOOK not executable" >&2
29
+ exit 1
30
+ fi
31
+
32
+ PASS=0
33
+ FAIL=0
34
+
35
+ run_case() {
36
+ local name="$1" stdin="$2" expected_exit="$3"
37
+ local actual_exit
38
+ ( printf '%s' "$stdin" | bash "$HOOK" >/dev/null 2>/dev/null )
39
+ actual_exit=$?
40
+ if [[ "$actual_exit" -eq "$expected_exit" ]]; then
41
+ echo "PASS: $name (exit=$actual_exit)"
42
+ PASS=$((PASS + 1))
43
+ else
44
+ echo "FAIL: $name (expected exit=$expected_exit, got=$actual_exit)" >&2
45
+ FAIL=$((FAIL + 1))
46
+ fi
47
+ }
48
+
49
+ bash_env() { # command string (JSON-escaped by caller)
50
+ printf '{"hook_event_name":"PreToolUse","tool_name":"Bash","tool_input":{"command":"%s"}}' "$1"
51
+ }
52
+
53
+ run_case "A: Bash runs quoting/engine.mjs → BLOCKED" \
54
+ "$(bash_env "node quoting/engine.mjs < quoting/job-1854.json")" 2
55
+
56
+ run_case "B: Bash runs quoting/render.mjs → BLOCKED" \
57
+ "$(bash_env "node quoting/render.mjs")" 2
58
+
59
+ run_case "C: engine.mjs mode=verify by hand → BLOCKED" \
60
+ "$(bash_env "node quoting/engine.mjs mode=verify")" 2
61
+
62
+ run_case "D: engine.mjs with # mode=verify tail → BLOCKED" \
63
+ "$(bash_env "node quoting/engine.mjs < job.json # mode=verify")" 2
64
+
65
+ run_case "E: unrelated Bash → ALLOWED" \
66
+ "$(bash_env "ls quoting")" 0
67
+
68
+ run_case "J: reading the script (cat) → ALLOWED" \
69
+ "$(bash_env "cat quoting/engine.mjs")" 0
70
+
71
+ run_case "K: grepping the script → ALLOWED" \
72
+ "$(bash_env "grep foo quoting/render.mjs")" 0
73
+
74
+ run_case "L: script at command position → BLOCKED" \
75
+ "$(bash_env "./quoting/engine.mjs < job.json")" 2
76
+
77
+ run_case "F: quote-engine-run MCP call → ALLOWED" \
78
+ '{"hook_event_name":"PreToolUse","tool_name":"mcp__plugin_sitedesk-job_sitedesk-job__quote-engine-run","tool_input":{"job":"1854","mode":"quote"}}' 0
79
+
80
+ run_case "G: empty stdin → ALLOWED (fail-open)" \
81
+ "" 0
82
+
83
+ run_case "H: non-Bash tool → ALLOWED" \
84
+ '{"hook_event_name":"PreToolUse","tool_name":"Write","tool_input":{"file_path":"/x/quoting/engine.mjs"}}' 0
85
+
86
+ # I: a block emits the op=bypass fault line on stderr.
87
+ STDERR=$( printf '%s' "$(bash_env "node quoting/engine.mjs")" | bash "$HOOK" 2>&1 >/dev/null )
88
+ if printf '%s' "$STDERR" | grep -q '\[quote-engine\] op=bypass reason=direct-script-exec'; then
89
+ echo "PASS: I: block emits op=bypass reason=direct-script-exec"
90
+ PASS=$((PASS + 1))
91
+ else
92
+ echo "FAIL: I: op=bypass line absent (got: $STDERR)" >&2
93
+ FAIL=$((FAIL + 1))
94
+ fi
95
+
96
+ echo "──────── quote-engine-gate test summary ────────"
97
+ echo "PASS=$PASS FAIL=$FAIL"
98
+ [[ "$FAIL" -eq 0 ]]
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env bash
2
+ # quote-engine-gate — PreToolUse gate on Bash.
3
+ #
4
+ # The account's quoting method is applied by two persisted scripts,
5
+ # quoting/engine.mjs (pricing) and quoting/render.mjs (documents). They must run
6
+ # ONLY through their MCP tools — quote-engine-run and quote-render — which apply
7
+ # the reconcile / margin-leak / link-liveness gates and write the figures and
8
+ # render receipts. Running either script directly from a Bash command bypasses
9
+ # all of that (the SiteDesk 2026-07-25 bypass: a repricing dispatched to
10
+ # content-producer that ran `node quoting/engine.mjs` and re-rendered by hand).
11
+ # This gate refuses that Bash call and points the agent at the tools. It fires
12
+ # only on an execution of the persisted script (a JS runtime invoking it, or the
13
+ # script run at command position), never on a read like `cat quoting/engine.mjs`.
14
+ # A mode=verify reproduction must also run through the quote-engine-run tool, so
15
+ # a hand-run `node quoting/engine.mjs mode=verify` is gated too.
16
+ #
17
+ # Exit codes: 0 = allow, 2 = block (stderr shown to the agent). Fail OPEN on an
18
+ # uninspectable call (Bash is a general-purpose tool and the agent never controls
19
+ # this hook's stdin, so failing open opens no bypass while never bricking
20
+ # unrelated commands). No task numbers or internal refs in operator-visible text.
21
+
22
+ set -uo pipefail
23
+
24
+ # No envelope (tty or empty stdin) → allow: cannot inspect, must not brick Bash.
25
+ if [ -t 0 ]; then exit 0; fi
26
+ INPUT=$(cat)
27
+ [ -z "$INPUT" ] && exit 0
28
+
29
+ # Print "block" when the Bash command runs a persisted quoting script directly
30
+ # (and is not a mode=verify run), or nothing for any other call.
31
+ DECISION=$(INPUT="$INPUT" python3 - <<'PY' 2>/dev/null || true
32
+ import os, json, re, sys
33
+ try:
34
+ d = json.loads(os.environ["INPUT"])
35
+ except Exception:
36
+ sys.exit(0)
37
+ if (d.get("tool_name", "") or "") != "Bash":
38
+ sys.exit(0)
39
+ cmd = (d.get("tool_input", {}) or {}).get("command", "") or ""
40
+ if not cmd:
41
+ sys.exit(0)
42
+ script = r'quoting/(engine|render)\.mjs\b'
43
+ # Block only an EXECUTION of the persisted script, not a read/inspect of it:
44
+ # - a JS runtime invoking it: `node|nodejs|bun|deno|ts-node ... quoting/engine.mjs`
45
+ # - the script run directly at command position: `./quoting/engine.mjs`, or the
46
+ # path as a bare command after a separator.
47
+ # A read (`cat|grep|git diff|head|wc quoting/engine.mjs`) leaves the path as an
48
+ # argument, not at command position, so it is not matched and passes.
49
+ # Verify runs are NOT carved out: `mode=verify` must also go through the
50
+ # quote-engine-run tool, never a hand-run of the persisted script.
51
+ executed = (
52
+ re.search(r'\b(?:node|nodejs|bun|deno|ts-node)\b[^;&|\n]*' + script, cmd)
53
+ or re.search(r'(?:^|[;&|]\s*)\.?/?' + script, cmd)
54
+ )
55
+ # Known fail-open gap (accepted, consistent with this gate's soft posture): a
56
+ # cd-relative run like `cd quoting && node engine.mjs` drops the `quoting/`
57
+ # prefix and is not matched.
58
+ if not executed:
59
+ sys.exit(0)
60
+ print("block")
61
+ PY
62
+ )
63
+
64
+ [ "$DECISION" = "block" ] || exit 0
65
+
66
+ echo "[quote-engine] op=bypass reason=direct-script-exec" >&2
67
+ echo "Blocked: the quoting engine and render scripts must run through their tools, not directly. Use the quote-engine-run tool to price a job (it files the figures) and the quote-render tool to produce the documents (it files them behind the reconcile, margin-leak and link-liveness gates). Running quoting/engine.mjs or quoting/render.mjs by hand skips those gates and files no receipt." >&2
68
+ exit 2
@@ -9,6 +9,12 @@ Invoked by the admin agent directly.
9
9
 
10
10
  This is the platform's release timeline, newest first. Each entry shows the date it shipped and the version it shipped in, so you can tell the operator how current their install is. To compare, read the installed version from `capabilities-here` and match it against the versions below. Keep answers high level and in plain English; this is a summary, not a full commit log.
11
11
 
12
+ ## 2026-07-25 (0.1.503)
13
+
14
+ - The "stalled" indicator in chat now only shows when a turn is genuinely stuck, not during a normal pause.
15
+ - Quote price changes always go through the proper pricing engine now, closing a path that could skip its checks.
16
+ - The Skills and Calendar detail views are wider and no longer show an unnecessary scrollbar.
17
+
12
18
  ## 2026-07-25 (0.1.502)
13
19
 
14
20
  - Uploading a file from the phone or desktop app now shows as a proper thumbnail in chat, not a raw file path.
@@ -92,7 +92,8 @@ provision_account_dir() {
92
92
  "matcher": "Bash",
93
93
  "hooks": [
94
94
  { "type": "command", "command": "bash $HOOKS_PATH/archive-ingest-surface-gate.sh" },
95
- { "type": "command", "command": "bash $HOOKS_PATH/fs-schema-guard-bash-pre.sh" }
95
+ { "type": "command", "command": "bash $HOOKS_PATH/fs-schema-guard-bash-pre.sh" },
96
+ { "type": "command", "command": "bash $HOOKS_PATH/quote-engine-gate.sh" }
96
97
  ]
97
98
  },
98
99
  {
@@ -72,8 +72,8 @@ export function replyTextDescription(role) {
72
72
  // NO_INTERNALS violation. The public role keeps plain delivery and relies on the
73
73
  // server-level PUBLIC_INSTRUCTIONS.
74
74
  export const ADMIN_REFRAME_INSTRUCTION = 'Dispatch the owning specialist with the Agent tool. ' +
75
- 'Any deliverable artefact email, letter, quote, order, report, PDF, image, page ' +
76
- 'is content-producer work, without exception, including follow-up edits to one already produced. ' +
75
+ 'Every deliverable artefact (email, letter, quote, order, report, PDF, image, page) goes to the installed specialist that owns that artefact type, never produced inline, including follow-up edits to one already produced; ' +
76
+ 'only when no specialist owns the artefact type is it content-producer work. ' +
77
77
  'Else load the owning skill; else (a greeting, quick question, confirmation) just answer. ' +
78
78
  'Artefact work with neither is the violation signal — reconsider. ' +
79
79
  'Your capabilities here are very well defined: before telling the operator something cannot be done, ' +
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,qEAAqE;AACrE,8EAA8E;AAC9E,kCAAkC;AAIlC;mEACmE;AACnE,MAAM,UAAU,kBAAkB,CAAC,GAAuB;IACxD,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAA;AAC9C,CAAC;AAED,MAAM,YAAY,GAChB,gGAAgG;IAChG,iGAAiG;IACjG,mGAAmG;IACnG,iGAAiG;IACjG,0EAA0E,CAAA;AAE5E,yEAAyE;AACzE,gFAAgF;AAChF,wEAAwE;AACxE,yEAAyE;AACzE,8EAA8E;AAC9E,iFAAiF;AACjF,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,MAAM,mBAAmB,GACvB,6FAA6F;IAC7F,mGAAmG;IACnG,yFAAyF;IACzF,sGAAsG,CAAA;AAExG,MAAM,kBAAkB,GACtB,mBAAmB;IACnB,iEAAiE;IACjE,mGAAmG;IACnG,+FAA+F;IAC/F,8FAA8F;IAC9F,kGAAkG;IAClG,6FAA6F;IAC7F,wFAAwF;IACxF,YAAY,CAAA;AAEd,MAAM,mBAAmB,GACvB,mBAAmB;IACnB,uEAAuE;IACvE,oGAAoG;IACpG,iGAAiG;IACjG,4FAA4F;IAC5F,kGAAkG;IAClG,iGAAiG;IACjG,oCAAoC;IACpC,YAAY,CAAA;AAEd,MAAM,UAAU,mBAAmB,CAAC,IAAyB;IAC3D,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAA;AACrE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAyB;IAC5D,OAAO,IAAI,KAAK,QAAQ;QACtB,CAAC,CAAC,2EAA2E;QAC7E,CAAC,CAAC,2EAA2E,CAAA;AACjF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAyB;IAC5D,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,qCAAqC,CAAA;AACzG,CAAC;AAED,yEAAyE;AACzE,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,+EAA+E;AAC/E,wEAAwE;AACxE,gFAAgF;AAChF,wEAAwE;AACxE,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,uEAAuE;AACvE,iFAAiF;AACjF,oCAAoC;AACpC,MAAM,CAAC,MAAM,yBAAyB,GACpC,sDAAsD;IACtD,qFAAqF;IACrF,kGAAkG;IAClG,2FAA2F;IAC3F,mEAAmE;IACnE,sGAAsG;IACtG,oHAAoH;IACpH,+IAA+I;IAC/I,gFAAgF;IAChF,+EAA+E;IAC/E,8DAA8D;IAC9D,0EAA0E;IAC1E,4DAA4D;IAC5D,8EAA8E;IAC9E,0EAA0E;IAC1E,uGAAuG;IACvG,iDAAiD;IACjD,gFAAgF;IAChF,mFAAmF;IACnF,oHAAoH;IACpH,yBAAyB;IACzB,+EAA+E;IAC/E,iFAAiF;IACjF,iFAAiF;IACjF,mBAAmB;IACnB,8GAA8G;IAC9G,gHAAgH;IAChH,4BAA4B,CAAA"}
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,qEAAqE;AACrE,8EAA8E;AAC9E,kCAAkC;AAIlC;mEACmE;AACnE,MAAM,UAAU,kBAAkB,CAAC,GAAuB;IACxD,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAA;AAC9C,CAAC;AAED,MAAM,YAAY,GAChB,gGAAgG;IAChG,iGAAiG;IACjG,mGAAmG;IACnG,iGAAiG;IACjG,0EAA0E,CAAA;AAE5E,yEAAyE;AACzE,gFAAgF;AAChF,wEAAwE;AACxE,yEAAyE;AACzE,8EAA8E;AAC9E,iFAAiF;AACjF,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,MAAM,mBAAmB,GACvB,6FAA6F;IAC7F,mGAAmG;IACnG,yFAAyF;IACzF,sGAAsG,CAAA;AAExG,MAAM,kBAAkB,GACtB,mBAAmB;IACnB,iEAAiE;IACjE,mGAAmG;IACnG,+FAA+F;IAC/F,8FAA8F;IAC9F,kGAAkG;IAClG,6FAA6F;IAC7F,wFAAwF;IACxF,YAAY,CAAA;AAEd,MAAM,mBAAmB,GACvB,mBAAmB;IACnB,uEAAuE;IACvE,oGAAoG;IACpG,iGAAiG;IACjG,4FAA4F;IAC5F,kGAAkG;IAClG,iGAAiG;IACjG,oCAAoC;IACpC,YAAY,CAAA;AAEd,MAAM,UAAU,mBAAmB,CAAC,IAAyB;IAC3D,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAA;AACrE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAyB;IAC5D,OAAO,IAAI,KAAK,QAAQ;QACtB,CAAC,CAAC,2EAA2E;QAC7E,CAAC,CAAC,2EAA2E,CAAA;AACjF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAyB;IAC5D,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,qCAAqC,CAAA;AACzG,CAAC;AAED,yEAAyE;AACzE,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,2EAA2E;AAC3E,+EAA+E;AAC/E,wEAAwE;AACxE,gFAAgF;AAChF,wEAAwE;AACxE,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,uEAAuE;AACvE,iFAAiF;AACjF,oCAAoC;AACpC,MAAM,CAAC,MAAM,yBAAyB,GACpC,sDAAsD;IACtD,8NAA8N;IAC9N,8EAA8E;IAC9E,2FAA2F;IAC3F,mEAAmE;IACnE,sGAAsG;IACtG,oHAAoH;IACpH,+IAA+I;IAC/I,gFAAgF;IAChF,+EAA+E;IAC/E,8DAA8D;IAC9D,0EAA0E;IAC1E,4DAA4D;IAC5D,8EAA8E;IAC9E,0EAA0E;IAC1E,uGAAuG;IACvG,iDAAiD;IACjD,gFAAgF;IAChF,mFAAmF;IACnF,oHAAoH;IACpH,yBAAyB;IACzB,+EAA+E;IAC/E,iFAAiF;IACjF,iFAAiF;IACjF,mBAAmB;IACnB,8GAA8G;IAC9G,gHAAgH;IAChH,4BAA4B,CAAA"}
@@ -96,8 +96,8 @@ export function connectorAuthenticateToolDescription() {
96
96
  // routing language to the visitor — a NO_INTERNALS violation. The public role
97
97
  // keeps plain delivery and relies on the server-level PUBLIC_INSTRUCTIONS.
98
98
  export const ADMIN_REFRAME_INSTRUCTION = 'Dispatch the owning specialist with the Agent tool. ' +
99
- 'Any deliverable artefact email, letter, quote, order, report, PDF, image, page ' +
100
- 'is content-producer work, without exception, including follow-up edits to one already produced. ' +
99
+ 'Every deliverable artefact (email, letter, quote, order, report, PDF, image, page) goes to the installed specialist that owns that artefact type, never produced inline, including follow-up edits to one already produced; ' +
100
+ 'only when no specialist owns the artefact type is it content-producer work. ' +
101
101
  'Else load the owning skill; else (a greeting, quick question, confirmation) just answer. ' +
102
102
  'Artefact work with neither is the violation signal — reconsider. ' +
103
103
  'Your capabilities here are very well defined: before telling the operator something cannot be done, ' +
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"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"}
@@ -45,8 +45,8 @@ export function composeReplyNote(rc) {
45
45
  * the unit tests assert the exact wrapped shape.
46
46
  */
47
47
  export const REFRAME_INSTRUCTION = 'Dispatch the owning specialist with the Agent tool. ' +
48
- 'Any deliverable artefact email, letter, quote, order, report, PDF, image, page ' +
49
- 'is content-producer work, without exception, including follow-up edits to one already produced. ' +
48
+ 'Every deliverable artefact (email, letter, quote, order, report, PDF, image, page) goes to the installed specialist that owns that artefact type, never produced inline, including follow-up edits to one already produced; ' +
49
+ 'only when no specialist owns the artefact type is it content-producer work. ' +
50
50
  'Else load the owning skill; else (a greeting, quick question, confirmation) just answer. ' +
51
51
  'Artefact work with neither is the violation signal — reconsider. ' +
52
52
  'Your capabilities here are very well defined: before telling the sender something cannot be done, ' +
@@ -1 +1 @@
1
- {"version":3,"file":"notification.js","sourceRoot":"","sources":["../src/notification.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"notification.js","sourceRoot":"","sources":["../src/notification.ts"],"names":[],"mappings":"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"}
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CCr-iYLO.js";import{A as t,F as n,K as r,S as i,T as a,U as o,V as s,W as c,_ as l,g as u,k as d,p as f}from"./useSubAccountSwitcher-iQGqNJhI.js";import{C as p,t as m}from"./AdminShell-Gq8DU_ig.js";import{t as h}from"./chevron-left-CQ8rcBoO.js";import{t as g}from"./chevron-right-CSRSqblN.js";import{t as _}from"./clock-B7Ba8AZL.js";var v=n(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),y=n(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),b=n(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),x=n(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),S=n(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),C=c(),w=e(r(),1);function T(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function E(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function D(e){let t=T(e),n=t.getDay();return E(t,n===0?-6:1-n)}function O(e){let t=D(e);return Array.from({length:7},(e,n)=>E(t,n))}function k(e){let t=D(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>E(t,n))}function A(){return Array.from({length:24},(e,t)=>t)}function j(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function M(e,t){switch(e){case`day`:{let e=T(t);return{from:e,to:E(e,1)}}case`week`:{let e=D(t);return{from:e,to:E(e,7)}}case`month`:{let e=D(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:E(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function N(e,t,n){switch(e){case`day`:return E(t,n);case`week`:return E(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function P(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function F(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var I=s(),L=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],R=3;function z(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function B({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=e.getMonth(),a=new Date;return(0,I.jsxs)(`div`,{className:`cal-month`,children:[(0,I.jsx)(`div`,{className:`cal-weekday-row`,children:L.map(e=>(0,I.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,I.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>P(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=P(e,a);return(0,I.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,I.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,R).map(e=>(0,I.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...F(e,n),children:[!e.isAllDay&&(0,I.jsx)(`span`,{className:`cal-chip-time`,children:z(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>R&&(0,I.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-R,` more`]})]},e.toISOString())})})]})}var V=1440,H=1.8;function U(e){return e.getHours()*60+e.getMinutes()}function W(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&P(new Date(t.startsAt),e));return(0,I.jsx)(`div`,{className:`cal-day-col`,children:(0,I.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,I.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=U(n),o=P(i,e)?U(i):V,s=a/V*100,c=Math.max((o-a)/V*100,H);return(0,I.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...F(t,r),children:[(0,I.jsx)(`span`,{className:`cal-event-time`,children:W(n)}),(0,I.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var K=44;function q(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function J({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=new Date;return(0,I.jsxs)(`div`,{className:`cal-timed`,children:[(0,I.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,I.jsxs)(`div`,{className:`cal-day-head${P(e,i)?` cal-day-head-today`:``}`,children:[(0,I.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,I.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,I.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,I.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&P(new Date(t.startsAt),e)).map(e=>(0,I.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...F(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,I.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,I.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${K}px`},children:e===0?``:q(e)},e))}),r.map(e=>(0,I.jsx)(G,{day:e,meetings:t,hourHeight:K,onSelect:n},e.toISOString()))]})]})}var Y=52;function X(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Z({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&P(new Date(t.startsAt),e));return(0,I.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,I.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,I.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,I.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...F(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,I.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,I.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${Y}px`},children:e===0?``:X(e)},e))}),(0,I.jsx)(G,{day:e,meetings:t,hourHeight:Y,onSelect:n})]})]})}var ee=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function te(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>te(new Date(e.startsAt))));return(0,I.jsx)(`div`,{className:`cal-year`,children:(0,I.jsx)(`div`,{className:`cal-year-grid`,children:j(e).map(e=>{let t=k(e),a=e.getMonth();return(0,I.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,I.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,I.jsx)(`div`,{className:`cal-mini-weekrow`,children:ee.map((e,t)=>(0,I.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,I.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=P(e,r),o=!t&&i.has(te(e));return(0,I.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,I.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,I.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,I.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,I.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:n,onClose:r,onSaved:o,onDeleted:s}){let c=e.kind===`meeting`,[d,f]=(0,w.useState)(!1),[p,m]=(0,w.useState)(!1),[h,g]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(e),[A,j]=(0,w.useState)(e.title??``),[M,N]=(0,w.useState)(ie(e.startsAt)),[P,F]=(0,w.useState)(e.endsAt?ie(e.endsAt):``),[L,R]=(0,w.useState)(e.location??``),[z,B]=(0,w.useState)(e.privateNote??``),[V,H]=(0,w.useState)(``),[U,W]=(0,w.useState)(``);(0,w.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!C&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,r]);let G=(0,w.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=ae(M);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=P?ae(P):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=L.trim()||null;i!==(O.location??null)&&(e.location=i);let a=z.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,M,P,L,z,O]),K=(0,w.useCallback)(async()=>{let t=G();if(Object.keys(t).length===0){f(!1);return}T(!0),D(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();k(i.meeting),o(i.meeting),f(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{T(!1)}},[n,G,e.meetingId,o]),q=(0,w.useCallback)(async()=>{let t=V.trim(),r=U.trim();if(!(!t&&!r)){T(!0),D(null);try{let i=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:r||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),o(a.meeting),H(``),W(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{T(!1)}}},[n,V,U,e.meetingId,o]),J=(0,w.useCallback)(async t=>{let r=t.email?{email:t.email}:{name:t.name};T(!0),D(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();k(i.meeting),o(i.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{T(!1)}},[n,e.meetingId,o]),Y=(0,w.useCallback)(async()=>{T(!0),D(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);s(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),T(!1)}},[n,e.meetingId,s]),X=(0,w.useCallback)(async t=>{g(!1),T(!0),D(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=se(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{T(!1)}},[n,e.meetingId]),Z=re[e.kind??`meeting`],ee=V.trim().length>0||U.trim().length>0;return(0,I.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{C||r()},children:(0,I.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":d?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,I.jsx)(`span`,{className:`cal-modal-kind`,children:Z}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:C,children:(0,I.jsx)(u,{size:16})})]}),!d&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(_,{size:14}),(0,I.jsx)(`span`,{children:oe(O)})]}),O.location&&(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(y,{size:14}),(0,I.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,I.jsx)(S,{size:14}),(0,I.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,I.jsx)(`div`,{className:`cal-attendee-row`,children:(0,I.jsx)(le,{a:e})},ce(e,t)))})]}),O.privateNote&&(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,I.jsx)(b,{size:14}),(0,I.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,I.jsx)(v,{size:14}),(0,I.jsx)(`span`,{children:Z})]})]}),d&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Title`}),(0,I.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Start`}),(0,I.jsx)(`input`,{type:`datetime-local`,value:M,onChange:e=>N(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`End`}),(0,I.jsx)(`input`,{type:`datetime-local`,value:P,onChange:e=>F(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Location`}),(0,I.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),disabled:C})]}),(0,I.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Attendees`}),(0,I.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,I.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,I.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,I.jsx)(le,{a:e}),(0,I.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>J(e),disabled:C,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,I.jsx)(u,{size:13})})]},ce(e,t)))]}),(0,I.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,I.jsx)(`input`,{type:`text`,placeholder:`Name`,value:V,onChange:e=>H(e.target.value),disabled:C,"aria-label":`Attendee name`}),(0,I.jsx)(`input`,{type:`email`,placeholder:`Email`,value:U,onChange:e=>W(e.target.value),disabled:C,"aria-label":`Attendee email`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:q,disabled:C||!ee,"aria-label":`Add attendee`,children:C?(0,I.jsx)(a,{size:13,className:`spin`}):(0,I.jsx)(x,{size:13})})]})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Private note`}),(0,I.jsx)(`textarea`,{className:`cal-modal-textarea`,value:z,onChange:e=>B(e.target.value),disabled:C,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,I.jsx)(`div`,{className:`cal-modal-error`,children:E}),c&&(0,I.jsxs)(`div`,{className:`cal-modal-actions`,children:[!d&&!p&&!h&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>f(!0),disabled:C,children:[(0,I.jsx)(i,{size:14}),` Edit`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:C,children:[(0,I.jsx)(l,{size:14}),` Delete`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?g(!0):X(!1)},disabled:C,children:[C?(0,I.jsx)(a,{size:14,className:`spin`}):(0,I.jsx)(t,{size:14}),` Download`]})]}),h&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>X(!0),disabled:C,children:[C?(0,I.jsx)(a,{size:14,className:`spin`}):null,` Yes`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>X(!1),disabled:C,children:`No`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>g(!1),disabled:C,children:`Cancel`})]}),d&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:K,disabled:C,children:[C?(0,I.jsx)(a,{size:14,className:`spin`}):null,` Save`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{f(!1),D(null)},disabled:C,children:`Cancel`})]}),p&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:Y,disabled:C,children:[C?(0,I.jsx)(a,{size:14,className:`spin`}):null,` Delete`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:C,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=M(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,t]=(0,w.useState)(null),[n,r]=(0,w.useState)(!1),[i,o]=(0,w.useState)(void 0),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(void 0),[d,h]=(0,w.useState)(null),[g,_]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,w.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,w.useState)(!1),x=(0,w.useCallback)(async()=>{b(!0);try{let e=await p();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,I.jsx)(f,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,I.jsx)(m,{cacheKey:e,businessName:i,sessionId:s,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:d,role:g,children:(0,I.jsx)(me,{cacheKey:e})})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-empty`,children:[(0,I.jsx)(`p`,{children:`You are not signed in.`}),(0,I.jsxs)(`p`,{children:[`Open the `,(0,I.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-loading`,children:[(0,I.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=o({initialCacheKey:e,surface:`calendar`}),[r,i]=(0,w.useState)(`month`),[s,c]=(0,w.useState)(()=>new Date),[l,u]=(0,w.useState)([]),[f,p]=(0,w.useState)(!1),[m,_]=(0,w.useState)(null),[v,y]=(0,w.useState)(null),[b,x]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1;return t(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&x(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[t]),(0,w.useEffect)(()=>{let e=!1,{from:n,to:i}=M(r,s);return p(!0),_(null),t(`/api/admin/calendar/meetings?from=${encodeURIComponent(n.toISOString())}&to=${encodeURIComponent(i.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();u(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(_(t instanceof Error?t.message:`Failed to load`),u([]))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[r,s,n,t]);let S=(0,w.useCallback)(()=>c(new Date),[]),C=(0,w.useCallback)(()=>c(e=>N(r,e,-1)),[r]),T=(0,w.useCallback)(()=>c(e=>N(r,e,1)),[r]),E=(0,w.useCallback)(e=>{c(e),i(`month`)},[]);(0,w.useEffect)(()=>{y(null)},[r,s]);let D=(0,w.useCallback)(e=>{u(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),y(e)},[]),O=(0,w.useCallback)(e=>{u(t=>t.filter(t=>t.meetingId!==e)),y(null)},[]);return(0,I.jsxs)(`div`,{className:`cal-page`,children:[(0,I.jsxs)(`header`,{className:`cal-header`,children:[(0,I.jsxs)(`div`,{className:`cal-nav`,children:[(0,I.jsx)(`span`,{className:`cal-range-label`,children:fe(r,s)}),(0,I.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:C,"aria-label":`Previous`,children:(0,I.jsx)(h,{size:18})}),(0,I.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Next`,children:(0,I.jsx)(g,{size:18})}),(0,I.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:S,children:`Today`}),f&&(0,I.jsx)(a,{size:16,className:`spin`})]}),(0,I.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===r?` cal-view-btn-active`:``}`,onClick:()=>i(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),b&&(0,I.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${b}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(d,{size:14}),` Booking page`]})]}),(0,I.jsxs)(`div`,{className:`cal-body`,children:[m&&(0,I.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,m]}),r===`day`&&(0,I.jsx)(Z,{anchor:s,meetings:l,onSelect:y}),r===`week`&&(0,I.jsx)(J,{anchor:s,meetings:l,onSelect:y}),r===`month`&&(0,I.jsx)(B,{anchor:s,meetings:l,onSelect:y}),r===`year`&&(0,I.jsx)(ne,{anchor:s,meetings:l,onPickMonth:E})]}),v&&(0,I.jsx)(ue,{meeting:v,adminFetch:t,onClose:()=>y(null),onSaved:D,onDeleted:O})]})}(0,C.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(pe,{}));
1
+ import{o as e}from"./chunk-CCr-iYLO.js";import{A as t,F as n,K as r,S as i,T as a,U as o,V as s,W as c,_ as l,g as u,k as d,p as f}from"./useSubAccountSwitcher-iQGqNJhI.js";import{C as p,t as m}from"./AdminShell-Gq8DU_ig.js";import{t as h}from"./chevron-left-CQ8rcBoO.js";import{t as g}from"./chevron-right-CSRSqblN.js";import{t as _}from"./clock-B7Ba8AZL.js";var v=n(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),y=n(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),b=n(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),x=n(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),S=n(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),C=c(),w=e(r(),1);function T(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function E(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function D(e){let t=T(e),n=t.getDay();return E(t,n===0?-6:1-n)}function O(e){let t=D(e);return Array.from({length:7},(e,n)=>E(t,n))}function k(e){let t=D(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>E(t,n))}function A(){return Array.from({length:24},(e,t)=>t)}function j(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function M(e,t){switch(e){case`day`:{let e=T(t);return{from:e,to:E(e,1)}}case`week`:{let e=D(t);return{from:e,to:E(e,7)}}case`month`:{let e=D(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:E(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function N(e,t,n){switch(e){case`day`:return E(t,n);case`week`:return E(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function P(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function F(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var I=s(),L=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],R=3;function z(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function B({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=e.getMonth(),a=new Date;return(0,I.jsxs)(`div`,{className:`cal-month`,children:[(0,I.jsx)(`div`,{className:`cal-weekday-row`,children:L.map(e=>(0,I.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,I.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>P(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=P(e,a);return(0,I.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,I.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,R).map(e=>(0,I.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...F(e,n),children:[!e.isAllDay&&(0,I.jsx)(`span`,{className:`cal-chip-time`,children:z(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>R&&(0,I.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-R,` more`]})]},e.toISOString())})})]})}var V=1440,H=1.8;function U(e){return e.getHours()*60+e.getMinutes()}function W(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function G({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&P(new Date(t.startsAt),e));return(0,I.jsx)(`div`,{className:`cal-day-col`,children:(0,I.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,I.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=U(n),o=P(i,e)?U(i):V,s=a/V*100,c=Math.max((o-a)/V*100,H);return(0,I.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...F(t,r),children:[(0,I.jsx)(`span`,{className:`cal-event-time`,children:W(n)}),(0,I.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var K=44;function q(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function J({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=new Date;return(0,I.jsxs)(`div`,{className:`cal-timed`,children:[(0,I.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,I.jsxs)(`div`,{className:`cal-day-head${P(e,i)?` cal-day-head-today`:``}`,children:[(0,I.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,I.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,I.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,I.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&P(new Date(t.startsAt),e)).map(e=>(0,I.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...F(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,I.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,I.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${K}px`},children:e===0?``:q(e)},e))}),r.map(e=>(0,I.jsx)(G,{day:e,meetings:t,hourHeight:K,onSelect:n},e.toISOString()))]})]})}var Y=52;function X(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Z({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&P(new Date(t.startsAt),e));return(0,I.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,I.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,I.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,I.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...F(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,I.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,I.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,I.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${Y}px`},children:e===0?``:X(e)},e))}),(0,I.jsx)(G,{day:e,meetings:t,hourHeight:Y,onSelect:n})]})]})}var ee=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function te(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>te(new Date(e.startsAt))));return(0,I.jsx)(`div`,{className:`cal-year`,children:(0,I.jsx)(`div`,{className:`cal-year-grid`,children:j(e).map(e=>{let t=k(e),a=e.getMonth();return(0,I.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,I.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,I.jsx)(`div`,{className:`cal-mini-weekrow`,children:ee.map((e,t)=>(0,I.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,I.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=P(e,r),o=!t&&i.has(te(e));return(0,I.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,I.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,I.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,I.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,I.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:n,onClose:r,onSaved:o,onDeleted:s}){let c=e.kind===`meeting`,[d,f]=(0,w.useState)(!1),[p,m]=(0,w.useState)(!1),[h,g]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(e),[A,j]=(0,w.useState)(e.title??``),[M,N]=(0,w.useState)(ie(e.startsAt)),[P,F]=(0,w.useState)(e.endsAt?ie(e.endsAt):``),[L,R]=(0,w.useState)(e.location??``),[z,B]=(0,w.useState)(e.privateNote??``),[V,H]=(0,w.useState)(``),[U,W]=(0,w.useState)(``);(0,w.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!C&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,r]);let G=(0,w.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=ae(M);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=P?ae(P):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=L.trim()||null;i!==(O.location??null)&&(e.location=i);let a=z.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,M,P,L,z,O]),K=(0,w.useCallback)(async()=>{let t=G();if(Object.keys(t).length===0){f(!1);return}T(!0),D(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.json();k(i.meeting),o(i.meeting),f(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{T(!1)}},[n,G,e.meetingId,o]),q=(0,w.useCallback)(async()=>{let t=V.trim(),r=U.trim();if(!(!t&&!r)){T(!0),D(null);try{let i=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t||void 0,email:r||void 0})});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),o(a.meeting),H(``),W(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{T(!1)}}},[n,V,U,e.meetingId,o]),J=(0,w.useCallback)(async t=>{let r=t.email?{email:t.email}:{name:t.name};T(!0),D(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=await t.json();k(i.meeting),o(i.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{T(!1)}},[n,e.meetingId,o]),Y=(0,w.useCallback)(async()=>{T(!0),D(null);try{let t=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);s(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),T(!1)}},[n,e.meetingId,s]),X=(0,w.useCallback)(async t=>{g(!1),T(!0),D(null);try{let r=await n(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${t?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=se(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{T(!1)}},[n,e.meetingId]),Z=re[e.kind??`meeting`],ee=V.trim().length>0||U.trim().length>0;return(0,I.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{C||r()},children:(0,I.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":d?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,I.jsx)(`span`,{className:`cal-modal-kind`,children:Z}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:C,children:(0,I.jsx)(u,{size:16})})]}),!d&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(_,{size:14}),(0,I.jsx)(`span`,{children:oe(O)})]}),O.location&&(0,I.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,I.jsx)(y,{size:14}),(0,I.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,I.jsx)(S,{size:14}),(0,I.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,I.jsx)(`div`,{className:`cal-attendee-row`,children:(0,I.jsx)(le,{a:e})},ce(e,t)))})]}),O.privateNote&&(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,I.jsx)(b,{size:14}),(0,I.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,I.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,I.jsx)(v,{size:14}),(0,I.jsx)(`span`,{children:Z})]})]}),d&&(0,I.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Title`}),(0,I.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Start`}),(0,I.jsx)(`input`,{type:`datetime-local`,value:M,onChange:e=>N(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`End`}),(0,I.jsx)(`input`,{type:`datetime-local`,value:P,onChange:e=>F(e.target.value),disabled:C})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Location`}),(0,I.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),disabled:C})]}),(0,I.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Attendees`}),(0,I.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,I.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,I.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,I.jsx)(le,{a:e}),(0,I.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>J(e),disabled:C,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,I.jsx)(u,{size:13})})]},ce(e,t)))]}),(0,I.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,I.jsx)(`input`,{type:`text`,placeholder:`Name`,value:V,onChange:e=>H(e.target.value),disabled:C,"aria-label":`Attendee name`}),(0,I.jsx)(`input`,{type:`email`,placeholder:`Email`,value:U,onChange:e=>W(e.target.value),disabled:C,"aria-label":`Attendee email`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:q,disabled:C||!ee,"aria-label":`Add attendee`,children:C?(0,I.jsx)(a,{size:13,className:`spin`}):(0,I.jsx)(x,{size:13})})]})]}),(0,I.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,I.jsx)(`span`,{children:`Private note`}),(0,I.jsx)(`textarea`,{className:`cal-modal-textarea`,value:z,onChange:e=>B(e.target.value),disabled:C,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,I.jsx)(`div`,{className:`cal-modal-error`,children:E}),c&&(0,I.jsxs)(`div`,{className:`cal-modal-actions`,children:[!d&&!p&&!h&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>f(!0),disabled:C,children:[(0,I.jsx)(i,{size:14}),` Edit`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:C,children:[(0,I.jsx)(l,{size:14}),` Delete`]}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?g(!0):X(!1)},disabled:C,children:[C?(0,I.jsx)(a,{size:14,className:`spin`}):(0,I.jsx)(t,{size:14}),` Download`]})]}),h&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>X(!0),disabled:C,children:[C?(0,I.jsx)(a,{size:14,className:`spin`}):null,` Yes`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>X(!1),disabled:C,children:`No`}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>g(!1),disabled:C,children:`Cancel`})]}),d&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:K,disabled:C,children:[C?(0,I.jsx)(a,{size:14,className:`spin`}):null,` Save`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{f(!1),D(null)},disabled:C,children:`Cancel`})]}),p&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,I.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:Y,disabled:C,children:[C?(0,I.jsx)(a,{size:14,className:`spin`}):null,` Delete`]}),(0,I.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:C,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=M(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,t]=(0,w.useState)(null),[n,r]=(0,w.useState)(!1),[i,o]=(0,w.useState)(void 0),[s,c]=(0,w.useState)(null),[l,u]=(0,w.useState)(void 0),[d,h]=(0,w.useState)(null),[g,_]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),u(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,w.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,w.useState)(!1),x=(0,w.useCallback)(async()=>{b(!0);try{let e=await p();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,I.jsx)(f,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,I.jsx)(m,{cacheKey:e,businessName:i,sessionId:s,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:d,role:g,children:(0,I.jsx)(me,{cacheKey:e})})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-empty`,children:[(0,I.jsx)(`p`,{children:`You are not signed in.`}),(0,I.jsxs)(`p`,{children:[`Open the `,(0,I.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,I.jsx)(`div`,{className:`cal-page`,children:(0,I.jsxs)(`div`,{className:`cal-loading`,children:[(0,I.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=o({initialCacheKey:e,surface:`calendar`}),[r,i]=(0,w.useState)(`month`),[s,c]=(0,w.useState)(()=>new Date),[l,u]=(0,w.useState)([]),[f,p]=(0,w.useState)(!1),[m,_]=(0,w.useState)(null),[v,y]=(0,w.useState)(null),[b,x]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1;return t(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&x(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[t]),(0,w.useEffect)(()=>{let e=!1,{from:n,to:i}=M(r,s);return p(!0),_(null),t(`/api/admin/calendar/meetings?from=${encodeURIComponent(n.toISOString())}&to=${encodeURIComponent(i.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();u(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(_(t instanceof Error?t.message:`Failed to load`),u([]))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[r,s,n,t]);let S=(0,w.useCallback)(()=>c(new Date),[]),C=(0,w.useCallback)(()=>c(e=>N(r,e,-1)),[r]),T=(0,w.useCallback)(()=>c(e=>N(r,e,1)),[r]),E=(0,w.useCallback)(e=>{c(e),i(`month`)},[]);(0,w.useEffect)(()=>{y(null)},[r,s]);let D=(0,w.useCallback)(e=>{u(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),y(e)},[]),O=(0,w.useCallback)(e=>{u(t=>t.filter(t=>t.meetingId!==e)),y(null)},[]);return(0,I.jsxs)(`div`,{className:`cal-page`,children:[(0,I.jsxs)(`header`,{className:`cal-header`,children:[(0,I.jsxs)(`div`,{className:`cal-nav`,children:[(0,I.jsx)(`span`,{className:`cal-range-label`,children:fe(r,s)}),(0,I.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:C,"aria-label":`Previous`,children:(0,I.jsx)(h,{size:18})}),(0,I.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Next`,children:(0,I.jsx)(g,{size:18})}),(0,I.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:S,children:`Today`}),f&&(0,I.jsx)(a,{size:16,className:`spin`})]}),(0,I.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===r?` cal-view-btn-active`:``}`,onClick:()=>i(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),b&&(0,I.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${b}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(d,{size:14}),` Booking page`]})]}),(0,I.jsxs)(`div`,{className:`cal-body`,children:[m&&(0,I.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,m]}),r===`day`&&(0,I.jsx)(Z,{anchor:s,meetings:l,onSelect:y}),r===`week`&&(0,I.jsx)(J,{anchor:s,meetings:l,onSelect:y}),r===`month`&&(0,I.jsx)(B,{anchor:s,meetings:l,onSelect:y}),r===`year`&&(0,I.jsx)(ne,{anchor:s,meetings:l,onPickMonth:E})]}),v&&(0,I.jsx)(ue,{meeting:v,adminFetch:t,onClose:()=>y(null),onSaved:D,onDeleted:O})]})}(0,C.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(pe,{}));
@@ -1 +1 @@
1
- import{V as e,W as t}from"./useSubAccountSwitcher-iQGqNJhI.js";import"./useVoiceRecorder-v--TIxaM.js";import"./AdminShell-Gq8DU_ig.js";import{n}from"./page-DomkejEB.js";import"./useCopyFeedback-DN1WA5vU.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
1
+ import{V as e,W as t}from"./useSubAccountSwitcher-iQGqNJhI.js";import"./useVoiceRecorder-v--TIxaM.js";import"./AdminShell-Gq8DU_ig.js";import{n}from"./page-Bs24tO-C.js";import"./useCopyFeedback-DN1WA5vU.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CCr-iYLO.js";import{K as t,V as n,W as r}from"./useSubAccountSwitcher-iQGqNJhI.js";import{n as i,t as a}from"./AdminLoginScreens-Bv_bKKeL.js";import"./useVoiceRecorder-v--TIxaM.js";import"./AdminShell-Gq8DU_ig.js";import{t as o}from"./page-DomkejEB.js";import"./useCopyFeedback-DN1WA5vU.js";var s=r(),c=e(t(),1),l=n();function u(){let e=i(`operator`),t=(0,c.useRef)(null);return(0,c.useEffect)(()=>{e.appState!==`chat`&&t.current!==e.appState&&(t.current=e.appState,console.info(`[operator-ui] op=auth-gate state=${e.appState}`))},[e.appState]),e.appState===`chat`?(0,l.jsx)(o,{variant:`operator`,forceCanonicalSession:window.location.pathname!==`/chat`}):(0,l.jsx)(a,{auth:e})}(0,s.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(u,{}));
1
+ import{o as e}from"./chunk-CCr-iYLO.js";import{K as t,V as n,W as r}from"./useSubAccountSwitcher-iQGqNJhI.js";import{n as i,t as a}from"./AdminLoginScreens-Bv_bKKeL.js";import"./useVoiceRecorder-v--TIxaM.js";import"./AdminShell-Gq8DU_ig.js";import{t as o}from"./page-Bs24tO-C.js";import"./useCopyFeedback-DN1WA5vU.js";var s=r(),c=e(t(),1),l=n();function u(){let e=i(`operator`),t=(0,c.useRef)(null);return(0,c.useEffect)(()=>{e.appState!==`chat`&&t.current!==e.appState&&(t.current=e.appState,console.info(`[operator-ui] op=auth-gate state=${e.appState}`))},[e.appState]),e.appState===`chat`?(0,l.jsx)(o,{variant:`operator`,forceCanonicalSession:window.location.pathname!==`/chat`}):(0,l.jsx)(a,{auth:e})}(0,s.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(u,{}));
@@ -29,4 +29,4 @@ import{o as e,r as t,t as n}from"./chunk-CCr-iYLO.js";import{F as r,K as i,M as
29
29
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
30
30
  `,...a.current()});return/^[\t ]/.test(l)&&(l=wc(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Ac.peek=jc;function Ac(e){return e.value||``}function jc(){return`<`}Mc.peek=Nc;function Mc(e,t,n,r){let i=xc(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function Nc(){return`!`}Pc.peek=Fc;function Pc(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Fc(){return`!`}Ic.peek=Lc;function Ic(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Lc(){return"`"}function Rc(e,t){let n=vn(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}zc.peek=Bc;function zc(e,t,n,r){let i=xc(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Rc(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Bc(e,t,n){return Rc(e,n)?`<`:`[`}Vc.peek=Hc;function Vc(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Hc(){return`[`}function Uc(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Wc(e){let t=Uc(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Gc(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Kc(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function qc(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Gc(n):Uc(n),s=e.ordered?o===`.`?`)`:`.`:Wc(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Kc(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Jc(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Yc(e,t,n,r){let i=Jc(n),a=n.bulletCurrent||Uc(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function Xc(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Zc=ro([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Qc(e,t,n,r){return(e.children.some(function(e){return Zc(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function $c(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}el.peek=tl;function el(e,t,n,r){let i=$c(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=Tc(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=wc(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Tc(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+wc(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function tl(e,t,n){return n.options.strong||`*`}function nl(e,t,n,r){return n.safe(e.value,r)}function rl(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function il(e,t,n){let r=(Kc(n)+(n.options.ruleSpaces?` `:``)).repeat(rl(n));return n.options.ruleSpaces?r.slice(0,-1):r}var al={blockquote:dc,break:hc,code:yc,definition:Sc,emphasis:Ec,hardBreak:hc,heading:kc,html:Ac,image:Mc,imageReference:Pc,inlineCode:Ic,link:zc,linkReference:Vc,list:qc,listItem:Yc,paragraph:Xc,root:Qc,strong:el,text:nl,thematicBreak:il};function ol(){return{enter:{table:sl,tableData:dl,tableHeader:dl,tableRow:ll},exit:{codeText:fl,table:cl,tableData:ul,tableHeader:ul,tableRow:ul}}}function sl(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function cl(e){this.exit(e),this.data.inTable=void 0}function ll(e){this.enter({type:`tableRow`,children:[]},e)}function ul(e){this.exit(e)}function dl(e){this.enter({type:`tableCell`,children:[]},e)}function fl(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,pl));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function pl(e,t){return t===`|`?t:e}function ml(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
31
31
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
32
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return cc(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=al.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function hl(){return{exit:{taskListCheckValueChecked:_l,taskListCheckValueUnchecked:_l,paragraph:vl}}}function gl(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:yl}}}function _l(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function vl(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function yl(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=al.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function bl(){return[Es(),Xs(),tc(),ol(),hl()]}function xl(e){return{extensions:[Ds(),Zs(e),nc(),ml(e),gl()]}}var Sl={tokenize:Il,partial:!0},Cl={tokenize:Ll,partial:!0},wl={tokenize:Rl,partial:!0},Tl={tokenize:zl,partial:!0},El={tokenize:Bl,partial:!0},Dl={name:`wwwAutolink`,tokenize:Pl,previous:Vl},Ol={name:`protocolAutolink`,tokenize:Fl,previous:Hl},kl={name:`emailAutolink`,tokenize:Nl,previous:Ul},Al={};function jl(){return{text:Al}}for(var Ml=48;Ml<123;)Al[Ml]=kl,Ml++,Ml===58?Ml=65:Ml===91&&(Ml=97);Al[43]=kl,Al[45]=kl,Al[46]=kl,Al[95]=kl,Al[72]=[kl,Ol],Al[104]=[kl,Ol],Al[87]=[kl,Dl],Al[119]=[kl,Dl];function Nl(e,t,n){let r=this,i,a;return o;function o(t){return!Wl(t)||!Ul.call(r,r.previous)||Gl(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Wl(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(El,u,l)(t):t===45||t===95||K(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&G(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Pl(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Vl.call(r,r.previous)||Gl(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Sl,e.attempt(Cl,e.attempt(wl,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Fl(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Hl.call(r,r.previous)&&!Gl(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(G(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Mn(t)||J(t)||Ln(t)||In(t)?n(t):e.attempt(Cl,e.attempt(wl,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Il(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Ll(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Tl,c,s)(t):t===null||J(t)||Ln(t)||t!==45&&In(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Rl(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Tl,t,a)(o):o===null||J(o)||Ln(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zl(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||J(o)||Ln(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||J(e)||Ln(e)?t(e):r(e)}function a(e){return G(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):G(t)?(e.consume(t),o):n(t)}}function Bl(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return K(e)?n(e):t(e)}}function Vl(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||J(e)}function Hl(e){return!G(e)}function Ul(e){return!(e===47||Wl(e))}function Wl(e){return e===43||e===45||e===46||e===95||K(e)}function Gl(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Kl={tokenize:eu,partial:!0};function ql(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Zl,continuation:{tokenize:Ql},exit:$l}},text:{91:{name:`gfmFootnoteCall`,tokenize:Xl},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Jl,resolveTo:Yl}}}}function Jl(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=An(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Yl(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Xl(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||J(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(An(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return J(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Zl(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||J(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=An(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return J(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),X(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Ql(e,t,n){return e.check(er,t,e.attempt(Kl,t,n))}function $l(e){e.exit(`gfmFootnoteDefinition`)}function eu(e,t,n){let r=this;return X(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function tu(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&W(o,o.length,0,qn(s,e.slice(r+1,n),t)),W(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),W(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Kn(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Kn(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var nu=class{constructor(){this.map=[]}add(e,t,n){ru(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function ru(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function iu(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function au(){return{flow:{null:{name:`table`,tokenize:ou,resolveAll:su}}}}function ou(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||J(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||J(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function su(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new nu;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(lu(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=cu(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=cu(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=cu(f,t,o,i,n,d)):(o[0]=o[1],d=cu(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&lu(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=iu(t.events,n))}return e}function cu(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},uu(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=uu(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=uu(t.events,n[2]),a=uu(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},uu(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function lu(e,t,n,r,i){let a=[],o=uu(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function uu(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var du={name:`tasklistCheck`,tokenize:pu};function fu(){return{text:{91:du}}}function pu(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return J(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):Y(r)?e.check({tokenize:mu},t,n)(r):n(r)}}function mu(e,t,n){return X(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function hu(e){return En([jl(),ql(),tu(e),au(),fu()])}var gu={};function _u(e){let t=this,n=e||gu,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(hu(n)),a.push(bl()),o.push(xl(n))}var vu=null;function yu(){return vu||=Pe(async()=>{let{default:e}=await import(`./mermaid.core-Durk4m6D.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({default:e})=>(e.initialize({startOnLoad:!1,theme:`neutral`}),e)),vu}function bu({source:e}){let t=(0,$.useRef)(null),[n,r]=(0,$.useState)(null);return(0,$.useEffect)(()=>{let n=!1,i=`mermaid-${Math.random().toString(36).slice(2,9)}`;return yu().then(t=>t.render(i,e)).then(({svg:e})=>{!n&&t.current&&(t.current.innerHTML=e)}).catch(t=>{n||(console.error(`[MermaidBlock] render failed:`,e,t),r(t instanceof Error?t.message:`Diagram render failed`))}),()=>{n=!0}},[e]),n?(0,Q.jsxs)(`div`,{className:`md-mermaid md-mermaid-error`,children:[(0,Q.jsx)(`div`,{className:`md-mermaid-error-label`,children:`Diagram render error`}),(0,Q.jsx)(`pre`,{className:`md-pre`,children:(0,Q.jsx)(`code`,{className:`md-code`,children:e})})]}):(0,Q.jsx)(`div`,{className:`md-mermaid`,ref:t})}var xu=/\.(mp4|webm|mov)(\?.*)?$/i,Su=/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/,Cu=/vimeo\.com\/(\d+)/;function wu(e){return!!e&&xu.test(e)}function Tu(e){if(!e)return null;let t=e.match(Su);return t?t[1]:null}function Eu(e){if(!e)return null;let t=e.match(Cu);return t?t[1]:null}function Du({src:e}){return(0,Q.jsx)(`video`,{className:`md-video`,controls:!0,playsInline:!0,preload:`metadata`,children:(0,Q.jsx)(`source`,{src:e})})}function Ou({videoId:e}){return(0,Q.jsx)(`div`,{className:`md-video-iframe`,children:(0,Q.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${e}`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function ku({videoId:e}){return(0,Q.jsx)(`div`,{className:`md-video-iframe`,children:(0,Q.jsx)(`iframe`,{src:`https://player.vimeo.com/video/${e}`,allow:`autoplay; fullscreen; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function Au(e){if(wu(e))return(0,Q.jsx)(Du,{src:e});let t=Tu(e);if(t)return(0,Q.jsx)(Ou,{videoId:t});let n=Eu(e);return n?(0,Q.jsx)(ku,{videoId:n}):null}var ju={p:({children:e})=>(0,Q.jsx)(`p`,{className:`md-p`,children:e}),h1:({children:e})=>(0,Q.jsx)(`h1`,{className:`md-heading`,children:e}),h2:({children:e})=>(0,Q.jsx)(`h2`,{className:`md-heading`,children:e}),h3:({children:e})=>(0,Q.jsx)(`h3`,{className:`md-heading`,children:e}),code:({children:e,className:t})=>t===`language-mermaid`?(0,Q.jsx)(bu,{source:String(e).replace(/\n$/,``)}):(0,Q.jsx)(`code`,{className:`md-code ${t||``}`.trim(),children:e}),pre:({children:e,node:t})=>{let n=t?.children?.[0];return n?.type===`element`&&n.tagName===`code`&&(n.properties?.className??[]).includes(`language-mermaid`)?(0,Q.jsx)(Q.Fragment,{children:e}):(0,Q.jsx)(`pre`,{className:`md-pre`,children:e})},ul:({children:e})=>(0,Q.jsx)(`ul`,{className:`md-list`,children:e}),ol:({children:e})=>(0,Q.jsx)(`ol`,{className:`md-list md-list-ordered`,children:e}),li:({children:e})=>(0,Q.jsx)(`li`,{className:`md-list-item`,children:e}),hr:()=>(0,Q.jsx)(`hr`,{className:`md-hr`}),strong:({children:e})=>(0,Q.jsx)(`strong`,{className:`md-strong`,children:e}),img:({src:e,alt:t})=>Au(e)||(0,Q.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:(0,Q.jsx)(`img`,{className:`md-img`,src:e,alt:t||``,loading:`lazy`})}),a:({href:e,children:t})=>Au(e)||(0,Q.jsx)(`a`,{href:e,className:`md-link`,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({children:e})=>(0,Q.jsx)(`table`,{className:`md-table`,children:e}),thead:({children:e})=>(0,Q.jsx)(`thead`,{className:`md-thead`,children:e}),tbody:({children:e})=>(0,Q.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,Q.jsx)(`tr`,{className:`md-tr`,children:e}),th:({children:e})=>(0,Q.jsx)(`th`,{className:`md-th`,children:e}),td:({children:e})=>(0,Q.jsx)(`td`,{className:`md-td`,children:e})};function Mu({content:e,elapsedSeconds:t,timestamp:n}){return(0,Q.jsxs)(`div`,{className:`markdown-message`,children:[(0,Q.jsx)(ps,{remarkPlugins:[_u],components:ju,children:e}),t!==void 0&&(0,Q.jsxs)(`div`,{className:`message-meta`,children:[t,`s`]}),n&&(0,Q.jsx)(`span`,{className:`message-timestamp`,children:n})]})}var Nu=`Accomplishing.Actioning.Actualizing.Architecting.Baking.Beaming.Befuddling.Billowing.Blanching.Bloviating.Boogieing.Boondoggling.Booping.Bootstrapping.Brewing.Bunning.Burrowing.Calculating.Canoodling.Caramelizing.Cascading.Catapulting.Cerebrating.Channeling.Channelling.Choreographing.Churning.Clauding.Coalescing.Cogitating.Combobulating.Composing.Computing.Concocting.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Crystallizing.Cultivating.Deciphering.Deliberating.Determining.Discombobulating.Doing.Doodling.Drizzling.Ebbing.Effecting.Elucidating.Embellishing.Enchanting.Envisioning.Evaporating.Fermenting.Finagling.Flibbertigibbeting.Flowing.Flummoxing.Fluttering.Forging.Forming.Frolicking.Frosting.Gallivanting.Galloping.Garnishing.Generating.Germinating.Gesticulating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hatching.Herding.Honking.Hullaballooing.Hyperspacing.Ideating.Imagining.Improvising.Incubating.Inferring.Infusing.Ionizing.Jitterbugging.Julienning.Kneading.Leavening.Levitating.Lollygagging.Manifesting.Marinating.Meandering.Metamorphosing.Misting.Moonwalking.Moseying.Mulling.Musing.Mustering.Nebulizing.Nesting.Newspapering.Noodling.Nucleating.Orbiting.Orchestrating.Osmosing.Perambulating.Percolating.Perusing.Philosophising.Photosynthesizing.Pollinating.Pondering.Pontificating.Pouncing.Precipitating.Prestidigitating.Processing.Proofing.Propagating.Puttering.Puzzling.Quantumizing.Razzmatazzing.Recombobulating.Reticulating.Roosting.Ruminating.Scampering.Schlepping.Scurrying.Seasoning.Shenaniganing.Shimmying.Simmering.Skedaddling.Sketching.Slithering.Smooshing.Spelunking.Spinning.Sprouting.Stewing.Sublimating.Swirling.Swooping.Symbioting.Synthesizing.Tempering.Thinking.Thundering.Tinkering.Tomfoolering.Transfiguring.Transmuting.Twisting.Undulating.Unfurling.Unravelling.Vibing.Waddling.Wandering.Warping.Whatchamacalliting.Whirlpooling.Whirring.Whisking.Wibbling.Working.Wrangling.Zesting.Zigzagging`.split(`.`),Pu=3e5,Fu=9e4,Iu=4e3,Lu=2500;function Ru(e){let t=Math.max(0,Math.floor(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function zu({activity:e,turnCount:t,liveness:n}){let[r]=(0,$.useState)(()=>Date.now()),[i,a]=(0,$.useState)(()=>Date.now());(0,$.useEffect)(()=>{let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[]);let[o,s]=(0,$.useState)(()=>Date.now()),[c,l]=(0,$.useState)(()=>Math.floor(Math.random()*Nu.length)),u=()=>l(e=>(e+1+Math.floor(Math.random()*(Nu.length-1)))%Nu.length);(0,$.useEffect)(()=>{s(Date.now()),u()},[t]);let d=(0,$.useRef)(0),f=n?n.tick:null;(0,$.useEffect)(()=>{if(f===null)return;let e=Date.now();e-d.current<Lu||(d.current=e,u())},[f]);let p=n!=null&&!e,m=e?e.lastEmitAt:p?n.at??r:o,h=p?Fu:Pu,g=i-m>h,_=p?i-m<Iu:null,v=e?`${e.count>=2?`${e.count} agents · `:``}${e.agentType} · ${e.description}`:`${Nu[c]}…`;return(0,Q.jsxs)(`div`,{className:`chat-activity`,"data-stalled":g?`true`:`false`,"data-fresh":_===null?void 0:_?`true`:`false`,"aria-live":`polite`,"aria-label":g?`Agent may be stalled`:`Agent is working`,children:[(0,Q.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`chat-activity-icon`}),(0,Q.jsx)(`span`,{className:`chat-activity-word`,children:v}),(0,Q.jsx)(`span`,{className:`chat-activity-elapsed`,children:Ru(i-r)}),g&&(0,Q.jsx)(`span`,{className:`chat-activity-stalled`,children:`stalled`})]})}function Bu({variant:e,icon:t,label:n,children:r,defaultExpanded:i=!1}){let[a,o]=(0,$.useState)(i);return(0,Q.jsxs)(`div`,{className:`chat-${e}`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`chat-${e}-toggle`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[(0,Q.jsx)(`span`,{className:`wa-chevron`,children:t}),(0,Q.jsx)(`span`,{className:`chat-${e}-label`,children:n})]}),a&&r]})}function Vu({turns:e}){let t=e.filter(e=>e.kind===`tool-call`).length,n=t>0?`Used ${t} tool${t===1?``:`s`}`:`${e.length} tool result${e.length===1?``:`s`}`;return(0,Q.jsx)(Bu,{variant:`toolrun`,icon:(0,Q.jsx)(Ne,{size:12}),label:n,children:e.map((e,t)=>(0,Q.jsxs)(`div`,{className:`chat-toolrun-item`,children:[(0,Q.jsx)(`span`,{className:`chat-toolrun-name`,children:e.kind===`tool-call`?`↳ ${e.name}`:e.isError?`result (error)`:`result`}),(0,Q.jsx)(`pre`,{className:`wa-code`,children:e.kind===`tool-call`?JSON.stringify(e.input,null,2):e.text})]},t))})}function Hu({turns:e}){return(0,Q.jsx)(Bu,{variant:`thinking`,icon:(0,Q.jsx)(Ve,{size:12}),label:`Thoughts`,children:e.map((e,t)=>(0,Q.jsx)(`div`,{className:`chat-thinking-item`,children:(0,Q.jsx)(Mu,{content:e.text})},t))})}function Uu({ts:e}){let t=se(e);return t?(0,Q.jsx)(`time`,{className:`chat-time`,children:t}):null}function Wu({text:e}){let{status:t,copy:n}=Fe(),r=t===`ok`;return(0,Q.jsx)(`button`,{type:`button`,className:`chat-copy`,"aria-label":r?`Copied`:`Copy message`,title:r?`Copied`:`Copy`,onClick:()=>n(e),children:r?(0,Q.jsx)(a,{size:13,"aria-hidden":!0}):(0,Q.jsx)(ke,{size:13,"aria-hidden":!0})})}function Gu({ts:e,copyText:t}){return(0,Q.jsxs)(`div`,{className:`chat-msg-foot`,children:[(0,Q.jsx)(Uu,{ts:e}),(0,Q.jsx)(Wu,{text:t})]})}function Ku(e,t,n,r,i,a=!1){switch(e.kind){case`operator-inbound`:case`operator-typed`:{let o=e.kind===`operator-inbound`?e.rawBody:void 0,s=a?o??e.text:e.text,c=e.kind===`operator-inbound`?e.attachments:void 0,l=e.channel,u=e.kind===`operator-inbound`&&(e.source===`whatsapp`||e.source===`telegram`)?e.source:void 0,d=l??u;return(0,Q.jsxs)(`div`,{className:d?`chat-turn-op chat-turn-op--${d}`:`chat-turn-op`,children:[s&&(0,Q.jsx)(`p`,{className:`chat-op-body`,children:s}),c&&c.length>0&&(0,Q.jsx)(`div`,{className:`chat-attachment-list`,children:c.map((e,t)=>(0,Q.jsx)(E,{expandable:!0,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,href:e.source===`claude-upload`?ce(r,e.filename,i):D(e.attachmentId,n,r,i)},t))}),s?(0,Q.jsx)(Gu,{ts:e.ts,copyText:s}):(0,Q.jsx)(Uu,{ts:e.ts})]},t)}case`agent-reply`:return(0,Q.jsxs)(`div`,{className:`chat-prose`,children:[(0,Q.jsx)(Mu,{content:e.text}),e.text?(0,Q.jsx)(Gu,{ts:e.ts,copyText:e.text}):(0,Q.jsx)(Uu,{ts:e.ts})]},t);case`agent-webchat-final`:return(0,Q.jsx)(`div`,{className:`chat-prose`,children:(0,Q.jsxs)(Bu,{variant:`narration`,icon:(0,Q.jsx)(ye,{size:12}),label:`Assistant note`,defaultExpanded:!0,children:[(0,Q.jsx)(Mu,{content:e.text}),e.text?(0,Q.jsx)(Gu,{ts:e.ts,copyText:e.text}):(0,Q.jsx)(Uu,{ts:e.ts})]})},t);case`agent-reply-document`:return(0,Q.jsxs)(`div`,{className:`chat-prose`,children:[e.files.map((e,t)=>(0,Q.jsx)(E,{filename:w(e)},t)),e.caption&&(0,Q.jsx)(Mu,{content:e.caption}),(0,Q.jsx)(Uu,{ts:e.ts})]},t);case`agent-file`:return(0,Q.jsxs)(`div`,{className:`chat-prose`,children:[e.files.map((t,n)=>{let a=w(t),o=e.downloads?.[n];if(!o)return(0,Q.jsxs)(`p`,{className:`chat-doc`,children:[(0,Q.jsx)(ue,{size:14,"aria-hidden":!0,style:{verticalAlign:`text-bottom`}}),` `,a]},n);let s=x(o,r,i);return O.test(a)?(0,Q.jsx)(re,{src:x(o,r,i,`inline`),filename:a},n):te.test(a)?(0,Q.jsx)(`img`,{className:`chat-doc-image`,src:s,alt:a},n):(0,Q.jsxs)(`a`,{className:`chat-doc chat-doc-attachment`,href:s,download:a,children:[(0,Q.jsx)(ue,{size:14,"aria-hidden":!0}),a]},n)}),e.caption&&(0,Q.jsx)(Mu,{content:e.caption}),(0,Q.jsx)(Uu,{ts:e.ts})]},t);case`session-continued`:return(0,Q.jsx)(A,{},t);case`harness-internal`:return(0,Q.jsx)(Bu,{variant:`thinking`,icon:(0,Q.jsx)(Ne,{size:12}),label:`Internal`,children:(0,Q.jsx)(`div`,{className:`chat-thinking-item`,children:(0,Q.jsx)(Mu,{content:e.text})})},t);case`whatsapp-persisted`:return(0,Q.jsxs)(`div`,{className:`chat-prose`,children:[(0,Q.jsx)(Mu,{content:e.text}),e.reactions&&e.reactions.length>0&&(0,Q.jsx)(`div`,{className:`wa-reactions`,children:e.reactions.map((e,t)=>(0,Q.jsx)(`span`,{className:`wa-reaction`,title:e.reactorName??void 0,children:e.emoji},t))}),(0,Q.jsx)(Uu,{ts:e.ts})]},t);case`agent-error`:return(0,Q.jsxs)(`div`,{className:`chat-agent-error`,role:`alert`,children:[(0,Q.jsx)(`span`,{className:`chat-agent-error-msg`,children:de(e.code,n)}),n===`admin`&&e.code===`agent_error`&&e.raw&&(0,Q.jsx)(`pre`,{className:`chat-agent-error-raw`,children:e.raw})]},t)}}function qu({text:e,filenames:t}){return(0,Q.jsxs)(`div`,{className:`chat-turn-op chat-turn-op--pending`,"aria-busy":`true`,children:[e&&(0,Q.jsx)(`p`,{className:`chat-op-body`,children:e}),t.length>0&&(0,Q.jsx)(`div`,{className:`chat-attachment-list`,children:t.map((e,t)=>(0,Q.jsx)(`span`,{className:`chat-pending-attachment`,children:e},t))})]})}function Ju(e,t,n,r=`admin`,i=!1){let a=[],o=[],s=[],c=null,l=()=>{o.length!==0&&(a.push((0,Q.jsx)(Vu,{turns:o},`tools-${a.length}`)),o=[])},u=()=>{s.length!==0&&(a.push((0,Q.jsx)(Hu,{turns:s},`think-${a.length}`)),s=[])};return e.forEach((e,d)=>{let f=T(e),p=ee(f);if(p!==null&&p!==c&&(l(),u(),a.push((0,Q.jsx)(k,{ts:f},`day-${d}`)),c=p),e.kind===`turn`&&(e.turn.kind===`tool-call`||e.turn.kind===`tool-result`)){u(),o.push(e.turn);return}if(e.kind===`turn`&&e.turn.kind===`agent-text`){l(),s.push(e.turn);return}if(i&&e.kind===`turn`&&e.turn.kind===`operator-inbound`&&e.turn.scheduled){l(),u();return}l(),u(),e.kind===`directive`?a.push((0,Q.jsx)(S,{entry:e.entry,sessionId:t,sessionKey:n},d)):a.push(Ku(e.turn,d,r,t,n,i))}),l(),u(),a}new Set(`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text,text/rtf,application/rtf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-powerpoint,application/vnd.oasis.opendocument.presentation,audio/ogg,audio/opus,audio/mp4,audio/mpeg,audio/webm,audio/wav,.docx,.odt,.rtf,.xlsx,.xls,.ods,.pptx,.ppt,.odp,.opus,.ogg,.m4a,.mp3,.wav,.webm`.split(`,`).filter(e=>!e.startsWith(`.`)));var Yu=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function Xu(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Zu(){let e=window.location.pathname.match(/^\/([a-z][a-z0-9-]{2,49})$/);return e?e[1]:void 0}var Qu=`maxy_seed_q`;function $u(){let e=new URLSearchParams(window.location.search).get(`q`);if(e==null)return null;let t=e.trim();return t?t.slice(0,2e3):null}function ed(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function td({data:e,active:t}){let n=[];if(e&&e.length>0&&t){let t=Math.floor(e.length/24);for(let r=0;r<24;r++){let i=e[r*t]??128,a=Math.abs(i-128)/128;n.push(Math.max(.15,a))}}else for(let e=0;e<24;e++)n.push(.15);return(0,Q.jsx)(`div`,{className:`voice-waveform`,"aria-hidden":`true`,children:n.map((e,t)=>(0,Q.jsx)(`div`,{className:`voice-waveform-bar`,style:{height:`${Math.round(e*100)}%`}},t))})}function nd({state:e,elapsedSeconds:t,waveform:n,onTogglePause:r,onDiscard:i,onSend:a}){if(e===`idle`||e===`error`)return null;let o=e===`recording`,s=e===`paused`,c=e===`sending`;return(0,Q.jsxs)(`div`,{className:`voice-recorder`,role:`region`,"aria-label":`Voice recording`,"aria-live":`polite`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`voice-trash`,onClick:i,disabled:c,"aria-label":`Discard recording`,children:(0,Q.jsx)(u,{size:16})}),(0,Q.jsx)(`span`,{className:`voice-timer`,"aria-live":`polite`,"aria-atomic":`true`,children:ed(t)}),(0,Q.jsx)(td,{data:n,active:o}),(0,Q.jsx)(`button`,{type:`button`,className:`voice-pause`,onClick:r,disabled:c,"aria-label":s?`Resume recording`:`Pause recording`,children:s?(0,Q.jsx)(je,{size:14}):(0,Q.jsx)(C,{size:14})}),(0,Q.jsx)(Ee,{variant:`send`,type:`button`,onClick:a,disabled:c,loading:c,"aria-label":`Send voice note`,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,Q.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})}var rd=r(`wrench-off`,[[`path`,{d:`M10.747 5.093a6 6 0 0 1 6.841-2.882c.438.12.54.662.219.984L14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-2.882 6.842`,key:`a1`}],[`path`,{d:`m13.5 13.5-7.88 7.88a1 1 0 0 1-2.999-3l7.88-7.88`,key:`a2`}],[`path`,{d:`m2 2 20 20`,key:`a3`}]]),id={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},ad=[{id:Se,label:we(Se)},{id:me,label:we(me)},{id:be,label:we(be)}],od=[{id:`low`,label:`Low`},{id:`medium`,label:`Medium`},{id:`high`,label:`High`},{id:`xhigh`,label:`Extra`},{id:`max`,label:`Max`}],sd=[{id:`default`,label:`Ask permissions`},{id:`acceptEdits`,label:`Accept edits`},{id:`bypassPermissions`,label:`Bypass permissions`}];function cd({newModel:e,onPickModel:t,newEffort:n,onPickEffort:r,onNewSession:i,newSessionPending:o,newPermMode:s,onPickPermMode:c}){let l=Math.max(0,od.findIndex(e=>e.id===n)),u=od[l]?.label??``,d=od.length-1,f=e=>`calc(14px + (100% - 28px) * ${d>0?e/d:0})`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`webchat-newsession-field`,children:[(0,Q.jsx)(`span`,{children:`Model`}),(0,Q.jsx)(`div`,{className:`webchat-newsession-models`,children:ad.map(n=>(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-newsession-model`,role:`menuitemradio`,"aria-checked":e===n.id,onClick:()=>t(n.id),children:[(0,Q.jsx)(`span`,{children:n.label}),e===n.id&&(0,Q.jsx)(a,{size:13})]},n.id))})]}),(0,Q.jsxs)(`div`,{className:`webchat-newsession-field`,children:[(0,Q.jsxs)(`div`,{className:`webchat-newsession-effort-head`,children:[(0,Q.jsxs)(`span`,{children:[`Effort `,(0,Q.jsx)(`strong`,{children:u})]}),(0,Q.jsx)(`span`,{className:`webchat-newsession-effort-help`,title:`Higher effort lets the model think longer before it answers.`,children:(0,Q.jsx)(Le,{size:14})})]}),(0,Q.jsxs)(`div`,{className:`webchat-newsession-slider-ends`,"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{children:`Faster`}),(0,Q.jsx)(`span`,{children:`Smarter`})]}),(0,Q.jsxs)(`div`,{className:`webchat-newsession-track`,children:[(0,Q.jsx)(`span`,{className:`webchat-newsession-track-fill`,style:{width:f(l)},"aria-hidden":`true`}),od.map((e,t)=>(0,Q.jsx)(`span`,{className:`webchat-newsession-dot${t===d?` is-max`:``}`,style:{left:f(t)},"aria-hidden":`true`},e.id)),(0,Q.jsx)(`span`,{className:`webchat-newsession-knob`,style:{left:f(l)},"aria-hidden":`true`}),(0,Q.jsx)(`input`,{type:`range`,className:`webchat-newsession-slider`,min:0,max:d,step:1,value:l,onChange:e=>r(od[Number(e.target.value)].id),"aria-label":`New session thinking effort`})]})]}),s!=null&&c&&(0,Q.jsxs)(`div`,{className:`webchat-newsession-field`,children:[(0,Q.jsx)(`span`,{children:`Permissions`}),(0,Q.jsx)(`div`,{className:`webchat-newsession-models`,children:sd.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-newsession-model`,role:`menuitemradio`,"aria-checked":s===e.id,onClick:()=>c(e.id),children:[(0,Q.jsx)(`span`,{children:e.label}),s===e.id&&(0,Q.jsx)(a,{size:13})]},e.id))})]}),(0,Q.jsx)(`button`,{type:`button`,className:`webchat-newsession-go`,onClick:()=>void i(),disabled:o,children:o?`Starting…`:`Start new session`})]})}var ld={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`};function ud(e){return we(ve(e))}function dd(e){return e>=1e6?`~${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`~${Math.round(e/1e3)}k`:`~${e}`}function fd({pct:e,usedTokens:t,window:n}){let r=Math.max(0,Math.min(100,e)),i=`Context window used — ${e}% · ${dd(t)}/${dd(n)}`;return(0,Q.jsx)(`span`,{className:`webchat-context-ring`,role:`img`,"aria-label":i,title:i,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 14 14`,width:`14`,height:`14`,"aria-hidden":`true`,children:[(0,Q.jsx)(`circle`,{className:`ring-track`,cx:`7`,cy:`7`,r:`5`}),(0,Q.jsx)(`circle`,{className:`ring-fill`,cx:`7`,cy:`7`,r:`5`,pathLength:100,strokeDasharray:`${r} 100`,transform:`rotate(-90 7 7)`})]})})}function pd(e){let{deliveryFailure:t,permPrompt:n,onVerdict:r,isDragOver:i,onDragOver:o,onDragLeave:s,onDrop:l,fileInputRef:u,acceptMime:d,onFileInputChange:f,showResizeHandle:p,onResizePointerDown:m,onResizeKeyDown:v,pendingFiles:b,thumbUrls:x,onRemoveFile:S,attachError:C,sendError:w,transcribing:T=!1,voice:E,isVoiceActive:D,onVoiceSend:O,text:k,onTextareaChange:ee,textareaRef:te,textareaHeight:ne,textareaDisabled:A,placeholder:re=`Message your agent…`,onKeyDown:ie,onPaste:ae,onSend:oe,sendDisabled:se,turnActive:ce=!1,onStop:le,stopping:de=!1,deadChildNotice:fe,conflictHint:j,showNewSession:me,newSessionRef:ge,newSessionOpen:_e,onToggleNewSession:ve,newSessionDisabled:ye,newModel:be,onPickModel:xe,newEffort:Se,onPickEffort:Ce,onNewSession:we,newSessionPending:Ee,newPermMode:De,onPickPermMode:M,onAttachClick:je,attachDisabled:Pe,micMenuRef:Fe,onMicStart:Ie,micStartDisabled:Le,onOpenMicMenu:Be,micMenuOpen:Ve,micDevices:Ue,micDeviceId:We,onChooseMic:Ge,showCleanToggle:Ke,cleanView:qe,onToggleClean:Je,showControlsRight:Ye,sessionId:N,mode:Xe,model:Ze,effort:Qe,contextUsage:$e,paramsMenuRef:et,paramsMenuOpen:tt,onToggleParamsMenu:nt}=e,P=e=>e.preventDefault(),[F,rt]=(0,$.useState)(!1),it=(0,$.useRef)(null),I=(0,$.useRef)(null),L=()=>{N&&(it.current=setTimeout(()=>{let e=navigator.clipboard?.writeText(N);e&&e.then(()=>{rt(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>rt(!1),1200)}).catch(()=>{})},500))},at=()=>{it.current&&=(clearTimeout(it.current),null)};return(0,$.useEffect)(()=>()=>{it.current&&clearTimeout(it.current),I.current&&clearTimeout(I.current)},[]),(0,Q.jsxs)(`div`,{className:`webchat-composer`,children:[t&&(0,Q.jsx)(`div`,{className:`webchat-delivery-failed`,role:`alert`,children:`Message not delivered — the session was unresponsive. Resend to retry.`}),n&&(0,Q.jsxs)(`div`,{className:`webchat-perm-card`,role:`alertdialog`,"aria-label":`Permission request`,children:[(0,Q.jsxs)(`div`,{className:`webchat-perm-head`,children:[`Claude wants to run `,(0,Q.jsx)(`strong`,{children:n.toolName})]}),n.description&&(0,Q.jsx)(`div`,{className:`webchat-perm-desc`,children:n.description}),n.inputPreview&&(0,Q.jsx)(`pre`,{className:`webchat-perm-preview`,children:n.inputPreview}),(0,Q.jsxs)(`div`,{className:`webchat-perm-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`webchat-perm-deny`,onPointerDown:P,onClick:()=>void r(`deny`),children:`Deny`}),(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-perm-allow`,onPointerDown:P,onClick:()=>void r(`allow`),children:[`Allow`,(0,Q.jsx)(Re,{size:14})]})]})]}),(0,Q.jsxs)(`div`,{className:`webchat-composer-box${i?` drag-over`:``}`,onDragOver:o,onDragLeave:s,onDrop:l,children:[(0,Q.jsx)(`input`,{ref:u,type:`file`,multiple:!0,accept:d,style:{display:`none`},onChange:f}),p&&(0,Q.jsx)(`div`,{className:`webchat-resize-handle`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize input — drag up to enlarge`,tabIndex:0,onPointerDown:m,onKeyDown:v}),b.length>0&&(0,Q.jsx)(`div`,{className:`attachment-strip`,children:b.map((e,t)=>(0,Q.jsxs)(`div`,{className:`attachment-chip`,children:[x[t]?(0,Q.jsx)(`img`,{src:x[t]??void 0,alt:e.name,className:`attachment-chip-thumb`}):e.type.startsWith(`audio/`)?(0,Q.jsx)(y,{size:14}):e.type===`application/pdf`?(0,Q.jsx)(Ae,{size:14}):(0,Q.jsx)(_,{size:14}),(0,Q.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,Q.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>S(t),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),C&&(0,Q.jsx)(`p`,{className:`attach-error`,children:C}),w&&(0,Q.jsx)(`p`,{className:`webchat-send-error`,role:`alert`,children:w}),fe&&(0,Q.jsxs)(`p`,{className:`webchat-dead-child-notice`,role:`status`,children:[(0,Q.jsx)(Me,{size:14,"aria-hidden":!0}),` `,fe]}),T&&(0,Q.jsxs)(`p`,{className:`webchat-transcribing`,role:`status`,"aria-live":`polite`,children:[(0,Q.jsx)(c,{size:14,className:`webchat-transcribing-spin`}),`Transcribing audio…`]}),E.state===`error`&&E.errorMessage&&(0,Q.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,Q.jsx)(y,{size:14}),E.errorMessage]}),D?(0,Q.jsx)(`div`,{className:`webchat-input-row voice-active`,children:(0,Q.jsx)(nd,{state:E.state,elapsedSeconds:E.elapsedSeconds,waveform:E.waveform,onTogglePause:E.togglePause,onDiscard:E.discard,onSend:()=>void O()})}):(0,Q.jsxs)(`div`,{className:`webchat-input-row`,children:[(0,Q.jsx)(`textarea`,{ref:te,className:`webchat-input`,value:k,placeholder:re,rows:2,style:{height:`${ne}px`},disabled:A,onChange:ee,onKeyDown:ie,onPaste:ae}),ce?(0,Q.jsx)(`button`,{type:`button`,className:`webchat-send webchat-stop${de?` is-stopping`:``}`,onPointerDown:P,onClick:()=>void le?.(),disabled:de,"aria-label":de?`Stopping`:`Stop`,title:de?`Stopping…`:`Stop generating`,children:de?(0,Q.jsx)(c,{size:16,className:`webchat-stop-spin`}):(0,Q.jsx)(h,{size:16})}):k.trim().length===0&&b.length===0?(0,Q.jsx)(`button`,{type:`button`,className:`webchat-send webchat-mic-inline`,onPointerDown:P,onClick:()=>void Ie(),disabled:Le,"aria-label":`Voice input`,title:`Record voice note`,children:(0,Q.jsx)(y,{size:16})}):(0,Q.jsx)(`button`,{type:`button`,className:`webchat-send`,onPointerDown:P,onClick:()=>void oe(),disabled:se,"aria-label":`Send`,title:`Send`,children:(0,Q.jsx)(Re,{size:16})})]}),j!==null&&(0,Q.jsxs)(`p`,{className:`webchat-conflict-hint`,children:[`This session is bound to the `,j,` channel — message it there. The transcript stays readable here.`]})]}),(0,Q.jsxs)(`div`,{className:`webchat-controls`,children:[(0,Q.jsxs)(`div`,{className:`webchat-controls-left`,children:[me&&(0,Q.jsxs)(`div`,{className:`webchat-newsession`,ref:ge,children:[(0,Q.jsx)(`button`,{type:`button`,className:`webchat-control`,onPointerDown:P,onClick:ve,disabled:ye,"aria-haspopup":`menu`,"aria-expanded":_e,title:`New session`,"aria-label":`New session`,children:(0,Q.jsx)(g,{size:14})}),_e&&(0,Q.jsx)(`div`,{className:`webchat-newsession-panel`,role:`menu`,children:(0,Q.jsx)(cd,{newModel:be,onPickModel:xe,newEffort:Se,onPickEffort:Ce,onNewSession:we,newSessionPending:Ee,newPermMode:De,onPickPermMode:M})})]}),(0,Q.jsx)(`button`,{type:`button`,className:`webchat-control`,onPointerDown:P,onClick:je,disabled:Pe,title:`Attach files`,"aria-label":`Attach`,children:(0,Q.jsx)(ue,{size:14})}),(0,Q.jsxs)(`div`,{className:`webchat-mic-split`,ref:Fe,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-control webchat-mic-chevron`,onPointerDown:P,onClick:Be,disabled:Le,"aria-haspopup":`menu`,"aria-expanded":Ve,title:`Choose microphone`,"aria-label":`Choose microphone`,children:[(0,Q.jsx)(y,{size:14}),(0,Q.jsx)(Te,{size:12})]}),Ve&&(0,Q.jsxs)(`div`,{className:`webchat-mic-panel`,role:`menu`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-mic-item`,role:`menuitemradio`,"aria-checked":We===null,onClick:()=>Ge(null,`System default`),children:[(0,Q.jsx)(`span`,{children:`System default`}),We===null&&(0,Q.jsx)(a,{size:13})]}),Ue.filter(e=>e.label).map((e,t)=>(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-mic-item`,role:`menuitemradio`,"aria-checked":e.deviceId===We,onClick:()=>Ge(e.deviceId,e.label||`Microphone ${t+1}`),children:[(0,Q.jsx)(`span`,{children:e.label}),e.deviceId===We&&(0,Q.jsx)(a,{size:13})]},e.deviceId)),Ue.filter(e=>e.label).length===0&&(0,Q.jsx)(`span`,{className:`webchat-mic-hint`,children:`Allow microphone access to choose a device`})]})]}),Ke&&(0,Q.jsx)(`button`,{type:`button`,className:`webchat-control webchat-clean-toggle`,onPointerDown:P,onClick:Je,"aria-pressed":!qe,"aria-label":`Show tool calls and thinking`,title:qe?`Showing delivered messages only — click to show tool calls, results, and thinking`:`Showing tool calls, results, and thinking — click to show delivered messages only`,children:qe?(0,Q.jsx)(rd,{size:14}):(0,Q.jsx)(Ne,{size:14})})]}),Ye&&(0,Q.jsxs)(`div`,{className:`webchat-controls-right`,children:[N&&(0,Q.jsx)(`code`,{className:`webchat-session-id`,title:`First 8 characters of this session's id — matches the Sessions list.`,children:N.slice(0,8)}),(Xe||Ze||Qe)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`webchat-params webchat-params--inline`,"aria-label":`Session parameters`,children:[Xe&&(0,Q.jsx)(`span`,{className:`webchat-param`,children:ld[Xe]??Xe}),Ze&&(0,Q.jsx)(`span`,{className:`webchat-param`,children:ud(Ze)}),Qe&&(0,Q.jsx)(`span`,{className:`webchat-param`,children:id[Qe]??Qe})]}),(0,Q.jsxs)(`div`,{className:`webchat-params-menu`,ref:et,children:[(0,Q.jsx)(`button`,{type:`button`,className:`webchat-control webchat-params-trigger`,onPointerDown:P,"aria-haspopup":`menu`,"aria-expanded":tt,"aria-label":`Session parameters`,title:`Session parameters`,onClick:nt,children:(0,Q.jsx)(pe,{size:14})}),tt&&(0,Q.jsxs)(`div`,{className:`webchat-params-panel`,role:`menu`,children:[Xe&&(0,Q.jsxs)(`span`,{className:`webchat-param`,role:`menuitem`,children:[(0,Q.jsx)(He,{size:13,"aria-hidden":`true`}),ld[Xe]??Xe]}),Ze&&(0,Q.jsxs)(`span`,{className:`webchat-param`,role:`menuitem`,children:[(0,Q.jsx)(Oe,{size:13,"aria-hidden":`true`}),ud(Ze)]}),Qe&&(0,Q.jsxs)(`span`,{className:`webchat-param`,role:`menuitem`,children:[(0,Q.jsx)(ze,{size:13,"aria-hidden":`true`}),id[Qe]??Qe]}),N&&(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-param webchat-session-id-full${F?` is-copied`:``}`,role:`menuitem`,title:`Long-press to copy the full session id`,"aria-label":F?`Session id copied`:`Session id — long-press to copy`,onPointerDown:L,onPointerUp:at,onPointerLeave:at,onContextMenu:e=>e.preventDefault(),children:[F?(0,Q.jsx)(a,{size:13,"aria-hidden":`true`}):(0,Q.jsx)(ke,{size:13,"aria-hidden":`true`}),(0,Q.jsx)(`code`,{children:F?`Copied`:N})]}),$e&&(0,Q.jsxs)(`span`,{className:`webchat-param`,role:`menuitem`,children:[(0,Q.jsx)(he,{size:13,"aria-hidden":`true`}),$e.pct,`% · `,dd($e.usedTokens),`/`,dd($e.window)]})]})]})]}),$e&&(0,Q.jsx)(fd,{pct:$e.pct,usedTokens:$e.usedTokens,window:$e.window})]})]})]})}function md(e,t){return(t??{}).deadChild===!0?`dead-child`:e===200?`ok`:`failed`}function hd(e,t){if(e)return null;try{return new URLSearchParams(t).get(`session`)}catch{return null}}function gd(e){return typeof e!=`number`||!Number.isFinite(e)?``:new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function _d({s:e,onOpen:t,onRename:n,onArchive:r,onDelete:i,onEnd:o,onCopyId:c}){let[l,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(!1),[g,_]=(0,$.useState)(``),[v,y]=(0,$.useState)(!1),b=(0,$.useRef)(!1),x=()=>{f(!1),y(!1)},S=()=>{_(e.name||``),m(!0),f(!1)},C=()=>{if(m(!1),b.current){b.current=!1;return}g.trim()!==(e.name||``)&&n(e,g)};return p?(0,Q.jsx)(`div`,{className:`op-conv-rename`,children:(0,Q.jsx)(`input`,{className:`op-conv-rename-input`,autoFocus:!0,onFocus:e=>e.currentTarget.select(),value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`?C():e.key===`Escape`&&(b.current=!0,m(!1))},onBlur:C,placeholder:`Conversation name`,"aria-label":`Conversation name`})}):(0,Q.jsxs)(`div`,{className:`op-conv-rowwrap`,"aria-current":e.active?`true`:void 0,children:[(0,Q.jsxs)(`div`,{className:`op-conv-row-inner`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-resume`,onClick:()=>t(e),children:[(0,Q.jsxs)(`span`,{className:`op-conv-line1`,children:[e.active?(0,Q.jsx)(`span`,{className:`op-conv-current`,"aria-label":`Current session`,children:(0,Q.jsx)(a,{size:14})}):null,(0,Q.jsx)(`span`,{className:`op-conv-name`,children:e.name||`New conversation`})]}),(0,Q.jsxs)(`span`,{className:`op-conv-line2`,children:[(0,Q.jsx)(`span`,{className:`op-conv-when`,children:gd(e.lastActiveMs)}),(0,Q.jsx)(`code`,{className:`op-conv-id`,title:e.id,children:e.id})]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`op-conv-copy`,"aria-label":`Copy session id`,title:`Copy session id`,onClick:()=>c(e),children:(0,Q.jsx)(ke,{size:14})}),(0,Q.jsx)(`button`,{type:`button`,className:`op-conv-kebab`,"aria-label":l?`Close actions`:`Conversation actions`,"aria-expanded":l,onClick:()=>l?x():f(!0),children:l?(0,Q.jsx)(d,{size:16}):(0,Q.jsx)(pe,{size:16})})]}),l?(0,Q.jsxs)(`div`,{className:`op-conv-actions`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action`,onClick:S,children:[(0,Q.jsx)(s,{size:13}),` Rename`]}),e.active?(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action`,onClick:()=>{o(e),x()},children:[(0,Q.jsx)(h,{size:13}),` End session`]}):null,e.active?null:e.archived?(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action`,onClick:()=>{r(e,!1),x()},children:[(0,Q.jsx)(j,{size:13}),` Unarchive`]}):(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action`,onClick:()=>{r(e,!0),x()},children:[(0,Q.jsx)(De,{size:13}),` Archive`]}),e.active?null:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action danger`,onClick:()=>{i(e),x()},children:[(0,Q.jsx)(u,{size:13}),` Confirm`]}),(0,Q.jsx)(`button`,{type:`button`,className:`op-conv-action`,onClick:()=>y(!1),children:`Cancel`})]}):(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action danger`,onClick:()=>y(!0),children:[(0,Q.jsx)(u,{size:13}),` Delete`]})]}):null]})}function vd({sessions:e,onOpen:t,onRename:n,onArchive:r,onDelete:i,onEnd:a,onNew:o,onBack:s,onCopyId:c}){let[l,u]=(0,$.useState)(!1),f=e.filter(e=>!e.archived),p=e.filter(e=>e.archived),m={onOpen:t,onRename:n,onArchive:r,onDelete:i,onEnd:a,onCopyId:c};return(0,Q.jsxs)(`div`,{className:`op-conv`,style:{flex:1,minHeight:0,position:`relative`},children:[(0,Q.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,Q.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`}),(0,Q.jsx)(`button`,{type:`button`,className:`op-conv-close`,onClick:s,"aria-label":`Close conversations`,title:`Close`,children:(0,Q.jsx)(d,{size:16})})]}),(0,Q.jsx)(`div`,{className:`op-conv-list`,style:{flex:1,minHeight:0},children:e.length===0?(0,Q.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No conversations yet`}):(0,Q.jsxs)(Q.Fragment,{children:[f.map(e=>(0,Q.jsx)(_d,{s:e,...m},e.id)),p.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-archived-head`,"aria-expanded":l,onClick:()=>u(e=>!e),children:[(0,Q.jsx)(M,{size:14,style:{transform:l?`rotate(-90deg)`:`rotate(180deg)`,transition:`transform 0.12s`}}),`Archived (`,p.length,`)`]}),l?p.map(e=>(0,Q.jsx)(_d,{s:e,...m},e.id)):null]}):null]})}),(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-new op-conv-new-float`,onClick:o,children:[(0,Q.jsx)(g,{size:14}),` New session`]})]})}var yd=2500,bd=15e3,xd=[{id:`catch-up`,label:`Catch me up`,Icon:Be,prompt:`Catch me up — what came in across my inbox and WhatsApp while I was away, and what needs a reply?`},{id:`my-day`,label:`My day`,Icon:Ie,prompt:`What does my day look like — calendar, anything I need to prep for, and is there a free slot this afternoon?`},{id:`to-do`,label:`To-do`,Icon:ge,prompt:`What is still open and on me — pull together my outstanding tasks: unanswered messages, emails awaiting a reply, follow-ups I have asked you to track, and anything due soon.`}];function Sd({userName:e,variant:t,onChip:n}){let r=e?.trim().split(/\s+/)[0];return(0,Q.jsxs)(`div`,{className:`webchat-greeting`,children:[(0,Q.jsx)(`h2`,{className:`webchat-greeting-head`,children:r?`What's up next, ${r}?`:`What's up next?`}),t!==`public`&&(0,Q.jsx)(`div`,{className:`webchat-greeting-chips`,children:xd.map(({id:e,label:t,Icon:r,prompt:i})=>(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-greeting-chip`,onClick:()=>n({id:e,prompt:i}),children:[(0,Q.jsx)(r,{size:16}),` `,t]},e))})]})}function Cd({cacheKey:e,userName:t,targetSessionId:n,variant:r=`admin`,conversationsOpen:i=!1,onCloseConversations:a,cleared:s=!1,onFirstSend:l,switchId:u=null}){let d=r===`public`,p=d,[h,g]=(0,$.useState)(!0),[_,y]=(0,$.useState)(!1),[x,S]=(0,$.useState)(null),C=(0,$.useRef)(null),[w,T]=(0,$.useState)(null),[E,D]=(0,$.useState)(``),O=(0,$.useRef)(null),k=(0,$.useRef)(!1),ee=(0,$.useRef)(null),[te,A]=(0,$.useState)(0),[re,se]=(0,$.useState)(!1),[ce,ue]=(0,$.useState)(0),de=ce>0,[fe,pe]=(0,$.useState)(!1),[j,me]=(0,$.useState)(null),[he,ge]=(0,$.useState)(null),ve=(0,$.useRef)(!1),[ye,be]=(0,$.useState)(!1);(0,$.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(pointer: coarse)`);be(e.matches);let t=e=>be(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[Ce,we]=(0,$.useState)(0),Te=(0,$.useRef)(0),Ee=(0,$.useCallback)(e=>{Te.current=e,we(e)},[]),[De,Oe]=(0,$.useState)(null),[M,ke]=(0,$.useState)([]),[Ae,je]=(0,$.useState)(null),[Me,Ne]=(0,$.useState)(!1),Pe=(0,$.useRef)(null),Fe=()=>Math.round((typeof window>`u`?900:window.innerHeight)/3),[Ie,Le]=(0,$.useState)(null),Re=(0,$.useRef)(null),ze=(0,$.useRef)(null),Be=(0,$.useRef)(null),Ve=(0,$.useCallback)(e=>{let t=Be.current;t&&Le(Math.min(Fe(),Math.max(44,t.startH+(t.startY-e.clientY))))},[]),He=(0,$.useCallback)(()=>{Be.current=null,window.removeEventListener(`pointermove`,Ve),window.removeEventListener(`pointerup`,He)},[Ve]),Ge=(0,$.useCallback)(e=>{Be.current={startY:e.clientY,startH:Re.current?.offsetHeight??44},window.addEventListener(`pointermove`,Ve),window.addEventListener(`pointerup`,He),e.preventDefault()},[Ve,He]),Ke=(0,$.useCallback)(e=>{let t=Ie??Re.current?.offsetHeight??44;e.key===`ArrowUp`?(e.preventDefault(),Le(Math.min(Fe(),t+24))):e.key===`ArrowDown`&&(e.preventDefault(),Le(Math.max(44,t-24)))},[Ie]),[Je,Ye]=(0,$.useState)(null);(0,$.useEffect)(()=>{if(Ie!==null)return;let e=Re.current;if(!e)return;let t=e.style.height;e.style.height=`auto`;let n=Math.min(Fe(),Math.max(44,e.scrollHeight));e.style.height=t,Ye(n)},[E,Ie]),(0,$.useLayoutEffect)(()=>{if(ze.current===null)return;let e=Re.current;if(!e)return;let t=ze.current;ze.current=null,e.setSelectionRange(t,t)},[E]);let N=f(e),[Xe,Ze]=(0,$.useState)(!1),[Qe,$e]=(0,$.useState)(Se),[et,tt]=(0,$.useState)(`medium`),[nt,P]=(0,$.useState)(!1),F=(0,$.useRef)(null);(0,$.useEffect)(()=>{if(!Xe)return;let e=e=>{F.current?.contains(e.target)||Ze(!1)},t=e=>{e.key===`Escape`&&Ze(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[Xe]);let rt=(0,$.useCallback)(async()=>{if(!nt){P(!0);try{let e=await N(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:Qe,effort:et})}),t=await e.json().catch(()=>({})),n=xe(e.ok,e.status,t);console.info(`[admin-ui] composer-new-session status=${e.status} outcome=${n.kind} model=${Qe} effort=${et}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),Ze(!1)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),Ze(!1),y(!0)):console.error(`[admin-ui] composer-new-session-failed status=${e.status} reason=${n.reason}`)}catch(e){console.error(`[admin-ui] composer-new-session-failed error=${e instanceof Error?e.message:String(e)}`)}finally{P(!1)}}},[N,Qe,et,nt]),it=!d,[I,L]=(0,$.useState)([]),[at,R]=(0,$.useState)(!1),z=(0,$.useRef)(0),ot=(0,$.useRef)(!1);(0,$.useEffect)(()=>(ot.current=!1,()=>{ot.current=!0}),[]);let B=(0,$.useCallback)(async()=>{if(!it)return;let e=++z.current;try{let t=await N(`/api/admin/sidebar-sessions`);if(!t.ok){console.error(`[chat-conversations] op=enumerate-failed status=${t.status}`);return}let n=((await t.json()).sessions??[]).filter(e=>e.channel!==`whatsapp`&&e.channel!==`telegram`).map(e=>({id:e.sessionId,name:e.title,active:e.live,archived:!!e.archived,lastActiveMs:Number.isFinite(Date.parse(e.startedAt))?Date.parse(e.startedAt):null})).sort((e,t)=>(t.lastActiveMs??0)-(e.lastActiveMs??0));if(ot.current||e!==z.current)return;L(n),R(!0),console.info(`[chat-conversations] op=enumerate owned=${n.length}`)}catch(e){console.error(`[chat-conversations] op=enumerate-failed error=${e instanceof Error?e.message:String(e)}`)}},[N,it]);(0,$.useEffect)(()=>{B()},[B]),(0,$.useEffect)(()=>{i&&B()},[i,B]);let V=(0,$.useCallback)(async(e,t,n,r)=>{console.info(`[chat-conversations] op=action name=${e} sessionId=${t.id.slice(0,8)}`);try{let t=await N(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!t.ok){console.error(`[chat-conversations] op=action-failed name=${e} status=${t.status}`);return}B()}catch(t){console.error(`[chat-conversations] op=action-failed name=${e} error=${t instanceof Error?t.message:String(t)}`)}},[N,B]),st=(0,$.useCallback)(e=>{console.info(`[chat-conversations] op=action name=open sessionId=${e.id.slice(0,8)}`),window.location.assign(`/chat?session=${encodeURIComponent(e.id)}`)},[]),ct=(0,$.useCallback)((e,t)=>{V(`rename`,e,`/api/admin/session-rename`,{sessionId:e.id,title:t.trim()})},[V]),lt=(0,$.useCallback)((e,t)=>{V(`archive`,e,`/api/admin/session-archive`,{sessionId:e.id,mode:t?`archive`:`unarchive`})},[V]),ut=(0,$.useCallback)(e=>{V(`delete`,e,`/api/admin/session-delete`,{sessionId:e.id})},[V]),dt=(0,$.useCallback)(e=>{V(`stop`,e,`/api/admin/session-stop`,{sessionId:e.id})},[V]),ft=(0,$.useCallback)(e=>{m(e.id)},[]),pt=(0,$.useCallback)(e=>{je(null);let t=e.find(e=>!ie(e.type,v));if(t){je(`Unsupported file type: "${t.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, zip, voice notes.`);return}let n=e.find(e=>e.size>b);if(n){je(`"${n.name}" exceeds the 50 MB limit.`);return}ke(t=>[...t,...e].slice(0,5))},[]),mt=(0,$.useMemo)(()=>M.map(e=>e.type.startsWith(`image/`)?URL.createObjectURL(e):null),[M]);(0,$.useEffect)(()=>()=>{for(let e of mt)e&&URL.revokeObjectURL(e)},[mt]);let ht=ne(),gt=ht.state===`recording`||ht.state===`paused`||ht.state===`sending`,_t=(0,$.useCallback)(async()=>{let t=await ht.send();if(!t)return;let r=t.type===`audio/ogg`?`.ogg`:t.type===`audio/mp4`?`.m4a`:`.webm`,i=new File([t],`voice-note${r}`,{type:t.type});if(re){ke(e=>[...e,i].slice(0,5));return}se(!0);let a=new FormData;if(d){a.append(`message`,``),a.append(`session_key`,w??``);let e=Zu();e&&a.append(`agent`,e)}else a.append(`text`,``);a.append(`attachments`,i),!d&&n&&a.append(`session`,n);try{let t=d?await fetch(`/api/chat`,{method:`POST`,body:a}):await fetch(`/api/webchat/send?session_key=${encodeURIComponent(e)}`,{method:`POST`,body:a});t.ok||(console.error(`[admin-ui] webchat-send-failed kind=voice status=${t.status}`),ke(e=>[...e,i].slice(0,5)),je(`Voice note failed to send. The recording is attached — press send to retry.`))}catch(e){console.error(`[admin-ui] webchat-send-failed kind=voice error=${e instanceof Error?e.message:String(e)}`),ke(e=>[...e,i].slice(0,5)),je(`Voice note failed to send. The recording is attached — press send to retry.`)}finally{se(!1)}},[ht,e,n,re,d,w]),vt=(0,$.useRef)(!1);(0,$.useEffect)(()=>(vt.current=!1,()=>{vt.current=!0}),[]);let yt=(0,$.useRef)(!1),bt=(0,$.useCallback)(async()=>{if(yt.current)return null;yt.current=!0;try{if(d){let e=Zu(),t=await fetch(`/api/public-reader/session${e?`?agent=${encodeURIComponent(e)}`:``}`);if(!t.ok)return null;let n=await t.json();if(vt.current)return null;T(n.sessionKey);let r={sessionId:n.sessionId??``,projectDir:n.projectDir};return C.current=r,S(r),r}let t=`session_key=${encodeURIComponent(e)}${n?`&session=${encodeURIComponent(n)}`:``}`,r=await fetch(`/api/webchat/session?${t}`);if(!r.ok)return null;let i=await r.json();return vt.current?i:(C.current=i,S(i),i)}catch{return null}finally{yt.current=!1}},[e,n,d]);(0,$.useEffect)(()=>{bt();let e=setInterval(()=>{bt()},yd);return()=>clearInterval(e)},[bt]),(0,$.useEffect)(()=>{if(d)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||g(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[d]);let xt=(0,$.useCallback)(async()=>{let t=E.trim();if(!t&&M.length===0||re)return!1;if(!d&&!h)return console.info(`[admin-ui] op=llm-action-blocked action=send reason=claude-disconnected`),y(!0),!1;se(!0),ve.current=!1;try{if(d){let e=w;if(!e)return console.error(`[public-webchat] op=send-skip reason=no-key`),!1;let n,r=Zu();if(M.length>0){let i=new FormData;i.append(`message`,t),i.append(`session_key`,e),r&&i.append(`agent`,r);for(let e of M)i.append(`attachments`,e);n=await fetch(`/api/chat`,{method:`POST`,body:i})}else n=await fetch(`/api/chat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:t,session_key:e,...r?{agent:r}:{}})});return n.ok?(D(``),ke([]),je(null),!0):(console.error(`[public-webchat] op=send-failed status=${n.status}`),!1)}M.some(e=>qe(e.type))&&(pe(!0),console.info(`[admin-ui] op=transcribe-indicator state=show`));let r=s&&!n,i;if(M.length>0){let a=new FormData;a.append(`text`,t);for(let e of M)a.append(`attachments`,e);n&&a.append(`session`,n),r&&a.append(`clearSignal`,`true`),i=await fetch(`/api/webchat/send?session_key=${encodeURIComponent(e)}`,{method:`POST`,body:a})}else i=await fetch(`/api/webchat/send?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t,...n?{session:n}:{},...r?{clearSignal:!0}:{}})});if(i.ok)return je(null),ge(null),Kt(!1),Jt(null),l?.(),ve.current=!0,me({baselineSize:C.current?.sizeBytes??null,baselineTurns:Te.current,text:t,files:M}),D(``),ke([]),!0;i.status===409?console.error(`[admin-ui] webchat-send-refused reason=channel-conflict`):console.error(`[admin-ui] webchat-send-failed status=${i.status}`)}catch(e){console.error(`[admin-ui] webchat-send-failed error=${e instanceof Error?e.message:String(e)}`)}finally{ve.current||se(!1),M.some(e=>qe(e.type))&&console.info(`[admin-ui] op=transcribe-indicator state=clear`),pe(!1)}return!1},[E,re,e,M,n,d,h,w,l,s]);(0,$.useEffect)(()=>{if(!d||k.current||!w)return;let e=$u(),t=`url`;if(!e)try{let n=sessionStorage.getItem(Qu);n&&n.trim()&&(e=n.trim().slice(0,2e3),t=`storage`)}catch{}if(!e){new URLSearchParams(window.location.search).has(`q`)&&Yu&&console.info(`[public-webchat] op=seed-skip reason=empty`),k.current=!0;return}if(Yu&&console.info(`[public-webchat] op=seed-detected source=${t} len=${e.length} head=${e.slice(0,40)}`),t===`storage`&&Yu&&console.info(`[public-webchat] op=seed-restored source=storage len=${e.length}`),E!==``){Yu&&console.info(`[public-webchat] op=seed-skip reason=composer-dirty`),k.current=!0;return}O.current=e,D(e)},[d,w]),(0,$.useEffect)(()=>{let e=O.current;if(!(!e||E!==e||!w||k.current)){k.current=!0,O.current=null;try{let e=new URL(window.location.href);e.searchParams.delete(`q`),window.history.replaceState({},``,e.pathname+e.search+e.hash)}catch{}try{sessionStorage.removeItem(Qu)}catch{}Yu&&console.info(`[public-webchat] op=seed-sent key=${w} len=${e.length}`),xt().then(e=>{e||console.error(`[public-webchat] op=seed-send-failed`)})}},[E,w,xt]);let St=(0,$.useCallback)(e=>{console.info(`[admin-ui] op=chip-tap id=${e.id} chars=${e.prompt.length}`),ee.current=e.prompt,D(e.prompt),A(e=>e+1)},[]);(0,$.useEffect)(()=>{let e=ee.current;!e||E!==e||(ee.current=null,xt().then(e=>{e||console.error(`[admin-ui] op=chip-send-failed`)}))},[te,E,xt]);let Ct=(0,$.useCallback)(async()=>{Wt(!0),ue(e=>e+1);let t=x?.sessionId??n??void 0;try{let n=await fetch(`/api/webchat/interrupt?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t?{session:t}:{})}),r=await n.json().catch(()=>({}));md(n.status,r)===`dead-child`&&(Kt(!0),Wt(!1),Jt(`The agent stopped. Send a message to resume.`),console.log(`[admin-ui] op=stop-dead-child sessionId=${(t??``).slice(0,8)}`))}catch(e){console.error(`[admin-ui] webchat-stop-failed error=${e instanceof Error?e.message:String(e)}`)}finally{ue(e=>e-1)}},[e,x?.sessionId,n]),wt=(0,$.useCallback)(e=>{if(e.key===`Enter`&&!e.shiftKey&&!ye){e.preventDefault(),xt();return}if(e.key===`Enter`){let t=e.currentTarget,n=Ue(t.value,t.selectionStart,t.selectionEnd);n&&(e.preventDefault(),ze.current=n.caret,D(n.value));return}},[xt,ye]),Tt=(0,$.useMemo)(()=>{if(!j)return null;let e=x?.sizeBytes;return e!=null&&(j.baselineSize==null||e>j.baselineSize)?`pointer`:Ce>j.baselineTurns?`transcript`:null},[j,x?.sizeBytes,Ce]),Et=Tt!==null;(0,$.useEffect)(()=>{!j||!Tt||(console.info(`[admin-ui] op=send-confirmed via=${Tt} baselineSize=${j.baselineSize??`absent`} baselineTurns=${j.baselineTurns}`),ge(null),me(null),ve.current=!1,se(!1))},[j,Tt]),(0,$.useEffect)(()=>{if(!j)return;let e=setTimeout(()=>{D(j.text),ke(e=>[...j.files,...e].slice(0,5)),me(null),ve.current=!1,se(!1),ge(`Couldn't be delivered — press send to retry.`)},bd);return()=>clearTimeout(e)},[j]);let Dt=n?x?.channelBinding??null:null,Ot=(0,$.useRef)(!1);(0,$.useEffect)(()=>{!n||Ot.current||!x||(Ot.current=!0,console.warn(`[admin-ui] chat-session-target sessionId=${n} jsonl=${x.projectDir?`found`:`missing`} known=${x.known===!0}`))},[x,n]);let kt=(0,$.useRef)(!1);(0,$.useEffect)(()=>{n||kt.current||!x?.sessionId||(kt.current=!0,console.info(`[admin-ui] chat-session-resolve sessionId=${x.sessionId.slice(0,8)} source=canonical`))},[x,n]);let H=s?null:x,At=H?H.effectivePermissionMode??H.permissionMode??null:null,jt=H?.model??null,Mt=H?.activity===`busy`,Nt=(0,$.useRef)(!1);(0,$.useEffect)(()=>{if(!s||Nt.current||!x)return;Nt.current=!0;let e=x.sessionId?x.sessionId.slice(0,8):`none`;console.info(`[sub-account] op=post-switch-pointer switchId=${u?u.slice(0,8):`none`} source=${x.source??`unknown`} shown=${e}`)},[s,x,u]);let[Pt,Ft]=(0,$.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`maxy:whatsapp-reader:clean-view`)===`1`}catch{return!1}}),It=(0,$.useCallback)(()=>{Ft(e=>{let t=!e;try{window.localStorage.setItem(`maxy:whatsapp-reader:clean-view`,t?`1`:`0`)}catch{}return t})},[]),Lt=(0,$.useMemo)(()=>d?(e,t,n)=>Ju(e,t,n,`public`):(e,t,n)=>Ju(e,t,n,`admin`,r===`admin`?Pt:!0),[d,Pt,r]),Rt=(0,$.useMemo)(()=>!d&&j&&!Et?(0,Q.jsx)(qu,{text:j.text,filenames:j.files.map(e=>e.name)}):null,[d,j,Et]),zt=(0,$.useMemo)(()=>{if(d)return null;let e=Mt?(0,Q.jsx)(zu,{activity:De,turnCount:Ce}):null;return!Rt&&!e?null:(0,Q.jsxs)(Q.Fragment,{children:[Rt,e]})},[d,Mt,De,Ce,Rt]),U=(0,$.useMemo)(()=>{try{return new URLSearchParams(window.location.search).get(`diag`)===`composer`}catch{return!1}},[]),Bt=(0,$.useRef)(null),Vt=(0,$.useRef)(0),Ht=(0,$.useCallback)((e,t,n)=>{let r=Bt.current;r&&console.info(`[diag:composer] keystroke #${r.seq} reconciled transcript — phase=${t} actualDuration=${n.toFixed(2)}ms latency=${(performance.now()-r.t0).toFixed(2)}ms`)},[]),[Ut,Wt]=(0,$.useState)(!1);(0,$.useEffect)(()=>{Mt||Wt(!1)},[Mt]);let[Gt,Kt]=(0,$.useState)(!1),[qt,Jt]=(0,$.useState)(null);(0,$.useEffect)(()=>{H?.turnAborted?Gt||(Kt(!0),Jt(`The agent stopped. Send a message to resume.`),console.log(`[admin-ui] op=phantom-turn-cleared sessionId=${(H.sessionId??``).slice(0,8)}`)):Mt&&(Gt||qt!==null)&&(Kt(!1),Jt(null))},[H?.turnAborted,H?.sessionId,Mt,Gt,qt]);let[Yt,Xt]=(0,$.useState)(!1),Zt=(0,$.useRef)(null);(0,$.useEffect)(()=>{if(!Yt)return;let e=e=>{Zt.current?.contains(e.target)||Xt(!1)},t=e=>{e.key===`Escape`&&Xt(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[Yt]);let[Qt,$t]=(0,$.useState)(()=>{try{return window.localStorage.getItem(`maxy:webchat:mic-device-id`)}catch{return null}}),[en,tn]=(0,$.useState)([]),[nn,rn]=(0,$.useState)(!1),an=(0,$.useRef)(null);(0,$.useEffect)(()=>{if(!nn)return;let e=e=>{an.current?.contains(e.target)||rn(!1)},t=e=>{e.key===`Escape`&&rn(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[nn]);let on=(0,$.useCallback)(async()=>{rn(e=>!e),tn(await oe())},[]),sn=(0,$.useCallback)((e,t)=>{$t(e);try{e?window.localStorage.setItem(`maxy:webchat:mic-device-id`,e):window.localStorage.removeItem(`maxy:webchat:mic-device-id`)}catch{}console.info(`[admin-ui] mic-device-selected`,t),rn(!1)},[]),cn=(0,$.useCallback)(async t=>{let n=x?.pendingPermissionPrompt;if(!(!n||!x?.sessionId))try{await fetch(`/api/webchat/permission-verdict?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sessionId:x.sessionId,request_id:n.requestId,behavior:t})})}catch(e){console.error(`[admin-ui] permission-verdict-failed error=${e instanceof Error?e.message:String(e)}`)}},[e,x?.sessionId,x?.pendingPermissionPrompt]),ln=(0,$.useRef)(!1);return(0,$.useEffect)(()=>{ln.current||x?.projectDir&&x.activity==null&&At==null&&jt==null&&(ln.current=!0,console.warn(`[admin-ui] composer-indicators-unavailable sessionId=${x.sessionId} (manager meta unreadable or pre-activity)`))},[x,At,jt]),(0,$.useEffect)(()=>{console.info(`[admin-ui] chat-render variant=${r} isPublic=${d} deliveredOnly=${p} model=${jt??`null`} audience=${d?`public`:`admin`}`)},[r,d,p,jt]),(0,Q.jsxs)(`div`,{className:`webchat-page`,children:[de?(0,Q.jsx)(`div`,{className:`interrupt-overlay`,role:`status`,"aria-live":`polite`,children:(0,Q.jsxs)(`div`,{className:`interrupt-modal`,children:[(0,Q.jsx)(c,{className:`spin interrupt-spinner`,size:28,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`interrupt-label`,children:`Interruption in progress…`})]})}):null,x?.projectDir&&!s?(()=>{let t=(0,Q.jsx)(ae,{resetKey:x.sessionId,sessionId:x.transcriptSessionId??x.sessionId,projectDir:x.projectDir,sessionKey:d?w??``:e,renderItems:Lt,clean:r===`admin`?Pt:void 0,onToggleClean:r===`admin`?It:void 0,forceDeliveredOnly:p,streamEndpoint:d?`/api/public-reader/stream`:`/api/whatsapp-reader/stream`,suppressDirectives:d,tail:zt,onTurnsChange:d?void 0:Ee,onActivityChange:d?void 0:Oe},x.sessionId);return U?(0,Q.jsx)($.Profiler,{id:`chat-transcript`,onRender:Ht,children:t}):t})():it&&!n&&at&&I.length===0&&x?.known===!1?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`webchat-conv-splash`,"data-testid":`conversations-splash`,children:[(0,Q.jsx)(`img`,{src:o,alt:``,className:`webchat-conv-splash-logo`}),(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-conv-splash-new`,onClick:rt,disabled:nt,children:[nt?(0,Q.jsx)(c,{size:16,className:`spin`}):null,` New session`]})]}),Rt?(0,Q.jsx)(`div`,{className:`webchat-pending-standalone`,children:Rt}):null]}):x&&!d?!n||x.known?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Sd,{userName:t,variant:r,onChip:St}),Rt?(0,Q.jsx)(`div`,{className:`webchat-pending-standalone`,children:Rt}):null]}):(0,Q.jsx)(`div`,{className:`webchat-greeting`,children:(0,Q.jsx)(`p`,{className:`webchat-greeting-none`,children:`No transcript found for this session.`})}):null,i&&it?(0,Q.jsx)(`div`,{className:`webchat-conv-overlay`,children:(0,Q.jsx)(vd,{sessions:s?I.map(e=>({...e,active:!1})):I,onOpen:st,onRename:ct,onArchive:lt,onDelete:ut,onEnd:dt,onNew:rt,onBack:()=>a?.(),onCopyId:ft})}):null,(0,Q.jsx)(pd,{deliveryFailure:!!H?.deliveryFailure,permPrompt:H?.pendingPermissionPrompt??null,onVerdict:cn,isDragOver:Me,onDragOver:e=>{e.preventDefault(),Ne(!0)},onDragLeave:()=>Ne(!1),onDrop:e=>{e.preventDefault(),Ne(!1),pt([...e.dataTransfer.files])},fileInputRef:Pe,acceptMime:le,onFileInputChange:e=>{e.target.files&&pt([...e.target.files]),e.target.value=``},showResizeHandle:!gt,onResizePointerDown:Ge,onResizeKeyDown:Ke,pendingFiles:M,thumbUrls:mt,onRemoveFile:e=>ke(t=>t.filter((t,n)=>n!==e)),attachError:Ae,sendError:he,transcribing:fe,voice:ht,isVoiceActive:gt,onVoiceSend:_t,text:E,onTextareaChange:e=>{if(U){let e=++Vt.current;Bt.current={seq:e,t0:performance.now()},requestAnimationFrame(()=>{Bt.current?.seq===e&&(Bt.current=null)})}D(e.target.value)},textareaRef:Re,textareaHeight:Ie??Je??44,textareaDisabled:Dt!==null||re||j!==null,onKeyDown:wt,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=We(t,Date.now());n.length>0&&pt(n)},onSend:xt,sendDisabled:re||E.trim().length===0&&M.length===0||Dt!==null,turnActive:!d&&Mt&&!Gt,onStop:Ct,stopping:Ut,deadChildNotice:qt,conflictHint:Dt,showNewSession:!d,newSessionRef:F,newSessionOpen:Xe,onToggleNewSession:()=>Ze(e=>!e),newSessionDisabled:Dt!==null,newModel:Qe,onPickModel:$e,newEffort:et,onPickEffort:tt,onNewSession:rt,newSessionPending:nt,onAttachClick:()=>Pe.current?.click(),attachDisabled:Dt!==null,micMenuRef:an,onMicStart:()=>ht.start(Qt??void 0),micStartDisabled:gt||Dt!==null,onOpenMicMenu:on,micMenuOpen:nn,micDevices:en,micDeviceId:Qt,onChooseMic:sn,showCleanToggle:r===`admin`,cleanView:Pt,onToggleClean:It,showControlsRight:!d,sessionId:H?.sessionId??null,mode:At,model:jt,effort:H?.effort??null,contextUsage:H?.contextUsage??null,paramsMenuRef:Zt,paramsMenuOpen:Yt,onToggleParamsMenu:()=>Xt(e=>!e)}),(0,Q.jsx)(_e,{open:_,onConnect:()=>window.location.assign(`/?connect=claude`),onClose:()=>y(!1)})]})}var wd=`maxy-subaccount-switch-clear`;function Td(e){if(e)return!1;try{return sessionStorage.getItem(wd)!=null}catch{return!1}}function Ed(e){if(e)return null;try{return sessionStorage.getItem(wd)}catch{return null}}function Dd(e){if(e)return!1;let t=null;try{t=sessionStorage.getItem(wd),t&&sessionStorage.removeItem(wd)}catch{}return console.info(`[sub-account] op=post-switch-chat switchId=${t??`none`} signal=${t!=null} resume=${t==null}`),t!=null}function Od({variant:e=`admin`,forceCanonicalSession:t=!1}){let[n,r]=(0,$.useState)(null),[i]=(0,$.useState)(()=>hd(t,window.location.search)),[a,o]=(0,$.useState)(()=>Td(t)),[s]=(0,$.useState)(()=>Ed(t)),l=(0,$.useRef)(!1);(0,$.useEffect)(()=>{l.current||(l.current=!0,Dd(t))},[t]);let[u,d]=(0,$.useState)(!1),[f,m]=(0,$.useState)(!1),[h,g]=(0,$.useState)(void 0),[_,v]=(0,$.useState)(null),[y,b]=(0,$.useState)(void 0),[x,S]=(0,$.useState)(null),[C,w]=(0,$.useState)(null);(0,$.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){r(null),d(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(async n=>{if(!e){if(n.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(n.ok)try{let e=await n.json();typeof e.businessName==`string`&&g(e.businessName),e.sessionId!==void 0&&v(e.sessionId??null),w(e.role??null),b(e.userName===void 0?null:e.userName),S(e.avatar??null)}catch{}r(t),d(!0)}}).catch(()=>{e||(r(t),d(!0))}),()=>{e=!0}},[]);let T=(0,$.useRef)(!1);(0,$.useEffect)(()=>{e!==`operator`||!u||!n||T.current||(T.current=!0,console.info(`[operator-ui] op=mount surface=chat sessionId=${(_??``).slice(0,8)}`))},[e,u,n,_]);let E=(0,$.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[D,O]=(0,$.useState)(!1),k=(0,$.useCallback)(async()=>{O(!0);try{let e=await fe();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{O(!1)}},[]);return u?n?(0,Q.jsx)(p,{cacheKey:n,surface:`chat`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=chat`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,Q.jsx)(Ce,{cacheKey:n,businessName:h,variant:e,sessionId:_,onLogout:E,onDisconnect:k,disconnecting:D,userName:y,userAvatar:x,role:C,onOpenConversations:()=>m(!0),children:(0,Q.jsx)(Cd,{cacheKey:n,userName:y??null,targetSessionId:i,variant:e,conversationsOpen:f,onCloseConversations:()=>m(!1),cleared:a,onFirstSend:()=>o(!1),switchId:s})})}):(0,Q.jsx)(`div`,{className:`data-page`,children:(0,Q.jsxs)(`div`,{className:`data-empty`,children:[(0,Q.jsx)(`p`,{children:`You are not signed in.`}),(0,Q.jsxs)(`p`,{children:[`Open the `,(0,Q.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,Q.jsx)(`div`,{className:`data-page`,children:(0,Q.jsxs)(`div`,{className:`data-loading`,children:[(0,Q.jsx)(c,{size:18,className:`spin`}),` Loading…`]})})}function kd(){return(0,Q.jsx)(Od,{})}export{Zu as a,Yu as c,Qu as i,kd as n,$u as o,Cd as r,Xu as s,Od as t};
32
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return cc(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=al.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function hl(){return{exit:{taskListCheckValueChecked:_l,taskListCheckValueUnchecked:_l,paragraph:vl}}}function gl(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:yl}}}function _l(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function vl(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function yl(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=al.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function bl(){return[Es(),Xs(),tc(),ol(),hl()]}function xl(e){return{extensions:[Ds(),Zs(e),nc(),ml(e),gl()]}}var Sl={tokenize:Il,partial:!0},Cl={tokenize:Ll,partial:!0},wl={tokenize:Rl,partial:!0},Tl={tokenize:zl,partial:!0},El={tokenize:Bl,partial:!0},Dl={name:`wwwAutolink`,tokenize:Pl,previous:Vl},Ol={name:`protocolAutolink`,tokenize:Fl,previous:Hl},kl={name:`emailAutolink`,tokenize:Nl,previous:Ul},Al={};function jl(){return{text:Al}}for(var Ml=48;Ml<123;)Al[Ml]=kl,Ml++,Ml===58?Ml=65:Ml===91&&(Ml=97);Al[43]=kl,Al[45]=kl,Al[46]=kl,Al[95]=kl,Al[72]=[kl,Ol],Al[104]=[kl,Ol],Al[87]=[kl,Dl],Al[119]=[kl,Dl];function Nl(e,t,n){let r=this,i,a;return o;function o(t){return!Wl(t)||!Ul.call(r,r.previous)||Gl(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Wl(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(El,u,l)(t):t===45||t===95||K(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&G(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Pl(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Vl.call(r,r.previous)||Gl(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Sl,e.attempt(Cl,e.attempt(wl,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Fl(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Hl.call(r,r.previous)&&!Gl(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(G(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Mn(t)||J(t)||Ln(t)||In(t)?n(t):e.attempt(Cl,e.attempt(wl,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Il(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Ll(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Tl,c,s)(t):t===null||J(t)||Ln(t)||t!==45&&In(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Rl(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Tl,t,a)(o):o===null||J(o)||Ln(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zl(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||J(o)||Ln(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||J(e)||Ln(e)?t(e):r(e)}function a(e){return G(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):G(t)?(e.consume(t),o):n(t)}}function Bl(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return K(e)?n(e):t(e)}}function Vl(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||J(e)}function Hl(e){return!G(e)}function Ul(e){return!(e===47||Wl(e))}function Wl(e){return e===43||e===45||e===46||e===95||K(e)}function Gl(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Kl={tokenize:eu,partial:!0};function ql(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Zl,continuation:{tokenize:Ql},exit:$l}},text:{91:{name:`gfmFootnoteCall`,tokenize:Xl},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Jl,resolveTo:Yl}}}}function Jl(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=An(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Yl(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Xl(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||J(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(An(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return J(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Zl(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||J(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=An(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return J(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),X(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Ql(e,t,n){return e.check(er,t,e.attempt(Kl,t,n))}function $l(e){e.exit(`gfmFootnoteDefinition`)}function eu(e,t,n){let r=this;return X(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function tu(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&W(o,o.length,0,qn(s,e.slice(r+1,n),t)),W(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),W(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Kn(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Kn(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var nu=class{constructor(){this.map=[]}add(e,t,n){ru(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function ru(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function iu(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function au(){return{flow:{null:{name:`table`,tokenize:ou,resolveAll:su}}}}function ou(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||J(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||J(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function su(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new nu;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(lu(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=cu(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=cu(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=cu(f,t,o,i,n,d)):(o[0]=o[1],d=cu(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&lu(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=iu(t.events,n))}return e}function cu(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},uu(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=uu(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=uu(t.events,n[2]),a=uu(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},uu(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function lu(e,t,n,r,i){let a=[],o=uu(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function uu(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var du={name:`tasklistCheck`,tokenize:pu};function fu(){return{text:{91:du}}}function pu(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return J(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):Y(r)?e.check({tokenize:mu},t,n)(r):n(r)}}function mu(e,t,n){return X(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function hu(e){return En([jl(),ql(),tu(e),au(),fu()])}var gu={};function _u(e){let t=this,n=e||gu,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(hu(n)),a.push(bl()),o.push(xl(n))}var vu=null;function yu(){return vu||=Pe(async()=>{let{default:e}=await import(`./mermaid.core-Durk4m6D.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({default:e})=>(e.initialize({startOnLoad:!1,theme:`neutral`}),e)),vu}function bu({source:e}){let t=(0,$.useRef)(null),[n,r]=(0,$.useState)(null);return(0,$.useEffect)(()=>{let n=!1,i=`mermaid-${Math.random().toString(36).slice(2,9)}`;return yu().then(t=>t.render(i,e)).then(({svg:e})=>{!n&&t.current&&(t.current.innerHTML=e)}).catch(t=>{n||(console.error(`[MermaidBlock] render failed:`,e,t),r(t instanceof Error?t.message:`Diagram render failed`))}),()=>{n=!0}},[e]),n?(0,Q.jsxs)(`div`,{className:`md-mermaid md-mermaid-error`,children:[(0,Q.jsx)(`div`,{className:`md-mermaid-error-label`,children:`Diagram render error`}),(0,Q.jsx)(`pre`,{className:`md-pre`,children:(0,Q.jsx)(`code`,{className:`md-code`,children:e})})]}):(0,Q.jsx)(`div`,{className:`md-mermaid`,ref:t})}var xu=/\.(mp4|webm|mov)(\?.*)?$/i,Su=/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/,Cu=/vimeo\.com\/(\d+)/;function wu(e){return!!e&&xu.test(e)}function Tu(e){if(!e)return null;let t=e.match(Su);return t?t[1]:null}function Eu(e){if(!e)return null;let t=e.match(Cu);return t?t[1]:null}function Du({src:e}){return(0,Q.jsx)(`video`,{className:`md-video`,controls:!0,playsInline:!0,preload:`metadata`,children:(0,Q.jsx)(`source`,{src:e})})}function Ou({videoId:e}){return(0,Q.jsx)(`div`,{className:`md-video-iframe`,children:(0,Q.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${e}`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function ku({videoId:e}){return(0,Q.jsx)(`div`,{className:`md-video-iframe`,children:(0,Q.jsx)(`iframe`,{src:`https://player.vimeo.com/video/${e}`,allow:`autoplay; fullscreen; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function Au(e){if(wu(e))return(0,Q.jsx)(Du,{src:e});let t=Tu(e);if(t)return(0,Q.jsx)(Ou,{videoId:t});let n=Eu(e);return n?(0,Q.jsx)(ku,{videoId:n}):null}var ju={p:({children:e})=>(0,Q.jsx)(`p`,{className:`md-p`,children:e}),h1:({children:e})=>(0,Q.jsx)(`h1`,{className:`md-heading`,children:e}),h2:({children:e})=>(0,Q.jsx)(`h2`,{className:`md-heading`,children:e}),h3:({children:e})=>(0,Q.jsx)(`h3`,{className:`md-heading`,children:e}),code:({children:e,className:t})=>t===`language-mermaid`?(0,Q.jsx)(bu,{source:String(e).replace(/\n$/,``)}):(0,Q.jsx)(`code`,{className:`md-code ${t||``}`.trim(),children:e}),pre:({children:e,node:t})=>{let n=t?.children?.[0];return n?.type===`element`&&n.tagName===`code`&&(n.properties?.className??[]).includes(`language-mermaid`)?(0,Q.jsx)(Q.Fragment,{children:e}):(0,Q.jsx)(`pre`,{className:`md-pre`,children:e})},ul:({children:e})=>(0,Q.jsx)(`ul`,{className:`md-list`,children:e}),ol:({children:e})=>(0,Q.jsx)(`ol`,{className:`md-list md-list-ordered`,children:e}),li:({children:e})=>(0,Q.jsx)(`li`,{className:`md-list-item`,children:e}),hr:()=>(0,Q.jsx)(`hr`,{className:`md-hr`}),strong:({children:e})=>(0,Q.jsx)(`strong`,{className:`md-strong`,children:e}),img:({src:e,alt:t})=>Au(e)||(0,Q.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:(0,Q.jsx)(`img`,{className:`md-img`,src:e,alt:t||``,loading:`lazy`})}),a:({href:e,children:t})=>Au(e)||(0,Q.jsx)(`a`,{href:e,className:`md-link`,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({children:e})=>(0,Q.jsx)(`table`,{className:`md-table`,children:e}),thead:({children:e})=>(0,Q.jsx)(`thead`,{className:`md-thead`,children:e}),tbody:({children:e})=>(0,Q.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,Q.jsx)(`tr`,{className:`md-tr`,children:e}),th:({children:e})=>(0,Q.jsx)(`th`,{className:`md-th`,children:e}),td:({children:e})=>(0,Q.jsx)(`td`,{className:`md-td`,children:e})};function Mu({content:e,elapsedSeconds:t,timestamp:n}){return(0,Q.jsxs)(`div`,{className:`markdown-message`,children:[(0,Q.jsx)(ps,{remarkPlugins:[_u],components:ju,children:e}),t!==void 0&&(0,Q.jsxs)(`div`,{className:`message-meta`,children:[t,`s`]}),n&&(0,Q.jsx)(`span`,{className:`message-timestamp`,children:n})]})}var Nu=`Accomplishing.Actioning.Actualizing.Architecting.Baking.Beaming.Befuddling.Billowing.Blanching.Bloviating.Boogieing.Boondoggling.Booping.Bootstrapping.Brewing.Bunning.Burrowing.Calculating.Canoodling.Caramelizing.Cascading.Catapulting.Cerebrating.Channeling.Channelling.Choreographing.Churning.Clauding.Coalescing.Cogitating.Combobulating.Composing.Computing.Concocting.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Crystallizing.Cultivating.Deciphering.Deliberating.Determining.Discombobulating.Doing.Doodling.Drizzling.Ebbing.Effecting.Elucidating.Embellishing.Enchanting.Envisioning.Evaporating.Fermenting.Finagling.Flibbertigibbeting.Flowing.Flummoxing.Fluttering.Forging.Forming.Frolicking.Frosting.Gallivanting.Galloping.Garnishing.Generating.Germinating.Gesticulating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hatching.Herding.Honking.Hullaballooing.Hyperspacing.Ideating.Imagining.Improvising.Incubating.Inferring.Infusing.Ionizing.Jitterbugging.Julienning.Kneading.Leavening.Levitating.Lollygagging.Manifesting.Marinating.Meandering.Metamorphosing.Misting.Moonwalking.Moseying.Mulling.Musing.Mustering.Nebulizing.Nesting.Newspapering.Noodling.Nucleating.Orbiting.Orchestrating.Osmosing.Perambulating.Percolating.Perusing.Philosophising.Photosynthesizing.Pollinating.Pondering.Pontificating.Pouncing.Precipitating.Prestidigitating.Processing.Proofing.Propagating.Puttering.Puzzling.Quantumizing.Razzmatazzing.Recombobulating.Reticulating.Roosting.Ruminating.Scampering.Schlepping.Scurrying.Seasoning.Shenaniganing.Shimmying.Simmering.Skedaddling.Sketching.Slithering.Smooshing.Spelunking.Spinning.Sprouting.Stewing.Sublimating.Swirling.Swooping.Symbioting.Synthesizing.Tempering.Thinking.Thundering.Tinkering.Tomfoolering.Transfiguring.Transmuting.Twisting.Undulating.Unfurling.Unravelling.Vibing.Waddling.Wandering.Warping.Whatchamacalliting.Whirlpooling.Whirring.Whisking.Wibbling.Working.Wrangling.Zesting.Zigzagging`.split(`.`),Pu=9e4,Fu=4e3,Iu=2500;function Lu(e){let t=Math.max(0,Math.floor(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function Ru({activity:e,turnCount:t,liveness:n,wedged:r}){let[i]=(0,$.useState)(()=>Date.now()),[a,o]=(0,$.useState)(()=>Date.now());(0,$.useEffect)(()=>{let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[]);let[s,c]=(0,$.useState)(()=>Math.floor(Math.random()*Nu.length)),l=()=>c(e=>(e+1+Math.floor(Math.random()*(Nu.length-1)))%Nu.length);(0,$.useEffect)(()=>{l()},[t]);let u=(0,$.useRef)(0),d=n?n.tick:null;(0,$.useEffect)(()=>{if(d===null)return;let e=Date.now();e-u.current<Iu||(u.current=e,l())},[d]);let f=n!=null&&!e,p=n?n.at??i:i,m=f?a-p>Pu:!!r,h=f?a-p<Fu:null,g=e?`${e.count>=2?`${e.count} agents · `:``}${e.agentType} · ${e.description}`:`${Nu[s]}…`;return(0,Q.jsxs)(`div`,{className:`chat-activity`,"data-stalled":m?`true`:`false`,"data-fresh":h===null?void 0:h?`true`:`false`,"aria-live":`polite`,"aria-label":m?`Agent may be stalled`:`Agent is working`,children:[(0,Q.jsx)(`img`,{src:`/brand/claude.png`,alt:``,className:`chat-activity-icon`}),(0,Q.jsx)(`span`,{className:`chat-activity-word`,children:g}),(0,Q.jsx)(`span`,{className:`chat-activity-elapsed`,children:Lu(a-i)}),m&&(0,Q.jsx)(`span`,{className:`chat-activity-stalled`,children:`stalled`})]})}function zu({variant:e,icon:t,label:n,children:r,defaultExpanded:i=!1}){let[a,o]=(0,$.useState)(i);return(0,Q.jsxs)(`div`,{className:`chat-${e}`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`chat-${e}-toggle`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[(0,Q.jsx)(`span`,{className:`wa-chevron`,children:t}),(0,Q.jsx)(`span`,{className:`chat-${e}-label`,children:n})]}),a&&r]})}function Bu({turns:e}){let t=e.filter(e=>e.kind===`tool-call`).length,n=t>0?`Used ${t} tool${t===1?``:`s`}`:`${e.length} tool result${e.length===1?``:`s`}`;return(0,Q.jsx)(zu,{variant:`toolrun`,icon:(0,Q.jsx)(Ne,{size:12}),label:n,children:e.map((e,t)=>(0,Q.jsxs)(`div`,{className:`chat-toolrun-item`,children:[(0,Q.jsx)(`span`,{className:`chat-toolrun-name`,children:e.kind===`tool-call`?`↳ ${e.name}`:e.isError?`result (error)`:`result`}),(0,Q.jsx)(`pre`,{className:`wa-code`,children:e.kind===`tool-call`?JSON.stringify(e.input,null,2):e.text})]},t))})}function Vu({turns:e}){return(0,Q.jsx)(zu,{variant:`thinking`,icon:(0,Q.jsx)(Ve,{size:12}),label:`Thoughts`,children:e.map((e,t)=>(0,Q.jsx)(`div`,{className:`chat-thinking-item`,children:(0,Q.jsx)(Mu,{content:e.text})},t))})}function Hu({ts:e}){let t=se(e);return t?(0,Q.jsx)(`time`,{className:`chat-time`,children:t}):null}function Uu({text:e}){let{status:t,copy:n}=Fe(),r=t===`ok`;return(0,Q.jsx)(`button`,{type:`button`,className:`chat-copy`,"aria-label":r?`Copied`:`Copy message`,title:r?`Copied`:`Copy`,onClick:()=>n(e),children:r?(0,Q.jsx)(a,{size:13,"aria-hidden":!0}):(0,Q.jsx)(ke,{size:13,"aria-hidden":!0})})}function Wu({ts:e,copyText:t}){return(0,Q.jsxs)(`div`,{className:`chat-msg-foot`,children:[(0,Q.jsx)(Hu,{ts:e}),(0,Q.jsx)(Uu,{text:t})]})}function Gu(e,t,n,r,i,a=!1){switch(e.kind){case`operator-inbound`:case`operator-typed`:{let o=e.kind===`operator-inbound`?e.rawBody:void 0,s=a?o??e.text:e.text,c=e.kind===`operator-inbound`?e.attachments:void 0,l=e.channel,u=e.kind===`operator-inbound`&&(e.source===`whatsapp`||e.source===`telegram`)?e.source:void 0,d=l??u;return(0,Q.jsxs)(`div`,{className:d?`chat-turn-op chat-turn-op--${d}`:`chat-turn-op`,children:[s&&(0,Q.jsx)(`p`,{className:`chat-op-body`,children:s}),c&&c.length>0&&(0,Q.jsx)(`div`,{className:`chat-attachment-list`,children:c.map((e,t)=>(0,Q.jsx)(E,{expandable:!0,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,href:e.source===`claude-upload`?ce(r,e.filename,i):D(e.attachmentId,n,r,i)},t))}),s?(0,Q.jsx)(Wu,{ts:e.ts,copyText:s}):(0,Q.jsx)(Hu,{ts:e.ts})]},t)}case`agent-reply`:return(0,Q.jsxs)(`div`,{className:`chat-prose`,children:[(0,Q.jsx)(Mu,{content:e.text}),e.text?(0,Q.jsx)(Wu,{ts:e.ts,copyText:e.text}):(0,Q.jsx)(Hu,{ts:e.ts})]},t);case`agent-webchat-final`:return(0,Q.jsx)(`div`,{className:`chat-prose`,children:(0,Q.jsxs)(zu,{variant:`narration`,icon:(0,Q.jsx)(ye,{size:12}),label:`Assistant note`,defaultExpanded:!0,children:[(0,Q.jsx)(Mu,{content:e.text}),e.text?(0,Q.jsx)(Wu,{ts:e.ts,copyText:e.text}):(0,Q.jsx)(Hu,{ts:e.ts})]})},t);case`agent-reply-document`:return(0,Q.jsxs)(`div`,{className:`chat-prose`,children:[e.files.map((e,t)=>(0,Q.jsx)(E,{filename:w(e)},t)),e.caption&&(0,Q.jsx)(Mu,{content:e.caption}),(0,Q.jsx)(Hu,{ts:e.ts})]},t);case`agent-file`:return(0,Q.jsxs)(`div`,{className:`chat-prose`,children:[e.files.map((t,n)=>{let a=w(t),o=e.downloads?.[n];if(!o)return(0,Q.jsxs)(`p`,{className:`chat-doc`,children:[(0,Q.jsx)(ue,{size:14,"aria-hidden":!0,style:{verticalAlign:`text-bottom`}}),` `,a]},n);let s=x(o,r,i);return O.test(a)?(0,Q.jsx)(re,{src:x(o,r,i,`inline`),filename:a},n):te.test(a)?(0,Q.jsx)(`img`,{className:`chat-doc-image`,src:s,alt:a},n):(0,Q.jsxs)(`a`,{className:`chat-doc chat-doc-attachment`,href:s,download:a,children:[(0,Q.jsx)(ue,{size:14,"aria-hidden":!0}),a]},n)}),e.caption&&(0,Q.jsx)(Mu,{content:e.caption}),(0,Q.jsx)(Hu,{ts:e.ts})]},t);case`session-continued`:return(0,Q.jsx)(A,{},t);case`harness-internal`:return(0,Q.jsx)(zu,{variant:`thinking`,icon:(0,Q.jsx)(Ne,{size:12}),label:`Internal`,children:(0,Q.jsx)(`div`,{className:`chat-thinking-item`,children:(0,Q.jsx)(Mu,{content:e.text})})},t);case`whatsapp-persisted`:return(0,Q.jsxs)(`div`,{className:`chat-prose`,children:[(0,Q.jsx)(Mu,{content:e.text}),e.reactions&&e.reactions.length>0&&(0,Q.jsx)(`div`,{className:`wa-reactions`,children:e.reactions.map((e,t)=>(0,Q.jsx)(`span`,{className:`wa-reaction`,title:e.reactorName??void 0,children:e.emoji},t))}),(0,Q.jsx)(Hu,{ts:e.ts})]},t);case`agent-error`:return(0,Q.jsxs)(`div`,{className:`chat-agent-error`,role:`alert`,children:[(0,Q.jsx)(`span`,{className:`chat-agent-error-msg`,children:de(e.code,n)}),n===`admin`&&e.code===`agent_error`&&e.raw&&(0,Q.jsx)(`pre`,{className:`chat-agent-error-raw`,children:e.raw})]},t)}}function Ku({text:e,filenames:t}){return(0,Q.jsxs)(`div`,{className:`chat-turn-op chat-turn-op--pending`,"aria-busy":`true`,children:[e&&(0,Q.jsx)(`p`,{className:`chat-op-body`,children:e}),t.length>0&&(0,Q.jsx)(`div`,{className:`chat-attachment-list`,children:t.map((e,t)=>(0,Q.jsx)(`span`,{className:`chat-pending-attachment`,children:e},t))})]})}function qu(e,t,n,r=`admin`,i=!1){let a=[],o=[],s=[],c=null,l=()=>{o.length!==0&&(a.push((0,Q.jsx)(Bu,{turns:o},`tools-${a.length}`)),o=[])},u=()=>{s.length!==0&&(a.push((0,Q.jsx)(Vu,{turns:s},`think-${a.length}`)),s=[])};return e.forEach((e,d)=>{let f=T(e),p=ee(f);if(p!==null&&p!==c&&(l(),u(),a.push((0,Q.jsx)(k,{ts:f},`day-${d}`)),c=p),e.kind===`turn`&&(e.turn.kind===`tool-call`||e.turn.kind===`tool-result`)){u(),o.push(e.turn);return}if(e.kind===`turn`&&e.turn.kind===`agent-text`){l(),s.push(e.turn);return}if(i&&e.kind===`turn`&&e.turn.kind===`operator-inbound`&&e.turn.scheduled){l(),u();return}l(),u(),e.kind===`directive`?a.push((0,Q.jsx)(S,{entry:e.entry,sessionId:t,sessionKey:n},d)):a.push(Gu(e.turn,d,r,t,n,i))}),l(),u(),a}new Set(`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text,text/rtf,application/rtf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-powerpoint,application/vnd.oasis.opendocument.presentation,audio/ogg,audio/opus,audio/mp4,audio/mpeg,audio/webm,audio/wav,.docx,.odt,.rtf,.xlsx,.xls,.ods,.pptx,.ppt,.odp,.opus,.ogg,.m4a,.mp3,.wav,.webm`.split(`,`).filter(e=>!e.startsWith(`.`)));var Ju=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function Yu(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Xu(){let e=window.location.pathname.match(/^\/([a-z][a-z0-9-]{2,49})$/);return e?e[1]:void 0}var Zu=`maxy_seed_q`;function Qu(){let e=new URLSearchParams(window.location.search).get(`q`);if(e==null)return null;let t=e.trim();return t?t.slice(0,2e3):null}function $u(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function ed({data:e,active:t}){let n=[];if(e&&e.length>0&&t){let t=Math.floor(e.length/24);for(let r=0;r<24;r++){let i=e[r*t]??128,a=Math.abs(i-128)/128;n.push(Math.max(.15,a))}}else for(let e=0;e<24;e++)n.push(.15);return(0,Q.jsx)(`div`,{className:`voice-waveform`,"aria-hidden":`true`,children:n.map((e,t)=>(0,Q.jsx)(`div`,{className:`voice-waveform-bar`,style:{height:`${Math.round(e*100)}%`}},t))})}function td({state:e,elapsedSeconds:t,waveform:n,onTogglePause:r,onDiscard:i,onSend:a}){if(e===`idle`||e===`error`)return null;let o=e===`recording`,s=e===`paused`,c=e===`sending`;return(0,Q.jsxs)(`div`,{className:`voice-recorder`,role:`region`,"aria-label":`Voice recording`,"aria-live":`polite`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`voice-trash`,onClick:i,disabled:c,"aria-label":`Discard recording`,children:(0,Q.jsx)(u,{size:16})}),(0,Q.jsx)(`span`,{className:`voice-timer`,"aria-live":`polite`,"aria-atomic":`true`,children:$u(t)}),(0,Q.jsx)(ed,{data:n,active:o}),(0,Q.jsx)(`button`,{type:`button`,className:`voice-pause`,onClick:r,disabled:c,"aria-label":s?`Resume recording`:`Pause recording`,children:s?(0,Q.jsx)(je,{size:14}):(0,Q.jsx)(C,{size:14})}),(0,Q.jsx)(Ee,{variant:`send`,type:`button`,onClick:a,disabled:c,loading:c,"aria-label":`Send voice note`,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,Q.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})}var nd=r(`wrench-off`,[[`path`,{d:`M10.747 5.093a6 6 0 0 1 6.841-2.882c.438.12.54.662.219.984L14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-2.882 6.842`,key:`a1`}],[`path`,{d:`m13.5 13.5-7.88 7.88a1 1 0 0 1-2.999-3l7.88-7.88`,key:`a2`}],[`path`,{d:`m2 2 20 20`,key:`a3`}]]),rd={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},id=[{id:Se,label:we(Se)},{id:me,label:we(me)},{id:be,label:we(be)}],ad=[{id:`low`,label:`Low`},{id:`medium`,label:`Medium`},{id:`high`,label:`High`},{id:`xhigh`,label:`Extra`},{id:`max`,label:`Max`}],od=[{id:`default`,label:`Ask permissions`},{id:`acceptEdits`,label:`Accept edits`},{id:`bypassPermissions`,label:`Bypass permissions`}];function sd({newModel:e,onPickModel:t,newEffort:n,onPickEffort:r,onNewSession:i,newSessionPending:o,newPermMode:s,onPickPermMode:c}){let l=Math.max(0,ad.findIndex(e=>e.id===n)),u=ad[l]?.label??``,d=ad.length-1,f=e=>`calc(14px + (100% - 28px) * ${d>0?e/d:0})`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`webchat-newsession-field`,children:[(0,Q.jsx)(`span`,{children:`Model`}),(0,Q.jsx)(`div`,{className:`webchat-newsession-models`,children:id.map(n=>(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-newsession-model`,role:`menuitemradio`,"aria-checked":e===n.id,onClick:()=>t(n.id),children:[(0,Q.jsx)(`span`,{children:n.label}),e===n.id&&(0,Q.jsx)(a,{size:13})]},n.id))})]}),(0,Q.jsxs)(`div`,{className:`webchat-newsession-field`,children:[(0,Q.jsxs)(`div`,{className:`webchat-newsession-effort-head`,children:[(0,Q.jsxs)(`span`,{children:[`Effort `,(0,Q.jsx)(`strong`,{children:u})]}),(0,Q.jsx)(`span`,{className:`webchat-newsession-effort-help`,title:`Higher effort lets the model think longer before it answers.`,children:(0,Q.jsx)(Le,{size:14})})]}),(0,Q.jsxs)(`div`,{className:`webchat-newsession-slider-ends`,"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{children:`Faster`}),(0,Q.jsx)(`span`,{children:`Smarter`})]}),(0,Q.jsxs)(`div`,{className:`webchat-newsession-track`,children:[(0,Q.jsx)(`span`,{className:`webchat-newsession-track-fill`,style:{width:f(l)},"aria-hidden":`true`}),ad.map((e,t)=>(0,Q.jsx)(`span`,{className:`webchat-newsession-dot${t===d?` is-max`:``}`,style:{left:f(t)},"aria-hidden":`true`},e.id)),(0,Q.jsx)(`span`,{className:`webchat-newsession-knob`,style:{left:f(l)},"aria-hidden":`true`}),(0,Q.jsx)(`input`,{type:`range`,className:`webchat-newsession-slider`,min:0,max:d,step:1,value:l,onChange:e=>r(ad[Number(e.target.value)].id),"aria-label":`New session thinking effort`})]})]}),s!=null&&c&&(0,Q.jsxs)(`div`,{className:`webchat-newsession-field`,children:[(0,Q.jsx)(`span`,{children:`Permissions`}),(0,Q.jsx)(`div`,{className:`webchat-newsession-models`,children:od.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-newsession-model`,role:`menuitemradio`,"aria-checked":s===e.id,onClick:()=>c(e.id),children:[(0,Q.jsx)(`span`,{children:e.label}),s===e.id&&(0,Q.jsx)(a,{size:13})]},e.id))})]}),(0,Q.jsx)(`button`,{type:`button`,className:`webchat-newsession-go`,onClick:()=>void i(),disabled:o,children:o?`Starting…`:`Start new session`})]})}var cd={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`};function ld(e){return we(ve(e))}function ud(e){return e>=1e6?`~${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`~${Math.round(e/1e3)}k`:`~${e}`}function dd({pct:e,usedTokens:t,window:n}){let r=Math.max(0,Math.min(100,e)),i=`Context window used — ${e}% · ${ud(t)}/${ud(n)}`;return(0,Q.jsx)(`span`,{className:`webchat-context-ring`,role:`img`,"aria-label":i,title:i,children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 14 14`,width:`14`,height:`14`,"aria-hidden":`true`,children:[(0,Q.jsx)(`circle`,{className:`ring-track`,cx:`7`,cy:`7`,r:`5`}),(0,Q.jsx)(`circle`,{className:`ring-fill`,cx:`7`,cy:`7`,r:`5`,pathLength:100,strokeDasharray:`${r} 100`,transform:`rotate(-90 7 7)`})]})})}function fd(e){let{deliveryFailure:t,permPrompt:n,onVerdict:r,isDragOver:i,onDragOver:o,onDragLeave:s,onDrop:l,fileInputRef:u,acceptMime:d,onFileInputChange:f,showResizeHandle:p,onResizePointerDown:m,onResizeKeyDown:v,pendingFiles:b,thumbUrls:x,onRemoveFile:S,attachError:C,sendError:w,transcribing:T=!1,voice:E,isVoiceActive:D,onVoiceSend:O,text:k,onTextareaChange:ee,textareaRef:te,textareaHeight:ne,textareaDisabled:A,placeholder:re=`Message your agent…`,onKeyDown:ie,onPaste:ae,onSend:oe,sendDisabled:se,turnActive:ce=!1,onStop:le,stopping:de=!1,deadChildNotice:fe,conflictHint:j,showNewSession:me,newSessionRef:ge,newSessionOpen:_e,onToggleNewSession:ve,newSessionDisabled:ye,newModel:be,onPickModel:xe,newEffort:Se,onPickEffort:Ce,onNewSession:we,newSessionPending:Ee,newPermMode:De,onPickPermMode:M,onAttachClick:je,attachDisabled:Pe,micMenuRef:Fe,onMicStart:Ie,micStartDisabled:Le,onOpenMicMenu:Be,micMenuOpen:Ve,micDevices:Ue,micDeviceId:We,onChooseMic:Ge,showCleanToggle:Ke,cleanView:qe,onToggleClean:Je,showControlsRight:Ye,sessionId:N,mode:Xe,model:Ze,effort:Qe,contextUsage:$e,paramsMenuRef:et,paramsMenuOpen:tt,onToggleParamsMenu:nt}=e,P=e=>e.preventDefault(),[F,rt]=(0,$.useState)(!1),it=(0,$.useRef)(null),I=(0,$.useRef)(null),L=()=>{N&&(it.current=setTimeout(()=>{let e=navigator.clipboard?.writeText(N);e&&e.then(()=>{rt(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>rt(!1),1200)}).catch(()=>{})},500))},at=()=>{it.current&&=(clearTimeout(it.current),null)};return(0,$.useEffect)(()=>()=>{it.current&&clearTimeout(it.current),I.current&&clearTimeout(I.current)},[]),(0,Q.jsxs)(`div`,{className:`webchat-composer`,children:[t&&(0,Q.jsx)(`div`,{className:`webchat-delivery-failed`,role:`alert`,children:`Message not delivered — the session was unresponsive. Resend to retry.`}),n&&(0,Q.jsxs)(`div`,{className:`webchat-perm-card`,role:`alertdialog`,"aria-label":`Permission request`,children:[(0,Q.jsxs)(`div`,{className:`webchat-perm-head`,children:[`Claude wants to run `,(0,Q.jsx)(`strong`,{children:n.toolName})]}),n.description&&(0,Q.jsx)(`div`,{className:`webchat-perm-desc`,children:n.description}),n.inputPreview&&(0,Q.jsx)(`pre`,{className:`webchat-perm-preview`,children:n.inputPreview}),(0,Q.jsxs)(`div`,{className:`webchat-perm-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`webchat-perm-deny`,onPointerDown:P,onClick:()=>void r(`deny`),children:`Deny`}),(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-perm-allow`,onPointerDown:P,onClick:()=>void r(`allow`),children:[`Allow`,(0,Q.jsx)(Re,{size:14})]})]})]}),(0,Q.jsxs)(`div`,{className:`webchat-composer-box${i?` drag-over`:``}`,onDragOver:o,onDragLeave:s,onDrop:l,children:[(0,Q.jsx)(`input`,{ref:u,type:`file`,multiple:!0,accept:d,style:{display:`none`},onChange:f}),p&&(0,Q.jsx)(`div`,{className:`webchat-resize-handle`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize input — drag up to enlarge`,tabIndex:0,onPointerDown:m,onKeyDown:v}),b.length>0&&(0,Q.jsx)(`div`,{className:`attachment-strip`,children:b.map((e,t)=>(0,Q.jsxs)(`div`,{className:`attachment-chip`,children:[x[t]?(0,Q.jsx)(`img`,{src:x[t]??void 0,alt:e.name,className:`attachment-chip-thumb`}):e.type.startsWith(`audio/`)?(0,Q.jsx)(y,{size:14}):e.type===`application/pdf`?(0,Q.jsx)(Ae,{size:14}):(0,Q.jsx)(_,{size:14}),(0,Q.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,Q.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>S(t),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),C&&(0,Q.jsx)(`p`,{className:`attach-error`,children:C}),w&&(0,Q.jsx)(`p`,{className:`webchat-send-error`,role:`alert`,children:w}),fe&&(0,Q.jsxs)(`p`,{className:`webchat-dead-child-notice`,role:`status`,children:[(0,Q.jsx)(Me,{size:14,"aria-hidden":!0}),` `,fe]}),T&&(0,Q.jsxs)(`p`,{className:`webchat-transcribing`,role:`status`,"aria-live":`polite`,children:[(0,Q.jsx)(c,{size:14,className:`webchat-transcribing-spin`}),`Transcribing audio…`]}),E.state===`error`&&E.errorMessage&&(0,Q.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,Q.jsx)(y,{size:14}),E.errorMessage]}),D?(0,Q.jsx)(`div`,{className:`webchat-input-row voice-active`,children:(0,Q.jsx)(td,{state:E.state,elapsedSeconds:E.elapsedSeconds,waveform:E.waveform,onTogglePause:E.togglePause,onDiscard:E.discard,onSend:()=>void O()})}):(0,Q.jsxs)(`div`,{className:`webchat-input-row`,children:[(0,Q.jsx)(`textarea`,{ref:te,className:`webchat-input`,value:k,placeholder:re,rows:2,style:{height:`${ne}px`},disabled:A,onChange:ee,onKeyDown:ie,onPaste:ae}),ce?(0,Q.jsx)(`button`,{type:`button`,className:`webchat-send webchat-stop${de?` is-stopping`:``}`,onPointerDown:P,onClick:()=>void le?.(),disabled:de,"aria-label":de?`Stopping`:`Stop`,title:de?`Stopping…`:`Stop generating`,children:de?(0,Q.jsx)(c,{size:16,className:`webchat-stop-spin`}):(0,Q.jsx)(h,{size:16})}):k.trim().length===0&&b.length===0?(0,Q.jsx)(`button`,{type:`button`,className:`webchat-send webchat-mic-inline`,onPointerDown:P,onClick:()=>void Ie(),disabled:Le,"aria-label":`Voice input`,title:`Record voice note`,children:(0,Q.jsx)(y,{size:16})}):(0,Q.jsx)(`button`,{type:`button`,className:`webchat-send`,onPointerDown:P,onClick:()=>void oe(),disabled:se,"aria-label":`Send`,title:`Send`,children:(0,Q.jsx)(Re,{size:16})})]}),j!==null&&(0,Q.jsxs)(`p`,{className:`webchat-conflict-hint`,children:[`This session is bound to the `,j,` channel — message it there. The transcript stays readable here.`]})]}),(0,Q.jsxs)(`div`,{className:`webchat-controls`,children:[(0,Q.jsxs)(`div`,{className:`webchat-controls-left`,children:[me&&(0,Q.jsxs)(`div`,{className:`webchat-newsession`,ref:ge,children:[(0,Q.jsx)(`button`,{type:`button`,className:`webchat-control`,onPointerDown:P,onClick:ve,disabled:ye,"aria-haspopup":`menu`,"aria-expanded":_e,title:`New session`,"aria-label":`New session`,children:(0,Q.jsx)(g,{size:14})}),_e&&(0,Q.jsx)(`div`,{className:`webchat-newsession-panel`,role:`menu`,children:(0,Q.jsx)(sd,{newModel:be,onPickModel:xe,newEffort:Se,onPickEffort:Ce,onNewSession:we,newSessionPending:Ee,newPermMode:De,onPickPermMode:M})})]}),(0,Q.jsx)(`button`,{type:`button`,className:`webchat-control`,onPointerDown:P,onClick:je,disabled:Pe,title:`Attach files`,"aria-label":`Attach`,children:(0,Q.jsx)(ue,{size:14})}),(0,Q.jsxs)(`div`,{className:`webchat-mic-split`,ref:Fe,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-control webchat-mic-chevron`,onPointerDown:P,onClick:Be,disabled:Le,"aria-haspopup":`menu`,"aria-expanded":Ve,title:`Choose microphone`,"aria-label":`Choose microphone`,children:[(0,Q.jsx)(y,{size:14}),(0,Q.jsx)(Te,{size:12})]}),Ve&&(0,Q.jsxs)(`div`,{className:`webchat-mic-panel`,role:`menu`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-mic-item`,role:`menuitemradio`,"aria-checked":We===null,onClick:()=>Ge(null,`System default`),children:[(0,Q.jsx)(`span`,{children:`System default`}),We===null&&(0,Q.jsx)(a,{size:13})]}),Ue.filter(e=>e.label).map((e,t)=>(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-mic-item`,role:`menuitemradio`,"aria-checked":e.deviceId===We,onClick:()=>Ge(e.deviceId,e.label||`Microphone ${t+1}`),children:[(0,Q.jsx)(`span`,{children:e.label}),e.deviceId===We&&(0,Q.jsx)(a,{size:13})]},e.deviceId)),Ue.filter(e=>e.label).length===0&&(0,Q.jsx)(`span`,{className:`webchat-mic-hint`,children:`Allow microphone access to choose a device`})]})]}),Ke&&(0,Q.jsx)(`button`,{type:`button`,className:`webchat-control webchat-clean-toggle`,onPointerDown:P,onClick:Je,"aria-pressed":!qe,"aria-label":`Show tool calls and thinking`,title:qe?`Showing delivered messages only — click to show tool calls, results, and thinking`:`Showing tool calls, results, and thinking — click to show delivered messages only`,children:qe?(0,Q.jsx)(nd,{size:14}):(0,Q.jsx)(Ne,{size:14})})]}),Ye&&(0,Q.jsxs)(`div`,{className:`webchat-controls-right`,children:[N&&(0,Q.jsx)(`code`,{className:`webchat-session-id`,title:`First 8 characters of this session's id — matches the Sessions list.`,children:N.slice(0,8)}),(Xe||Ze||Qe)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`webchat-params webchat-params--inline`,"aria-label":`Session parameters`,children:[Xe&&(0,Q.jsx)(`span`,{className:`webchat-param`,children:cd[Xe]??Xe}),Ze&&(0,Q.jsx)(`span`,{className:`webchat-param`,children:ld(Ze)}),Qe&&(0,Q.jsx)(`span`,{className:`webchat-param`,children:rd[Qe]??Qe})]}),(0,Q.jsxs)(`div`,{className:`webchat-params-menu`,ref:et,children:[(0,Q.jsx)(`button`,{type:`button`,className:`webchat-control webchat-params-trigger`,onPointerDown:P,"aria-haspopup":`menu`,"aria-expanded":tt,"aria-label":`Session parameters`,title:`Session parameters`,onClick:nt,children:(0,Q.jsx)(pe,{size:14})}),tt&&(0,Q.jsxs)(`div`,{className:`webchat-params-panel`,role:`menu`,children:[Xe&&(0,Q.jsxs)(`span`,{className:`webchat-param`,role:`menuitem`,children:[(0,Q.jsx)(He,{size:13,"aria-hidden":`true`}),cd[Xe]??Xe]}),Ze&&(0,Q.jsxs)(`span`,{className:`webchat-param`,role:`menuitem`,children:[(0,Q.jsx)(Oe,{size:13,"aria-hidden":`true`}),ld(Ze)]}),Qe&&(0,Q.jsxs)(`span`,{className:`webchat-param`,role:`menuitem`,children:[(0,Q.jsx)(ze,{size:13,"aria-hidden":`true`}),rd[Qe]??Qe]}),N&&(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-param webchat-session-id-full${F?` is-copied`:``}`,role:`menuitem`,title:`Long-press to copy the full session id`,"aria-label":F?`Session id copied`:`Session id — long-press to copy`,onPointerDown:L,onPointerUp:at,onPointerLeave:at,onContextMenu:e=>e.preventDefault(),children:[F?(0,Q.jsx)(a,{size:13,"aria-hidden":`true`}):(0,Q.jsx)(ke,{size:13,"aria-hidden":`true`}),(0,Q.jsx)(`code`,{children:F?`Copied`:N})]}),$e&&(0,Q.jsxs)(`span`,{className:`webchat-param`,role:`menuitem`,children:[(0,Q.jsx)(he,{size:13,"aria-hidden":`true`}),$e.pct,`% · `,ud($e.usedTokens),`/`,ud($e.window)]})]})]})]}),$e&&(0,Q.jsx)(dd,{pct:$e.pct,usedTokens:$e.usedTokens,window:$e.window})]})]})]})}function pd(e,t){return(t??{}).deadChild===!0?`dead-child`:e===200?`ok`:`failed`}function md(e,t){if(e)return null;try{return new URLSearchParams(t).get(`session`)}catch{return null}}function hd(e){return typeof e!=`number`||!Number.isFinite(e)?``:new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function gd({s:e,onOpen:t,onRename:n,onArchive:r,onDelete:i,onEnd:o,onCopyId:c}){let[l,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(!1),[g,_]=(0,$.useState)(``),[v,y]=(0,$.useState)(!1),b=(0,$.useRef)(!1),x=()=>{f(!1),y(!1)},S=()=>{_(e.name||``),m(!0),f(!1)},C=()=>{if(m(!1),b.current){b.current=!1;return}g.trim()!==(e.name||``)&&n(e,g)};return p?(0,Q.jsx)(`div`,{className:`op-conv-rename`,children:(0,Q.jsx)(`input`,{className:`op-conv-rename-input`,autoFocus:!0,onFocus:e=>e.currentTarget.select(),value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`?C():e.key===`Escape`&&(b.current=!0,m(!1))},onBlur:C,placeholder:`Conversation name`,"aria-label":`Conversation name`})}):(0,Q.jsxs)(`div`,{className:`op-conv-rowwrap`,"aria-current":e.active?`true`:void 0,children:[(0,Q.jsxs)(`div`,{className:`op-conv-row-inner`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-resume`,onClick:()=>t(e),children:[(0,Q.jsxs)(`span`,{className:`op-conv-line1`,children:[e.active?(0,Q.jsx)(`span`,{className:`op-conv-current`,"aria-label":`Current session`,children:(0,Q.jsx)(a,{size:14})}):null,(0,Q.jsx)(`span`,{className:`op-conv-name`,children:e.name||`New conversation`})]}),(0,Q.jsxs)(`span`,{className:`op-conv-line2`,children:[(0,Q.jsx)(`span`,{className:`op-conv-when`,children:hd(e.lastActiveMs)}),(0,Q.jsx)(`code`,{className:`op-conv-id`,title:e.id,children:e.id})]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`op-conv-copy`,"aria-label":`Copy session id`,title:`Copy session id`,onClick:()=>c(e),children:(0,Q.jsx)(ke,{size:14})}),(0,Q.jsx)(`button`,{type:`button`,className:`op-conv-kebab`,"aria-label":l?`Close actions`:`Conversation actions`,"aria-expanded":l,onClick:()=>l?x():f(!0),children:l?(0,Q.jsx)(d,{size:16}):(0,Q.jsx)(pe,{size:16})})]}),l?(0,Q.jsxs)(`div`,{className:`op-conv-actions`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action`,onClick:S,children:[(0,Q.jsx)(s,{size:13}),` Rename`]}),e.active?(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action`,onClick:()=>{o(e),x()},children:[(0,Q.jsx)(h,{size:13}),` End session`]}):null,e.active?null:e.archived?(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action`,onClick:()=>{r(e,!1),x()},children:[(0,Q.jsx)(j,{size:13}),` Unarchive`]}):(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action`,onClick:()=>{r(e,!0),x()},children:[(0,Q.jsx)(De,{size:13}),` Archive`]}),e.active?null:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action danger`,onClick:()=>{i(e),x()},children:[(0,Q.jsx)(u,{size:13}),` Confirm`]}),(0,Q.jsx)(`button`,{type:`button`,className:`op-conv-action`,onClick:()=>y(!1),children:`Cancel`})]}):(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-action danger`,onClick:()=>y(!0),children:[(0,Q.jsx)(u,{size:13}),` Delete`]})]}):null]})}function _d({sessions:e,onOpen:t,onRename:n,onArchive:r,onDelete:i,onEnd:a,onNew:o,onBack:s,onCopyId:c}){let[l,u]=(0,$.useState)(!1),f=e.filter(e=>!e.archived),p=e.filter(e=>e.archived),m={onOpen:t,onRename:n,onArchive:r,onDelete:i,onEnd:a,onCopyId:c};return(0,Q.jsxs)(`div`,{className:`op-conv`,style:{flex:1,minHeight:0,position:`relative`},children:[(0,Q.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,Q.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`}),(0,Q.jsx)(`button`,{type:`button`,className:`op-conv-close`,onClick:s,"aria-label":`Close conversations`,title:`Close`,children:(0,Q.jsx)(d,{size:16})})]}),(0,Q.jsx)(`div`,{className:`op-conv-list`,style:{flex:1,minHeight:0},children:e.length===0?(0,Q.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No conversations yet`}):(0,Q.jsxs)(Q.Fragment,{children:[f.map(e=>(0,Q.jsx)(gd,{s:e,...m},e.id)),p.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-archived-head`,"aria-expanded":l,onClick:()=>u(e=>!e),children:[(0,Q.jsx)(M,{size:14,style:{transform:l?`rotate(-90deg)`:`rotate(180deg)`,transition:`transform 0.12s`}}),`Archived (`,p.length,`)`]}),l?p.map(e=>(0,Q.jsx)(gd,{s:e,...m},e.id)):null]}):null]})}),(0,Q.jsxs)(`button`,{type:`button`,className:`op-conv-new op-conv-new-float`,onClick:o,children:[(0,Q.jsx)(g,{size:14}),` New session`]})]})}var vd=2500,yd=15e3,bd=[{id:`catch-up`,label:`Catch me up`,Icon:Be,prompt:`Catch me up — what came in across my inbox and WhatsApp while I was away, and what needs a reply?`},{id:`my-day`,label:`My day`,Icon:Ie,prompt:`What does my day look like — calendar, anything I need to prep for, and is there a free slot this afternoon?`},{id:`to-do`,label:`To-do`,Icon:ge,prompt:`What is still open and on me — pull together my outstanding tasks: unanswered messages, emails awaiting a reply, follow-ups I have asked you to track, and anything due soon.`}];function xd({userName:e,variant:t,onChip:n}){let r=e?.trim().split(/\s+/)[0];return(0,Q.jsxs)(`div`,{className:`webchat-greeting`,children:[(0,Q.jsx)(`h2`,{className:`webchat-greeting-head`,children:r?`What's up next, ${r}?`:`What's up next?`}),t!==`public`&&(0,Q.jsx)(`div`,{className:`webchat-greeting-chips`,children:bd.map(({id:e,label:t,Icon:r,prompt:i})=>(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-greeting-chip`,onClick:()=>n({id:e,prompt:i}),children:[(0,Q.jsx)(r,{size:16}),` `,t]},e))})]})}function Sd({cacheKey:e,userName:t,targetSessionId:n,variant:r=`admin`,conversationsOpen:i=!1,onCloseConversations:a,cleared:s=!1,onFirstSend:l,switchId:u=null}){let d=r===`public`,p=d,[h,g]=(0,$.useState)(!0),[_,y]=(0,$.useState)(!1),[x,S]=(0,$.useState)(null),C=(0,$.useRef)(null),[w,T]=(0,$.useState)(null),[E,D]=(0,$.useState)(``),O=(0,$.useRef)(null),k=(0,$.useRef)(!1),ee=(0,$.useRef)(null),[te,A]=(0,$.useState)(0),[re,se]=(0,$.useState)(!1),[ce,ue]=(0,$.useState)(0),de=ce>0,[fe,pe]=(0,$.useState)(!1),[j,me]=(0,$.useState)(null),[he,ge]=(0,$.useState)(null),ve=(0,$.useRef)(!1),[ye,be]=(0,$.useState)(!1);(0,$.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(pointer: coarse)`);be(e.matches);let t=e=>be(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[Ce,we]=(0,$.useState)(0),Te=(0,$.useRef)(0),Ee=(0,$.useCallback)(e=>{Te.current=e,we(e)},[]),[De,Oe]=(0,$.useState)(null),[M,ke]=(0,$.useState)([]),[Ae,je]=(0,$.useState)(null),[Me,Ne]=(0,$.useState)(!1),Pe=(0,$.useRef)(null),Fe=()=>Math.round((typeof window>`u`?900:window.innerHeight)/3),[Ie,Le]=(0,$.useState)(null),Re=(0,$.useRef)(null),ze=(0,$.useRef)(null),Be=(0,$.useRef)(null),Ve=(0,$.useCallback)(e=>{let t=Be.current;t&&Le(Math.min(Fe(),Math.max(44,t.startH+(t.startY-e.clientY))))},[]),He=(0,$.useCallback)(()=>{Be.current=null,window.removeEventListener(`pointermove`,Ve),window.removeEventListener(`pointerup`,He)},[Ve]),Ge=(0,$.useCallback)(e=>{Be.current={startY:e.clientY,startH:Re.current?.offsetHeight??44},window.addEventListener(`pointermove`,Ve),window.addEventListener(`pointerup`,He),e.preventDefault()},[Ve,He]),Ke=(0,$.useCallback)(e=>{let t=Ie??Re.current?.offsetHeight??44;e.key===`ArrowUp`?(e.preventDefault(),Le(Math.min(Fe(),t+24))):e.key===`ArrowDown`&&(e.preventDefault(),Le(Math.max(44,t-24)))},[Ie]),[Je,Ye]=(0,$.useState)(null);(0,$.useEffect)(()=>{if(Ie!==null)return;let e=Re.current;if(!e)return;let t=e.style.height;e.style.height=`auto`;let n=Math.min(Fe(),Math.max(44,e.scrollHeight));e.style.height=t,Ye(n)},[E,Ie]),(0,$.useLayoutEffect)(()=>{if(ze.current===null)return;let e=Re.current;if(!e)return;let t=ze.current;ze.current=null,e.setSelectionRange(t,t)},[E]);let N=f(e),[Xe,Ze]=(0,$.useState)(!1),[Qe,$e]=(0,$.useState)(Se),[et,tt]=(0,$.useState)(`medium`),[nt,P]=(0,$.useState)(!1),F=(0,$.useRef)(null);(0,$.useEffect)(()=>{if(!Xe)return;let e=e=>{F.current?.contains(e.target)||Ze(!1)},t=e=>{e.key===`Escape`&&Ze(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[Xe]);let rt=(0,$.useCallback)(async()=>{if(!nt){P(!0);try{let e=await N(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:Qe,effort:et})}),t=await e.json().catch(()=>({})),n=xe(e.ok,e.status,t);console.info(`[admin-ui] composer-new-session status=${e.status} outcome=${n.kind} model=${Qe} effort=${et}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),Ze(!1)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),Ze(!1),y(!0)):console.error(`[admin-ui] composer-new-session-failed status=${e.status} reason=${n.reason}`)}catch(e){console.error(`[admin-ui] composer-new-session-failed error=${e instanceof Error?e.message:String(e)}`)}finally{P(!1)}}},[N,Qe,et,nt]),it=!d,[I,L]=(0,$.useState)([]),[at,R]=(0,$.useState)(!1),z=(0,$.useRef)(0),ot=(0,$.useRef)(!1);(0,$.useEffect)(()=>(ot.current=!1,()=>{ot.current=!0}),[]);let B=(0,$.useCallback)(async()=>{if(!it)return;let e=++z.current;try{let t=await N(`/api/admin/sidebar-sessions`);if(!t.ok){console.error(`[chat-conversations] op=enumerate-failed status=${t.status}`);return}let n=((await t.json()).sessions??[]).filter(e=>e.channel!==`whatsapp`&&e.channel!==`telegram`).map(e=>({id:e.sessionId,name:e.title,active:e.live,archived:!!e.archived,lastActiveMs:Number.isFinite(Date.parse(e.startedAt))?Date.parse(e.startedAt):null})).sort((e,t)=>(t.lastActiveMs??0)-(e.lastActiveMs??0));if(ot.current||e!==z.current)return;L(n),R(!0),console.info(`[chat-conversations] op=enumerate owned=${n.length}`)}catch(e){console.error(`[chat-conversations] op=enumerate-failed error=${e instanceof Error?e.message:String(e)}`)}},[N,it]);(0,$.useEffect)(()=>{B()},[B]),(0,$.useEffect)(()=>{i&&B()},[i,B]);let V=(0,$.useCallback)(async(e,t,n,r)=>{console.info(`[chat-conversations] op=action name=${e} sessionId=${t.id.slice(0,8)}`);try{let t=await N(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!t.ok){console.error(`[chat-conversations] op=action-failed name=${e} status=${t.status}`);return}B()}catch(t){console.error(`[chat-conversations] op=action-failed name=${e} error=${t instanceof Error?t.message:String(t)}`)}},[N,B]),st=(0,$.useCallback)(e=>{console.info(`[chat-conversations] op=action name=open sessionId=${e.id.slice(0,8)}`),window.location.assign(`/chat?session=${encodeURIComponent(e.id)}`)},[]),ct=(0,$.useCallback)((e,t)=>{V(`rename`,e,`/api/admin/session-rename`,{sessionId:e.id,title:t.trim()})},[V]),lt=(0,$.useCallback)((e,t)=>{V(`archive`,e,`/api/admin/session-archive`,{sessionId:e.id,mode:t?`archive`:`unarchive`})},[V]),ut=(0,$.useCallback)(e=>{V(`delete`,e,`/api/admin/session-delete`,{sessionId:e.id})},[V]),dt=(0,$.useCallback)(e=>{V(`stop`,e,`/api/admin/session-stop`,{sessionId:e.id})},[V]),ft=(0,$.useCallback)(e=>{m(e.id)},[]),pt=(0,$.useCallback)(e=>{je(null);let t=e.find(e=>!ie(e.type,v));if(t){je(`Unsupported file type: "${t.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, zip, voice notes.`);return}let n=e.find(e=>e.size>b);if(n){je(`"${n.name}" exceeds the 50 MB limit.`);return}ke(t=>[...t,...e].slice(0,5))},[]),mt=(0,$.useMemo)(()=>M.map(e=>e.type.startsWith(`image/`)?URL.createObjectURL(e):null),[M]);(0,$.useEffect)(()=>()=>{for(let e of mt)e&&URL.revokeObjectURL(e)},[mt]);let ht=ne(),gt=ht.state===`recording`||ht.state===`paused`||ht.state===`sending`,_t=(0,$.useCallback)(async()=>{let t=await ht.send();if(!t)return;let r=t.type===`audio/ogg`?`.ogg`:t.type===`audio/mp4`?`.m4a`:`.webm`,i=new File([t],`voice-note${r}`,{type:t.type});if(re){ke(e=>[...e,i].slice(0,5));return}se(!0);let a=new FormData;if(d){a.append(`message`,``),a.append(`session_key`,w??``);let e=Xu();e&&a.append(`agent`,e)}else a.append(`text`,``);a.append(`attachments`,i),!d&&n&&a.append(`session`,n);try{let t=d?await fetch(`/api/chat`,{method:`POST`,body:a}):await fetch(`/api/webchat/send?session_key=${encodeURIComponent(e)}`,{method:`POST`,body:a});t.ok||(console.error(`[admin-ui] webchat-send-failed kind=voice status=${t.status}`),ke(e=>[...e,i].slice(0,5)),je(`Voice note failed to send. The recording is attached — press send to retry.`))}catch(e){console.error(`[admin-ui] webchat-send-failed kind=voice error=${e instanceof Error?e.message:String(e)}`),ke(e=>[...e,i].slice(0,5)),je(`Voice note failed to send. The recording is attached — press send to retry.`)}finally{se(!1)}},[ht,e,n,re,d,w]),vt=(0,$.useRef)(!1);(0,$.useEffect)(()=>(vt.current=!1,()=>{vt.current=!0}),[]);let yt=(0,$.useRef)(!1),bt=(0,$.useCallback)(async()=>{if(yt.current)return null;yt.current=!0;try{if(d){let e=Xu(),t=await fetch(`/api/public-reader/session${e?`?agent=${encodeURIComponent(e)}`:``}`);if(!t.ok)return null;let n=await t.json();if(vt.current)return null;T(n.sessionKey);let r={sessionId:n.sessionId??``,projectDir:n.projectDir};return C.current=r,S(r),r}let t=`session_key=${encodeURIComponent(e)}${n?`&session=${encodeURIComponent(n)}`:``}`,r=await fetch(`/api/webchat/session?${t}`);if(!r.ok)return null;let i=await r.json();return vt.current?i:(C.current=i,S(i),i)}catch{return null}finally{yt.current=!1}},[e,n,d]);(0,$.useEffect)(()=>{bt();let e=setInterval(()=>{bt()},vd);return()=>clearInterval(e)},[bt]),(0,$.useEffect)(()=>{if(d)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||g(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[d]);let xt=(0,$.useCallback)(async()=>{let t=E.trim();if(!t&&M.length===0||re)return!1;if(!d&&!h)return console.info(`[admin-ui] op=llm-action-blocked action=send reason=claude-disconnected`),y(!0),!1;se(!0),ve.current=!1;try{if(d){let e=w;if(!e)return console.error(`[public-webchat] op=send-skip reason=no-key`),!1;let n,r=Xu();if(M.length>0){let i=new FormData;i.append(`message`,t),i.append(`session_key`,e),r&&i.append(`agent`,r);for(let e of M)i.append(`attachments`,e);n=await fetch(`/api/chat`,{method:`POST`,body:i})}else n=await fetch(`/api/chat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:t,session_key:e,...r?{agent:r}:{}})});return n.ok?(D(``),ke([]),je(null),!0):(console.error(`[public-webchat] op=send-failed status=${n.status}`),!1)}M.some(e=>qe(e.type))&&(pe(!0),console.info(`[admin-ui] op=transcribe-indicator state=show`));let r=s&&!n,i;if(M.length>0){let a=new FormData;a.append(`text`,t);for(let e of M)a.append(`attachments`,e);n&&a.append(`session`,n),r&&a.append(`clearSignal`,`true`),i=await fetch(`/api/webchat/send?session_key=${encodeURIComponent(e)}`,{method:`POST`,body:a})}else i=await fetch(`/api/webchat/send?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({text:t,...n?{session:n}:{},...r?{clearSignal:!0}:{}})});if(i.ok)return je(null),ge(null),Kt(!1),Jt(null),l?.(),ve.current=!0,me({baselineSize:C.current?.sizeBytes??null,baselineTurns:Te.current,text:t,files:M}),D(``),ke([]),!0;i.status===409?console.error(`[admin-ui] webchat-send-refused reason=channel-conflict`):console.error(`[admin-ui] webchat-send-failed status=${i.status}`)}catch(e){console.error(`[admin-ui] webchat-send-failed error=${e instanceof Error?e.message:String(e)}`)}finally{ve.current||se(!1),M.some(e=>qe(e.type))&&console.info(`[admin-ui] op=transcribe-indicator state=clear`),pe(!1)}return!1},[E,re,e,M,n,d,h,w,l,s]);(0,$.useEffect)(()=>{if(!d||k.current||!w)return;let e=Qu(),t=`url`;if(!e)try{let n=sessionStorage.getItem(Zu);n&&n.trim()&&(e=n.trim().slice(0,2e3),t=`storage`)}catch{}if(!e){new URLSearchParams(window.location.search).has(`q`)&&Ju&&console.info(`[public-webchat] op=seed-skip reason=empty`),k.current=!0;return}if(Ju&&console.info(`[public-webchat] op=seed-detected source=${t} len=${e.length} head=${e.slice(0,40)}`),t===`storage`&&Ju&&console.info(`[public-webchat] op=seed-restored source=storage len=${e.length}`),E!==``){Ju&&console.info(`[public-webchat] op=seed-skip reason=composer-dirty`),k.current=!0;return}O.current=e,D(e)},[d,w]),(0,$.useEffect)(()=>{let e=O.current;if(!(!e||E!==e||!w||k.current)){k.current=!0,O.current=null;try{let e=new URL(window.location.href);e.searchParams.delete(`q`),window.history.replaceState({},``,e.pathname+e.search+e.hash)}catch{}try{sessionStorage.removeItem(Zu)}catch{}Ju&&console.info(`[public-webchat] op=seed-sent key=${w} len=${e.length}`),xt().then(e=>{e||console.error(`[public-webchat] op=seed-send-failed`)})}},[E,w,xt]);let St=(0,$.useCallback)(e=>{console.info(`[admin-ui] op=chip-tap id=${e.id} chars=${e.prompt.length}`),ee.current=e.prompt,D(e.prompt),A(e=>e+1)},[]);(0,$.useEffect)(()=>{let e=ee.current;!e||E!==e||(ee.current=null,xt().then(e=>{e||console.error(`[admin-ui] op=chip-send-failed`)}))},[te,E,xt]);let Ct=(0,$.useCallback)(async()=>{Wt(!0),ue(e=>e+1);let t=x?.sessionId??n??void 0;try{let n=await fetch(`/api/webchat/interrupt?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t?{session:t}:{})}),r=await n.json().catch(()=>({}));pd(n.status,r)===`dead-child`&&(Kt(!0),Wt(!1),Jt(`The agent stopped. Send a message to resume.`),console.log(`[admin-ui] op=stop-dead-child sessionId=${(t??``).slice(0,8)}`))}catch(e){console.error(`[admin-ui] webchat-stop-failed error=${e instanceof Error?e.message:String(e)}`)}finally{ue(e=>e-1)}},[e,x?.sessionId,n]),wt=(0,$.useCallback)(e=>{if(e.key===`Enter`&&!e.shiftKey&&!ye){e.preventDefault(),xt();return}if(e.key===`Enter`){let t=e.currentTarget,n=Ue(t.value,t.selectionStart,t.selectionEnd);n&&(e.preventDefault(),ze.current=n.caret,D(n.value));return}},[xt,ye]),Tt=(0,$.useMemo)(()=>{if(!j)return null;let e=x?.sizeBytes;return e!=null&&(j.baselineSize==null||e>j.baselineSize)?`pointer`:Ce>j.baselineTurns?`transcript`:null},[j,x?.sizeBytes,Ce]),Et=Tt!==null;(0,$.useEffect)(()=>{!j||!Tt||(console.info(`[admin-ui] op=send-confirmed via=${Tt} baselineSize=${j.baselineSize??`absent`} baselineTurns=${j.baselineTurns}`),ge(null),me(null),ve.current=!1,se(!1))},[j,Tt]),(0,$.useEffect)(()=>{if(!j)return;let e=setTimeout(()=>{D(j.text),ke(e=>[...j.files,...e].slice(0,5)),me(null),ve.current=!1,se(!1),ge(`Couldn't be delivered — press send to retry.`)},yd);return()=>clearTimeout(e)},[j]);let Dt=n?x?.channelBinding??null:null,Ot=(0,$.useRef)(!1);(0,$.useEffect)(()=>{!n||Ot.current||!x||(Ot.current=!0,console.warn(`[admin-ui] chat-session-target sessionId=${n} jsonl=${x.projectDir?`found`:`missing`} known=${x.known===!0}`))},[x,n]);let kt=(0,$.useRef)(!1);(0,$.useEffect)(()=>{n||kt.current||!x?.sessionId||(kt.current=!0,console.info(`[admin-ui] chat-session-resolve sessionId=${x.sessionId.slice(0,8)} source=canonical`))},[x,n]);let H=s?null:x,At=H?H.effectivePermissionMode??H.permissionMode??null:null,jt=H?.model??null,Mt=H?.activity===`busy`,Nt=(0,$.useRef)(!1);(0,$.useEffect)(()=>{if(!s||Nt.current||!x)return;Nt.current=!0;let e=x.sessionId?x.sessionId.slice(0,8):`none`;console.info(`[sub-account] op=post-switch-pointer switchId=${u?u.slice(0,8):`none`} source=${x.source??`unknown`} shown=${e}`)},[s,x,u]);let[Pt,Ft]=(0,$.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`maxy:whatsapp-reader:clean-view`)===`1`}catch{return!1}}),It=(0,$.useCallback)(()=>{Ft(e=>{let t=!e;try{window.localStorage.setItem(`maxy:whatsapp-reader:clean-view`,t?`1`:`0`)}catch{}return t})},[]),Lt=(0,$.useMemo)(()=>d?(e,t,n)=>qu(e,t,n,`public`):(e,t,n)=>qu(e,t,n,`admin`,r===`admin`?Pt:!0),[d,Pt,r]),Rt=(0,$.useMemo)(()=>!d&&j&&!Et?(0,Q.jsx)(Ku,{text:j.text,filenames:j.files.map(e=>e.name)}):null,[d,j,Et]),zt=(0,$.useMemo)(()=>{if(d)return null;let e=!!(H?.turnAborted||H?.deliveryFailure),t=Mt?(0,Q.jsx)(Ru,{activity:De,turnCount:Ce,wedged:e}):null;return!Rt&&!t?null:(0,Q.jsxs)(Q.Fragment,{children:[Rt,t]})},[d,Mt,De,Ce,Rt,H?.turnAborted,H?.deliveryFailure]),U=(0,$.useMemo)(()=>{try{return new URLSearchParams(window.location.search).get(`diag`)===`composer`}catch{return!1}},[]),Bt=(0,$.useRef)(null),Vt=(0,$.useRef)(0),Ht=(0,$.useCallback)((e,t,n)=>{let r=Bt.current;r&&console.info(`[diag:composer] keystroke #${r.seq} reconciled transcript — phase=${t} actualDuration=${n.toFixed(2)}ms latency=${(performance.now()-r.t0).toFixed(2)}ms`)},[]),[Ut,Wt]=(0,$.useState)(!1);(0,$.useEffect)(()=>{Mt||Wt(!1)},[Mt]);let[Gt,Kt]=(0,$.useState)(!1),[qt,Jt]=(0,$.useState)(null);(0,$.useEffect)(()=>{H?.turnAborted?Gt||(Kt(!0),Jt(`The agent stopped. Send a message to resume.`),console.log(`[admin-ui] op=phantom-turn-cleared sessionId=${(H.sessionId??``).slice(0,8)}`)):Mt&&(Gt||qt!==null)&&(Kt(!1),Jt(null))},[H?.turnAborted,H?.sessionId,Mt,Gt,qt]);let[Yt,Xt]=(0,$.useState)(!1),Zt=(0,$.useRef)(null);(0,$.useEffect)(()=>{if(!Yt)return;let e=e=>{Zt.current?.contains(e.target)||Xt(!1)},t=e=>{e.key===`Escape`&&Xt(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[Yt]);let[Qt,$t]=(0,$.useState)(()=>{try{return window.localStorage.getItem(`maxy:webchat:mic-device-id`)}catch{return null}}),[en,tn]=(0,$.useState)([]),[nn,rn]=(0,$.useState)(!1),an=(0,$.useRef)(null);(0,$.useEffect)(()=>{if(!nn)return;let e=e=>{an.current?.contains(e.target)||rn(!1)},t=e=>{e.key===`Escape`&&rn(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[nn]);let on=(0,$.useCallback)(async()=>{rn(e=>!e),tn(await oe())},[]),sn=(0,$.useCallback)((e,t)=>{$t(e);try{e?window.localStorage.setItem(`maxy:webchat:mic-device-id`,e):window.localStorage.removeItem(`maxy:webchat:mic-device-id`)}catch{}console.info(`[admin-ui] mic-device-selected`,t),rn(!1)},[]),cn=(0,$.useCallback)(async t=>{let n=x?.pendingPermissionPrompt;if(!(!n||!x?.sessionId))try{await fetch(`/api/webchat/permission-verdict?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sessionId:x.sessionId,request_id:n.requestId,behavior:t})})}catch(e){console.error(`[admin-ui] permission-verdict-failed error=${e instanceof Error?e.message:String(e)}`)}},[e,x?.sessionId,x?.pendingPermissionPrompt]),ln=(0,$.useRef)(!1);return(0,$.useEffect)(()=>{ln.current||x?.projectDir&&x.activity==null&&At==null&&jt==null&&(ln.current=!0,console.warn(`[admin-ui] composer-indicators-unavailable sessionId=${x.sessionId} (manager meta unreadable or pre-activity)`))},[x,At,jt]),(0,$.useEffect)(()=>{console.info(`[admin-ui] chat-render variant=${r} isPublic=${d} deliveredOnly=${p} model=${jt??`null`} audience=${d?`public`:`admin`}`)},[r,d,p,jt]),(0,Q.jsxs)(`div`,{className:`webchat-page`,children:[de?(0,Q.jsx)(`div`,{className:`interrupt-overlay`,role:`status`,"aria-live":`polite`,children:(0,Q.jsxs)(`div`,{className:`interrupt-modal`,children:[(0,Q.jsx)(c,{className:`spin interrupt-spinner`,size:28,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`interrupt-label`,children:`Interruption in progress…`})]})}):null,x?.projectDir&&!s?(()=>{let t=(0,Q.jsx)(ae,{resetKey:x.sessionId,sessionId:x.transcriptSessionId??x.sessionId,projectDir:x.projectDir,sessionKey:d?w??``:e,renderItems:Lt,clean:r===`admin`?Pt:void 0,onToggleClean:r===`admin`?It:void 0,forceDeliveredOnly:p,streamEndpoint:d?`/api/public-reader/stream`:`/api/whatsapp-reader/stream`,suppressDirectives:d,tail:zt,onTurnsChange:d?void 0:Ee,onActivityChange:d?void 0:Oe},x.sessionId);return U?(0,Q.jsx)($.Profiler,{id:`chat-transcript`,onRender:Ht,children:t}):t})():it&&!n&&at&&I.length===0&&x?.known===!1?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`webchat-conv-splash`,"data-testid":`conversations-splash`,children:[(0,Q.jsx)(`img`,{src:o,alt:``,className:`webchat-conv-splash-logo`}),(0,Q.jsxs)(`button`,{type:`button`,className:`webchat-conv-splash-new`,onClick:rt,disabled:nt,children:[nt?(0,Q.jsx)(c,{size:16,className:`spin`}):null,` New session`]})]}),Rt?(0,Q.jsx)(`div`,{className:`webchat-pending-standalone`,children:Rt}):null]}):x&&!d?!n||x.known?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xd,{userName:t,variant:r,onChip:St}),Rt?(0,Q.jsx)(`div`,{className:`webchat-pending-standalone`,children:Rt}):null]}):(0,Q.jsx)(`div`,{className:`webchat-greeting`,children:(0,Q.jsx)(`p`,{className:`webchat-greeting-none`,children:`No transcript found for this session.`})}):null,i&&it?(0,Q.jsx)(`div`,{className:`webchat-conv-overlay`,children:(0,Q.jsx)(_d,{sessions:s?I.map(e=>({...e,active:!1})):I,onOpen:st,onRename:ct,onArchive:lt,onDelete:ut,onEnd:dt,onNew:rt,onBack:()=>a?.(),onCopyId:ft})}):null,(0,Q.jsx)(fd,{deliveryFailure:!!H?.deliveryFailure,permPrompt:H?.pendingPermissionPrompt??null,onVerdict:cn,isDragOver:Me,onDragOver:e=>{e.preventDefault(),Ne(!0)},onDragLeave:()=>Ne(!1),onDrop:e=>{e.preventDefault(),Ne(!1),pt([...e.dataTransfer.files])},fileInputRef:Pe,acceptMime:le,onFileInputChange:e=>{e.target.files&&pt([...e.target.files]),e.target.value=``},showResizeHandle:!gt,onResizePointerDown:Ge,onResizeKeyDown:Ke,pendingFiles:M,thumbUrls:mt,onRemoveFile:e=>ke(t=>t.filter((t,n)=>n!==e)),attachError:Ae,sendError:he,transcribing:fe,voice:ht,isVoiceActive:gt,onVoiceSend:_t,text:E,onTextareaChange:e=>{if(U){let e=++Vt.current;Bt.current={seq:e,t0:performance.now()},requestAnimationFrame(()=>{Bt.current?.seq===e&&(Bt.current=null)})}D(e.target.value)},textareaRef:Re,textareaHeight:Ie??Je??44,textareaDisabled:Dt!==null||re||j!==null,onKeyDown:wt,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=We(t,Date.now());n.length>0&&pt(n)},onSend:xt,sendDisabled:re||E.trim().length===0&&M.length===0||Dt!==null,turnActive:!d&&Mt&&!Gt,onStop:Ct,stopping:Ut,deadChildNotice:qt,conflictHint:Dt,showNewSession:!d,newSessionRef:F,newSessionOpen:Xe,onToggleNewSession:()=>Ze(e=>!e),newSessionDisabled:Dt!==null,newModel:Qe,onPickModel:$e,newEffort:et,onPickEffort:tt,onNewSession:rt,newSessionPending:nt,onAttachClick:()=>Pe.current?.click(),attachDisabled:Dt!==null,micMenuRef:an,onMicStart:()=>ht.start(Qt??void 0),micStartDisabled:gt||Dt!==null,onOpenMicMenu:on,micMenuOpen:nn,micDevices:en,micDeviceId:Qt,onChooseMic:sn,showCleanToggle:r===`admin`,cleanView:Pt,onToggleClean:It,showControlsRight:!d,sessionId:H?.sessionId??null,mode:At,model:jt,effort:H?.effort??null,contextUsage:H?.contextUsage??null,paramsMenuRef:Zt,paramsMenuOpen:Yt,onToggleParamsMenu:()=>Xt(e=>!e)}),(0,Q.jsx)(_e,{open:_,onConnect:()=>window.location.assign(`/?connect=claude`),onClose:()=>y(!1)})]})}var Cd=`maxy-subaccount-switch-clear`;function wd(e){if(e)return!1;try{return sessionStorage.getItem(Cd)!=null}catch{return!1}}function Td(e){if(e)return null;try{return sessionStorage.getItem(Cd)}catch{return null}}function Ed(e){if(e)return!1;let t=null;try{t=sessionStorage.getItem(Cd),t&&sessionStorage.removeItem(Cd)}catch{}return console.info(`[sub-account] op=post-switch-chat switchId=${t??`none`} signal=${t!=null} resume=${t==null}`),t!=null}function Dd({variant:e=`admin`,forceCanonicalSession:t=!1}){let[n,r]=(0,$.useState)(null),[i]=(0,$.useState)(()=>md(t,window.location.search)),[a,o]=(0,$.useState)(()=>wd(t)),[s]=(0,$.useState)(()=>Td(t)),l=(0,$.useRef)(!1);(0,$.useEffect)(()=>{l.current||(l.current=!0,Ed(t))},[t]);let[u,d]=(0,$.useState)(!1),[f,m]=(0,$.useState)(!1),[h,g]=(0,$.useState)(void 0),[_,v]=(0,$.useState)(null),[y,b]=(0,$.useState)(void 0),[x,S]=(0,$.useState)(null),[C,w]=(0,$.useState)(null);(0,$.useEffect)(()=>{let e=!1,t=null;try{t=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!t){r(null),d(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(t)}`).then(async n=>{if(!e){if(n.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(n.ok)try{let e=await n.json();typeof e.businessName==`string`&&g(e.businessName),e.sessionId!==void 0&&v(e.sessionId??null),w(e.role??null),b(e.userName===void 0?null:e.userName),S(e.avatar??null)}catch{}r(t),d(!0)}}).catch(()=>{e||(r(t),d(!0))}),()=>{e=!0}},[]);let T=(0,$.useRef)(!1);(0,$.useEffect)(()=>{e!==`operator`||!u||!n||T.current||(T.current=!0,console.info(`[operator-ui] op=mount surface=chat sessionId=${(_??``).slice(0,8)}`))},[e,u,n,_]);let E=(0,$.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[D,O]=(0,$.useState)(!1),k=(0,$.useCallback)(async()=>{O(!0);try{let e=await fe();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{O(!1)}},[]);return u?n?(0,Q.jsx)(p,{cacheKey:n,surface:`chat`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=chat`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,Q.jsx)(Ce,{cacheKey:n,businessName:h,variant:e,sessionId:_,onLogout:E,onDisconnect:k,disconnecting:D,userName:y,userAvatar:x,role:C,onOpenConversations:()=>m(!0),children:(0,Q.jsx)(Sd,{cacheKey:n,userName:y??null,targetSessionId:i,variant:e,conversationsOpen:f,onCloseConversations:()=>m(!1),cleared:a,onFirstSend:()=>o(!1),switchId:s})})}):(0,Q.jsx)(`div`,{className:`data-page`,children:(0,Q.jsxs)(`div`,{className:`data-empty`,children:[(0,Q.jsx)(`p`,{children:`You are not signed in.`}),(0,Q.jsxs)(`p`,{children:[`Open the `,(0,Q.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,Q.jsx)(`div`,{className:`data-page`,children:(0,Q.jsxs)(`div`,{className:`data-loading`,children:[(0,Q.jsx)(c,{size:18,className:`spin`}),` Loading…`]})})}function Od(){return(0,Q.jsx)(Dd,{})}export{Xu as a,Ju as c,Zu as i,Od as n,Qu as o,Sd as r,Yu as s,Dd as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CCr-iYLO.js";import{K as t,V as n,W as r}from"./useSubAccountSwitcher-iQGqNJhI.js";import"./useVoiceRecorder-v--TIxaM.js";import{x as i}from"./AdminShell-Gq8DU_ig.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-DomkejEB.js";import"./useCopyFeedback-DN1WA5vU.js";var d=r(),f=e(t(),1),p=n();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:r}){let[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(null);async function d(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:r.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:d,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(i,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}function h(){let[e,t]=(0,f.useState)(null),[n,r]=(0,f.useState)(null),[i,l]=(0,f.useState)(`loading`),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(null),[g,_]=(0,f.useState)(null),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(null),S=(0,f.useMemo)(()=>a(),[]),C=(0,f.useRef)(S||``),w=(0,f.useRef)(null),T=(0,f.useRef)(null),E=(0,f.useRef)(!1),D=(0,f.useRef)(null),[O,k]=(0,f.useState)(`request-link`),[A,j]=(0,f.useState)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(N.current=e)}catch{}},[]),(0,f.useEffect)(()=>{try{let e=c();e&&(sessionStorage.setItem(s,e),o&&console.info(`[public-webchat] op=seed-persisted len=${e.length} head=${e.slice(0,40)}`))}catch{}},[]);let P=(0,f.useCallback)(e=>{w.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}l(`chat`)},[]),F=(0,f.useCallback)(()=>{w.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),l(`auth-required`),k(`request-link`)},[]),I=(0,f.useCallback)(async e=>{k(`verifying`);try{let t=C.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&j({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return k(`verify-failed`),!1}catch{return k(`verify-failed`),!1}},[]),L=(0,f.useCallback)(async()=>{if(w.current)return w.current;if(T.current)return T.current;let e=(async()=>{try{let e=N.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:u(),...S?{agent:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return o&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(C.current=i.agent_id),p(i.displayName||``),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await I(e)&&window.location.reload():k(`request-link`),null}w.current=i.session_key,t(i.session_key),i.displayName&&p(i.displayName),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`chat`),i.resumed&&i.messages&&(E.current=!0,D.current=i.messages);try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return o&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{T.current=null}})();return T.current=e,e},[S,I]);return{sessionId:e,cacheKeyRef:w,sessionError:n,pageState:i,setPageState:l,agentDisplayName:d,agentImage:m,agentImageShape:g,showAgentName:v,agentSlug:S,branding:b,resolvedSlugRef:C,ensureSession:L,startNewSession:(0,f.useCallback)(async()=>{w.current=null,T.current=null,N.current=null,E.current=!1,D.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await L()},[L]),enterChat:P,enterGate:F,resumedRef:E,resumeMessagesRef:D,gateState:O,setGateState:k,grantInfo:A,setGrantInfo:j,gateCacheKeyRef:M}}function g(){let{ensureSession:e,pageState:t,gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}=h();return(0,f.useEffect)(()=>{e()},[e]),t===`loading`?(0,p.jsx)(`div`,{className:`public-loading`,children:`Loading…`}):t===`auth-required`?(0,p.jsx)(m,{gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}):(0,p.jsx)(`div`,{className:`public-shell`,children:(0,p.jsx)(l,{cacheKey:``,variant:`public`})})}(0,d.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(g,{}));
1
+ import{o as e}from"./chunk-CCr-iYLO.js";import{K as t,V as n,W as r}from"./useSubAccountSwitcher-iQGqNJhI.js";import"./useVoiceRecorder-v--TIxaM.js";import{x as i}from"./AdminShell-Gq8DU_ig.js";import{a,c as o,i as s,o as c,r as l,s as u}from"./page-Bs24tO-C.js";import"./useCopyFeedback-DN1WA5vU.js";var d=r(),f=e(t(),1),p=n();function m({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:r}){let[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(null);async function d(e){e.preventDefault();let n=a.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:r.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,p.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Verifying your link…`}),(0,p.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`That link did not work`}),(0,p.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,p.jsxs)(`form`,{className:`access-gate-form`,onSubmit:d,children:[(0,p.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,p.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,p.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,p.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:a,onChange:e=>o(e.target.value),disabled:s}),l&&(0,p.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,p.jsx)(i,{type:`submit`,disabled:s||!a.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,p.jsxs)(`div`,{className:`access-gate-message`,children:[(0,p.jsx)(`h2`,{children:`Check your email`}),(0,p.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,p.jsx)(i,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}function h(){let[e,t]=(0,f.useState)(null),[n,r]=(0,f.useState)(null),[i,l]=(0,f.useState)(`loading`),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(null),[g,_]=(0,f.useState)(null),[v,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(null),S=(0,f.useMemo)(()=>a(),[]),C=(0,f.useRef)(S||``),w=(0,f.useRef)(null),T=(0,f.useRef)(null),E=(0,f.useRef)(!1),D=(0,f.useRef)(null),[O,k]=(0,f.useState)(`request-link`),[A,j]=(0,f.useState)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(null);(0,f.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(N.current=e)}catch{}},[]),(0,f.useEffect)(()=>{try{let e=c();e&&(sessionStorage.setItem(s,e),o&&console.info(`[public-webchat] op=seed-persisted len=${e.length} head=${e.slice(0,40)}`))}catch{}},[]);let P=(0,f.useCallback)(e=>{w.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}l(`chat`)},[]),F=(0,f.useCallback)(()=>{w.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),l(`auth-required`),k(`request-link`)},[]),I=(0,f.useCallback)(async e=>{k(`verifying`);try{let t=C.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&j({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return k(`verify-failed`),!1}catch{return k(`verify-failed`),!1}},[]),L=(0,f.useCallback)(async()=>{if(w.current)return w.current;if(T.current)return T.current;let e=(async()=>{try{let e=N.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:u(),...S?{agent:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return o&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(C.current=i.agent_id),p(i.displayName||``),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await I(e)&&window.location.reload():k(`request-link`),null}w.current=i.session_key,t(i.session_key),i.displayName&&p(i.displayName),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),l(`chat`),i.resumed&&i.messages&&(E.current=!0,D.current=i.messages);try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return o&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{T.current=null}})();return T.current=e,e},[S,I]);return{sessionId:e,cacheKeyRef:w,sessionError:n,pageState:i,setPageState:l,agentDisplayName:d,agentImage:m,agentImageShape:g,showAgentName:v,agentSlug:S,branding:b,resolvedSlugRef:C,ensureSession:L,startNewSession:(0,f.useCallback)(async()=>{w.current=null,T.current=null,N.current=null,E.current=!1,D.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await L()},[L]),enterChat:P,enterGate:F,resumedRef:E,resumeMessagesRef:D,gateState:O,setGateState:k,grantInfo:A,setGrantInfo:j,gateCacheKeyRef:M}}function g(){let{ensureSession:e,pageState:t,gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}=h();return(0,f.useEffect)(()=>{e()},[e]),t===`loading`?(0,p.jsx)(`div`,{className:`public-loading`,children:`Loading…`}):t===`auth-required`?(0,p.jsx)(m,{gateState:n,setGateState:r,grantInfo:i,resolvedSlugRef:a}):(0,p.jsx)(`div`,{className:`public-shell`,children:(0,p.jsx)(l,{cacheKey:``,variant:`public`})})}(0,d.createRoot)(document.getElementById(`root`)).render((0,p.jsx)(g,{}));
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-CCr-iYLO.js";import{D as t,K as n,T as r,U as i,V as a,W as o,_ as s,g as c,p as l}from"./useSubAccountSwitcher-iQGqNJhI.js";import{C as u,f as d,t as f}from"./AdminShell-Gq8DU_ig.js";import{t as p}from"./file-text-BpLcZKld.js";var m=o(),h=e(n(),1),g=a();function _({summary:e,adminFetch:n,onClose:i,onDeleted:a}){let[o,l]=(0,h.useState)(null),[u,f]=(0,h.useState)(!0),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(!1),[b,x]=(0,h.useState)(!1);(0,h.useEffect)(()=>{let t=!1;return f(!0),_(null),n(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);l((await e.json()).skill)}}).catch(e=>{t||_(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||f(!1)}),()=>{t=!0}},[n,e.plugin,e.skill]),(0,h.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!b&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,i]);let S=(0,h.useCallback)(async()=>{x(!0),_(null);try{let t=await n(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}a(e)}catch(e){_(e instanceof Error?e.message:`Delete failed`),x(!1),y(!1)}},[n,e,a]);return(0,g.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{b||i()},children:(0,g.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Skill detail`,onClick:e=>e.stopPropagation(),children:[(0,g.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,g.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,g.jsx)(d,{size:13}),` Skill`]}),(0,g.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:b,children:(0,g.jsx)(c,{size:16})})]}),(0,g.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,g.jsx)(`div`,{className:`cal-modal-title`,children:e.skill}),(0,g.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,g.jsx)(p,{size:14}),(0,g.jsx)(`span`,{children:e.plugin})]}),u&&(0,g.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,g.jsx)(r,{size:14,className:`spin`}),(0,g.jsx)(`span`,{children:`Loading…`})]}),o&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,g.jsx)(`span`,{children:o.frontmatter.description||`No description.`})}),o.frontmatter.publicEmbed&&(0,g.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,g.jsx)(t,{size:14}),(0,g.jsx)(`span`,{children:`Public embed`})]}),(0,g.jsx)(`pre`,{className:`skill-body`,children:o.body.trim()||`No body content.`}),o.references.length>0&&(0,g.jsxs)(`div`,{className:`skill-refs`,children:[(0,g.jsx)(`span`,{className:`skill-refs-label`,children:`References`}),o.references.map(e=>(0,g.jsxs)(`span`,{className:`skill-ref`,children:[(0,g.jsx)(p,{size:13}),` `,e]},e))]})]})]}),m&&(0,g.jsx)(`div`,{className:`cal-modal-error`,children:m}),(0,g.jsxs)(`div`,{className:`cal-modal-actions`,children:[!v&&(0,g.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>y(!0),disabled:b||u,children:[(0,g.jsx)(s,{size:14}),` Delete`]}),v&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this skill?`}),(0,g.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:S,disabled:b,children:[b?(0,g.jsx)(r,{size:14,className:`spin`}):(0,g.jsx)(s,{size:14}),` Delete`]}),(0,g.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>y(!1),disabled:b,children:`Cancel`})]})]})]})})}var v=`maxy-admin-session-key`;function y(){let[e,t]=(0,h.useState)(null),[n,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[s,c]=(0,h.useState)(null),[d,p]=(0,h.useState)(void 0),[m,_]=(0,h.useState)(null),[y,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(v)}catch{}if(!n){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(v)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),x(e.role??null),p(e.userName===void 0?null:e.userName),_(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(v)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await u();if(e){try{sessionStorage.removeItem(v)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,g.jsx)(l,{cacheKey:e,surface:`skills`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=skills`);try{sessionStorage.removeItem(v)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:a,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:d,userAvatar:m,role:y,children:(0,g.jsx)(b,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`cal-page`,children:(0,g.jsxs)(`div`,{className:`cal-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(`div`,{className:`cal-page`,children:(0,g.jsxs)(`div`,{className:`cal-loading`,children:[(0,g.jsx)(r,{size:18,className:`spin`}),` Loading…`]})})}function b({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=i({initialCacheKey:e,surface:`skills`}),[a,o]=(0,h.useState)([]),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),[f,m]=(0,h.useState)(null),v=(0,h.useCallback)(()=>{let e=!1;return c(!0),u(null),t(`/api/admin/skills`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();o(Array.isArray(n.skills)?n.skills:[])}).catch(t=>{e||(u(t instanceof Error?t.message:`Failed to load`),o([]))}).finally(()=>{e||c(!1)}),()=>{e=!0}},[t]);(0,h.useEffect)(()=>v(),[v,n]);let y=(0,h.useCallback)(e=>{o(t=>t.filter(t=>!(t.plugin===e.plugin&&t.skill===e.skill))),m(null),v()},[v]);return(0,g.jsxs)(`div`,{className:`cal-page`,children:[(0,g.jsx)(`header`,{className:`cal-header`,children:(0,g.jsxs)(`div`,{className:`cal-nav`,children:[(0,g.jsxs)(`span`,{className:`cal-range-label`,children:[(0,g.jsx)(d,{size:16}),` Skills`]}),s&&(0,g.jsx)(r,{size:16,className:`spin`})]})}),(0,g.jsxs)(`div`,{className:`cal-body`,children:[l&&(0,g.jsxs)(`div`,{className:`cal-error`,children:[`Could not load skills: `,l]}),!l&&!s&&a.length===0&&(0,g.jsx)(`div`,{className:`cal-empty`,children:(0,g.jsx)(`p`,{children:`No skills yet. Ask in chat to create one.`})}),a.length>0&&(0,g.jsx)(`div`,{className:`routine-list`,children:a.map(e=>(0,g.jsxs)(`button`,{type:`button`,className:`routine-card`,onClick:()=>m(e),children:[(0,g.jsx)(`span`,{className:`routine-card-title`,children:e.skill}),(0,g.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,g.jsx)(p,{size:13}),` `,e.plugin]}),(0,g.jsx)(`span`,{className:`skill-card-desc`,children:e.description||`No description.`}),(0,g.jsx)(`span`,{className:`routine-card-meta`,children:e.refCount===0?`No references`:`${e.refCount} reference${e.refCount===1?``:`s`}`})]},`${e.plugin}/${e.skill}`))})]}),f&&(0,g.jsx)(_,{summary:f,adminFetch:t,onClose:()=>m(null),onDeleted:y})]})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Calendar — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/calendar-D0qIvLUR.js"></script>
8
+ <script type="module" crossorigin src="/assets/calendar-B8ujkn_K.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-CCr-iYLO.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-iQGqNJhI.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-Gq8DU_ig.js">
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Chat — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/chat-geSkx0j2.js"></script>
8
+ <script type="module" crossorigin src="/assets/chat-lQXd6gsM.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-CCr-iYLO.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-iQGqNJhI.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-Gq8DU_ig.js">
@@ -19,7 +19,7 @@
19
19
  <link rel="modulepreload" crossorigin href="/assets/file-text-BpLcZKld.js">
20
20
  <link rel="modulepreload" crossorigin href="/assets/rotate-ccw-D9qOBLig.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/wrench-CKhz8KnQ.js">
22
- <link rel="modulepreload" crossorigin href="/assets/page-DomkejEB.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/page-Bs24tO-C.js">
23
23
  <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-fvBunpOC.css">
24
24
  <link rel="stylesheet" href="/brand-defaults.css">
25
25
  </head>
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Operator — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/operator-DejfJlvi.js"></script>
8
+ <script type="module" crossorigin src="/assets/operator-Bf3hP3qo.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-CCr-iYLO.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-iQGqNJhI.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-Gq8DU_ig.js">
@@ -20,7 +20,7 @@
20
20
  <link rel="modulepreload" crossorigin href="/assets/file-text-BpLcZKld.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/rotate-ccw-D9qOBLig.js">
22
22
  <link rel="modulepreload" crossorigin href="/assets/wrench-CKhz8KnQ.js">
23
- <link rel="modulepreload" crossorigin href="/assets/page-DomkejEB.js">
23
+ <link rel="modulepreload" crossorigin href="/assets/page-Bs24tO-C.js">
24
24
  <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-fvBunpOC.css">
25
25
  <link rel="stylesheet" crossorigin href="/assets/AdminLoginScreens-CWMpccrR.css">
26
26
  <link rel="stylesheet" href="/brand-defaults.css">
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/public-Be_Galv6.js"></script>
8
+ <script type="module" crossorigin src="/assets/public-DZHPsyKX.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-CCr-iYLO.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-iQGqNJhI.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-Gq8DU_ig.js">
@@ -19,7 +19,7 @@
19
19
  <link rel="modulepreload" crossorigin href="/assets/file-text-BpLcZKld.js">
20
20
  <link rel="modulepreload" crossorigin href="/assets/rotate-ccw-D9qOBLig.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/wrench-CKhz8KnQ.js">
22
- <link rel="modulepreload" crossorigin href="/assets/page-DomkejEB.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/page-Bs24tO-C.js">
23
23
  <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-fvBunpOC.css">
24
24
  <link rel="stylesheet" href="/brand-defaults.css">
25
25
  </head>
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Skills — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/skills-D9nWOqoz.js"></script>
8
+ <script type="module" crossorigin src="/assets/skills-y-h0P9rC.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-CCr-iYLO.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-iQGqNJhI.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/AdminShell-Gq8DU_ig.js">
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-CCr-iYLO.js";import{D as t,K as n,T as r,U as i,V as a,W as o,_ as s,g as c,p as l}from"./useSubAccountSwitcher-iQGqNJhI.js";import{C as u,f as d,t as f}from"./AdminShell-Gq8DU_ig.js";import{t as p}from"./file-text-BpLcZKld.js";var m=o(),h=e(n(),1),g=a();function _({summary:e,adminFetch:n,onClose:i,onDeleted:a}){let[o,l]=(0,h.useState)(null),[u,f]=(0,h.useState)(!0),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(!1),[b,x]=(0,h.useState)(!1);(0,h.useEffect)(()=>{let t=!1;return f(!0),_(null),n(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);l((await e.json()).skill)}}).catch(e=>{t||_(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||f(!1)}),()=>{t=!0}},[n,e.plugin,e.skill]),(0,h.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!b&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b,i]);let S=(0,h.useCallback)(async()=>{x(!0),_(null);try{let t=await n(`/api/admin/skills/${encodeURIComponent(e.plugin)}/${encodeURIComponent(e.skill)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}a(e)}catch(e){_(e instanceof Error?e.message:`Delete failed`),x(!1),y(!1)}},[n,e,a]);return(0,g.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{b||i()},children:(0,g.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Skill detail`,onClick:e=>e.stopPropagation(),children:[(0,g.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,g.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,g.jsx)(d,{size:13}),` Skill`]}),(0,g.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:i,"aria-label":`Close`,autoFocus:!0,disabled:b,children:(0,g.jsx)(c,{size:16})})]}),(0,g.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,g.jsx)(`div`,{className:`cal-modal-title`,children:e.skill}),(0,g.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,g.jsx)(p,{size:14}),(0,g.jsx)(`span`,{children:e.plugin})]}),u&&(0,g.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,g.jsx)(r,{size:14,className:`spin`}),(0,g.jsx)(`span`,{children:`Loading…`})]}),o&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,g.jsx)(`span`,{children:o.frontmatter.description||`No description.`})}),o.frontmatter.publicEmbed&&(0,g.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,g.jsx)(t,{size:14}),(0,g.jsx)(`span`,{children:`Public embed`})]}),(0,g.jsx)(`pre`,{className:`skill-body`,children:o.body.trim()||`No body content.`}),o.references.length>0&&(0,g.jsxs)(`div`,{className:`skill-refs`,children:[(0,g.jsx)(`span`,{className:`skill-refs-label`,children:`References`}),o.references.map(e=>(0,g.jsxs)(`span`,{className:`skill-ref`,children:[(0,g.jsx)(p,{size:13}),` `,e]},e))]})]})]}),m&&(0,g.jsx)(`div`,{className:`cal-modal-error`,children:m}),(0,g.jsxs)(`div`,{className:`cal-modal-actions`,children:[!v&&(0,g.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>y(!0),disabled:b||u,children:[(0,g.jsx)(s,{size:14}),` Delete`]}),v&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this skill?`}),(0,g.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:S,disabled:b,children:[b?(0,g.jsx)(r,{size:14,className:`spin`}):(0,g.jsx)(s,{size:14}),` Delete`]}),(0,g.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>y(!1),disabled:b,children:`Cancel`})]})]})]})})}var v=`maxy-admin-session-key`;function y(){let[e,t]=(0,h.useState)(null),[n,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[s,c]=(0,h.useState)(null),[d,p]=(0,h.useState)(void 0),[m,_]=(0,h.useState)(null),[y,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(v)}catch{}if(!n){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(v)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),x(e.role??null),p(e.userName===void 0?null:e.userName),_(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(v)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await u();if(e){try{sessionStorage.removeItem(v)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,g.jsx)(l,{cacheKey:e,surface:`skills`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=skills`);try{sessionStorage.removeItem(v)}catch{}window.location.href=`/`},children:(0,g.jsx)(f,{cacheKey:e,businessName:a,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:d,userAvatar:m,role:y,children:(0,g.jsx)(b,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`cal-page`,children:(0,g.jsxs)(`div`,{className:`cal-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(`div`,{className:`cal-page`,children:(0,g.jsxs)(`div`,{className:`cal-loading`,children:[(0,g.jsx)(r,{size:18,className:`spin`}),` Loading…`]})})}function b({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=i({initialCacheKey:e,surface:`skills`}),[a,o]=(0,h.useState)([]),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(null),[f,m]=(0,h.useState)(null),v=(0,h.useCallback)(()=>{let e=!1;return c(!0),u(null),t(`/api/admin/skills`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();o(Array.isArray(n.skills)?n.skills:[])}).catch(t=>{e||(u(t instanceof Error?t.message:`Failed to load`),o([]))}).finally(()=>{e||c(!1)}),()=>{e=!0}},[t]);(0,h.useEffect)(()=>v(),[v,n]);let y=(0,h.useCallback)(e=>{o(t=>t.filter(t=>!(t.plugin===e.plugin&&t.skill===e.skill))),m(null),v()},[v]);return(0,g.jsxs)(`div`,{className:`cal-page`,children:[(0,g.jsx)(`header`,{className:`cal-header`,children:(0,g.jsxs)(`div`,{className:`cal-nav`,children:[(0,g.jsxs)(`span`,{className:`cal-range-label`,children:[(0,g.jsx)(d,{size:16}),` Skills`]}),s&&(0,g.jsx)(r,{size:16,className:`spin`})]})}),(0,g.jsxs)(`div`,{className:`cal-body`,children:[l&&(0,g.jsxs)(`div`,{className:`cal-error`,children:[`Could not load skills: `,l]}),!l&&!s&&a.length===0&&(0,g.jsx)(`div`,{className:`cal-empty`,children:(0,g.jsx)(`p`,{children:`No skills yet. Ask in chat to create one.`})}),a.length>0&&(0,g.jsx)(`div`,{className:`routine-list`,children:a.map(e=>(0,g.jsxs)(`button`,{type:`button`,className:`routine-card`,onClick:()=>m(e),children:[(0,g.jsx)(`span`,{className:`routine-card-title`,children:e.skill}),(0,g.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,g.jsx)(p,{size:13}),` `,e.plugin]}),(0,g.jsx)(`span`,{className:`skill-card-desc`,children:e.description||`No description.`}),(0,g.jsx)(`span`,{className:`routine-card-meta`,children:e.refCount===0?`No references`:`${e.refCount} reference${e.refCount===1?``:`s`}`})]},`${e.plugin}/${e.skill}`))})]}),f&&(0,g.jsx)(_,{summary:f,adminFetch:t,onClose:()=>m(null),onDeleted:y})]})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));