fix(office-ui): native progress parity, ui_state lock hardening, approval-card idempotency

Native agent progress panel (company mode):
- ws_handler: filter runtime bookkeeping noise (turn/status/member_inbox_updated),
  keep tool_completed as tool_call, thinking summary previews content,
  preserve raw thinking_delta fragments (no strip; skip whitespace-only)
- frontend progressLog: summarize thinking by content preview; merge thinking
  by detail only so the 'Thinking' label never splices into text
- AgentProgressBlock: add bottom "Show more (N earlier steps)" toggle

ui_state.db "database is locked" hardening:
- ws_handler: isolate engine progress/kanban/runtime-event callbacks so UI
  persistence failures never crash work items
- chat_store: busy_timeout, _retry_locked backoff, idempotent insert_message
  (INSERT OR REPLACE), create_channel read-before-write to stop poll writes
- server: flock single-instance guard for `opc ui` per OPC home

Approval card duplicate-click bug:
- EscalationPanel: disable buttons on click with Submitting state and 30s
  reconnect fallback
- ws_handler: stale-escalation branch checks real card status (new
  chat_store.get_checkpoint_message); already-resolved cards get an accurate
  "already handled (decision: X)" reply without being re-marked stale;
  dedup identical helper messages within 120s to stop reply spam

Company mode prompt:
- add soft guidance that the runtime monitors state and re-activates roles,
  so leaders need not poll work items after delegation/review

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
LZH-YS1998andClaude Fable 5 committed 2026-07-07 16:18:01 +08:00
1 parent ee79331d48
commit 12817a4e60
12 files changed
+472 -113

No files matched your search

@@ -40,6 +40,7 @@ _MULTI_TEAM_ORG_GUIDELINES = """
- The WorkItem is the collaboration source of truth. Use WorkItem IDs for collaboration; never use runtime Task IDs as WorkItem IDs. - The WorkItem is the collaboration source of truth. Use WorkItem IDs for collaboration; never use runtime Task IDs as WorkItem IDs.
- `workspace_root` and `comms_workspace_root` are guaranteed. `output_root` may be blank; if needed, choose a suitable subfolder under `workspace_root` and communicate it in handoffs or delegation briefs. - `workspace_root` and `comms_workspace_root` are guaranteed. `output_root` may be blank; if needed, choose a suitable subfolder under `workspace_root` and communicate it in handoffs or delegation briefs.
- Kanban state is advanced by the runtime from completion reports and review verdicts. Do not manually flip board states. - Kanban state is advanced by the runtime from completion reports and review verdicts. Do not manually flip board states.
- There is no need to poll work items for progress: the runtime watches state changes and re-activates whichever roles need to act once delegated or dependent work completes. So after you have confirmed that your delegation succeeded or that your review verdict advanced the work, end your current run if nothing else requires your own work — the system monitors on your behalf.
- Use mailbox tools only for coordination, questions, blockers, or handoffs. - Use mailbox tools only for coordination, questions, blockers, or handoffs.
- Cross-team collaboration is request-based; only direct managers delegate executable work. - Cross-team collaboration is request-based; only direct managers delegate executable work.
- If you are the root final decider, only your finished turn is the authoritative owner-facing result. - If you are the root final decider, only your finished turn is the authoritative owner-facing result.
+109 -11
View File
@@ -6,16 +6,27 @@ Channel/message format uses snake_case to match what collabSync.ts expects.
from __future__ import annotations from __future__ import annotations
import asyncio
import json import json
import re import re
import sqlite3 import sqlite3
import time import time
import uuid import uuid
from typing import Any from typing import Any, Awaitable, Callable
import aiosqlite import aiosqlite
from opc.layer3_agent.adapters.codex_adapter import CodexAdapter from opc.layer3_agent.adapters.codex_adapter import CodexAdapter
_LOCKED_ERROR_MARKERS = ("database is locked", "database table is locked")
_WRITE_RETRY_ATTEMPTS = 3
_WRITE_RETRY_BASE_DELAY_SECONDS = 0.25
def _is_locked_error(exc: BaseException) -> bool:
return isinstance(exc, sqlite3.OperationalError) and any(
marker in str(exc).lower() for marker in _LOCKED_ERROR_MARKERS
)
class ChatStore: class ChatStore:
"""Chat channels + messages in ui_state.db. """Chat channels + messages in ui_state.db.
@@ -319,6 +330,28 @@ class ChatStore:
"metadata": metadata, "metadata": metadata,
} }
async def _retry_locked(self, operation: Callable[[], Awaitable[Any]]) -> Any:
"""Run a write operation, retrying briefly on transient sqlite lock errors.
Another process sharing ui_state.db (a second server, the CLI) can hold
the write lock past busy_timeout; a short backoff usually clears it.
"""
last_error: BaseException | None = None
for attempt in range(_WRITE_RETRY_ATTEMPTS):
try:
return await operation()
except sqlite3.OperationalError as exc:
if not _is_locked_error(exc):
raise
last_error = exc
try:
await self._db.rollback()
except Exception:
pass
await asyncio.sleep(_WRITE_RETRY_BASE_DELAY_SECONDS * (2 ** attempt))
assert last_error is not None
raise last_error
async def initialize(self) -> None: async def initialize(self) -> None:
"""Create tables if not exist.""" """Create tables if not exist."""
await self._db.execute(""" await self._db.execute("""
@@ -488,18 +521,13 @@ class ChatStore:
now = time.time() now = time.time()
parts = participants or [] parts = participants or []
cursor = await self._db.execute( cursor = await self._db.execute(
"SELECT created_at FROM channels WHERE channel_id = ? AND project_id = ?", "SELECT type, name, office_id, participants, created_at FROM channels "
"WHERE channel_id = ? AND project_id = ?",
(cid, project_id), (cid, project_id),
) )
existing = await cursor.fetchone() existing = await cursor.fetchone()
created_at = float(existing[0]) if existing and existing[0] is not None else now created_at = float(existing[4]) if existing and existing[4] is not None else now
await self._db.execute( channel = {
"INSERT OR REPLACE INTO channels (channel_id, type, name, office_id, participants, created_at, project_id) "
"VALUES (?, ?, ?, ?, ?, ?, ?)",
(cid, channel_type, name, office_id, json.dumps(parts), created_at, project_id),
)
await self._db.commit()
return {
"channel_id": cid, "channel_id": cid,
"type": channel_type, "type": channel_type,
"name": name, "name": name,
@@ -508,6 +536,33 @@ class ChatStore:
"created_at": created_at, "created_at": created_at,
"project_id": project_id, "project_id": project_id,
} }
if existing is not None:
# Callers (e.g. session_detail polling) invoke this on every
# request; skip the write when nothing changed so a read-only
# view does not generate a constant write load on ui_state.db.
try:
existing_parts = json.loads(existing[3]) if existing[3] else []
except (json.JSONDecodeError, TypeError):
existing_parts = None
unchanged = (
str(existing[0] or "") == channel_type
and str(existing[1] or "") == name
and (existing[2] or None) == (office_id or None)
and existing_parts == parts
)
if unchanged:
return channel
async def _write() -> None:
await self._db.execute(
"INSERT OR REPLACE INTO channels (channel_id, type, name, office_id, participants, created_at, project_id) "
"VALUES (?, ?, ?, ?, ?, ?, ?)",
(cid, channel_type, name, office_id, json.dumps(parts), created_at, project_id),
)
await self._db.commit()
await self._retry_locked(_write)
return channel
async def insert_message( async def insert_message(
self, self,
@@ -525,8 +580,10 @@ class ChatStore:
"""Insert a message. Returns message dict in backend format (snake_case).""" """Insert a message. Returns message dict in backend format (snake_case)."""
mid = message_id or str(uuid.uuid4()) mid = message_id or str(uuid.uuid4())
now = float(created_at) if created_at is not None else time.time() now = float(created_at) if created_at is not None else time.time()
async def _write() -> None:
await self._db.execute( await self._db.execute(
"INSERT INTO messages " "INSERT OR REPLACE INTO messages "
"(message_id, channel_id, sender, sender_name, content, timestamp, " "(message_id, channel_id, sender, sender_name, content, timestamp, "
"reply_to_id, mentions, metadata, project_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", "reply_to_id, mentions, metadata, project_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
( (
@@ -538,6 +595,8 @@ class ChatStore:
), ),
) )
await self._db.commit() await self._db.commit()
await self._retry_locked(_write)
return { return {
"message_id": mid, "message_id": mid,
"channel_id": channel_id, "channel_id": channel_id,
@@ -1220,6 +1279,41 @@ class ChatStore:
project_id=project_id, project_id=project_id,
) )
async def get_checkpoint_message(
self,
checkpoint_id: str,
*,
channel_id: str | None = None,
checkpoint_type: str | None = None,
project_id: str = "default",
) -> dict[str, Any] | None:
"""Read-only lookup of a checkpoint card message by checkpoint id."""
normalized_checkpoint_id = str(checkpoint_id or "").strip()
if not normalized_checkpoint_id:
return None
normalized_checkpoint_type = str(checkpoint_type or "").strip()
normalized_channel_id = str(channel_id or "").strip()
params: list[Any] = [project_id]
query = (
"SELECT message_id, channel_id, sender, sender_name, content, "
"timestamp, reply_to_id, mentions, metadata "
"FROM messages WHERE project_id = ?"
)
if normalized_channel_id:
query += " AND channel_id = ?"
params.append(normalized_channel_id)
query += " ORDER BY timestamp DESC"
cursor = await self._db.execute(query, tuple(params))
rows = await cursor.fetchall()
for row in rows:
metadata = json.loads(row[8]) if row[8] else {}
if str(metadata.get("checkpoint_id", "")).strip() != normalized_checkpoint_id:
continue
if normalized_checkpoint_type and str(metadata.get("checkpoint_type", "")).strip() != normalized_checkpoint_type:
continue
return self._row_to_message_dict(row)
return None
async def update_checkpoint_status( async def update_checkpoint_status(
self, self,
checkpoint_id: str, checkpoint_id: str,
@@ -1434,6 +1528,8 @@ class ChatStore:
""" """
existing = await self.get_progress(task_id, project_id=project_id) existing = await self.get_progress(task_id, project_id=project_id)
merged = (existing + new_entries)[-self._PROGRESS_MAX_ENTRIES:] merged = (existing + new_entries)[-self._PROGRESS_MAX_ENTRIES:]
async def _write() -> None:
await self._db.execute( await self._db.execute(
"INSERT OR REPLACE INTO task_progress (task_id, entries, updated_at, project_id) " "INSERT OR REPLACE INTO task_progress (task_id, entries, updated_at, project_id) "
"VALUES (?, ?, ?, ?)", "VALUES (?, ?, ?, ?)",
@@ -1441,6 +1537,8 @@ class ChatStore:
) )
await self._db.commit() await self._db.commit()
await self._retry_locked(_write)
async def get_progress(self, task_id: str, project_id: str = "default") -> list[dict[str, Any]]: async def get_progress(self, task_id: str, project_id: str = "default") -> list[dict[str, Any]]:
"""Read persisted progress entries for a task.""" """Read persisted progress entries for a task."""
cursor = await self._db.execute( cursor = await self._db.execute(
@@ -1,12 +1,12 @@
import{g as Zo,r as R3}from"./phaser-DFK5Ua9d.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var Wp={exports:{}},pc={};var lk;function A3(){if(lk)return pc;lk=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,o){var a=null;if(o!==void 0&&(a=""+o),i.key!==void 0&&(a=""+i.key),"key"in i){o={};for(var u in i)u!=="key"&&(o[u]=i[u])}else o=i;return i=o.ref,{$$typeof:e,type:r,key:a,ref:i!==void 0?i:null,props:o}}return pc.Fragment=t,pc.jsx=n,pc.jsxs=n,pc}var ck;function M3(){return ck||(ck=1,Wp.exports=A3()),Wp.exports}var c=M3(),Yp={exports:{}},_t={};var uk;function D3(){if(uk)return _t;uk=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function y(G){return G===null||typeof G!="object"?null:(G=g&&G[g]||G["@@iterator"],typeof G=="function"?G:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,S={};function _(G,J,P){this.props=G,this.context=J,this.refs=S,this.updater=P||v}_.prototype.isReactComponent={},_.prototype.setState=function(G,J){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,J,"setState")},_.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function k(){}k.prototype=_.prototype;function C(G,J,P){this.props=G,this.context=J,this.refs=S,this.updater=P||v}var N=C.prototype=new k;N.constructor=C,w(N,_.prototype),N.isPureReactComponent=!0;var O=Array.isArray;function I(){}var D={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function L(G,J,P){var X=P.ref;return{$$typeof:e,type:G,key:J,ref:X!==void 0?X:null,props:P}}function A(G,J){return L(G.type,J,G.props)}function M(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function $(G){var J={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(P){return J[P]})}var W=/\/+/g;function B(G,J){return typeof G=="object"&&G!==null&&G.key!=null?$(""+G.key):J.toString(36)}function U(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(I,I):(G.status="pending",G.then(function(J){G.status==="pending"&&(G.status="fulfilled",G.value=J)},function(J){G.status==="pending"&&(G.status="rejected",G.reason=J)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function H(G,J,P,X,ee){var te=typeof G;(te==="undefined"||te==="boolean")&&(G=null);var re=!1;if(G===null)re=!0;else switch(te){case"bigint":case"string":case"number":re=!0;break;case"object":switch(G.$$typeof){case e:case t:re=!0;break;case p:return re=G._init,H(re(G._payload),J,P,X,ee)}}if(re)return ee=ee(G),re=X===""?"."+B(G,0):X,O(ee)?(P="",re!=null&&(P=re.replace(W,"$&/")+"/"),H(ee,J,P,"",function(se){return se})):ee!=null&&(M(ee)&&(ee=A(ee,P+(ee.key==null||G&&G.key===ee.key?"":(""+ee.key).replace(W,"$&/")+"/")+re)),J.push(ee)),1;re=0;var oe=X===""?".":X+":";if(O(G))for(var de=0;de<G.length;de++)X=G[de],te=oe+B(X,de),re+=H(X,J,P,te,ee);else if(de=y(G),typeof de=="function")for(G=de.call(G),de=0;!(X=G.next()).done;)X=X.value,te=oe+B(X,de++),re+=H(X,J,P,te,ee);else if(te==="object"){if(typeof G.then=="function")return H(U(G),J,P,X,ee);throw J=String(G),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return re}function V(G,J,P){if(G==null)return G;var X=[],ee=0;return H(G,X,"","",function(te){return J.call(P,te,ee++)}),X}function Y(G){if(G._status===-1){var J=G._result;J=J(),J.then(function(P){(G._status===0||G._status===-1)&&(G._status=1,G._result=P)},function(P){(G._status===0||G._status===-1)&&(G._status=2,G._result=P)}),G._status===-1&&(G._status=0,G._result=J)}if(G._status===1)return G._reLine truncated import{g as Zo,r as R3}from"./phaser-DFK5Ua9d.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var Wp={exports:{}},pc={};var lk;function A3(){if(lk)return pc;lk=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,o){var a=null;if(o!==void 0&&(a=""+o),i.key!==void 0&&(a=""+i.key),"key"in i){o={};for(var u in i)u!=="key"&&(o[u]=i[u])}else o=i;return i=o.ref,{$$typeof:e,type:r,key:a,ref:i!==void 0?i:null,props:o}}return pc.Fragment=t,pc.jsx=n,pc.jsxs=n,pc}var ck;function M3(){return ck||(ck=1,Wp.exports=A3()),Wp.exports}var c=M3(),Yp={exports:{}},_t={};var uk;function D3(){if(uk)return _t;uk=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function y(G){return G===null||typeof G!="object"?null:(G=g&&G[g]||G["@@iterator"],typeof G=="function"?G:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,S={};function _(G,J,P){this.props=G,this.context=J,this.refs=S,this.updater=P||v}_.prototype.isReactComponent={},_.prototype.setState=function(G,J){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,J,"setState")},_.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function w(){}w.prototype=_.prototype;function C(G,J,P){this.props=G,this.context=J,this.refs=S,this.updater=P||v}var N=C.prototype=new w;N.constructor=C,k(N,_.prototype),N.isPureReactComponent=!0;var O=Array.isArray;function I(){}var D={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function L(G,J,P){var X=P.ref;return{$$typeof:e,type:G,key:J,ref:X!==void 0?X:null,props:P}}function A(G,J){return L(G.type,J,G.props)}function M(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function $(G){var J={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(P){return J[P]})}var W=/\/+/g;function B(G,J){return typeof G=="object"&&G!==null&&G.key!=null?$(""+G.key):J.toString(36)}function U(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(I,I):(G.status="pending",G.then(function(J){G.status==="pending"&&(G.status="fulfilled",G.value=J)},function(J){G.status==="pending"&&(G.status="rejected",G.reason=J)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function H(G,J,P,X,ee){var te=typeof G;(te==="undefined"||te==="boolean")&&(G=null);var re=!1;if(G===null)re=!0;else switch(te){case"bigint":case"string":case"number":re=!0;break;case"object":switch(G.$$typeof){case e:case t:re=!0;break;case p:return re=G._init,H(re(G._payload),J,P,X,ee)}}if(re)return ee=ee(G),re=X===""?"."+B(G,0):X,O(ee)?(P="",re!=null&&(P=re.replace(W,"$&/")+"/"),H(ee,J,P,"",function(se){return se})):ee!=null&&(M(ee)&&(ee=A(ee,P+(ee.key==null||G&&G.key===ee.key?"":(""+ee.key).replace(W,"$&/")+"/")+re)),J.push(ee)),1;re=0;var oe=X===""?".":X+":";if(O(G))for(var de=0;de<G.length;de++)X=G[de],te=oe+B(X,de),re+=H(X,J,P,te,ee);else if(de=y(G),typeof de=="function")for(G=de.call(G),de=0;!(X=G.next()).done;)X=X.value,te=oe+B(X,de++),re+=H(X,J,P,te,ee);else if(te==="object"){if(typeof G.then=="function")return H(U(G),J,P,X,ee);throw J=String(G),Error("Objects are not valid as a React child (found: "+(J==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":J)+"). If you meant to render a collection of children, use an array instead.")}return re}function V(G,J,P){if(G==null)return G;var X=[],ee=0;return H(G,X,"","",function(te){return J.call(P,te,ee++)}),X}function Y(G){if(G._status===-1){var J=G._result;J=J(),J.then(function(P){(G._status===0||G._status===-1)&&(G._status=1,G._result=P)},function(P){(G._status===0||G._status===-1)&&(G._status=2,G._result=P)}),G._status===-1&&(G._status=0,G._result=J)}if(G._status===1)return G._reLine truncated
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return` at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
`+we+s+Ce}var Ge=!1;function Ye(s,l){if(!s||Ge)return"";Ge=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var x={DetermineComponentFrameRoot:function(){try{if(l){var Ie=function(){throw Error()};if(Object.defineProperty(Ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ie,[])}catch(ye){var xe=ye}Reflect.construct(s,[],Ie)}else{try{Ie.call()}catch(ye){xe=ye}s.call(Ie.prototype)}}else{try{throw Error()}catch(ye){xe=ye}(Ie=s())&&typeof Ie.catch=="function"&&Ie.catch(function(){})}}catch(ye){if(ye&&xe&&typeof ye.stack=="string")return[ye.stack,xe.stack]}return[null,null]}};x.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(x.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(x.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=x.DetermineComponentFrameRoot(),F=j[0],K=j[1];if(F&&K){var ie=F.split(` `+we+s+Ce}var Ge=!1;function Ye(s,l){if(!s||Ge)return"";Ge=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var x={DetermineComponentFrameRoot:function(){try{if(l){var Ie=function(){throw Error()};if(Object.defineProperty(Ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ie,[])}catch(ye){var xe=ye}Reflect.construct(s,[],Ie)}else{try{Ie.call()}catch(ye){xe=ye}s.call(Ie.prototype)}}else{try{throw Error()}catch(ye){xe=ye}(Ie=s())&&typeof Ie.catch=="function"&&Ie.catch(function(){})}}catch(ye){if(ye&&xe&&typeof ye.stack=="string")return[ye.stack,xe.stack]}return[null,null]}};x.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(x.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(x.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var E=x.DetermineComponentFrameRoot(),F=E[0],K=E[1];if(F&&K){var ie=F.split(`
`),pe=K.split(` `),pe=K.split(`
`);for(b=x=0;x<ie.length&&!ie[x].includes("DetermineComponentFrameRoot");)x++;for(;b<pe.length&&!pe[b].includes("DetermineComponentFrameRoot");)b++;if(x===ie.length||b===pe.length)for(x=ie.length-1,b=pe.length-1;1<=x&&0<=b&&ie[x]!==pe[b];)b--;for(;1<=x&&0<=b;x--,b--)if(ie[x]!==pe[b]){if(x!==1||b!==1)do if(x--,b--,0>b||ie[x]!==pe[b]){var _e=` `);for(b=x=0;x<ie.length&&!ie[x].includes("DetermineComponentFrameRoot");)x++;for(;b<pe.length&&!pe[b].includes("DetermineComponentFrameRoot");)b++;if(x===ie.length||b===pe.length)for(x=ie.length-1,b=pe.length-1;1<=x&&0<=b&&ie[x]!==pe[b];)b--;for(;1<=x&&0<=b;x--,b--)if(ie[x]!==pe[b]){if(x!==1||b!==1)do if(x--,b--,0>b||ie[x]!==pe[b]){var _e=`
`+ie[x].replace(" at new "," at ");return s.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",s.displayName)),_e}while(1<=x&&0<=b);break}}}finally{Ge=!1,Error.prepareStackTrace=f}return(f=s?s.displayName||s.name:"")?Be(f):""}function yt(s,l){switch(s.tag){case 26:case 27:case 5:return Be(s.type);case 16:return Be("Lazy");case 13:return s.child!==l&&l!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Ye(s.type,!1);case 11:return Ye(s.type.render,!1);case 1:return Ye(s.type,!0);case 31:return Be("Activity");default:return""}}function Vt(s){try{var l="",f=null;do l+=yt(s,f),f=s,s=s.return;while(s);return l}catch(x){return` `+ie[x].replace(" at new "," at ");return s.displayName&&_e.includes("<anonymous>")&&(_e=_e.replace("<anonymous>",s.displayName)),_e}while(1<=x&&0<=b);break}}}finally{Ge=!1,Error.prepareStackTrace=f}return(f=s?s.displayName||s.name:"")?Be(f):""}function yt(s,l){switch(s.tag){case 26:case 27:case 5:return Be(s.type);case 16:return Be("Lazy");case 13:return s.child!==l&&l!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Ye(s.type,!1);case 11:return Ye(s.type.render,!1);case 1:return Ye(s.type,!0);case 31:return Be("Activity");default:return""}}function Vt(s){try{var l="",f=null;do l+=yt(s,f),f=s,s=s.return;while(s);return l}catch(x){return`
Error generating stack: `+x.message+` Error generating stack: `+x.message+`
`+x.stack}}var bt=Object.prototype.hasOwnProperty,vt=e.unstable_scheduleCallback,me=e.unstable_cancelCallback,Oe=e.unstable_shouldYield,rt=e.unstable_requestPaint,Qe=e.unstable_now,Je=e.unstable_getCurrentPriorityLevel,fe=e.unstable_ImmediatePriority,be=e.unstable_UserBlockingPriority,Me=e.unstable_NormalPriority,Fe=e.unstable_LowPriority,$e=e.unstable_IdlePriority,Ut=e.log,rn=e.unstable_setDisableYieldValue,ke=null,Te=null;function Pe(s){if(typeof Ut=="function"&&rn(s),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(ke,s)}catch{}}var Ve=Math.clz32?Math.clz32:Mn,qe=Math.log,et=Math.LN2;function Mn(s){return s>>>=0,s===0?32:31-(qe(s)/et|0)|0}var Tn=256,Dn=262144,yn=4194304;function Wt(s){var l=s&42;if(l!==0)return l;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Zt(s,l,f){var x=s.pendingLanes;if(x===0)return 0;var b=0,j=s.suspendedLanes,F=s.pingedLanes;s=s.warmLanes;var K=x&134217727;return K!==0?(x=K&~j,x!==0?b=Wt(x):(F&=K,F!==0?b=Wt(F):f||(f=K&~s,f!==0&&(b=Wt(f))))):(K=x&~j,K!==0?b=Wt(K):F!==0?b=Wt(F):f||(f=x&~s,f!==0&&(b=Wt(f)))),b===0?0:l!==0&&l!==b&&(l&j)===0&&(j=b&-b,f=l&-l,j>=f||j===32&&(f&4194048)!==0)?l:b}function Et(s,l){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&l)===0}function wt(s,l){switch(s){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function tt(){var s=yn;return yn<<=1,(yn&62914560)===0&&(yn=4194304),s}function it(s){for(var l=[],f=0;31>f;f++)l.push(s);return l}function sn(s,l){s.pendingLanes|=l,l!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Qt(s,l,f,x,b,j){var F=s.pendingLanes;s.pendingLanes=f,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=f,s.entangledLanes&=f,s.errorRecoveryDisabledLanes&=f,s.shellSuspendCounter=0;var K=s.entanglements,ie=s.expirationTimes,pe=s.hiddenUpdates;for(f=F&~f;0<f;){var _e=31-Ve(f),Ie=1<<_e;K[_e]=0,ie[_e]=-1;var xe=pe[_e];if(xe!==null)for(pe[_e]=null,_e=0;_e<xe.length;_e++){var ye=xe[_e];ye!==null&&(ye.lane&=-536870913)}f&=~Ie}x!==0&&mt(s,x,0),j!==0&&b===0&&s.tag!==0&&(s.suspendedLanes|=j&~(F&~l))}function mt(s,l,f){s.pendingLanes|=l,s.suspendedLanes&=~l;var x=31-Ve(l);s.entangledLanes|=l,s.entanglements[x]=s.entanglements[x]|1073741824|f&261930}function Bt(s,l){var f=s.entangledLanes|=l;for(s=s.entanglements;f;){var x=31-Ve(f),b=1<<x;b&l|s[x]&l&&(s[x]|=l),f&=~b}}function On(s,l){var f=l&-l;return f=(f&42)!==0?1:vn(f),(f&(s.suspendedLanes|l))!==0?0:f}function vn(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function Rn(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function ve(){var s=V.p;return s!==0?s:(s=window.event,s===void 0?32:tk(s.type))}function Re(s,l){var f=V.p;try{return V.p=s,l()}finally{V.p=f}}var Xe=Math.random().toString(36).slice(2),He="__reactFiber$"+Xe,Tt="__reactProps$"+Xe,ft="__reactContainer$"+Xe,$n="__reactEvents$"+Xe,Ae="__reactListeners$"+Xe,Dt="__reactHandles$"+Xe,kn="__reactResources$"+Xe,nr="__reactMarker$"+Xe;function Sn(s){delete s[He],delete s[Tt],delete s[$n],delete s[Ae],delete s[Dt]}function We(s){var l=s[He];if(l)return l;for(var f=s.parentNode;f;){if(l=f[ft]||f[He]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(s=B_(s);s!==null;){if(f=s[He])return f;s=B_(s)}return l}s=f,f=s.parentNode}return null}function ar(s){if(s=s[He]||s[ft]){var l=s.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return s}return null}function lr(s){var l=s.tag;if(l===5||l===26||l===27||l===6)return s.stateNode;throw Error(r(33))}function mn(s){var l=s[kn];return l||(l=s[kn]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function zt(s){s[nr]=!0}var Qn=new Set,wn={};function ht(s,l){Tr(s,l),Tr(s+"Capture",l)}function Tr(s,l){for(wn[s]=l,s=0;s<l.length;s++)Qn.add(l[s])}var wr=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u2 Line truncated `+x.stack}}var bt=Object.prototype.hasOwnProperty,vt=e.unstable_scheduleCallback,me=e.unstable_cancelCallback,Oe=e.unstable_shouldYield,rt=e.unstable_requestPaint,Qe=e.unstable_now,Je=e.unstable_getCurrentPriorityLevel,fe=e.unstable_ImmediatePriority,be=e.unstable_UserBlockingPriority,Me=e.unstable_NormalPriority,Fe=e.unstable_LowPriority,$e=e.unstable_IdlePriority,Ut=e.log,rn=e.unstable_setDisableYieldValue,ke=null,Te=null;function Pe(s){if(typeof Ut=="function"&&rn(s),Te&&typeof Te.setStrictMode=="function")try{Te.setStrictMode(ke,s)}catch{}}var Ve=Math.clz32?Math.clz32:Mn,qe=Math.log,et=Math.LN2;function Mn(s){return s>>>=0,s===0?32:31-(qe(s)/et|0)|0}var Tn=256,Dn=262144,yn=4194304;function Wt(s){var l=s&42;if(l!==0)return l;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Zt(s,l,f){var x=s.pendingLanes;if(x===0)return 0;var b=0,E=s.suspendedLanes,F=s.pingedLanes;s=s.warmLanes;var K=x&134217727;return K!==0?(x=K&~E,x!==0?b=Wt(x):(F&=K,F!==0?b=Wt(F):f||(f=K&~s,f!==0&&(b=Wt(f))))):(K=x&~E,K!==0?b=Wt(K):F!==0?b=Wt(F):f||(f=x&~s,f!==0&&(b=Wt(f)))),b===0?0:l!==0&&l!==b&&(l&E)===0&&(E=b&-b,f=l&-l,E>=f||E===32&&(f&4194048)!==0)?l:b}function Et(s,l){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&l)===0}function wt(s,l){switch(s){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function tt(){var s=yn;return yn<<=1,(yn&62914560)===0&&(yn=4194304),s}function it(s){for(var l=[],f=0;31>f;f++)l.push(s);return l}function sn(s,l){s.pendingLanes|=l,l!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Qt(s,l,f,x,b,E){var F=s.pendingLanes;s.pendingLanes=f,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=f,s.entangledLanes&=f,s.errorRecoveryDisabledLanes&=f,s.shellSuspendCounter=0;var K=s.entanglements,ie=s.expirationTimes,pe=s.hiddenUpdates;for(f=F&~f;0<f;){var _e=31-Ve(f),Ie=1<<_e;K[_e]=0,ie[_e]=-1;var xe=pe[_e];if(xe!==null)for(pe[_e]=null,_e=0;_e<xe.length;_e++){var ye=xe[_e];ye!==null&&(ye.lane&=-536870913)}f&=~Ie}x!==0&&mt(s,x,0),E!==0&&b===0&&s.tag!==0&&(s.suspendedLanes|=E&~(F&~l))}function mt(s,l,f){s.pendingLanes|=l,s.suspendedLanes&=~l;var x=31-Ve(l);s.entangledLanes|=l,s.entanglements[x]=s.entanglements[x]|1073741824|f&261930}function Bt(s,l){var f=s.entangledLanes|=l;for(s=s.entanglements;f;){var x=31-Ve(f),b=1<<x;b&l|s[x]&l&&(s[x]|=l),f&=~b}}function On(s,l){var f=l&-l;return f=(f&42)!==0?1:vn(f),(f&(s.suspendedLanes|l))!==0?0:f}function vn(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function Rn(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function ve(){var s=V.p;return s!==0?s:(s=window.event,s===void 0?32:tk(s.type))}function Re(s,l){var f=V.p;try{return V.p=s,l()}finally{V.p=f}}var Xe=Math.random().toString(36).slice(2),He="__reactFiber$"+Xe,Tt="__reactProps$"+Xe,ft="__reactContainer$"+Xe,$n="__reactEvents$"+Xe,Ae="__reactListeners$"+Xe,Dt="__reactHandles$"+Xe,kn="__reactResources$"+Xe,nr="__reactMarker$"+Xe;function Sn(s){delete s[He],delete s[Tt],delete s[$n],delete s[Ae],delete s[Dt]}function We(s){var l=s[He];if(l)return l;for(var f=s.parentNode;f;){if(l=f[ft]||f[He]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(s=B_(s);s!==null;){if(f=s[He])return f;s=B_(s)}return l}s=f,f=s.parentNode}return null}function ar(s){if(s=s[He]||s[ft]){var l=s.tag;if(l===5||l===6||l===13||l===31||l===26||l===27||l===3)return s}return null}function lr(s){var l=s.tag;if(l===5||l===26||l===27||l===6)return s.stateNode;throw Error(r(33))}function mn(s){var l=s[kn];return l||(l=s[kn]={hoistableStyles:new Map,hoistableScripts:new Map}),l}function zt(s){s[nr]=!0}var Qn=new Set,wn={};function ht(s,l){Tr(s,l),Tr(s+"Capture",l)}function Tr(s,l){for(wn[s]=l,s=0;s<l.length;s++)Qn.add(l[s])}var wr=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u2 Line truncated
`).replace(JA,"")}function I_(s,l){return l=N_(l),N_(s)===l}function dn(s,l,f,x,b,j){switch(f){case"children":typeof x=="string"?l==="body"||l==="textarea"&&x===""||Es(s,x):(typeof x=="number"||typeof x=="bigint")&&l!=="body"&&Es(s,""+x);break;case"className":It(s,"class",x);break;case"tabIndex":It(s,"tabindex",x);break;case"dir":case"role":case"viewBox":case"width":case"height":It(s,f,x);break;case"style":Au(s,x,j);break;case"data":if(l!=="object"){It(s,"data",x);break}case"src":case"href":if(x===""&&(l!=="a"||f!=="href")){s.removeAttribute(f);break}if(x==null||typeof x=="function"||typeof x=="symbol"||typeof x=="boolean"){s.removeAttribute(f);break}x=ea(""+x),s.setAttribute(f,x);break;case"action":case"formAction":if(typeof x=="function"){s.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof j=="function"&&(f==="formAction"?(l!=="input"&&dn(s,l,"name",b.name,b,null),dn(s,l,"formEncType",b.formEncType,b,null),dn(s,l,"formMethod",b.formMethod,b,null),dn(s,l,"formTarget",b.formTarget,b,null)):(dn(s,l,"encType",b.encType,b,null),dn(s,l,"method",b.method,b,null),dn(s,l,"target",b.target,b,null)));if(x==null||typeof x=="symbol"||typeof x=="boolean"){s.removeAttribute(f);break}x=ea(""+x),s.setAttribute(f,x);break;case"onClick":x!=null&&(s.onclick=ii);break;case"onScroll":x!=null&&At("scroll",s);break;case"onScrollEnd":x!=null&&At("scrollend",s);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(r(61));if(f=x.__html,f!=null){if(b.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"multiple":s.multiple=x&&typeof x!="function"&&typeof x!="symbol";break;case"muted":s.muted=x&&typeof x!="function"&&typeof x!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(x==null||typeof x=="function"||typeof x=="boolean"||typeof x=="symbol"){s.removeAttribute("xlink:href");break}f=ea(""+x),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":x!=null&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,""+x):s.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":x&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,""):s.removeAttribute(f);break;case"capture":case"download":x===!0?s.setAttribute(f,""):x!==!1&&x!=null&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,x):s.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":x!=null&&typeof x!="function"&&typeof x!="symbol"&&!isNaN(x)&&1<=x?s.setAttribute(f,x):s.removeAttribute(f);break;case"rowSpan":case"start":x==null||typeof x=="function"||typeof x=="symbol"||isNaN(x)?s.removeAttribute(f):s.setAttribute(f,x);break;case"popover":At("beforetoggle",s),At("toggle",s),on(s,"popover",x);break;case"xlinkActuate":pr(s,"http://www.w3.org/1999/xlink","xlink:actuate",x);break;case"xlinkArcrole":pr(s,"http://www.w3.org/1999/xlink","xlink:arcrole",x);break;case"xlinkRole":pr(s,"http://www.w3.org/1999/xlink","xlink:role",x);break;case"xlinkShow":pr(s,"http://www.w3.org/1999/xlink","xlink:show",x);break;case"xlinkTitle":pr(s,"http://www.w3.org/1999/xlink","xlink:title",x);break;case"xlinkType":pr(s,"http://www.w3.org/1999/xlink","xlink:type",x);break;case"xmlBase":pr(s,"http://www.w3.org/XML/1998/namespace","xml:base",x);break;case"xmlLang":pr(s,"http://www.w3.org/XML/1998/namespace","xml:lang",x);break;case"xmlSpace":pr(s,"http://www.w3.org/XML/1998/namespace","xml:space",x);break;case"is":on(s,"is",x);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=Mu.get(f)||f,on(s,f,x))}}function Ip(s,l,f,x,b,j){switch(f){case"style":Au(s,x,j);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(r(61));if(f=x.__html,f!=null){if(b.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"children":typeof x=="string"?Es(s,x):(typeof x=="number"||typeof x=="bigint")&&Es(s,""+x);break;case"onScroll":x!=null&&At("scroll",s);break;case"onScrollEnd":x!=null&&At("scrollend",s);break;case"onClick":x!=null&&(s.onclick=ii);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne Line truncated `).replace(JA,"")}function I_(s,l){return l=N_(l),N_(s)===l}function dn(s,l,f,x,b,E){switch(f){case"children":typeof x=="string"?l==="body"||l==="textarea"&&x===""||Es(s,x):(typeof x=="number"||typeof x=="bigint")&&l!=="body"&&Es(s,""+x);break;case"className":It(s,"class",x);break;case"tabIndex":It(s,"tabindex",x);break;case"dir":case"role":case"viewBox":case"width":case"height":It(s,f,x);break;case"style":Au(s,x,E);break;case"data":if(l!=="object"){It(s,"data",x);break}case"src":case"href":if(x===""&&(l!=="a"||f!=="href")){s.removeAttribute(f);break}if(x==null||typeof x=="function"||typeof x=="symbol"||typeof x=="boolean"){s.removeAttribute(f);break}x=ea(""+x),s.setAttribute(f,x);break;case"action":case"formAction":if(typeof x=="function"){s.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof E=="function"&&(f==="formAction"?(l!=="input"&&dn(s,l,"name",b.name,b,null),dn(s,l,"formEncType",b.formEncType,b,null),dn(s,l,"formMethod",b.formMethod,b,null),dn(s,l,"formTarget",b.formTarget,b,null)):(dn(s,l,"encType",b.encType,b,null),dn(s,l,"method",b.method,b,null),dn(s,l,"target",b.target,b,null)));if(x==null||typeof x=="symbol"||typeof x=="boolean"){s.removeAttribute(f);break}x=ea(""+x),s.setAttribute(f,x);break;case"onClick":x!=null&&(s.onclick=ii);break;case"onScroll":x!=null&&At("scroll",s);break;case"onScrollEnd":x!=null&&At("scrollend",s);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(r(61));if(f=x.__html,f!=null){if(b.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"multiple":s.multiple=x&&typeof x!="function"&&typeof x!="symbol";break;case"muted":s.muted=x&&typeof x!="function"&&typeof x!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(x==null||typeof x=="function"||typeof x=="boolean"||typeof x=="symbol"){s.removeAttribute("xlink:href");break}f=ea(""+x),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":x!=null&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,""+x):s.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":x&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,""):s.removeAttribute(f);break;case"capture":case"download":x===!0?s.setAttribute(f,""):x!==!1&&x!=null&&typeof x!="function"&&typeof x!="symbol"?s.setAttribute(f,x):s.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":x!=null&&typeof x!="function"&&typeof x!="symbol"&&!isNaN(x)&&1<=x?s.setAttribute(f,x):s.removeAttribute(f);break;case"rowSpan":case"start":x==null||typeof x=="function"||typeof x=="symbol"||isNaN(x)?s.removeAttribute(f):s.setAttribute(f,x);break;case"popover":At("beforetoggle",s),At("toggle",s),on(s,"popover",x);break;case"xlinkActuate":pr(s,"http://www.w3.org/1999/xlink","xlink:actuate",x);break;case"xlinkArcrole":pr(s,"http://www.w3.org/1999/xlink","xlink:arcrole",x);break;case"xlinkRole":pr(s,"http://www.w3.org/1999/xlink","xlink:role",x);break;case"xlinkShow":pr(s,"http://www.w3.org/1999/xlink","xlink:show",x);break;case"xlinkTitle":pr(s,"http://www.w3.org/1999/xlink","xlink:title",x);break;case"xlinkType":pr(s,"http://www.w3.org/1999/xlink","xlink:type",x);break;case"xmlBase":pr(s,"http://www.w3.org/XML/1998/namespace","xml:base",x);break;case"xmlLang":pr(s,"http://www.w3.org/XML/1998/namespace","xml:lang",x);break;case"xmlSpace":pr(s,"http://www.w3.org/XML/1998/namespace","xml:space",x);break;case"is":on(s,"is",x);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=Mu.get(f)||f,on(s,f,x))}}function Ip(s,l,f,x,b,E){switch(f){case"style":Au(s,x,E);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(r(61));if(f=x.__html,f!=null){if(b.children!=null)throw Error(r(60));s.innerHTML=f}}break;case"children":typeof x=="string"?Es(s,x):(typeof x=="number"||typeof x=="bigint")&&Es(s,""+x);break;case"onScroll":x!=null&&At("scroll",s);break;case"onScrollEnd":x!=null&&At("scrollend",s);break;case"onClick":x!=null&&(s.onclick=ii);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne Line truncated
`),oe=h.map(([de,se])=>` [${de}, ${se}],`).join(` `),oe=h.map(([de,se])=>` [${de}, ${se}],`).join(`
`);return`const MAP_STR: string[] = [ `);return`const MAP_STR: string[] = [
${re} ${re}
@@ -14,14 +14,14 @@ ${re}
const SEATS: [number, number][] = [ const SEATS: [number, number][] = [
${oe} ${oe}
]`})(),J=()=>I(te=>Math.min(te+.25,3)),P=()=>I(te=>Math.max(te-.25,.5)),X=m.flat().filter(te=>te===1).length,ee=m.flat().filter(te=>te===0).length;return c.jsxs("div",{className:"collision-editor",children:[c.jsxs("div",{className:"ce-toolbar",children:[c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("span",{className:"ce-title",children:"Map Editor"}),c.jsx("select",{className:"ce-office-select",value:a,onChange:te=>M(te.target.value),children:i.map(te=>c.jsx("option",{value:te.id,children:te.name},te.id))})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsxs("button",{className:`ce-mode-btn ${y==="wall"?"active wall":""}`,onClick:()=>v("wall"),children:[c.jsx("span",{className:"ce-mode-dot wall"})," Wall"]}),c.jsxs("button",{className:`ce-mode-btn ${y==="floor"?"active floor":""}`,onClick:()=>v("floor"),children:[c.jsx("span",{className:"ce-mode-dot floor"})," Floor"]}),c.jsxs("button",{className:`ce-mode-btn ${y==="seat"?"active seat":""}`,onClick:()=>v("seat"),children:[c.jsx("span",{className:"ce-mode-dot seat"})," Seat"]})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("button",{className:"ce-btn",onClick:P,children:"-"}),c.jsxs("span",{className:"ce-zoom-label",children:[Math.round(O*100),"%"]}),c.jsx("button",{className:"ce-btn",onClick:J,children:"+"}),c.jsx("button",{className:`ce-btn${D?" active":""}`,onClick:()=>T(te=>!te),children:"Grid"})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("button",{className:`ce-btn apply${C?" success":""}`,onClick:Y,children:C?"Applied":"Apply"}),c.jsx("button",{className:`ce-btn${_?" active":""}`,onClick:Z,children:"Export"}),c.jsx("button",{className:"ce-btn danger",onClick:q,children:"Reset"})]}),c.jsxs("div",{className:"ce-toolbar-group ce-stats",children:[c.jsxs("span",{children:["Walls: ",X]}),c.jsxs("span",{children:["Floor: ",ee]}),c.jsxs("span",{children:["Seats: ",h.length]})]})]}),c.jsxs("div",{className:"ce-body",children:[c.jsx("div",{className:"ce-canvas-wrap",style:{overflow:"auto"},children:c.jsx("canvas",{ref:t,style:{width:L*R*O,height:A*R*O,imageRendering:"pixelated",cursor:y==="seat"?"crosshair":"cell"},onMouseDown:U,onMouseMove:H,onMouseUp:V,onMouseLeave:V})}),_&&c.jsxs("div",{className:"ce-export-panel",children:[c.jsxs("div",{className:"ce-export-header",children:[c.jsx("span",{children:"Export — copy to source code"}),c.jsx("button",{className:"ce-btn",onClick:()=>navigator.clipboard.writeText(G),children:"Copy"})]}),c.jsx("textarea",{className:"ce-export-textarea",value:G,readOnly:!0,rows:20})]})]})]})}let GM=0;function tr(e,t,n={}){return{event_id:`test-${++GM}`,type:e,agent_id:t,data:n,timestamp:Date.now()/1e3}}function En(e){return new Promise(t=>setTimeout(t,e))}async function qM(e){const t=[],n=e.getScene();if(!n)return t.push({name:"scene-ready",pass:!1,detail:"OfficeScene not initialized"}),t;console.log("%c[EventTest] Starting full event test suite (multi-office)...","color: #6366f1; font-weight: bold");for(const M of[...n.agents.keys()])n.removeAgent(M);await En(100);const r=Bn();t.push({name:"offices-loaded",pass:r.length>=3,detail:`${r.length} offices loaded: ${r.map(M=>M.name).join(", ")}`});const i=["agent-A","agent-B","agent-C","agent-D","agent-E","agent-F"];for(const M of i)e.pushEvent(tr("agent_active",M));await En(300);const o=new Set;let a=!1;for(const M of i){const $=n.getAgent(M);$&&$.seatId&&(o.has($.seatId)&&(a=!0),o.add($.seatId))}t.push({name:"desk-assignment-unique",pass:!a&&o.size===i.length,detail:`Assigned ${o.size} unique seats to ${i.length} agents. IDs: [${[...o].join(", ")}]`});const u=i.every(M=>n.getAgent(M)?.officeId!=null);t.push({name:"agents-have-officeId",pass:u,detail:i.map(M=>`${M}=${n.getAgent(M)?.officeId}`).join(", ")}),e.pushEvent(tr("tool_start","agent-A",{tool_name:"shell"})),await En(200);const d=n.getAgent("agent-A");t.push({name:"tool_start-state",pass:d.isActive===!0&&d.currentTool==="shell",detail:`isActive=${d.isActive}, currentTool=${d.currentTool}`}),e.pushEvent(tr("tool_done","agent-A",{tool_name:"shell"})),await En(100),t.push({name:"tool_done-celebrate",pass:d.agentState==="celebrate",detail:`state=${d.agentState}`});for(let M=0;M<20&&d.agentState==="celebrate";M++)await En(500);t.push({name:"celebrate-to-idle",pass:d.agentState!=="celebrate",detail:`state=${d.agentState}`}),e.pushEvent(tr("waiting","agent-B")),await En(200);const m=n.getAgent("agent-B");t.push({name:"waiting-state",pass:m.isActive===!1&&(m.agentState==="walk"||m.agentState==="idle"||m.agentState==="coffee"),detail:`isActive=${m.isActive}, state=${m.agentState}`}),e.pushEvent(tr("reflect_start","agent-C")),await En(200);const p=n.getAgent("agent-C");t.push({name:"reflect_start-state",pass:p.currentTool==="Reflect"&&(p.agentState==="walk"||p.agentState==="reflect"),detail:`currentTool=${p.currentTool}, state=${p.agentState}`}),e.pushEvent(tr("reflect_done","agent-C")),await En(100),t.push({name:"reflect_done-celebrate",pass:p.agentState==="celebrate",detail:`staLine truncated ]`})(),J=()=>I(te=>Math.min(te+.25,3)),P=()=>I(te=>Math.max(te-.25,.5)),X=m.flat().filter(te=>te===1).length,ee=m.flat().filter(te=>te===0).length;return c.jsxs("div",{className:"collision-editor",children:[c.jsxs("div",{className:"ce-toolbar",children:[c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("span",{className:"ce-title",children:"Map Editor"}),c.jsx("select",{className:"ce-office-select",value:a,onChange:te=>M(te.target.value),children:i.map(te=>c.jsx("option",{value:te.id,children:te.name},te.id))})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsxs("button",{className:`ce-mode-btn ${y==="wall"?"active wall":""}`,onClick:()=>v("wall"),children:[c.jsx("span",{className:"ce-mode-dot wall"})," Wall"]}),c.jsxs("button",{className:`ce-mode-btn ${y==="floor"?"active floor":""}`,onClick:()=>v("floor"),children:[c.jsx("span",{className:"ce-mode-dot floor"})," Floor"]}),c.jsxs("button",{className:`ce-mode-btn ${y==="seat"?"active seat":""}`,onClick:()=>v("seat"),children:[c.jsx("span",{className:"ce-mode-dot seat"})," Seat"]})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("button",{className:"ce-btn",onClick:P,children:"-"}),c.jsxs("span",{className:"ce-zoom-label",children:[Math.round(O*100),"%"]}),c.jsx("button",{className:"ce-btn",onClick:J,children:"+"}),c.jsx("button",{className:`ce-btn${D?" active":""}`,onClick:()=>T(te=>!te),children:"Grid"})]}),c.jsxs("div",{className:"ce-toolbar-group",children:[c.jsx("button",{className:`ce-btn apply${C?" success":""}`,onClick:Y,children:C?"Applied":"Apply"}),c.jsx("button",{className:`ce-btn${_?" active":""}`,onClick:Z,children:"Export"}),c.jsx("button",{className:"ce-btn danger",onClick:q,children:"Reset"})]}),c.jsxs("div",{className:"ce-toolbar-group ce-stats",children:[c.jsxs("span",{children:["Walls: ",X]}),c.jsxs("span",{children:["Floor: ",ee]}),c.jsxs("span",{children:["Seats: ",h.length]})]})]}),c.jsxs("div",{className:"ce-body",children:[c.jsx("div",{className:"ce-canvas-wrap",style:{overflow:"auto"},children:c.jsx("canvas",{ref:t,style:{width:L*R*O,height:A*R*O,imageRendering:"pixelated",cursor:y==="seat"?"crosshair":"cell"},onMouseDown:U,onMouseMove:H,onMouseUp:V,onMouseLeave:V})}),_&&c.jsxs("div",{className:"ce-export-panel",children:[c.jsxs("div",{className:"ce-export-header",children:[c.jsx("span",{children:"Export — copy to source code"}),c.jsx("button",{className:"ce-btn",onClick:()=>navigator.clipboard.writeText(G),children:"Copy"})]}),c.jsx("textarea",{className:"ce-export-textarea",value:G,readOnly:!0,rows:20})]})]})]})}let GM=0;function tr(e,t,n={}){return{event_id:`test-${++GM}`,type:e,agent_id:t,data:n,timestamp:Date.now()/1e3}}function En(e){return new Promise(t=>setTimeout(t,e))}async function qM(e){const t=[],n=e.getScene();if(!n)return t.push({name:"scene-ready",pass:!1,detail:"OfficeScene not initialized"}),t;console.log("%c[EventTest] Starting full event test suite (multi-office)...","color: #6366f1; font-weight: bold");for(const M of[...n.agents.keys()])n.removeAgent(M);await En(100);const r=Bn();t.push({name:"offices-loaded",pass:r.length>=3,detail:`${r.length} offices loaded: ${r.map(M=>M.name).join(", ")}`});const i=["agent-A","agent-B","agent-C","agent-D","agent-E","agent-F"];for(const M of i)e.pushEvent(tr("agent_active",M));await En(300);const o=new Set;let a=!1;for(const M of i){const $=n.getAgent(M);$&&$.seatId&&(o.has($.seatId)&&(a=!0),o.add($.seatId))}t.push({name:"desk-assignment-unique",pass:!a&&o.size===i.length,detail:`Assigned ${o.size} unique seats to ${i.length} agents. IDs: [${[...o].join(", ")}]`});const u=i.every(M=>n.getAgent(M)?.officeId!=null);t.push({name:"agents-have-officeId",pass:u,detail:i.map(M=>`${M}=${n.getAgent(M)?.officeId}`).join(", ")}),e.pushEvent(tr("tool_start","agent-A",{tool_name:"shell"})),await En(200);const d=n.getAgent("agent-A");t.push({name:"tool_start-state",pass:d.isActive===!0&&d.currentTool==="shell",detail:`isActive=${d.isActive}, currentTool=${d.currentTool}`}),e.pushEvent(tr("tool_done","agent-A",{tool_name:"shell"})),await En(100),t.push({name:"tool_done-celebrate",pass:d.agentState==="celebrate",detail:`state=${d.agentState}`});for(let M=0;M<20&&d.agentState==="celebrate";M++)await En(500);t.push({name:"celebrate-to-idle",pass:d.agentState!=="celebrate",detail:`state=${d.agentState}`}),e.pushEvent(tr("waiting","agent-B")),await En(200);const m=n.getAgent("agent-B");t.push({name:"waiting-state",pass:m.isActive===!1&&(m.agentState==="walk"||m.agentState==="idle"||m.agentState==="coffee"),detail:`isActive=${m.isActive}, state=${m.agentState}`}),e.pushEvent(tr("reflect_start","agent-C")),await En(200);const p=n.getAgent("agent-C");t.push({name:"reflect_start-state",pass:p.currentTool==="Reflect"&&(p.agentState==="walk"||p.agentState==="reflect"),detail:`currentTool=${p.currentTool}, state=${p.agentState}`}),e.pushEvent(tr("reflect_done","agent-C")),await En(100),t.push({name:"reflect_done-celebrate",pass:p.agentState==="celebrate",detail:`staLine truncated
font-size: .6rem; font-size: .6rem;
font-weight: bold; font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*S,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(i),o=!1,i}return a.updateDeps=u=>{r=u},a}function Pk(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const r4=(e,t)=>Math.abs(e-t)<1.01,i4=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Bk=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},s4=e=>e,o4=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let i=t;i<=n;i++)r.push(i);return r},a4=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=a=>{const{width:u,height:d}=a;t({width:Math.round(u),height:Math.round(d)})};if(i(Bk(n)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(a=>{const u=()=>{const d=a[0];if(d?.borderBoxSize){const m=d.borderBoxSize[0];if(m){i({width:m.inlineSize,height:m.blockSize});return}}i(Bk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},$k={passive:!0},Hk=typeof window>"u"?!0:"onscrollend"in window,l4=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let i=0;const o=e.options.useScrollendEvent&&Hk?()=>{}:i4(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),a=p=>()=>{const{horizontal:h,isRtl:g}=e.options;i=h?n.scrollLeft*(g&&-1||1):n.scrollTop,o(),t(i,p)},u=a(!0),d=a(!1);n.addEventListener("scroll",u,$k);const m=e.options.useScrollendEvent&&Hk;return m&&n.addEventListener("scrollend",d,$k),()=>{n.removeEventListener("scroll",u),m&&n.removeEventListener("scrollend",d)}},c4=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},u4=(e,{adjustments:t=0,behavior:n},r)=>{var i,o;const a=e+t;(o=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||o.call(i,{[r.options.horizontal?"left":"top"]:a,behavior:n})};class d4{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(o=>{const a=()=>{const u=o.target,d=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var o;return(o=r())==null?void 0:o.observe(i,{box:"border-box"})},unobserve:i=>{var o;return(o=r())==null?void 0:o.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:s4,rangeExtractor:o4,onChange:()=>{},measureElement:c4,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=La(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)} Line truncated color: hsl(${Math.max(0,Math.min(120-120*S,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(i),o=!1,i}return a.updateDeps=u=>{r=u},a}function Pk(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const r4=(e,t)=>Math.abs(e-t)<1.01,i4=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Bk=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},s4=e=>e,o4=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let i=t;i<=n;i++)r.push(i);return r},a4=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=a=>{const{width:u,height:d}=a;t({width:Math.round(u),height:Math.round(d)})};if(i(Bk(n)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(a=>{const u=()=>{const d=a[0];if(d?.borderBoxSize){const m=d.borderBoxSize[0];if(m){i({width:m.inlineSize,height:m.blockSize});return}}i(Bk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},$k={passive:!0},Hk=typeof window>"u"?!0:"onscrollend"in window,l4=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let i=0;const o=e.options.useScrollendEvent&&Hk?()=>{}:i4(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),a=p=>()=>{const{horizontal:h,isRtl:g}=e.options;i=h?n.scrollLeft*(g&&-1||1):n.scrollTop,o(),t(i,p)},u=a(!0),d=a(!1);n.addEventListener("scroll",u,$k);const m=e.options.useScrollendEvent&&Hk;return m&&n.addEventListener("scrollend",d,$k),()=>{n.removeEventListener("scroll",u),m&&n.removeEventListener("scrollend",d)}},c4=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},u4=(e,{adjustments:t=0,behavior:n},r)=>{var i,o;const a=e+t;(o=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||o.call(i,{[r.options.horizontal?"left":"top"]:a,behavior:n})};class d4{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(o=>{const a=()=>{const u=o.target,d=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var o;return(o=r())==null?void 0:o.observe(i,{box:"border-box"})},unobserve:i=>{var o;return(o=r())==null?void 0:o.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:s4,rangeExtractor:o4,onChange:()=>{},measureElement:c4,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=La(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)} Line truncated
The error may be correlated with this previous error: The error may be correlated with this previous error:
${te.current.stack} ${te.current.stack}
`),we}Mf(()=>{te.current=void 0,P.current=void 0,G.current=de});const se=E.useMemo(()=>E.createElement(S,{...de,ref:L}),[L,S,de]);return E.useMemo(()=>v?E.createElement(M.Provider,{value:q},se):se,[M,se,q])}const I=E.memo(N);if(I.WrappedComponent=S,I.displayName=N.displayName=k,d){const T=E.forwardRef(function(A,M){return E.createElement(I,{...A,reactReduxForwardedRef:M})});return T.displayName=k,T.WrappedComponent=S,ky(T,S)}return ky(I,S)}}var Qj=X5;function K5(e){const{children:t,context:n,serverState:r,store:i}=e,o=E.useMemo(()=>{const d=Xj(i);return{store:i,subscription:d,getServerState:r?()=>r:void 0}},[i,r]),a=E.useMemo(()=>i.getState(),[i]);Mf(()=>{const{subscription:d}=o;return d.onStateChange=d.notifyNestedSubs,d.trySubscribe(),a!==i.getState()&&d.notifyNestedSubs(),()=>{d.tryUnsubscribe(),d.onStateChange=void 0}},[o,a]);const u=n||Zj;return E.createElement(u.Provider,{value:o},t)}var Z5=K5,Q5="Invariant failed";function J5(e,t){throw new Error(Q5)}var Ei=function(t){var n=t.top,r=t.right,i=t.bottom,o=t.left,a=r-o,u=i-n,d={top:n,right:r,bottom:i,left:o,width:a,height:u,x:o,y:n,center:{x:(r+o)/2,y:(i+n)/2}};return d},S0=function(t,n){return{top:t.top-n.top,left:t.left-n.left,bottom:t.bottom+n.bottom,right:t.right+n.right}},fS=function(t,n){return{top:t.top+n.top,left:t.left+n.left,bottom:t.bottom-n.bottom,right:t.right-n.right}},eD=function(t,n){return{top:t.top+n.y,left:t.left+n.x,bottom:t.bottom+n.y,right:t.right+n.x}},ug={top:0,right:0,bottom:0,left:0},w0=function(t){var n=t.borderBox,r=t.margin,i=r===void 0?ug:r,o=t.border,a=o===void 0?ug:o,u=t.padding,d=u===void 0?ug:u,m=Ei(S0(n,i)),p=Ei(fS(n,a)),h=Ei(fS(p,d));return{marginBox:m,borderBox:Ei(n),paddingBox:p,contentBox:h,margin:i,border:a,padding:d}},pi=function(t){var n=t.slice(0,-2),r=t.slice(-2);if(r!=="px")return 0;var i=Number(n);return isNaN(i)&&J5(),i},tD=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Df=function(t,n){var r=t.borderBox,i=t.border,o=t.margin,a=t.padding,u=eD(r,n);return w0({borderBox:u,border:i,margin:o,padding:a})},Of=function(t,n){return n===void 0&&(n=tD()),Df(t,n)},Jj=function(t,n){var r={top:pi(n.marginTop),right:pi(n.marginRight),bottom:pi(n.marginBottom),left:pi(n.marginLeft)},i={top:pi(n.paddingTop),right:pi(n.paddingRight),bottom:pi(n.paddingBottom),left:pi(n.paddingLeft)},o={top:pi(n.borderTopWidth),right:pi(n.borderRightWidth),bottom:pi(n.borderBottomWidth),left:pi(n.borderLeftWidth)};return w0({borderBox:t,margin:r,padding:i,border:o})},eE=function(t){var n=t.getBoundingClientRect(),r=window.getComputedStyle(t);return Jj(n,r)},Jc=function(t){var n=[],r=null,i=function(){for(var a=arguments.length,u=new Array(a),d=0;d<a;d++)u[d]=arguments[d];n=u,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return i.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},i};function Lf(){return Lf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lf.apply(null,arguments)}function tE(e,t){}tE.bind(null,"warn");tE.bind(null,"error");function ao(){}function nD(e,t){return{...e,...t}}function vi(e,t,n){const r=t.map(i=>{const o=nD(n,i.options);return e.addEventListener(i.eventName,i.fn,o),function(){e.removeEventListener(i.eventName,i.fn,o)}});return function(){r.forEach(o=>{o()})}}const rD="Invariant failed";class zf extends Error{}zf.prototype.toString=function(){return this.message};function Le(e,t){throw new zf(rD)}let iD=class extends St.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=ao,this.onWindowError=n=>{const r=this.getCallbacks();r.isDragging()&&r.tryAbort(),n.error instanceof zf&&n.preventDefault()},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=n=>{this.callbacks=n}}componentDidMount(){this.unbind=vi(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof zf){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}};const sD=` `),we}Mf(()=>{te.current=void 0,P.current=void 0,G.current=de});const se=j.useMemo(()=>j.createElement(S,{...de,ref:L}),[L,S,de]);return j.useMemo(()=>v?j.createElement(M.Provider,{value:q},se):se,[M,se,q])}const I=j.memo(N);if(I.WrappedComponent=S,I.displayName=N.displayName=w,d){const T=j.forwardRef(function(A,M){return j.createElement(I,{...A,reactReduxForwardedRef:M})});return T.displayName=w,T.WrappedComponent=S,ky(T,S)}return ky(I,S)}}var Qj=X5;function K5(e){const{children:t,context:n,serverState:r,store:i}=e,o=j.useMemo(()=>{const d=Xj(i);return{store:i,subscription:d,getServerState:r?()=>r:void 0}},[i,r]),a=j.useMemo(()=>i.getState(),[i]);Mf(()=>{const{subscription:d}=o;return d.onStateChange=d.notifyNestedSubs,d.trySubscribe(),a!==i.getState()&&d.notifyNestedSubs(),()=>{d.tryUnsubscribe(),d.onStateChange=void 0}},[o,a]);const u=n||Zj;return j.createElement(u.Provider,{value:o},t)}var Z5=K5,Q5="Invariant failed";function J5(e,t){throw new Error(Q5)}var Ei=function(t){var n=t.top,r=t.right,i=t.bottom,o=t.left,a=r-o,u=i-n,d={top:n,right:r,bottom:i,left:o,width:a,height:u,x:o,y:n,center:{x:(r+o)/2,y:(i+n)/2}};return d},S0=function(t,n){return{top:t.top-n.top,left:t.left-n.left,bottom:t.bottom+n.bottom,right:t.right+n.right}},fS=function(t,n){return{top:t.top+n.top,left:t.left+n.left,bottom:t.bottom-n.bottom,right:t.right-n.right}},eD=function(t,n){return{top:t.top+n.y,left:t.left+n.x,bottom:t.bottom+n.y,right:t.right+n.x}},ug={top:0,right:0,bottom:0,left:0},w0=function(t){var n=t.borderBox,r=t.margin,i=r===void 0?ug:r,o=t.border,a=o===void 0?ug:o,u=t.padding,d=u===void 0?ug:u,m=Ei(S0(n,i)),p=Ei(fS(n,a)),h=Ei(fS(p,d));return{marginBox:m,borderBox:Ei(n),paddingBox:p,contentBox:h,margin:i,border:a,padding:d}},pi=function(t){var n=t.slice(0,-2),r=t.slice(-2);if(r!=="px")return 0;var i=Number(n);return isNaN(i)&&J5(),i},tD=function(){return{x:window.pageXOffset,y:window.pageYOffset}},Df=function(t,n){var r=t.borderBox,i=t.border,o=t.margin,a=t.padding,u=eD(r,n);return w0({borderBox:u,border:i,margin:o,padding:a})},Of=function(t,n){return n===void 0&&(n=tD()),Df(t,n)},Jj=function(t,n){var r={top:pi(n.marginTop),right:pi(n.marginRight),bottom:pi(n.marginBottom),left:pi(n.marginLeft)},i={top:pi(n.paddingTop),right:pi(n.paddingRight),bottom:pi(n.paddingBottom),left:pi(n.paddingLeft)},o={top:pi(n.borderTopWidth),right:pi(n.borderRightWidth),bottom:pi(n.borderBottomWidth),left:pi(n.borderLeftWidth)};return w0({borderBox:t,margin:r,padding:i,border:o})},eE=function(t){var n=t.getBoundingClientRect(),r=window.getComputedStyle(t);return Jj(n,r)},Jc=function(t){var n=[],r=null,i=function(){for(var a=arguments.length,u=new Array(a),d=0;d<a;d++)u[d]=arguments[d];n=u,!r&&(r=requestAnimationFrame(function(){r=null,t.apply(void 0,n)}))};return i.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},i};function Lf(){return Lf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lf.apply(null,arguments)}function tE(e,t){}tE.bind(null,"warn");tE.bind(null,"error");function ao(){}function nD(e,t){return{...e,...t}}function vi(e,t,n){const r=t.map(i=>{const o=nD(n,i.options);return e.addEventListener(i.eventName,i.fn,o),function(){e.removeEventListener(i.eventName,i.fn,o)}});return function(){r.forEach(o=>{o()})}}const rD="Invariant failed";class zf extends Error{}zf.prototype.toString=function(){return this.message};function Le(e,t){throw new zf(rD)}let iD=class extends St.Component{constructor(...t){super(...t),this.callbacks=null,this.unbind=ao,this.onWindowError=n=>{const r=this.getCallbacks();r.isDragging()&&r.tryAbort(),n.error instanceof zf&&n.preventDefault()},this.getCallbacks=()=>{if(!this.callbacks)throw new Error("Unable to find AppCallbacks in <ErrorBoundary/>");return this.callbacks},this.setCallbacks=n=>{this.callbacks=n}}componentDidMount(){this.unbind=vi(window,[{eventName:"error",fn:this.onWindowError}])}componentDidCatch(t){if(t instanceof zf){this.setState({});return}throw t}componentWillUnmount(){this.unbind()}render(){return this.props.children(this.setCallbacks)}};const sD=`
Press space bar to start a drag. Press space bar to start a drag.
When dragging you can use the arrow keys to move the item around and escape to cancel. When dragging you can use the arrow keys to move the item around and escape to cancel.
Some screen readers may require you to be in focus mode or to use your pass through key Some screen readers may require you to be in focus mode or to use your pass through key
@@ -57,7 +57,7 @@ ${te.current.stack}
`:` `:`
The item has been dropped while not over a drop area. The item has been dropped while not over a drop area.
${mS(e.source)} ${mS(e.source)}
`},xf={dragHandleUsageInstructions:sD,onDragStart:oD,onDragUpdate:aD,onDragEnd:lD};function cD(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function iE(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!cD(e[n],t[n]))return!1;return!0}function $t(e,t){const n=E.useState(()=>({inputs:t,result:e()}))[0],r=E.useRef(!0),i=E.useRef(n),a=r.current||!!(t&&i.current.inputs&&iE(t,i.current.inputs))?i.current:{inputs:t,result:e()};return E.useEffect(()=>{r.current=!1,i.current=a},[a]),a.result}function st(e,t){return $t(()=>e,t)}const or={x:0,y:0},mr=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Qr=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),lo=(e,t)=>e.x===t.x&&e.y===t.y,kl=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),Fo=(e,t,n=0)=>e==="x"?{x:t,y:n}:{x:n,y:t},eu=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),hS=(e,t)=>Math.min(...t.map(n=>eu(e,n))),sE=e=>t=>({x:e(t.x),y:e(t.y)});var uD=(e,t)=>{const n=Ei({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return n.width<=0||n.height<=0?null:n};const vu=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),pS=e=>[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.left,y:e.bottom},{x:e.right,y:e.bottom}],dD={top:0,right:0,bottom:0,left:0},fD=(e,t)=>t?vu(e,t.scroll.diff.displacement):e,mD=(e,t,n)=>n&&n.increasedBy?{...e,[t.end]:e[t.end]+n.increasedBy[t.line]}:e,hD=(e,t)=>t&&t.shouldClipSubject?uD(t.pageMarginBox,e):Ei(e);var ol=({page:e,withPlaceholder:t,axis:n,frame:r})=>{const i=fD(e.marginBox,r),o=mD(i,n,t),a=hD(o,r);return{page:e,withPlaceholder:t,active:a}},C0=(e,t)=>{e.frame||Le();const n=e.frame,r=Qr(t,n.scroll.initial),i=kl(r),o={...n,scroll:{initial:n.scroll.initial,current:t,diff:{value:r,displacement:i},max:n.scroll.max}},a=ol({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:o});return{...e,frame:o,subject:a}};function sr(e,t=iE){let n=null;function r(...i){if(n&&n.lastThis===this&&t(i,n.lastArgs))return n.lastResult;const o=e.apply(this,i);return n={lastResult:o,lastArgs:i,lastThis:this},o}return r.clear=function(){n=null},r}const oE=sr(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),aE=sr(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),vm=sr(e=>Object.values(e)),pD=sr(e=>Object.values(e));var Sl=sr((e,t)=>pD(t).filter(r=>e===r.descriptor.droppableId).sort((r,i)=>r.descriptor.index-i.descriptor.index));function j0(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function bm(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var _m=sr((e,t)=>t.filter(n=>n.descriptor.id!==e.descriptor.id)),gD=({isMovingForward:e,draggable:t,destination:n,insideDestination:r,previousImpact:i})=>{if(!n.isCombineEnabled||!j0(i))return null;function a(y){const v={type:"COMBINE",combine:{draggableId:y,droppableId:n.descriptor.id}};return{...i,at:v}}const u=i.displaced.all,d=u.length?u[0]:null;if(e)return d?a(d):null;const m=_m(t,r);if(!d){if(!m.length)return null;const y=m[m.length-1];return a(y.descriptor.id)}const p=m.findIndex(y=>y.descriptor.id===d);p===-1&&Le();const h=p-1;if(h<0)return null;const g=m[h];return a(g.descriptor.id)},wl=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const lE={point:or,value:0},tu={invisible:{},visible:{},all:[]},xD={displaced:tu,displacedBy:lE,at:null};var bi=(e,t)=>n=>e<=n&&n<=t,cE=e=>{const t=bi(e.top,e.bottom),n=bi(e.left,e.right);return r=>{if(t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right))return!0;const o=t(r.top)||t(r.bottom),a=n(r.left)||n(r.right);if(o&&a)return!0;const d=r.top<e.top&&r.bottom>e.bottom,m=r.left<e.left&&r.right>e.right;return d&&m?!0:d&&a||m&&o}},yD=e=>{const t=bi(e.top,e.bottom),n=bi(e.left,e.right);return r=>t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right)};const E0={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},uE={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var vD=e=>t=>{const n=bi(t.top,t.bottom),r=bi(t.left,t.right);return i=>e===E0?n(i.top)&&n(i.bottom):r(i.left)&&r(i.right)};const bD=(e,t)=>{const n=t.frame?t.frame.scroll.diff.displacement:or;return vu(e,n)},_D=(e,t,n)=>t.subject.active?n(t.subject.active)(e):!1,kD=(e,t,n)=>n(t)(e),N0=({target:e,destination:t,viewport:n,withDroppableDisplacement:r,isVisibleThroughFrameFn:i})=>{const o=r?bD(e,t):e;return _D(o,t,i)&&kD(o,n,i)},SD=e=>N0({...e,isVisibleThroughFrameFn:cE}),dE=e=>N0({...e,isVisibleThroughFrameFn:yD}),wD=e=>N0({...e,isVisibleThroughFrameFn:vD(e.destination.axis)}),CD=(e,t,n)=>{if(typeof n=="boolean")return n;if(!t)return!0;const{invisible:r,visible:i}=t;if(r[e])return!1;const o=i[e];return o?o.shouldAnimate:!0};function jD(e,t){const n=e.page.marginBox,r={top:t.point.y,right:0,bottom:0,left:t.point.x};return Ei(S0(n,r))}function nu({afterDragging:e,destination:t,displacedBy:n,viewport:r,forceShouldAnimate:i,la Line truncated `},xf={dragHandleUsageInstructions:sD,onDragStart:oD,onDragUpdate:aD,onDragEnd:lD};function cD(e,t){return!!(e===t||Number.isNaN(e)&&Number.isNaN(t))}function iE(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!cD(e[n],t[n]))return!1;return!0}function $t(e,t){const n=j.useState(()=>({inputs:t,result:e()}))[0],r=j.useRef(!0),i=j.useRef(n),a=r.current||!!(t&&i.current.inputs&&iE(t,i.current.inputs))?i.current:{inputs:t,result:e()};return j.useEffect(()=>{r.current=!1,i.current=a},[a]),a.result}function st(e,t){return $t(()=>e,t)}const or={x:0,y:0},mr=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),Qr=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),lo=(e,t)=>e.x===t.x&&e.y===t.y,kl=e=>({x:e.x!==0?-e.x:0,y:e.y!==0?-e.y:0}),Fo=(e,t,n=0)=>e==="x"?{x:t,y:n}:{x:n,y:t},eu=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),hS=(e,t)=>Math.min(...t.map(n=>eu(e,n))),sE=e=>t=>({x:e(t.x),y:e(t.y)});var uD=(e,t)=>{const n=Ei({top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom),left:Math.max(t.left,e.left)});return n.width<=0||n.height<=0?null:n};const vu=(e,t)=>({top:e.top+t.y,left:e.left+t.x,bottom:e.bottom+t.y,right:e.right+t.x}),pS=e=>[{x:e.left,y:e.top},{x:e.right,y:e.top},{x:e.left,y:e.bottom},{x:e.right,y:e.bottom}],dD={top:0,right:0,bottom:0,left:0},fD=(e,t)=>t?vu(e,t.scroll.diff.displacement):e,mD=(e,t,n)=>n&&n.increasedBy?{...e,[t.end]:e[t.end]+n.increasedBy[t.line]}:e,hD=(e,t)=>t&&t.shouldClipSubject?uD(t.pageMarginBox,e):Ei(e);var ol=({page:e,withPlaceholder:t,axis:n,frame:r})=>{const i=fD(e.marginBox,r),o=mD(i,n,t),a=hD(o,r);return{page:e,withPlaceholder:t,active:a}},C0=(e,t)=>{e.frame||Le();const n=e.frame,r=Qr(t,n.scroll.initial),i=kl(r),o={...n,scroll:{initial:n.scroll.initial,current:t,diff:{value:r,displacement:i},max:n.scroll.max}},a=ol({page:e.subject.page,withPlaceholder:e.subject.withPlaceholder,axis:e.axis,frame:o});return{...e,frame:o,subject:a}};function sr(e,t=iE){let n=null;function r(...i){if(n&&n.lastThis===this&&t(i,n.lastArgs))return n.lastResult;const o=e.apply(this,i);return n={lastResult:o,lastArgs:i,lastThis:this},o}return r.clear=function(){n=null},r}const oE=sr(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),aE=sr(e=>e.reduce((t,n)=>(t[n.descriptor.id]=n,t),{})),vm=sr(e=>Object.values(e)),pD=sr(e=>Object.values(e));var Sl=sr((e,t)=>pD(t).filter(r=>e===r.descriptor.droppableId).sort((r,i)=>r.descriptor.index-i.descriptor.index));function j0(e){return e.at&&e.at.type==="REORDER"?e.at.destination:null}function bm(e){return e.at&&e.at.type==="COMBINE"?e.at.combine:null}var _m=sr((e,t)=>t.filter(n=>n.descriptor.id!==e.descriptor.id)),gD=({isMovingForward:e,draggable:t,destination:n,insideDestination:r,previousImpact:i})=>{if(!n.isCombineEnabled||!j0(i))return null;function a(y){const v={type:"COMBINE",combine:{draggableId:y,droppableId:n.descriptor.id}};return{...i,at:v}}const u=i.displaced.all,d=u.length?u[0]:null;if(e)return d?a(d):null;const m=_m(t,r);if(!d){if(!m.length)return null;const y=m[m.length-1];return a(y.descriptor.id)}const p=m.findIndex(y=>y.descriptor.id===d);p===-1&&Le();const h=p-1;if(h<0)return null;const g=m[h];return a(g.descriptor.id)},wl=(e,t)=>e.descriptor.droppableId===t.descriptor.id;const lE={point:or,value:0},tu={invisible:{},visible:{},all:[]},xD={displaced:tu,displacedBy:lE,at:null};var bi=(e,t)=>n=>e<=n&&n<=t,cE=e=>{const t=bi(e.top,e.bottom),n=bi(e.left,e.right);return r=>{if(t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right))return!0;const o=t(r.top)||t(r.bottom),a=n(r.left)||n(r.right);if(o&&a)return!0;const d=r.top<e.top&&r.bottom>e.bottom,m=r.left<e.left&&r.right>e.right;return d&&m?!0:d&&a||m&&o}},yD=e=>{const t=bi(e.top,e.bottom),n=bi(e.left,e.right);return r=>t(r.top)&&t(r.bottom)&&n(r.left)&&n(r.right)};const E0={direction:"vertical",line:"y",crossAxisLine:"x",start:"top",end:"bottom",size:"height",crossAxisStart:"left",crossAxisEnd:"right",crossAxisSize:"width"},uE={direction:"horizontal",line:"x",crossAxisLine:"y",start:"left",end:"right",size:"width",crossAxisStart:"top",crossAxisEnd:"bottom",crossAxisSize:"height"};var vD=e=>t=>{const n=bi(t.top,t.bottom),r=bi(t.left,t.right);return i=>e===E0?n(i.top)&&n(i.bottom):r(i.left)&&r(i.right)};const bD=(e,t)=>{const n=t.frame?t.frame.scroll.diff.displacement:or;return vu(e,n)},_D=(e,t,n)=>t.subject.active?n(t.subject.active)(e):!1,kD=(e,t,n)=>n(t)(e),N0=({target:e,destination:t,viewport:n,withDroppableDisplacement:r,isVisibleThroughFrameFn:i})=>{const o=r?bD(e,t):e;return _D(o,t,i)&&kD(o,n,i)},SD=e=>N0({...e,isVisibleThroughFrameFn:cE}),dE=e=>N0({...e,isVisibleThroughFrameFn:yD}),wD=e=>N0({...e,isVisibleThroughFrameFn:vD(e.destination.axis)}),CD=(e,t,n)=>{if(typeof n=="boolean")return n;if(!t)return!0;const{invisible:r,visible:i}=t;if(r[e])return!1;const o=i[e];return o?o.shouldAnimate:!0};function jD(e,t){const n=e.page.marginBox,r={top:t.point.y,right:0,bottom:0,left:t.point.x};return Ei(S0(n,r))}function nu({afterDragging:e,destination:t,displacedBy:n,viewport:r,forceShouldAnimate:i,la Line truncated
cursor: -webkit-grab; cursor: -webkit-grab;
cursor: grab; cursor: grab;
`;return{selector:t(ll.contextId),styles:{always:` `;return{selector:t(ll.contextId),styles:{always:`
@@ -74,21 +74,21 @@ ${te.current.stack}
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
overflow-anchor: none; overflow-anchor: none;
`}}];return{always:bc(a,"always"),resting:bc(a,"resting"),dragging:bc(a,"dragging"),dropAnimating:bc(a,"dropAnimating"),userCancel:bc(a,"userCancel")}};const ei=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?E.useLayoutEffect:E.useEffect,pg=()=>{const e=document.querySelector("head");return e||Le(),e},IS=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function IL(e,t){const n=$t(()=>NL(e),[e]),r=E.useRef(null),i=E.useRef(null),o=st(sr(h=>{const g=i.current;g||Le(),g.textContent=h}),[]),a=st(h=>{const g=r.current;g||Le(),g.textContent=h},[]);ei(()=>{!r.current&&!i.current||Le();const h=IS(t),g=IS(t);return r.current=h,i.current=g,h.setAttribute(`${al}-always`,e),g.setAttribute(`${al}-dynamic`,e),pg().appendChild(h),pg().appendChild(g),a(n.always),o(n.resting),()=>{const y=v=>{const w=v.current;w||Le(),pg().removeChild(w),v.current=null};y(r),y(i)}},[t,a,o,n.always,n.resting,e]);const u=st(()=>o(n.dragging),[o,n.dragging]),d=st(h=>{if(h==="DROP"){o(n.dropAnimating);return}o(n.userCancel)},[o,n.dropAnimating,n.userCancel]),m=st(()=>{i.current&&o(n.resting)},[o,n.resting]);return $t(()=>({dragging:u,dropping:d,resting:m}),[u,d,m])}function PE(e,t){return Array.from(e.querySelectorAll(t))}var BE=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function Sm(e){return e instanceof BE(e).HTMLElement}function TL(e,t){const n=`[${ll.contextId}="${e}"]`,r=PE(document,n);if(!r.length)return null;const i=r.find(o=>o.getAttribute(ll.draggableId)===t);return!i||!Sm(i)?null:i}function RL(e){const t=E.useRef({}),n=E.useRef(null),r=E.useRef(null),i=E.useRef(!1),o=st(function(g,y){const v={id:g,focus:y};return t.current[g]=v,function(){const S=t.current;S[g]!==v&&delete S[g]}},[]),a=st(function(g){const y=TL(e,g);y&&y!==document.activeElement&&y.focus()},[e]),u=st(function(g,y){n.current===g&&(n.current=y)},[]),d=st(function(){r.current||i.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const g=n.current;g&&a(g)}))},[a]),m=st(function(g){n.current=null;const y=document.activeElement;y&&y.getAttribute(ll.draggableId)===g&&(n.current=g)},[]);return ei(()=>(i.current=!0,function(){i.current=!1;const g=r.current;g&&cancelAnimationFrame(g)}),[]),$t(()=>({register:o,tryRecordFocus:m,tryRestoreFocusRecorded:d,tryShiftRecord:u}),[o,m,d,u])}function AL(){const e={draggables:{},droppables:{}},t=[];function n(h){return t.push(h),function(){const y=t.indexOf(h);y!==-1&&t.splice(y,1)}}function r(h){t.length&&t.forEach(g=>g(h))}function i(h){return e.draggables[h]||null}function o(h){const g=i(h);return g||Le(),g}const a={register:h=>{e.draggables[h.descriptor.id]=h,r({type:"ADDITION",value:h})},update:(h,g)=>{const y=e.draggables[g.descriptor.id];y&&y.uniqueId===h.uniqueId&&(delete e.draggables[g.descriptor.id],e.draggables[h.descriptor.id]=h)},unregister:h=>{const g=h.descriptor.id,y=i(g);y&&h.uniqueId===y.uniqueId&&(delete e.draggables[g],e.droppables[h.descriptor.droppableId]&&r({type:"REMOVAL",value:h}))},getById:o,findById:i,exists:h=>!!i(h),getAllByType:h=>Object.values(e.draggables).filter(g=>g.descriptor.type===h)};function u(h){return e.droppables[h]||null}function d(h){const g=u(h);return g||Le(),g}const m={register:h=>{e.droppables[h.descriptor.id]=h},unregister:h=>{const g=u(h.descriptor.id);g&&h.uniqueId===g.uniqueId&&delete e.droppables[h.descriptor.id]},getById:d,findById:u,exists:h=>!!u(h),getAllByType:h=>Object.values(e.droppables).filter(g=>g.descriptor.type===h)};function p(){e.draggables={},e.droppables={},t.length=0}return{draggable:a,droppable:m,subscribe:n,clean:p}}function ML(){const e=$t(AL,[]);return E.useEffect(()=>function(){e.clean()},[e]),e}var B0=St.createContext(null),$f=()=>{const e=document.body;return e||Le(),e};const DL={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},OL=e=>`rfd-announcement-${e}`;function LL(e){const t=$t(()=>OL(e),[e]),n=E.useRef(null);return E.useEffect(function(){const o=document.createElement("div");return n.current=o,o.id=t,o.setAttribute("aria-live","assertive"),o.setAttribute("aria-atomic","true"),Lf(o.style,DL),$f().appendChild(o),function(){setTimeout(function(){const d=$f();d.contains(o)&&d.removeChild(o),o===n.current&&(n.current=null)})}},[t]),st(i=>{const o=n.current;if(o){o.textContent=i;return}},[])}const zL={separator:"::"};function $0(e,t=zL){const n=St.useId();return $t(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function PL({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function BL({contextId:e,text:t}){const n=$0("hidden-text",{separator:"-"}),r=$t(()=>PL({contextId:e,uniqueId:n}),[n,e]);return E.useEffect(function(){const o=document.createElement("div");return o.id=r,o.textContent=t,o.style.display="none",$f().appendChild(o),function(){const u=$f();u.contains(o)&&u.removeChild(o)}},[r,t]),r}var wm=St.c Line truncated `}}];return{always:bc(a,"always"),resting:bc(a,"resting"),dragging:bc(a,"dragging"),dropAnimating:bc(a,"dropAnimating"),userCancel:bc(a,"userCancel")}};const ei=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?j.useLayoutEffect:j.useEffect,pg=()=>{const e=document.querySelector("head");return e||Le(),e},IS=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function IL(e,t){const n=$t(()=>NL(e),[e]),r=j.useRef(null),i=j.useRef(null),o=st(sr(h=>{const g=i.current;g||Le(),g.textContent=h}),[]),a=st(h=>{const g=r.current;g||Le(),g.textContent=h},[]);ei(()=>{!r.current&&!i.current||Le();const h=IS(t),g=IS(t);return r.current=h,i.current=g,h.setAttribute(`${al}-always`,e),g.setAttribute(`${al}-dynamic`,e),pg().appendChild(h),pg().appendChild(g),a(n.always),o(n.resting),()=>{const y=v=>{const k=v.current;k||Le(),pg().removeChild(k),v.current=null};y(r),y(i)}},[t,a,o,n.always,n.resting,e]);const u=st(()=>o(n.dragging),[o,n.dragging]),d=st(h=>{if(h==="DROP"){o(n.dropAnimating);return}o(n.userCancel)},[o,n.dropAnimating,n.userCancel]),m=st(()=>{i.current&&o(n.resting)},[o,n.resting]);return $t(()=>({dragging:u,dropping:d,resting:m}),[u,d,m])}function PE(e,t){return Array.from(e.querySelectorAll(t))}var BE=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function Sm(e){return e instanceof BE(e).HTMLElement}function TL(e,t){const n=`[${ll.contextId}="${e}"]`,r=PE(document,n);if(!r.length)return null;const i=r.find(o=>o.getAttribute(ll.draggableId)===t);return!i||!Sm(i)?null:i}function RL(e){const t=j.useRef({}),n=j.useRef(null),r=j.useRef(null),i=j.useRef(!1),o=st(function(g,y){const v={id:g,focus:y};return t.current[g]=v,function(){const S=t.current;S[g]!==v&&delete S[g]}},[]),a=st(function(g){const y=TL(e,g);y&&y!==document.activeElement&&y.focus()},[e]),u=st(function(g,y){n.current===g&&(n.current=y)},[]),d=st(function(){r.current||i.current&&(r.current=requestAnimationFrame(()=>{r.current=null;const g=n.current;g&&a(g)}))},[a]),m=st(function(g){n.current=null;const y=document.activeElement;y&&y.getAttribute(ll.draggableId)===g&&(n.current=g)},[]);return ei(()=>(i.current=!0,function(){i.current=!1;const g=r.current;g&&cancelAnimationFrame(g)}),[]),$t(()=>({register:o,tryRecordFocus:m,tryRestoreFocusRecorded:d,tryShiftRecord:u}),[o,m,d,u])}function AL(){const e={draggables:{},droppables:{}},t=[];function n(h){return t.push(h),function(){const y=t.indexOf(h);y!==-1&&t.splice(y,1)}}function r(h){t.length&&t.forEach(g=>g(h))}function i(h){return e.draggables[h]||null}function o(h){const g=i(h);return g||Le(),g}const a={register:h=>{e.draggables[h.descriptor.id]=h,r({type:"ADDITION",value:h})},update:(h,g)=>{const y=e.draggables[g.descriptor.id];y&&y.uniqueId===h.uniqueId&&(delete e.draggables[g.descriptor.id],e.draggables[h.descriptor.id]=h)},unregister:h=>{const g=h.descriptor.id,y=i(g);y&&h.uniqueId===y.uniqueId&&(delete e.draggables[g],e.droppables[h.descriptor.droppableId]&&r({type:"REMOVAL",value:h}))},getById:o,findById:i,exists:h=>!!i(h),getAllByType:h=>Object.values(e.draggables).filter(g=>g.descriptor.type===h)};function u(h){return e.droppables[h]||null}function d(h){const g=u(h);return g||Le(),g}const m={register:h=>{e.droppables[h.descriptor.id]=h},unregister:h=>{const g=u(h.descriptor.id);g&&h.uniqueId===g.uniqueId&&delete e.droppables[h.descriptor.id]},getById:d,findById:u,exists:h=>!!u(h),getAllByType:h=>Object.values(e.droppables).filter(g=>g.descriptor.type===h)};function p(){e.draggables={},e.droppables={},t.length=0}return{draggable:a,droppable:m,subscribe:n,clean:p}}function ML(){const e=$t(AL,[]);return j.useEffect(()=>function(){e.clean()},[e]),e}var B0=St.createContext(null),$f=()=>{const e=document.body;return e||Le(),e};const DL={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},OL=e=>`rfd-announcement-${e}`;function LL(e){const t=$t(()=>OL(e),[e]),n=j.useRef(null);return j.useEffect(function(){const o=document.createElement("div");return n.current=o,o.id=t,o.setAttribute("aria-live","assertive"),o.setAttribute("aria-atomic","true"),Lf(o.style,DL),$f().appendChild(o),function(){setTimeout(function(){const d=$f();d.contains(o)&&d.removeChild(o),o===n.current&&(n.current=null)})}},[t]),st(i=>{const o=n.current;if(o){o.textContent=i;return}},[])}const zL={separator:"::"};function $0(e,t=zL){const n=St.useId();return $t(()=>`${e}${t.separator}${n}`,[t.separator,e,n])}function PL({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function BL({contextId:e,text:t}){const n=$0("hidden-text",{separator:"-"}),r=$t(()=>PL({contextId:e,uniqueId:n}),[n,e]);return j.useEffect(function(){const o=document.createElement("div");return o.id=r,o.textContent=t,o.style.display="none",$f().appendChild(o),function(){const u=$f();u.contains(o)&&u.removeChild(o)}},[r,t]),r}var wm=St.c Line truncated
`,m="/",p="*",h="",g="comment",y="declaration";function v(S,_){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];_=_||{};var k=1,C=1;function N(B){var U=B.match(t);U&&(k+=U.length);var H=B.lastIndexOf(d);C=~H?B.length-H:C+B.length}function O(){var B={line:k,column:C};return function(U){return U.position=new I(B),L(),U}}function I(B){this.start=B,this.end={line:k,column:C},this.source=_.source}I.prototype.content=S;function D(B){var U=new Error(_.source+":"+k+":"+C+": "+B);if(U.reason=B,U.filename=_.source,U.line=k,U.column=C,U.source=S,!_.silent)throw U}function T(B){var U=B.exec(S);if(U){var H=U[0];return N(H),S=S.slice(H.length),U}}function L(){T(n)}function A(B){var U;for(B=B||[];U=M();)U!==!1&&B.push(U);return B}function M(){var B=O();if(!(m!=S.charAt(0)||p!=S.charAt(1))){for(var U=2;h!=S.charAt(U)&&(p!=S.charAt(U)||m!=S.charAt(U+1));)++U;if(U+=2,h===S.charAt(U-1))return D("End of comment missing");var H=S.slice(2,U-2);return C+=2,N(H),S=S.slice(U),C+=2,B({type:g,comment:H})}}function $(){var B=O(),U=T(r);if(U){if(M(),!T(i))return D("property missing ':'");var H=T(o),V=B({type:y,property:w(U[0].replace(e,h)),value:H?w(H[0].replace(e,h)):h});return T(a),V}}function W(){var B=[];A(B);for(var U;U=$();)U!==!1&&(B.push(U),A(B));return B}return L(),W()}function w(S){return S?S.replace(u,h):h}return wg=v,wg}var WS;function sz(){if(WS)return Ba;WS=1;var e=Ba&&Ba.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ba,"__esModule",{value:!0}),Ba.default=n;const t=e(iz());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,t.default)(r),u=typeof i=="function";return a.forEach(d=>{if(d.type!=="declaration")return;const{property:m,value:p}=d;u?i(m,p,d):p&&(o=o||{},o[m]=p)}),o}return Ba}var wc={},YS;function oz(){if(YS)return wc;YS=1,Object.defineProperty(wc,"__esModule",{value:!0}),wc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(m){return!m||n.test(m)||e.test(m)},a=function(m,p){return p.toUpperCase()},u=function(m,p){return"".concat(p,"-")},d=function(m,p){return p===void 0&&(p={}),o(m)?m:(m=m.toLowerCase(),p.reactCompat?m=m.replace(i,u):m=m.replace(r,u),m.replace(t,a))};return wc.camelCase=d,wc}var Cc,XS;function az(){if(XS)return Cc;XS=1;var e=Cc&&Cc.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(sz()),n=oz();function r(i,o){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(u,d){u&&d&&(a[(0,n.camelCase)(u,o)]=d)}),a}return r.default=r,Cc=r,Cc}var lz=az();const cz=Zo(lz),dN=fN("end"),q0=fN("start");function fN(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function uz(e){const t=q0(e),n=dN(e);if(t&&n)return{start:t,end:n}}function Vc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?KS(e.position):"start"in e||"end"in e?KS(e):"line"in e||"column"in e?Ay(e):""}function Ay(e){return ZS(e&&e.line)+":"+ZS(e&&e.column)}function KS(e){return Ay(e&&e.start)+"-"+Ay(e&&e.end)}function ZS(e){return e&&typeof e=="number"?e:1}class Sr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?o.ruleId=r:(o.source=r.slice(0,d),o.ruleId=r.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=u?u.line:void 0,this.name=Vc(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Sr.prototype.file="";Sr.prototype.name="";Sr.prototype.reason="";Sr.prototype.message="";Sr.prototype.stack="";Sr.prototype.column=void 0;Sr.prototype.line=void 0;Sr.prototype.ancestors=void 0;Sr.prototype.cause=void 0;Sr.prototype.fatal=void 0;Sr.prototype.place=void 0;Sr.prototype.ruleId=void 0;Sr.prototype.source=void 0;const W0={}.hasOwnProperty,dz=new Map,fz=/[A-Z]/g,mz=new Set(["table","tbody","thead","tfoot","tr"]),hz=new Set(["td","th"]),mN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function pz(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.j Line truncated `,m="/",p="*",h="",g="comment",y="declaration";function v(S,_){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];_=_||{};var w=1,C=1;function N(B){var U=B.match(t);U&&(w+=U.length);var H=B.lastIndexOf(d);C=~H?B.length-H:C+B.length}function O(){var B={line:w,column:C};return function(U){return U.position=new I(B),L(),U}}function I(B){this.start=B,this.end={line:w,column:C},this.source=_.source}I.prototype.content=S;function D(B){var U=new Error(_.source+":"+w+":"+C+": "+B);if(U.reason=B,U.filename=_.source,U.line=w,U.column=C,U.source=S,!_.silent)throw U}function T(B){var U=B.exec(S);if(U){var H=U[0];return N(H),S=S.slice(H.length),U}}function L(){T(n)}function A(B){var U;for(B=B||[];U=M();)U!==!1&&B.push(U);return B}function M(){var B=O();if(!(m!=S.charAt(0)||p!=S.charAt(1))){for(var U=2;h!=S.charAt(U)&&(p!=S.charAt(U)||m!=S.charAt(U+1));)++U;if(U+=2,h===S.charAt(U-1))return D("End of comment missing");var H=S.slice(2,U-2);return C+=2,N(H),S=S.slice(U),C+=2,B({type:g,comment:H})}}function $(){var B=O(),U=T(r);if(U){if(M(),!T(i))return D("property missing ':'");var H=T(o),V=B({type:y,property:k(U[0].replace(e,h)),value:H?k(H[0].replace(e,h)):h});return T(a),V}}function W(){var B=[];A(B);for(var U;U=$();)U!==!1&&(B.push(U),A(B));return B}return L(),W()}function k(S){return S?S.replace(u,h):h}return wg=v,wg}var WS;function sz(){if(WS)return Ba;WS=1;var e=Ba&&Ba.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ba,"__esModule",{value:!0}),Ba.default=n;const t=e(iz());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const a=(0,t.default)(r),u=typeof i=="function";return a.forEach(d=>{if(d.type!=="declaration")return;const{property:m,value:p}=d;u?i(m,p,d):p&&(o=o||{},o[m]=p)}),o}return Ba}var wc={},YS;function oz(){if(YS)return wc;YS=1,Object.defineProperty(wc,"__esModule",{value:!0}),wc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(m){return!m||n.test(m)||e.test(m)},a=function(m,p){return p.toUpperCase()},u=function(m,p){return"".concat(p,"-")},d=function(m,p){return p===void 0&&(p={}),o(m)?m:(m=m.toLowerCase(),p.reactCompat?m=m.replace(i,u):m=m.replace(r,u),m.replace(t,a))};return wc.camelCase=d,wc}var Cc,XS;function az(){if(XS)return Cc;XS=1;var e=Cc&&Cc.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(sz()),n=oz();function r(i,o){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(u,d){u&&d&&(a[(0,n.camelCase)(u,o)]=d)}),a}return r.default=r,Cc=r,Cc}var lz=az();const cz=Zo(lz),dN=fN("end"),q0=fN("start");function fN(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function uz(e){const t=q0(e),n=dN(e);if(t&&n)return{start:t,end:n}}function Vc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?KS(e.position):"start"in e||"end"in e?KS(e):"line"in e||"column"in e?Ay(e):""}function Ay(e){return ZS(e&&e.line)+":"+ZS(e&&e.column)}function KS(e){return Ay(e&&e.start)+"-"+Ay(e&&e.end)}function ZS(e){return e&&typeof e=="number"?e:1}class Sr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?o.ruleId=r:(o.source=r.slice(0,d),o.ruleId=r.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=u?u.line:void 0,this.name=Vc(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Sr.prototype.file="";Sr.prototype.name="";Sr.prototype.reason="";Sr.prototype.message="";Sr.prototype.stack="";Sr.prototype.column=void 0;Sr.prototype.line=void 0;Sr.prototype.ancestors=void 0;Sr.prototype.cause=void 0;Sr.prototype.fatal=void 0;Sr.prototype.place=void 0;Sr.prototype.ruleId=void 0;Sr.prototype.source=void 0;const W0={}.hasOwnProperty,dz=new Map,fz=/[A-Z]/g,mz=new Set(["table","tbody","thead","tfoot","tr"]),hz=new Set(["td","th"]),mN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function pz(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.j Line truncated
`;break}case-3:{a=`\r `;break}case-3:{a=`\r
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}function SB(e){const r={constructs:yN([vB,...(e||{}).extensions||[]]),content:i(Pz),defined:[],document:i($z),flow:i(iB),lazy:{},string:i(aB),text:i(lB)};return r;function i(o){return a;function a(u){return bB(r,o,u)}}}function wB(e){for(;!SN(e););return e}const aw=/[\0\t\n\r]/g;function CB(){let e=1,t="",n=!0,r;return i;function i(o,a,u){const d=[];let m,p,h,g,y;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),h=0,t="",n&&(o.charCodeAt(0)===65279&&h++,n=void 0);h<o.length;){if(aw.lastIndex=h,m=aw.exec(o),g=m&&m.index!==void 0?m.index:o.length,y=o.charCodeAt(g),!m){t=o.slice(h);break}if(y===10&&h===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),h<g&&(d.push(o.slice(h,g)),e+=g-h),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}h=g+1}return u&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const jB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function EB(e){return e.replace(jB,NB)}function NB(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return vN(n.slice(o?2:1),o?16:10)}return Z0(n)||e}const IN={}.hasOwnProperty;function IB(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),TB(n)(wB(SB(n).document().write(CB()(e,t,!0))))}function TB(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(bt),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(Ge),blockQuote:o(se),characterEscape:L,characterReference:L,codeFenced:o(je),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(je,a),codeText:o(we,a),codeTextData:L,data:L,codeFlowValue:L,definition:o(Ce),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Be),hardBreakEscape:o(Ye),hardBreakTrailing:o(Ye),htmlFlow:o(yt,a),htmlFlowData:L,htmlText:o(yt,a),htmlTextData:L,image:o(Vt),label:a,link:o(bt),listItem:o(me),listItemValue:g,listOrdered:o(vt,h),listUnordered:o(vt),paragraph:o(Oe),reference:P,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ge),strong:o(rt),thematicBreak:o(Je)},exit:{atxHeading:d(),atxHeadingSequence:O,autolink:d(),autolinkEmail:de,autolinkProtocol:oe,blockQuote:d(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:te,characterReference:re,codeFenced:d(S),codeFencedFence:w,codeFencedFenceInfo:y,codeFencedFenceMeta:v,codeFlowValue:A,codeIndented:d(_),codeText:d(U),codeTextData:A,data:A,definition:d(),definitionDestinationString:N,definitionLabelString:k,definitionTitleString:C,emphasis:d(),hardBreakEscape:d($),hardBreakTrailing:d($),htmlFlow:d(W),htmlFlowData:A,htmlText:d(B),htmlTextData:A,image:d(V),label:Z,labelText:Y,lineEnding:M,link:d(H),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:X,resourceDestinationString:q,resourceTitleString:G,resource:J,setextHeading:d(T),setextHeadingLineSequence:D,setextHeadingText:I,strong:d(),thematicBreak:d()}};TN(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(fe){let be={type:"root",children:[]};const Me={stack:[be],tokenStack:[],config:t,enter:u,exit:m,buffer:a,resume:p,data:n},Fe=[];let $e=-1;for(;++$e<fe.length;)if(fe[$e][1].type==="listOrdered"||fe[$e][1].type==="listUnordered")if(fe[$e][0]==="enter")Fe.push($e);else{const Ut=Fe.pop();$e=i(fe,Ut,$e)}for($e=-1;++$e<fe.length;){const Ut=t[fe[$e][0]];IN.call(Ut,fe[$e][1].type)&&Ut[fe[$e][1].type].call(Object.assign({sliceSerialize:fe[$e][2].sliceSerialize},Me),fe[$e][1])}if(Me.tokenStack.length>0){const Ut=Me.tokenStack[Me.tokenStack.length-1];(Ut[1]||lw).call(Me,void 0,Ut[0])}for(be.position={start:to(fe.length>0?fe[0][1].start:{line:1,column:1,offset:0}),end:to(fe.length>0?fe[fe.length-2][1].end:{line:1,column:1,offset:0})},$e=-1;++$e<t.transforms.length;)be=t.transforms[$e](be)||be;return be}function i(fe,be,Me){let Fe=be-1,$e=-1,Ut=!1,rn,ke,Te,Pe;for(;++Fe<=Me;){const Ve=fe[Fe];switch(Ve[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ve[0]==="enter"?$e++:$e--,Pe=void 0;break}case"lineEndingBlank":{Ve[0]==="enter"&&(rn&&!Pe&&!$e&&!Te&&(Te=Fe),Pe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Pe=void 0}if(!$e&&Ve[0]==="enter"&&Ve[1].type==="listItemPrefix"||$e===-1&&Ve[0]==="exit"&&(Ve[1].type==="listUnordered"||Ve[1].type==="listOrdered")){if(rn){let qe=Fe;for(ke=void 0;qe--;){const et=fe[qe];if(et[1].type==="lineEnding"||et[1].type==="lineEndingBlank"){if(et[0]==="exit")continue;ke&&(fe[ke][1].type="lineEndingBlank",Ut=!0),et[1].type="lineEnding",ke=qe}else if(!(et[1].type==="linePrefix"||et[1].type==="blockQuotePrefix"||et[1].type==="blockQuotePrefixWhitespace"Line truncated `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}function SB(e){const r={constructs:yN([vB,...(e||{}).extensions||[]]),content:i(Pz),defined:[],document:i($z),flow:i(iB),lazy:{},string:i(aB),text:i(lB)};return r;function i(o){return a;function a(u){return bB(r,o,u)}}}function wB(e){for(;!SN(e););return e}const aw=/[\0\t\n\r]/g;function CB(){let e=1,t="",n=!0,r;return i;function i(o,a,u){const d=[];let m,p,h,g,y;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),h=0,t="",n&&(o.charCodeAt(0)===65279&&h++,n=void 0);h<o.length;){if(aw.lastIndex=h,m=aw.exec(o),g=m&&m.index!==void 0?m.index:o.length,y=o.charCodeAt(g),!m){t=o.slice(h);break}if(y===10&&h===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),h<g&&(d.push(o.slice(h,g)),e+=g-h),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}h=g+1}return u&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const jB=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function EB(e){return e.replace(jB,NB)}function NB(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return vN(n.slice(o?2:1),o?16:10)}return Z0(n)||e}const IN={}.hasOwnProperty;function IB(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),TB(n)(wB(SB(n).document().write(CB()(e,t,!0))))}function TB(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(bt),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(Ge),blockQuote:o(se),characterEscape:L,characterReference:L,codeFenced:o(je),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(je,a),codeText:o(we,a),codeTextData:L,data:L,codeFlowValue:L,definition:o(Ce),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Be),hardBreakEscape:o(Ye),hardBreakTrailing:o(Ye),htmlFlow:o(yt,a),htmlFlowData:L,htmlText:o(yt,a),htmlTextData:L,image:o(Vt),label:a,link:o(bt),listItem:o(me),listItemValue:g,listOrdered:o(vt,h),listUnordered:o(vt),paragraph:o(Oe),reference:P,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ge),strong:o(rt),thematicBreak:o(Je)},exit:{atxHeading:d(),atxHeadingSequence:O,autolink:d(),autolinkEmail:de,autolinkProtocol:oe,blockQuote:d(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:te,characterReference:re,codeFenced:d(S),codeFencedFence:k,codeFencedFenceInfo:y,codeFencedFenceMeta:v,codeFlowValue:A,codeIndented:d(_),codeText:d(U),codeTextData:A,data:A,definition:d(),definitionDestinationString:N,definitionLabelString:w,definitionTitleString:C,emphasis:d(),hardBreakEscape:d($),hardBreakTrailing:d($),htmlFlow:d(W),htmlFlowData:A,htmlText:d(B),htmlTextData:A,image:d(V),label:Z,labelText:Y,lineEnding:M,link:d(H),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:X,resourceDestinationString:q,resourceTitleString:G,resource:J,setextHeading:d(T),setextHeadingLineSequence:D,setextHeadingText:I,strong:d(),thematicBreak:d()}};TN(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(fe){let be={type:"root",children:[]};const Me={stack:[be],tokenStack:[],config:t,enter:u,exit:m,buffer:a,resume:p,data:n},Fe=[];let $e=-1;for(;++$e<fe.length;)if(fe[$e][1].type==="listOrdered"||fe[$e][1].type==="listUnordered")if(fe[$e][0]==="enter")Fe.push($e);else{const Ut=Fe.pop();$e=i(fe,Ut,$e)}for($e=-1;++$e<fe.length;){const Ut=t[fe[$e][0]];IN.call(Ut,fe[$e][1].type)&&Ut[fe[$e][1].type].call(Object.assign({sliceSerialize:fe[$e][2].sliceSerialize},Me),fe[$e][1])}if(Me.tokenStack.length>0){const Ut=Me.tokenStack[Me.tokenStack.length-1];(Ut[1]||lw).call(Me,void 0,Ut[0])}for(be.position={start:to(fe.length>0?fe[0][1].start:{line:1,column:1,offset:0}),end:to(fe.length>0?fe[fe.length-2][1].end:{line:1,column:1,offset:0})},$e=-1;++$e<t.transforms.length;)be=t.transforms[$e](be)||be;return be}function i(fe,be,Me){let Fe=be-1,$e=-1,Ut=!1,rn,ke,Te,Pe;for(;++Fe<=Me;){const Ve=fe[Fe];switch(Ve[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ve[0]==="enter"?$e++:$e--,Pe=void 0;break}case"lineEndingBlank":{Ve[0]==="enter"&&(rn&&!Pe&&!$e&&!Te&&(Te=Fe),Pe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Pe=void 0}if(!$e&&Ve[0]==="enter"&&Ve[1].type==="listItemPrefix"||$e===-1&&Ve[0]==="exit"&&(Ve[1].type==="listUnordered"||Ve[1].type==="listOrdered")){if(rn){let qe=Fe;for(ke=void 0;qe--;){const et=fe[qe];if(et[1].type==="lineEnding"||et[1].type==="lineEndingBlank"){if(et[0]==="exit")continue;ke&&(fe[ke][1].type="lineEndingBlank",Ut=!0),et[1].type="lineEnding",ke=qe}else if(!(et[1].type==="linePrefix"||et[1].type==="blockQuotePrefix"||et[1].type==="blockQuotePrefixWhitespace"Line truncated
`}]}function OB(e,t){const n=t.value?t.value+` `}]}function OB(e,t){const n=t.value?t.value+`
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function LB(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function zB(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PB(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=jl(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,u=e.footnoteCounts.get(r);u===void 0?(u=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,u+=1,e.footnoteCounts.set(r,u);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,d);const m={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,m),e.applyData(t,m)}function BB(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $B(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function RN(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function HB(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return RN(e,t);const i={src:jl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function FB(e,t){const n={src:jl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function VB(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function UB(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return RN(e,t);const i={href:jl(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function GB(e,t){const n={href:jl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function qB(e,t,n){const r=e.all(t),i=n?WB(n):AN(t),o={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let h;p&&p.type==="element"&&p.tagName==="p"?h=p:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u<r.length;){const p=r[u];(i||u!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:` `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function LB(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function zB(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PB(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=jl(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,u=e.footnoteCounts.get(r);u===void 0?(u=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,u+=1,e.footnoteCounts.set(r,u);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,d);const m={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,m),e.applyData(t,m)}function BB(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $B(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function RN(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function HB(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return RN(e,t);const i={src:jl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function FB(e,t){const n={src:jl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function VB(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function UB(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return RN(e,t);const i={href:jl(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function GB(e,t){const n={href:jl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function qB(e,t,n){const r=e.all(t),i=n?WB(n):AN(t),o={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let h;p&&p.type==="element"&&p.tagName==="p"?h=p:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u<r.length;){const p=r[u];(i||u!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
`}),p.type==="element"&&p.tagName==="p"&&!i?a.push(...p.children):a.push(p)}const d=r[r.length-1];d&&(i||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:` `}),p.type==="element"&&p.tagName==="p"&&!i?a.push(...p.children):a.push(p)}const d=r[r.length-1];d&&(i||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
`});const m={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,m),e.applyData(t,m)}function WB(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=AN(n[r])}return t}function AN(e){const t=e.spread;return t??e.children.length>1}function YB(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function XB(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function KB(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function ZB(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function QB(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},u=q0(t.children[1]),d=dN(t.children[t.children.length-1]);u&&d&&(a.position={start:u,end:d}),i.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function JB(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,u=a?a.length:t.children.length;let d=-1;const m=[];for(;++d<u;){const h=t.children[d],g={},y=a?a[d]:void 0;y&&(g.align=y);let v={type:"element",tagName:o,properties:g,children:[]};h&&(v.children=e.all(h),e.patch(h,v),v=e.applyData(h,v)),m.push(v)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(m,!0)};return e.patch(t,p),e.applyData(t,p)}function e9(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const cw=9,uw=32;function t9(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(dw(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(dw(t.slice(i),i>0,!1)),o.join("")}function dw(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===cw||o===uw;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===cw||o===uw;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function n9(e,t){const n={type:"text",value:t9(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function r9(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const i9={blockquote:MB,break:DB,code:OB,delete:LB,emphasis:zB,footnoteReference:PB,heading:BB,html:$B,imageReference:HB,image:FB,inlineCode:VB,linkReference:UB,link:GB,listItem:qB,list:YB,paragraph:XB,root:KB,strong:ZB,table:QB,tableCell:e9,tableRow:JB,text:n9,thematicBreak:r9,toml:Ud,yaml:Ud,definition:Ud,footnoteDefinition:Ud};function Ud(){}const MN=-1,Tm=0,Gc=1,qf=2,J0=3,ev=4,tv=5,nv=6,DN=7,ON=8,fw=typeof self=="object"?self:globalThis,s9=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,a]=t[i];switch(o){case Tm:case MN:return n(a,i);case Gc:{const u=n([],i);for(const d of a)u.push(r(d));return u}case qf:{const u=n({},i);for(const[d,m]of a)u[r(d)]=r(m);return u}case J0:return n(new Date(a),i);case ev:{const{source:u,flags:d}=a;return n(new RegExp(u,d),i)}case tv:{const u=n(new Map,i);for(const[d,m]of a)u.set(r(d),r(m));return u}case nv:{const u=n(new Set,i);for(const d of a)u.add(r(d));return u}case DN:{const{name:u,message:d}=a;return n(new fw[u](d),i)}case ON:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:u}=new Uint8Array(a);return n(new DataView(u),a)}}return n(new fw[o](a),i)};return r},mw=e=>s9(new Map,e)(0),$a="",{toString:o9}={},{keys:a9}=Object,Ec=e=>{const t=typeof e;if(t!=="object"||!e)return[Tm,t];const n=o9.call(e).slice(8,-1);switch(n){case"Array":return[Gc,$a];case"Object":return[qf,$a];case"Date":return[J0,$a];case"RegExp":return[ev,$a];case"Map":return[tv,$a];case"Set":return[nv,$a];case"DataView":return[Gc,n]}return n.includes("Array")?[Gc,n]:n.includes("Error")?[DN,n]:[qf,n]},Gd=([e,t])=>e===Tm&&(t==="function"||t==="symbol"),l9=(e,t,n,r)=>{const i=(a,u)=>{const d=r.push(a)-1;return n.set(u,d),d},o=a=>{if(n.has(a))return n.get(a);let[u,d]=Ec(a);switch(u){case Tm:{let p=a;switch(d){case"bigint":u=ON,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return i([MN],a)}return i([u,p],a)}case Gc:{if(d){let g=a;return d==="DataView"?g=new Uint8Array(a.buffer):d==="ArrayBuffer"&&(g=new Uint8Array( Line truncated `});const m={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,m),e.applyData(t,m)}function WB(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=AN(n[r])}return t}function AN(e){const t=e.spread;return t??e.children.length>1}function YB(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function XB(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function KB(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function ZB(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function QB(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},u=q0(t.children[1]),d=dN(t.children[t.children.length-1]);u&&d&&(a.position={start:u,end:d}),i.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function JB(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,u=a?a.length:t.children.length;let d=-1;const m=[];for(;++d<u;){const h=t.children[d],g={},y=a?a[d]:void 0;y&&(g.align=y);let v={type:"element",tagName:o,properties:g,children:[]};h&&(v.children=e.all(h),e.patch(h,v),v=e.applyData(h,v)),m.push(v)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(m,!0)};return e.patch(t,p),e.applyData(t,p)}function e9(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const cw=9,uw=32;function t9(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(dw(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(dw(t.slice(i),i>0,!1)),o.join("")}function dw(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===cw||o===uw;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===cw||o===uw;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function n9(e,t){const n={type:"text",value:t9(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function r9(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const i9={blockquote:MB,break:DB,code:OB,delete:LB,emphasis:zB,footnoteReference:PB,heading:BB,html:$B,imageReference:HB,image:FB,inlineCode:VB,linkReference:UB,link:GB,listItem:qB,list:YB,paragraph:XB,root:KB,strong:ZB,table:QB,tableCell:e9,tableRow:JB,text:n9,thematicBreak:r9,toml:Ud,yaml:Ud,definition:Ud,footnoteDefinition:Ud};function Ud(){}const MN=-1,Tm=0,Gc=1,qf=2,J0=3,ev=4,tv=5,nv=6,DN=7,ON=8,fw=typeof self=="object"?self:globalThis,s9=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,a]=t[i];switch(o){case Tm:case MN:return n(a,i);case Gc:{const u=n([],i);for(const d of a)u.push(r(d));return u}case qf:{const u=n({},i);for(const[d,m]of a)u[r(d)]=r(m);return u}case J0:return n(new Date(a),i);case ev:{const{source:u,flags:d}=a;return n(new RegExp(u,d),i)}case tv:{const u=n(new Map,i);for(const[d,m]of a)u.set(r(d),r(m));return u}case nv:{const u=n(new Set,i);for(const d of a)u.add(r(d));return u}case DN:{const{name:u,message:d}=a;return n(new fw[u](d),i)}case ON:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:u}=new Uint8Array(a);return n(new DataView(u),a)}}return n(new fw[o](a),i)};return r},mw=e=>s9(new Map,e)(0),$a="",{toString:o9}={},{keys:a9}=Object,Ec=e=>{const t=typeof e;if(t!=="object"||!e)return[Tm,t];const n=o9.call(e).slice(8,-1);switch(n){case"Array":return[Gc,$a];case"Object":return[qf,$a];case"Date":return[J0,$a];case"RegExp":return[ev,$a];case"Map":return[tv,$a];case"Set":return[nv,$a];case"DataView":return[Gc,n]}return n.includes("Array")?[Gc,n]:n.includes("Error")?[DN,n]:[qf,n]},Gd=([e,t])=>e===Tm&&(t==="function"||t==="symbol"),l9=(e,t,n,r)=>{const i=(a,u)=>{const d=r.push(a)-1;return n.set(u,d),d},o=a=>{if(n.has(a))return n.get(a);let[u,d]=Ec(a);switch(u){case Tm:{let p=a;switch(d){case"bigint":u=ON,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return i([MN],a)}return i([u,p],a)}case Gc:{if(d){let g=a;return d==="DataView"?g=new Uint8Array(a.buffer):d==="ArrayBuffer"&&(g=new Uint8Array( Line truncated
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(u,!0)},{type:"text",value:`
`}]}}const Rm=(function(e){if(e==null)return p9;if(typeof e=="function")return Am(e);if(typeof e=="object")return Array.isArray(e)?f9(e):m9(e);if(typeof e=="string")return h9(e);throw new Error("Expected function, string, or object as test")});function f9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Rm(e[n]);return Am(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function m9(e){const t=e;return Am(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function h9(e){return Am(t);function t(n){return n&&n.type===e}}function Am(e){return t;function t(n,r,i){return!!(g9(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function p9(){return!0}function g9(e){return e!==null&&typeof e=="object"&&"type"in e}const LN=[],x9=!0,Oy=!1,y9="skip";function zN(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=Rm(i),a=r?-1:1;u(e,void 0,[])();function u(d,m,p){const h=d&&typeof d=="object"?d:{};if(typeof h.type=="string"){const y=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=LN,v,w,S;if((!t||o(d,m,p[p.length-1]||void 0))&&(y=v9(n(d,p)),y[0]===Oy))return y;if("children"in d&&d.children){const _=d;if(_.children&&y[0]!==y9)for(w=(r?_.children.length:-1)+a,S=p.concat(_);w>-1&&w<_.children.length;){const k=_.children[w];if(v=u(k,w,S)(),v[0]===Oy)return v;w=typeof v[1]=="number"?v[1]:w+a}}return y}}}function v9(e){return Array.isArray(e)?e:typeof e=="number"?[x9,e]:e==null?LN:[e]}function rv(e,t,n,r){let i,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,i=n):(o=t,a=n,i=r),zN(e,o,u,i);function u(d,m){const p=m[m.length-1],h=p?p.children.indexOf(d):void 0;return a(d,h,p)}}const Ly={}.hasOwnProperty,b9={};function _9(e,t){const n=t||b9,r=new Map,i=new Map,o=new Map,a={...i9,...n.handlers},u={all:m,applyData:S9,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:d,options:n,patch:k9,wrap:C9};return rv(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const h=p.type==="definition"?r:i,g=String(p.identifier).toUpperCase();h.has(g)||h.set(g,p)}}),u;function d(p,h){const g=p.type,y=u.handlers[g];if(Ly.call(u.handlers,g)&&y)return y(u,p,h);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in p){const{children:w,...S}=p,_=Wf(S);return _.children=u.all(p),_}return Wf(p)}return(u.options.unknownHandler||w9)(u,p,h)}function m(p){const h=[];if("children"in p){const g=p.children;let y=-1;for(;++y<g.length;){const v=u.one(g[y],p);if(v){if(y&&g[y-1].type==="break"&&(!Array.isArray(v)&&v.type==="text"&&(v.value=pw(v.value)),!Array.isArray(v)&&v.type==="element")){const w=v.children[0];w&&w.type==="text"&&(w.value=pw(w.value))}Array.isArray(v)?h.push(...v):h.push(v)}}}return h}}function k9(e,t){e.position&&(t.position=uz(e))}function S9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,Wf(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function w9(e,t){const n=t.data||{},r="value"in t&&!(Ly.call(n,"hProperties")||Ly.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function C9(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:` `}]}}const Rm=(function(e){if(e==null)return p9;if(typeof e=="function")return Am(e);if(typeof e=="object")return Array.isArray(e)?f9(e):m9(e);if(typeof e=="string")return h9(e);throw new Error("Expected function, string, or object as test")});function f9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Rm(e[n]);return Am(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function m9(e){const t=e;return Am(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function h9(e){return Am(t);function t(n){return n&&n.type===e}}function Am(e){return t;function t(n,r,i){return!!(g9(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function p9(){return!0}function g9(e){return e!==null&&typeof e=="object"&&"type"in e}const LN=[],x9=!0,Oy=!1,y9="skip";function zN(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=Rm(i),a=r?-1:1;u(e,void 0,[])();function u(d,m,p){const h=d&&typeof d=="object"?d:{};if(typeof h.type=="string"){const y=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=LN,v,k,S;if((!t||o(d,m,p[p.length-1]||void 0))&&(y=v9(n(d,p)),y[0]===Oy))return y;if("children"in d&&d.children){const _=d;if(_.children&&y[0]!==y9)for(k=(r?_.children.length:-1)+a,S=p.concat(_);k>-1&&k<_.children.length;){const w=_.children[k];if(v=u(w,k,S)(),v[0]===Oy)return v;k=typeof v[1]=="number"?v[1]:k+a}}return y}}}function v9(e){return Array.isArray(e)?e:typeof e=="number"?[x9,e]:e==null?LN:[e]}function rv(e,t,n,r){let i,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,i=n):(o=t,a=n,i=r),zN(e,o,u,i);function u(d,m){const p=m[m.length-1],h=p?p.children.indexOf(d):void 0;return a(d,h,p)}}const Ly={}.hasOwnProperty,b9={};function _9(e,t){const n=t||b9,r=new Map,i=new Map,o=new Map,a={...i9,...n.handlers},u={all:m,applyData:S9,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:d,options:n,patch:k9,wrap:C9};return rv(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const h=p.type==="definition"?r:i,g=String(p.identifier).toUpperCase();h.has(g)||h.set(g,p)}}),u;function d(p,h){const g=p.type,y=u.handlers[g];if(Ly.call(u.handlers,g)&&y)return y(u,p,h);if(u.options.passThrough&&u.options.passThrough.includes(g)){if("children"in p){const{children:k,...S}=p,_=Wf(S);return _.children=u.all(p),_}return Wf(p)}return(u.options.unknownHandler||w9)(u,p,h)}function m(p){const h=[];if("children"in p){const g=p.children;let y=-1;for(;++y<g.length;){const v=u.one(g[y],p);if(v){if(y&&g[y-1].type==="break"&&(!Array.isArray(v)&&v.type==="text"&&(v.value=pw(v.value)),!Array.isArray(v)&&v.type==="element")){const k=v.children[0];k&&k.type==="text"&&(k.value=pw(k.value))}Array.isArray(v)?h.push(...v):h.push(v)}}}return h}}function k9(e,t){e.position&&(t.position=uz(e))}function S9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,Wf(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function w9(e,t){const n=t.data||{},r="value"in t&&!(Ly.call(n,"hProperties")||Ly.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function C9(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
`});++r<e.length;)r&&n.push({type:"text",value:` `});++r<e.length;)r&&n.push({type:"text",value:`
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:` `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
`}),n}function pw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function gw(e,t){const n=_9(e,t),r=n.one(e,void 0),i=d9(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:` `}),n}function pw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function gw(e,t){const n=_9(e,t),r=n.one(e,void 0),i=d9(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
`},i),o}function j9(e,t){return e&&"run"in e?async function(n,r){const i=gw(n,{file:r,...t});await e.run(i,r)}:function(n,r){return gw(n,{file:r,...e||t})}}function xw(e){if(e)throw e}var Ng,yw;function E9(){if(yw)return Ng;yw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(m){return typeof Array.isArray=="function"?Array.isArray(m):t.call(m)==="[object Array]"},o=function(m){if(!m||t.call(m)!=="[object Object]")return!1;var p=e.call(m,"constructor"),h=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!p&&!h)return!1;var g;for(g in m);return typeof g>"u"||e.call(m,g)},a=function(m,p){n&&p.name==="__proto__"?n(m,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):m[p.name]=p.newValue},u=function(m,p){if(p==="__proto__")if(e.call(m,p)){if(r)return r(m,p).value}else return;return m[p]};return Ng=function d(){var m,p,h,g,y,v,w=arguments[0],S=1,_=arguments.length,k=!1;for(typeof w=="boolean"&&(k=w,w=arguments[1]||{},S=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});S<_;++S)if(m=arguments[S],m!=null)for(p in m)h=u(w,p),g=u(m,p),w!==g&&(k&&g&&(o(g)||(y=i(g)))?(y?(y=!1,v=h&&i(h)?h:[]):v=h&&o(h)?h:{},a(w,{name:p,newValue:d(k,v,g)})):typeof g<"u"&&a(w,{name:p,newValue:g}));return w},Ng}var N9=E9();const Ig=Zo(N9);function zy(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function I9(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);u(null,...i);function u(d,...m){const p=e[++o];let h=-1;if(d){a(d);return}for(;++h<i.length;)(m[h]===null||m[h]===void 0)&&(m[h]=i[h]);i=m,p?T9(p,u)(...m):a(null,...m)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function T9(e,t){let n;return r;function r(...a){const u=e.length>a.length;let d;u&&a.push(i);try{d=e.apply(this,a)}catch(m){const p=m;if(u&&n)throw p;return i(p)}u||(d&&d.then&&typeof d.then=="function"?d.then(o,i):d instanceof Error?i(d):o(d))}function i(a,...u){n||(n=!0,t(a,...u))}function o(a){i(null,a)}}const Hi={basename:R9,dirname:A9,extname:M9,join:D9,sep:"/"};function R9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Su(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,u=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else a<0&&(o=!0,a=i+1),u>-1&&(e.codePointAt(i)===t.codePointAt(u--)?u<0&&(r=i):(u=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function A9(e){if(Su(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function M9(e){Su(e);let t=e.length,n=-1,r=0,i=-1,o=0,a;for(;t--;){const u=e.codePointAt(t);if(u===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),u===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function D9(...e){let t=-1,n;for(;++t<e.length;)Su(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":O9(n)}function O9(e){Su(e);const t=e.codePointAt(0)===47;let n=L9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function L9(e,t){let n="",r=0,i=-1,o=0,a=-1,u,d;for(;++a<=e.length;){if(a<e.length)u=e.codePointAt(a);else{if(u===47)break;u=47}if(u===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),i=a,o=0;continue}}else if(n.length>0){n="",r=0,i=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,o=0}else u===46&&o>-1?o++:o=-1}return n}function Su(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const z9={cwd:P9};function P9(){return"/"}function Py(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function B9(e){if(typeof e=="string")e=new URL(e);else if(!Py(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return $9(e)}function $9(e){if(e.hostname!==""){consLine truncated `},i),o}function j9(e,t){return e&&"run"in e?async function(n,r){const i=gw(n,{file:r,...t});await e.run(i,r)}:function(n,r){return gw(n,{file:r,...e||t})}}function xw(e){if(e)throw e}var Ng,yw;function E9(){if(yw)return Ng;yw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(m){return typeof Array.isArray=="function"?Array.isArray(m):t.call(m)==="[object Array]"},o=function(m){if(!m||t.call(m)!=="[object Object]")return!1;var p=e.call(m,"constructor"),h=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!p&&!h)return!1;var g;for(g in m);return typeof g>"u"||e.call(m,g)},a=function(m,p){n&&p.name==="__proto__"?n(m,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):m[p.name]=p.newValue},u=function(m,p){if(p==="__proto__")if(e.call(m,p)){if(r)return r(m,p).value}else return;return m[p]};return Ng=function d(){var m,p,h,g,y,v,k=arguments[0],S=1,_=arguments.length,w=!1;for(typeof k=="boolean"&&(w=k,k=arguments[1]||{},S=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});S<_;++S)if(m=arguments[S],m!=null)for(p in m)h=u(k,p),g=u(m,p),k!==g&&(w&&g&&(o(g)||(y=i(g)))?(y?(y=!1,v=h&&i(h)?h:[]):v=h&&o(h)?h:{},a(k,{name:p,newValue:d(w,v,g)})):typeof g<"u"&&a(k,{name:p,newValue:g}));return k},Ng}var N9=E9();const Ig=Zo(N9);function zy(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function I9(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);u(null,...i);function u(d,...m){const p=e[++o];let h=-1;if(d){a(d);return}for(;++h<i.length;)(m[h]===null||m[h]===void 0)&&(m[h]=i[h]);i=m,p?T9(p,u)(...m):a(null,...m)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function T9(e,t){let n;return r;function r(...a){const u=e.length>a.length;let d;u&&a.push(i);try{d=e.apply(this,a)}catch(m){const p=m;if(u&&n)throw p;return i(p)}u||(d&&d.then&&typeof d.then=="function"?d.then(o,i):d instanceof Error?i(d):o(d))}function i(a,...u){n||(n=!0,t(a,...u))}function o(a){i(null,a)}}const Hi={basename:R9,dirname:A9,extname:M9,join:D9,sep:"/"};function R9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Su(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,u=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else a<0&&(o=!0,a=i+1),u>-1&&(e.codePointAt(i)===t.codePointAt(u--)?u<0&&(r=i):(u=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function A9(e){if(Su(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function M9(e){Su(e);let t=e.length,n=-1,r=0,i=-1,o=0,a;for(;t--;){const u=e.codePointAt(t);if(u===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),u===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function D9(...e){let t=-1,n;for(;++t<e.length;)Su(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":O9(n)}function O9(e){Su(e);const t=e.codePointAt(0)===47;let n=L9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function L9(e,t){let n="",r=0,i=-1,o=0,a=-1,u,d;for(;++a<=e.length;){if(a<e.length)u=e.codePointAt(a);else{if(u===47)break;u=47}if(u===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),i=a,o=0;continue}}else if(n.length>0){n="",r=0,i=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,o=0}else u===46&&o>-1?o++:o=-1}return n}function Su(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const z9={cwd:P9};function P9(){return"/"}function Py(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function B9(e){if(typeof e=="string")e=new URL(e);else if(!Py(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return $9(e)}function $9(e){if(e.hostname!==""){consLine truncated
`:" ")+o.indentLines(o.containerFlow(r,u.current()),t?HN:T$))),m(),d}}function T$(e,t,n){return t===0?e:HN(e,t,n)}function HN(e,t,n){return(n?"":" ")+e}const R$=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];FN.peek=L$;function A$(){return{canContainEols:["delete"],enter:{strikethrough:D$},exit:{strikethrough:O$}}}function M$(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:R$}],handlers:{delete:FN}}}function D$(e){this.enter({type:"delete",children:[]},e)}function O$(e){this.exit(e)}function FN(e,t,n,r){const i=n.createTracker(r),o=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),o(),a}function L$(){return"~"}function z$(e){return e.length}function P$(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||z$,o=[],a=[],u=[],d=[];let m=0,p=-1;for(;++p<e.length;){const w=[],S=[];let _=-1;for(e[p].length>m&&(m=e[p].length);++_<e[p].length;){const k=B$(e[p][_]);if(n.alignDelimiters!==!1){const C=i(k);S[_]=C,(d[_]===void 0||C>d[_])&&(d[_]=C)}w.push(k)}a[p]=w,u[p]=S}let h=-1;if(typeof r=="object"&&"length"in r)for(;++h<m;)o[h]=Cw(r[h]);else{const w=Cw(r);for(;++h<m;)o[h]=w}h=-1;const g=[],y=[];for(;++h<m;){const w=o[h];let S="",_="";w===99?(S=":",_=":"):w===108?S=":":w===114&&(_=":");let k=n.alignDelimiters===!1?1:Math.max(1,d[h]-S.length-_.length);const C=S+"-".repeat(k)+_;n.alignDelimiters!==!1&&(k=S.length+k+_.length,k>d[h]&&(d[h]=k),y[h]=k),g[h]=C}a.splice(1,0,g),u.splice(1,0,y),p=-1;const v=[];for(;++p<a.length;){const w=a[p],S=u[p];h=-1;const _=[];for(;++h<m;){const k=w[h]||"";let C="",N="";if(n.alignDelimiters!==!1){const O=d[h]-(S[h]||0),I=o[h];I===114?C=" ".repeat(O):I===99?O%2?(C=" ".repeat(O/2+.5),N=" ".repeat(O/2-.5)):(C=" ".repeat(O/2),N=C):N=" ".repeat(O)}n.delimiterStart!==!1&&!h&&_.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&k==="")&&(n.delimiterStart!==!1||h)&&_.push(" "),n.alignDelimiters!==!1&&_.push(C),_.push(k),n.alignDelimiters!==!1&&_.push(N),n.padding!==!1&&_.push(" "),(n.delimiterEnd!==!1||h!==m-1)&&_.push("|")}v.push(n.delimiterEnd===!1?_.join("").replace(/ +$/,""):_.join(""))}return v.join(` `:" ")+o.indentLines(o.containerFlow(r,u.current()),t?HN:T$))),m(),d}}function T$(e,t,n){return t===0?e:HN(e,t,n)}function HN(e,t,n){return(n?"":" ")+e}const R$=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];FN.peek=L$;function A$(){return{canContainEols:["delete"],enter:{strikethrough:D$},exit:{strikethrough:O$}}}function M$(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:R$}],handlers:{delete:FN}}}function D$(e){this.enter({type:"delete",children:[]},e)}function O$(e){this.exit(e)}function FN(e,t,n,r){const i=n.createTracker(r),o=n.enter("strikethrough");let a=i.move("~~");return a+=n.containerPhrasing(e,{...i.current(),before:a,after:"~"}),a+=i.move("~~"),o(),a}function L$(){return"~"}function z$(e){return e.length}function P$(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||z$,o=[],a=[],u=[],d=[];let m=0,p=-1;for(;++p<e.length;){const k=[],S=[];let _=-1;for(e[p].length>m&&(m=e[p].length);++_<e[p].length;){const w=B$(e[p][_]);if(n.alignDelimiters!==!1){const C=i(w);S[_]=C,(d[_]===void 0||C>d[_])&&(d[_]=C)}k.push(w)}a[p]=k,u[p]=S}let h=-1;if(typeof r=="object"&&"length"in r)for(;++h<m;)o[h]=Cw(r[h]);else{const k=Cw(r);for(;++h<m;)o[h]=k}h=-1;const g=[],y=[];for(;++h<m;){const k=o[h];let S="",_="";k===99?(S=":",_=":"):k===108?S=":":k===114&&(_=":");let w=n.alignDelimiters===!1?1:Math.max(1,d[h]-S.length-_.length);const C=S+"-".repeat(w)+_;n.alignDelimiters!==!1&&(w=S.length+w+_.length,w>d[h]&&(d[h]=w),y[h]=w),g[h]=C}a.splice(1,0,g),u.splice(1,0,y),p=-1;const v=[];for(;++p<a.length;){const k=a[p],S=u[p];h=-1;const _=[];for(;++h<m;){const w=k[h]||"";let C="",N="";if(n.alignDelimiters!==!1){const O=d[h]-(S[h]||0),I=o[h];I===114?C=" ".repeat(O):I===99?O%2?(C=" ".repeat(O/2+.5),N=" ".repeat(O/2-.5)):(C=" ".repeat(O/2),N=C):N=" ".repeat(O)}n.delimiterStart!==!1&&!h&&_.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&w==="")&&(n.delimiterStart!==!1||h)&&_.push(" "),n.alignDelimiters!==!1&&_.push(C),_.push(w),n.alignDelimiters!==!1&&_.push(N),n.padding!==!1&&_.push(" "),(n.delimiterEnd!==!1||h!==m-1)&&_.push("|")}v.push(n.delimiterEnd===!1?_.join("").replace(/ +$/,""):_.join(""))}return v.join(`
`)}function B$(e){return e==null?"":String(e)}function Cw(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function $$(e,t,n,r){const i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const a=n.indentLines(n.containerFlow(e,o.current()),H$);return i(),a}function H$(e,t,n){return">"+(n?"":" ")+e}function F$(e,t){return jw(e,t.inConstruct,!0)&&!jw(e,t.notInConstruct,!1)}function jw(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Ew(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===` `)}function B$(e){return e==null?"":String(e)}function Cw(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function $$(e,t,n,r){const i=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const a=n.indentLines(n.containerFlow(e,o.current()),H$);return i(),a}function H$(e,t,n){return">"+(n?"":" ")+e}function F$(e,t){return jw(e,t.inConstruct,!0)&&!jw(e,t.notInConstruct,!1)}function jw(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Ew(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
`&&F$(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\ `&&F$(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
`}function V$(e,t){const n=String(e);let r=n.indexOf(t),i=r,o=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>a&&(a=o):o=1,i=r+t.length,r=n.indexOf(t,i);return a}function U$(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function G$(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function q$(e,t,n,r){const i=G$(n),o=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(U$(e,n)){const h=n.enter("codeIndented"),g=n.indentLines(o,W$);return h(),g}const u=n.createTracker(r),d=i.repeat(Math.max(V$(o,i)+1,3)),m=n.enter("codeFenced");let p=u.move(d);if(e.lang){const h=n.enter(`codeFencedLang${a}`);p+=u.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...u.current()})),h()}if(e.lang&&e.meta){const h=n.enter(`codeFencedMeta${a}`);p+=u.move(" "),p+=u.move(n.safe(e.meta,{before:p,after:` `}function V$(e,t){const n=String(e);let r=n.indexOf(t),i=r,o=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++o>a&&(a=o):o=1,i=r+t.length,r=n.indexOf(t,i);return a}function U$(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function G$(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function q$(e,t,n,r){const i=G$(n),o=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(U$(e,n)){const h=n.enter("codeIndented"),g=n.indentLines(o,W$);return h(),g}const u=n.createTracker(r),d=i.repeat(Math.max(V$(o,i)+1,3)),m=n.enter("codeFenced");let p=u.move(d);if(e.lang){const h=n.enter(`codeFencedLang${a}`);p+=u.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...u.current()})),h()}if(e.lang&&e.meta){const h=n.enter(`codeFencedMeta${a}`);p+=u.move(" "),p+=u.move(n.safe(e.meta,{before:p,after:`
@@ -101,22 +101,22 @@ ${te.current.stack}
`+(i===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(` `+(i===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
`))+1))}const a="#".repeat(i),u=n.enter("headingAtx"),d=n.enter("phrasing");o.move(a+" ");let m=n.containerPhrasing(e,{before:"# ",after:` `))+1))}const a="#".repeat(i),u=n.enter("headingAtx"),d=n.enter("phrasing");o.move(a+" ");let m=n.containerPhrasing(e,{before:"# ",after:`
`,...o.current()});return/^[\t ]/.test(m)&&(m=lu(m.charCodeAt(0))+m.slice(1)),m=m?a+" "+m:a,n.options.closeAtx&&(m+=" "+a),d(),u(),m}UN.peek=J$;function UN(e){return e.value||""}function J$(){return"<"}GN.peek=e7;function GN(e,t,n,r){const i=sv(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let u=n.enter("label");const d=n.createTracker(r);let m=d.move("![");return m+=d.move(n.safe(e.alt,{before:m,after:"]",...d.current()})),m+=d.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),m+=d.move("<"),m+=d.move(n.safe(e.url,{before:m,after:">",...d.current()})),m+=d.move(">")):(u=n.enter("destinationRaw"),m+=d.move(n.safe(e.url,{before:m,after:e.title?" ":")",...d.current()}))),u(),e.title&&(u=n.enter(`title${o}`),m+=d.move(" "+i),m+=d.move(n.safe(e.title,{before:m,after:i,...d.current()})),m+=d.move(i),u()),m+=d.move(")"),a(),m}function e7(){return"!"}qN.peek=t7;function qN(e,t,n,r){const i=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const u=n.createTracker(r);let d=u.move("![");const m=n.safe(e.alt,{before:d,after:"]",...u.current()});d+=u.move(m+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return a(),n.stack=p,o(),i==="full"||!m||m!==h?d+=u.move(h+"]"):i==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function t7(){return"!"}WN.peek=n7;function WN(e,t,n){let r=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],u=n.compilePattern(a);let d;if(a.atBreak)for(;d=u.exec(r);){let m=d.index;r.charCodeAt(m)===10&&r.charCodeAt(m-1)===13&&m--,r=r.slice(0,m)+" "+r.slice(d.index+1)}}return i+r+i}function n7(){return"`"}function YN(e,t){const n=K0(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))}XN.peek=r7;function XN(e,t,n,r){const i=sv(n),o=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let u,d;if(YN(e,n)){const p=n.stack;n.stack=[],u=n.enter("autolink");let h=a.move("<");return h+=a.move(n.containerPhrasing(e,{before:h,after:">",...a.current()})),h+=a.move(">"),u(),n.stack=p,h}u=n.enter("link"),d=n.enter("label");let m=a.move("[");return m+=a.move(n.containerPhrasing(e,{before:m,after:"](",...a.current()})),m+=a.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),m+=a.move("<"),m+=a.move(n.safe(e.url,{before:m,after:">",...a.current()})),m+=a.move(">")):(d=n.enter("destinationRaw"),m+=a.move(n.safe(e.url,{before:m,after:e.title?" ":")",...a.current()}))),d(),e.title&&(d=n.enter(`title${o}`),m+=a.move(" "+i),m+=a.move(n.safe(e.title,{before:m,after:i,...a.current()})),m+=a.move(i),d()),m+=a.move(")"),u(),m}function r7(e,t,n){return YN(e,n)?"<":"["}KN.peek=i7;function KN(e,t,n,r){const i=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const u=n.createTracker(r);let d=u.move("[");const m=n.containerPhrasing(e,{before:d,after:"]",...u.current()});d+=u.move(m+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return a(),n.stack=p,o(),i==="full"||!m||m!==h?d+=u.move(h+"]"):i==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function i7(){return"["}function ov(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function s7(e){const t=ov(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function o7(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function ZN(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function a7(e,t,n,r){const i=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?o7(n):ov(n);const u=e.ordered?a==="."?")":".":s7(n);let d=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&p&&(!p.children||!p.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&&(d=!0),ZN(n)===a&&p){let h=-1;for(;++h<e.chilLine truncated `,...o.current()});return/^[\t ]/.test(m)&&(m=lu(m.charCodeAt(0))+m.slice(1)),m=m?a+" "+m:a,n.options.closeAtx&&(m+=" "+a),d(),u(),m}UN.peek=J$;function UN(e){return e.value||""}function J$(){return"<"}GN.peek=e7;function GN(e,t,n,r){const i=sv(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let u=n.enter("label");const d=n.createTracker(r);let m=d.move("![");return m+=d.move(n.safe(e.alt,{before:m,after:"]",...d.current()})),m+=d.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),m+=d.move("<"),m+=d.move(n.safe(e.url,{before:m,after:">",...d.current()})),m+=d.move(">")):(u=n.enter("destinationRaw"),m+=d.move(n.safe(e.url,{before:m,after:e.title?" ":")",...d.current()}))),u(),e.title&&(u=n.enter(`title${o}`),m+=d.move(" "+i),m+=d.move(n.safe(e.title,{before:m,after:i,...d.current()})),m+=d.move(i),u()),m+=d.move(")"),a(),m}function e7(){return"!"}qN.peek=t7;function qN(e,t,n,r){const i=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const u=n.createTracker(r);let d=u.move("![");const m=n.safe(e.alt,{before:d,after:"]",...u.current()});d+=u.move(m+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return a(),n.stack=p,o(),i==="full"||!m||m!==h?d+=u.move(h+"]"):i==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function t7(){return"!"}WN.peek=n7;function WN(e,t,n){let r=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],u=n.compilePattern(a);let d;if(a.atBreak)for(;d=u.exec(r);){let m=d.index;r.charCodeAt(m)===10&&r.charCodeAt(m-1)===13&&m--,r=r.slice(0,m)+" "+r.slice(d.index+1)}}return i+r+i}function n7(){return"`"}function YN(e,t){const n=K0(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))}XN.peek=r7;function XN(e,t,n,r){const i=sv(n),o=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let u,d;if(YN(e,n)){const p=n.stack;n.stack=[],u=n.enter("autolink");let h=a.move("<");return h+=a.move(n.containerPhrasing(e,{before:h,after:">",...a.current()})),h+=a.move(">"),u(),n.stack=p,h}u=n.enter("link"),d=n.enter("label");let m=a.move("[");return m+=a.move(n.containerPhrasing(e,{before:m,after:"](",...a.current()})),m+=a.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),m+=a.move("<"),m+=a.move(n.safe(e.url,{before:m,after:">",...a.current()})),m+=a.move(">")):(d=n.enter("destinationRaw"),m+=a.move(n.safe(e.url,{before:m,after:e.title?" ":")",...a.current()}))),d(),e.title&&(d=n.enter(`title${o}`),m+=a.move(" "+i),m+=a.move(n.safe(e.title,{before:m,after:i,...a.current()})),m+=a.move(i),d()),m+=a.move(")"),u(),m}function r7(e,t,n){return YN(e,n)?"<":"["}KN.peek=i7;function KN(e,t,n,r){const i=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const u=n.createTracker(r);let d=u.move("[");const m=n.containerPhrasing(e,{before:d,after:"]",...u.current()});d+=u.move(m+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(e),{before:d,after:"]",...u.current()});return a(),n.stack=p,o(),i==="full"||!m||m!==h?d+=u.move(h+"]"):i==="shortcut"?d=d.slice(0,-1):d+=u.move("]"),d}function i7(){return"["}function ov(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function s7(e){const t=ov(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function o7(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function ZN(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function a7(e,t,n,r){const i=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?o7(n):ov(n);const u=e.ordered?a==="."?")":".":s7(n);let d=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&p&&(!p.children||!p.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&&(d=!0),ZN(n)===a&&p){let h=-1;for(;++h<e.chilLine truncated
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:a,tableCell:d,tableRow:u}};function a(y,v,w,S){return m(p(y,w,S),y.align)}function u(y,v,w,S){const _=h(y,w,S),k=m([_]);return k.slice(0,k.indexOf(` `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:a,tableCell:d,tableRow:u}};function a(y,v,k,S){return m(p(y,k,S),y.align)}function u(y,v,k,S){const _=h(y,k,S),w=m([_]);return w.slice(0,w.indexOf(`
`))}function d(y,v,w,S){const _=w.enter("tableCell"),k=w.enter("phrasing"),C=w.containerPhrasing(y,{...S,before:o,after:o});return k(),_(),C}function m(y,v){return P$(y,{align:v,alignDelimiters:r,padding:n,stringLength:i})}function p(y,v,w){const S=y.children;let _=-1;const k=[],C=v.enter("table");for(;++_<S.length;)k[_]=h(S[_],v,w);return C(),k}function h(y,v,w){const S=y.children;let _=-1;const k=[],C=v.enter("tableRow");for(;++_<S.length;)k[_]=d(S[_],y,v,w);return C(),k}function g(y,v,w){let S=JN.inlineCode(y,v,w);return w.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function C7(){return{exit:{taskListCheckValueChecked:Iw,taskListCheckValueUnchecked:Iw,paragraph:E7}}}function j7(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:N7}}}function Iw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function E7(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let o=-1,a;for(;++o<i.length;){const u=i[o];if(u.type==="paragraph"){a=u;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function N7(e,t,n,r){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);o&&u.move(a);let d=JN.listItem(e,t,n,{...r,...u.current()});return o&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),d;function m(p){return p+a}}function I7(){return[a$(),N$(),A$(),y7(),C7()]}function T7(e){return{extensions:[l$(),I$(e),M$(),w7(e),j7()]}}const R7={tokenize:z7,partial:!0},eI={tokenize:P7,partial:!0},tI={tokenize:B7,partial:!0},nI={tokenize:$7,partial:!0},A7={tokenize:H7,partial:!0},rI={name:"wwwAutolink",tokenize:O7,previous:sI},iI={name:"protocolAutolink",tokenize:L7,previous:oI},Cs={name:"emailAutolink",tokenize:D7,previous:aI},Zi={};function M7(){return{text:Zi}}let Mo=48;for(;Mo<123;)Zi[Mo]=Cs,Mo++,Mo===58?Mo=65:Mo===91&&(Mo=97);Zi[43]=Cs;Zi[45]=Cs;Zi[46]=Cs;Zi[95]=Cs;Zi[72]=[Cs,iI];Zi[104]=[Cs,iI];Zi[87]=[Cs,rI];Zi[119]=[Cs,rI];function D7(e,t,n){const r=this;let i,o;return a;function a(h){return!By(h)||!aI.call(r,r.previous)||av(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(h))}function u(h){return By(h)?(e.consume(h),u):h===64?(e.consume(h),d):n(h)}function d(h){return h===46?e.check(A7,p,m)(h):h===45||h===95||kr(h)?(o=!0,e.consume(h),d):p(h)}function m(h){return e.consume(h),i=!0,d}function p(h){return o&&i&&Ir(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function O7(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!sI.call(r,r.previous)||av(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(R7,e.attempt(eI,e.attempt(tI,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function L7(e,t,n){const r=this;let i="",o=!1;return a;function a(h){return(h===72||h===104)&&oI.call(r,r.previous)&&!av(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),e.consume(h),u):n(h)}function u(h){if(Ir(h)&&i.length<5)return i+=String.fromCodePoint(h),e.consume(h),u;if(h===58){const g=i.toLowerCase();if(g==="http"||g==="https")return e.consume(h),d}return n(h)}function d(h){return h===47?(e.consume(h),o?m:(o=!0,d)):n(h)}function m(h){return h===null||Gf(h)||gn(h)||Uo(h)||Nm(h)?n(h):e.attempt(eI,e.attempt(tI,p),n)(h)}function p(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function z7(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function P7(e,t,n){let r,i,o;return a;function a(m){return m===46||m===95?e.check(nI,d,u)(m):m===null||gn(m)||Uo(m)||m!==45&&Nm(m)?d(m):(o=!0,e.consume(m),a)}function u(m){return m===95?r=!0:(i=r,r=void 0),e.consume(m),a}function d(m){return i||r||!o?n(m):t(m)}}function B7(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(nI,t,o)(a):a===null||gn(a)||Uo(a)?t(a):(e.consume(a),i)}function o(a){return a===41&&r++,e.consume(a),i}}function $7(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),o):u===93?(e.consume(u),i):u===60||u===null||gn(u)||Uo(u)?t(u):n(u)}function i(u){return u===null||u===40||u===91||gn(u)||Uo(u)?t(u):r(u)}function o(u){return Ir(u)?a(u):n(u)}function a(u){re Line truncated `))}function d(y,v,k,S){const _=k.enter("tableCell"),w=k.enter("phrasing"),C=k.containerPhrasing(y,{...S,before:o,after:o});return w(),_(),C}function m(y,v){return P$(y,{align:v,alignDelimiters:r,padding:n,stringLength:i})}function p(y,v,k){const S=y.children;let _=-1;const w=[],C=v.enter("table");for(;++_<S.length;)w[_]=h(S[_],v,k);return C(),w}function h(y,v,k){const S=y.children;let _=-1;const w=[],C=v.enter("tableRow");for(;++_<S.length;)w[_]=d(S[_],y,v,k);return C(),w}function g(y,v,k){let S=JN.inlineCode(y,v,k);return k.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function C7(){return{exit:{taskListCheckValueChecked:Iw,taskListCheckValueUnchecked:Iw,paragraph:E7}}}function j7(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:N7}}}function Iw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function E7(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let o=-1,a;for(;++o<i.length;){const u=i[o];if(u.type==="paragraph"){a=u;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function N7(e,t,n,r){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);o&&u.move(a);let d=JN.listItem(e,t,n,{...r,...u.current()});return o&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),d;function m(p){return p+a}}function I7(){return[a$(),N$(),A$(),y7(),C7()]}function T7(e){return{extensions:[l$(),I$(e),M$(),w7(e),j7()]}}const R7={tokenize:z7,partial:!0},eI={tokenize:P7,partial:!0},tI={tokenize:B7,partial:!0},nI={tokenize:$7,partial:!0},A7={tokenize:H7,partial:!0},rI={name:"wwwAutolink",tokenize:O7,previous:sI},iI={name:"protocolAutolink",tokenize:L7,previous:oI},Cs={name:"emailAutolink",tokenize:D7,previous:aI},Qi={};function M7(){return{text:Qi}}let Mo=48;for(;Mo<123;)Qi[Mo]=Cs,Mo++,Mo===58?Mo=65:Mo===91&&(Mo=97);Qi[43]=Cs;Qi[45]=Cs;Qi[46]=Cs;Qi[95]=Cs;Qi[72]=[Cs,iI];Qi[104]=[Cs,iI];Qi[87]=[Cs,rI];Qi[119]=[Cs,rI];function D7(e,t,n){const r=this;let i,o;return a;function a(h){return!By(h)||!aI.call(r,r.previous)||av(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(h))}function u(h){return By(h)?(e.consume(h),u):h===64?(e.consume(h),d):n(h)}function d(h){return h===46?e.check(A7,p,m)(h):h===45||h===95||kr(h)?(o=!0,e.consume(h),d):p(h)}function m(h){return e.consume(h),i=!0,d}function p(h){return o&&i&&Ir(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function O7(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!sI.call(r,r.previous)||av(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(R7,e.attempt(eI,e.attempt(tI,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function L7(e,t,n){const r=this;let i="",o=!1;return a;function a(h){return(h===72||h===104)&&oI.call(r,r.previous)&&!av(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),e.consume(h),u):n(h)}function u(h){if(Ir(h)&&i.length<5)return i+=String.fromCodePoint(h),e.consume(h),u;if(h===58){const g=i.toLowerCase();if(g==="http"||g==="https")return e.consume(h),d}return n(h)}function d(h){return h===47?(e.consume(h),o?m:(o=!0,d)):n(h)}function m(h){return h===null||Gf(h)||gn(h)||Uo(h)||Nm(h)?n(h):e.attempt(eI,e.attempt(tI,p),n)(h)}function p(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function z7(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function P7(e,t,n){let r,i,o;return a;function a(m){return m===46||m===95?e.check(nI,d,u)(m):m===null||gn(m)||Uo(m)||m!==45&&Nm(m)?d(m):(o=!0,e.consume(m),a)}function u(m){return m===95?r=!0:(i=r,r=void 0),e.consume(m),a}function d(m){return i||r||!o?n(m):t(m)}}function B7(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(nI,t,o)(a):a===null||gn(a)||Uo(a)?t(a):(e.consume(a),i)}function o(a){return a===41&&r++,e.consume(a),i}}function $7(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),o):u===93?(e.consume(u),i):u===60||u===null||gn(u)||Uo(u)?t(u):n(u)}function i(u){return u===null||u===40||u===91||gn(u)||Uo(u)?t(u):r(u)}function o(u){return Ir(u)?a(u):n(u)}function a(u){re Line truncated
`),m=d.length>dH,p=m?d.length-$g*2:0,h=E.useCallback(()=>{navigator.clipboard.writeText(a),r(!0),setTimeout(()=>r(!1),1500)},[a]);return c.jsxs("div",{className:"code-block-wrap",children:[c.jsxs("div",{className:"code-block-header",children:[c.jsxs("span",{className:"code-block-lang",children:[u||"code",m?` (${d.length} lines)`:""]}),c.jsx("button",{className:"code-block-copy",onClick:h,children:n?c.jsxs(c.Fragment,{children:[c.jsx(_l,{})," ",c.jsx("span",{children:"Copied"})]}):c.jsxs(c.Fragment,{children:[c.jsx(pm,{})," ",c.jsx("span",{children:"Copy"})]})})]}),c.jsx("pre",{children:c.jsx("code",{className:e,children:m&&!i?c.jsxs(c.Fragment,{children:[d.slice(0,$g).join(` `),m=d.length>dH,p=m?d.length-$g*2:0,h=j.useCallback(()=>{navigator.clipboard.writeText(a),r(!0),setTimeout(()=>r(!1),1500)},[a]);return c.jsxs("div",{className:"code-block-wrap",children:[c.jsxs("div",{className:"code-block-header",children:[c.jsxs("span",{className:"code-block-lang",children:[u||"code",m?` (${d.length} lines)`:""]}),c.jsx("button",{className:"code-block-copy",onClick:h,children:n?c.jsxs(c.Fragment,{children:[c.jsx(_l,{})," ",c.jsx("span",{children:"Copied"})]}):c.jsxs(c.Fragment,{children:[c.jsx(pm,{})," ",c.jsx("span",{children:"Copy"})]})})]}),c.jsx("pre",{children:c.jsx("code",{className:e,children:m&&!i?c.jsxs(c.Fragment,{children:[d.slice(0,$g).join(`
`)+` `)+`
`,c.jsxs("span",{className:"code-block-omitted",onClick:()=>o(!0),children:["... +",p," lines (click to expand)"]}),` `,c.jsxs("span",{className:"code-block-omitted",onClick:()=>o(!0),children:["... +",p," lines (click to expand)"]}),`
`+d.slice(-$g).join(` `+d.slice(-$g).join(`
`)]}):a})}),m&&i&&c.jsxs("button",{className:"code-block-collapse-btn",onClick:()=>o(!1),children:["Collapse (",d.length," lines)"]})]})}const mH={code({className:e,children:t,...n}){return e?.startsWith("language-")?c.jsx(fH,{className:e,children:t}):c.jsx("code",{className:e,...n,children:t})}},hH=3e3,pH=60,Hg=800;function Rw(e){if(e.length>hH)return!0;let t=0;for(let n=0;n<e.length;n++)if(e[n]===` `)]}):a})}),m&&i&&c.jsxs("button",{className:"code-block-collapse-btn",onClick:()=>o(!1),children:["Collapse (",d.length," lines)"]})]})}const mH={code({className:e,children:t,...n}){return e?.startsWith("language-")?c.jsx(fH,{className:e,children:t}):c.jsx("code",{className:e,...n,children:t})}},hH=3e3,pH=60,Hg=800;function Rw(e){if(e.length>hH)return!0;let t=0;for(let n=0;n<e.length;n++)if(e[n]===`
`&&++t>=pH)return!0;return!1}function gH(e){const t=e.lastIndexOf(` `&&++t>=pH)return!0;return!1}function gH(e){const t=e.lastIndexOf(`
`,Hg);return e.slice(0,t>Hg/2?t:Hg)}const ir=St.memo(function({content:t,className:n="msg-content-agent",collapseMode:r="auto"}){const i=r!=="never"&&Rw(t),[o,a]=E.useState(i);E.useEffect(()=>{a(r!=="never"&&Rw(t))},[r,t]);const u=o?gH(t):t,d=t.split(` `,Hg);return e.slice(0,t>Hg/2?t:Hg)}const ir=St.memo(function({content:t,className:n="msg-content-agent",collapseMode:r="auto"}){const i=r!=="never"&&Rw(t),[o,a]=j.useState(i);j.useEffect(()=>{a(r!=="never"&&Rw(t))},[r,t]);const u=o?gH(t):t,d=t.split(`
`).length,m=t.length;return c.jsxs("div",{className:n,children:[c.jsx(Z9,{remarkPlugins:[uH],components:mH,children:u}),i&&o&&c.jsxs("button",{className:"msg-collapse-toggle",onClick:()=>a(!1),children:["Show more (",d," lines, ",(m/1e3).toFixed(1),"k chars)"]}),i&&!o&&c.jsx("button",{className:"msg-collapse-toggle",onClick:()=>a(!0),children:"Show less"})]})}),Aw={native:"OpenOPC Native",codex:"Codex",claude_code:"Claude Code",cursor:"Cursor",opencode:"OpenCode"},cu="codex",Fg="native",xH=["codex","native","claude_code","cursor","opencode"],yH=["native","codex","claude_code","cursor","opencode"];function lI(e){if(!e)return{kind:"fallback"};if(e.kind==="employee"){const t=String(e.id??e.employee_id??"").trim();return t?{kind:"employee",id:t}:{kind:"fallback"}}if(e.kind==="template"){const t=String(e.id??e.template_id??"").trim();return t?{kind:"template",id:t}:{kind:"fallback"}}return{kind:"fallback"}}function cI(e){const t=lI(e);return t.kind==="fallback"?"fallback:":`${t.kind}:${t.id??""}`}function vH(e,t,n){const r=String(e.role_id??"").trim(),i=String(e.role_label??"").trim(),o=`${r} ${i} ${e.role_responsibility??""}`.toLowerCase(),a=new Set((e.same_role_employee_ids??[]).map(m=>String(m??"").trim()).filter(Boolean)),u=t.map(m=>{const p=String(m.employee_id??"").trim(),h=String(m.employee_name??p).trim()||p,g=String(m.role_id??"").trim(),y=String(m.category??"").trim(),v=[g,y].filter(Boolean).join(" · ")||p;return{kind:"employee",id:p,name:h,subtitle:v,category:y,searchText:`${p} ${h} ${g} ${y} ${(m.domains??[]).join(" ")} ${(m.tags??[]).join(" ")}`.toLowerCase(),rank:a.has(p)||g===r?0:2}}).filter(m=>m.id).sort((m,p)=>m.rank-p.rank||m.name.localeCompare(p.name)),d=n.map(m=>{const p=String(m.template_id??"").trim(),h=String(m.template_name??p).trim()||p,g=String(m.category??"").trim(),y=[g,p].filter(Boolean).join(" · ")||p,v=`${p} ${h} ${g} ${(m.domains??[]).join(" ")} ${(m.tags??[]).join(" ")}`.toLowerCase(),w=o.split(/[^a-z0-9]+/).filter(S=>S.length>=3).reduce((S,_)=>S+(v.includes(_)?1:0),0);return{kind:"template",id:p,name:h,subtitle:y,category:g,searchText:v,rank:w}}).filter(m=>m.id).sort((m,p)=>p.rank-m.rank||m.name.localeCompare(p.name));return[...u,...d,{kind:"fallback",id:"",name:"Fallback role-only",subtitle:"No employee override",category:"fallback",searchText:"fallback role only no employee override"}]}function bH(e,t){const n=cI(t);return e.find(r=>`${r.kind}:${r.id}`===n)??e[0]}function _H(e,t){const n=t.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?!0:n.every(r=>e.searchText.includes(r))}function kH(e){return e.map(t=>{const n=String(t.role_id??"").trim(),r=String(t.existing_employee?.employee_id??"").trim(),i=String(t.candidate?.template_id??"").trim(),o=r?{kind:"employee",id:r}:i?{kind:"template",id:i}:{kind:"fallback"};return{role_id:n,role_label:t.role_labels?.[0]??n,role_responsibility:"",default_selection:o,same_role_employee_ids:t.existing_employee_ids??[],fallback_available:!0,default_agent:t.default_agent??cu,selected_agent:t.selected_agent??t.default_agent??cu,default_source:"recruitment"}}).filter(t=>t.role_id)}function SH(e,t){return t.kind==="template"&&e?.candidate?.template_id===t.id?e.candidate.proposed_name||e.candidate.template_name||t.name:t.kind==="employee"&&e?.existing_employee?.employee_id===t.id&&e.existing_employee.employee_name||t.name}function Mw(e,t){const n={},r=e.staffing_selections??{};for(const i of t){const o=String(i.role_id??"").trim();o&&(n[o]=lI(r[o]??i.default_selection))}return n}function Dw(e,t){const n=e.recruitment_role_agents??{},r={};for(const i of t){const o=String(i.role_id??"").trim();o&&(r[o]=n[o]??i.selected_agent??i.default_agent??cu)}return r}function wH(e){return!!(String(e.checkpoint_response_message_id??"").trim()||String(e.checkpoint_responded_at??"").trim()||String(e.checkpoint_reply_kind??"").trim())}const uI=St.memo(function({meta:t,onReply:n,responded:r}){const i=t.proposals??[],o=E.useMemo(()=>{const L={};for(const A of i){const M=String(A.role_id??"").trim();M&&(L[M]=A)}return L},[i]),a=E.useMemo(()=>t.staffing_roles?.length?t.staffing_roles:kH(i),[t.staffing_roles,i]),u=t.staffing_pool?.employees??[],d=t.staffing_pool?.templates??[],m=t.recruitment_rationales??[],p=E.useMemo(()=>{const L={};for(const A of a){const M=String(A.role_id??"").trim();M&&(L[M]=vH(A,u,d))}return L},[u,a,d]),[h,g]=E.useState({}),[y,v]=E.useState(""),[w,S]=E.useState(()=>Mw(t,a)),[_,k]=E.useState(()=>Dw(t,a)),[C,N]=E.useState(t.recruitment_agent??Fg),O=r;E.useEffect(()=>{!O||!wH(t)||(S(Mw(t,a)),k(Dw(t,a)),N(t.recruitment_agent??Fg))},[O,t,a]),E.useEffect(()=>{N(t.recruitment_agent??Fg)},[t.recruitment_agent]);const I=E.useCallback(L=>{const A=String(t.checkpoint_id??"").trim();if(!A)throw new Error("Recruitment checkpoint reply requires checkpoint_id metadata.");const M=String(t.checkpoint_type??"").trim();return{response_to_checkpoint_id:A,response_to_checkpoint_type:M||"company_recruitment_confirmation",checkpoint_reply_kind:L,staffin Line truncated `).length,m=t.length;return c.jsxs("div",{className:n,children:[c.jsx(Z9,{remarkPlugins:[uH],components:mH,children:u}),i&&o&&c.jsxs("button",{className:"msg-collapse-toggle",onClick:()=>a(!1),children:["Show more (",d," lines, ",(m/1e3).toFixed(1),"k chars)"]}),i&&!o&&c.jsx("button",{className:"msg-collapse-toggle",onClick:()=>a(!0),children:"Show less"})]})}),Aw={native:"OpenOPC Native",codex:"Codex",claude_code:"Claude Code",cursor:"Cursor",opencode:"OpenCode"},cu="codex",Fg="native",xH=["codex","native","claude_code","cursor","opencode"],yH=["native","codex","claude_code","cursor","opencode"];function lI(e){if(!e)return{kind:"fallback"};if(e.kind==="employee"){const t=String(e.id??e.employee_id??"").trim();return t?{kind:"employee",id:t}:{kind:"fallback"}}if(e.kind==="template"){const t=String(e.id??e.template_id??"").trim();return t?{kind:"template",id:t}:{kind:"fallback"}}return{kind:"fallback"}}function cI(e){const t=lI(e);return t.kind==="fallback"?"fallback:":`${t.kind}:${t.id??""}`}function vH(e,t,n){const r=String(e.role_id??"").trim(),i=String(e.role_label??"").trim(),o=`${r} ${i} ${e.role_responsibility??""}`.toLowerCase(),a=new Set((e.same_role_employee_ids??[]).map(m=>String(m??"").trim()).filter(Boolean)),u=t.map(m=>{const p=String(m.employee_id??"").trim(),h=String(m.employee_name??p).trim()||p,g=String(m.role_id??"").trim(),y=String(m.category??"").trim(),v=[g,y].filter(Boolean).join(" · ")||p;return{kind:"employee",id:p,name:h,subtitle:v,category:y,searchText:`${p} ${h} ${g} ${y} ${(m.domains??[]).join(" ")} ${(m.tags??[]).join(" ")}`.toLowerCase(),rank:a.has(p)||g===r?0:2}}).filter(m=>m.id).sort((m,p)=>m.rank-p.rank||m.name.localeCompare(p.name)),d=n.map(m=>{const p=String(m.template_id??"").trim(),h=String(m.template_name??p).trim()||p,g=String(m.category??"").trim(),y=[g,p].filter(Boolean).join(" · ")||p,v=`${p} ${h} ${g} ${(m.domains??[]).join(" ")} ${(m.tags??[]).join(" ")}`.toLowerCase(),k=o.split(/[^a-z0-9]+/).filter(S=>S.length>=3).reduce((S,_)=>S+(v.includes(_)?1:0),0);return{kind:"template",id:p,name:h,subtitle:y,category:g,searchText:v,rank:k}}).filter(m=>m.id).sort((m,p)=>p.rank-m.rank||m.name.localeCompare(p.name));return[...u,...d,{kind:"fallback",id:"",name:"Fallback role-only",subtitle:"No employee override",category:"fallback",searchText:"fallback role only no employee override"}]}function bH(e,t){const n=cI(t);return e.find(r=>`${r.kind}:${r.id}`===n)??e[0]}function _H(e,t){const n=t.toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?!0:n.every(r=>e.searchText.includes(r))}function kH(e){return e.map(t=>{const n=String(t.role_id??"").trim(),r=String(t.existing_employee?.employee_id??"").trim(),i=String(t.candidate?.template_id??"").trim(),o=r?{kind:"employee",id:r}:i?{kind:"template",id:i}:{kind:"fallback"};return{role_id:n,role_label:t.role_labels?.[0]??n,role_responsibility:"",default_selection:o,same_role_employee_ids:t.existing_employee_ids??[],fallback_available:!0,default_agent:t.default_agent??cu,selected_agent:t.selected_agent??t.default_agent??cu,default_source:"recruitment"}}).filter(t=>t.role_id)}function SH(e,t){return t.kind==="template"&&e?.candidate?.template_id===t.id?e.candidate.proposed_name||e.candidate.template_name||t.name:t.kind==="employee"&&e?.existing_employee?.employee_id===t.id&&e.existing_employee.employee_name||t.name}function Mw(e,t){const n={},r=e.staffing_selections??{};for(const i of t){const o=String(i.role_id??"").trim();o&&(n[o]=lI(r[o]??i.default_selection))}return n}function Dw(e,t){const n=e.recruitment_role_agents??{},r={};for(const i of t){const o=String(i.role_id??"").trim();o&&(r[o]=n[o]??i.selected_agent??i.default_agent??cu)}return r}function wH(e){return!!(String(e.checkpoint_response_message_id??"").trim()||String(e.checkpoint_responded_at??"").trim()||String(e.checkpoint_reply_kind??"").trim())}const uI=St.memo(function({meta:t,onReply:n,responded:r}){const i=t.proposals??[],o=j.useMemo(()=>{const L={};for(const A of i){const M=String(A.role_id??"").trim();M&&(L[M]=A)}return L},[i]),a=j.useMemo(()=>t.staffing_roles?.length?t.staffing_roles:kH(i),[t.staffing_roles,i]),u=t.staffing_pool?.employees??[],d=t.staffing_pool?.templates??[],m=t.recruitment_rationales??[],p=j.useMemo(()=>{const L={};for(const A of a){const M=String(A.role_id??"").trim();M&&(L[M]=vH(A,u,d))}return L},[u,a,d]),[h,g]=j.useState({}),[y,v]=j.useState(""),[k,S]=j.useState(()=>Mw(t,a)),[_,w]=j.useState(()=>Dw(t,a)),[C,N]=j.useState(t.recruitment_agent??Fg),O=r;j.useEffect(()=>{!O||!wH(t)||(S(Mw(t,a)),w(Dw(t,a)),N(t.recruitment_agent??Fg))},[O,t,a]),j.useEffect(()=>{N(t.recruitment_agent??Fg)},[t.recruitment_agent]);const I=j.useCallback(L=>{const A=String(t.checkpoint_id??"").trim();if(!A)throw new Error("Recruitment checkpoint reply requires checkpoint_id metadata.");const M=String(t.checkpoint_type??"").trim();return{response_to_checkpoint_id:A,response_to_checkpoint_type:M||"company_recruitment_confirmation",checkpoint_reply_kind:L,staffin Line truncated
`).map(t=>t.trim()).find(Boolean)??e}function MH(e){switch(e){case"timeout":case"timed_out":case"expired":return"Expired";case"stale":case"invalid":return"Inactive";case"cancelled":case"canceled":return"Cancelled";case"resolved":return"Resolved";default:return"Responded"}}const Xf=St.memo(function({meta:t,onReply:n,responded:r}){const i=r,o=String(t.checkpoint_status??"").trim().toLowerCase(),a=MH(o),u=String(t.prompt??t.summary??""),d=E.useMemo(()=>u.split(` `).map(t=>t.trim()).find(Boolean)??e}function DH(e){switch(e){case"timeout":case"timed_out":case"expired":return"Expired";case"stale":case"invalid":return"Inactive";case"cancelled":case"canceled":return"Cancelled";case"resolved":return"Resolved";default:return"Responded"}}const Xf=St.memo(function({meta:t,onReply:n,responded:r}){const i=r,o=String(t.checkpoint_status??"").trim().toLowerCase(),a=DH(o),u=String(t.prompt??t.summary??""),d=j.useMemo(()=>u.split(`
`).map(k=>k.trim()).filter(Boolean),[u]),m=AH(u).replace(/^\[[^\]]+\]\s*/,"")||"Action Required",p=d.slice(1).join(` `).map(O=>O.trim()).filter(Boolean),[u]),m=MH(u).replace(/^\[[^\]]+\]\s*/,"")||"Action Required",p=d.slice(1).join(`
`).trim(),h=String(t.summary??"").trim(),g=(t.options??[]).filter(k=>!!k?.id),y=E.useMemo(()=>(t.active_subagents??[]).filter(k=>!!k&&typeof k=="object"),[t.active_subagents]),v=E.useMemo(()=>(t.permission_requests??[]).filter(k=>!!k&&typeof k=="object"),[t.permission_requests]),w=String(t.worktree_path??"").trim(),S=y.length>0||v.length>0||!!w,_=E.useCallback(k=>{i||n(k.label||k.id)},[i,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-escalation",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-escalation",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 1.5L14.5 13H1.5L8 1.5Z"}),c.jsx("path",{d:"M8 5.5V9"}),c.jsx("circle",{cx:"8",cy:"11.5",r:"0.75",fill:"currentColor",stroke:"none"})]})}),c.jsx("div",{className:"ckpt-title",children:m}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:String(t.escalation_type??"decision_needed").replace(/_/g," ")}),i&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:a})]}),h&&h!==m&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),p&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Request"}),c.jsx(ir,{content:p,className:"ckpt-markdown"})]}),S&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[w&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:w})]}),y.length>0&&c.jsxs("div",{children:["Active subagents: ",y.length]}),v.length>0&&c.jsxs("div",{children:["Pending permission records: ",v.length]})]})]}),!i&&g.length>0&&c.jsx("div",{className:"ckpt-actions ckpt-escalation-actions",children:g.map(k=>c.jsx("button",{className:`ckpt-btn ${k.id.includes("deny")?"ckpt-btn-deny":"ckpt-btn-approve"}`,onClick:()=>_(k),children:k.label||k.id},k.id))}),!i&&t.default_action&&c.jsxs("div",{className:"ckpt-escalation-hint",children:["Default on timeout: ",c.jsx("code",{children:t.default_action})]})]})});function DH(e){return e.split(` `).trim(),h=String(t.summary??"").trim(),g=(t.options??[]).filter(O=>!!O?.id),y=j.useMemo(()=>(t.active_subagents??[]).filter(O=>!!O&&typeof O=="object"),[t.active_subagents]),v=j.useMemo(()=>(t.permission_requests??[]).filter(O=>!!O&&typeof O=="object"),[t.permission_requests]),k=String(t.worktree_path??"").trim(),S=y.length>0||v.length>0||!!k,[_,w]=j.useState(""),C=!!_&&!i;j.useEffect(()=>{if(!C)return;const O=window.setTimeout(()=>w(""),AH);return()=>window.clearTimeout(O)},[C,_]);const N=j.useCallback(O=>{i||C||(w(O.id),n(O.label||O.id))},[i,C,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-escalation",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-escalation",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 1.5L14.5 13H1.5L8 1.5Z"}),c.jsx("path",{d:"M8 5.5V9"}),c.jsx("circle",{cx:"8",cy:"11.5",r:"0.75",fill:"currentColor",stroke:"none"})]})}),c.jsx("div",{className:"ckpt-title",children:m}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:String(t.escalation_type??"decision_needed").replace(/_/g," ")}),i&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:a})]}),h&&h!==m&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),p&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Request"}),c.jsx(ir,{content:p,className:"ckpt-markdown"})]}),S&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[k&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:k})]}),y.length>0&&c.jsxs("div",{children:["Active subagents: ",y.length]}),v.length>0&&c.jsxs("div",{children:["Pending permission records: ",v.length]})]})]}),!i&&g.length>0&&c.jsx("div",{className:"ckpt-actions ckpt-escalation-actions",children:g.map(O=>c.jsx("button",{className:`ckpt-btn ${O.id.includes("deny")?"ckpt-btn-deny":"ckpt-btn-approve"}${C?" ckpt-btn-submitting":""}`,onClick:()=>N(O),disabled:C,children:C&&_===O.id?"Submitting…":O.label||O.id},O.id))}),C&&c.jsx("div",{className:"ckpt-escalation-hint",children:"Decision sent — waiting for server confirmation…"}),!i&&t.default_action&&c.jsxs("div",{className:"ckpt-escalation-hint",children:["Default on timeout: ",c.jsx("code",{children:t.default_action})]})]})});function OH(e){return e.split(`
`).map(t=>t.trim()).find(Boolean)??e}function OH(e){switch(e){case"ignored":return"Ignored";case"timeout":case"timed_out":case"expired":return"Expired";case"stale":case"invalid":return"Inactive";case"superseded":return"Superseded";case"cancelled":case"canceled":return"Cancelled";case"resolved":return"Resolved";default:return"Responded"}}const pI=St.memo(function({meta:t,onReply:n,responded:r}){const i=r,[o,a]=E.useState(""),[u,d]=E.useState(null),m=String(t.checkpoint_status??"").trim().toLowerCase(),p=OH(m),h=String(t.prompt??t.summary??"").trim(),y=`${String(t.work_item_projection_title??DH(h)??"Human Review").trim()||"Human Review"} (for self-evolution)`,v=String(t.summary??"").trim(),w=E.useMemo(()=>(t.active_subagents??[]).filter(T=>!!T&&typeof T=="object"),[t.active_subagents]),S=E.useMemo(()=>(t.permission_requests??[]).filter(T=>!!T&&typeof T=="object"),[t.permission_requests]),_=String(t.worktree_path??"").trim(),k=w.length>0||S.length>0||!!_,C=i||u!==null,N=E.useCallback((T,L="")=>{const A=String(t.checkpoint_id??"").trim();if(!A)throw new Error("Delivery self-evolution reply requires checkpoint_id metadata.");const M={response_to_checkpoint_id:A,response_to_checkpoint_type:"company_delivery_feedback",checkpoint_reply_kind:T};return(T==="approve"||T==="feedback")&&(M.self_evolution_trigger=!0,M.human_feedback_text=L),M},[t.checkpoint_id]),O=E.useCallback(()=>{if(C)return;const T=N("approve");d("approve"),n("I fully agree with this delivery.",T)},[C,N,n]),I=E.useCallback(()=>{const T=o.trim();if(C||!T)return;const L=N("feedback",T);d("feedback"),n(T,L),a("")},[C,N,o,n]),D=E.useCallback(()=>{if(C)return;const T=N("ignore");d("ignore"),n("Ignore this self-evolution review.",T)},[C,N,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-delivery-feedback",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-user-input",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 1.5L14 5v4.5c0 2.25-1.8 4.25-6 5-4.2-.75-6-2.75-6-5V5L8 1.5Z"}),c.jsx("path",{d:"M5.5 8.25L7.25 10l3.25-4"})]})}),c.jsx("div",{className:"ckpt-title",children:y}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:String(t.feedback_scope??"final").replace(/_/g," ")}),i&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:p})]}),v&&v!==y&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:v,className:"ckpt-markdown"})]}),h&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Review Request"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),k&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[_&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:_})]}),w.length>0&&c.jsxs("div",{children:["Active subagents: ",w.length]}),S.length>0&&c.jsxs("div",{children:["Pending permission records: ",S.length]})]})]}),!i&&c.jsxs("div",{className:"ckpt-actions ckpt-actions-inline-feedback",children:[c.jsx("button",{className:"ckpt-btn ckpt-btn-approve",onClick:O,disabled:C,children:"Fully Agree"}),c.jsx("button",{className:"ckpt-btn ckpt-btn-cancel",onClick:D,disabled:C,children:"Ignore"}),c.jsx("textarea",{className:"ckpt-feedback-input ckpt-feedback-inline-input",placeholder:"Feedback for self-evolution...",value:o,onChange:T=>a(T.target.value),disabled:C,rows:2}),c.jsx("button",{className:"ckpt-btn ckpt-btn-feedback",onClick:I,disabled:C||!o.trim(),children:"Send Feedback"})]})]})}),Yd="__other__",LH=["A","B","C"];function Fi(e){return String(e??"").trim()}function zH(e,t){const n=Fi(e.question),r=Fi(e.header);if(!n&&!r)return null;const i=(e.options??[]).slice(0,3).map((o,a)=>({id:Fi(o.id)||String.fromCharCode(97+a),label:Fi(o.label),description:Fi(o.description)})).filter(o=>o.label);return{id:Fi(e.id)||`question_${t+1}`,header:r,question:n||r,options:i,allow_freeform:e.allow_freeform!==!1,required:e.required!==!1}}const gI=St.memo(function({meta:t,onReply:n,responded:r}){const[i,o]=E.useState(""),[a,u]=E.useState({}),d=r,m=String(t.work_item_projection_title??t.work_item_projection_id??"Input Needed").trim()||"Input Needed",p=String(t.summary??"").trim(),h=String(t.prompt??"").trim(),g=String(t.context_note??"").trim(),y=String(t.resume_hint??"").trim(),v=E.useMemo(()=>(t.questions??[]).map(V=>String(V).trim()).filter(Boolean),[t.questions]),w=E.useMemo(()=>(t.input_questions??[]).map((V,Y)=>zH(V,Y)).filter(V=>V!==null),[t.input_questions]),S=w.some(V=>(V.options??[]).length>0),_=E.useMemo(()=>(t.required_fields??[]).map(V=>String(V).trim()).filter(Boolean),[t.required_fields]),k=E.useMemo(()=>(t.active_subagents??[]).filter(V=>!!V&&typeof V=="object"),[t.active_subagents]),C=E.useMemo(( Line truncated `).map(t=>t.trim()).find(Boolean)??e}function LH(e){switch(e){case"ignored":return"Ignored";case"timeout":case"timed_out":case"expired":return"Expired";case"stale":case"invalid":return"Inactive";case"superseded":return"Superseded";case"cancelled":case"canceled":return"Cancelled";case"resolved":return"Resolved";default:return"Responded"}}const pI=St.memo(function({meta:t,onReply:n,responded:r}){const i=r,[o,a]=j.useState(""),[u,d]=j.useState(null),m=String(t.checkpoint_status??"").trim().toLowerCase(),p=LH(m),h=String(t.prompt??t.summary??"").trim(),y=`${String(t.work_item_projection_title??OH(h)??"Human Review").trim()||"Human Review"} (for self-evolution)`,v=String(t.summary??"").trim(),k=j.useMemo(()=>(t.active_subagents??[]).filter(T=>!!T&&typeof T=="object"),[t.active_subagents]),S=j.useMemo(()=>(t.permission_requests??[]).filter(T=>!!T&&typeof T=="object"),[t.permission_requests]),_=String(t.worktree_path??"").trim(),w=k.length>0||S.length>0||!!_,C=i||u!==null,N=j.useCallback((T,L="")=>{const A=String(t.checkpoint_id??"").trim();if(!A)throw new Error("Delivery self-evolution reply requires checkpoint_id metadata.");const M={response_to_checkpoint_id:A,response_to_checkpoint_type:"company_delivery_feedback",checkpoint_reply_kind:T};return(T==="approve"||T==="feedback")&&(M.self_evolution_trigger=!0,M.human_feedback_text=L),M},[t.checkpoint_id]),O=j.useCallback(()=>{if(C)return;const T=N("approve");d("approve"),n("I fully agree with this delivery.",T)},[C,N,n]),I=j.useCallback(()=>{const T=o.trim();if(C||!T)return;const L=N("feedback",T);d("feedback"),n(T,L),a("")},[C,N,o,n]),D=j.useCallback(()=>{if(C)return;const T=N("ignore");d("ignore"),n("Ignore this self-evolution review.",T)},[C,N,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-delivery-feedback",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-user-input",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M8 1.5L14 5v4.5c0 2.25-1.8 4.25-6 5-4.2-.75-6-2.75-6-5V5L8 1.5Z"}),c.jsx("path",{d:"M5.5 8.25L7.25 10l3.25-4"})]})}),c.jsx("div",{className:"ckpt-title",children:y}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:String(t.feedback_scope??"final").replace(/_/g," ")}),i&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:p})]}),v&&v!==y&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:v,className:"ckpt-markdown"})]}),h&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Review Request"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),w&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[_&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:_})]}),k.length>0&&c.jsxs("div",{children:["Active subagents: ",k.length]}),S.length>0&&c.jsxs("div",{children:["Pending permission records: ",S.length]})]})]}),!i&&c.jsxs("div",{className:"ckpt-actions ckpt-actions-inline-feedback",children:[c.jsx("button",{className:"ckpt-btn ckpt-btn-approve",onClick:O,disabled:C,children:"Fully Agree"}),c.jsx("button",{className:"ckpt-btn ckpt-btn-cancel",onClick:D,disabled:C,children:"Ignore"}),c.jsx("textarea",{className:"ckpt-feedback-input ckpt-feedback-inline-input",placeholder:"Feedback for self-evolution...",value:o,onChange:T=>a(T.target.value),disabled:C,rows:2}),c.jsx("button",{className:"ckpt-btn ckpt-btn-feedback",onClick:I,disabled:C||!o.trim(),children:"Send Feedback"})]})]})}),Yd="__other__",zH=["A","B","C"];function Fi(e){return String(e??"").trim()}function PH(e,t){const n=Fi(e.question),r=Fi(e.header);if(!n&&!r)return null;const i=(e.options??[]).slice(0,3).map((o,a)=>({id:Fi(o.id)||String.fromCharCode(97+a),label:Fi(o.label),description:Fi(o.description)})).filter(o=>o.label);return{id:Fi(e.id)||`question_${t+1}`,header:r,question:n||r,options:i,allow_freeform:e.allow_freeform!==!1,required:e.required!==!1}}const gI=St.memo(function({meta:t,onReply:n,responded:r}){const[i,o]=j.useState(""),[a,u]=j.useState({}),d=r,m=String(t.work_item_projection_title??t.work_item_projection_id??"Input Needed").trim()||"Input Needed",p=String(t.summary??"").trim(),h=String(t.prompt??"").trim(),g=String(t.context_note??"").trim(),y=String(t.resume_hint??"").trim(),v=j.useMemo(()=>(t.questions??[]).map(V=>String(V).trim()).filter(Boolean),[t.questions]),k=j.useMemo(()=>(t.input_questions??[]).map((V,Y)=>PH(V,Y)).filter(V=>V!==null),[t.input_questions]),S=k.some(V=>(V.options??[]).length>0),_=j.useMemo(()=>(t.required_fields??[]).map(V=>String(V).trim()).filter(Boolean),[t.required_fields]),w=j.useMemo(()=>(t.active_subagents??[]).filter(V=>!!V&&typeof V=="object"),[t.active_subagents]),C=j.useMemo(( Line truncated
`),{user_input_answers:V})},[a,B,w,d,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-user-input",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-user-input",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M3 3.5h10v6H6.5L3 13V3.5Z"}),c.jsx("path",{d:"M5.5 6h5"}),c.jsx("path",{d:"M5.5 8h3.5"})]})}),c.jsx("div",{className:"ckpt-title",children:m}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:"awaiting input"}),d&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:"Responded"})]}),p&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:p,className:"ckpt-markdown"})]}),h&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Request"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),S?c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Questions"}),c.jsx("div",{className:"ckpt-choice-list",children:w.map(V=>{const Y=a[V.id]??{freeformText:""},Z=V.options??[],q=V.allow_freeform!==!1,G=q&&(Z.length===0||Y.selectedOptionId===Yd);return c.jsxs("div",{className:"ckpt-choice-question",children:[V.header&&c.jsx("div",{className:"ckpt-question-header",children:V.header}),c.jsx(ir,{content:V.question,className:"ckpt-markdown"}),Z.length>0&&c.jsxs("div",{className:"ckpt-choice-grid",children:[Z.map((J,P)=>{const X=Y.selectedOptionId===J.id;return c.jsxs("button",{className:`ckpt-choice-option${X?" is-selected":""}`,onClick:()=>M(V.id,J.id),children:[c.jsx("span",{className:"ckpt-choice-letter",children:LH[P]??"?"}),c.jsxs("span",{className:"ckpt-choice-copy",children:[c.jsx("span",{className:"ckpt-choice-label",children:J.label}),J.description&&c.jsx("span",{className:"ckpt-choice-desc",children:J.description})]})]},J.id)}),q&&c.jsxs("button",{className:`ckpt-choice-option${Y.selectedOptionId===Yd?" is-selected":""}`,onClick:()=>M(V.id,Yd),children:[c.jsx("span",{className:"ckpt-choice-letter",children:"D"}),c.jsxs("span",{className:"ckpt-choice-copy",children:[c.jsx("span",{className:"ckpt-choice-label",children:"Other"}),c.jsx("span",{className:"ckpt-choice-desc",children:"Enter a custom answer"})]})]})]}),G&&c.jsx("textarea",{className:"ckpt-feedback-input ckpt-other-field",placeholder:"Type your answer...",value:Y.freeformText,onChange:J=>$(V.id,J.target.value),rows:3})]},V.id)})})]}):v.length>0&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Questions"}),c.jsx("ul",{className:"ckpt-task-list",children:v.map(V=>c.jsx("li",{children:V},V))})]}),_.length>0&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Required Fields"}),c.jsx("div",{className:"ckpt-task-tags",children:_.map(V=>c.jsx("span",{className:"ckpt-field-tag",children:V},V))})]}),g&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Context"}),c.jsx(ir,{content:g,className:"ckpt-markdown ckpt-markdown-muted"})]}),y&&c.jsx("div",{className:"ckpt-escalation-hint",children:y}),A&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[O&&c.jsxs("div",{children:["Requester: ",c.jsx("code",{children:O})]}),D&&c.jsxs("div",{children:["Work item: ",c.jsx("code",{children:D})]}),I&&c.jsxs("div",{children:["Task: ",c.jsx("code",{children:I})]}),T&&c.jsxs("div",{children:["Seat: ",c.jsx("code",{children:T})]}),N&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:N})]}),k.length>0&&c.jsxs("div",{children:["Active subagents: ",k.length]}),C.length>0&&c.jsxs("div",{children:["Pending permission records: ",C.length]})]})]}),!d&&c.jsxs("div",{className:"ckpt-feedback-area",children:[S?null:c.jsx("textarea",{className:"ckpt-feedback-input",placeholder:"Reply with the missing input to continue...",value:i,onChange:V=>o(V.target.value),rows:3}),c.jsx("div",{className:"ckpt-feedback-btns",children:c.jsx("button",{className:"ckpt-btn ckpt-btn-approve",onClick:S?H:U,disabled:S?!B:!i.trim(),children:"Send Reply"})})]})]})}),Hy={todo:"To do",in_progress:"In progress",in_review:"In review",done:"Done"};function Ug(e,t){if(t&&t in Hy)return t;switch(e){case"active":return"in_progress";case"waiting":return"in_review";case"done":return"done";case"failed":return"done";case"pending":return"todo";default:return"todo"}}function Xd(e){return Hy[e]??Hy.todo}const Bw={active:0,waiting:1,failed:2,done:3,pending:4};function PH(e){if(e.length===0)return"pending";let t=e[0],n=Bw[t]??99;for(const r of e){const i=Bw[r]??99;i<n&&(t=r,n=i)}return t}const BH={native:"Native",codex:"Codex",claude_code:"Claude Code",cursor Line truncated `),{user_input_answers:V})},[a,B,k,d,n]);return c.jsxs("div",{className:"ckpt-panel ckpt-user-input",children:[c.jsxs("div",{className:"ckpt-header",children:[c.jsx("div",{className:"ckpt-icon ckpt-icon-user-input",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M3 3.5h10v6H6.5L3 13V3.5Z"}),c.jsx("path",{d:"M5.5 6h5"}),c.jsx("path",{d:"M5.5 8h3.5"})]})}),c.jsx("div",{className:"ckpt-title",children:m}),c.jsx("span",{className:"ckpt-badge ckpt-badge-scope",children:"awaiting input"}),d&&c.jsx("span",{className:"ckpt-badge ckpt-badge-responded",children:"Responded"})]}),p&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Summary"}),c.jsx(ir,{content:p,className:"ckpt-markdown"})]}),h&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Request"}),c.jsx(ir,{content:h,className:"ckpt-markdown"})]}),S?c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Questions"}),c.jsx("div",{className:"ckpt-choice-list",children:k.map(V=>{const Y=a[V.id]??{freeformText:""},Z=V.options??[],q=V.allow_freeform!==!1,G=q&&(Z.length===0||Y.selectedOptionId===Yd);return c.jsxs("div",{className:"ckpt-choice-question",children:[V.header&&c.jsx("div",{className:"ckpt-question-header",children:V.header}),c.jsx(ir,{content:V.question,className:"ckpt-markdown"}),Z.length>0&&c.jsxs("div",{className:"ckpt-choice-grid",children:[Z.map((J,P)=>{const X=Y.selectedOptionId===J.id;return c.jsxs("button",{className:`ckpt-choice-option${X?" is-selected":""}`,onClick:()=>M(V.id,J.id),children:[c.jsx("span",{className:"ckpt-choice-letter",children:zH[P]??"?"}),c.jsxs("span",{className:"ckpt-choice-copy",children:[c.jsx("span",{className:"ckpt-choice-label",children:J.label}),J.description&&c.jsx("span",{className:"ckpt-choice-desc",children:J.description})]})]},J.id)}),q&&c.jsxs("button",{className:`ckpt-choice-option${Y.selectedOptionId===Yd?" is-selected":""}`,onClick:()=>M(V.id,Yd),children:[c.jsx("span",{className:"ckpt-choice-letter",children:"D"}),c.jsxs("span",{className:"ckpt-choice-copy",children:[c.jsx("span",{className:"ckpt-choice-label",children:"Other"}),c.jsx("span",{className:"ckpt-choice-desc",children:"Enter a custom answer"})]})]})]}),G&&c.jsx("textarea",{className:"ckpt-feedback-input ckpt-other-field",placeholder:"Type your answer...",value:Y.freeformText,onChange:J=>$(V.id,J.target.value),rows:3})]},V.id)})})]}):v.length>0&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Questions"}),c.jsx("ul",{className:"ckpt-task-list",children:v.map(V=>c.jsx("li",{children:V},V))})]}),_.length>0&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Required Fields"}),c.jsx("div",{className:"ckpt-task-tags",children:_.map(V=>c.jsx("span",{className:"ckpt-field-tag",children:V},V))})]}),g&&c.jsxs("div",{className:"ckpt-section",children:[c.jsx("div",{className:"ckpt-section-title",children:"Context"}),c.jsx(ir,{content:g,className:"ckpt-markdown ckpt-markdown-muted"})]}),y&&c.jsx("div",{className:"ckpt-escalation-hint",children:y}),A&&c.jsxs("details",{className:"ckpt-runtime-details",children:[c.jsx("summary",{children:"Runtime State"}),c.jsxs("div",{className:"ckpt-runtime-body",children:[O&&c.jsxs("div",{children:["Requester: ",c.jsx("code",{children:O})]}),D&&c.jsxs("div",{children:["Work item: ",c.jsx("code",{children:D})]}),I&&c.jsxs("div",{children:["Task: ",c.jsx("code",{children:I})]}),T&&c.jsxs("div",{children:["Seat: ",c.jsx("code",{children:T})]}),N&&c.jsxs("div",{children:["Worktree: ",c.jsx("code",{children:N})]}),w.length>0&&c.jsxs("div",{children:["Active subagents: ",w.length]}),C.length>0&&c.jsxs("div",{children:["Pending permission records: ",C.length]})]})]}),!d&&c.jsxs("div",{className:"ckpt-feedback-area",children:[S?null:c.jsx("textarea",{className:"ckpt-feedback-input",placeholder:"Reply with the missing input to continue...",value:i,onChange:V=>o(V.target.value),rows:3}),c.jsx("div",{className:"ckpt-feedback-btns",children:c.jsx("button",{className:"ckpt-btn ckpt-btn-approve",onClick:S?H:U,disabled:S?!B:!i.trim(),children:"Send Reply"})})]})]})}),Hy={todo:"To do",in_progress:"In progress",in_review:"In review",done:"Done"};function Ug(e,t){if(t&&t in Hy)return t;switch(e){case"active":return"in_progress";case"waiting":return"in_review";case"done":return"done";case"failed":return"done";case"pending":return"todo";default:return"todo"}}function Xd(e){return Hy[e]??Hy.todo}const Bw={active:0,waiting:1,failed:2,done:3,pending:4};function BH(e){if(e.length===0)return"pending";let t=e[0],n=Bw[t]??99;for(const r of e){const i=Bw[r]??99;i<n&&(t=r,n=i)}return t}const $H={native:"Native",codex:"Codex",claude_code:"Claude Code",cursor Line truncated
`)[0].slice(0,140),tone:"danger"};const o=t.match(/^\[Company:([^\]]+)\]\s*(.+)$/);if(o){const d=o[1].split("::"),m=d[0]||"company",p=o[2].trim(),h=p.toLowerCase(),g=h.includes("completed")||h.includes("done")?"success":h.includes("blocked")||h.includes("failed")?"warning":"info";return{kind:"company_event",label:`${m.toUpperCase()} · ${d[1]??""}`.replace(/ · $/,""),summary:p,tone:g}}const a=t.match(/^(Review needed|Status digest|Blocked|Completion):\s*(.+)$/i);if(a){const d=a[1].replace(/\b\w/g,p=>p.toUpperCase()),m=qc(a[2]);return{kind:"company_event",label:d,summary:m,tone:/^Blocked$/i.test(a[1])?"warning":"info"}}const u=t.match(/^NO_DELEGATION_JUSTIFICATION:\s*(.+)$/i);return u?{kind:"company_event",label:"Delegation check",summary:qc(u[1]).slice(0,180),tone:"info"}:null}function pF(e,t){const{isCompanyRuntime:n,detailMode:r}=t;if(!n||r==="full"||Qc(e.metadata))return null;const i=yI(e.content);if(!i)return null;const o=e.sender==="system"||e.metadata?.type==="system",a=i.kind==="company_event"||e.content.startsWith("[Company:");return!o&&!a?null:{msg:e,classification:i}}function gF(e,t={}){const{isCompanyRuntime:n=!1,detailMode:r="summary"}=t,i=[];let o=[],a=0;const u=new Set,d=new Set,m=()=>{if(o.length===0)return;const p=o[0].msg,h=o[o.length-1].msg;i.push({kind:"ops-bundle",id:`ops:${p.id}:${o.length}:${h.id}`,timestamp:p.timestamp,events:o,sortOrder:a}),o=[]};return e.forEach((p,h)=>{const g=h*2+1,y=pF(p,{isCompanyRuntime:n,detailMode:r});if(y){o.length===0&&(a=g),o.push(y);return}const v=r==="summary"?xI(p.content):null;if(v){const w=[p.sender,Math.round(p.timestamp/1e3),v.kind,qc(v.summary||v.acceptanceSummary||"").slice(0,500),v.verdict??"",v.deliverables.map(S=>`${S.name}:${S.path}`).join("|").slice(0,800)].join("");if(u.has(w))return;u.add(w)}if(r==="summary"){const w=qc(iF(p.content)).slice(0,1200);if(w){const S=sF(p)?["result",w].join(""):[p.sender,Math.round(p.timestamp/1e3),w].join("");if(d.has(S))return;d.add(S)}}m(),i.push({kind:"message",id:p.id,timestamp:p.timestamp,msg:p,sortOrder:g})}),m(),i}const xF=St.memo(function({msg:t,showDate:n,dateStr:r,classification:i}){const[o,a]=E.useState(!1),u=t.content.trim()!==`[${i.label}] ${i.summary}`.trim()&&t.content.trim().length>i.summary.length+4;return c.jsxs("div",{children:[n&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("span",{children:r})}),c.jsxs("div",{className:`msg-ops-row msg-ops-tone-${i.tone}${o?" expanded":""}`,onClick:u?()=>a(d=>!d):void 0,role:u?"button":void 0,tabIndex:u?0:-1,children:[c.jsx("span",{className:"msg-ops-dot","aria-hidden":"true"}),c.jsx("span",{className:"msg-ops-label",children:i.label}),i.summary&&c.jsx("span",{className:"msg-ops-summary",title:i.summary,children:i.summary}),c.jsx("span",{className:"msg-ops-time",title:Yi(t.timestamp),children:Ss(t.timestamp)}),u&&c.jsx("span",{className:`msg-ops-chevron${o?" open":""}`,"aria-hidden":"true",children:c.jsx(_s,{down:o})})]}),u&&o&&c.jsx("div",{className:"msg-ops-details",children:c.jsx("pre",{className:"msg-ops-details-pre",children:t.content})})]})}),yF=St.memo(function({events:t,showDate:n,dateStr:r}){const[i,o]=E.useState(!1);if(t.length===0)return null;const a=t[0].msg,u=t[t.length-1].msg,d=t.reduce((h,g)=>{const y=g.classification.kind==="company_event"?"company":g.classification.kind.startsWith("external")?"runtime":"delegation";return h[y]=(h[y]??0)+1,h},{}),m=Object.entries(d).map(([h,g])=>`${g} ${h}`).join(" · "),p=`${t.length} technical event${t.length===1?"":"s"} hidden`;return c.jsxs("div",{children:[n&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("span",{children:r})}),c.jsxs("button",{type:"button",className:`msg-ops-bundle${i?" expanded":""}`,onClick:()=>o(h=>!h),title:`${Yi(a.timestamp)} - ${Yi(u.timestamp)}`,children:[c.jsx("span",{className:"msg-ops-bundle-dot"}),c.jsx("span",{className:"msg-ops-bundle-title",children:p}),c.jsx("span",{className:"msg-ops-bundle-summary",children:m}),c.jsx("span",{className:"msg-ops-bundle-time",children:Ss(a.timestamp)}),c.jsx("span",{className:"msg-ops-bundle-chevron",children:c.jsx(_s,{down:i})})]}),i&&c.jsx("div",{className:"msg-ops-bundle-details",children:t.map(({msg:h,classification:g})=>c.jsxs("div",{className:`msg-ops-bundle-event msg-ops-tone-${g.tone}`,children:[c.jsx("span",{className:"msg-ops-dot"}),c.jsx("span",{className:"msg-ops-label",children:g.label}),c.jsx("span",{className:"msg-ops-summary",children:g.summary}),c.jsx("span",{className:"msg-ops-time",title:Yi(h.timestamp),children:Ss(h.timestamp)})]},h.id))})]})});function vF(e){return e.kind==="review"?`Review · ${e.verdict?e.verdict.replace(/_/g," "):"review"}`:e.kind==="report"?"Report":"Update"}const bF=St.memo(function({msg:t,payload:n,showDate:r,dateStr:i,isCopied:o,onCopy:a}){const u=lv(t.sender==="system"?t.senderName||"OPC":t.sender),d=t.senderDeleted?"[Deleted]":t.senderName,m=vF(n),p=n.summary||n.acceptanceSummary||m;return c.jsxs("div",{children:[r&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("spa Line truncated `)[0].slice(0,140),tone:"danger"};const o=t.match(/^\[Company:([^\]]+)\]\s*(.+)$/);if(o){const d=o[1].split("::"),m=d[0]||"company",p=o[2].trim(),h=p.toLowerCase(),g=h.includes("completed")||h.includes("done")?"success":h.includes("blocked")||h.includes("failed")?"warning":"info";return{kind:"company_event",label:`${m.toUpperCase()} · ${d[1]??""}`.replace(/ · $/,""),summary:p,tone:g}}const a=t.match(/^(Review needed|Status digest|Blocked|Completion):\s*(.+)$/i);if(a){const d=a[1].replace(/\b\w/g,p=>p.toUpperCase()),m=qc(a[2]);return{kind:"company_event",label:d,summary:m,tone:/^Blocked$/i.test(a[1])?"warning":"info"}}const u=t.match(/^NO_DELEGATION_JUSTIFICATION:\s*(.+)$/i);return u?{kind:"company_event",label:"Delegation check",summary:qc(u[1]).slice(0,180),tone:"info"}:null}function gF(e,t){const{isCompanyRuntime:n,detailMode:r}=t;if(!n||r==="full"||Qc(e.metadata))return null;const i=yI(e.content);if(!i)return null;const o=e.sender==="system"||e.metadata?.type==="system",a=i.kind==="company_event"||e.content.startsWith("[Company:");return!o&&!a?null:{msg:e,classification:i}}function xF(e,t={}){const{isCompanyRuntime:n=!1,detailMode:r="summary"}=t,i=[];let o=[],a=0;const u=new Set,d=new Set,m=()=>{if(o.length===0)return;const p=o[0].msg,h=o[o.length-1].msg;i.push({kind:"ops-bundle",id:`ops:${p.id}:${o.length}:${h.id}`,timestamp:p.timestamp,events:o,sortOrder:a}),o=[]};return e.forEach((p,h)=>{const g=h*2+1,y=gF(p,{isCompanyRuntime:n,detailMode:r});if(y){o.length===0&&(a=g),o.push(y);return}const v=r==="summary"?xI(p.content):null;if(v){const k=[p.sender,Math.round(p.timestamp/1e3),v.kind,qc(v.summary||v.acceptanceSummary||"").slice(0,500),v.verdict??"",v.deliverables.map(S=>`${S.name}:${S.path}`).join("|").slice(0,800)].join("");if(u.has(k))return;u.add(k)}if(r==="summary"){const k=qc(sF(p.content)).slice(0,1200);if(k){const S=oF(p)?["result",k].join(""):[p.sender,Math.round(p.timestamp/1e3),k].join("");if(d.has(S))return;d.add(S)}}m(),i.push({kind:"message",id:p.id,timestamp:p.timestamp,msg:p,sortOrder:g})}),m(),i}const yF=St.memo(function({msg:t,showDate:n,dateStr:r,classification:i}){const[o,a]=j.useState(!1),u=t.content.trim()!==`[${i.label}] ${i.summary}`.trim()&&t.content.trim().length>i.summary.length+4;return c.jsxs("div",{children:[n&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("span",{children:r})}),c.jsxs("div",{className:`msg-ops-row msg-ops-tone-${i.tone}${o?" expanded":""}`,onClick:u?()=>a(d=>!d):void 0,role:u?"button":void 0,tabIndex:u?0:-1,children:[c.jsx("span",{className:"msg-ops-dot","aria-hidden":"true"}),c.jsx("span",{className:"msg-ops-label",children:i.label}),i.summary&&c.jsx("span",{className:"msg-ops-summary",title:i.summary,children:i.summary}),c.jsx("span",{className:"msg-ops-time",title:Xi(t.timestamp),children:Ss(t.timestamp)}),u&&c.jsx("span",{className:`msg-ops-chevron${o?" open":""}`,"aria-hidden":"true",children:c.jsx(qi,{down:o})})]}),u&&o&&c.jsx("div",{className:"msg-ops-details",children:c.jsx("pre",{className:"msg-ops-details-pre",children:t.content})})]})}),vF=St.memo(function({events:t,showDate:n,dateStr:r}){const[i,o]=j.useState(!1);if(t.length===0)return null;const a=t[0].msg,u=t[t.length-1].msg,d=t.reduce((h,g)=>{const y=g.classification.kind==="company_event"?"company":g.classification.kind.startsWith("external")?"runtime":"delegation";return h[y]=(h[y]??0)+1,h},{}),m=Object.entries(d).map(([h,g])=>`${g} ${h}`).join(" · "),p=`${t.length} technical event${t.length===1?"":"s"} hidden`;return c.jsxs("div",{children:[n&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("span",{children:r})}),c.jsxs("button",{type:"button",className:`msg-ops-bundle${i?" expanded":""}`,onClick:()=>o(h=>!h),title:`${Xi(a.timestamp)} - ${Xi(u.timestamp)}`,children:[c.jsx("span",{className:"msg-ops-bundle-dot"}),c.jsx("span",{className:"msg-ops-bundle-title",children:p}),c.jsx("span",{className:"msg-ops-bundle-summary",children:m}),c.jsx("span",{className:"msg-ops-bundle-time",children:Ss(a.timestamp)}),c.jsx("span",{className:"msg-ops-bundle-chevron",children:c.jsx(qi,{down:i})})]}),i&&c.jsx("div",{className:"msg-ops-bundle-details",children:t.map(({msg:h,classification:g})=>c.jsxs("div",{className:`msg-ops-bundle-event msg-ops-tone-${g.tone}`,children:[c.jsx("span",{className:"msg-ops-dot"}),c.jsx("span",{className:"msg-ops-label",children:g.label}),c.jsx("span",{className:"msg-ops-summary",children:g.summary}),c.jsx("span",{className:"msg-ops-time",title:Xi(h.timestamp),children:Ss(h.timestamp)})]},h.id))})]})});function bF(e){return e.kind==="review"?`Review · ${e.verdict?e.verdict.replace(/_/g," "):"review"}`:e.kind==="report"?"Report":"Update"}const _F=St.memo(function({msg:t,payload:n,showDate:r,dateStr:i,isCopied:o,onCopy:a}){const u=lv(t.sender==="system"?t.senderName||"OPC":t.sender),d=t.senderDeleted?"[Deleted]":t.senderName,m=bF(n),p=n.summary||n.acceptanceSummary||m;return c.jsxs("div",{children:[r&&c.jsx("div",{className:"msg-date-sep",children:c.jsx("spa Line truncated
Set up at least one role before running a task. Set up at least one role before running a task.
@@ -129,27 +129,27 @@ Go to Org tab now?`)&&n?.(),!1;const d=[],m=new Set(r.map(y=>y.role_id));o.runti
`+d.map(y=>"• "+y).join(` `+d.map(y=>"• "+y).join(`
`)+` `)+`
Run anyway?`):!0}function eV(e){if(!e)return!1;const t=Em(e);return!!(t.projectRun?.run_id||t.runtimeTeams.length>0||t.runtimeSeats.length>0)}function nC(e,t){const n=!!t?.childDetail;return e?n?"full":e.execMode==="company"||e.execMode==="org"||e.execMode==="custom"?"summary":"full":"summary"}function rC(e){return String(e?.originTaskId??e?.taskId??"").trim()||null}function tV({boardColor:e,title:t,onCommit:n}){const[r,i]=E.useState(!1),[o,a]=E.useState(t),u=E.useRef(null);E.useEffect(()=>{r||a(t)},[t,r]);const d=E.useCallback(()=>{const p=o.trim();p&&p!==t?n(p):a(t),i(!1)},[o,t,n]),m=E.useCallback(()=>{a(t),i(!0),setTimeout(()=>u.current?.select(),0)},[t]);return c.jsx("div",{className:"board-selector",children:c.jsx("div",{className:"board-tabs",children:c.jsxs("span",{className:"board-tab active board-tab-editable",style:{"--board-color":e},children:[c.jsx("span",{className:"board-tab-dot",style:{background:e}}),r?c.jsx("input",{ref:u,className:"board-tab-title-input",value:o,onChange:p=>a(p.target.value),onBlur:d,onKeyDown:p=>{p.key==="Enter"&&d(),p.key==="Escape"&&(a(t),i(!1))}}):c.jsx("span",{className:"board-tab-title",onClick:m,title:"Click to edit session title",children:t})]})})})}function nV({boardStore:e,agents:t,officeMap:n,execMode:r,companyProfile:i,taskPreferredAgent:o,chatStore:a,sessionStore:u,projectId:d,onRunTask:m,onCreateTask:p,onMoveTask:h,onCreateSession:g,onSessionSend:y,onSecretarySend:v,onDeleteSession:w,onTitleChange:S,onSessionConfigChange:_,onSessionTaskAgentChange:k,onContinueInNewChat:C,onSessionStop:N,onSessionResume:O,onSessionComplete:I,onLoadSessionDetail:D,onOpenExecutionPanel:T,onCollabSync:L,orgInfoData:A,onNavigateToOrg:M,recoveryStatus:$,onRecoveryResume:W,onRecoveryCancel:B,commsState:U,commsMessage:H,onCommsRefresh:V,onCommsReadMessage:Y,savedOrgsList:Z,activeSavedOrg:q,onSavedOrgsList:G,onSavedOrgLoad:J}){const{sessions:P,activeSessionId:X,activeSession:ee}=u,[te,re]=E.useState("collapsed"),{width:oe,isResizing:de,handleMouseDown:se}=KF({initialWidth:380,minWidth:300,maxWidth:600,onCollapse:()=>re("collapsed")}),[je,we]=E.useState("chat"),[Ce,Be]=E.useState(null),[Ge,Ye]=E.useState({kind:"activity"}),[yt,Vt]=E.useState([]),[bt,vt]=E.useState(!1),[me,Oe]=E.useState({}),rt=E.useRef(D),Qe=E.useRef({active:null,child:null}),Je=r==="company"||r==="org"||r==="custom",fe=`secretary:${d}`,be=`activity:${d}`,Me=E.useMemo(()=>Ce?P.find(ue=>ue.taskId===Ce)??null:null,[P,Ce]),Fe=E.useMemo(()=>Ge.kind!=="task-detail"?null:e.tasks.find(ue=>ue.id===Ge.taskId)??null,[Ge,e.tasks]),$e=E.useMemo(()=>{const ue=jm(Fe);return ue?P.find(Se=>Se.taskId===ue||Se.runtimeTaskId===ue||Se.executionTurnId===ue)??null:null},[P,Fe]),Ut=E.useMemo(()=>$e?a.getChannelMessages($e.channelId):[],[a.messages,a.getChannelMessages,$e]),rn=E.useMemo(()=>gf(ee,P),[P,ee]),ke=E.useMemo(()=>Tf(ee,P),[P,ee]),Te=E.useMemo(()=>Rf(ee,[...ke,...rn]),[ee,rn,ke]);E.useEffect(()=>{rt.current=D},[D]);const Pe=E.useCallback((ue,Se,Ue="summary")=>{const pt=rt.current;!pt||!ue||(Oe(tn=>tn[ue]?tn:{...tn,[ue]:!0}),pt(ue,{limit:ZF,beforeCreatedAt:Se?.timestamp,beforeMessageId:Se?.id,detailLevel:Ue}),window.setTimeout(()=>{Oe(tn=>tn[ue]?{...tn,[ue]:!1}:tn)},800))},[]),Ve=E.useCallback(ue=>!!me[ue],[me]);E.useEffect(()=>{Qe.current={active:null,child:null}},[d]),E.useEffect(()=>{Ce&&!Me&&Be(null)},[Ce,Me]),E.useEffect(()=>{Ge.kind==="task-detail"&&!Fe&&Ye({kind:"activity"})},[Ge,Fe]);const qe=E.useRef(null);E.useEffect(()=>{if(!$e){qe.current=null;return}qe.current!==$e.taskId&&(qe.current=$e.taskId,Pe($e.taskId,void 0,"full"))},[$e,Pe]),E.useEffect(()=>{if(!Ce){Qe.current.child=null;return}Qe.current.child!==Ce&&(Qe.current.child=Ce,Pe(Ce,void 0,"full"))},[Ce,Pe]),E.useEffect(()=>{if(!X){Qe.current.active=null;return}const ue=Te.timelineSessions.length>0?Te.timelineSessions:P.find(Ue=>Ue.taskId===X)?[P.find(Ue=>Ue.taskId===X)]:[];if(ue.length===0){Qe.current.active=null;return}const Se=ue.map(Ue=>`${Ue.taskId}:${nC(Ue,{childDetail:Ue.mode==="child"})}`).join("|");if(Qe.current.active!==Se){Qe.current.active=Se;for(const Ue of ue)Pe(Ue.taskId,void 0,nC(Ue,{childDetail:Ue.mode==="child"}))}},[Te.timelineSessions,X,Pe,P]);const et=E.useMemo(()=>Ce?{kind:"child-detail"}:Ge.kind==="task-detail"||Ge.kind==="secretary"?Ge:X?{kind:"session",taskId:X}:{kind:"activity"},[Ge,X,Ce]),Mn=E.useMemo(()=>et.kind==="secretary"?fe:et.kind==="child-detail"&&Me?Me.channelId:et.kind==="session"&&Te.displaySession?Te.displaySession.channelId:et.kind==="session"&&ee?ee.channelId:be,[et,Te.displaySession,ee,Me,fe,be]),Tn=E.useMemo(()=>{if(et.kind==="activity")return[be];if(et.kind==="secretary")return[fe];if(et.kind==="child-detail"&&Me)return[Me.channelId];if(et.kind==="session"){const ue=Te.timelineSessions.map(Se=>Se.channelId).filter((Se,Ue,pt)=>!!Se&&pt.indexOf(Se)===Ue);if(ue.length>0)return ue}return Mn?[Mn]:[]},[et.kind,Te.timelineSessions,Me,be,fe,Mn]),Dn=E.useMemo(()=>{const ue=new Set;for(const Se of P)Se.status!=="cancelled"&&ue.add(Se. Line truncated Run anyway?`):!0}function tV(e){if(!e)return!1;const t=Em(e);return!!(t.projectRun?.run_id||t.runtimeTeams.length>0||t.runtimeSeats.length>0)}function nC(e,t){const n=!!t?.childDetail;return e?n?"full":e.execMode==="company"||e.execMode==="org"||e.execMode==="custom"?"summary":"full":"summary"}function rC(e){return String(e?.originTaskId??e?.taskId??"").trim()||null}function nV({boardColor:e,title:t,onCommit:n}){const[r,i]=j.useState(!1),[o,a]=j.useState(t),u=j.useRef(null);j.useEffect(()=>{r||a(t)},[t,r]);const d=j.useCallback(()=>{const p=o.trim();p&&p!==t?n(p):a(t),i(!1)},[o,t,n]),m=j.useCallback(()=>{a(t),i(!0),setTimeout(()=>u.current?.select(),0)},[t]);return c.jsx("div",{className:"board-selector",children:c.jsx("div",{className:"board-tabs",children:c.jsxs("span",{className:"board-tab active board-tab-editable",style:{"--board-color":e},children:[c.jsx("span",{className:"board-tab-dot",style:{background:e}}),r?c.jsx("input",{ref:u,className:"board-tab-title-input",value:o,onChange:p=>a(p.target.value),onBlur:d,onKeyDown:p=>{p.key==="Enter"&&d(),p.key==="Escape"&&(a(t),i(!1))}}):c.jsx("span",{className:"board-tab-title",onClick:m,title:"Click to edit session title",children:t})]})})})}function rV({boardStore:e,agents:t,officeMap:n,execMode:r,companyProfile:i,taskPreferredAgent:o,chatStore:a,sessionStore:u,projectId:d,onRunTask:m,onCreateTask:p,onMoveTask:h,onCreateSession:g,onSessionSend:y,onSecretarySend:v,onDeleteSession:k,onTitleChange:S,onSessionConfigChange:_,onSessionTaskAgentChange:w,onContinueInNewChat:C,onSessionStop:N,onSessionResume:O,onSessionComplete:I,onLoadSessionDetail:D,onOpenExecutionPanel:T,onCollabSync:L,orgInfoData:A,onNavigateToOrg:M,recoveryStatus:$,onRecoveryResume:W,onRecoveryCancel:B,commsState:U,commsMessage:H,onCommsRefresh:V,onCommsReadMessage:Y,savedOrgsList:Z,activeSavedOrg:q,onSavedOrgsList:G,onSavedOrgLoad:J}){const{sessions:P,activeSessionId:X,activeSession:ee}=u,[te,re]=j.useState("collapsed"),{width:oe,isResizing:de,handleMouseDown:se}=ZF({initialWidth:380,minWidth:300,maxWidth:600,onCollapse:()=>re("collapsed")}),[je,we]=j.useState("chat"),[Ce,Be]=j.useState(null),[Ge,Ye]=j.useState({kind:"activity"}),[yt,Vt]=j.useState([]),[bt,vt]=j.useState(!1),[me,Oe]=j.useState({}),rt=j.useRef(D),Qe=j.useRef({active:null,child:null}),Je=r==="company"||r==="org"||r==="custom",fe=`secretary:${d}`,be=`activity:${d}`,Me=j.useMemo(()=>Ce?P.find(ue=>ue.taskId===Ce)??null:null,[P,Ce]),Fe=j.useMemo(()=>Ge.kind!=="task-detail"?null:e.tasks.find(ue=>ue.id===Ge.taskId)??null,[Ge,e.tasks]),$e=j.useMemo(()=>{const ue=jm(Fe);return ue?P.find(Se=>Se.taskId===ue||Se.runtimeTaskId===ue||Se.executionTurnId===ue)??null:null},[P,Fe]),Ut=j.useMemo(()=>$e?a.getChannelMessages($e.channelId):[],[a.messages,a.getChannelMessages,$e]),rn=j.useMemo(()=>gf(ee,P),[P,ee]),ke=j.useMemo(()=>Tf(ee,P),[P,ee]),Te=j.useMemo(()=>Rf(ee,[...ke,...rn]),[ee,rn,ke]);j.useEffect(()=>{rt.current=D},[D]);const Pe=j.useCallback((ue,Se,Ue="summary")=>{const pt=rt.current;!pt||!ue||(Oe(tn=>tn[ue]?tn:{...tn,[ue]:!0}),pt(ue,{limit:QF,beforeCreatedAt:Se?.timestamp,beforeMessageId:Se?.id,detailLevel:Ue}),window.setTimeout(()=>{Oe(tn=>tn[ue]?{...tn,[ue]:!1}:tn)},800))},[]),Ve=j.useCallback(ue=>!!me[ue],[me]);j.useEffect(()=>{Qe.current={active:null,child:null}},[d]),j.useEffect(()=>{Ce&&!Me&&Be(null)},[Ce,Me]),j.useEffect(()=>{Ge.kind==="task-detail"&&!Fe&&Ye({kind:"activity"})},[Ge,Fe]);const qe=j.useRef(null);j.useEffect(()=>{if(!$e){qe.current=null;return}qe.current!==$e.taskId&&(qe.current=$e.taskId,Pe($e.taskId,void 0,"full"))},[$e,Pe]),j.useEffect(()=>{if(!Ce){Qe.current.child=null;return}Qe.current.child!==Ce&&(Qe.current.child=Ce,Pe(Ce,void 0,"full"))},[Ce,Pe]),j.useEffect(()=>{if(!X){Qe.current.active=null;return}const ue=Te.timelineSessions.length>0?Te.timelineSessions:P.find(Ue=>Ue.taskId===X)?[P.find(Ue=>Ue.taskId===X)]:[];if(ue.length===0){Qe.current.active=null;return}const Se=ue.map(Ue=>`${Ue.taskId}:${nC(Ue,{childDetail:Ue.mode==="child"})}`).join("|");if(Qe.current.active!==Se){Qe.current.active=Se;for(const Ue of ue)Pe(Ue.taskId,void 0,nC(Ue,{childDetail:Ue.mode==="child"}))}},[Te.timelineSessions,X,Pe,P]);const et=j.useMemo(()=>Ce?{kind:"child-detail"}:Ge.kind==="task-detail"||Ge.kind==="secretary"?Ge:X?{kind:"session",taskId:X}:{kind:"activity"},[Ge,X,Ce]),Mn=j.useMemo(()=>et.kind==="secretary"?fe:et.kind==="child-detail"&&Me?Me.channelId:et.kind==="session"&&Te.displaySession?Te.displaySession.channelId:et.kind==="session"&&ee?ee.channelId:be,[et,Te.displaySession,ee,Me,fe,be]),Tn=j.useMemo(()=>{if(et.kind==="activity")return[be];if(et.kind==="secretary")return[fe];if(et.kind==="child-detail"&&Me)return[Me.channelId];if(et.kind==="session"){const ue=Te.timelineSessions.map(Se=>Se.channelId).filter((Se,Ue,pt)=>!!Se&&pt.indexOf(Se)===Ue);if(ue.length>0)return ue}return Mn?[Mn]:[]},[et.kind,Te.timelineSessions,Me,be,fe,Mn]),Dn=j.useMemo(()=>{const ue=new Set;for(const Se of P)Se.status!=="cancelled"&&ue.add(Se. Line truncated
`).replace(/\r/g,` `).replace(/\r/g,`
`).split(` `).split(`
`).map(i=>i.trimEnd()).join(` `).map(i=>i.trimEnd()).join(`
`).replace(/\n{3,}/g,` `).replace(/\n{3,}/g,`
`).trim(),n=iV(t),r=n.split(/\n{2,}/).map(i=>i.trim()).filter(Boolean);return r.length>1&&/^Verification:\s/i.test(r[r.length-1])?r.slice(0,-1).join(` `).trim(),n=sV(t),r=n.split(/\n{2,}/).map(i=>i.trim()).filter(Boolean);return r.length>1&&/^Verification:\s/i.test(r[r.length-1])?r.slice(0,-1).join(`
`).trim():n}function iV(e){const t=String(e||"").trim(),n=t.match(/^\*\*(.{8,160}?)\*\*:\s+([\s\S]+)$/);if(n){const a=n[2].trim();if(a.length>=80)return a}const r=t.indexOf(": ");if(r<8||r>160)return t;const i=t.slice(0,r).replace(/\*/g,"").trim(),o=t.slice(r+2).trim();return o.length<80||!/[A-Za-z\u4e00-\u9fff]/.test(i)||/^(https?|file)$/i.test(i)?t:o}function qo(e){const t=Go(e),n=new Set,r=typeof t.checkpoint_type=="string"?t.checkpoint_type.trim():"",i=typeof t.checkpoint_id=="string"?t.checkpoint_id.trim():"";for(const o of[e.id,typeof t.ui_message_id=="string"?t.ui_message_id:"",r&&i?`checkpoint:${r}:${i}`:""]){const a=String(o??"").trim();a&&n.add(a)}return n}function sV(e){return e.startsWith("checkpoint:")}function qi(e){return typeof e.timestamp=="number"?e.timestamp:0}function sC(e){const t=String(e.sender??"").trim().toLowerCase(),n=Go(e),r=typeof n.role=="string"?n.role.trim().toLowerCase():"";return t==="user"||r==="user"?"user":"assistant"}function oC(e){const t=Go(e),n=String(e.sender??"").trim().toLowerCase();let r=0;const i=kI(e);return i&&(r+=1e3+i),t.source==="engine"&&(r+=100),n&&n!=="system"&&(r+=20),n&&!["assistant","system","user"].includes(n)&&(r+=5),e.replyToId&&(r+=2),r+=Math.min(Object.keys(t).length,10),r}function aC(e){return String(Go(e).source??"").trim().toLowerCase()==="engine"}function kI(e){const t=Go(e),n=String(t.transcript_kind??"").trim();if(n)return iC[n]??0;const r=String(t.kind??"").trim();return iC[r]??0}function Zf(e){return kI(e)>0}function SI(e,t){if(e.channelId!==t.channelId)return!1;const n=qo(e),r=qo(t);for(const i of n)if(r.has(i))return!0;return!1}function Gy(e,t){if(SI(e,t))return!0;if(e.channelId!==t.channelId||sC(e)!==sC(t)||Kf(e.content)!==Kf(t.content))return!1;const n=Zf(e)&&Zf(t);if(!n&&String(e.replyToId??"")!==String(t.replyToId??"")||!(aC(e)||aC(t)))return!1;const r=qi(e),i=qi(t);return!(!n&&r&&i&&Math.abs(r-i)>dv)}function qy(e,t,n=!1){let r=e,i=t;(n||oC(t)>oC(e))&&(r=t,i=e);const o=[];for(const h of[i.mentions,r.mentions])for(const g of h??[])o.includes(g)||o.push(g);const a=qo(e),u=qo(t);let d="";for(const h of a)if(u.has(h)&&!sV(h)){d=h;break}const m=Kf(r.content),p=m&&m===Kf(i.content)?m:r.content;return{...i,...r,...d?{id:d}:{},content:p,metadata:{...Go(i),...Go(r)},mentions:o,timestamp:qi(r)||qi(i)}}function Qg(e){const t=[],n=new Map;for(const r of[...e].sort((i,o)=>qi(i)-qi(o))){const i=qo(r);let o=-1,a=!1;for(const d of i){const m=n.get(d);if(m!==void 0){o=m,a=t[m].id===r.id;break}}if(o===-1){const d=qi(r),m=Zf(r);for(let p=t.length-1;p>=0;p--){const h=qi(t[p]);if(!m&&d>0&&h>0&&d-h>dv)break;if(Gy(t[p],r)){o=p;break}}}const u=o===-1?t.length:o;o===-1?t.push(r):t[o]=qy(t[o],r,a);for(const d of qo(t[u]))n.has(d)||n.set(d,u)}return t}function oV(e,t){switch(t.type){case"SET":return t.channels;case"CLEAR":return[];case"ADD":return e.some(n=>n.id===t.channel.id)?e:[...e,t.channel];case"REMOVE":return e.filter(n=>n.id!==t.channelId);case"REMOVE_PARTICIPANT":return e.map(n=>({...n,participants:n.participants.filter(r=>r!==t.agentId)}));default:return e}}function aV(e,t){switch(t.type){case"SET":{const n=Qg(t.messages);if(e.length===0)return n;const r=e.filter(i=>typeof i.id=="string"&&i.id.startsWith("msg-")&&!n.some(o=>Gy(i,o)));return r.length===0?n:Qg([...n,...r])}case"CLEAR":return[];case"ADD":{const n=qi(t.message);qo(t.message);let r=!1;for(let i=e.length-1;i>=0;i--){const o=qi(e[i]);if(!r&&n>0&&o>0&&n-o>dv&&(r=!0),SI(e[i],t.message)){const a=[...e];return a[i]=qy(e[i],t.message,e[i].id===t.message.id),a}if((Zf(t.message)||!r)&&Gy(e[i],t.message)){const a=[...e];return a[i]=qy(e[i],t.message),a}}return[...e,t.message]}case"MERGE":return t.messages.length===0?e:Qg([...e,...t.messages]);case"MARK_SENDER_DELETED":return e.map(n=>n.sender===t.senderId?{...n,senderDeleted:!0,senderName:"[已删除的 Agent]"}:n);case"REMOVE_BY_CHANNEL":return e.filter(n=>n.channelId!==t.channelId);case"REMOVE_BY_TASK_ID":return e.filter(n=>n.channelId!==`session:${t.taskId}`&&n.metadata?.task_id!==t.taskId);default:return e}}function lV(){const[e,t]=E.useReducer(oV,[]),[n,r]=E.useReducer(aV,[]),[i,o]=E.useState({}),[a,u]=E.useState("default"),d=E.useMemo(()=>{const I={};for(const D of n)I[D.channelId]||(I[D.channelId]=[]),I[D.channelId].push(D);return I},[n]),m=E.useMemo(()=>{const I={};for(const D of n){if(D.sender==="user")continue;const T=i[D.channelId]??0;D.timestamp<=T||(I[D.channelId]=(I[D.channelId]??0)+1)}return I},[n,i]),p=E.useCallback(I=>{const D={id:`msg-${rV()}`,channelId:I.channelId,sender:I.sender,senderName:I.senderName,content:I.content,timestamp:Date.now(),replyToId:I.replyToId,mentions:[],metadata:I.metadata};return r({type:"ADD",message:D}),D},[]),h=E.useCallback(I=>d[I]??[],[d]),g=E.useCallback(I=>m[I]??0,[m]),y=E.useCallback(I=>{o(D=>({...D,[I]:Date.now()}))},[]),v=E.useCallback(I=>{r({type:"MARK_SENDER_DELETED",senderId:I})},[]),w=E.useCallback(I=>{t({type:"REMOVE_PARTICIPANT",agentId:I})},[]),S=E.useCallback(I=>{t({type:"REMOVE",channe Line truncated `).trim():n}function sV(e){const t=String(e||"").trim(),n=t.match(/^\*\*(.{8,160}?)\*\*:\s+([\s\S]+)$/);if(n){const a=n[2].trim();if(a.length>=80)return a}const r=t.indexOf(": ");if(r<8||r>160)return t;const i=t.slice(0,r).replace(/\*/g,"").trim(),o=t.slice(r+2).trim();return o.length<80||!/[A-Za-z\u4e00-\u9fff]/.test(i)||/^(https?|file)$/i.test(i)?t:o}function qo(e){const t=Go(e),n=new Set,r=typeof t.checkpoint_type=="string"?t.checkpoint_type.trim():"",i=typeof t.checkpoint_id=="string"?t.checkpoint_id.trim():"";for(const o of[e.id,typeof t.ui_message_id=="string"?t.ui_message_id:"",r&&i?`checkpoint:${r}:${i}`:""]){const a=String(o??"").trim();a&&n.add(a)}return n}function oV(e){return e.startsWith("checkpoint:")}function Wi(e){return typeof e.timestamp=="number"?e.timestamp:0}function sC(e){const t=String(e.sender??"").trim().toLowerCase(),n=Go(e),r=typeof n.role=="string"?n.role.trim().toLowerCase():"";return t==="user"||r==="user"?"user":"assistant"}function oC(e){const t=Go(e),n=String(e.sender??"").trim().toLowerCase();let r=0;const i=kI(e);return i&&(r+=1e3+i),t.source==="engine"&&(r+=100),n&&n!=="system"&&(r+=20),n&&!["assistant","system","user"].includes(n)&&(r+=5),e.replyToId&&(r+=2),r+=Math.min(Object.keys(t).length,10),r}function aC(e){return String(Go(e).source??"").trim().toLowerCase()==="engine"}function kI(e){const t=Go(e),n=String(t.transcript_kind??"").trim();if(n)return iC[n]??0;const r=String(t.kind??"").trim();return iC[r]??0}function Zf(e){return kI(e)>0}function SI(e,t){if(e.channelId!==t.channelId)return!1;const n=qo(e),r=qo(t);for(const i of n)if(r.has(i))return!0;return!1}function Gy(e,t){if(SI(e,t))return!0;if(e.channelId!==t.channelId||sC(e)!==sC(t)||Kf(e.content)!==Kf(t.content))return!1;const n=Zf(e)&&Zf(t);if(!n&&String(e.replyToId??"")!==String(t.replyToId??"")||!(aC(e)||aC(t)))return!1;const r=Wi(e),i=Wi(t);return!(!n&&r&&i&&Math.abs(r-i)>dv)}function qy(e,t,n=!1){let r=e,i=t;(n||oC(t)>oC(e))&&(r=t,i=e);const o=[];for(const h of[i.mentions,r.mentions])for(const g of h??[])o.includes(g)||o.push(g);const a=qo(e),u=qo(t);let d="";for(const h of a)if(u.has(h)&&!oV(h)){d=h;break}const m=Kf(r.content),p=m&&m===Kf(i.content)?m:r.content;return{...i,...r,...d?{id:d}:{},content:p,metadata:{...Go(i),...Go(r)},mentions:o,timestamp:Wi(r)||Wi(i)}}function Qg(e){const t=[],n=new Map;for(const r of[...e].sort((i,o)=>Wi(i)-Wi(o))){const i=qo(r);let o=-1,a=!1;for(const d of i){const m=n.get(d);if(m!==void 0){o=m,a=t[m].id===r.id;break}}if(o===-1){const d=Wi(r),m=Zf(r);for(let p=t.length-1;p>=0;p--){const h=Wi(t[p]);if(!m&&d>0&&h>0&&d-h>dv)break;if(Gy(t[p],r)){o=p;break}}}const u=o===-1?t.length:o;o===-1?t.push(r):t[o]=qy(t[o],r,a);for(const d of qo(t[u]))n.has(d)||n.set(d,u)}return t}function aV(e,t){switch(t.type){case"SET":return t.channels;case"CLEAR":return[];case"ADD":return e.some(n=>n.id===t.channel.id)?e:[...e,t.channel];case"REMOVE":return e.filter(n=>n.id!==t.channelId);case"REMOVE_PARTICIPANT":return e.map(n=>({...n,participants:n.participants.filter(r=>r!==t.agentId)}));default:return e}}function lV(e,t){switch(t.type){case"SET":{const n=Qg(t.messages);if(e.length===0)return n;const r=e.filter(i=>typeof i.id=="string"&&i.id.startsWith("msg-")&&!n.some(o=>Gy(i,o)));return r.length===0?n:Qg([...n,...r])}case"CLEAR":return[];case"ADD":{const n=Wi(t.message);qo(t.message);let r=!1;for(let i=e.length-1;i>=0;i--){const o=Wi(e[i]);if(!r&&n>0&&o>0&&n-o>dv&&(r=!0),SI(e[i],t.message)){const a=[...e];return a[i]=qy(e[i],t.message,e[i].id===t.message.id),a}if((Zf(t.message)||!r)&&Gy(e[i],t.message)){const a=[...e];return a[i]=qy(e[i],t.message),a}}return[...e,t.message]}case"MERGE":return t.messages.length===0?e:Qg([...e,...t.messages]);case"MARK_SENDER_DELETED":return e.map(n=>n.sender===t.senderId?{...n,senderDeleted:!0,senderName:"[已删除的 Agent]"}:n);case"REMOVE_BY_CHANNEL":return e.filter(n=>n.channelId!==t.channelId);case"REMOVE_BY_TASK_ID":return e.filter(n=>n.channelId!==`session:${t.taskId}`&&n.metadata?.task_id!==t.taskId);default:return e}}function cV(){const[e,t]=j.useReducer(aV,[]),[n,r]=j.useReducer(lV,[]),[i,o]=j.useState({}),[a,u]=j.useState("default"),d=j.useMemo(()=>{const I={};for(const D of n)I[D.channelId]||(I[D.channelId]=[]),I[D.channelId].push(D);return I},[n]),m=j.useMemo(()=>{const I={};for(const D of n){if(D.sender==="user")continue;const T=i[D.channelId]??0;D.timestamp<=T||(I[D.channelId]=(I[D.channelId]??0)+1)}return I},[n,i]),p=j.useCallback(I=>{const D={id:`msg-${iV()}`,channelId:I.channelId,sender:I.sender,senderName:I.senderName,content:I.content,timestamp:Date.now(),replyToId:I.replyToId,mentions:[],metadata:I.metadata};return r({type:"ADD",message:D}),D},[]),h=j.useCallback(I=>d[I]??[],[d]),g=j.useCallback(I=>m[I]??0,[m]),y=j.useCallback(I=>{o(D=>({...D,[I]:Date.now()}))},[]),v=j.useCallback(I=>{r({type:"MARK_SENDER_DELETED",senderId:I})},[]),k=j.useCallback(I=>{t({type:"REMOVE_PARTICIPANT",agentId:I})},[]),S=j.useCallback(I=>{t({type:"REMOVE",channe Line truncated
${t}`:`${e}${t}`}function cV(e,t){return"Thinking"}function uV(e){return{timestamp:Number.isFinite(e.timestamp)?e.timestamp:Date.now(),type:e.type,summary:typeof e.summary=="string"?e.summary:"",detail:typeof e.detail=="string"&&e.detail?e.detail:void 0,turnId:typeof e.turnId=="string"&&e.turnId?e.turnId:void 0,itemId:typeof e.itemId=="string"&&e.itemId?e.itemId:void 0,streamId:typeof e.streamId=="string"&&e.streamId?e.streamId:void 0,toolCallId:typeof e.toolCallId=="string"&&e.toolCallId?e.toolCallId:void 0,permissionGroupKey:typeof e.permissionGroupKey=="string"&&e.permissionGroupKey?e.permissionGroupKey:void 0,seq:typeof e.seq=="number"&&Number.isFinite(e.seq)?e.seq:void 0,executionMode:typeof e.executionMode=="string"&&e.executionMode?e.executionMode:void 0}}function Qf(e){const t=e.itemId||e.streamId;return t?`${e.type}:${e.turnId??""}:${t}`:e.toolCallId&&(e.type==="tool_call"||e.type==="autonomy")?`${e.type}:${e.turnId??""}:${e.toolCallId}`:e.permissionGroupKey&&e.type==="autonomy"?`${e.type}:${e.turnId??""}:${e.permissionGroupKey}`:""}function dV(e,t){const n=Qf(e),r=Qf(t);return n&&r?n===r:t.timestamp-e.timestamp>Mm||e.type!==t.type?!1:e.type==="thinking"?!0:e.type==="tool_call"?e.summary===t.summary:!1}function fV(e,t){return t.timestamp-e.timestamp<=Mm&&e.type===t.type&&e.summary===t.summary&&(e.detail??"")===(t.detail??"")}function mV(e,t){if(e.type==="thinking"){const n=Wy(e.detail??e.summary,t.detail??t.summary,"thinking");return{timestamp:t.timestamp,type:"thinking",summary:cV(n,t.summary||e.summary),detail:n||void 0,turnId:t.turnId??e.turnId,itemId:t.itemId??e.itemId,streamId:t.streamId??e.streamId,toolCallId:t.toolCallId??e.toolCallId,permissionGroupKey:t.permissionGroupKey??e.permissionGroupKey,seq:t.seq??e.seq,executionMode:t.executionMode??e.executionMode}}if(e.type==="tool_call"){const n=Wy(e.detail??"",t.detail??"","tool_call");return{timestamp:t.timestamp,type:"tool_call",summary:t.summary||e.summary,detail:n||void 0,turnId:t.turnId??e.turnId,itemId:t.itemId??e.itemId,streamId:t.streamId??e.streamId,toolCallId:t.toolCallId??e.toolCallId,permissionGroupKey:t.permissionGroupKey??e.permissionGroupKey,seq:t.seq??e.seq,executionMode:t.executionMode??e.executionMode}}return t}function wI(e,t,n=100){const r=uV(t),i=Qf(r),o=i?[...e].reverse().findIndex(d=>Qf(d)===i):-1,a=o>=0?e.length-1-o:e.length-1,u=e[a];return u?i&&typeof u.seq=="number"&&typeof r.seq=="number"&&r.seq<=u.seq?e:fV(u,r)?tl([...e.slice(0,a),{...u,timestamp:r.timestamp},...e.slice(a+1)],n):dV(u,r)?tl([...e.slice(0,a),mV(u,r),...e.slice(a+1)],n):tl([...e,r],n):[r]}function CI(e,t=100){return(Array.isArray(e)?e:[]).reduce((n,r)=>wI(n,r,t),[])}function hV(e){return{timestamp:Number.isFinite(e.timestamp)?e.timestamp:Date.now(),type:e.type,workItemProjectionId:typeof e.workItemProjectionId=="string"&&e.workItemProjectionId?e.workItemProjectionId:void 0,workItemTurnType:typeof e.workItemTurnType=="string"&&e.workItemTurnType?e.workItemTurnType:void 0,workItemProjectionTitle:typeof e.workItemProjectionTitle=="string"&&e.workItemProjectionTitle?e.workItemProjectionTitle:void 0,runtimeTaskId:typeof e.runtimeTaskId=="string"&&e.runtimeTaskId?e.runtimeTaskId:void 0,executionTurnId:typeof e.executionTurnId=="string"&&e.executionTurnId?e.executionTurnId:void 0,roleName:typeof e.roleName=="string"&&e.roleName?e.roleName:void 0,detail:typeof e.detail=="string"&&e.detail?e.detail:void 0}}function jI(e,t){return e.type===t.type&&(e.workItemProjectionId??"")===(t.workItemProjectionId??"")&&(e.workItemTurnType??"")===(t.workItemTurnType??"")&&(e.workItemProjectionTitle??"")===(t.workItemProjectionTitle??"")&&(e.executionTurnId??e.runtimeTaskId??"")===(t.executionTurnId??t.runtimeTaskId??"")&&(e.roleName??"")===(t.roleName??"")}function pV(e,t){return t.timestamp-e.timestamp<=Mm&&jI(e,t)&&(e.type==="thinking"||e.type==="tool_call")}function gV(e,t){return jI(e,t)&&(e.detail??"")===(t.detail??"")&&t.timestamp-e.timestamp<=Mm}function xV(e,t){const n=t.type==="tool_call"?"tool_call":"thinking";return{...e,...t,timestamp:t.timestamp,detail:Wy(e.detail??"",t.detail??"",n)||void 0}}function EI(e,t,n=100){const r=hV(t),i=e[e.length-1];return i?gV(i,r)?tl([...e.slice(0,-1),{...i,timestamp:r.timestamp}],n):pV(i,r)?tl([...e.slice(0,-1),xV(i,r)],n):tl([...e,r],n):[r]}function NI(e,t=100){return(Array.isArray(e)?e:[]).reduce((n,r)=>EI(n,r,t),[])}function Yy(e){const t=String(e??"").trim().toLowerCase();return t==="company"?"company":t==="org"||t==="custom"?"org":"task"}function yV(e){return String(e??"").trim().toLowerCase()==="custom"?"custom":"corporate"}function II(e){const t=String(e.execMode??"").trim().toLowerCase(),n=String(e.companyProfile??"").trim().toLowerCase(),r=String(e.orgId??"").trim(),o=t.length>0?Yy(t):n==="custom"||r?"org":Yy(t);return o==="org"?{...e,execMode:"org",companyProfile:"custom",orgId:r||void 0}:o==="company"?{...e,execMode:"company",companyProfile:"corporate",orgId:void 0}:{...e,execMode:"task",companyProfile:void 0,orgId:void Line truncated ${t}`:`${e}${t}`}function uV(e,t){const n=e.trim().replace(/\s+/g," ");return n?n.length>120?`${n.slice(0,120).trimEnd()}...`:n:t||"Thinking"}function dV(e){return{timestamp:Number.isFinite(e.timestamp)?e.timestamp:Date.now(),type:e.type,summary:typeof e.summary=="string"?e.summary:"",detail:typeof e.detail=="string"&&e.detail?e.detail:void 0,turnId:typeof e.turnId=="string"&&e.turnId?e.turnId:void 0,itemId:typeof e.itemId=="string"&&e.itemId?e.itemId:void 0,streamId:typeof e.streamId=="string"&&e.streamId?e.streamId:void 0,toolCallId:typeof e.toolCallId=="string"&&e.toolCallId?e.toolCallId:void 0,permissionGroupKey:typeof e.permissionGroupKey=="string"&&e.permissionGroupKey?e.permissionGroupKey:void 0,seq:typeof e.seq=="number"&&Number.isFinite(e.seq)?e.seq:void 0,executionMode:typeof e.executionMode=="string"&&e.executionMode?e.executionMode:void 0}}function Qf(e){const t=e.itemId||e.streamId;return t?`${e.type}:${e.turnId??""}:${t}`:e.toolCallId&&(e.type==="tool_call"||e.type==="autonomy")?`${e.type}:${e.turnId??""}:${e.toolCallId}`:e.permissionGroupKey&&e.type==="autonomy"?`${e.type}:${e.turnId??""}:${e.permissionGroupKey}`:""}function fV(e,t){const n=Qf(e),r=Qf(t);return n&&r?n===r:t.timestamp-e.timestamp>Mm||e.type!==t.type?!1:e.type==="thinking"?!0:e.type==="tool_call"?e.summary===t.summary:!1}function mV(e,t){return t.timestamp-e.timestamp<=Mm&&e.type===t.type&&e.summary===t.summary&&(e.detail??"")===(t.detail??"")}function hV(e,t){if(e.type==="thinking"){const n=Wy(e.detail??"",t.detail??"","thinking");return{timestamp:t.timestamp,type:"thinking",summary:uV(n,t.summary||e.summary),detail:n||void 0,turnId:t.turnId??e.turnId,itemId:t.itemId??e.itemId,streamId:t.streamId??e.streamId,toolCallId:t.toolCallId??e.toolCallId,permissionGroupKey:t.permissionGroupKey??e.permissionGroupKey,seq:t.seq??e.seq,executionMode:t.executionMode??e.executionMode}}if(e.type==="tool_call"){const n=Wy(e.detail??"",t.detail??"","tool_call");return{timestamp:t.timestamp,type:"tool_call",summary:t.summary||e.summary,detail:n||void 0,turnId:t.turnId??e.turnId,itemId:t.itemId??e.itemId,streamId:t.streamId??e.streamId,toolCallId:t.toolCallId??e.toolCallId,permissionGroupKey:t.permissionGroupKey??e.permissionGroupKey,seq:t.seq??e.seq,executionMode:t.executionMode??e.executionMode}}return t}function wI(e,t,n=100){const r=dV(t),i=Qf(r),o=i?[...e].reverse().findIndex(d=>Qf(d)===i):-1,a=o>=0?e.length-1-o:e.length-1,u=e[a];return u?i&&typeof u.seq=="number"&&typeof r.seq=="number"&&r.seq<=u.seq?e:mV(u,r)?tl([...e.slice(0,a),{...u,timestamp:r.timestamp},...e.slice(a+1)],n):fV(u,r)?tl([...e.slice(0,a),hV(u,r),...e.slice(a+1)],n):tl([...e,r],n):[r]}function CI(e,t=100){return(Array.isArray(e)?e:[]).reduce((n,r)=>wI(n,r,t),[])}function pV(e){return{timestamp:Number.isFinite(e.timestamp)?e.timestamp:Date.now(),type:e.type,workItemProjectionId:typeof e.workItemProjectionId=="string"&&e.workItemProjectionId?e.workItemProjectionId:void 0,workItemTurnType:typeof e.workItemTurnType=="string"&&e.workItemTurnType?e.workItemTurnType:void 0,workItemProjectionTitle:typeof e.workItemProjectionTitle=="string"&&e.workItemProjectionTitle?e.workItemProjectionTitle:void 0,runtimeTaskId:typeof e.runtimeTaskId=="string"&&e.runtimeTaskId?e.runtimeTaskId:void 0,executionTurnId:typeof e.executionTurnId=="string"&&e.executionTurnId?e.executionTurnId:void 0,roleName:typeof e.roleName=="string"&&e.roleName?e.roleName:void 0,detail:typeof e.detail=="string"&&e.detail?e.detail:void 0}}function jI(e,t){return e.type===t.type&&(e.workItemProjectionId??"")===(t.workItemProjectionId??"")&&(e.workItemTurnType??"")===(t.workItemTurnType??"")&&(e.workItemProjectionTitle??"")===(t.workItemProjectionTitle??"")&&(e.executionTurnId??e.runtimeTaskId??"")===(t.executionTurnId??t.runtimeTaskId??"")&&(e.roleName??"")===(t.roleName??"")}function gV(e,t){return t.timestamp-e.timestamp<=Mm&&jI(e,t)&&(e.type==="thinking"||e.type==="tool_call")}function xV(e,t){return jI(e,t)&&(e.detail??"")===(t.detail??"")&&t.timestamp-e.timestamp<=Mm}function yV(e,t){const n=t.type==="tool_call"?"tool_call":"thinking";return{...e,...t,timestamp:t.timestamp,detail:Wy(e.detail??"",t.detail??"",n)||void 0}}function EI(e,t,n=100){const r=pV(t),i=e[e.length-1];return i?xV(i,r)?tl([...e.slice(0,-1),{...i,timestamp:r.timestamp}],n):gV(i,r)?tl([...e.slice(0,-1),yV(i,r)],n):tl([...e,r],n):[r]}function NI(e,t=100){return(Array.isArray(e)?e:[]).reduce((n,r)=>EI(n,r,t),[])}function Yy(e){const t=String(e??"").trim().toLowerCase();return t==="company"?"company":t==="org"||t==="custom"?"org":"task"}function vV(e){return String(e??"").trim().toLowerCase()==="custom"?"custom":"corporate"}function II(e){const t=String(e.execMode??"").trim().toLowerCase(),n=String(e.companyProfile??"").trim().toLowerCase(),r=String(e.orgId??"").trim(),o=t.length>0?Yy(t):n==="custom"||r?"org":Yy(t);return o==="org"?{...e,execMode:"org",companyProfile:"custom",orgId:r||void 0}:o==="company"?{...e,execMode:"company",companyProfile:"co Line truncated
`)),[L,A]=E.useState(!1),M=E.useRef(e.role_id);E.useEffect(()=>{M.current!==e.role_id&&(M.current=e.role_id,d(e.name),p(e.responsibility),g(e.reports_to),v(e.icon??null),S(new Set(e.can_spawn)),k(new Set(e.tools)),N(e.runtime_policy?.execution_strategy??"auto"),I(e.preferred_external_agent??null),T((e.prompt_refs??[]).join(` `)),[L,A]=j.useState(!1),M=j.useRef(e.role_id);j.useEffect(()=>{M.current!==e.role_id&&(M.current=e.role_id,d(e.name),p(e.responsibility),g(e.reports_to),v(e.icon??null),S(new Set(e.can_spawn)),w(new Set(e.tools)),N(e.runtime_policy?.execution_strategy??"auto"),I(e.preferred_external_agent??null),T((e.prompt_refs??[]).join(`
`)),A(!1))},[e]);const $=E.useRef({}),W=E.useRef(null),B=E.useRef(e.role_id);E.useEffect(()=>{B.current=e.role_id},[e.role_id]);const U=E.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null);const se=$.current;$.current={},Object.keys(se).length!==0&&i(B.current,se)},[i]),H=E.useCallback(se=>{r||($.current={...$.current,...se},W.current&&clearTimeout(W.current),W.current=setTimeout(U,500))},[U,r]);E.useEffect(()=>()=>{W.current&&(clearTimeout(W.current),W.current=null);const se=$.current;Object.keys(se).length>0&&($.current={},i(B.current,se))},[i]);const V=se=>{d(se),H({name:se})},Y=se=>{p(se),H({responsibility:se})},Z=se=>{g(se),H({reports_to:se})},q=se=>{v(se),H({icon:se})},G=se=>{N(se),H({execution_strategy:se})},J=se=>{I(se),H({preferred_external_agent:se})},P=se=>{T(se);const je=se.split(` `)),A(!1))},[e]);const $=j.useRef({}),W=j.useRef(null),B=j.useRef(e.role_id);j.useEffect(()=>{B.current=e.role_id},[e.role_id]);const U=j.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null);const se=$.current;$.current={},Object.keys(se).length!==0&&i(B.current,se)},[i]),H=j.useCallback(se=>{r||($.current={...$.current,...se},W.current&&clearTimeout(W.current),W.current=setTimeout(U,500))},[U,r]);j.useEffect(()=>()=>{W.current&&(clearTimeout(W.current),W.current=null);const se=$.current;Object.keys(se).length>0&&($.current={},i(B.current,se))},[i]);const V=se=>{d(se),H({name:se})},Y=se=>{p(se),H({responsibility:se})},Z=se=>{g(se),H({reports_to:se})},q=se=>{v(se),H({icon:se})},G=se=>{N(se),H({execution_strategy:se})},J=se=>{I(se),H({preferred_external_agent:se})},P=se=>{T(se);const je=se.split(`
`).map(we=>we.trim()).filter(Boolean);H({prompt_refs:je})},X=se=>{const je=new Set(w);je.has(se)?je.delete(se):je.add(se),S(je),H({can_spawn:Array.from(je)})},ee=se=>{const je=new Set(_);je.has(se)?je.delete(se):je.add(se),k(je),H({tools:Array.from(je)})},te=E.useMemo(()=>t.filter(se=>se.role_id!==e.role_id),[t,e.role_id]),re=E.useMemo(()=>n.filter(se=>(se.role_ids?.length?se.role_ids:[se.role_id]).includes(e.role_id)).length,[n,e.role_id]),oe=E.useMemo(()=>D.split(` `).map(we=>we.trim()).filter(Boolean);H({prompt_refs:je})},X=se=>{const je=new Set(k);je.has(se)?je.delete(se):je.add(se),S(je),H({can_spawn:Array.from(je)})},ee=se=>{const je=new Set(_);je.has(se)?je.delete(se):je.add(se),w(je),H({tools:Array.from(je)})},te=j.useMemo(()=>t.filter(se=>se.role_id!==e.role_id),[t,e.role_id]),re=j.useMemo(()=>n.filter(se=>(se.role_ids?.length?se.role_ids:[se.role_id]).includes(e.role_id)).length,[n,e.role_id]),oe=j.useMemo(()=>D.split(`
`).filter(se=>se.trim()).length,[D]),de=()=>{if(!L){A(!0);return}U(),o(e.role_id)};return c.jsxs("aside",{className:"ri-panel","aria-label":`Inspector for role ${e.name}`,children:[c.jsxs("header",{className:"ri-panel-header",children:[c.jsx("img",{src:wu(y),alt:"",className:"ri-panel-icon"}),c.jsxs("div",{className:"ri-panel-title-wrap",children:[c.jsx("h3",{className:"ri-panel-title",children:u||"(unnamed)"}),c.jsx("code",{className:"ri-panel-id",children:e.role_id})]}),c.jsx("button",{className:"btn btn-ghost btn-sm ri-panel-close",onClick:a,title:"Close (Esc)",children:"✕"})]}),c.jsxs("div",{className:"ri-panel-body",children:[c.jsxs(Ha,{title:"Identity",defaultExpanded:!0,children:[c.jsx(gi,{label:"Name",children:c.jsx("input",{className:"ri-text-input",value:u,onChange:se=>V(se.target.value),disabled:r})}),c.jsx(gi,{label:"Responsibility",children:c.jsx("textarea",{className:"ri-textarea",rows:3,value:m,onChange:se=>Y(se.target.value),disabled:r})}),c.jsx(gi,{label:"Icon",children:c.jsx(UV,{value:y,onChange:q,readOnly:r})})]}),c.jsxs(Ha,{title:"Hierarchy",defaultExpanded:!0,children:[c.jsx(gi,{label:"Reports to",children:c.jsxs("select",{className:"ri-select",value:h,onChange:se=>Z(se.target.value),disabled:r,children:[c.jsx("option",{value:"owner",children:"You (Owner)"}),te.map(se=>c.jsx("option",{value:se.role_id,children:se.name},se.role_id))]})}),c.jsx(gi,{label:"Can delegate to",children:c.jsx(GV,{allIds:te.map(se=>se.role_id),labelFor:se=>te.find(je=>je.role_id===se)?.name??se,selected:w,onToggle:X,readOnly:r})}),c.jsx(gi,{label:"Employees assigned",children:c.jsx("span",{className:"ri-meta-value",children:re})})]}),c.jsx(Ha,{title:`Tools (${_.size})`,children:c.jsx(qV,{tools:_,onToggle:ee,readOnly:r})}),c.jsx(Ha,{title:`Prompts (${oe})`,children:c.jsx(gi,{label:"Prompt refs / inline",children:c.jsx("textarea",{className:"ri-textarea ri-textarea-mono",rows:5,placeholder:"One prompt ref or inline instruction per line",value:D,onChange:se=>P(se.target.value),disabled:r})})}),c.jsxs(Ha,{title:"Runtime policy",children:[c.jsx(gi,{label:"Execution strategy",children:c.jsx("div",{className:"ri-radio-group",children:FV.map(se=>c.jsxs("label",{className:"ri-radio",title:se.hint,children:[c.jsx("input",{type:"radio",name:`exec-strategy-${e.role_id}`,value:se.value,checked:C===se.value,onChange:()=>G(se.value),disabled:r}),se.label]},se.value))})}),C==="external"&&c.jsx(gi,{label:"Preferred external agent",children:c.jsxs("select",{className:"ri-select",value:O??"",onChange:se=>J(se.target.value||null),disabled:r,children:[c.jsx("option",{value:"",children:"(any)"}),HV.map(se=>c.jsx("option",{value:se,children:se},se))]})})]}),c.jsxs(Ha,{title:"Advanced",children:[c.jsx(gi,{label:"Role type",children:c.jsx("span",{className:"ri-meta-value",children:e.role_type??"worker"})}),c.jsx(gi,{label:"Skills",children:c.jsx("span",{className:"ri-meta-value",children:e.skill_refs&&e.skill_refs.length>0?e.skill_refs.join(", "):"(none)"})}),c.jsx(gi,{label:"Artifact contract",children:c.jsx("span",{className:"ri-meta-value",children:e.artifact_contract_ref??"(none)"})})]})]}),!r&&c.jsx("footer",{className:"ri-panel-footer",children:c.jsx("button",{className:`btn btn-sm ${L?"btn-danger":"btn-ghost"}`,onClick:de,onBlur:()=>A(!1),children:L?"Confirm delete?":"Delete role"})})]})}function Ha({title:e,defaultExpanded:t=!1,children:n}){const[r,i]=E.useState(t);return c.jsxs("section",{className:`ri-group${r?" is-expanded":""}`,children:[c.jsxs("button",{className:"ri-group-header",onClick:()=>i(o=>!o),children:[c.jsx("span",{className:"ri-group-caret",children:r?"▾":"▸"}),c.jsx("span",{className:"ri-group-title",children:e})]}),r&&c.jsx("div",{className:"ri-group-body",children:n})]})}function gi({label:e,children:t}){return c.jsxs("div",{className:"ri-field",children:[c.jsx("label",{className:"ri-field-label",children:e}),c.jsx("div",{className:"ri-field-control",children:t})]})}function UV({value:e,onChange:t,readOnly:n}){const[r,i]=E.useState(!1);return c.jsxs("div",{className:"ri-icon-picker",children:[c.jsxs("button",{className:"ri-icon-picker-trigger",onClick:()=>!n&&i(o=>!o),disabled:n,children:[c.jsx("img",{src:wu(e),alt:"",className:"ri-icon-picker-current"}),c.jsx("span",{className:"ri-icon-picker-label",children:e??"generic"})]}),r&&c.jsxs("div",{className:"ri-icon-picker-popover",children:[c.jsx("button",{className:`ri-icon-option${e===null?" is-active":""}`,onClick:()=>{t(null),i(!1)},title:"Default icon",children:c.jsx("img",{src:Wc.generic,alt:""})}),BV.filter(o=>o!=="generic").map(o=>c.jsx("button",{className:`ri-icon-option${e===o?" is-active":""}`,onClick:()=>{t(o),i(!1)},title:o,children:c.jsx("img",{src:Wc[o],alt:o})},o))]})]})}function GV({allIds:e,labelFor:t,selected:n,onToggle:r,readOnly:i}){const[o,a]=E.useState(!1),u=e.filter(d=>!n.has(d));return c.jsxs("div",{className:"ri-multiselect",children:[c.jsxs("div",{className:"ri-chips",children:[Array.from(n).map(d=>c.jsxs("span",{className:"ri-ch Line truncated `).filter(se=>se.trim()).length,[D]),de=()=>{if(!L){A(!0);return}U(),o(e.role_id)};return c.jsxs("aside",{className:"ri-panel","aria-label":`Inspector for role ${e.name}`,children:[c.jsxs("header",{className:"ri-panel-header",children:[c.jsx("img",{src:wu(y),alt:"",className:"ri-panel-icon"}),c.jsxs("div",{className:"ri-panel-title-wrap",children:[c.jsx("h3",{className:"ri-panel-title",children:u||"(unnamed)"}),c.jsx("code",{className:"ri-panel-id",children:e.role_id})]}),c.jsx("button",{className:"btn btn-ghost btn-sm ri-panel-close",onClick:a,title:"Close (Esc)",children:"✕"})]}),c.jsxs("div",{className:"ri-panel-body",children:[c.jsxs(Ha,{title:"Identity",defaultExpanded:!0,children:[c.jsx(gi,{label:"Name",children:c.jsx("input",{className:"ri-text-input",value:u,onChange:se=>V(se.target.value),disabled:r})}),c.jsx(gi,{label:"Responsibility",children:c.jsx("textarea",{className:"ri-textarea",rows:3,value:m,onChange:se=>Y(se.target.value),disabled:r})}),c.jsx(gi,{label:"Icon",children:c.jsx(GV,{value:y,onChange:q,readOnly:r})})]}),c.jsxs(Ha,{title:"Hierarchy",defaultExpanded:!0,children:[c.jsx(gi,{label:"Reports to",children:c.jsxs("select",{className:"ri-select",value:h,onChange:se=>Z(se.target.value),disabled:r,children:[c.jsx("option",{value:"owner",children:"You (Owner)"}),te.map(se=>c.jsx("option",{value:se.role_id,children:se.name},se.role_id))]})}),c.jsx(gi,{label:"Can delegate to",children:c.jsx(qV,{allIds:te.map(se=>se.role_id),labelFor:se=>te.find(je=>je.role_id===se)?.name??se,selected:k,onToggle:X,readOnly:r})}),c.jsx(gi,{label:"Employees assigned",children:c.jsx("span",{className:"ri-meta-value",children:re})})]}),c.jsx(Ha,{title:`Tools (${_.size})`,children:c.jsx(WV,{tools:_,onToggle:ee,readOnly:r})}),c.jsx(Ha,{title:`Prompts (${oe})`,children:c.jsx(gi,{label:"Prompt refs / inline",children:c.jsx("textarea",{className:"ri-textarea ri-textarea-mono",rows:5,placeholder:"One prompt ref or inline instruction per line",value:D,onChange:se=>P(se.target.value),disabled:r})})}),c.jsxs(Ha,{title:"Runtime policy",children:[c.jsx(gi,{label:"Execution strategy",children:c.jsx("div",{className:"ri-radio-group",children:VV.map(se=>c.jsxs("label",{className:"ri-radio",title:se.hint,children:[c.jsx("input",{type:"radio",name:`exec-strategy-${e.role_id}`,value:se.value,checked:C===se.value,onChange:()=>G(se.value),disabled:r}),se.label]},se.value))})}),C==="external"&&c.jsx(gi,{label:"Preferred external agent",children:c.jsxs("select",{className:"ri-select",value:O??"",onChange:se=>J(se.target.value||null),disabled:r,children:[c.jsx("option",{value:"",children:"(any)"}),FV.map(se=>c.jsx("option",{value:se,children:se},se))]})})]}),c.jsxs(Ha,{title:"Advanced",children:[c.jsx(gi,{label:"Role type",children:c.jsx("span",{className:"ri-meta-value",children:e.role_type??"worker"})}),c.jsx(gi,{label:"Skills",children:c.jsx("span",{className:"ri-meta-value",children:e.skill_refs&&e.skill_refs.length>0?e.skill_refs.join(", "):"(none)"})}),c.jsx(gi,{label:"Artifact contract",children:c.jsx("span",{className:"ri-meta-value",children:e.artifact_contract_ref??"(none)"})})]})]}),!r&&c.jsx("footer",{className:"ri-panel-footer",children:c.jsx("button",{className:`btn btn-sm ${L?"btn-danger":"btn-ghost"}`,onClick:de,onBlur:()=>A(!1),children:L?"Confirm delete?":"Delete role"})})]})}function Ha({title:e,defaultExpanded:t=!1,children:n}){const[r,i]=j.useState(t);return c.jsxs("section",{className:`ri-group${r?" is-expanded":""}`,children:[c.jsxs("button",{className:"ri-group-header",onClick:()=>i(o=>!o),children:[c.jsx("span",{className:"ri-group-caret",children:r?"▾":"▸"}),c.jsx("span",{className:"ri-group-title",children:e})]}),r&&c.jsx("div",{className:"ri-group-body",children:n})]})}function gi({label:e,children:t}){return c.jsxs("div",{className:"ri-field",children:[c.jsx("label",{className:"ri-field-label",children:e}),c.jsx("div",{className:"ri-field-control",children:t})]})}function GV({value:e,onChange:t,readOnly:n}){const[r,i]=j.useState(!1);return c.jsxs("div",{className:"ri-icon-picker",children:[c.jsxs("button",{className:"ri-icon-picker-trigger",onClick:()=>!n&&i(o=>!o),disabled:n,children:[c.jsx("img",{src:wu(e),alt:"",className:"ri-icon-picker-current"}),c.jsx("span",{className:"ri-icon-picker-label",children:e??"generic"})]}),r&&c.jsxs("div",{className:"ri-icon-picker-popover",children:[c.jsx("button",{className:`ri-icon-option${e===null?" is-active":""}`,onClick:()=>{t(null),i(!1)},title:"Default icon",children:c.jsx("img",{src:Wc.generic,alt:""})}),$V.filter(o=>o!=="generic").map(o=>c.jsx("button",{className:`ri-icon-option${e===o?" is-active":""}`,onClick:()=>{t(o),i(!1)},title:o,children:c.jsx("img",{src:Wc[o],alt:o})},o))]})]})}function qV({allIds:e,labelFor:t,selected:n,onToggle:r,readOnly:i}){const[o,a]=j.useState(!1),u=e.filter(d=>!n.has(d));return c.jsxs("div",{className:"ri-multiselect",children:[c.jsxs("div",{className:"ri-chips",children:[Array.from(n).map(d=>c.jsxs("span",{className:"ri-ch Line truncated
font-size: .6rem; font-size: .6rem;
font-weight: bold; font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,n?.key)}return i}}function xt(e,t,n,r){return{debug:()=>{var i;return(i=e?.debugAll)!=null?i:e[t]},key:!1,onChange:r}}function XV(e,t,n,r){const i=()=>{var a;return(a=o.getValue())!=null?a:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:i,getContext:gt(()=>[e,n,t,o],(a,u,d,m)=>({table:a,column:u,row:d,cell:m,getValue:m.getValue,renderValue:m.renderValue}),xt(e.options,"debugCells"))};return e._features.forEach(a=>{a.createCell==null||a.createCell(o,n,t,e)},{}),o}function KV(e,t,n,r){var i,o;const u={...e._getDefaultColumnDef(),...t},d=u.accessorKey;let m=(i=(o=u.id)!=null?o:d?typeof String.prototype.replaceAll=="function"?d.replaceAll(".","_"):d.replace(/\./g,"_"):void 0)!=null?i:typeof u.header=="string"?u.header:void 0,p;if(u.accessorFn?p=u.accessorFn:d&&(d.includes(".")?p=g=>{let y=g;for(const w of d.split(".")){var v;y=(v=y)==null?void 0:v[w]}return y}:p=g=>g[u.accessorKey]),!m)throw new Error;let h={id:`${String(m)}`,accessorFn:p,parent:r,depth:n,columnDef:u,columns:[],getFlatColumns:gt(()=>[!0],()=>{var g;return[h,...(g=h.columns)==null?void 0:g.flatMap(y=>y.getFlatColumns())]},xt(e.options,"debugColumns")),getLeafColumns:gt(()=>[e._getOrderColumnsFn()],g=>{var y;if((y=h.columns)!=null&&y.length){let v=h.columns.flatMap(w=>w.getLeafColumns());return g(v)}return[h]},xt(e.options,"debugColumns"))};for(const g of e._features)g.createColumn==null||g.createColumn(h,e);return h}const _r="debugHeaders";function fC(e,t,n){var r;let o={id:(r=n.id)!=null?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const a=[],u=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(u),a.push(d)};return u(o),a},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(a=>{a.createHeader==null||a.createHeader(o,e)}),o}const ZV={createTable:e=>{e.getHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{var o,a;const u=(o=r?.map(h=>n.find(g=>g.id===h)).filter(Boolean))!=null?o:[],d=(a=i?.map(h=>n.find(g=>g.id===h)).filter(Boolean))!=null?a:[],m=n.filter(h=>!(r!=null&&r.includes(h.id))&&!(i!=null&&i.includes(h.id)));return Jd(t,[...u,...m,...d],e)},xt(e.options,_r)),e.getCenterHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(o=>!(r!=null&&r.includes(o.id))&&!(i!=null&&i.includes(o.id))),Jd(t,n,e,"center")),xt(e.options,_r)),e.getLeftHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var i;const o=(i=r?.map(a=>n.find(u=>u.id===a)).filter(Boolean))!=null?i:[];return Jd(t,o,e,"left")},xt(e.options,_r)),e.getRightHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var i;const o=(i=r?.map(a=>n.find(u=>u.id===a)).filter(Boolean))!=null?i:[];return Jd(t,o,e,"right")},xt(e.options,_r)),e.getFooterGroups=gt(()=>[e.getHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getLeftFooterGroups=gt(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getCenterFooterGroups=gt(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getRightFooterGroups=gt(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getFlatHeaders=gt(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getLeftFlatHeaders=gt(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getCenterFlatHeaders=gt(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getRightFlatHeaders=gt(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getCenterLeafHeaders=gt(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getLeftLeafHeaders=gt(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getRightLeafHeaders=gt(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getLeafHeaders=gt(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,r)=>{var i,o,a,u,d,m;return[...(i=(o=t[0])==null?void 0:o.headers)!=null?i:[],...(a=(u=n[0])==null?void 0:u.headers)!=null?a:[],...(d=(m=r[0])==null?void 0:m.headers)!=null?d:[]].map(p=>p.getLeafHeaders()).flat()},xt(e.options,_r))}};function Jd(e,t,n,r){var i,o;let a=0;const u=function(g,y){y===void 0&&(y=1),a=Math.max(a,y),g.filter(v=>v.getIsVisible()).forEach(v=>{var w;(w=v.columns)!=null&&w.length&&u(v.columns,y+1)},0)};u(e);let d=[];const m=(g,y)=>{const v={depth:y,id:[r,`${y}`].filter(Boolean).jo Line truncated color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,n?.key)}return i}}function xt(e,t,n,r){return{debug:()=>{var i;return(i=e?.debugAll)!=null?i:e[t]},key:!1,onChange:r}}function KV(e,t,n,r){const i=()=>{var a;return(a=o.getValue())!=null?a:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:i,getContext:gt(()=>[e,n,t,o],(a,u,d,m)=>({table:a,column:u,row:d,cell:m,getValue:m.getValue,renderValue:m.renderValue}),xt(e.options,"debugCells"))};return e._features.forEach(a=>{a.createCell==null||a.createCell(o,n,t,e)},{}),o}function ZV(e,t,n,r){var i,o;const u={...e._getDefaultColumnDef(),...t},d=u.accessorKey;let m=(i=(o=u.id)!=null?o:d?typeof String.prototype.replaceAll=="function"?d.replaceAll(".","_"):d.replace(/\./g,"_"):void 0)!=null?i:typeof u.header=="string"?u.header:void 0,p;if(u.accessorFn?p=u.accessorFn:d&&(d.includes(".")?p=g=>{let y=g;for(const k of d.split(".")){var v;y=(v=y)==null?void 0:v[k]}return y}:p=g=>g[u.accessorKey]),!m)throw new Error;let h={id:`${String(m)}`,accessorFn:p,parent:r,depth:n,columnDef:u,columns:[],getFlatColumns:gt(()=>[!0],()=>{var g;return[h,...(g=h.columns)==null?void 0:g.flatMap(y=>y.getFlatColumns())]},xt(e.options,"debugColumns")),getLeafColumns:gt(()=>[e._getOrderColumnsFn()],g=>{var y;if((y=h.columns)!=null&&y.length){let v=h.columns.flatMap(k=>k.getLeafColumns());return g(v)}return[h]},xt(e.options,"debugColumns"))};for(const g of e._features)g.createColumn==null||g.createColumn(h,e);return h}const _r="debugHeaders";function fC(e,t,n){var r;let o={id:(r=n.id)!=null?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const a=[],u=d=>{d.subHeaders&&d.subHeaders.length&&d.subHeaders.map(u),a.push(d)};return u(o),a},getContext:()=>({table:e,header:o,column:t})};return e._features.forEach(a=>{a.createHeader==null||a.createHeader(o,e)}),o}const QV={createTable:e=>{e.getHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{var o,a;const u=(o=r?.map(h=>n.find(g=>g.id===h)).filter(Boolean))!=null?o:[],d=(a=i?.map(h=>n.find(g=>g.id===h)).filter(Boolean))!=null?a:[],m=n.filter(h=>!(r!=null&&r.includes(h.id))&&!(i!=null&&i.includes(h.id)));return Jd(t,[...u,...m,...d],e)},xt(e.options,_r)),e.getCenterHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(o=>!(r!=null&&r.includes(o.id))&&!(i!=null&&i.includes(o.id))),Jd(t,n,e,"center")),xt(e.options,_r)),e.getLeftHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var i;const o=(i=r?.map(a=>n.find(u=>u.id===a)).filter(Boolean))!=null?i:[];return Jd(t,o,e,"left")},xt(e.options,_r)),e.getRightHeaderGroups=gt(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var i;const o=(i=r?.map(a=>n.find(u=>u.id===a)).filter(Boolean))!=null?i:[];return Jd(t,o,e,"right")},xt(e.options,_r)),e.getFooterGroups=gt(()=>[e.getHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getLeftFooterGroups=gt(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getCenterFooterGroups=gt(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getRightFooterGroups=gt(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),xt(e.options,_r)),e.getFlatHeaders=gt(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getLeftFlatHeaders=gt(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getCenterFlatHeaders=gt(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getRightFlatHeaders=gt(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),xt(e.options,_r)),e.getCenterLeafHeaders=gt(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getLeftLeafHeaders=gt(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getRightLeafHeaders=gt(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),xt(e.options,_r)),e.getLeafHeaders=gt(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,r)=>{var i,o,a,u,d,m;return[...(i=(o=t[0])==null?void 0:o.headers)!=null?i:[],...(a=(u=n[0])==null?void 0:u.headers)!=null?a:[],...(d=(m=r[0])==null?void 0:m.headers)!=null?d:[]].map(p=>p.getLeafHeaders()).flat()},xt(e.options,_r))}};function Jd(e,t,n,r){var i,o;let a=0;const u=function(g,y){y===void 0&&(y=1),a=Math.max(a,y),g.filter(v=>v.getIsVisible()).forEach(v=>{var k;(k=v.columns)!=null&&k.length&&u(v.columns,y+1)},0)};u(e);let d=[];const m=(g,y)=>{const v={depth:y,id:[r,`${y}`].filter(Boolean).jo Line truncated
`).replace(` `).replace(`
`,` `,`
+`).split(` +`).split(`
`)),p=m.reduce((h,g)=>h.concat(...g),[]);return[m,p]}return[[],[]]},[e]);return E.useEffect(()=>{const d=t?.target??i2,m=t?.actInsideInputWithModifier??!0;if(e!==null){const p=y=>{if(i.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!i.current||i.current&&!m)&&ET(y))return!1;const w=o2(y.code,u);if(o.current.add(y[w]),s2(a,o.current,!1)){const S=y.composedPath?.()?.[0]||y.target,_=S?.nodeName==="BUTTON"||S?.nodeName==="A";t.preventDefault!==!1&&(i.current||!_)&&y.preventDefault(),r(!0)}},h=y=>{const v=o2(y.code,u);s2(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(y[v]),y.key==="Meta"&&o.current.clear(),i.current=!1},g=()=>{o.current.clear(),r(!1)};return d?.addEventListener("keydown",p),d?.addEventListener("keyup",h),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d?.removeEventListener("keydown",p),d?.removeEventListener("keyup",h),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,r]),n}function s2(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function o2(e,t){return t.includes(e)?"code":"key"}const YX=()=>{const e=In();return E.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,i,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:a,panZoom:u}=e.getState(),d=wv(t,r,i,o,a,n?.padding??.1);return u?(await u.setViewport(d,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:u,y:d}=a.getBoundingClientRect(),m={x:t.x-u,y:t.y-d},p=n.snapGrid??i,h=n.snapToGrid??o;return Tu(m,r,h,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),a=lm(t,n);return{x:a.x+i,y:a.y+o}}}),[])};function XT(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const u={...o};for(const d of a)XX(d,u);n.push(u)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function XX(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function KT(e,t){return XT(e,t)}function KX(e,t){return XT(e,t)}function zo(e,t){return{id:e,type:"select",selected:t}}function Xa(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const a=t.has(i);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(zo(o.id,a)))}return r}function a2({items:e=[],lookup:t}){const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,o]of e.entries()){const a=t.get(o.id),u=a?.internals?.userNode??a;u!==void 0&&u!==o&&n.push({id:o.id,item:o,type:"replace"}),u===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function l2(e){return{id:e.id,type:"remove"}}const c2=e=>vY(e),ZX=e=>vT(e);function ZT(e){return E.forwardRef(e)}function u2(e){const[t,n]=E.useState(BigInt(0)),[r]=E.useState(()=>QX(()=>n(i=>i+BigInt(1))));return m0(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function QX(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const QT=E.createContext(null);function JX({children:e}){const t=In(),n=E.useCallback(u=>{const{nodes:d=[],setNodes:m,hasDefaultNodes:p,onNodesChange:h,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:v}=t.getState();let w=d;for(const _ of u)w=typeof _=="function"?_(w):_;let S=a2({items:w,lookup:g});for(const _ of v.values())S=_(S);p&&m(w),S.length>0?h?.(S):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:k,setNodes:C}=t.getState();_&&C(k)})},[]),r=u2(n),i=E.useCallback(u=>{const{edges:d=[],setEdges:m,hasDefaul Line truncated `)),p=m.reduce((h,g)=>h.concat(...g),[]);return[m,p]}return[[],[]]},[e]);return j.useEffect(()=>{const d=t?.target??i2,m=t?.actInsideInputWithModifier??!0;if(e!==null){const p=y=>{if(i.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!i.current||i.current&&!m)&&ET(y))return!1;const k=o2(y.code,u);if(o.current.add(y[k]),s2(a,o.current,!1)){const S=y.composedPath?.()?.[0]||y.target,_=S?.nodeName==="BUTTON"||S?.nodeName==="A";t.preventDefault!==!1&&(i.current||!_)&&y.preventDefault(),r(!0)}},h=y=>{const v=o2(y.code,u);s2(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(y[v]),y.key==="Meta"&&o.current.clear(),i.current=!1},g=()=>{o.current.clear(),r(!1)};return d?.addEventListener("keydown",p),d?.addEventListener("keyup",h),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d?.removeEventListener("keydown",p),d?.removeEventListener("keyup",h),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,r]),n}function s2(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function o2(e,t){return t.includes(e)?"code":"key"}const XX=()=>{const e=In();return j.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,i,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:a,panZoom:u}=e.getState(),d=wv(t,r,i,o,a,n?.padding??.1);return u?(await u.setViewport(d,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:u,y:d}=a.getBoundingClientRect(),m={x:t.x-u,y:t.y-d},p=n.snapGrid??i,h=n.snapToGrid??o;return Tu(m,r,h,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),a=lm(t,n);return{x:a.x+i,y:a.y+o}}}),[])};function XT(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const u={...o};for(const d of a)KX(d,u);n.push(u)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function KX(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function KT(e,t){return XT(e,t)}function ZX(e,t){return XT(e,t)}function zo(e,t){return{id:e,type:"select",selected:t}}function Xa(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const a=t.has(i);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(zo(o.id,a)))}return r}function a2({items:e=[],lookup:t}){const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,o]of e.entries()){const a=t.get(o.id),u=a?.internals?.userNode??a;u!==void 0&&u!==o&&n.push({id:o.id,item:o,type:"replace"}),u===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function l2(e){return{id:e.id,type:"remove"}}const c2=e=>bY(e),QX=e=>vT(e);function ZT(e){return j.forwardRef(e)}function u2(e){const[t,n]=j.useState(BigInt(0)),[r]=j.useState(()=>JX(()=>n(i=>i+BigInt(1))));return m0(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function JX(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const QT=j.createContext(null);function eK({children:e}){const t=In(),n=j.useCallback(u=>{const{nodes:d=[],setNodes:m,hasDefaultNodes:p,onNodesChange:h,nodeLookup:g,fitViewQueued:y,onNodesChangeMiddlewareMap:v}=t.getState();let k=d;for(const _ of u)k=typeof _=="function"?_(k):_;let S=a2({items:k,lookup:g});for(const _ of v.values())S=_(S);p&&m(k),S.length>0?h?.(S):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:w,setNodes:C}=t.getState();_&&C(w)})},[]),r=u2(n),i=j.useCallback(u=>{const{edges:d=[],setEdges:m,hasDefaul Line truncated
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}wR.displayName="MiniMap";const $Z=E.memo(wR),HZ=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,FZ={[yl.Line]:"right",[yl.Handle]:"bottom-right"};function VZ({nodeId:e,position:t,variant:n=yl.Handle,className:r,style:i=void 0,children:o,color:a,minWidth:u=10,minHeight:d=10,maxWidth:m=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:g,autoScale:y=!0,shouldResize:v,onResizeStart:w,onResize:S,onResizeEnd:_}){const k=tR(),C=typeof e=="string"?e:k,N=In(),O=E.useRef(null),I=n===yl.Handle,D=Ft(E.useCallback(HZ(I&&y),[I,y]),Nn),T=E.useRef(null),L=t??FZ[n];E.useEffect(()=>{if(!(!O.current||!C))return T.current||(T.current=xX({domNode:O.current,nodeId:C,getStoreItems:()=>{const{nodeLookup:M,transform:$,snapGrid:W,snapToGrid:B,nodeOrigin:U,domNode:H}=N.getState();return{nodeLookup:M,transform:$,snapGrid:W,snapToGrid:B,nodeOrigin:U,paneDomNode:H}},onChange:(M,$)=>{const{triggerNodeChanges:W,nodeLookup:B,parentLookup:U,nodeOrigin:H}=N.getState(),V=[],Y={x:M.x,y:M.y},Z=B.get(C);if(Z&&Z.expandParent&&Z.parentId){const q=Z.origin??H,G=M.width??Z.measured.width??0,J=M.height??Z.measured.height??0,P={id:Z.id,parentId:Z.parentId,rect:{width:G,height:J,...CT({x:M.x??Z.position.x,y:M.y??Z.position.y},{width:G,height:J},Z.parentId,B,q)}},X=Tv([P],B,U,H);V.push(...X),Y.x=M.x?Math.max(q[0]*G,M.x):void 0,Y.y=M.y?Math.max(q[1]*J,M.y):void 0}if(Y.x!==void 0&&Y.y!==void 0){const q={id:C,type:"position",position:{...Y}};V.push(q)}if(M.width!==void 0&&M.height!==void 0){const G={id:C,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};V.push(G)}for(const q of $){const G={...q,type:"position"};V.push(G)}W(V)},onEnd:({width:M,height:$})=>{const W={id:C,type:"dimensions",resizing:!1,dimensions:{width:M,height:$}};N.getState().triggerNodeChanges([W])}})),T.current.update({controlPosition:L,boundaries:{minWidth:u,minHeight:d,maxWidth:m,maxHeight:p},keepAspectRatio:h,resizeDirection:g,onResizeStart:w,onResize:S,onResizeEnd:_,shouldResize:v}),()=>{T.current?.destroy()}},[L,u,d,m,p,h,w,S,_,v]);const A=L.split("-");return c.jsx("div",{className:Zn(["react-flow__resize-control","nodrag",...A,n,r]),ref:O,style:{...i,scale:D,...a&&{[I?"backgroundColor":"borderColor"]:a}},children:o})}E.memo(VZ);const UZ=E.memo(function({data:t}){const n=["oc-canvas-node",t.isOwner&&"is-owner",t.isSelected&&"is-selected",t.isDropTarget&&"is-drop-target"].filter(Boolean).join(" "),r=wu(t.icon);return c.jsxs("div",{className:n,children:[c.jsx(vl,{type:"target",position:at.Top,className:"oc-canvas-handle"}),c.jsxs("div",{className:"oc-canvas-node-row",children:[c.jsx("div",{className:"oc-canvas-node-chip",children:c.jsx("span",{className:"oc-canvas-node-chip-icon",style:{WebkitMaskImage:`url("${r}")`,maskImage:`url("${r}")`},"aria-hidden":!0})}),c.jsxs("div",{className:"oc-canvas-node-text",children:[c.jsx("span",{className:"oc-canvas-node-name",children:t.name}),c.jsxs("div",{className:"oc-canvas-node-meta",children:[t.employeeNames.length>0?c.jsxs("span",{className:"oc-canvas-node-person",title:t.employeeNames.join(", "),children:[t.employeeNames[0],t.employeeNames.length>1?` +${t.employeeNames.length-1}`:""]}):c.jsx("span",{className:"oc-canvas-node-id",children:t.roleId}),t.employeeCount>0&&c.jsx("span",{className:"oc-canvas-node-badge",children:t.employeeCount})]})]})]}),c.jsx(vl,{type:"source",position:at.Bottom,className:"oc-canvas-handle"})]})});var bx,k2;function Mv(){if(k2)return bx;k2=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(p){p&&(this._isDirected=Object.hasOwn(p,"directed")?p.directed:!0,this._isMultigraph=Object.hasOwn(p,"multigraph")?p.multigraph:!1,this._isCompound=Object.hasOwn(p,"compound")?p.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(p){return this._label=p,this}graph(){return this._label}setDefaultNodeLabel(p){return this._defaultNodeLabelFn=p,typeof p!="function"&&(this._defaultNodeLabelFn=()=>p),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var p=this;return this.nodes().filter(h=>Object.keys(p._in[h]).length===0)}sinks(){var p=this;return this.nodes().filter(h=>Object.keys(p._out[h]).length===0)}setNodes(p,h){var g=arguments,y=this;return p.forEach(function(v){g.length>1?y.setNode(v,h):y.setNode(v)}),this}setNode(p,h){return Object.hasOwn(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=h),this):(this._nodes[p]=arguments.length>1?h:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=t, Line truncated M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}wR.displayName="MiniMap";const HZ=j.memo(wR),FZ=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,VZ={[yl.Line]:"right",[yl.Handle]:"bottom-right"};function UZ({nodeId:e,position:t,variant:n=yl.Handle,className:r,style:i=void 0,children:o,color:a,minWidth:u=10,minHeight:d=10,maxWidth:m=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:g,autoScale:y=!0,shouldResize:v,onResizeStart:k,onResize:S,onResizeEnd:_}){const w=tR(),C=typeof e=="string"?e:w,N=In(),O=j.useRef(null),I=n===yl.Handle,D=Ft(j.useCallback(FZ(I&&y),[I,y]),Nn),T=j.useRef(null),L=t??VZ[n];j.useEffect(()=>{if(!(!O.current||!C))return T.current||(T.current=yX({domNode:O.current,nodeId:C,getStoreItems:()=>{const{nodeLookup:M,transform:$,snapGrid:W,snapToGrid:B,nodeOrigin:U,domNode:H}=N.getState();return{nodeLookup:M,transform:$,snapGrid:W,snapToGrid:B,nodeOrigin:U,paneDomNode:H}},onChange:(M,$)=>{const{triggerNodeChanges:W,nodeLookup:B,parentLookup:U,nodeOrigin:H}=N.getState(),V=[],Y={x:M.x,y:M.y},Z=B.get(C);if(Z&&Z.expandParent&&Z.parentId){const q=Z.origin??H,G=M.width??Z.measured.width??0,J=M.height??Z.measured.height??0,P={id:Z.id,parentId:Z.parentId,rect:{width:G,height:J,...CT({x:M.x??Z.position.x,y:M.y??Z.position.y},{width:G,height:J},Z.parentId,B,q)}},X=Tv([P],B,U,H);V.push(...X),Y.x=M.x?Math.max(q[0]*G,M.x):void 0,Y.y=M.y?Math.max(q[1]*J,M.y):void 0}if(Y.x!==void 0&&Y.y!==void 0){const q={id:C,type:"position",position:{...Y}};V.push(q)}if(M.width!==void 0&&M.height!==void 0){const G={id:C,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};V.push(G)}for(const q of $){const G={...q,type:"position"};V.push(G)}W(V)},onEnd:({width:M,height:$})=>{const W={id:C,type:"dimensions",resizing:!1,dimensions:{width:M,height:$}};N.getState().triggerNodeChanges([W])}})),T.current.update({controlPosition:L,boundaries:{minWidth:u,minHeight:d,maxWidth:m,maxHeight:p},keepAspectRatio:h,resizeDirection:g,onResizeStart:k,onResize:S,onResizeEnd:_,shouldResize:v}),()=>{T.current?.destroy()}},[L,u,d,m,p,h,k,S,_,v]);const A=L.split("-");return c.jsx("div",{className:Zn(["react-flow__resize-control","nodrag",...A,n,r]),ref:O,style:{...i,scale:D,...a&&{[I?"backgroundColor":"borderColor"]:a}},children:o})}j.memo(UZ);const GZ=j.memo(function({data:t}){const n=["oc-canvas-node",t.isOwner&&"is-owner",t.isSelected&&"is-selected",t.isDropTarget&&"is-drop-target"].filter(Boolean).join(" "),r=wu(t.icon);return c.jsxs("div",{className:n,children:[c.jsx(vl,{type:"target",position:at.Top,className:"oc-canvas-handle"}),c.jsxs("div",{className:"oc-canvas-node-row",children:[c.jsx("div",{className:"oc-canvas-node-chip",children:c.jsx("span",{className:"oc-canvas-node-chip-icon",style:{WebkitMaskImage:`url("${r}")`,maskImage:`url("${r}")`},"aria-hidden":!0})}),c.jsxs("div",{className:"oc-canvas-node-text",children:[c.jsx("span",{className:"oc-canvas-node-name",children:t.name}),c.jsxs("div",{className:"oc-canvas-node-meta",children:[t.employeeNames.length>0?c.jsxs("span",{className:"oc-canvas-node-person",title:t.employeeNames.join(", "),children:[t.employeeNames[0],t.employeeNames.length>1?` +${t.employeeNames.length-1}`:""]}):c.jsx("span",{className:"oc-canvas-node-id",children:t.roleId}),t.employeeCount>0&&c.jsx("span",{className:"oc-canvas-node-badge",children:t.employeeCount})]})]})]}),c.jsx(vl,{type:"source",position:at.Bottom,className:"oc-canvas-handle"})]})});var bx,k2;function Mv(){if(k2)return bx;k2=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(p){p&&(this._isDirected=Object.hasOwn(p,"directed")?p.directed:!0,this._isMultigraph=Object.hasOwn(p,"multigraph")?p.multigraph:!1,this._isCompound=Object.hasOwn(p,"compound")?p.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(p){return this._label=p,this}graph(){return this._label}setDefaultNodeLabel(p){return this._defaultNodeLabelFn=p,typeof p!="function"&&(this._defaultNodeLabelFn=()=>p),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var p=this;return this.nodes().filter(h=>Object.keys(p._in[h]).length===0)}sinks(){var p=this;return this.nodes().filter(h=>Object.keys(p._out[h]).length===0)}setNodes(p,h){var g=arguments,y=this;return p.forEach(function(v){g.length>1?y.setNode(v,h):y.setNode(v)}),this}setNode(p,h){return Object.hasOwn(this._nodes,p)?(arguments.length>1&&(this._nodes[p]=h),this):(this._nodes[p]=arguments.length>1?h:this._defaultNodeLabelFn(p),this._isCompound&&(this._parent[p]=t, Line truncated
${r}`}),c.jsx(TV,{projects:Rr.projects,activeId:Rr.activeProjectId,onSelect:Q=>{const z=Es(Q);t.current?.switchProject(Q,z)},onCreate:Q=>{t.current?.createProject(Q)},onDelete:Q=>t.current?.deleteProject(Q)})]}),c.jsxs("div",{className:"topbar-center",children:[c.jsxs("div",{className:"page-nav",children:[c.jsxs("button",{className:`page-nav-btn${$==="workspace"?" active":""}`,onClick:()=>W("workspace"),children:["Workspace",(()=>{const Q=Cr.channels.reduce((z,ne)=>z+Cr.getUnreadCount(ne.id),0);return Q>0?c.jsx("span",{className:"nav-unread-badge",children:Q>99?"99+":Q}):null})()]}),c.jsx("button",{className:`page-nav-btn${$==="office"?" active":""}`,onClick:()=>W("office"),children:"Office"}),c.jsx("button",{className:`page-nav-btn${$==="org"?" active":""}`,onClick:()=>W("org"),children:"Org"})]}),c.jsxs("div",{className:"stat-chips",children:[c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:ii.totalAgents})," agents"]}),c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:ii.totalSkills})," skills"]}),c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:Hn.getOpenTaskCount()})," tasks"]})]})]}),c.jsxs("div",{className:"topbar-right",children:[c.jsxs("select",{className:"theme-select",value:Tr,title:"Outdoor lighting override",onChange:Q=>{const z=Q.target.value;wr(z);try{z==="auto"?(localStorage.removeItem("opc_outdoor_override"),localStorage.removeItem("opc_outdoor_day"),localStorage.removeItem("opc_outdoor_night")):(localStorage.setItem("opc_outdoor_override",z),localStorage.removeItem("opc_outdoor_day"),localStorage.removeItem("opc_outdoor_night"))}catch{}e.current.syncOutdoorLighting()},children:[c.jsx("option",{value:"auto",children:"Outdoor auto"}),c.jsx("option",{value:"day",children:"Outdoor day"}),c.jsx("option",{value:"night",children:"Outdoor night"})]}),c.jsxs("select",{className:"theme-select",value:C,onChange:Q=>N(Q.target.value),children:[c.jsx("option",{value:"midnight",children:"Midnight"}),c.jsx("option",{value:"neon",children:"Neon"}),c.jsx("option",{value:"paper",children:"Paper"}),c.jsx("option",{value:"retro",children:"Retro"}),c.jsx("option",{value:"terminal",children:"Terminal"}),c.jsx("option",{value:"cozy",children:"Cozy"}),c.jsx("option",{value:"openopc",children:"OpenOPC"})]}),c.jsx("button",{className:`icon-btn ${H?"active":""}`,onClick:()=>V(Q=>!Q),title:"Developer Tools",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[c.jsx("path",{d:"M5.5 2L2 5.5 5.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M10.5 7L14 10.5 10.5 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),$==="workspace"&&c.jsx(nV,{boardStore:Hn,chatStore:Cr,sessionStore:hn,agents:B,officeMap:Is,execMode:q,companyProfile:J,taskPreferredAgent:X,projectId:Rr.activeProjectId,orgInfoData:te,onNavigateToOrg:()=>W("org"),savedOrgsList:rn,activeSavedOrg:Te,onSavedOrgsList:El,onSavedOrgLoad:Mu,recoveryStatus:oe,onRecoveryResume:Q=>t.current?.recoveryAction(ct(),"resume",Q),onRecoveryCancel:Q=>t.current?.recoveryAction(ct(),"cancel",Q),commsState:se,commsMessage:we,onCommsRefresh:Q=>{const{project_id:z,...ne}=Q??{};t.current?.commsState(ct(),ne)},onCommsReadMessage:Q=>t.current?.commsReadMessage(ct(),Q),onRunTask:(Q,z,ne,le,ge)=>{t.current?.send({type:"run_task",project_id:ct(),task_id:Q,title:z,description:ne,mode:le,profile:ge})},onCreateTask:(Q,z,ne,le)=>{t.current?.send({type:"kanban_create_task",project_id:ct(),title:Q,board_id:z,column_id:ne,task_id:le})},onMoveTask:(Q,z)=>{t.current?.send({type:"kanban_move_task",project_id:ct(),task_id:Q,column_id:z})},onCreateSession:()=>{if(vn.current||Tt.current)return;const Q=ct();Cn(Q),t.current?.createSession(Q,void 0,q,py(q),X,Do(q,Te))},onSessionSend:(Q,z,ne,le)=>t.current?.sessionSend(ct(),Q,z,ne,le),onSecretarySend:Q=>t.current?.secretarySend(ct(),Q),onDeleteSession:Q=>t.current?.deleteSession(ct(),Q),onTitleChange:(Q,z)=>t.current?.sessionUpdateTitle(ct(),Q,z),onSessionConfigChange:Ou,onSessionTaskAgentChange:xr,onContinueInNewChat:Ji,onSessionStop:go,onSessionResume:Zm,onSessionComplete:Q=>t.current?.sessionComplete(ct(),Q),onLoadSessionDetail:(Q,z)=>t.current?.sessionDetail(ct(),Q,{...z,include:z?.detailLevel==="full"?["messages","session_state","progress","work_items","runtime_context"]:["messages","session_state"],viewGeneration:ve.current}),onOpenExecutionPanel:Q=>ht(Q),onCollabSync:()=>t.current?.collabSync(ct(),void 0,ve.current)}),$==="org"&&c.jsx("div",{className:"org-page",children:c.jsx(JQ,{data:te,sessionRecruitmentByRole:Ru,talents:Be,employeeDetail:Vt,reorgProposals:vt,isCustomMode:Oi,onRequestData:()=>t.current?.orgInfo(),onRequestTalents:()=>t.current?.talentList(),onRequestEmployeeDetail:Q=>t.current?.employeeDetail(Q),onHireTalent:(Q,z)=>{kn(Q),t.current?.talentHire(Q,z,void 0,te?.organization_id||Te||void 0)},hiringTemplateId:Dt,onImportEmployee:Q=>t.curre Line truncated ${r}`}),c.jsx(RV,{projects:Rr.projects,activeId:Rr.activeProjectId,onSelect:Q=>{const z=Es(Q);t.current?.switchProject(Q,z)},onCreate:Q=>{t.current?.createProject(Q)},onDelete:Q=>t.current?.deleteProject(Q)})]}),c.jsxs("div",{className:"topbar-center",children:[c.jsxs("div",{className:"page-nav",children:[c.jsxs("button",{className:`page-nav-btn${$==="workspace"?" active":""}`,onClick:()=>W("workspace"),children:["Workspace",(()=>{const Q=Cr.channels.reduce((z,ne)=>z+Cr.getUnreadCount(ne.id),0);return Q>0?c.jsx("span",{className:"nav-unread-badge",children:Q>99?"99+":Q}):null})()]}),c.jsx("button",{className:`page-nav-btn${$==="office"?" active":""}`,onClick:()=>W("office"),children:"Office"}),c.jsx("button",{className:`page-nav-btn${$==="org"?" active":""}`,onClick:()=>W("org"),children:"Org"})]}),c.jsxs("div",{className:"stat-chips",children:[c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:ii.totalAgents})," agents"]}),c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:ii.totalSkills})," skills"]}),c.jsxs("span",{className:"stat-chip",children:[c.jsx("b",{children:Hn.getOpenTaskCount()})," tasks"]})]})]}),c.jsxs("div",{className:"topbar-right",children:[c.jsxs("select",{className:"theme-select",value:Tr,title:"Outdoor lighting override",onChange:Q=>{const z=Q.target.value;wr(z);try{z==="auto"?(localStorage.removeItem("opc_outdoor_override"),localStorage.removeItem("opc_outdoor_day"),localStorage.removeItem("opc_outdoor_night")):(localStorage.setItem("opc_outdoor_override",z),localStorage.removeItem("opc_outdoor_day"),localStorage.removeItem("opc_outdoor_night"))}catch{}e.current.syncOutdoorLighting()},children:[c.jsx("option",{value:"auto",children:"Outdoor auto"}),c.jsx("option",{value:"day",children:"Outdoor day"}),c.jsx("option",{value:"night",children:"Outdoor night"})]}),c.jsxs("select",{className:"theme-select",value:C,onChange:Q=>N(Q.target.value),children:[c.jsx("option",{value:"midnight",children:"Midnight"}),c.jsx("option",{value:"neon",children:"Neon"}),c.jsx("option",{value:"paper",children:"Paper"}),c.jsx("option",{value:"retro",children:"Retro"}),c.jsx("option",{value:"terminal",children:"Terminal"}),c.jsx("option",{value:"cozy",children:"Cozy"}),c.jsx("option",{value:"openopc",children:"OpenOPC"})]}),c.jsx("button",{className:`icon-btn ${H?"active":""}`,onClick:()=>V(Q=>!Q),title:"Developer Tools",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[c.jsx("path",{d:"M5.5 2L2 5.5 5.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M10.5 7L14 10.5 10.5 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),$==="workspace"&&c.jsx(rV,{boardStore:Hn,chatStore:Cr,sessionStore:hn,agents:B,officeMap:Is,execMode:q,companyProfile:J,taskPreferredAgent:X,projectId:Rr.activeProjectId,orgInfoData:te,onNavigateToOrg:()=>W("org"),savedOrgsList:rn,activeSavedOrg:Te,onSavedOrgsList:El,onSavedOrgLoad:Mu,recoveryStatus:oe,onRecoveryResume:Q=>t.current?.recoveryAction(ct(),"resume",Q),onRecoveryCancel:Q=>t.current?.recoveryAction(ct(),"cancel",Q),commsState:se,commsMessage:we,onCommsRefresh:Q=>{const{project_id:z,...ne}=Q??{};t.current?.commsState(ct(),ne)},onCommsReadMessage:Q=>t.current?.commsReadMessage(ct(),Q),onRunTask:(Q,z,ne,le,ge)=>{t.current?.send({type:"run_task",project_id:ct(),task_id:Q,title:z,description:ne,mode:le,profile:ge})},onCreateTask:(Q,z,ne,le)=>{t.current?.send({type:"kanban_create_task",project_id:ct(),title:Q,board_id:z,column_id:ne,task_id:le})},onMoveTask:(Q,z)=>{t.current?.send({type:"kanban_move_task",project_id:ct(),task_id:Q,column_id:z})},onCreateSession:()=>{if(vn.current||Tt.current)return;const Q=ct();Cn(Q),t.current?.createSession(Q,void 0,q,py(q),X,Do(q,Te))},onSessionSend:(Q,z,ne,le)=>t.current?.sessionSend(ct(),Q,z,ne,le),onSecretarySend:Q=>t.current?.secretarySend(ct(),Q),onDeleteSession:Q=>t.current?.deleteSession(ct(),Q),onTitleChange:(Q,z)=>t.current?.sessionUpdateTitle(ct(),Q,z),onSessionConfigChange:Ou,onSessionTaskAgentChange:xr,onContinueInNewChat:es,onSessionStop:go,onSessionResume:Zm,onSessionComplete:Q=>t.current?.sessionComplete(ct(),Q),onLoadSessionDetail:(Q,z)=>t.current?.sessionDetail(ct(),Q,{...z,include:z?.detailLevel==="full"?["messages","session_state","progress","work_items","runtime_context"]:["messages","session_state"],viewGeneration:ve.current}),onOpenExecutionPanel:Q=>ht(Q),onCollabSync:()=>t.current?.collabSync(ct(),void 0,ve.current)}),$==="org"&&c.jsx("div",{className:"org-page",children:c.jsx(eJ,{data:te,sessionRecruitmentByRole:Ru,talents:Be,employeeDetail:Vt,reorgProposals:vt,isCustomMode:Oi,onRequestData:()=>t.current?.orgInfo(),onRequestTalents:()=>t.current?.talentList(),onRequestEmployeeDetail:Q=>t.current?.employeeDetail(Q),onHireTalent:(Q,z)=>{kn(Q),t.current?.talentHire(Q,z,void 0,te?.organization_id||Te||void 0)},hiringTemplateId:Dt,onImportEmployee:Q=>t.curre Line truncated
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="data:," /> <link rel="icon" href="data:," />
<title>OpenOPC Pixel Office</title> <title>OpenOPC Pixel Office</title>
<script type="module" crossorigin src="./assets/index-DoyFIcGP.js"></script> <script type="module" crossorigin src="./assets/index-CYE7dSgZ.js"></script>
<link rel="modulepreload" crossorigin href="./assets/phaser-DFK5Ua9d.js"> <link rel="modulepreload" crossorigin href="./assets/phaser-DFK5Ua9d.js">
<link rel="stylesheet" crossorigin href="./assets/index-CMqG6mW8.css"> <link rel="stylesheet" crossorigin href="./assets/index-CMqG6mW8.css">
</head> </head>
@@ -155,7 +155,7 @@ export function AgentProgressBlock({ entries, agentStatus, currentTool, toolElap
const cfg = ENTRY_CONFIG[entry.type] || ENTRY_CONFIG.status_change const cfg = ENTRY_CONFIG[entry.type] || ENTRY_CONFIG.status_change
return ( return (
<div key={progressEntryKey(entry, i)} className={`ptl-entry${isLast ? ' ptl-entry-last' : ''}`}> <div key={progressEntryKey(entry, hiddenCount + i)} className={`ptl-entry${isLast ? ' ptl-entry-last' : ''}`}>
<div className="ptl-connector"> <div className="ptl-connector">
<div className="ptl-dot" style={{ color: cfg.color }}> <div className="ptl-dot" style={{ color: cfg.color }}>
{cfg.icon} {cfg.icon}
@@ -183,13 +183,19 @@ export function AgentProgressBlock({ entries, agentStatus, currentTool, toolElap
</div> </div>
)} )}
{/* ── Collapse button (when expanded) ────────────── */} {/* ── Expand/collapse toggle (below timeline) ────── */}
{expanded && filteredEntries.length > COLLAPSED_COUNT && ( {expanded && filteredEntries.length > COLLAPSED_COUNT && (
<button className="ptl-expand" onClick={() => setExpanded(false)}> <button className="ptl-expand" onClick={() => setExpanded(false)}>
<IconChevron down /> <IconChevron down />
<span>Show less</span> <span>Show less</span>
</button> </button>
)} )}
{!expanded && hiddenCount > 0 && (
<button className="ptl-expand" onClick={() => setExpanded(true)}>
<IconChevron />
<span>Show more ({hiddenCount} earlier step{hiddenCount > 1 ? 's' : ''})</span>
</button>
)}
</div> </div>
) )
} }
@@ -1,7 +1,11 @@
import React, { useCallback, useMemo } from 'react' import React, { useCallback, useEffect, useMemo, useState } from 'react'
import type { ChatMessageMeta, HumanEscalationOption } from '../types/chat' import type { ChatMessageMeta, HumanEscalationOption } from '../types/chat'
import { MarkdownBody } from './MarkdownBody' import { MarkdownBody } from './MarkdownBody'
// If the server never confirms (click lost on a dropped connection), re-enable
// the buttons after this long so the user can retry.
const SUBMIT_CONFIRM_TIMEOUT_MS = 30000
interface EscalationPanelProps { interface EscalationPanelProps {
meta: ChatMessageMeta meta: ChatMessageMeta
onReply: (text: string) => void onReply: (text: string) => void
@@ -57,10 +61,20 @@ export const EscalationPanel = React.memo(function EscalationPanel({
const worktreePath = String(meta.worktree_path ?? '').trim() const worktreePath = String(meta.worktree_path ?? '').trim()
const hasRuntimeState = activeSubagents.length > 0 || permissionRequests.length > 0 || !!worktreePath const hasRuntimeState = activeSubagents.length > 0 || permissionRequests.length > 0 || !!worktreePath
const [submittedOptionId, setSubmittedOptionId] = useState('')
const isSubmitting = !!submittedOptionId && !isResponded
useEffect(() => {
if (!isSubmitting) return
const timer = window.setTimeout(() => setSubmittedOptionId(''), SUBMIT_CONFIRM_TIMEOUT_MS)
return () => window.clearTimeout(timer)
}, [isSubmitting, submittedOptionId])
const handleReply = useCallback((option: HumanEscalationOption) => { const handleReply = useCallback((option: HumanEscalationOption) => {
if (isResponded) return if (isResponded || isSubmitting) return
setSubmittedOptionId(option.id)
onReply(option.label || option.id) onReply(option.label || option.id)
}, [isResponded, onReply]) }, [isResponded, isSubmitting, onReply])
return ( return (
<div className="ckpt-panel ckpt-escalation"> <div className="ckpt-panel ckpt-escalation">
@@ -109,15 +123,22 @@ export const EscalationPanel = React.memo(function EscalationPanel({
{options.map((option) => ( {options.map((option) => (
<button <button
key={option.id} key={option.id}
className={`ckpt-btn ${option.id.includes('deny') ? 'ckpt-btn-deny' : 'ckpt-btn-approve'}`} className={`ckpt-btn ${option.id.includes('deny') ? 'ckpt-btn-deny' : 'ckpt-btn-approve'}${isSubmitting ? ' ckpt-btn-submitting' : ''}`}
onClick={() => handleReply(option)} onClick={() => handleReply(option)}
disabled={isSubmitting}
> >
{option.label || option.id} {isSubmitting && submittedOptionId === option.id ? 'Submitting…' : (option.label || option.id)}
</button> </button>
))} ))}
</div> </div>
)} )}
{isSubmitting && (
<div className="ckpt-escalation-hint">
Decision sent — waiting for server confirmation…
</div>
)}
{!isResponded && meta.default_action && ( {!isResponded && meta.default_action && (
<div className="ckpt-escalation-hint"> <div className="ckpt-escalation-hint">
Default on timeout: <code>{meta.default_action}</code> Default on timeout: <code>{meta.default_action}</code>
@@ -28,9 +28,41 @@ for (const [seq, detail] of [
} }
assert.equal(log.length, 1) assert.equal(log.length, 1)
assert.equal(log[0]?.summary, 'Thinking') assert.equal(log[0]?.summary, '我先联网抓取')
assert.equal(log[0]?.detail, '我先联网抓取') assert.equal(log[0]?.detail, '我先联网抓取')
// Token-sized streaming fragments keep their whitespace when merged, and
// entries without detail never splice their summary label into the text.
let spacedLog = appendProgressEntry([], {
timestamp: 100,
type: 'thinking',
summary: 'The user',
detail: 'The user',
turnId: 'rt-2:1',
itemId: 'rt-2:1:thinking',
seq: 1,
})
spacedLog = appendProgressEntry(spacedLog, {
timestamp: 101,
type: 'thinking',
summary: 'wants to',
detail: ' wants to',
turnId: 'rt-2:1',
itemId: 'rt-2:1:thinking',
seq: 2,
})
spacedLog = appendProgressEntry(spacedLog, {
timestamp: 102,
type: 'thinking',
summary: 'Thinking',
turnId: 'rt-2:1',
itemId: 'rt-2:1:thinking',
seq: 3,
})
assert.equal(spacedLog.length, 1)
assert.equal(spacedLog[0]?.detail, 'The user wants to')
assert.equal(spacedLog[0]?.summary, 'The user wants to')
const unchanged = appendProgressEntry(log, { const unchanged = appendProgressEntry(log, {
timestamp: 5, timestamp: 5,
type: 'thinking', type: 'thinking',
@@ -27,9 +27,9 @@ function mergeText(left: string, right: string, kind: 'thinking' | 'tool_call'):
} }
function summarizeThinking(detail: string, fallback: string): string { function summarizeThinking(detail: string, fallback: string): string {
void detail const text = detail.trim().replace(/\s+/g, ' ')
void fallback if (!text) return fallback || 'Thinking'
return 'Thinking' return text.length > 120 ? `${text.slice(0, 120).trimEnd()}...` : text
} }
function normalizeProgressEntry(entry: ProgressEntry): ProgressEntry { function normalizeProgressEntry(entry: ProgressEntry): ProgressEntry {
@@ -84,7 +84,10 @@ function isDuplicateProgress(left: ProgressEntry, right: ProgressEntry): boolean
function mergeProgress(left: ProgressEntry, right: ProgressEntry): ProgressEntry { function mergeProgress(left: ProgressEntry, right: ProgressEntry): ProgressEntry {
if (left.type === 'thinking') { if (left.type === 'thinking') {
const detail = mergeText(left.detail ?? left.summary, right.detail ?? right.summary, 'thinking') // Merge detail text only: summary is a label/preview ("Thinking",
// truncated excerpt), so falling back to it would splice label text
// into the middle of the merged thinking stream.
const detail = mergeText(left.detail ?? '', right.detail ?? '', 'thinking')
return { return {
timestamp: right.timestamp, timestamp: right.timestamp,
type: 'thinking', type: 'thinking',
+52
View File
@@ -7,6 +7,7 @@ sets up the event adapter pipeline, and serves static files + WebSocket.
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
import os
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@@ -47,6 +48,41 @@ def _is_under_path(path: Path, base: Path) -> bool:
return False return False
def _acquire_single_instance_lock(opc_home: Path) -> Any | None:
"""Prevent two office-UI servers from sharing one OPC home.
Two server processes writing the same ui_state.db contend for the sqlite
write lock and surface as 'database is locked' failures mid-run. The lock
is advisory (flock), scoped to this OPC home, and released automatically
when the process exits — including on crash/SIGKILL, so a stale lock file
can never block a fresh start.
"""
try:
import fcntl
except ImportError:
return None # Non-POSIX platform: no flock available, skip the guard.
lock_path = opc_home / "office_ui.lock"
lock_file = open(lock_path, "a+", encoding="utf-8")
try:
fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except OSError:
lock_file.seek(0)
holder_pid = lock_file.read().strip() or "unknown"
lock_file.close()
raise SystemExit(
f"Another office-UI server (pid {holder_pid}) is already running against "
f"{opc_home}. Two instances sharing one ui_state.db cause 'database is "
"locked' failures that can crash in-flight agent runs. Stop the other "
"instance first, or point this one at a different OPC home."
)
lock_file.seek(0)
lock_file.truncate()
lock_file.write(str(os.getpid()))
lock_file.flush()
return lock_file
# ── Application factory ────────────────────────────────────────────────── # ── Application factory ──────────────────────────────────────────────────
async def create_app( async def create_app(
@@ -72,8 +108,12 @@ async def create_app(
# ── UI-state database (agents + chat) ───────────────────────────── # ── UI-state database (agents + chat) ─────────────────────────────
opc_home = engine.opc_home opc_home = engine.opc_home
instance_lock = _acquire_single_instance_lock(opc_home)
db_path = opc_home / "ui_state.db" db_path = opc_home / "ui_state.db"
db = await aiosqlite.connect(str(db_path)) db = await aiosqlite.connect(str(db_path))
# Wait for a concurrent writer (CLI, tooling) instead of failing after
# sqlite's 5s default with 'database is locked'.
await db.execute("PRAGMA busy_timeout=30000")
agent_store = AgentStore(db) agent_store = AgentStore(db)
await agent_store.initialize() await agent_store.initialize()
@@ -129,6 +169,7 @@ async def create_app(
app["engine"] = engine app["engine"] = engine
app["db"] = db app["db"] = db
app["ws_handler"] = ws_handler app["ws_handler"] = ws_handler
app["instance_lock"] = instance_lock
# ── Routes ──────────────────────────────────────────────────────── # ── Routes ────────────────────────────────────────────────────────
app.router.add_get("/ws", ws_handler.handle_ws) app.router.add_get("/ws", ws_handler.handle_ws)
@@ -230,6 +271,12 @@ async def _on_shutdown(app: aiohttp.web.Application) -> None:
await engine.shutdown() await engine.shutdown()
if db: if db:
await db.close() await db.close()
instance_lock = app.get("instance_lock")
if instance_lock is not None:
try:
instance_lock.close()
except Exception:
pass
logger.info("Office-UI server shut down") logger.info("Office-UI server shut down")
@@ -263,3 +310,8 @@ def run_server(
asyncio.run(_start()) asyncio.run(_start())
except KeyboardInterrupt: except KeyboardInterrupt:
terminal_status("Shutting down Office UI", kind="warning") terminal_status("Shutting down Office UI", kind="warning")
except SystemExit as exc:
if exc.code and not isinstance(exc.code, int):
terminal_status(str(exc.code), kind="error")
raise SystemExit(1) from None
raise
@@ -50,6 +50,9 @@ class OfficeServiceFactory:
on_escalation=self.on_escalation, on_escalation=self.on_escalation,
) )
self.db = await aiosqlite.connect(str(self.engine.opc_home / "ui_state.db")) self.db = await aiosqlite.connect(str(self.engine.opc_home / "ui_state.db"))
# Wait for a concurrent writer (e.g. a running office-UI server)
# instead of failing after sqlite's 5s default with 'database is locked'.
await self.db.execute("PRAGMA busy_timeout=30000")
agent_store = AgentStore(self.db) agent_store = AgentStore(self.db)
await agent_store.initialize() await agent_store.initialize()
chat_store = ChatStore(self.db) chat_store = ChatStore(self.db)
+118 -12
View File
@@ -195,6 +195,14 @@ _TASK_MODE_DEBUG_ONLY_PROGRESS_TYPES: frozenset[str] = frozenset({
}) })
# Company mode shares the task-mode noise list; runtime bookkeeping events
# (turns, status snapshots, cost ticks) carry no reviewable content and drown
# out thinking/tool entries in the per-role activity feed.
_COMPANY_MODE_HIDDEN_RUNTIME_PROGRESS_TYPES: frozenset[str] = (
_TASK_MODE_HIDDEN_RUNTIME_PROGRESS_TYPES | frozenset({"member_inbox_updated"})
)
_TASK_MODE_VISIBLE_RUNTIME_PROGRESS_TYPES: frozenset[str] = frozenset({ _TASK_MODE_VISIBLE_RUNTIME_PROGRESS_TYPES: frozenset[str] = frozenset({
"thinking_delta", "thinking_delta",
"tool_started", "tool_started",
@@ -618,22 +626,39 @@ class WSHandler:
def _progress_callback_for_engine(self, engine: Any) -> Any: def _progress_callback_for_engine(self, engine: Any) -> Any:
async def _progress(text: str, **kw: Any) -> None: async def _progress(text: str, **kw: Any) -> None:
# UI progress is a best-effort display copy: a failure here (e.g.
# a locked ui_state.db) must never crash the agent execution that
# emitted the progress line.
try:
await self.on_progress( await self.on_progress(
text, text,
_runtime_engine=engine, _runtime_engine=engine,
_project_id=self._normalize_project_id(getattr(engine, "project_id", None)), _project_id=self._normalize_project_id(getattr(engine, "project_id", None)),
**kw, **kw,
) )
except asyncio.CancelledError:
raise
except Exception:
logger.opt(exception=True).warning(
"UI progress handling failed; agent execution continues"
)
return _progress return _progress
def _runtime_event_callback_for_engine(self, engine: Any) -> Any: def _runtime_event_callback_for_engine(self, engine: Any) -> Any:
async def _runtime_event(event: Any) -> None: async def _runtime_event(event: Any) -> None:
try:
await self.on_opc_event( await self.on_opc_event(
event, event,
runtime_engine=engine, runtime_engine=engine,
project_id=self._normalize_project_id(getattr(engine, "project_id", None)), project_id=self._normalize_project_id(getattr(engine, "project_id", None)),
) )
except asyncio.CancelledError:
raise
except Exception:
logger.opt(exception=True).warning(
"UI runtime-event handling failed; agent execution continues"
)
setattr(_runtime_event, "_opc_ui_handler_id", id(self)) setattr(_runtime_event, "_opc_ui_handler_id", id(self))
setattr(_runtime_event, "_opc_ui_project_id", self._normalize_project_id(getattr(engine, "project_id", None))) setattr(_runtime_event, "_opc_ui_project_id", self._normalize_project_id(getattr(engine, "project_id", None)))
@@ -653,7 +678,14 @@ class WSHandler:
def _kanban_callback_for_engine(self, engine: Any) -> Any: def _kanban_callback_for_engine(self, engine: Any) -> Any:
async def _kanban_changed() -> None: async def _kanban_changed() -> None:
try:
await self.on_kanban_changed(engine=engine) await self.on_kanban_changed(engine=engine)
except asyncio.CancelledError:
raise
except Exception:
logger.opt(exception=True).warning(
"UI kanban refresh failed; agent execution continues"
)
return _kanban_changed return _kanban_changed
@@ -2552,9 +2584,12 @@ class WSHandler:
if not runtime_type: if not runtime_type:
return None return None
is_task_mode = WSHandler._runtime_payload_is_task_mode(payload) is_task_mode = WSHandler._runtime_payload_is_task_mode(payload)
if is_task_mode and runtime_type in _TASK_MODE_HIDDEN_RUNTIME_PROGRESS_TYPES: if is_task_mode:
if runtime_type in _TASK_MODE_HIDDEN_RUNTIME_PROGRESS_TYPES:
return None return None
if is_task_mode and runtime_type not in _TASK_MODE_VISIBLE_RUNTIME_PROGRESS_TYPES: if runtime_type not in _TASK_MODE_VISIBLE_RUNTIME_PROGRESS_TYPES:
return None
elif runtime_type in _COMPANY_MODE_HIDDEN_RUNTIME_PROGRESS_TYPES:
return None return None
summary = runtime_type.replace("_", " ").title() summary = runtime_type.replace("_", " ").title()
@@ -2570,8 +2605,14 @@ class WSHandler:
return None return None
elif runtime_type == "thinking_delta": elif runtime_type == "thinking_delta":
entry_type = "thinking" entry_type = "thinking"
detail = str(payload.get("text", "") or "").strip() # Keep the raw fragment: streaming deltas are token-sized, so
summary = "Thinking" # stripping them destroys the whitespace between tokens once the
# fragments are merged back into one entry.
detail = str(payload.get("text", "") or "")
if not detail.strip():
return None
preview = " ".join(detail.split())
summary = preview[:120].rstrip() + ("..." if len(preview) > 120 else "")
elif runtime_type == "member_claimed_work_item": elif runtime_type == "member_claimed_work_item":
entry_type = "work_item_started" entry_type = "work_item_started"
priority = str(payload.get("message_priority", "") or "").strip().lower() priority = str(payload.get("message_priority", "") or "").strip().lower()
@@ -2595,10 +2636,8 @@ class WSHandler:
summary = str(payload.get("tool_name", "") or "tool") summary = str(payload.get("tool_name", "") or "tool")
detail = str(payload.get("text", "") or payload.get("message", "") or "").strip() detail = str(payload.get("text", "") or payload.get("message", "") or "").strip()
elif runtime_type == "tool_completed": elif runtime_type == "tool_completed":
entry_type = "tool_call" if is_task_mode else "status_change" entry_type = "tool_call"
summary = str(payload.get("tool_name", "") or "tool") summary = str(payload.get("tool_name", "") or "tool")
if not is_task_mode:
summary = f"{summary} completed"
detail = str(payload.get("result_summary", "") or payload.get("result_preview", "") or "").strip() detail = str(payload.get("result_summary", "") or payload.get("result_preview", "") or "").strip()
elif runtime_type == "status_snapshot": elif runtime_type == "status_snapshot":
entry_type = "status_change" entry_type = "status_change"
@@ -2726,7 +2765,7 @@ class WSHandler:
"detail": detail[:4000] if detail else None, "detail": detail[:4000] if detail else None,
} }
tool_call_id = str(payload.get("tool_call_id", "") or "").strip() tool_call_id = str(payload.get("tool_call_id", "") or "").strip()
if is_task_mode and tool_call_id and entry_type in {"tool_call", "autonomy"}: if tool_call_id and entry_type in {"tool_call", "autonomy"}:
turn_id = str(payload.get("turn_id", "") or "").strip() turn_id = str(payload.get("turn_id", "") or "").strip()
prefix = "permission" if entry_type == "autonomy" else "tool" prefix = "permission" if entry_type == "autonomy" else "tool"
entry.setdefault("item_id", f"{turn_id}:{prefix}:{tool_call_id}" if turn_id else f"{prefix}:{tool_call_id}") entry.setdefault("item_id", f"{turn_id}:{prefix}:{tool_call_id}" if turn_id else f"{prefix}:{tool_call_id}")
@@ -4818,6 +4857,40 @@ class WSHandler:
) )
await self.broadcast({"type": "session_message", "payload": msg}) await self.broadcast({"type": "session_message", "payload": msg})
async def _recent_identical_helper_exists(
self,
channel_id: str,
content: str,
*,
project_id: str,
window_seconds: float = 120.0,
scan_limit: int = 10,
) -> bool:
"""True when an identical assistant helper was posted very recently.
Used to collapse rapid duplicate user clicks into a single helper
reply instead of one warning per click.
"""
try:
recent = await self.chat_store.get_channel_messages(
channel_id, limit=scan_limit, project_id=project_id,
)
except Exception:
return False
now = time.time()
for item in reversed(recent):
if str(item.get("sender", "")) != "assistant":
continue
if str(item.get("content", "")) != content:
continue
try:
created_at = float(item.get("created_at", 0) or 0)
except (TypeError, ValueError):
continue
if now - created_at <= window_seconds:
return True
return False
async def _mark_human_escalation_checkpoint_status( async def _mark_human_escalation_checkpoint_status(
self, self,
escalation_id: str, escalation_id: str,
@@ -5503,6 +5576,34 @@ class WSHandler:
if stale_human_escalation: if stale_human_escalation:
if _looks_like_escalation_reply(content): if _looks_like_escalation_reply(content):
stale_checkpoint_id = explicit_escalation_id or explicit_checkpoint_id stale_checkpoint_id = explicit_escalation_id or explicit_checkpoint_id
# Duplicate clicks on an approval card that was JUST resolved
# (e.g. the user's own first click) are a normal occurrence
# when the server is slow: answer idempotently instead of
# flipping the card to "stale" and spamming inactive warnings.
card = None
try:
card = await self.chat_store.get_checkpoint_message(
stale_checkpoint_id,
channel_id=channel_id,
checkpoint_type="human_escalation",
project_id=pid,
)
except Exception:
logger.opt(exception=True).debug(
"Failed to load checkpoint card for stale escalation reply"
)
card_meta = dict((card or {}).get("metadata", {}) or {})
card_status = str(card_meta.get("checkpoint_status", "") or "").strip().lower()
if card_status in {"resolved", "responded"}:
resolution_reply = str(
card_meta.get("checkpoint_resolution_reply", "") or ""
).strip()
helper_text = (
"This approval was already handled"
+ (f" (decision: {resolution_reply})" if resolution_reply else "")
+ ". No further action is needed."
)
else:
await self._mark_human_escalation_checkpoint_status( await self._mark_human_escalation_checkpoint_status(
stale_checkpoint_id, stale_checkpoint_id,
status="stale", status="stale",
@@ -5510,14 +5611,19 @@ class WSHandler:
channel_id=channel_id, channel_id=channel_id,
reason="reply_to_inactive_escalation", reason="reply_to_inactive_escalation",
) )
helper_text = (
"That approval request is no longer active. "
"The approval card has been marked inactive in the session history."
)
if await self._recent_identical_helper_exists(
channel_id, helper_text, project_id=pid
):
return
helper = await self.chat_store.insert_message( helper = await self.chat_store.insert_message(
channel_id=channel_id, channel_id=channel_id,
sender="assistant", sender="assistant",
sender_name="OPC", sender_name="OPC",
content=( content=helper_text,
"That approval request is no longer active. "
"The approval card has been marked inactive in the session history."
),
project_id=pid, project_id=pid,
metadata={"type": "system"}, metadata={"type": "system"},
) )
+76 -39
View File
@@ -87,22 +87,23 @@ class WSHandlerProgressParsingTests(unittest.TestCase):
self.assertIsNone(entry) self.assertIsNone(entry)
def test_runtime_status_snapshot_maps_to_status_change_entry(self) -> None: def test_company_mode_hides_runtime_bookkeeping_events(self) -> None:
for runtime_type in (
"turn_started",
"turn_completed",
"status_snapshot",
"context_usage",
"cost_update",
"member_inbox_updated",
):
entry = WSHandler._runtime_event_to_progress_entry( entry = WSHandler._runtime_event_to_progress_entry(
{ {
"type": "status_snapshot", "type": runtime_type,
"current_tool": "shell_exec", "current_tool": "shell_exec",
"context_remaining_pct": 64,
"turn_cost_usd": 0.0123, "turn_cost_usd": 0.0123,
}, },
) )
self.assertIsNone(entry, runtime_type)
self.assertIsNotNone(entry)
assert entry is not None
self.assertEqual(entry["type"], "status_change")
self.assertEqual(entry["summary"], "Runtime status")
self.assertIn("tool=shell_exec", entry["detail"])
self.assertIn("context=36% used", entry["detail"])
def test_runtime_member_claimed_work_item_maps_to_started_entry(self) -> None: def test_runtime_member_claimed_work_item_maps_to_started_entry(self) -> None:
entry = WSHandler._runtime_event_to_progress_entry( entry = WSHandler._runtime_event_to_progress_entry(
@@ -124,10 +125,10 @@ class WSHandlerProgressParsingTests(unittest.TestCase):
self.assertNotIn("legacy_title", entry) self.assertNotIn("legacy_title", entry)
self.assertTrue(entry["is_company_runtime"]) self.assertTrue(entry["is_company_runtime"])
def test_runtime_context_usage_prefers_token_count_over_remaining_pct(self) -> None: def test_runtime_context_warning_prefers_token_count_over_remaining_pct(self) -> None:
entry = WSHandler._runtime_event_to_progress_entry( entry = WSHandler._runtime_event_to_progress_entry(
{ {
"type": "context_usage", "type": "context_warning",
"context_tokens": 3200, "context_tokens": 3200,
"context_window": 8000, "context_window": 8000,
"context_remaining_pct": 70, "context_remaining_pct": 70,
@@ -137,23 +138,77 @@ class WSHandlerProgressParsingTests(unittest.TestCase):
self.assertIsNotNone(entry) self.assertIsNotNone(entry)
assert entry is not None assert entry is not None
self.assertEqual(entry["type"], "status_change") self.assertEqual(entry["type"], "status_change")
self.assertEqual(entry["summary"], "Context usage") self.assertEqual(entry["summary"], "Context usage high")
self.assertEqual(entry["detail"], "3200/8000 tokens | 40% used") self.assertEqual(entry["detail"], "3200/8000 tokens | 40% used")
def test_runtime_cost_update_maps_to_status_change_entry(self) -> None: def test_company_mode_tool_completed_stays_tool_call_with_stable_item_id(self) -> None:
entry = WSHandler._runtime_event_to_progress_entry( entry = WSHandler._runtime_event_to_progress_entry(
{ {
"type": "cost_update", "type": "tool_completed",
"turn_cost_usd": 0.0123, "turn_id": "rt-1:2",
"session_cost_usd": 0.0456, "tool_call_id": "call-1",
"tool_name": "web_search",
"result_summary": "3 results",
"work_item_projection_id": "engineering_execution",
}, },
) )
self.assertIsNotNone(entry) self.assertIsNotNone(entry)
assert entry is not None assert entry is not None
self.assertEqual(entry["type"], "status_change") self.assertEqual(entry["type"], "tool_call")
self.assertEqual(entry["summary"], "Cost update") self.assertEqual(entry["summary"], "web_search")
self.assertIn("turn=$0.0123", entry["detail"]) self.assertEqual(entry["detail"], "3 results")
self.assertEqual(entry["item_id"], "rt-1:2:tool:call-1")
self.assertEqual(entry["stream_id"], "rt-1:2:tool:call-1")
self.assertEqual(entry["tool_call_id"], "call-1")
self.assertTrue(entry["is_company_runtime"])
def test_thinking_delta_preserves_fragment_whitespace(self) -> None:
entry = WSHandler._runtime_event_to_progress_entry(
{
"type": "thinking_delta",
"turn_id": "rt-1:1",
"item_id": "rt-1:1:thinking",
"seq": 2,
"text": " wants to analyze",
},
)
self.assertIsNotNone(entry)
assert entry is not None
self.assertEqual(entry["detail"], " wants to analyze")
self.assertEqual(entry["summary"], "wants to analyze")
def test_thinking_delta_whitespace_only_fragment_is_skipped(self) -> None:
entry = WSHandler._runtime_event_to_progress_entry(
{
"type": "thinking_delta",
"turn_id": "rt-1:1",
"item_id": "rt-1:1:thinking",
"seq": 3,
"text": " \n ",
},
)
self.assertIsNone(entry)
def test_company_mode_thinking_summary_previews_content(self) -> None:
entry = WSHandler._runtime_event_to_progress_entry(
{
"type": "thinking_delta",
"turn_id": "rt-1:1",
"item_id": "rt-1:1:thinking",
"seq": 1,
"text": "先梳理竞品清单,再对比功能矩阵。",
"work_item_projection_id": "engineering_execution",
},
)
self.assertIsNotNone(entry)
assert entry is not None
self.assertEqual(entry["type"], "thinking")
self.assertEqual(entry["summary"], "先梳理竞品清单,再对比功能矩阵。")
self.assertEqual(entry["detail"], "先梳理竞品清单,再对比功能矩阵。")
def test_task_mode_low_value_runtime_events_are_hidden(self) -> None: def test_task_mode_low_value_runtime_events_are_hidden(self) -> None:
for runtime_type in ( for runtime_type in (
@@ -195,7 +250,7 @@ class WSHandlerProgressParsingTests(unittest.TestCase):
self.assertIsNotNone(entry) self.assertIsNotNone(entry)
assert entry is not None assert entry is not None
self.assertEqual(entry["type"], "thinking") self.assertEqual(entry["type"], "thinking")
self.assertEqual(entry["summary"], "Thinking") self.assertEqual(entry["summary"], "我先检查。")
self.assertEqual(entry["detail"], "我先检查。") self.assertEqual(entry["detail"], "我先检查。")
self.assertEqual(entry["turn_id"], "rt-1:1") self.assertEqual(entry["turn_id"], "rt-1:1")
self.assertEqual(entry["item_id"], "rt-1:1:thinking") self.assertEqual(entry["item_id"], "rt-1:1:thinking")
@@ -256,24 +311,6 @@ class WSHandlerProgressParsingTests(unittest.TestCase):
self.assertEqual(entry["summary"], "Needs input") self.assertEqual(entry["summary"], "Needs input")
self.assertEqual(entry["detail"], "task_user_input") self.assertEqual(entry["detail"], "task_user_input")
def test_runtime_member_inbox_updated_maps_to_status_change_entry(self) -> None:
entry = WSHandler._runtime_event_to_progress_entry(
{
"type": "member_inbox_updated",
"actionable_inbox_count": 2,
"protocol_backlog_count": 1,
"notification_backlog_count": 3,
"resident_status": "idle",
},
)
self.assertIsNotNone(entry)
assert entry is not None
self.assertEqual(entry["type"], "status_change")
self.assertEqual(entry["summary"], "Resident inbox updated")
self.assertIn("chat=2", entry["detail"])
self.assertIn("protocol=1", entry["detail"])
def test_runtime_worker_notification_maps_error_to_work_item_failed_entry(self) -> None: def test_runtime_worker_notification_maps_error_to_work_item_failed_entry(self) -> None:
entry = WSHandler._runtime_event_to_progress_entry( entry = WSHandler._runtime_event_to_progress_entry(
{ {