@hybridaione/hybridclaw 0.12.7 → 0.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +6 -0
- package/console/dist/assets/chat-A439MpRy.css +1 -0
- package/console/dist/assets/{chat-9p59eGtz.js → chat-I6Pguk2e.js} +4 -4
- package/console/dist/assets/{index-UavkasGt.js → index-DON3wuuC.js} +3 -3
- package/console/dist/assets/index-DQoS6dsR.css +1 -0
- package/console/dist/assets/{terminal-DeXdduvj.js → terminal-BQEo_jcm.js} +1 -1
- package/console/dist/index.html +2 -2
- package/container/Dockerfile +2 -0
- package/container/dist/tools.js +1 -2
- package/container/dist/tools.js.map +1 -1
- package/container/dist/web-fetch.js +0 -15
- package/container/dist/web-fetch.js.map +1 -1
- package/container/package-lock.json +2 -2
- package/container/package.json +1 -1
- package/container/src/tools.ts +1 -5
- package/container/src/web-fetch.ts +0 -28
- package/dist/agent/prompt-hooks.d.ts.map +1 -1
- package/dist/agent/prompt-hooks.js +3 -2
- package/dist/agent/prompt-hooks.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +1 -1
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/gateway/gateway-http-proxy.d.ts.map +1 -1
- package/dist/gateway/gateway-http-proxy.js +0 -27
- package/dist/gateway/gateway-http-proxy.js.map +1 -1
- package/dist/gateway/gateway-http-server.d.ts.map +1 -1
- package/dist/gateway/gateway-http-server.js +0 -6
- package/dist/gateway/gateway-http-server.js.map +1 -1
- package/dist/gateway/gateway-http-utils.d.ts.map +1 -1
- package/dist/gateway/gateway-http-utils.js +0 -6
- package/dist/gateway/gateway-http-utils.js.map +1 -1
- package/dist/gateway/gateway-restart.d.ts +16 -0
- package/dist/gateway/gateway-restart.d.ts.map +1 -1
- package/dist/gateway/gateway-restart.js +101 -19
- package/dist/gateway/gateway-restart.js.map +1 -1
- package/dist/gateway/gateway-service.d.ts.map +1 -1
- package/dist/gateway/gateway-service.js +18 -0
- package/dist/gateway/gateway-service.js.map +1 -1
- package/dist/infra/container-runner.d.ts.map +1 -1
- package/dist/infra/container-runner.js +7 -4
- package/dist/infra/container-runner.js.map +1 -1
- package/dist/infra/container-setup.d.ts +6 -0
- package/dist/infra/container-setup.d.ts.map +1 -1
- package/dist/infra/container-setup.js +107 -9
- package/dist/infra/container-setup.js.map +1 -1
- package/dist/memory/db.d.ts.map +1 -1
- package/dist/memory/db.js +0 -7
- package/dist/memory/db.js.map +1 -1
- package/dist/observability/otel.d.ts.map +1 -1
- package/dist/observability/otel.js +0 -3
- package/dist/observability/otel.js.map +1 -1
- package/dist/scheduler/scheduler.d.ts.map +1 -1
- package/dist/scheduler/scheduler.js +0 -2
- package/dist/scheduler/scheduler.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +10 -2
- package/dist/update.js.map +1 -1
- package/dist/workspace.d.ts +13 -5
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +29 -11
- package/dist/workspace.js.map +1 -1
- package/docs/chat.html +90 -38
- package/docs/content/developer-guide/runtime.md +9 -4
- package/docs/content/getting-started/quickstart.md +4 -0
- package/docs/content/reference/commands.md +7 -1
- package/docs/development/getting-started/quickstart.md +4 -0
- package/docs/development/internals/runtime.md +9 -4
- package/docs/development/reference/commands.md +7 -1
- package/docs/static/docs.js +108 -38
- package/package.json +1 -1
- package/skills/pdf/SKILL.md +4 -1
- package/console/dist/assets/chat-CKhyYUgY.css +0 -1
- package/console/dist/assets/index-DH54vb4K.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## [0.12.8](https://github.com/HybridAIOne/hybridclaw/tree/v0.12.8)
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **`hybridclaw update` can restart the gateway automatically**: After a
|
|
10
|
+
successful global npm upgrade, HybridClaw now attempts to restart a running
|
|
11
|
+
local gateway with its recorded launch command and flags. If no running
|
|
12
|
+
gateway is found, or the recorded process cannot be replayed or signalled,
|
|
13
|
+
the CLI falls back to manual `hybridclaw gateway restart` instructions.
|
|
14
|
+
- **Container status is more informative**: `hybridclaw gateway status` and
|
|
15
|
+
`!claw status` now include the configured container image name plus the
|
|
16
|
+
resolved image version and short image id when sandbox mode is `container`.
|
|
17
|
+
- **Release-built agent images carry version metadata**: `npm run
|
|
18
|
+
build:container` now passes the container package version into the image's
|
|
19
|
+
OCI labels so runtime status output can report the actual image version when
|
|
20
|
+
available.
|
|
21
|
+
- **Bundled deliverable guidance now prefers workspace-relative outputs**:
|
|
22
|
+
Built-in prompt hooks and the PDF skill now reserve `/tmp` for scratch files
|
|
23
|
+
and direct final PDFs, reports, and similar user-visible outputs into the
|
|
24
|
+
workspace so they persist and can be attached.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Source-checkout Docker workspaces bootstrap `node_modules` correctly**:
|
|
29
|
+
Container launches now pre-stage or repair the workspace `node_modules`
|
|
30
|
+
symlink to `/app/node_modules`, so bundled JS skills can import repo-managed
|
|
31
|
+
dependencies reliably inside Docker even when a stale host symlink already
|
|
32
|
+
exists.
|
|
33
|
+
- **Default agent image release and pull flow no longer depends on GHCR**:
|
|
34
|
+
The packaged runtime now pulls the default `hybridclaw-agent` image from
|
|
35
|
+
Docker Hub only, and the release workflow stops publishing the private GHCR
|
|
36
|
+
agent image or advertising a dead fallback path.
|
|
37
|
+
- **Ordered-list rendering is restored across chat and docs surfaces**: Web
|
|
38
|
+
chat, docs pages, and console markdown rendering now preserve ordered-list
|
|
39
|
+
numbering across intervening bullets, support nested list indentation, and
|
|
40
|
+
handle LLM-emitted `**1. Heading**` list items correctly.
|
|
41
|
+
|
|
5
42
|
## [0.12.7](https://github.com/HybridAIOne/hybridclaw/tree/v0.12.7)
|
|
6
43
|
|
|
7
44
|
### Added
|
package/README.md
CHANGED
|
@@ -100,6 +100,12 @@ Once the gateway is running, open HybridClaw locally:
|
|
|
100
100
|
|
|
101
101
|
## Operator workflows
|
|
102
102
|
|
|
103
|
+
- `hybridclaw gateway status` reports sandbox/runtime details, and in
|
|
104
|
+
container mode it includes the configured image name plus the resolved
|
|
105
|
+
version and short image id.
|
|
106
|
+
- `hybridclaw update --yes` upgrades a global npm install and auto-restarts a
|
|
107
|
+
running local gateway with its original launch parameters when possible,
|
|
108
|
+
falling back to `hybridclaw gateway restart` if not.
|
|
103
109
|
- `/admin/agents` edits allowlisted bootstrap markdown files such as
|
|
104
110
|
`AGENTS.md`, keeps saved revisions, and restores earlier versions from the
|
|
105
111
|
browser.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._chatPage_ezgbk_1{grid-template-columns:260px 1fr;height:100%;min-height:0;display:grid;overflow:hidden}._sidebar_ezgbk_9{background:var(--sidebar);border-right:1px solid var(--line);flex-direction:column;gap:8px;min-height:0;padding:16px 12px;display:flex;overflow-y:auto}._sidebarHeader_ezgbk_20{align-items:center;gap:10px;padding:4px 6px 12px;display:flex}._sidebarLogo_ezgbk_27{flex-shrink:0;width:28px;height:28px}._sidebarBrand_ezgbk_33{color:var(--text);letter-spacing:-.02em;font-size:1rem;font-weight:700}._newChatButton_ezgbk_40{border-radius:var(--radius-sm);border:1px solid var(--line-strong);background:var(--panel-bg);width:100%;color:var(--text);cursor:pointer;justify-content:center;align-items:center;gap:6px;padding:9px 12px;font-size:.875rem;font-weight:500;transition:background .15s;display:flex}._newChatButton_ezgbk_40:hover{background:var(--accent-soft)}._sidebarLabel_ezgbk_61{text-transform:uppercase;letter-spacing:.08em;color:var(--muted-foreground);margin:12px 0 4px;padding:0 6px;font-size:.7rem;font-weight:700}._sessionList_ezgbk_71{flex-direction:column;gap:2px;margin:0;padding:0;list-style:none;display:flex}._sessionItem_ezgbk_80{appearance:none;border-radius:var(--radius-sm);cursor:pointer;text-align:left;width:100%;font:inherit;color:inherit;background:0 0;border:0;flex-direction:column;gap:2px;padding:8px 10px;transition:background .12s;display:flex;overflow:hidden}._sessionItem_ezgbk_80:hover{background:var(--panel-bg)}._sessionItemActive_ezgbk_102{background:var(--panel-bg);box-shadow:var(--shadow-raised)}._sessionTitle_ezgbk_107{color:var(--text);white-space:nowrap;text-overflow:ellipsis;font-size:.875rem;font-weight:500;overflow:hidden}._sessionTime_ezgbk_116{color:var(--muted-foreground);font-size:.72rem}._chatMain_ezgbk_121{flex-direction:column;min-height:0;display:flex;position:relative;overflow:hidden}._messageArea_ezgbk_129{scroll-behavior:smooth;flex:auto;min-height:0;padding:24px 24px 12px;overflow-y:auto}._messageList_ezgbk_137{flex-direction:column;gap:12px;width:100%;max-width:860px;margin:0 auto;display:flex}._emptyState_ezgbk_146{flex-direction:column;flex:auto;justify-content:center;align-items:center;min-height:0;padding:48px 24px;display:flex}._greeting_ezgbk_156{color:var(--muted-foreground);text-align:center;letter-spacing:-.02em;font-size:clamp(1.6rem,3vw,2.2rem);font-weight:700;line-height:1.3}._messageBlock_ezgbk_165{flex-direction:column;gap:6px;display:flex}._messageBlockUser_ezgbk_171{align-items:flex-end}._messageBlockAssistant_ezgbk_175,._messageBlockSystem_ezgbk_176{align-items:flex-start}._agentLabel_ezgbk_180{color:var(--muted-foreground);align-items:center;gap:6px;padding:0 4px;font-size:.75rem;font-weight:600;display:flex}._agentAvatar_ezgbk_190{object-fit:cover;border-radius:999px;width:20px;height:20px}._agentInitial_ezgbk_197{background:var(--primary);width:20px;height:20px;color:var(--primary-foreground);border-radius:999px;justify-content:center;align-items:center;font-size:.65rem;font-weight:700;display:flex}._bubble_ezgbk_210{word-wrap:break-word;overflow-wrap:break-word;border-radius:14px;max-width:85%;padding:10px 14px;font-size:.92rem;line-height:1.55}._bubbleUser_ezgbk_220{background:linear-gradient(135deg, var(--primary), var(--ring));color:var(--primary-foreground);border-bottom-right-radius:4px}._bubbleAssistant_ezgbk_226{background:var(--card);color:var(--card-foreground);border:1px solid var(--line);box-shadow:var(--shadow-card);border-bottom-left-radius:4px}._bubbleSystem_ezgbk_234{background:var(--accent-soft);color:var(--accent-foreground);text-align:center;align-self:center;max-width:90%;font-size:.84rem}._markdownContent_ezgbk_243{line-height:1.6}._markdownContent_ezgbk_243 h1,._markdownContent_ezgbk_243 h2,._markdownContent_ezgbk_243 h3{color:var(--foreground);letter-spacing:-.02em;margin:.6em 0 .3em;font-weight:600}._markdownContent_ezgbk_243 h1{font-size:1.25rem}._markdownContent_ezgbk_243 h2{font-size:1.12rem}._markdownContent_ezgbk_243 h3{font-size:1rem}._markdownContent_ezgbk_243 p{margin:.4em 0}._markdownContent_ezgbk_243 ul,._markdownContent_ezgbk_243 ol{margin:.4em 0;padding-left:20px}._markdownContent_ezgbk_243 li{margin:2px 0}._markdownContent_ezgbk_243 blockquote{border-left:3px solid var(--line-strong);color:var(--muted-foreground);margin:.5em 0;padding:4px 12px}._markdownContent_ezgbk_243 code{background:var(--muted);color:var(--foreground);border-radius:4px;padding:2px 5px;font-size:.86em}._markdownContent_ezgbk_243 pre{background:var(--terminal);color:var(--terminal-foreground);border-radius:var(--radius-sm);margin:.5em 0;padding:12px 14px;font-size:.84rem;line-height:1.5;overflow-x:auto}._markdownContent_ezgbk_243 pre code{color:inherit;font-size:inherit;background:0 0;border-radius:0;padding:0}._markdownContent_ezgbk_243 hr{border:none;border-top:1px solid var(--line);margin:.8em 0}._markdownContent_ezgbk_243 a{color:var(--primary);text-decoration:none}._markdownContent_ezgbk_243 a:hover{text-decoration:underline}._markdownContent_ezgbk_243 table{border-collapse:collapse;width:100%;margin:.5em 0;font-size:.86rem}._markdownContent_ezgbk_243 th,._markdownContent_ezgbk_243 td{border:1px solid var(--line);text-align:left;padding:6px 10px}._markdownContent_ezgbk_243 th{background:var(--muted);font-weight:600}._markdownContent_ezgbk_243 tbody tr:nth-child(2n){background:var(--muted)}._messageActions_ezgbk_354{opacity:0;gap:4px;padding:0 4px;transition:opacity .15s;display:flex}._messageBlock_ezgbk_165:hover ._messageActions_ezgbk_354{opacity:1}._actionButton_ezgbk_366{width:28px;height:28px;color:var(--muted-foreground);cursor:pointer;background:0 0;border:none;border-radius:999px;justify-content:center;align-items:center;font-size:.82rem;transition:background .12s,color .12s;display:flex}._actionButton_ezgbk_366:hover{background:var(--muted);color:var(--text)}._actionButtonSuccess_ezgbk_388{color:var(--success)}._branchSwitcher_ezgbk_392{color:var(--muted-foreground);align-items:center;gap:4px;padding:0 4px;font-size:.75rem;display:inline-flex}._branchButton_ezgbk_401{width:22px;height:22px;color:var(--muted-foreground);cursor:pointer;background:0 0;border:none;border-radius:999px;justify-content:center;align-items:center;font-size:.8rem;display:flex}._branchButton_ezgbk_401:hover{background:var(--muted);color:var(--text)}._branchButton_ezgbk_401:disabled{opacity:.4;cursor:default}._approvalActions_ezgbk_425{flex-wrap:wrap;gap:6px;margin-top:8px;display:flex}._approvalAllow_ezgbk_432{border-radius:var(--radius-sm);border:1px solid var(--success-border);background:var(--success-soft);color:var(--success);cursor:pointer;padding:6px 12px;font-size:.82rem;font-weight:500}._approvalAllow_ezgbk_432:hover{opacity:.85}._approvalDeny_ezgbk_447{border-radius:var(--radius-sm);border:1px solid var(--danger-border);background:var(--danger-soft);color:var(--danger);cursor:pointer;padding:6px 12px;font-size:.82rem;font-weight:500}._approvalDeny_ezgbk_447:hover{opacity:.85}._approvalAllow_ezgbk_432:disabled,._approvalDeny_ezgbk_447:disabled{opacity:.5;cursor:default}._artifactCard_ezgbk_468{border:1px solid var(--line);border-radius:var(--radius-sm);background:var(--muted);align-items:center;gap:10px;margin-top:8px;padding:10px 14px;display:flex}._artifactFilename_ezgbk_479{color:var(--text);white-space:nowrap;text-overflow:ellipsis;font-size:.84rem;font-weight:500;overflow:hidden}._artifactBadge_ezgbk_488{background:var(--accent-soft);color:var(--accent-foreground);border-radius:4px;flex-shrink:0;padding:2px 6px;font-size:.7rem;font-weight:500}._artifactDownload_ezgbk_498{color:var(--primary);cursor:pointer;background:0 0;border:none;flex-shrink:0;margin-left:auto;padding:0;font-size:.82rem;text-decoration:none}._artifactDownload_ezgbk_498:hover{text-decoration:underline}._artifactDownload_ezgbk_498:disabled{opacity:.6;cursor:default;text-decoration:none}._artifactPreview_ezgbk_520{border-radius:var(--radius-sm);max-width:100%;margin-top:8px}._artifactPreview_ezgbk_520 img{border-radius:var(--radius-sm);max-width:100%}._thinking_ezgbk_531{align-items:center;gap:4px;padding:10px 14px;display:flex}._thinkingDot_ezgbk_538{background:var(--muted-foreground);border-radius:999px;width:7px;height:7px;animation:1.2s ease-in-out infinite _thinkingBounce_ezgbk_1}._thinkingDot_ezgbk_538:nth-child(2){animation-delay:.15s}._thinkingDot_ezgbk_538:nth-child(3){animation-delay:.3s}@keyframes _thinkingBounce_ezgbk_1{0%,80%,to{opacity:.4;transform:scale(.6)}40%{opacity:1;transform:scale(1)}}._composerWrapper_ezgbk_567{flex-shrink:0;padding:0 24px 20px}._composer_ezgbk_567{border:1px solid var(--line-strong);background:var(--panel-bg);width:100%;max-width:860px;box-shadow:var(--shadow-raised);border-radius:24px;flex-direction:column;margin:0 auto;display:flex;overflow:hidden}._pendingMediaRow_ezgbk_585{flex-wrap:wrap;gap:6px;padding:10px 14px 0;display:flex}._mediaChip_ezgbk_592{background:var(--muted);color:var(--text);border-radius:6px;align-items:center;gap:4px;max-width:180px;padding:4px 8px;font-size:.78rem;display:inline-flex}._mediaChipName_ezgbk_604{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}._mediaChipRemove_ezgbk_610{width:16px;height:16px;color:var(--muted-foreground);cursor:pointer;background:0 0;border:none;border-radius:999px;flex-shrink:0;justify-content:center;align-items:center;font-size:.7rem;display:flex}._mediaChipRemove_ezgbk_610:hover{color:var(--danger)}._composerRow_ezgbk_629{align-items:flex-end;gap:8px;padding:10px 14px;display:flex}._composerInput_ezgbk_636{resize:none;min-height:24px;max-height:180px;color:var(--text);background:0 0;border:none;outline:none;flex:auto;padding:2px 0;font-size:.92rem;line-height:1.5}._composerInput_ezgbk_636::placeholder{color:var(--muted-foreground)}._attachButton_ezgbk_654,._sendButton_ezgbk_655{cursor:pointer;border:none;border-radius:999px;flex-shrink:0;justify-content:center;align-items:center;width:36px;height:36px;transition:background .12s,color .12s;display:flex}._attachButton_ezgbk_654{color:var(--muted-foreground);background:0 0;font-size:1.2rem}._attachButton_ezgbk_654:hover{background:var(--muted);color:var(--text)}._sendButton_ezgbk_655{background:var(--primary);color:var(--primary-foreground);font-size:.9rem}._sendButton_ezgbk_655:disabled{opacity:.5;cursor:default}._sendButton_ezgbk_655._stopping_ezgbk_692{background:var(--danger-soft);color:var(--danger)}._slashSuggestions_ezgbk_697{background:var(--popover);border:1px solid var(--line);border-radius:var(--radius-md);max-height:220px;box-shadow:var(--shadow-popover);z-index:20;margin-bottom:4px;position:absolute;bottom:100%;left:0;right:0;overflow-y:auto}._suggestionItem_ezgbk_712{cursor:pointer;flex-direction:column;gap:2px;padding:8px 14px;transition:background .1s;display:flex}._suggestionItem_ezgbk_712:hover,._suggestionItemActive_ezgbk_722{background:var(--muted)}._suggestionLabel_ezgbk_726{color:var(--text);font-size:.86rem;font-weight:500}._suggestionDesc_ezgbk_732{color:var(--muted-foreground);font-size:.76rem}._errorBanner_ezgbk_737{border-radius:var(--radius-sm);background:var(--danger-soft);border:1px solid var(--danger-border);color:var(--danger);width:calc(100% - 48px);max-width:860px;margin:0 auto;padding:8px 14px;font-size:.84rem}._editArea_ezgbk_751{resize:vertical;border:1px solid var(--line-strong);border-radius:var(--radius-sm);background:var(--panel-bg);width:100%;min-height:48px;max-height:200px;color:var(--text);padding:8px 10px;font-family:inherit;font-size:.92rem;line-height:1.5}._editButtons_ezgbk_766{gap:6px;margin-top:6px;display:flex}@media (width<=900px){._chatPage_ezgbk_1{grid-template-columns:1fr}._sidebar_ezgbk_9{display:none}._sidebarOpen_ezgbk_781{z-index:100;width:280px;max-width:85vw;animation:.2s _slideIn_ezgbk_1;display:flex;position:fixed;inset:0}._sidebarBackdrop_ezgbk_791{z-index:99;cursor:default;background:#0006;border:none;padding:0;position:fixed;inset:0}._mobileHeader_ezgbk_801{border-bottom:1px solid var(--line);flex-shrink:0;align-items:center;gap:10px;padding:12px 16px;display:flex}._messageArea_ezgbk_129{padding:16px 16px 8px}._composerWrapper_ezgbk_567{padding:0 16px 12px}}@media (width>=901px){._mobileHeader_ezgbk_801,._sidebarBackdrop_ezgbk_791{display:none}}@keyframes _slideIn_ezgbk_1{0%{transform:translate(-100%)}to{transform:translate(0)}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{n as e,t}from"./rolldown-runtime-DF2fYuay.js";import{T as n,a as r,i,n as a}from"./query-DYNohPrB.js";import{B as o,V as s,at as c,m as l,r as u,rt as d,s as f,t as p}from"./cx-Dzb14TPi.js";import{t as m}from"./index-
|
|
2
|
-
`)}var P={once:`/approve once`,always:`/approve always`,session:`/approve session`,agent:`/approve agent`,all:`/approve all`,deny:`/approve no`};function F(e,t){let n=P[e];if(!n)return null;let r=t.trim();return r?`${n} ${r}`:n}function I(e){return(e.name??``).trim()||`clipboard${{"application/pdf":`.pdf`,"image/gif":`.gif`,"image/jpeg":`.jpg`,"image/png":`.png`,"image/webp":`.webp`,"text/plain":`.txt`}[(e.type??``).trim().toLowerCase()]??``}`}function L(e){let t=I(e);return e.name===t?e:new File([e],t,{type:e.type||`application/octet-stream`,lastModified:Number.isFinite(e.lastModified)?e.lastModified:Date.now()})}function R(e){if(!e)return[];let t=[];for(let n of Array.from(e.files))t.push(L(n));if(t.length>0)return t;let n=new Set;for(let r of Array.from(e.items)){if(r.kind!==`file`)continue;let e=r.getAsFile();if(!e)continue;let i=L(e),a=`${i.name}:${i.size}:${i.type}:${i.lastModified}`;n.has(a)||(n.add(a),t.push(i))}return t}function ee(e,t=64){return e?e.scrollHeight-e.scrollTop-e.clientHeight<=t:!0}var z={chatPage:`_chatPage_1ovpu_3`,sidebar:`_sidebar_1ovpu_13`,sidebarHeader:`_sidebarHeader_1ovpu_24`,sidebarLogo:`_sidebarLogo_1ovpu_31`,sidebarBrand:`_sidebarBrand_1ovpu_37`,newChatButton:`_newChatButton_1ovpu_44`,sidebarLabel:`_sidebarLabel_1ovpu_65`,sessionList:`_sessionList_1ovpu_75`,sessionItem:`_sessionItem_1ovpu_84`,sessionItemActive:`_sessionItemActive_1ovpu_106`,sessionTitle:`_sessionTitle_1ovpu_111`,sessionTime:`_sessionTime_1ovpu_120`,chatMain:`_chatMain_1ovpu_127`,messageArea:`_messageArea_1ovpu_135`,messageList:`_messageList_1ovpu_143`,emptyState:`_emptyState_1ovpu_154`,greeting:`_greeting_1ovpu_164`,messageBlock:`_messageBlock_1ovpu_175`,messageBlockUser:`_messageBlockUser_1ovpu_181`,messageBlockAssistant:`_messageBlockAssistant_1ovpu_185`,messageBlockSystem:`_messageBlockSystem_1ovpu_186`,agentLabel:`_agentLabel_1ovpu_190`,agentAvatar:`_agentAvatar_1ovpu_200`,agentInitial:`_agentInitial_1ovpu_207`,bubble:`_bubble_1ovpu_220`,bubbleUser:`_bubbleUser_1ovpu_230`,bubbleAssistant:`_bubbleAssistant_1ovpu_236`,bubbleSystem:`_bubbleSystem_1ovpu_244`,markdownContent:`_markdownContent_1ovpu_255`,messageActions:`_messageActions_1ovpu_368`,actionButton:`_actionButton_1ovpu_380`,actionButtonSuccess:`_actionButtonSuccess_1ovpu_402`,branchSwitcher:`_branchSwitcher_1ovpu_408`,branchButton:`_branchButton_1ovpu_417`,approvalActions:`_approvalActions_1ovpu_443`,approvalAllow:`_approvalAllow_1ovpu_450`,approvalDeny:`_approvalDeny_1ovpu_465`,artifactCard:`_artifactCard_1ovpu_488`,artifactFilename:`_artifactFilename_1ovpu_499`,artifactBadge:`_artifactBadge_1ovpu_508`,artifactDownload:`_artifactDownload_1ovpu_518`,artifactPreview:`_artifactPreview_1ovpu_540`,thinking:`_thinking_1ovpu_553`,thinkingDot:`_thinkingDot_1ovpu_560`,thinkingBounce:`_thinkingBounce_1ovpu_1`,composerWrapper:`_composerWrapper_1ovpu_591`,composer:`_composer_1ovpu_591`,pendingMediaRow:`_pendingMediaRow_1ovpu_609`,mediaChip:`_mediaChip_1ovpu_616`,mediaChipName:`_mediaChipName_1ovpu_628`,mediaChipRemove:`_mediaChipRemove_1ovpu_634`,composerRow:`_composerRow_1ovpu_653`,composerInput:`_composerInput_1ovpu_660`,attachButton:`_attachButton_1ovpu_678`,sendButton:`_sendButton_1ovpu_679`,stopping:`_stopping_1ovpu_716`,slashSuggestions:`_slashSuggestions_1ovpu_723`,suggestionItem:`_suggestionItem_1ovpu_738`,suggestionItemActive:`_suggestionItemActive_1ovpu_748`,suggestionLabel:`_suggestionLabel_1ovpu_752`,suggestionDesc:`_suggestionDesc_1ovpu_758`,errorBanner:`_errorBanner_1ovpu_765`,editArea:`_editArea_1ovpu_781`,editButtons:`_editButtons_1ovpu_796`,sidebarOpen:`_sidebarOpen_1ovpu_813`,slideIn:`_slideIn_1ovpu_1`,sidebarBackdrop:`_sidebarBackdrop_1ovpu_823`,mobileHeader:`_mobileHeader_1ovpu_833`},B=r();function te(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:z.sidebarHeader,children:[(0,B.jsx)(`img`,{className:z.sidebarLogo,src:`/static/hybridclaw-logo.svg`,alt:`HybridClaw`}),(0,B.jsx)(`span`,{className:z.sidebarBrand,children:`HybridClaw`})]}),(0,B.jsx)(`button`,{type:`button`,className:z.newChatButton,onClick:e.onNewChat,children:`+ New Conversation`}),e.sessions.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:z.sidebarLabel,children:`Recent`}),(0,B.jsx)(`ul`,{className:z.sessionList,"aria-live":`polite`,children:e.sessions.map(t=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,className:p(z.sessionItem,t.sessionId===e.activeSessionId&&z.sessionItemActive),"aria-current":t.sessionId===e.activeSessionId?`page`:void 0,onClick:()=>e.onOpenSession(t.sessionId),children:[(0,B.jsx)(`span`,{className:z.sessionTitle,children:t.title||`Untitled`}),(0,B.jsx)(`span`,{className:z.sessionTime,children:m(t.lastActive)})]})},t.sessionId))})]}):null]})}function ne(e){return e.items.length===0?null:(0,B.jsx)(`div`,{className:z.slashSuggestions,role:`listbox`,children:e.items.map((t,n)=>(0,B.jsxs)(`div`,{className:p(z.suggestionItem,n===e.activeIndex&&z.suggestionItemActive),role:`option`,tabIndex:-1,"aria-selected":n===e.activeIndex,onMouseDown:n=>{n.preventDefault(),e.onSelect(t)},children:[(0,B.jsx)(`span`,{className:z.suggestionLabel,children:t.label}),t.description?(0,B.jsx)(`span`,{className:z.suggestionDesc,children:t.description}):null]},t.id))})}function re(e){let t=(0,h.useRef)(null),n=(0,h.useRef)(null),[r,i]=(0,h.useState)([]),[a,o]=(0,h.useState)(0),[s,c]=(0,h.useState)([]),[l,u]=(0,h.useState)(0),[d,f]=(0,h.useState)(!1),m=(0,h.useRef)(null),g=(0,h.useRef)(0);(0,h.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let _=()=>{let e=t.current;e&&(e.style.height=`24px`,e.style.height=`${Math.min(e.scrollHeight,180)}px`)},y=(0,h.useCallback)(async t=>{g.current+=1;let n=g.current;try{let r=await v(e.token,t||void 0);if(n!==g.current)return;c(r.commands??[]),u(0),f((r.commands??[]).length>0)}catch{if(n!==g.current)return;c([]),f(!1)}},[e.token]),b=()=>{_();let e=t.current?.value??``;if(e.startsWith(`/`)){let t=e.slice(1).trim();m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{y(t)},150)}else f(!1)},x=e=>{t.current&&(t.current.value=`${e.insertText} `,f(!1),_(),t.current.focus())},S=()=>{if(e.isStreaming){e.onStop();return}let n=(t.current?.value??``).trim();!n&&r.length===0||a>0||(e.onSend(n,r),t.current&&(t.current.value=``),i([]),_())},C=e=>{if(d&&s.length>0){if(e.key===`ArrowDown`){e.preventDefault(),u(e=>(e+1)%s.length);return}if(e.key===`ArrowUp`){e.preventDefault(),u(e=>(e-1+s.length)%s.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),x(s[l]);return}if(e.key===`Escape`){e.preventDefault(),f(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),S())},w=e=>{let t=R(e.clipboardData);t.length>0&&(e.preventDefault(),T(t))},T=async t=>{o(e=>e+t.length);try{let n=await e.onUploadFiles(t);n.length>0&&i(e=>[...e,...n])}finally{o(e=>Math.max(0,e-t.length))}},E=e=>{let t=Array.from(e.target.files??[]);t.length>0&&T(t),e.target.value=``},D=e=>{i(t=>t.filter((t,n)=>n!==e))};return(0,B.jsx)(`div`,{className:z.composerWrapper,children:(0,B.jsxs)(`div`,{className:z.composer,style:{position:`relative`},children:[d?(0,B.jsx)(ne,{items:s,activeIndex:l,onSelect:x}):null,r.length>0||a>0?(0,B.jsxs)(`div`,{className:z.pendingMediaRow,children:[r.map((e,t)=>(0,B.jsxs)(`span`,{className:z.mediaChip,children:[(0,B.jsx)(`span`,{className:z.mediaChipName,children:e.filename}),(0,B.jsx)(`button`,{type:`button`,className:z.mediaChipRemove,onClick:()=>D(t),children:`×`})]},e.path)),a>0?(0,B.jsx)(`span`,{className:z.mediaChip,children:`Uploading…`}):null]}):null,(0,B.jsxs)(`div`,{className:z.composerRow,children:[(0,B.jsx)(`button`,{type:`button`,className:z.attachButton,onClick:()=>n.current?.click(),"aria-label":`Attach files`,children:`+`}),(0,B.jsx)(`textarea`,{ref:t,className:z.composerInput,rows:1,placeholder:`Message HybridClaw`,disabled:e.isStreaming,onInput:b,onKeyDown:C,onPaste:w,"aria-label":`Message input`}),(0,B.jsx)(`button`,{type:`button`,className:p(z.sendButton,e.isStreaming&&z.stopping),onClick:S,"aria-label":e.isStreaming?`Stop`:`Send message`,children:e.isStreaming?(0,B.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`,"aria-hidden":`true`,children:(0,B.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})}):(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M12 19V5`}),(0,B.jsx)(`path`,{d:`m5 12 7-7 7 7`})]})}),(0,B.jsx)(`input`,{ref:n,type:`file`,hidden:!0,multiple:!0,onChange:E})]})]})})}function V(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var H=V();function ie(e){H=e}var U={exec:()=>null};function W(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(G.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ae=(()=>{try{return!0}catch{return!1}})(),G={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},K=/^(?:[ \t]*(?:\n|$))+/,oe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,se=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ce=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,le=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ue=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,de=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fe=W(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),pe=W(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),me=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,he=/^[^\n]+/,ge=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,_e=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,ge).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ve=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ue).getRegex(),ye=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,be=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xe=W(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,be).replace(`tag`,ye).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se=W(me).replace(`hr`,ce).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ye).getRegex(),Ce={blockquote:W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Se).getRegex(),code:oe,def:_e,fences:se,heading:le,hr:ce,html:xe,lheading:fe,list:ve,newline:K,paragraph:Se,table:U,text:he},we=W(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,ce).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ye).getRegex(),Te={...Ce,lheading:pe,table:we,paragraph:W(me).replace(`hr`,ce).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,we).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ye).getRegex()},Ee={...Ce,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,be).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:U,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(me).replace(`hr`,ce).replace(`heading`,` *#{1,6} *[^
|
|
1
|
+
import{n as e,t}from"./rolldown-runtime-DF2fYuay.js";import{T as n,a as r,i,n as a}from"./query-DYNohPrB.js";import{B as o,V as s,at as c,m as l,r as u,rt as d,s as f,t as p}from"./cx-Dzb14TPi.js";import{t as m}from"./index-DON3wuuC.js";var h=e(n(),1);function g(e,t,n=`web`,r=10){return s(`/api/chat/recent?${new URLSearchParams({userId:t,channelId:n,limit:String(r)}).toString()}`,{token:e})}function _(e,t,n=80){return s(`/api/history?${new URLSearchParams({sessionId:t,limit:String(n)}).toString()}`,{token:e})}function v(e,t){return s(t?`/api/chat/commands?q=${encodeURIComponent(t)}`:`/api/chat/commands`,{token:e})}function y(e,t,n){return s(`/api/chat/branch`,{token:e,method:`POST`,body:{sessionId:t,beforeMessageId:n}})}function b(e,t,n,r){return s(`/api/command`,{token:e,method:`POST`,body:f({sessionId:t,args:r,userId:n,username:`web`})})}function x(e,t){return s(`/api/media/upload`,{token:e,method:`POST`,rawBody:t,extraHeaders:{"Content-Type":t.type||`application/octet-stream`,"X-Hybridclaw-Filename":encodeURIComponent(t.name||`upload`)}})}function S(e){return`/api/artifact?${new URLSearchParams({path:e}).toString()}`}async function C(e,t){let n=await fetch(S(t),{headers:o(e),cache:`no-store`});if(!n.ok){let e=(n.headers.get(`content-type`)||``).toLowerCase().trim(),t=`${n.status} ${n.statusText}`;if(e.includes(`application/json`)){let e=await n.json().catch(()=>null);t=e?.error||e?.text||t}else{let e=(await n.text().catch(()=>``)).trim();e&&(t=e)}throw n.status===401&&l(t),Error(t)}return n.blob()}var w=`main`;function T(e){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}function E(e=w){let t=e.trim().toLowerCase();return`agent:${encodeURIComponent(t)}:channel:web:chat:dm:peer:${T(8)}`}function D(){let e=`hybridclaw_user_id`,t=localStorage.getItem(e);if(t)return t;let n=`web-user-${T(4)}`;return localStorage.setItem(e,n),n}function O(){return localStorage.getItem(`hybridclaw_session`)??``}function k(e){localStorage.setItem(`hybridclaw_session`,e)}var A=0;function j(){return A+=1,`local-${A}-${Date.now()}`}function M(e){navigator.clipboard?.writeText(e).catch(()=>{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)})}function N(e){if(!e)return``;if(e.summary)return e.summary;let t=[];return e.intent&&t.push(`Approval needed for: ${e.intent}`),e.reason&&t.push(`Why: ${e.reason}`),t.push(`Approval ID: ${e.approvalId}`),t.join(`
|
|
2
|
+
`)}var P={once:`/approve once`,always:`/approve always`,session:`/approve session`,agent:`/approve agent`,all:`/approve all`,deny:`/approve no`};function F(e,t){let n=P[e];if(!n)return null;let r=t.trim();return r?`${n} ${r}`:n}function I(e){return(e.name??``).trim()||`clipboard${{"application/pdf":`.pdf`,"image/gif":`.gif`,"image/jpeg":`.jpg`,"image/png":`.png`,"image/webp":`.webp`,"text/plain":`.txt`}[(e.type??``).trim().toLowerCase()]??``}`}function L(e){let t=I(e);return e.name===t?e:new File([e],t,{type:e.type||`application/octet-stream`,lastModified:Number.isFinite(e.lastModified)?e.lastModified:Date.now()})}function R(e){if(!e)return[];let t=[];for(let n of Array.from(e.files))t.push(L(n));if(t.length>0)return t;let n=new Set;for(let r of Array.from(e.items)){if(r.kind!==`file`)continue;let e=r.getAsFile();if(!e)continue;let i=L(e),a=`${i.name}:${i.size}:${i.type}:${i.lastModified}`;n.has(a)||(n.add(a),t.push(i))}return t}function ee(e,t=64){return e?e.scrollHeight-e.scrollTop-e.clientHeight<=t:!0}var z={chatPage:`_chatPage_ezgbk_1`,sidebar:`_sidebar_ezgbk_9`,sidebarHeader:`_sidebarHeader_ezgbk_20`,sidebarLogo:`_sidebarLogo_ezgbk_27`,sidebarBrand:`_sidebarBrand_ezgbk_33`,newChatButton:`_newChatButton_ezgbk_40`,sidebarLabel:`_sidebarLabel_ezgbk_61`,sessionList:`_sessionList_ezgbk_71`,sessionItem:`_sessionItem_ezgbk_80`,sessionItemActive:`_sessionItemActive_ezgbk_102`,sessionTitle:`_sessionTitle_ezgbk_107`,sessionTime:`_sessionTime_ezgbk_116`,chatMain:`_chatMain_ezgbk_121`,messageArea:`_messageArea_ezgbk_129`,messageList:`_messageList_ezgbk_137`,emptyState:`_emptyState_ezgbk_146`,greeting:`_greeting_ezgbk_156`,messageBlock:`_messageBlock_ezgbk_165`,messageBlockUser:`_messageBlockUser_ezgbk_171`,messageBlockAssistant:`_messageBlockAssistant_ezgbk_175`,messageBlockSystem:`_messageBlockSystem_ezgbk_176`,agentLabel:`_agentLabel_ezgbk_180`,agentAvatar:`_agentAvatar_ezgbk_190`,agentInitial:`_agentInitial_ezgbk_197`,bubble:`_bubble_ezgbk_210`,bubbleUser:`_bubbleUser_ezgbk_220`,bubbleAssistant:`_bubbleAssistant_ezgbk_226`,bubbleSystem:`_bubbleSystem_ezgbk_234`,markdownContent:`_markdownContent_ezgbk_243`,messageActions:`_messageActions_ezgbk_354`,actionButton:`_actionButton_ezgbk_366`,actionButtonSuccess:`_actionButtonSuccess_ezgbk_388`,branchSwitcher:`_branchSwitcher_ezgbk_392`,branchButton:`_branchButton_ezgbk_401`,approvalActions:`_approvalActions_ezgbk_425`,approvalAllow:`_approvalAllow_ezgbk_432`,approvalDeny:`_approvalDeny_ezgbk_447`,artifactCard:`_artifactCard_ezgbk_468`,artifactFilename:`_artifactFilename_ezgbk_479`,artifactBadge:`_artifactBadge_ezgbk_488`,artifactDownload:`_artifactDownload_ezgbk_498`,artifactPreview:`_artifactPreview_ezgbk_520`,thinking:`_thinking_ezgbk_531`,thinkingDot:`_thinkingDot_ezgbk_538`,thinkingBounce:`_thinkingBounce_ezgbk_1`,composerWrapper:`_composerWrapper_ezgbk_567`,composer:`_composer_ezgbk_567`,pendingMediaRow:`_pendingMediaRow_ezgbk_585`,mediaChip:`_mediaChip_ezgbk_592`,mediaChipName:`_mediaChipName_ezgbk_604`,mediaChipRemove:`_mediaChipRemove_ezgbk_610`,composerRow:`_composerRow_ezgbk_629`,composerInput:`_composerInput_ezgbk_636`,attachButton:`_attachButton_ezgbk_654`,sendButton:`_sendButton_ezgbk_655`,stopping:`_stopping_ezgbk_692`,slashSuggestions:`_slashSuggestions_ezgbk_697`,suggestionItem:`_suggestionItem_ezgbk_712`,suggestionItemActive:`_suggestionItemActive_ezgbk_722`,suggestionLabel:`_suggestionLabel_ezgbk_726`,suggestionDesc:`_suggestionDesc_ezgbk_732`,errorBanner:`_errorBanner_ezgbk_737`,editArea:`_editArea_ezgbk_751`,editButtons:`_editButtons_ezgbk_766`,sidebarOpen:`_sidebarOpen_ezgbk_781`,slideIn:`_slideIn_ezgbk_1`,sidebarBackdrop:`_sidebarBackdrop_ezgbk_791`,mobileHeader:`_mobileHeader_ezgbk_801`},B=r();function te(e){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:z.sidebarHeader,children:[(0,B.jsx)(`img`,{className:z.sidebarLogo,src:`/static/hybridclaw-logo.svg`,alt:`HybridClaw`}),(0,B.jsx)(`span`,{className:z.sidebarBrand,children:`HybridClaw`})]}),(0,B.jsx)(`button`,{type:`button`,className:z.newChatButton,onClick:e.onNewChat,children:`+ New Conversation`}),e.sessions.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:z.sidebarLabel,children:`Recent`}),(0,B.jsx)(`ul`,{className:z.sessionList,"aria-live":`polite`,children:e.sessions.map(t=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,className:p(z.sessionItem,t.sessionId===e.activeSessionId&&z.sessionItemActive),"aria-current":t.sessionId===e.activeSessionId?`page`:void 0,onClick:()=>e.onOpenSession(t.sessionId),children:[(0,B.jsx)(`span`,{className:z.sessionTitle,children:t.title||`Untitled`}),(0,B.jsx)(`span`,{className:z.sessionTime,children:m(t.lastActive)})]})},t.sessionId))})]}):null]})}function ne(e){return e.items.length===0?null:(0,B.jsx)(`div`,{className:z.slashSuggestions,role:`listbox`,children:e.items.map((t,n)=>(0,B.jsxs)(`div`,{className:p(z.suggestionItem,n===e.activeIndex&&z.suggestionItemActive),role:`option`,tabIndex:-1,"aria-selected":n===e.activeIndex,onMouseDown:n=>{n.preventDefault(),e.onSelect(t)},children:[(0,B.jsx)(`span`,{className:z.suggestionLabel,children:t.label}),t.description?(0,B.jsx)(`span`,{className:z.suggestionDesc,children:t.description}):null]},t.id))})}function re(e){let t=(0,h.useRef)(null),n=(0,h.useRef)(null),[r,i]=(0,h.useState)([]),[a,o]=(0,h.useState)(0),[s,c]=(0,h.useState)([]),[l,u]=(0,h.useState)(0),[d,f]=(0,h.useState)(!1),m=(0,h.useRef)(null),g=(0,h.useRef)(0);(0,h.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]);let _=()=>{let e=t.current;e&&(e.style.height=`24px`,e.style.height=`${Math.min(e.scrollHeight,180)}px`)},y=(0,h.useCallback)(async t=>{g.current+=1;let n=g.current;try{let r=await v(e.token,t||void 0);if(n!==g.current)return;c(r.commands??[]),u(0),f((r.commands??[]).length>0)}catch{if(n!==g.current)return;c([]),f(!1)}},[e.token]),b=()=>{_();let e=t.current?.value??``;if(e.startsWith(`/`)){let t=e.slice(1).trim();m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{y(t)},150)}else f(!1)},x=e=>{t.current&&(t.current.value=`${e.insertText} `,f(!1),_(),t.current.focus())},S=()=>{if(e.isStreaming){e.onStop();return}let n=(t.current?.value??``).trim();!n&&r.length===0||a>0||(e.onSend(n,r),t.current&&(t.current.value=``),i([]),_())},C=e=>{if(d&&s.length>0){if(e.key===`ArrowDown`){e.preventDefault(),u(e=>(e+1)%s.length);return}if(e.key===`ArrowUp`){e.preventDefault(),u(e=>(e-1+s.length)%s.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),x(s[l]);return}if(e.key===`Escape`){e.preventDefault(),f(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),S())},w=e=>{let t=R(e.clipboardData);t.length>0&&(e.preventDefault(),T(t))},T=async t=>{o(e=>e+t.length);try{let n=await e.onUploadFiles(t);n.length>0&&i(e=>[...e,...n])}finally{o(e=>Math.max(0,e-t.length))}},E=e=>{let t=Array.from(e.target.files??[]);t.length>0&&T(t),e.target.value=``},D=e=>{i(t=>t.filter((t,n)=>n!==e))};return(0,B.jsx)(`div`,{className:z.composerWrapper,children:(0,B.jsxs)(`div`,{className:z.composer,style:{position:`relative`},children:[d?(0,B.jsx)(ne,{items:s,activeIndex:l,onSelect:x}):null,r.length>0||a>0?(0,B.jsxs)(`div`,{className:z.pendingMediaRow,children:[r.map((e,t)=>(0,B.jsxs)(`span`,{className:z.mediaChip,children:[(0,B.jsx)(`span`,{className:z.mediaChipName,children:e.filename}),(0,B.jsx)(`button`,{type:`button`,className:z.mediaChipRemove,onClick:()=>D(t),children:`×`})]},e.path)),a>0?(0,B.jsx)(`span`,{className:z.mediaChip,children:`Uploading…`}):null]}):null,(0,B.jsxs)(`div`,{className:z.composerRow,children:[(0,B.jsx)(`button`,{type:`button`,className:z.attachButton,onClick:()=>n.current?.click(),"aria-label":`Attach files`,children:`+`}),(0,B.jsx)(`textarea`,{ref:t,className:z.composerInput,rows:1,placeholder:`Message HybridClaw`,disabled:e.isStreaming,onInput:b,onKeyDown:C,onPaste:w,"aria-label":`Message input`}),(0,B.jsx)(`button`,{type:`button`,className:p(z.sendButton,e.isStreaming&&z.stopping),onClick:S,"aria-label":e.isStreaming?`Stop`:`Send message`,children:e.isStreaming?(0,B.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`currentColor`,"aria-hidden":`true`,children:(0,B.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})}):(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M12 19V5`}),(0,B.jsx)(`path`,{d:`m5 12 7-7 7 7`})]})}),(0,B.jsx)(`input`,{ref:n,type:`file`,hidden:!0,multiple:!0,onChange:E})]})]})})}function V(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var H=V();function ie(e){H=e}var U={exec:()=>null};function W(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(G.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ae=(()=>{try{return!0}catch{return!1}})(),G={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},K=/^(?:[ \t]*(?:\n|$))+/,oe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,se=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ce=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,le=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ue=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,de=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,fe=W(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),pe=W(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),me=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,he=/^[^\n]+/,ge=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,_e=W(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,ge).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ve=W(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ue).getRegex(),ye=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,be=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xe=W(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,be).replace(`tag`,ye).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se=W(me).replace(`hr`,ce).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ye).getRegex(),Ce={blockquote:W(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Se).getRegex(),code:oe,def:_e,fences:se,heading:le,hr:ce,html:xe,lheading:fe,list:ve,newline:K,paragraph:Se,table:U,text:he},we=W(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,ce).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ye).getRegex(),Te={...Ce,lheading:pe,table:we,paragraph:W(me).replace(`hr`,ce).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,we).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,ye).getRegex()},Ee={...Ce,html:W(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,be).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:U,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:W(me).replace(`hr`,ce).replace(`heading`,` *#{1,6} *[^
|
|
3
3
|
]`).replace(`lheading`,fe).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},De=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Oe=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ke=/^( {2,}|\\)\n(?!\s*$)/,Ae=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,je=/[\p{P}\p{S}]/u,Me=/[\s\p{P}\p{S}]/u,Ne=/[^\s\p{P}\p{S}]/u,Pe=W(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Me).getRegex(),Fe=/(?!~)[\p{P}\p{S}]/u,Ie=/(?!~)[\s\p{P}\p{S}]/u,Le=/(?:[^\s\p{P}\p{S}]|~)/u,Re=/(?![*_])[\p{P}\p{S}]/u,ze=/(?![*_])[\s\p{P}\p{S}]/u,Be=/(?:[^\s\p{P}\p{S}]|[*_])/u,Ve=W(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,ae?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),He=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ue=W(He,`u`).replace(/punct/g,je).getRegex(),We=W(He,`u`).replace(/punct/g,Fe).getRegex(),Ge=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Ke=W(Ge,`gu`).replace(/notPunctSpace/g,Ne).replace(/punctSpace/g,Me).replace(/punct/g,je).getRegex(),qe=W(Ge,`gu`).replace(/notPunctSpace/g,Le).replace(/punctSpace/g,Ie).replace(/punct/g,Fe).getRegex(),Je=W(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Ne).replace(/punctSpace/g,Me).replace(/punct/g,je).getRegex(),Ye=W(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Re).getRegex(),Xe=W(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Be).replace(/punctSpace/g,ze).replace(/punct/g,Re).getRegex(),Ze=W(/\\(punct)/,`gu`).replace(/punct/g,je).getRegex(),Qe=W(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),$e=W(be).replace(`(?:-->|$)`,`-->`).getRegex(),et=W(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,$e).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),tt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,nt=W(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,tt).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),rt=W(/^!?\[(label)\]\[(ref)\]/).replace(`label`,tt).replace(`ref`,ge).getRegex(),it=W(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,ge).getRegex(),at=W(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,rt).replace(`nolink`,it).getRegex(),ot=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,st={_backpedal:U,anyPunctuation:Ze,autolink:Qe,blockSkip:Ve,br:ke,code:Oe,del:U,delLDelim:U,delRDelim:U,emStrongLDelim:Ue,emStrongRDelimAst:Ke,emStrongRDelimUnd:Je,escape:De,link:nt,nolink:it,punctuation:Pe,reflink:rt,reflinkSearch:at,tag:et,text:Ae,url:U},ct={...st,link:W(/^!?\[(label)\]\((.*?)\)/).replace(`label`,tt).getRegex(),reflink:W(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,tt).getRegex()},lt={...st,emStrongRDelimAst:qe,emStrongLDelim:We,delLDelim:Ye,delRDelim:Xe,url:W(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,ot).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:W(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,ot).getRegex()},ut={...lt,br:W(ke).replace(`{2,}`,`*`).getRegex(),text:W(lt.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},dt={normal:Ce,gfm:Te,pedantic:Ee},ft={normal:st,gfm:lt,breaks:ut,pedantic:ct},pt={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},mt=e=>pt[e];function q(e,t){if(t){if(G.escapeTest.test(e))return e.replace(G.escapeReplace,mt)}else if(G.escapeTestNoEncode.test(e))return e.replace(G.escapeReplaceNoEncode,mt);return e}function ht(e){try{e=encodeURI(e).replace(G.percentDecode,`%`)}catch{return null}return e}function gt(e,t){let n=e.replace(G.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(G.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(G.slashPipe,`|`);return n}function _t(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function vt(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function yt(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function bt(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function xt(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
4
4
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
5
5
|
`)}var St=class{options;rules;lexer;constructor(e){this.options=e||H}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:_t(e,`
|
|
@@ -87,7 +87,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
87
87
|
`;)e--;this.css=this.css.slice(0,e)+this.css.slice(t+2)}}}}generate(){if(this.clearAnnotation(),d&&u&&this.isMap())return this.generateMap();{let e=``;return this.stringify(this.root,t=>{e+=t}),[e]}}generateMap(){if(this.root)this.generateString();else if(this.previous().length===1){let e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=s.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new s({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):`<no source>`});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]}generateString(){this.css=``,this.map=new s({file:this.outputFile(),ignoreInvalidMapping:!0});let e=1,t=1,n=`<no source>`,r={generated:{column:0,line:0},original:{column:0,line:0},source:``},i,a;this.stringify(this.root,(o,s,c)=>{if(this.css+=o,s&&c!==`end`&&(r.generated.line=e,r.generated.column=t-1,s.source&&s.source.start?(r.source=this.sourcePath(s),r.original.line=s.source.start.line,r.original.column=s.source.start.column-1,this.map.addMapping(r)):(r.source=n,r.original.line=1,r.original.column=0,this.map.addMapping(r))),a=o.match(/\n/g),a?(e+=a.length,i=o.lastIndexOf(`
|
|
88
88
|
`),t=o.length-i):t+=o.length,s&&c!==`start`){let i=s.parent||{raws:{}};(!(s.type===`decl`||s.type===`atrule`&&!s.nodes)||s!==i.last||i.raws.semicolon)&&(s.source&&s.source.end?(r.source=this.sourcePath(s),r.original.line=s.source.end.line,r.original.column=s.source.end.column-1,r.generated.line=e,r.generated.column=t-2,this.map.addMapping(r)):(r.source=n,r.original.line=1,r.original.column=0,r.generated.line=e,r.generated.column=t-1,this.map.addMapping(r)))}})}isAnnotation(){return this.isInline()?!0:this.mapOpts.annotation===void 0?this.previous().length?this.previous().some(e=>e.annotation):!0:this.mapOpts.annotation}isInline(){if(this.mapOpts.inline!==void 0)return this.mapOpts.inline;let e=this.mapOpts.annotation;return e!==void 0&&e!==!0?!1:this.previous().length?this.previous().some(e=>e.inline):!0}isMap(){return this.opts.map===void 0?this.previous().length>0:!!this.opts.map}isSourcesContent(){return this.mapOpts.sourcesContent===void 0?this.previous().length?this.previous().some(e=>e.withContent()):!0:this.mapOpts.sourcesContent}outputFile(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):`to.css`}path(e){if(this.mapOpts.absolute||e.charCodeAt(0)===60||/^\w+:\/\//.test(e))return e;let t=this.memoizedPaths.get(e);if(t)return t;let a=this.opts.to?n(this.opts.to):`.`;typeof this.mapOpts.annotation==`string`&&(a=n(i(a,this.mapOpts.annotation)));let o=r(a,e);return this.memoizedPaths.set(e,o),o}previous(){if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(e=>{if(e.source&&e.source.input.map){let t=e.source.input.map;this.previousMaps.includes(t)||this.previousMaps.push(t)}});else{let e=new l(this.originalCSS,this.opts);e.map&&this.previousMaps.push(e.map)}return this.previousMaps}setSourcesContent(){let e={};if(this.root)this.root.walk(t=>{if(t.source){let n=t.source.input.from;if(n&&!e[n]){e[n]=!0;let r=this.usesFileUrls?this.toFileUrl(n):this.toUrl(this.path(n));this.map.setSourceContent(r,t.source.input.css)}}});else if(this.css){let e=this.opts.from?this.toUrl(this.path(this.opts.from)):`<no source>`;this.map.setSourceContent(e,this.css)}}sourcePath(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))}toBase64(e){return Buffer?Buffer.from(e).toString(`base64`):window.btoa(unescape(encodeURIComponent(e)))}toFileUrl(e){let t=this.memoizedFileURLs.get(e);if(t)return t;if(c){let t=c(e).toString();return this.memoizedFileURLs.set(e,t),t}else throw Error("`map.absolute` option is not available in this PostCSS build")}toUrl(e){let t=this.memoizedURLs.get(e);if(t)return t;a===`\\`&&(e=e.replace(/\\/g,`/`));let n=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,n),n}}})),Cn=t(((e,t)=>{var n=39,r=34,i=92,a=47,o=10,s=32,c=12,l=9,u=13,d=91,f=93,p=40,m=41,h=123,g=125,_=59,v=42,y=58,b=64,x=/[\t\n\f\r "#'()/;[\\\]{}]/g,S=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,C=/.[\r\n"'(/\\]/,w=/[\da-f]/i;t.exports=function(e,t={}){let T=e.css.valueOf(),E=t.ignoreErrors,D,O,k,A,j,M,N,P,F,I,L=T.length,R=0,ee=[],z=[];function B(){return R}function te(t){throw e.error(`Unclosed `+t,R)}function ne(){return z.length===0&&R>=L}function re(e){if(z.length)return z.pop();if(R>=L)return;let t=e?e.ignoreUnclosed:!1;switch(D=T.charCodeAt(R),D){case o:case s:case l:case u:case c:A=R;do A+=1,D=T.charCodeAt(A);while(D===s||D===o||D===l||D===u||D===c);M=[`space`,T.slice(R,A)],R=A-1;break;case d:case f:case h:case g:case y:case _:case m:{let e=String.fromCharCode(D);M=[e,e,R];break}case p:if(I=ee.length?ee.pop()[1]:``,F=T.charCodeAt(R+1),I===`url`&&F!==n&&F!==r&&F!==s&&F!==o&&F!==l&&F!==c&&F!==u){A=R;do{if(N=!1,A=T.indexOf(`)`,A+1),A===-1)if(E||t){A=R;break}else te(`bracket`);for(P=A;T.charCodeAt(P-1)===i;)--P,N=!N}while(N);M=[`brackets`,T.slice(R,A+1),R,A],R=A}else A=T.indexOf(`)`,R+1),O=T.slice(R,A+1),A===-1||C.test(O)?M=[`(`,`(`,R]:(M=[`brackets`,O,R,A],R=A);break;case n:case r:j=D===n?`'`:`"`,A=R;do{if(N=!1,A=T.indexOf(j,A+1),A===-1)if(E||t){A=R+1;break}else te(`string`);for(P=A;T.charCodeAt(P-1)===i;)--P,N=!N}while(N);M=[`string`,T.slice(R,A+1),R,A],R=A;break;case b:x.lastIndex=R+1,x.test(T),A=x.lastIndex===0?T.length-1:x.lastIndex-2,M=[`at-word`,T.slice(R,A+1),R,A],R=A;break;case i:for(A=R,k=!0;T.charCodeAt(A+1)===i;)A+=1,k=!k;if(D=T.charCodeAt(A+1),k&&D!==a&&D!==s&&D!==o&&D!==l&&D!==u&&D!==c&&(A+=1,w.test(T.charAt(A)))){for(;w.test(T.charAt(A+1));)A+=1;T.charCodeAt(A+1)===s&&(A+=1)}M=[`word`,T.slice(R,A+1),R,A],R=A;break;default:D===a&&T.charCodeAt(R+1)===v?(A=T.indexOf(`*/`,R+2)+1,A===0&&(E||t?A=T.length:te(`comment`)),M=[`comment`,T.slice(R,A+1),R,A],R=A):(S.lastIndex=R+1,S.test(T),A=S.lastIndex===0?T.length-1:S.lastIndex-2,M=[`word`,T.slice(R,A+1),R,A],ee.push(M),R=A);break}return R++,M}function V(e){z.push(e)}return{back:V,endOfFile:ne,nextToken:re,position:B}}})),wn=t(((e,t)=>{var n=pn(),r=un(),i=dn(),a=vn(),o=bn(),s=Cn(),c={empty:!0,space:!0};function l(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}t.exports=class{constructor(e){this.input=e,this.root=new a,this.current=this.root,this.spaces=``,this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t=new n;t.name=e[1].slice(1),t.name===``&&this.unnamedAtrule(t,e),this.init(t,e[2]);let r,i,a,o=!1,s=!1,c=[],l=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),r=e[0],r===`(`||r===`[`?l.push(r===`(`?`)`:`]`):r===`{`&&l.length>0?l.push(`}`):r===l[l.length-1]&&l.pop(),l.length===0)if(r===`;`){t.source.end=this.getPosition(e[2]),t.source.end.offset++,this.semicolon=!0;break}else if(r===`{`){s=!0;break}else if(r===`}`){if(c.length>0){for(a=c.length-1,i=c[a];i&&i[0]===`space`;)i=c[--a];i&&(t.source.end=this.getPosition(i[3]||i[2]),t.source.end.offset++)}this.end(e);break}else c.push(e);else c.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}t.raws.between=this.spacesAndCommentsFromEnd(c),c.length?(t.raws.afterName=this.spacesAndCommentsFromStart(c),this.raw(t,`params`,c),o&&(e=c[c.length-1],t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++,this.spaces=t.raws.between,t.raws.between=``)):(t.raws.afterName=``,t.params=``),s&&(t.nodes=[],this.current=t)}checkMissedSemicolon(e){let t=this.colon(e);if(t===!1)return;let n=0,r;for(let i=t-1;i>=0&&(r=e[i],!(r[0]!==`space`&&(n+=1,n===2)));i--);throw this.input.error(`Missed semicolon`,r[0]===`word`?r[3]+1:r[2])}colon(e){let t=0,n,r,i;for(let[a,o]of e.entries()){if(r=o,i=r[0],i===`(`&&(t+=1),i===`)`&&--t,t===0&&i===`:`)if(!n)this.doubleColon(r);else if(n[0]===`word`&&n[1]===`progid`)continue;else return a;n=r}return!1}comment(e){let t=new r;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(!n.trim())t.text=``,t.raws.left=n,t.raws.right=``;else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=s(this.input)}decl(e,t){let n=new i;this.init(n,e[0][2]);let r=e[e.length-1];for(r[0]===`;`&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(r[3]||r[2]||l(e)),n.source.end.offset++;e[0][0]!==`word`;)e.length===1&&this.unknownWord(e),n.raws.before+=e.shift()[1];for(n.source.start=this.getPosition(e[0][2]),n.prop=``;e.length;){let t=e[0][0];if(t===`:`||t===`space`||t===`comment`)break;n.prop+=e.shift()[1]}n.raws.between=``;let a;for(;e.length;)if(a=e.shift(),a[0]===`:`){n.raws.between+=a[1];break}else a[0]===`word`&&/\w/.test(a[1])&&this.unknownWord([a]),n.raws.between+=a[1];(n.prop[0]===`_`||n.prop[0]===`*`)&&(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let o=[],s;for(;e.length&&(s=e[0][0],!(s!==`space`&&s!==`comment`));)o.push(e.shift());this.precheckMissedSemicolon(e);for(let t=e.length-1;t>=0;t--){if(a=e[t],a[1].toLowerCase()===`!important`){n.important=!0;let r=this.stringFrom(e,t);r=this.spacesFromEnd(e)+r,r!==` !important`&&(n.raws.important=r);break}else if(a[1].toLowerCase()===`important`){let r=e.slice(0),i=``;for(let e=t;e>0;e--){let t=r[e][0];if(i.trim().startsWith(`!`)&&t!==`space`)break;i=r.pop()[1]+i}i.trim().startsWith(`!`)&&(n.important=!0,n.raws.important=i,e=r)}if(a[0]!==`space`&&a[0]!==`comment`)break}e.some(e=>e[0]!==`space`&&e[0]!==`comment`)&&(n.raws.between+=o.map(e=>e[1]).join(``),o=[]),this.raw(n,`value`,o.concat(e),t),n.value.includes(`:`)&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error(`Double colon`,{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new o;this.init(t,e[2]),t.selector=``,t.raws.between=``,this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.spaces=``,this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let t=this.current.nodes[this.current.nodes.length-1];t&&t.type===`rule`&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces=``,t.source.end=this.getPosition(e[2]),t.source.end.offset+=t.raws.ownSemicolon.length)}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces=``,e.type!==`comment`&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,a=[],o=e[1].startsWith(`--`),s=[],c=e;for(;c;){if(n=c[0],s.push(c),n===`(`||n===`[`)i||=c,a.push(n===`(`?`)`:`]`);else if(o&&r&&n===`{`)i||=c,a.push(`}`);else if(a.length===0)if(n===`;`)if(r){this.decl(s,o);return}else break;else if(n===`{`){this.rule(s);return}else if(n===`}`){this.tokenizer.back(s.pop()),t=!0;break}else n===`:`&&(r=!0);else n===a[a.length-1]&&(a.pop(),a.length===0&&(i=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),a.length>0&&this.unclosedBracket(i),t&&r){if(!o)for(;s.length&&(c=s[s.length-1][0],!(c!==`space`&&c!==`comment`));)this.tokenizer.back(s.pop());this.decl(s,o)}else this.unknownWord(s)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case`space`:this.spaces+=e[1];break;case`;`:this.freeSemicolon(e);break;case`}`:this.end(e);break;case`comment`:this.comment(e);break;case`at-word`:this.atrule(e);break;case`{`:this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,a,o=n.length,s=``,l=!0,u,d;for(let e=0;e<o;e+=1)i=n[e],a=i[0],a===`space`&&e===o-1&&!r?l=!1:a===`comment`?(d=n[e-1]?n[e-1][0]:`empty`,u=n[e+1]?n[e+1][0]:`empty`,!c[d]&&!c[u]?s.slice(-1)===`,`?l=!1:s+=i[1]:l=!1):s+=i[1];if(!l){let r=n.reduce((e,t)=>e+t[1],``);e.raws[t]={raw:r,value:s}}e[t]=s}rule(e){e.pop();let t=new o;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,`selector`,e),this.current=t}spacesAndCommentsFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],!(t!==`space`&&t!==`comment`));)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n=``;for(;e.length&&(t=e[0][0],!(t!==`space`&&t!==`comment`));)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],t===`space`);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n=``;for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error(`Unclosed block`,e.line,e.column)}unclosedBracket(e){throw this.input.error(`Unclosed bracket`,{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error(`Unexpected }`,{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error(`Unknown word `+e[0][1],{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error(`At-rule without name`,{offset:t[2]},{offset:t[2]+t[1].length})}}})),Tn=t(((e,t)=>{var n=fn(),r=_n(),i=wn();function a(e,t){let n=new i(new r(e,t));try{n.parse()}catch(e){throw e}return n.root}t.exports=a,a.default=a,n.registerParse(a)})),En=t(((e,t)=>{var n=class{constructor(e,t={}){if(this.type=`warning`,this.text=e,t.node&&t.node.source){let e=t.node.rangeBy(t);this.line=e.start.line,this.column=e.start.column,this.endLine=e.end.line,this.endColumn=e.end.column}for(let e in t)this[e]=t[e]}toString(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+`: `+this.text:this.text}};t.exports=n,n.default=n})),Dn=t(((e,t)=>{var n=En(),r=class{get content(){return this.css}constructor(e,t,n){this.processor=e,this.messages=[],this.root=t,this.opts=n,this.css=``,this.map=void 0}toString(){return this.css}warn(e,t={}){t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);let r=new n(e,t);return this.messages.push(r),r}warnings(){return this.messages.filter(e=>e.type===`warning`)}};t.exports=r,r.default=r})),On=t(((e,t)=>{var n={};t.exports=function(e){n[e]||(n[e]=!0,typeof console<`u`&&console.warn&&console.warn(e))}})),kn=t(((e,t)=>{var n=fn(),r=mn(),i=Sn(),a=Tn(),o=Dn(),s=vn(),c=sn(),{isClean:l,my:u}=cn();On();var d={atrule:`AtRule`,comment:`Comment`,decl:`Declaration`,document:`Document`,root:`Root`,rule:`Rule`},f={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},p={Once:!0,postcssPlugin:!0,prepare:!0},m=0;function h(e){return typeof e==`object`&&typeof e.then==`function`}function g(e){let t=!1,n=d[e.type];return e.type===`decl`?t=e.prop.toLowerCase():e.type===`atrule`&&(t=e.name.toLowerCase()),t&&e.append?[n,n+`-`+t,m,n+`Exit`,n+`Exit-`+t]:t?[n,n+`-`+t,n+`Exit`,n+`Exit-`+t]:e.append?[n,m,n+`Exit`]:[n,n+`Exit`]}function _(e){let t;return t=e.type===`document`?[`Document`,m,`DocumentExit`]:e.type===`root`?[`Root`,m,`RootExit`]:g(e),{eventIndex:0,events:t,iterator:0,node:e,visitorIndex:0,visitors:[]}}function v(e){return e[l]=!1,e.nodes&&e.nodes.forEach(e=>v(e)),e}var y={},b=class e{get content(){return this.stringify().content}get css(){return this.stringify().css}get map(){return this.stringify().map}get messages(){return this.sync().messages}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){return this.sync().root}get[Symbol.toStringTag](){return`LazyResult`}constructor(t,r,i){this.stringified=!1,this.processed=!1;let s;if(typeof r==`object`&&r&&(r.type===`root`||r.type===`document`))s=v(r);else if(r instanceof e||r instanceof o)s=v(r.root),r.map&&(i.map===void 0&&(i.map={}),i.map.inline||(i.map.inline=!1),i.map.prev=r.map);else{let e=a;i.syntax&&(e=i.syntax.parse),i.parser&&(e=i.parser),e.parse&&(e=e.parse);try{s=e(r,i)}catch(e){this.processed=!0,this.error=e}s&&!s[u]&&n.rebuild(s)}this.result=new o(t,s,i),this.helpers={...y,postcss:y,result:this.result},this.plugins=this.processor.plugins.map(e=>typeof e==`object`&&e.prepare?{...e,...e.prepare(this.result)}:e)}async(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||=this.runAsync(),this.processing)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}getAsyncError(){throw Error(`Use process(css).then(cb) to work with async plugins`)}handleError(e,t){let n=this.result.lastPlugin;try{t&&t.addToError(e),this.error=e,e.name===`CssSyntaxError`&&!e.plugin?(e.plugin=n.postcssPlugin,e.setMessage()):n.postcssVersion}catch(e){console&&console.error&&console.error(e)}return e}prepareVisitors(){this.listeners={};let e=(e,t,n)=>{this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push([e,n])};for(let t of this.plugins)if(typeof t==`object`)for(let n in t){if(!f[n]&&/^[A-Z]/.test(n))throw Error(`Unknown event ${n} in ${t.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`);if(!p[n])if(typeof t[n]==`object`)for(let r in t[n])r===`*`?e(t,n,t[n][r]):e(t,n+`-`+r.toLowerCase(),t[n][r]);else typeof t[n]==`function`&&e(t,n,t[n])}this.hasListener=Object.keys(this.listeners).length>0}async runAsync(){this.plugin=0;for(let e=0;e<this.plugins.length;e++){let t=this.plugins[e],n=this.runOnRoot(t);if(h(n))try{await n}catch(e){throw this.handleError(e)}}if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[l];){e[l]=!0;let t=[_(e)];for(;t.length>0;){let e=this.visitTick(t);if(h(e))try{await e}catch(e){let n=t[t.length-1].node;throw this.handleError(e,n)}}}if(this.listeners.OnceExit)for(let[t,n]of this.listeners.OnceExit){this.result.lastPlugin=t;try{if(e.type===`document`){let t=e.nodes.map(e=>n(e,this.helpers));await Promise.all(t)}else await n(e,this.helpers)}catch(e){throw this.handleError(e)}}}return this.processed=!0,this.stringify()}runOnRoot(e){this.result.lastPlugin=e;try{if(typeof e==`object`&&e.Once){if(this.result.root.type===`document`){let t=this.result.root.nodes.map(t=>e.Once(t,this.helpers));return h(t[0])?Promise.all(t):t}return e.Once(this.result.root,this.helpers)}else if(typeof e==`function`)return e(this.result.root,this.result)}catch(e){throw this.handleError(e)}}stringify(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();let e=this.result.opts,t=c;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);let n=new i(t,this.result.root,this.result.opts).generate();return this.result.css=n[0],this.result.map=n[1],this.result}sync(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(let e of this.plugins)if(h(this.runOnRoot(e)))throw this.getAsyncError();if(this.prepareVisitors(),this.hasListener){let e=this.result.root;for(;!e[l];)e[l]=!0,this.walkSync(e);if(this.listeners.OnceExit)if(e.type===`document`)for(let t of e.nodes)this.visitSync(this.listeners.OnceExit,t);else this.visitSync(this.listeners.OnceExit,e)}return this.result}then(e,t){return this.async().then(e,t)}toString(){return this.css}visitSync(e,t){for(let[n,r]of e){this.result.lastPlugin=n;let e;try{e=r(t,this.helpers)}catch(e){throw this.handleError(e,t.proxyOf)}if(t.type!==`root`&&t.type!==`document`&&!t.parent)return!0;if(h(e))throw this.getAsyncError()}}visitTick(e){let t=e[e.length-1],{node:n,visitors:r}=t;if(n.type!==`root`&&n.type!==`document`&&!n.parent){e.pop();return}if(r.length>0&&t.visitorIndex<r.length){let[e,i]=r[t.visitorIndex];t.visitorIndex+=1,t.visitorIndex===r.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=e;try{return i(n.toProxy(),this.helpers)}catch(e){throw this.handleError(e,n)}}if(t.iterator!==0){let r=t.iterator,i;for(;i=n.nodes[n.indexes[r]];)if(n.indexes[r]+=1,!i[l]){i[l]=!0,e.push(_(i));return}t.iterator=0,delete n.indexes[r]}let i=t.events;for(;t.eventIndex<i.length;){let e=i[t.eventIndex];if(t.eventIndex+=1,e===m){n.nodes&&n.nodes.length&&(n[l]=!0,t.iterator=n.getIterator());return}else if(this.listeners[e]){t.visitors=this.listeners[e];return}}e.pop()}walkSync(e){e[l]=!0;let t=g(e);for(let n of t)if(n===m)e.nodes&&e.each(e=>{e[l]||this.walkSync(e)});else{let t=this.listeners[n];if(t&&this.visitSync(t,e.toProxy()))return}}warnings(){return this.sync().warnings()}};b.registerPostcss=e=>{y=e},t.exports=b,b.default=b,s.registerLazyResult(b),r.registerLazyResult(b)})),An=t(((e,t)=>{var n=Sn(),r=Tn(),i=Dn(),a=sn();On();var o=class{get content(){return this.result.css}get css(){return this.result.css}get map(){return this.result.map}get messages(){return[]}get opts(){return this.result.opts}get processor(){return this.result.processor}get root(){if(this._root)return this._root;let e,t=r;try{e=t(this._css,this._opts)}catch(e){this.error=e}if(this.error)throw this.error;return this._root=e,e}get[Symbol.toStringTag](){return`NoWorkResult`}constructor(e,t,r){t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=r,this._map=void 0;let o=a;this.result=new i(this._processor,void 0,this._opts),this.result.css=t;let s=this;Object.defineProperty(this.result,`root`,{get(){return s.root}});let c=new n(o,void 0,this._opts,t);if(c.isMap()){let[e,t]=c.generate();e&&(this.result.css=e),t&&(this.result.map=t)}else c.clearAnnotation(),this.result.css=c.css}async(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)}catch(e){return this.async().catch(e)}finally(e){return this.async().then(e,e)}sync(){if(this.error)throw this.error;return this.result}then(e,t){return this.async().then(e,t)}toString(){return this._css}warnings(){return[]}};t.exports=o,o.default=o})),jn=t(((e,t)=>{var n=mn(),r=kn(),i=An(),a=vn(),o=class{constructor(e=[]){this.version=`8.5.8`,this.plugins=this.normalize(e)}normalize(e){let t=[];for(let n of e)if(n.postcss===!0?n=n():n.postcss&&(n=n.postcss),typeof n==`object`&&Array.isArray(n.plugins))t=t.concat(n.plugins);else if(typeof n==`object`&&n.postcssPlugin)t.push(n);else if(typeof n==`function`)t.push(n);else if(!(typeof n==`object`&&(n.parse||n.stringify)))throw Error(n+` is not a PostCSS plugin`);return t}process(e,t={}){return!this.plugins.length&&!t.parser&&!t.stringifier&&!t.syntax?new i(this,e,t):new r(this,e,t)}use(e){return this.plugins=this.plugins.concat(this.normalize([e])),this}};t.exports=o,o.default=o,a.registerProcessor(o),n.registerProcessor(o)})),Mn=t(((e,t)=>{var n=pn(),r=un(),i=fn(),a=an(),o=dn(),s=mn(),c=xn(),l=_n(),u=kn(),d=yn(),f=ln(),p=Tn(),m=jn(),h=Dn(),g=vn(),_=bn(),v=sn(),y=En();function b(...e){return e.length===1&&Array.isArray(e[0])&&(e=e[0]),new m(e)}b.plugin=function(e,t){let n=!1;function r(...r){console&&console.warn&&!n&&(n=!0,console.warn(e+`: postcss.plugin was deprecated. Migration guide:
|
|
89
89
|
https://evilmartians.com/chronicles/postcss-8-plugin-migration`),{}.LANG&&{}.LANG.startsWith(`cn`)&&console.warn(e+`: 里面 postcss.plugin 被弃用. 迁移指南:
|
|
90
|
-
https://www.w3ctech.com/topic/2226`));let i=t(...r);return i.postcssPlugin=e,i.postcssVersion=new m().version,i}let i;return Object.defineProperty(r,`postcss`,{get(){return i||=r(),i}}),r.process=function(e,t,n){return b([r(n)]).process(e,t)},r},b.stringify=v,b.parse=p,b.fromJSON=c,b.list=d,b.comment=e=>new r(e),b.atRule=e=>new n(e),b.decl=e=>new o(e),b.rule=e=>new _(e),b.root=e=>new g(e),b.document=e=>new s(e),b.CssSyntaxError=a,b.Declaration=o,b.Container=i,b.Processor=m,b.Document=s,b.Comment=r,b.Warning=y,b.AtRule=n,b.Result=h,b.Input=l,b.Rule=_,b.Root=g,b.Node=f,u.registerPostcss(b),t.exports=b,b.default=b})),Nn=e(t(((e,t)=>{var n=Qt(),r=$t(),{isPlainObject:i}=en(),a=tn(),o=nn(),{parse:s}=Mn(),c=[`img`,`audio`,`video`,`picture`,`svg`,`object`,`map`,`iframe`,`embed`],l=[`script`,`style`];function u(e,t){e&&Object.keys(e).forEach(function(n){t(e[n],n)})}function d(e,t){return{}.hasOwnProperty.call(e,t)}function f(e,t){let n=[];return u(e,function(e){t(e)&&n.push(e)}),n}function p(e){for(let t in e)if(d(e,t))return!1;return!0}function m(e){return e.map(function(e){if(!e.url)throw Error(`URL missing`);return e.url+(e.w?` ${e.w}w`:``)+(e.h?` ${e.h}h`:``)+(e.d?` ${e.d}x`:``)}).join(`, `)}t.exports=g;var h=/^[^\0\t\n\f\r /<=>]+$/;function g(e,t,v){if(e==null)return``;typeof e==`number`&&(e=e.toString());let y=``,b=``;function x(e,t){let n=this;this.tag=e,this.attribs=t||{},this.tagPosition=y.length,this.text=``,this.openingTagLength=0,this.mediaChildren=[],this.updateParentNodeText=function(){if(M.length){let e=M[M.length-1];e.text+=n.text}},this.updateParentNodeMediaChildren=function(){M.length&&c.includes(this.tag)&&M[M.length-1].mediaChildren.push(this.tag)}}t=Object.assign({},g.defaults,t),t.parser=Object.assign({},_,t.parser);let S=function(e){return t.allowedTags===!1||(t.allowedTags||[]).indexOf(e)>-1};l.forEach(function(e){S(e)&&!t.allowVulnerableTags&&console.warn(`\n\n⚠️ Your \`allowedTags\` option includes, \`${e}\`, which is inherently\nvulnerable to XSS attacks. Please remove it from \`allowedTags\`.\nOr, to disable this warning, add the \`allowVulnerableTags\` option\nand ensure you are accounting for this risk.\n\n`)});let C=t.nonTextTags||[`script`,`style`,`textarea`,`option`],w,T;t.allowedAttributes&&(w={},T={},u(t.allowedAttributes,function(e,t){w[t]=[];let n=[];e.forEach(function(e){typeof e==`string`&&e.indexOf(`*`)>=0?n.push(r(e).replace(/\\\*/g,`.*`)):w[t].push(e)}),n.length&&(T[t]=RegExp(`^(`+n.join(`|`)+`)$`))}));let E={},D={},O={};u(t.allowedClasses,function(e,t){if(w&&(d(w,t)||(w[t]=[]),w[t].push(`class`)),E[t]=e,Array.isArray(e)){let n=[];E[t]=[],O[t]=[],e.forEach(function(e){typeof e==`string`&&e.indexOf(`*`)>=0?n.push(r(e).replace(/\\\*/g,`.*`)):e instanceof RegExp?O[t].push(e):E[t].push(e)}),n.length&&(D[t]=RegExp(`^(`+n.join(`|`)+`)$`))}});let k={},A;u(t.transformTags,function(e,t){let n;typeof e==`function`?n=e:typeof e==`string`&&(n=g.simpleTransform(e)),t===`*`?A=n:k[t]=n});let j,M,N,P,F,I,L=!1;ee();let R=new n.Parser({onopentag:function(e,n){if(t.onOpenTag&&t.onOpenTag(e,n),t.enforceHtmlBoundary&&e===`html`&&ee(),F){I++;return}let r=new x(e,n);M.push(r);let c=!1,l=!!r.text,g;if(d(k,e)&&(g=k[e](e,n),r.attribs=n=g.attribs,g.text!==void 0&&(r.innerText=g.text),e!==g.tagName&&(r.name=e=g.tagName,P[j]=g.tagName)),A&&(g=A(e,n),r.attribs=n=g.attribs,e!==g.tagName&&(r.name=e=g.tagName,P[j]=g.tagName)),(!S(e)||t.disallowedTagsMode===`recursiveEscape`&&!p(N)||t.nestingLimit!=null&&j>=t.nestingLimit)&&(c=!0,N[j]=!0,(t.disallowedTagsMode===`discard`||t.disallowedTagsMode===`completelyDiscard`)&&C.indexOf(e)!==-1&&(F=!0,I=1)),j++,c){if(t.disallowedTagsMode===`discard`||t.disallowedTagsMode===`completelyDiscard`){if(r.innerText&&!l){let n=z(r.innerText);t.textFilter?y+=t.textFilter(n,e):y+=n,L=!0}return}b=y,y=``}y+=`<`+e,e===`script`&&(t.allowedScriptHostnames||t.allowedScriptDomains)&&(r.innerText=``),c&&(t.disallowedTagsMode===`escape`||t.disallowedTagsMode===`recursiveEscape`)&&t.preserveEscapedAttributes?u(n,function(e,t){y+=` `+t+`="`+z(e||``,!0)+`"`}):(!w||d(w,e)||w[`*`])&&u(n,function(n,c){if(!h.test(c)){delete r.attribs[c];return}if(n===``&&!t.allowedEmptyAttributes.includes(c)&&(t.nonBooleanAttributes.includes(c)||t.nonBooleanAttributes.includes(`*`))){delete r.attribs[c];return}let l=!1;if(!w||d(w,e)&&w[e].indexOf(c)!==-1||w[`*`]&&w[`*`].indexOf(c)!==-1||d(T,e)&&T[e].test(c)||T[`*`]&&T[`*`].test(c))l=!0;else if(w&&w[e]){for(let t of w[e])if(i(t)&&t.name&&t.name===c){l=!0;let e=``;if(t.multiple===!0){let r=n.split(` `);for(let n of r)t.values.indexOf(n)!==-1&&(e===``?e=n:e+=` `+n)}else t.values.indexOf(n)>=0&&(e=n);n=e}}if(l){if(t.allowedSchemesAppliedToAttributes.indexOf(c)!==-1&&B(e,n)){delete r.attribs[c];return}if(e===`script`&&c===`src`){let e=!0;try{let r=te(n);if(t.allowedScriptHostnames||t.allowedScriptDomains){let n=(t.allowedScriptHostnames||[]).find(function(e){return e===r.url.hostname}),i=(t.allowedScriptDomains||[]).find(function(e){return r.url.hostname===e||r.url.hostname.endsWith(`.${e}`)});e=n||i}}catch{e=!1}if(!e){delete r.attribs[c];return}}if(e===`iframe`&&c===`src`){let e=!0;try{let r=te(n);if(r.isRelativeUrl)e=d(t,`allowIframeRelativeUrls`)?t.allowIframeRelativeUrls:!t.allowedIframeHostnames&&!t.allowedIframeDomains;else if(t.allowedIframeHostnames||t.allowedIframeDomains){let n=(t.allowedIframeHostnames||[]).find(function(e){return e===r.url.hostname}),i=(t.allowedIframeDomains||[]).find(function(e){return r.url.hostname===e||r.url.hostname.endsWith(`.${e}`)});e=n||i}}catch{e=!1}if(!e){delete r.attribs[c];return}}if(c===`srcset`)try{let e=o(n);if(e.forEach(function(e){B(`srcset`,e.url)&&(e.evil=!0)}),e=f(e,function(e){return!e.evil}),e.length)n=m(f(e,function(e){return!e.evil})),r.attribs[c]=n;else{delete r.attribs[c];return}}catch{delete r.attribs[c];return}if(c===`class`){let t=E[e],i=E[`*`],o=D[e],s=O[e],l=O[`*`],u=[o,D[`*`]].concat(s,l).filter(function(e){return e});if(n=t&&i?H(n,a(t,i),u):H(n,t||i,u),!n.length){delete r.attribs[c];return}}if(c===`style`){if(t.parseStyleAttributes)try{if(n=re(ne(s(e+` {`+n+`}`,{map:!1}),t.allowedStyles)),n.length===0){delete r.attribs[c];return}}catch{typeof window<`u`&&console.warn(`Failed to parse "`+e+` {`+n+`}", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547`),delete r.attribs[c];return}else if(t.allowedStyles)throw Error(`allowedStyles option cannot be used together with parseStyleAttributes: false.`)}y+=` `+c,n&&n.length?y+=`="`+z(n,!0)+`"`:t.allowedEmptyAttributes.includes(c)&&(y+=`=""`)}else delete r.attribs[c]}),t.selfClosing.indexOf(e)===-1?(y+=`>`,r.innerText&&!l&&!t.textFilter&&(y+=z(r.innerText),L=!0)):y+=` />`,c&&(y=b+z(y),b=``),r.openingTagLength=y.length-r.tagPosition},ontext:function(e){if(F)return;let n=M[M.length-1],r;if(n&&(r=n.tag,e=n.innerText===void 0?e:n.innerText),t.disallowedTagsMode===`completelyDiscard`&&!S(r))e=``;else if((t.disallowedTagsMode===`discard`||t.disallowedTagsMode===`completelyDiscard`)&&(r===`script`||r===`style`))y+=e;else if(!L){let n=z(e,!1);t.textFilter?y+=t.textFilter(n,r):y+=n}if(M.length){let t=M[M.length-1];t.text+=e}},onclosetag:function(e,n){if(t.onCloseTag&&t.onCloseTag(e,n),F)if(I--,!I)F=!1;else return;let r=M.pop();if(!r)return;if(r.tag!==e){M.push(r);return}F=t.enforceHtmlBoundary?e===`html`:!1,j--;let i=N[j];if(i){if(delete N[j],t.disallowedTagsMode===`discard`||t.disallowedTagsMode===`completelyDiscard`){r.updateParentNodeText();return}b=y,y=``}if(P[j]&&(e=P[j],delete P[j]),t.exclusiveFilter){let e=t.exclusiveFilter(r);if(e===`excludeTag`){i&&(y=b,b=``),y=y.substring(0,r.tagPosition)+y.substring(r.tagPosition+r.openingTagLength);return}else if(e){y=y.substring(0,r.tagPosition);return}}if(r.updateParentNodeMediaChildren(),r.updateParentNodeText(),t.selfClosing.indexOf(e)!==-1||n&&!S(e)&&[`escape`,`recursiveEscape`].indexOf(t.disallowedTagsMode)>=0){i&&(y=b,b=``);return}y+=`</`+e+`>`,i&&(y=b+z(y),b=``),L=!1}},t.parser);if(R.write(e),R.end(),t.disallowedTagsMode===`escape`||t.disallowedTagsMode===`recursiveEscape`){let t=R.endIndex;if(t!=null&&t>=0&&t<e.length){let n=e.substring(t);y+=z(n)}else (t==null||t<0)&&e.length>0&&y===``&&(y=z(e))}return y;function ee(){y=``,j=0,M=[],N={},P={},F=!1,I=0}function z(e,n){return typeof e!=`string`&&(e+=``),t.parser.decodeEntities&&(e=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),n&&(e=e.replace(/"/g,`"`))),e=e.replace(/&(?![a-zA-Z0-9#]{1,20};)/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),n&&(e=e.replace(/"/g,`"`)),e}function B(e,n){for(n=n.replace(/[\x00-\x20]+/g,``);;){let e=n.indexOf(`<!--`);if(e===-1)break;let t=n.indexOf(`-->`,e+4);if(t===-1)break;n=n.substring(0,e)+n.substring(t+3)}let r=n.match(/^([a-zA-Z][a-zA-Z0-9.\-+]*):/);if(!r)return n.match(/^[/\\]{2}/)?!t.allowProtocolRelative:!1;let i=r[1].toLowerCase();return d(t.allowedSchemesByTag,e)?t.allowedSchemesByTag[e].indexOf(i)===-1:!t.allowedSchemes||t.allowedSchemes.indexOf(i)===-1}function te(e){if(e=e.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/,`$1//`),e.startsWith(`relative:`))throw Error(`relative: exploit attempt`);let t=`relative://relative-site`;for(let e=0;e<100;e++)t+=`/${e}`;let n=new URL(e,t);return{isRelativeUrl:n&&n.hostname===`relative-site`&&n.protocol===`relative:`,url:n}}function ne(e,t){if(!t)return e;let n=e.nodes[0],r;return r=t[n.selector]&&t[`*`]?a(t[n.selector],t[`*`]):t[n.selector]||t[`*`],r&&(e.nodes[0].nodes=n.nodes.reduce(V(r),[])),e}function re(e){return e.nodes[0].nodes.reduce(function(e,t){return e.push(`${t.prop}:${t.value}${t.important?` !important`:``}`),e},[]).join(`;`)}function V(e){return function(t,n){return d(e,n.prop)&&e[n.prop].some(function(e){return e.test(n.value)})&&t.push(n),t}}function H(e,t,n){return t?(e=e.split(/\s+/),e.filter(function(e){return t.indexOf(e)!==-1||n.some(function(t){return t.test(e)})}).join(` `)):e}}var _={decodeEntities:!0};g.defaults={allowedTags:`address.article.aside.footer.header.h1.h2.h3.h4.h5.h6.hgroup.main.nav.section.blockquote.dd.div.dl.dt.figcaption.figure.hr.li.menu.ol.p.pre.ul.a.abbr.b.bdi.bdo.br.cite.code.data.dfn.em.i.kbd.mark.q.rb.rp.rt.rtc.ruby.s.samp.small.span.strong.sub.sup.time.u.var.wbr.caption.col.colgroup.table.tbody.td.tfoot.th.thead.tr`.split(`.`),nonBooleanAttributes:`abbr.accept.accept-charset.accesskey.action.allow.alt.as.autocapitalize.autocomplete.blocking.charset.cite.class.color.cols.colspan.content.contenteditable.coords.crossorigin.data.datetime.decoding.dir.dirname.download.draggable.enctype.enterkeyhint.fetchpriority.for.form.formaction.formenctype.formmethod.formtarget.headers.height.hidden.high.href.hreflang.http-equiv.id.imagesizes.imagesrcset.inputmode.integrity.is.itemid.itemprop.itemref.itemtype.kind.label.lang.list.loading.low.max.maxlength.media.method.min.minlength.name.nonce.optimum.pattern.ping.placeholder.popover.popovertarget.popovertargetaction.poster.preload.referrerpolicy.rel.rows.rowspan.sandbox.scope.shape.size.sizes.slot.span.spellcheck.src.srcdoc.srclang.srcset.start.step.style.tabindex.target.title.translate.type.usemap.value.width.wrap.onauxclick.onafterprint.onbeforematch.onbeforeprint.onbeforeunload.onbeforetoggle.onblur.oncancel.oncanplay.oncanplaythrough.onchange.onclick.onclose.oncontextlost.oncontextmenu.oncontextrestored.oncopy.oncuechange.oncut.ondblclick.ondrag.ondragend.ondragenter.ondragleave.ondragover.ondragstart.ondrop.ondurationchange.onemptied.onended.onerror.onfocus.onformdata.onhashchange.oninput.oninvalid.onkeydown.onkeypress.onkeyup.onlanguagechange.onload.onloadeddata.onloadedmetadata.onloadstart.onmessage.onmessageerror.onmousedown.onmouseenter.onmouseleave.onmousemove.onmouseout.onmouseover.onmouseup.onoffline.ononline.onpagehide.onpageshow.onpaste.onpause.onplay.onplaying.onpopstate.onprogress.onratechange.onreset.onresize.onrejectionhandled.onscroll.onscrollend.onsecuritypolicyviolation.onseeked.onseeking.onselect.onslotchange.onstalled.onstorage.onsubmit.onsuspend.ontimeupdate.ontoggle.onunhandledrejection.onunload.onvolumechange.onwaiting.onwheel`.split(`.`),disallowedTagsMode:`discard`,allowedAttributes:{a:[`href`,`name`,`target`],img:[`src`,`srcset`,`alt`,`title`,`width`,`height`,`loading`]},allowedEmptyAttributes:[`alt`],selfClosing:[`img`,`br`,`hr`,`area`,`base`,`basefont`,`input`,`link`,`meta`],allowedSchemes:[`http`,`https`,`ftp`,`mailto`,`tel`],allowedSchemesByTag:{},allowedSchemesAppliedToAttributes:[`href`,`src`,`cite`],allowProtocolRelative:!0,enforceHtmlBoundary:!1,parseStyleAttributes:!0,preserveEscapedAttributes:!1},g.simpleTransform=function(e,t,n){return n=n===void 0?!0:n,t||={},function(r,i){let a;if(n)for(a in t)i[a]=t[a];else i=t;return{tagName:e,attribs:i}}}}))(),1),Pn={allowedTags:[`a`,`blockquote`,`br`,`code`,`del`,`em`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`li`,`ol`,`p`,`pre`,`strong`,`table`,`tbody`,`td`,`th`,`thead`,`tr`,`ul`],allowedAttributes:{a:[`href`,`rel`,`target`,`title`],code:[`class`],td:[`style`],th:[`style`]},allowedStyles:{td:{"text-align":[/^left$/,/^center$/,/^right$/]},th:{"text-align":[/^left$/,/^center$/,/^right$/]}},allowedSchemes:[`http`,`https`,`mailto`],allowedSchemesAppliedToAttributes:[`href`],allowProtocolRelative:!1,transformTags:{a:Nn.default.simpleTransform(`a`,{rel:`noopener noreferrer`,target:`_blank`},!0)}};function Fn(e){let t=String(e||``).replace(/\r\n/g,`
|
|
91
|
-
`);if(!t.trim())return``;let n=Z.parse(t,{async:!1,breaks:!0,gfm:!0});return(0,Nn.default)(typeof n==`string`?n:String(n||``),Pn).trim()}var In=[{label:`Allow once`,action:`once`},{label:`Allow always`,action:`always`},{label:`Allow session`,action:`session`},{label:`Allow agent`,action:`agent`},{label:`Allow all`,action:`all`}],Ln=120;function Rn(e,t,n){let[r,i]=(0,h.useState)(e),a=(0,h.useRef)(e),o=(0,h.useRef)(null);a.current=e,(0,h.useEffect)(()=>{if(!t){o.current!==null&&(window.clearTimeout(o.current),o.current=null),i(``);return}if(!n){o.current!==null&&(window.clearTimeout(o.current),o.current=null),i(e);return}o.current!==null||e===r||(o.current=window.setTimeout(()=>{o.current=null,(0,h.startTransition)(()=>{i(a.current)})},Ln))},[e,t,n,r]),(0,h.useEffect)(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);let s=t?n?r:e:``;return(0,h.useMemo)(()=>t?Fn(s):``,[t,s])}function zn(e){let{artifact:t,token:n}=e,r=(0,h.useRef)(null),[i,a]=(0,h.useState)(null),[o,s]=(0,h.useState)(!1),c=(t.mimeType??``).startsWith(`image/`);(0,h.useEffect)(()=>{let e=r.current;if(r.current=null,e&&URL.revokeObjectURL(e),a(null),!c||!t.path)return;let i=!1;return C(n,t.path).then(e=>{if(i)return;let t=URL.createObjectURL(e);r.current=t,a(t)}).catch(()=>{i||a(null)}),()=>{i=!0;let e=r.current;r.current=null,e&&URL.revokeObjectURL(e)}},[t.path,c,n]);let l=o?`Downloading…`:`Download`,u=async()=>{if(!(!t.path||o)){s(!0);try{let e=i??URL.createObjectURL(await C(n,t.path)),r=document.createElement(`a`);r.href=e,r.download=t.filename??`artifact`,r.rel=`noopener noreferrer`,document.body.appendChild(r),r.click(),r.remove(),i||window.setTimeout(()=>URL.revokeObjectURL(e),0)}catch{}finally{s(!1)}}};return(0,B.jsxs)(`div`,{className:z.artifactCard,children:[(0,B.jsx)(`span`,{className:z.artifactFilename,children:t.filename??`artifact`}),t.type?(0,B.jsx)(`span`,{className:z.artifactBadge,children:t.type}):null,t.path?(0,B.jsx)(`button`,{type:`button`,className:z.artifactDownload,disabled:o,onClick:()=>{u()},children:l}):null,c&&i?(0,B.jsx)(`div`,{className:z.artifactPreview,children:(0,B.jsx)(`img`,{src:i,alt:t.filename??`preview`})}):null]})}var Bn=(0,h.memo)(function(e){let{message:t,token:n}=e,[r,i]=(0,h.useState)(!1),a=()=>{e.onCopy(t.rawContent??t.content),i(!0),setTimeout(()=>i(!1),900)},o=(0,h.useMemo)(()=>{let e=new Map;return(t.artifacts??[]).map(t=>{let n=[t.path,t.filename,t.mimeType,t.type].filter(Boolean),r=n.length>0?n.join(`|`):`artifact`,i=e.get(r)??0;return e.set(r,i+1),{artifact:t,key:`${r}:${i}`}})},[t.artifacts]),s=t.role===`assistant`||t.role===`approval`||!!t.pendingApproval,c=Rn(t.content,s,e.isStreaming);if(t.role===`thinking`)return(0,B.jsxs)(`div`,{className:z.thinking,children:[(0,B.jsx)(`span`,{className:z.thinkingDot}),(0,B.jsx)(`span`,{className:z.thinkingDot}),(0,B.jsx)(`span`,{className:z.thinkingDot})]});let l=t.role===`user`,u=t.role===`assistant`,d=t.role===`approval`||!!t.pendingApproval,f=p(z.messageBlock,l&&z.messageBlockUser,(u||t.role===`system`||d)&&z.messageBlockAssistant),m=p(z.bubble,l&&z.bubbleUser,(u||d)&&z.bubbleAssistant,t.role===`system`&&z.bubbleSystem),g=t.assistantPresentation,_=g?.displayName??`Assistant`;return(0,B.jsxs)(`div`,{className:f,children:[u?(0,B.jsxs)(`div`,{className:z.agentLabel,children:[g?.imageUrl?(0,B.jsx)(`img`,{className:z.agentAvatar,src:g.imageUrl,alt:``}):(0,B.jsx)(`span`,{className:z.agentInitial,children:_.charAt(0).toUpperCase()}),(0,B.jsx)(`span`,{children:_})]}):null,(0,B.jsxs)(`div`,{className:m,children:[u||d?(0,B.jsx)(`div`,{className:z.markdownContent,dangerouslySetInnerHTML:{__html:c}}):t.content,d&&t.pendingApproval?(0,B.jsxs)(`div`,{className:z.approvalActions,children:[In.map(n=>(0,B.jsx)(`button`,{type:`button`,className:z.approvalAllow,disabled:e.approvalBusy,onClick:()=>e.onApprovalAction(n.action,t.pendingApproval?.approvalId??``),children:n.label},n.action)),(0,B.jsx)(`button`,{type:`button`,className:z.approvalDeny,disabled:e.approvalBusy,onClick:()=>e.onApprovalAction(`deny`,t.pendingApproval?.approvalId??``),children:`Deny`})]}):null]}),o.map(({artifact:e,key:t})=>(0,B.jsx)(zn,{artifact:e,token:n},t)),e.isStreaming?null:(0,B.jsxs)(`div`,{className:z.messageActions,children:[(0,B.jsx)(`button`,{type:`button`,className:p(z.actionButton,r&&z.actionButtonSuccess),title:`Copy`,onClick:a,children:r?`✓`:`⧉`}),l?(0,B.jsx)(`button`,{type:`button`,className:z.actionButton,title:`Edit`,onClick:()=>e.onEdit(t),children:`✎`}):null,u&&t.replayRequest?(0,B.jsx)(`button`,{type:`button`,className:z.actionButton,title:`Regenerate`,onClick:()=>e.onRegenerate(t),children:`↻`}):null,e.branchInfo&&e.branchInfo.total>1?(0,B.jsxs)(`div`,{className:z.branchSwitcher,children:[(0,B.jsx)(`button`,{type:`button`,className:z.branchButton,disabled:e.branchInfo.current<=1,onClick:()=>e.onBranchNav(-1),children:`‹`}),(0,B.jsxs)(`span`,{children:[e.branchInfo.current,`/`,e.branchInfo.total]}),(0,B.jsx)(`button`,{type:`button`,className:z.branchButton,disabled:e.branchInfo.current>=e.branchInfo.total,onClick:()=>e.onBranchNav(1),children:`›`})]}):null]})]})});function Vn(e){let[t,n]=(0,h.useState)(e.initial);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`textarea`,{className:z.editArea,value:t,onChange:e=>n(e.target.value),autoFocus:!0}),(0,B.jsxs)(`div`,{className:z.editButtons,children:[(0,B.jsx)(`button`,{type:`button`,className:`primary-button`,onClick:()=>e.onSave(t.trim()),disabled:!t.trim(),children:`Save`}),(0,B.jsx)(`button`,{type:`button`,className:`ghost-button`,onClick:e.onCancel,children:`Cancel`})]})]})}async function Hn(e,t){let n=await fetch(e,{method:`POST`,headers:{...o(t.token,t.body),Accept:`application/x-ndjson`},body:JSON.stringify(t.body),signal:t.signal});n.ok||await d(n);let{callbacks:r}=t,i=e=>{let t=String(e||``).trim();if(!t)return null;let n;try{n=JSON.parse(t)}catch{return console.warn(`Ignoring malformed chat stream line`,t),null}return!n||typeof n!=`object`?null:n.type===`text`&&typeof n.delta==`string`?(r.onTextDelta(n.delta),null):n.type===`approval`&&typeof n.approvalId==`string`&&typeof n.prompt==`string`?(r.onApproval(n),null):n.type===`result`&&n.result&&typeof n.result==`object`?n.result:typeof n.status==`string`&&Array.isArray(n.toolsUsed)?n:null};if(!n.body){let e=await n.text().catch(()=>``),t=null;for(let n of e.split(`
|
|
90
|
+
https://www.w3ctech.com/topic/2226`));let i=t(...r);return i.postcssPlugin=e,i.postcssVersion=new m().version,i}let i;return Object.defineProperty(r,`postcss`,{get(){return i||=r(),i}}),r.process=function(e,t,n){return b([r(n)]).process(e,t)},r},b.stringify=v,b.parse=p,b.fromJSON=c,b.list=d,b.comment=e=>new r(e),b.atRule=e=>new n(e),b.decl=e=>new o(e),b.rule=e=>new _(e),b.root=e=>new g(e),b.document=e=>new s(e),b.CssSyntaxError=a,b.Declaration=o,b.Container=i,b.Processor=m,b.Document=s,b.Comment=r,b.Warning=y,b.AtRule=n,b.Result=h,b.Input=l,b.Rule=_,b.Root=g,b.Node=f,u.registerPostcss(b),t.exports=b,b.default=b})),Nn=e(t(((e,t)=>{var n=Qt(),r=$t(),{isPlainObject:i}=en(),a=tn(),o=nn(),{parse:s}=Mn(),c=[`img`,`audio`,`video`,`picture`,`svg`,`object`,`map`,`iframe`,`embed`],l=[`script`,`style`];function u(e,t){e&&Object.keys(e).forEach(function(n){t(e[n],n)})}function d(e,t){return{}.hasOwnProperty.call(e,t)}function f(e,t){let n=[];return u(e,function(e){t(e)&&n.push(e)}),n}function p(e){for(let t in e)if(d(e,t))return!1;return!0}function m(e){return e.map(function(e){if(!e.url)throw Error(`URL missing`);return e.url+(e.w?` ${e.w}w`:``)+(e.h?` ${e.h}h`:``)+(e.d?` ${e.d}x`:``)}).join(`, `)}t.exports=g;var h=/^[^\0\t\n\f\r /<=>]+$/;function g(e,t,v){if(e==null)return``;typeof e==`number`&&(e=e.toString());let y=``,b=``;function x(e,t){let n=this;this.tag=e,this.attribs=t||{},this.tagPosition=y.length,this.text=``,this.openingTagLength=0,this.mediaChildren=[],this.updateParentNodeText=function(){if(M.length){let e=M[M.length-1];e.text+=n.text}},this.updateParentNodeMediaChildren=function(){M.length&&c.includes(this.tag)&&M[M.length-1].mediaChildren.push(this.tag)}}t=Object.assign({},g.defaults,t),t.parser=Object.assign({},_,t.parser);let S=function(e){return t.allowedTags===!1||(t.allowedTags||[]).indexOf(e)>-1};l.forEach(function(e){S(e)&&!t.allowVulnerableTags&&console.warn(`\n\n⚠️ Your \`allowedTags\` option includes, \`${e}\`, which is inherently\nvulnerable to XSS attacks. Please remove it from \`allowedTags\`.\nOr, to disable this warning, add the \`allowVulnerableTags\` option\nand ensure you are accounting for this risk.\n\n`)});let C=t.nonTextTags||[`script`,`style`,`textarea`,`option`],w,T;t.allowedAttributes&&(w={},T={},u(t.allowedAttributes,function(e,t){w[t]=[];let n=[];e.forEach(function(e){typeof e==`string`&&e.indexOf(`*`)>=0?n.push(r(e).replace(/\\\*/g,`.*`)):w[t].push(e)}),n.length&&(T[t]=RegExp(`^(`+n.join(`|`)+`)$`))}));let E={},D={},O={};u(t.allowedClasses,function(e,t){if(w&&(d(w,t)||(w[t]=[]),w[t].push(`class`)),E[t]=e,Array.isArray(e)){let n=[];E[t]=[],O[t]=[],e.forEach(function(e){typeof e==`string`&&e.indexOf(`*`)>=0?n.push(r(e).replace(/\\\*/g,`.*`)):e instanceof RegExp?O[t].push(e):E[t].push(e)}),n.length&&(D[t]=RegExp(`^(`+n.join(`|`)+`)$`))}});let k={},A;u(t.transformTags,function(e,t){let n;typeof e==`function`?n=e:typeof e==`string`&&(n=g.simpleTransform(e)),t===`*`?A=n:k[t]=n});let j,M,N,P,F,I,L=!1;ee();let R=new n.Parser({onopentag:function(e,n){if(t.onOpenTag&&t.onOpenTag(e,n),t.enforceHtmlBoundary&&e===`html`&&ee(),F){I++;return}let r=new x(e,n);M.push(r);let c=!1,l=!!r.text,g;if(d(k,e)&&(g=k[e](e,n),r.attribs=n=g.attribs,g.text!==void 0&&(r.innerText=g.text),e!==g.tagName&&(r.name=e=g.tagName,P[j]=g.tagName)),A&&(g=A(e,n),r.attribs=n=g.attribs,e!==g.tagName&&(r.name=e=g.tagName,P[j]=g.tagName)),(!S(e)||t.disallowedTagsMode===`recursiveEscape`&&!p(N)||t.nestingLimit!=null&&j>=t.nestingLimit)&&(c=!0,N[j]=!0,(t.disallowedTagsMode===`discard`||t.disallowedTagsMode===`completelyDiscard`)&&C.indexOf(e)!==-1&&(F=!0,I=1)),j++,c){if(t.disallowedTagsMode===`discard`||t.disallowedTagsMode===`completelyDiscard`){if(r.innerText&&!l){let n=z(r.innerText);t.textFilter?y+=t.textFilter(n,e):y+=n,L=!0}return}b=y,y=``}y+=`<`+e,e===`script`&&(t.allowedScriptHostnames||t.allowedScriptDomains)&&(r.innerText=``),c&&(t.disallowedTagsMode===`escape`||t.disallowedTagsMode===`recursiveEscape`)&&t.preserveEscapedAttributes?u(n,function(e,t){y+=` `+t+`="`+z(e||``,!0)+`"`}):(!w||d(w,e)||w[`*`])&&u(n,function(n,c){if(!h.test(c)){delete r.attribs[c];return}if(n===``&&!t.allowedEmptyAttributes.includes(c)&&(t.nonBooleanAttributes.includes(c)||t.nonBooleanAttributes.includes(`*`))){delete r.attribs[c];return}let l=!1;if(!w||d(w,e)&&w[e].indexOf(c)!==-1||w[`*`]&&w[`*`].indexOf(c)!==-1||d(T,e)&&T[e].test(c)||T[`*`]&&T[`*`].test(c))l=!0;else if(w&&w[e]){for(let t of w[e])if(i(t)&&t.name&&t.name===c){l=!0;let e=``;if(t.multiple===!0){let r=n.split(` `);for(let n of r)t.values.indexOf(n)!==-1&&(e===``?e=n:e+=` `+n)}else t.values.indexOf(n)>=0&&(e=n);n=e}}if(l){if(t.allowedSchemesAppliedToAttributes.indexOf(c)!==-1&&B(e,n)){delete r.attribs[c];return}if(e===`script`&&c===`src`){let e=!0;try{let r=te(n);if(t.allowedScriptHostnames||t.allowedScriptDomains){let n=(t.allowedScriptHostnames||[]).find(function(e){return e===r.url.hostname}),i=(t.allowedScriptDomains||[]).find(function(e){return r.url.hostname===e||r.url.hostname.endsWith(`.${e}`)});e=n||i}}catch{e=!1}if(!e){delete r.attribs[c];return}}if(e===`iframe`&&c===`src`){let e=!0;try{let r=te(n);if(r.isRelativeUrl)e=d(t,`allowIframeRelativeUrls`)?t.allowIframeRelativeUrls:!t.allowedIframeHostnames&&!t.allowedIframeDomains;else if(t.allowedIframeHostnames||t.allowedIframeDomains){let n=(t.allowedIframeHostnames||[]).find(function(e){return e===r.url.hostname}),i=(t.allowedIframeDomains||[]).find(function(e){return r.url.hostname===e||r.url.hostname.endsWith(`.${e}`)});e=n||i}}catch{e=!1}if(!e){delete r.attribs[c];return}}if(c===`srcset`)try{let e=o(n);if(e.forEach(function(e){B(`srcset`,e.url)&&(e.evil=!0)}),e=f(e,function(e){return!e.evil}),e.length)n=m(f(e,function(e){return!e.evil})),r.attribs[c]=n;else{delete r.attribs[c];return}}catch{delete r.attribs[c];return}if(c===`class`){let t=E[e],i=E[`*`],o=D[e],s=O[e],l=O[`*`],u=[o,D[`*`]].concat(s,l).filter(function(e){return e});if(n=t&&i?H(n,a(t,i),u):H(n,t||i,u),!n.length){delete r.attribs[c];return}}if(c===`style`){if(t.parseStyleAttributes)try{if(n=re(ne(s(e+` {`+n+`}`,{map:!1}),t.allowedStyles)),n.length===0){delete r.attribs[c];return}}catch{typeof window<`u`&&console.warn(`Failed to parse "`+e+` {`+n+`}", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547`),delete r.attribs[c];return}else if(t.allowedStyles)throw Error(`allowedStyles option cannot be used together with parseStyleAttributes: false.`)}y+=` `+c,n&&n.length?y+=`="`+z(n,!0)+`"`:t.allowedEmptyAttributes.includes(c)&&(y+=`=""`)}else delete r.attribs[c]}),t.selfClosing.indexOf(e)===-1?(y+=`>`,r.innerText&&!l&&!t.textFilter&&(y+=z(r.innerText),L=!0)):y+=` />`,c&&(y=b+z(y),b=``),r.openingTagLength=y.length-r.tagPosition},ontext:function(e){if(F)return;let n=M[M.length-1],r;if(n&&(r=n.tag,e=n.innerText===void 0?e:n.innerText),t.disallowedTagsMode===`completelyDiscard`&&!S(r))e=``;else if((t.disallowedTagsMode===`discard`||t.disallowedTagsMode===`completelyDiscard`)&&(r===`script`||r===`style`))y+=e;else if(!L){let n=z(e,!1);t.textFilter?y+=t.textFilter(n,r):y+=n}if(M.length){let t=M[M.length-1];t.text+=e}},onclosetag:function(e,n){if(t.onCloseTag&&t.onCloseTag(e,n),F)if(I--,!I)F=!1;else return;let r=M.pop();if(!r)return;if(r.tag!==e){M.push(r);return}F=t.enforceHtmlBoundary?e===`html`:!1,j--;let i=N[j];if(i){if(delete N[j],t.disallowedTagsMode===`discard`||t.disallowedTagsMode===`completelyDiscard`){r.updateParentNodeText();return}b=y,y=``}if(P[j]&&(e=P[j],delete P[j]),t.exclusiveFilter){let e=t.exclusiveFilter(r);if(e===`excludeTag`){i&&(y=b,b=``),y=y.substring(0,r.tagPosition)+y.substring(r.tagPosition+r.openingTagLength);return}else if(e){y=y.substring(0,r.tagPosition);return}}if(r.updateParentNodeMediaChildren(),r.updateParentNodeText(),t.selfClosing.indexOf(e)!==-1||n&&!S(e)&&[`escape`,`recursiveEscape`].indexOf(t.disallowedTagsMode)>=0){i&&(y=b,b=``);return}y+=`</`+e+`>`,i&&(y=b+z(y),b=``),L=!1}},t.parser);if(R.write(e),R.end(),t.disallowedTagsMode===`escape`||t.disallowedTagsMode===`recursiveEscape`){let t=R.endIndex;if(t!=null&&t>=0&&t<e.length){let n=e.substring(t);y+=z(n)}else (t==null||t<0)&&e.length>0&&y===``&&(y=z(e))}return y;function ee(){y=``,j=0,M=[],N={},P={},F=!1,I=0}function z(e,n){return typeof e!=`string`&&(e+=``),t.parser.decodeEntities&&(e=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),n&&(e=e.replace(/"/g,`"`))),e=e.replace(/&(?![a-zA-Z0-9#]{1,20};)/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),n&&(e=e.replace(/"/g,`"`)),e}function B(e,n){for(n=n.replace(/[\x00-\x20]+/g,``);;){let e=n.indexOf(`<!--`);if(e===-1)break;let t=n.indexOf(`-->`,e+4);if(t===-1)break;n=n.substring(0,e)+n.substring(t+3)}let r=n.match(/^([a-zA-Z][a-zA-Z0-9.\-+]*):/);if(!r)return n.match(/^[/\\]{2}/)?!t.allowProtocolRelative:!1;let i=r[1].toLowerCase();return d(t.allowedSchemesByTag,e)?t.allowedSchemesByTag[e].indexOf(i)===-1:!t.allowedSchemes||t.allowedSchemes.indexOf(i)===-1}function te(e){if(e=e.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/,`$1//`),e.startsWith(`relative:`))throw Error(`relative: exploit attempt`);let t=`relative://relative-site`;for(let e=0;e<100;e++)t+=`/${e}`;let n=new URL(e,t);return{isRelativeUrl:n&&n.hostname===`relative-site`&&n.protocol===`relative:`,url:n}}function ne(e,t){if(!t)return e;let n=e.nodes[0],r;return r=t[n.selector]&&t[`*`]?a(t[n.selector],t[`*`]):t[n.selector]||t[`*`],r&&(e.nodes[0].nodes=n.nodes.reduce(V(r),[])),e}function re(e){return e.nodes[0].nodes.reduce(function(e,t){return e.push(`${t.prop}:${t.value}${t.important?` !important`:``}`),e},[]).join(`;`)}function V(e){return function(t,n){return d(e,n.prop)&&e[n.prop].some(function(e){return e.test(n.value)})&&t.push(n),t}}function H(e,t,n){return t?(e=e.split(/\s+/),e.filter(function(e){return t.indexOf(e)!==-1||n.some(function(t){return t.test(e)})}).join(` `)):e}}var _={decodeEntities:!0};g.defaults={allowedTags:`address.article.aside.footer.header.h1.h2.h3.h4.h5.h6.hgroup.main.nav.section.blockquote.dd.div.dl.dt.figcaption.figure.hr.li.menu.ol.p.pre.ul.a.abbr.b.bdi.bdo.br.cite.code.data.dfn.em.i.kbd.mark.q.rb.rp.rt.rtc.ruby.s.samp.small.span.strong.sub.sup.time.u.var.wbr.caption.col.colgroup.table.tbody.td.tfoot.th.thead.tr`.split(`.`),nonBooleanAttributes:`abbr.accept.accept-charset.accesskey.action.allow.alt.as.autocapitalize.autocomplete.blocking.charset.cite.class.color.cols.colspan.content.contenteditable.coords.crossorigin.data.datetime.decoding.dir.dirname.download.draggable.enctype.enterkeyhint.fetchpriority.for.form.formaction.formenctype.formmethod.formtarget.headers.height.hidden.high.href.hreflang.http-equiv.id.imagesizes.imagesrcset.inputmode.integrity.is.itemid.itemprop.itemref.itemtype.kind.label.lang.list.loading.low.max.maxlength.media.method.min.minlength.name.nonce.optimum.pattern.ping.placeholder.popover.popovertarget.popovertargetaction.poster.preload.referrerpolicy.rel.rows.rowspan.sandbox.scope.shape.size.sizes.slot.span.spellcheck.src.srcdoc.srclang.srcset.start.step.style.tabindex.target.title.translate.type.usemap.value.width.wrap.onauxclick.onafterprint.onbeforematch.onbeforeprint.onbeforeunload.onbeforetoggle.onblur.oncancel.oncanplay.oncanplaythrough.onchange.onclick.onclose.oncontextlost.oncontextmenu.oncontextrestored.oncopy.oncuechange.oncut.ondblclick.ondrag.ondragend.ondragenter.ondragleave.ondragover.ondragstart.ondrop.ondurationchange.onemptied.onended.onerror.onfocus.onformdata.onhashchange.oninput.oninvalid.onkeydown.onkeypress.onkeyup.onlanguagechange.onload.onloadeddata.onloadedmetadata.onloadstart.onmessage.onmessageerror.onmousedown.onmouseenter.onmouseleave.onmousemove.onmouseout.onmouseover.onmouseup.onoffline.ononline.onpagehide.onpageshow.onpaste.onpause.onplay.onplaying.onpopstate.onprogress.onratechange.onreset.onresize.onrejectionhandled.onscroll.onscrollend.onsecuritypolicyviolation.onseeked.onseeking.onselect.onslotchange.onstalled.onstorage.onsubmit.onsuspend.ontimeupdate.ontoggle.onunhandledrejection.onunload.onvolumechange.onwaiting.onwheel`.split(`.`),disallowedTagsMode:`discard`,allowedAttributes:{a:[`href`,`name`,`target`],img:[`src`,`srcset`,`alt`,`title`,`width`,`height`,`loading`]},allowedEmptyAttributes:[`alt`],selfClosing:[`img`,`br`,`hr`,`area`,`base`,`basefont`,`input`,`link`,`meta`],allowedSchemes:[`http`,`https`,`ftp`,`mailto`,`tel`],allowedSchemesByTag:{},allowedSchemesAppliedToAttributes:[`href`,`src`,`cite`],allowProtocolRelative:!0,enforceHtmlBoundary:!1,parseStyleAttributes:!0,preserveEscapedAttributes:!1},g.simpleTransform=function(e,t,n){return n=n===void 0?!0:n,t||={},function(r,i){let a;if(n)for(a in t)i[a]=t[a];else i=t;return{tagName:e,attribs:i}}}}))(),1),Pn={allowedTags:[`a`,`blockquote`,`br`,`code`,`del`,`em`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`li`,`ol`,`p`,`pre`,`strong`,`table`,`tbody`,`td`,`th`,`thead`,`tr`,`ul`],allowedAttributes:{a:[`href`,`rel`,`target`,`title`],code:[`class`],ol:[`start`],td:[`style`],th:[`style`]},allowedStyles:{td:{"text-align":[/^left$/,/^center$/,/^right$/]},th:{"text-align":[/^left$/,/^center$/,/^right$/]}},allowedSchemes:[`http`,`https`,`mailto`],allowedSchemesAppliedToAttributes:[`href`],allowProtocolRelative:!1,transformTags:{a:Nn.default.simpleTransform(`a`,{rel:`noopener noreferrer`,target:`_blank`},!0)}};function Fn(e){let t=String(e||``).replace(/\r\n/g,`
|
|
91
|
+
`).replace(/^(\s*)\*\*(\d+)\.\s+(.+?)\*\*\s*$/gm,`$1$2. **$3**`);if(!t.trim())return``;let n=Z.parse(t,{async:!1,breaks:!0,gfm:!0});return(0,Nn.default)(typeof n==`string`?n:String(n||``),Pn).trim()}var In=[{label:`Allow once`,action:`once`},{label:`Allow always`,action:`always`},{label:`Allow session`,action:`session`},{label:`Allow agent`,action:`agent`},{label:`Allow all`,action:`all`}],Ln=120;function Rn(e,t,n){let[r,i]=(0,h.useState)(e),a=(0,h.useRef)(e),o=(0,h.useRef)(null);a.current=e,(0,h.useEffect)(()=>{if(!t){o.current!==null&&(window.clearTimeout(o.current),o.current=null),i(``);return}if(!n){o.current!==null&&(window.clearTimeout(o.current),o.current=null),i(e);return}o.current!==null||e===r||(o.current=window.setTimeout(()=>{o.current=null,(0,h.startTransition)(()=>{i(a.current)})},Ln))},[e,t,n,r]),(0,h.useEffect)(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);let s=t?n?r:e:``;return(0,h.useMemo)(()=>t?Fn(s):``,[t,s])}function zn(e){let{artifact:t,token:n}=e,r=(0,h.useRef)(null),[i,a]=(0,h.useState)(null),[o,s]=(0,h.useState)(!1),c=(t.mimeType??``).startsWith(`image/`);(0,h.useEffect)(()=>{let e=r.current;if(r.current=null,e&&URL.revokeObjectURL(e),a(null),!c||!t.path)return;let i=!1;return C(n,t.path).then(e=>{if(i)return;let t=URL.createObjectURL(e);r.current=t,a(t)}).catch(()=>{i||a(null)}),()=>{i=!0;let e=r.current;r.current=null,e&&URL.revokeObjectURL(e)}},[t.path,c,n]);let l=o?`Downloading…`:`Download`,u=async()=>{if(!(!t.path||o)){s(!0);try{let e=i??URL.createObjectURL(await C(n,t.path)),r=document.createElement(`a`);r.href=e,r.download=t.filename??`artifact`,r.rel=`noopener noreferrer`,document.body.appendChild(r),r.click(),r.remove(),i||window.setTimeout(()=>URL.revokeObjectURL(e),0)}catch{}finally{s(!1)}}};return(0,B.jsxs)(`div`,{className:z.artifactCard,children:[(0,B.jsx)(`span`,{className:z.artifactFilename,children:t.filename??`artifact`}),t.type?(0,B.jsx)(`span`,{className:z.artifactBadge,children:t.type}):null,t.path?(0,B.jsx)(`button`,{type:`button`,className:z.artifactDownload,disabled:o,onClick:()=>{u()},children:l}):null,c&&i?(0,B.jsx)(`div`,{className:z.artifactPreview,children:(0,B.jsx)(`img`,{src:i,alt:t.filename??`preview`})}):null]})}var Bn=(0,h.memo)(function(e){let{message:t,token:n}=e,[r,i]=(0,h.useState)(!1),a=()=>{e.onCopy(t.rawContent??t.content),i(!0),setTimeout(()=>i(!1),900)},o=(0,h.useMemo)(()=>{let e=new Map;return(t.artifacts??[]).map(t=>{let n=[t.path,t.filename,t.mimeType,t.type].filter(Boolean),r=n.length>0?n.join(`|`):`artifact`,i=e.get(r)??0;return e.set(r,i+1),{artifact:t,key:`${r}:${i}`}})},[t.artifacts]),s=t.role===`assistant`||t.role===`approval`||!!t.pendingApproval,c=Rn(t.content,s,e.isStreaming);if(t.role===`thinking`)return(0,B.jsxs)(`div`,{className:z.thinking,children:[(0,B.jsx)(`span`,{className:z.thinkingDot}),(0,B.jsx)(`span`,{className:z.thinkingDot}),(0,B.jsx)(`span`,{className:z.thinkingDot})]});let l=t.role===`user`,u=t.role===`assistant`,d=t.role===`approval`||!!t.pendingApproval,f=p(z.messageBlock,l&&z.messageBlockUser,(u||t.role===`system`||d)&&z.messageBlockAssistant),m=p(z.bubble,l&&z.bubbleUser,(u||d)&&z.bubbleAssistant,t.role===`system`&&z.bubbleSystem),g=t.assistantPresentation,_=g?.displayName??`Assistant`;return(0,B.jsxs)(`div`,{className:f,children:[u?(0,B.jsxs)(`div`,{className:z.agentLabel,children:[g?.imageUrl?(0,B.jsx)(`img`,{className:z.agentAvatar,src:g.imageUrl,alt:``}):(0,B.jsx)(`span`,{className:z.agentInitial,children:_.charAt(0).toUpperCase()}),(0,B.jsx)(`span`,{children:_})]}):null,(0,B.jsxs)(`div`,{className:m,children:[u||d?(0,B.jsx)(`div`,{className:z.markdownContent,dangerouslySetInnerHTML:{__html:c}}):t.content,d&&t.pendingApproval?(0,B.jsxs)(`div`,{className:z.approvalActions,children:[In.map(n=>(0,B.jsx)(`button`,{type:`button`,className:z.approvalAllow,disabled:e.approvalBusy,onClick:()=>e.onApprovalAction(n.action,t.pendingApproval?.approvalId??``),children:n.label},n.action)),(0,B.jsx)(`button`,{type:`button`,className:z.approvalDeny,disabled:e.approvalBusy,onClick:()=>e.onApprovalAction(`deny`,t.pendingApproval?.approvalId??``),children:`Deny`})]}):null]}),o.map(({artifact:e,key:t})=>(0,B.jsx)(zn,{artifact:e,token:n},t)),e.isStreaming?null:(0,B.jsxs)(`div`,{className:z.messageActions,children:[(0,B.jsx)(`button`,{type:`button`,className:p(z.actionButton,r&&z.actionButtonSuccess),title:`Copy`,onClick:a,children:r?`✓`:`⧉`}),l?(0,B.jsx)(`button`,{type:`button`,className:z.actionButton,title:`Edit`,onClick:()=>e.onEdit(t),children:`✎`}):null,u&&t.replayRequest?(0,B.jsx)(`button`,{type:`button`,className:z.actionButton,title:`Regenerate`,onClick:()=>e.onRegenerate(t),children:`↻`}):null,e.branchInfo&&e.branchInfo.total>1?(0,B.jsxs)(`div`,{className:z.branchSwitcher,children:[(0,B.jsx)(`button`,{type:`button`,className:z.branchButton,disabled:e.branchInfo.current<=1,onClick:()=>e.onBranchNav(-1),children:`‹`}),(0,B.jsxs)(`span`,{children:[e.branchInfo.current,`/`,e.branchInfo.total]}),(0,B.jsx)(`button`,{type:`button`,className:z.branchButton,disabled:e.branchInfo.current>=e.branchInfo.total,onClick:()=>e.onBranchNav(1),children:`›`})]}):null]})]})});function Vn(e){let[t,n]=(0,h.useState)(e.initial);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`textarea`,{className:z.editArea,value:t,onChange:e=>n(e.target.value),autoFocus:!0}),(0,B.jsxs)(`div`,{className:z.editButtons,children:[(0,B.jsx)(`button`,{type:`button`,className:`primary-button`,onClick:()=>e.onSave(t.trim()),disabled:!t.trim(),children:`Save`}),(0,B.jsx)(`button`,{type:`button`,className:`ghost-button`,onClick:e.onCancel,children:`Cancel`})]})]})}async function Hn(e,t){let n=await fetch(e,{method:`POST`,headers:{...o(t.token,t.body),Accept:`application/x-ndjson`},body:JSON.stringify(t.body),signal:t.signal});n.ok||await d(n);let{callbacks:r}=t,i=e=>{let t=String(e||``).trim();if(!t)return null;let n;try{n=JSON.parse(t)}catch{return console.warn(`Ignoring malformed chat stream line`,t),null}return!n||typeof n!=`object`?null:n.type===`text`&&typeof n.delta==`string`?(r.onTextDelta(n.delta),null):n.type===`approval`&&typeof n.approvalId==`string`&&typeof n.prompt==`string`?(r.onApproval(n),null):n.type===`result`&&n.result&&typeof n.result==`object`?n.result:typeof n.status==`string`&&Array.isArray(n.toolsUsed)?n:null};if(!n.body){let e=await n.text().catch(()=>``),t=null;for(let n of e.split(`
|
|
92
92
|
`)){let e=i(n);e&&(t=e)}if(!t)throw Error(`Chat stream ended without a result payload.`);return t}let a=n.body.getReader(),s=new TextDecoder,c=``,l=null,u=(e=!1)=>{let t=c.split(`
|
|
93
93
|
`),n=e?t.pop()??``:null;c=e?``:t.pop()??``;for(let e of t){let t=i(e);t&&(l=t)}if(e&&n?.trim()){let e=i(n);e&&(l=e)}};try{for(;;){let{done:e,value:t}=await a.read();if(e)break;c+=s.decode(t,{stream:!0}),u()}c+=s.decode(),u(!0)}finally{a.releaseLock()}if(!l)throw Error(`Chat stream ended without a result payload.`);return l}function Un(e){let{token:t,userId:n,getSessionId:r,setMessages:i,setSessionId:a,setError:o,refreshRecent:s}=e,c=(0,h.useRef)(null),[l,u]=(0,h.useState)(!1),[d,f]=(0,h.useState)(null);return{sendMessage:(0,h.useCallback)(async(e,l,d)=>{if(c.current)return o(`Wait for the current run to finish before sending another message.`),!1;let p=r(),m=d?.hideUser?null:j();if(o(``),m){let t={id:m,role:`user`,content:e,rawContent:e,sessionId:p,media:l,artifacts:[],replayRequest:{content:e,media:l}};i(e=>[...e,t])}let h=j();i(e=>[...e,{id:h,role:`thinking`,content:``,sessionId:p}]);let g=j();f(g);let _={controller:new AbortController,sessionId:p,assistantText:``,lastRenderedText:``,pendingApproval:null,renderFrame:0,stopping:!1};c.current=_,u(!0);let v=()=>{if(_.renderFrame=0,_.assistantText===_.lastRenderedText&&!_.pendingApproval)return;_.lastRenderedText=_.assistantText;let e=_.pendingApproval?`approval`:`assistant`,t=_.assistantText,n=_.pendingApproval;i(r=>{let i=r.filter(e=>e.id!==h),a=i.find(e=>e.id===g);return a?i.map(r=>r===a?{...r,role:e,content:t,pendingApproval:n}:r):[...i,{id:g,role:e,content:t,sessionId:_.sessionId,artifacts:[],pendingApproval:n}]})},y=()=>{_.renderFrame&&=(cancelAnimationFrame(_.renderFrame),0),v()},b=()=>{_.renderFrame||=requestAnimationFrame(v)};try{let r=await Hn(`/api/chat`,{token:t,body:{sessionId:p,channelId:`web`,userId:n,username:`web`,content:e,stream:!0,...l.length>0?{media:l}:{}},signal:_.controller.signal,callbacks:{onTextDelta:e=>{_.assistantText+=e,b()},onApproval:e=>{_.pendingApproval=e,_.assistantText.trim()||(_.assistantText=N(e)),b()}}});if(r.status===`error`)throw Error(r.error??`Unknown error`);r.sessionId&&a(r.sessionId),y();let o=r.result??_.assistantText??``,c=_.pendingApproval,u=r.artifacts??[];i(t=>t.map(t=>t.id===g?{...t,role:c?`approval`:`assistant`,content:o,messageId:r.assistantMessageId??null,artifacts:u,pendingApproval:c,replayRequest:{content:e,media:l}}:m&&t.id===m&&t.role===`user`&&!t.messageId?{...t,messageId:r.userMessageId??null,sessionId:r.sessionId??t.sessionId}:t)),s()}catch(e){_.renderFrame&&cancelAnimationFrame(_.renderFrame);let t=!_.stopping&&e instanceof Error?e.message:String(e);i(e=>{let n=e.filter(e=>e.id!==h);return _.stopping?n:[...n,{id:j(),role:`system`,content:`Error: ${t}`,sessionId:p}]})}finally{c.current=null,u(!1),f(null)}return!0},[t,n,r,i,a,o,s]),stopRequest:(0,h.useCallback)(async()=>{let e=c.current;if(!(!e||e.stopping)){e.stopping=!0;try{await b(t,e.sessionId,n,[`stop`])}catch(e){o(`Failed to stop: ${e instanceof Error?e.message:String(e)}`)}finally{e.controller.abort()}}},[t,n,o]),isStreaming:l,streamingMsgId:d,isActive:(0,h.useCallback)(()=>c.current!==null,[])}}function Wn(e,t){let n=new Map;for(let r of e){let e=r.branchKey;if(!e)continue;let i=t.get(e);if(!i||i.length<2)continue;let a=i.findIndex(e=>e.sessionId===r.sessionId);a<0||n.set(r.id,{current:a+1,total:i.length})}return n}function Gn(){let e=u(),t=i(),n=(0,h.useRef)(D()).current,r=(0,h.useRef)(w),[o,s]=(0,h.useState)(()=>O()||E()),[l,d]=(0,h.useState)([]),[f,m]=(0,h.useState)(``),[v,b]=(0,h.useState)(null),[S,C]=(0,h.useState)(!1),[T,A]=(0,h.useState)(!1),[N,P]=(0,h.useState)(new Map),[I,L]=(0,h.useState)(new Map),R=(0,h.useRef)(null),ne=(0,h.useRef)(null),V=(0,h.useRef)(o);V.current=o;let H=(0,h.useRef)(null),ie=(0,h.useCallback)(()=>{t.invalidateQueries({queryKey:[`chat-recent`,e.token,n]})},[t,e.token,n]),U=(0,h.useCallback)(()=>V.current,[]),W=Un({token:e.token,userId:n,getSessionId:U,setMessages:d,setSessionId:s,setError:m,refreshRecent:ie}),ae=(0,h.useRef)(W.sendMessage);ae.current=W.sendMessage,(0,h.useEffect)(()=>{k(o)},[o]),(0,h.useEffect)(()=>{c(e.token).then(e=>{e.defaultAgentId&&(r.current=e.defaultAgentId.trim().toLowerCase())}).catch(e=>{console.error(`Failed to load gateway status for chat page`,e),m(e=>e||`Failed to load the default agent. New chats will use main until gateway status loads.`)})},[e.token]);let G=a({queryKey:[`chat-recent`,e.token,n],queryFn:()=>g(e.token,n),staleTime:1e4}).data?.sessions??[],K=a({queryKey:[`chat-history`,e.token,o],queryFn:()=>_(e.token,o),enabled:!!o,staleTime:45e3,refetchOnWindowFocus:!1});(0,h.useEffect)(()=>{let e=K.data;if(!o||!e)return;e.sessionId&&e.sessionId!==o&&s(e.sessionId);let t=e.sessionId??o,n=new Map((e.branchFamilies??[]).map(e=>[`${e.anchorSessionId}:${e.anchorMessageId}`,e.variants])),r=new Map;for(let[e,i]of n.entries()){let n=i.find(e=>e.sessionId===t);n&&r.set(n.messageId,e)}let i=(e.history??[]).map(n=>({id:j(),role:n.role,content:n.content,rawContent:n.content,sessionId:t,messageId:n.id??null,media:[],artifacts:[],replayRequest:n.role===`user`?{content:n.content,media:[]}:null,assistantPresentation:e.assistantPresentation??null,branchKey:n.id!==void 0&&n.id!==null?r.get(n.id)??null:null}));d(i),P(n),L(Wn(i,n)),m(``);let a=H.current;a&&(H.current=null,ae.current(a.content,a.media))},[K.data,o]),(0,h.useEffect)(()=>{K.error&&m(K.error instanceof Error?K.error.message:String(K.error))},[K.error]);let oe=(0,h.useRef)(0);(0,h.useEffect)(()=>{oe.current||=requestAnimationFrame(()=>{oe.current=0,ee(ne.current)&&R.current?.scrollIntoView({behavior:`smooth`})})},[l]),(0,h.useEffect)(()=>()=>{oe.current&&cancelAnimationFrame(oe.current)},[]);let se=(0,h.useCallback)(()=>{d([]),P(new Map),L(new Map),m(``),b(null),A(!1)},[]),ce=(0,h.useCallback)(async(t,n)=>{if(!t.messageId||!t.sessionId){m(`This message cannot be edited right now.`);return}b(null);try{let r=await y(e.token,t.sessionId,t.messageId);H.current={content:n,media:t.media??[]},s(r.sessionId)}catch(e){m(e instanceof Error?e.message:String(e))}},[e.token]),le=(0,h.useCallback)(e=>{e.replayRequest&&W.sendMessage(e.replayRequest.content,e.replayRequest.media,{hideUser:!0})},[W.sendMessage]),ue=(0,h.useCallback)(async(e,t)=>{let n=F(e,t);if(n){C(!0);try{await W.sendMessage(n,[],{hideUser:!0})}finally{C(!1)}}},[W.sendMessage]),de=(0,h.useCallback)(async t=>{let n=await Promise.allSettled(t.map(t=>x(e.token,t))),r=[];for(let e of n)if(e.status===`fulfilled`&&e.value.media)r.push(e.value.media);else if(e.status===`rejected`){let t=e.reason;m(t instanceof Error?t.message:String(t))}return r},[e.token]),fe=(0,h.useCallback)(()=>{if(W.isActive()){m(`Stop the current run before starting a new chat.`);return}se(),s(E(r.current)),ie()},[W,se,ie]),pe=(0,h.useCallback)(e=>{if(W.isActive()){m(`Stop the current run before switching chats.`);return}se(),s(e)},[W,se]),me=(0,h.useCallback)((e,t)=>{let n=e.branchKey;if(!n)return;let r=N.get(n);if(!r||r.length<2)return;let i=r.findIndex(t=>t.sessionId===e.sessionId);if(i<0)return;let a=i+t;if(a<0||a>=r.length)return;let o=r[a];o&&pe(o.sessionId)},[N,pe]),he=l.length===0,ge={sessions:G,activeSessionId:o,onNewChat:fe,onOpenSession:pe};return(0,B.jsxs)(`div`,{className:z.chatPage,children:[T?(0,B.jsx)(`button`,{type:`button`,className:z.sidebarBackdrop,tabIndex:-1,"aria-label":`Close sidebar`,onClick:()=>A(!1)}):null,(0,B.jsx)(`div`,{className:p(z.sidebar,T&&z.sidebarOpen),children:(0,B.jsx)(te,{...ge})}),(0,B.jsxs)(`div`,{className:z.chatMain,children:[(0,B.jsxs)(`div`,{className:z.mobileHeader,children:[(0,B.jsx)(`button`,{type:`button`,className:`ghost-button`,onClick:()=>A(!0),"aria-label":`Open sidebar`,children:`☰`}),(0,B.jsx)(`span`,{style:{fontWeight:600},children:`HybridClaw`})]}),he?(0,B.jsx)(`div`,{className:z.emptyState,children:(0,B.jsx)(`h1`,{className:z.greeting,children:`Ready to claw through your to-do list?`})}):(0,B.jsx)(`div`,{className:z.messageArea,ref:ne,children:(0,B.jsxs)(`div`,{className:z.messageList,children:[l.map(t=>v===t.id&&t.role!==`thinking`?(0,B.jsx)(`div`,{className:z.messageBlock,children:(0,B.jsx)(Vn,{initial:t.rawContent??t.content,onSave:e=>void ce(t,e),onCancel:()=>b(null)})},t.id):(0,B.jsx)(Bn,{message:t,token:e.token,isStreaming:t.id===W.streamingMsgId,onCopy:M,onEdit:e=>b(e.id),onRegenerate:le,onApprovalAction:ue,approvalBusy:S,branchInfo:I.get(t.id)??null,onBranchNav:e=>{t.role!==`thinking`&&me(t,e)}},t.id)),(0,B.jsx)(`div`,{ref:R})]})}),f?(0,B.jsx)(`div`,{className:z.errorBanner,children:f}):null,(0,B.jsx)(re,{isStreaming:W.isStreaming,onSend:(e,t)=>void W.sendMessage(e,t),onStop:()=>void W.stopRequest(),onUploadFiles:de,token:e.token})]})]})}export{Gn as ChatPage};
|