@ashlr/hub 3.5.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +160 -0
- package/README.md +3 -0
- package/dist/build-identity.json +2 -2
- package/dist/cli/activation.d.ts +41 -0
- package/dist/cli/activation.js +485 -0
- package/dist/cli/activation.js.map +1 -0
- package/dist/core/daemon/cutoff-checkpoint-scheduler.js +7 -0
- package/dist/core/daemon/cutoff-checkpoint-scheduler.js.map +1 -1
- package/dist/core/daemon/loop.d.ts +19 -0
- package/dist/core/daemon/loop.js +235 -5
- package/dist/core/daemon/loop.js.map +1 -1
- package/dist/core/daemon/overnight-status.d.ts +152 -0
- package/dist/core/daemon/overnight-status.js +275 -0
- package/dist/core/daemon/overnight-status.js.map +1 -0
- package/dist/core/daemon/post-merge-halt.d.ts +212 -0
- package/dist/core/daemon/post-merge-halt.js +503 -0
- package/dist/core/daemon/post-merge-halt.js.map +1 -0
- package/dist/core/daemon/run-window.d.ts +218 -0
- package/dist/core/daemon/run-window.js +420 -0
- package/dist/core/daemon/run-window.js.map +1 -0
- package/dist/core/fleet/external-skill-audit.js +1 -1
- package/dist/core/fleet/external-skill-audit.js.map +1 -1
- package/dist/core/fleet/generated-repair-resolution.d.ts +36 -0
- package/dist/core/fleet/generated-repair-resolution.js +245 -0
- package/dist/core/fleet/generated-repair-resolution.js.map +1 -0
- package/dist/core/local-runtime/llama/config.d.ts +28 -6
- package/dist/core/local-runtime/llama/config.js +28 -6
- package/dist/core/local-runtime/llama/config.js.map +1 -1
- package/dist/core/local-runtime/llama/port.d.ts +17 -0
- package/dist/core/local-runtime/llama/port.js +47 -0
- package/dist/core/local-runtime/llama/port.js.map +1 -0
- package/dist/core/local-runtime/llama/proxy-host.d.ts +54 -0
- package/dist/core/local-runtime/llama/proxy-host.js +159 -0
- package/dist/core/local-runtime/llama/proxy-host.js.map +1 -0
- package/dist/core/local-runtime/llama/proxy-process.d.ts +148 -0
- package/dist/core/local-runtime/llama/proxy-process.js +250 -0
- package/dist/core/local-runtime/llama/proxy-process.js.map +1 -0
- package/dist/core/local-runtime/llama/proxy-record.d.ts +40 -0
- package/dist/core/local-runtime/llama/proxy-record.js +133 -0
- package/dist/core/local-runtime/llama/proxy-record.js.map +1 -0
- package/dist/core/local-runtime/llama/proxy-supervisor.d.ts +118 -0
- package/dist/core/local-runtime/llama/proxy-supervisor.js +511 -0
- package/dist/core/local-runtime/llama/proxy-supervisor.js.map +1 -0
- package/dist/core/web/public/next/assets/App-Cgi6j1Gk.css +1 -0
- package/dist/core/web/public/next/assets/App-vtaHB9mp.js +7 -0
- package/dist/core/web/public/next/assets/App-vtaHB9mp.js.map +1 -0
- package/dist/core/web/public/next/assets/ApprovalsSection-B-bFJ0I9.js +2 -0
- package/dist/core/web/public/next/assets/ApprovalsSection-B-bFJ0I9.js.map +1 -0
- package/dist/core/web/public/next/assets/ApprovalsSection-Su-NUTis.css +1 -0
- package/dist/core/web/public/next/assets/AutonomySection-CHjxJt2z.css +1 -0
- package/dist/core/web/public/next/assets/AutonomySection-DoqmsCjw.js +2 -0
- package/dist/core/web/public/next/assets/AutonomySection-DoqmsCjw.js.map +1 -0
- package/dist/core/web/public/next/assets/ChatSection-BfnLe5dT.css +1 -0
- package/dist/core/web/public/next/assets/ChatSection-vNPIJffd.js +80 -0
- package/dist/core/web/public/next/assets/ChatSection-vNPIJffd.js.map +1 -0
- package/dist/core/web/public/next/assets/ConfirmDialog-Dd2APQhB.js +2 -0
- package/dist/core/web/public/next/assets/ConfirmDialog-Dd2APQhB.js.map +1 -0
- package/dist/core/web/public/next/assets/{ConfirmDialog-cYuivhCX.css → ConfirmDialog-Dx15x0Ho.css} +1 -1
- package/dist/core/web/public/next/assets/Dialog-CPM9JxBc.js +2 -0
- package/dist/core/web/public/next/assets/Dialog-CPM9JxBc.js.map +1 -0
- package/dist/core/web/public/next/assets/Dialog-tQ8kFulD.css +1 -0
- package/dist/core/web/public/next/assets/DiffViewer-B84qVef9.js +7 -0
- package/dist/core/web/public/next/assets/DiffViewer-B84qVef9.js.map +1 -0
- package/dist/core/web/public/next/assets/DiffViewer-C8HHTnVE.css +1 -0
- package/dist/core/web/public/next/assets/McpSection-CEUpV_5X.js +2 -0
- package/dist/core/web/public/next/assets/McpSection-CEUpV_5X.js.map +1 -0
- package/dist/core/web/public/next/assets/McpSection-D88QlDpG.css +1 -0
- package/dist/core/web/public/next/assets/Meter--h3MmZS-.js +2 -0
- package/dist/core/web/public/next/assets/Meter--h3MmZS-.js.map +1 -0
- package/dist/core/web/public/next/assets/Meter-CLcr-4wS.css +1 -0
- package/dist/core/web/public/next/assets/{MutationTokenDialog-jWLLCxWn.css → MutationTokenDialog-CrfJ0PdD.css} +1 -1
- package/dist/core/web/public/next/assets/MutationTokenDialog-DA8t97XT.js +2 -0
- package/dist/core/web/public/next/assets/MutationTokenDialog-DA8t97XT.js.map +1 -0
- package/dist/core/web/public/next/assets/ResourcePoolConsoleApp-Bq7Vyud0.js +7 -0
- package/dist/core/web/public/next/assets/ResourcePoolConsoleApp-Bq7Vyud0.js.map +1 -0
- package/dist/core/web/public/next/assets/ResourcePoolConsoleApp-CM_8pJs6.css +1 -0
- package/dist/core/web/public/next/assets/RouteErrorBoundary-Badio_uO.js +2 -0
- package/dist/core/web/public/next/assets/RouteErrorBoundary-Badio_uO.js.map +1 -0
- package/dist/core/web/public/next/assets/RouteErrorBoundary-ekyMXAK8.css +1 -0
- package/dist/core/web/public/next/assets/SettingsSection-BII7TTSD.css +1 -0
- package/dist/core/web/public/next/assets/SettingsSection-BwrpQlpP.js +2 -0
- package/dist/core/web/public/next/assets/SettingsSection-BwrpQlpP.js.map +1 -0
- package/dist/core/web/public/next/assets/UniverseConsoleApp-Dh7A-hLD.css +1 -0
- package/dist/core/web/public/next/assets/UniverseConsoleApp-_FSohAdN.js +2 -0
- package/dist/core/web/public/next/assets/UniverseConsoleApp-_FSohAdN.js.map +1 -0
- package/dist/core/web/public/next/assets/UniverseView-Bqa8DH57.css +1 -0
- package/dist/core/web/public/next/assets/UniverseView-DqcXbed4.js +9 -0
- package/dist/core/web/public/next/assets/UniverseView-DqcXbed4.js.map +1 -0
- package/dist/core/web/public/next/assets/UsageSection-Bq6Daaby.js +2 -0
- package/dist/core/web/public/next/assets/UsageSection-Bq6Daaby.js.map +1 -0
- package/dist/core/web/public/next/assets/UsageSection-DwgNOYvi.css +1 -0
- package/dist/core/web/public/next/assets/VerseConsoleApp-CMkCizvL.css +1 -0
- package/dist/core/web/public/next/assets/VerseConsoleApp-CsIQv9id.js +3 -0
- package/dist/core/web/public/next/assets/VerseConsoleApp-CsIQv9id.js.map +1 -0
- package/dist/core/web/public/next/assets/charts-CTZJ-JrH.js +2 -0
- package/dist/core/web/public/next/assets/charts-CTZJ-JrH.js.map +1 -0
- package/dist/core/web/public/next/assets/charts-CsrtT4rk.css +1 -0
- package/dist/core/web/public/next/assets/fleet-model-ClBbQ0Uj.js +2 -0
- package/dist/core/web/public/next/assets/fleet-model-ClBbQ0Uj.js.map +1 -0
- package/dist/core/web/public/next/assets/format-BNYWGJat.js +2 -0
- package/dist/core/web/public/next/assets/format-BNYWGJat.js.map +1 -0
- package/dist/core/web/public/next/assets/global-D6bTxIRn.js +2 -0
- package/dist/core/web/public/next/assets/global-D6bTxIRn.js.map +1 -0
- package/dist/core/web/public/next/assets/global-z-JfD3ow.css +1 -0
- package/dist/core/web/public/next/assets/icons-D9vlf85u.js +2 -0
- package/dist/core/web/public/next/assets/icons-D9vlf85u.js.map +1 -0
- package/dist/core/web/public/next/assets/index-CZamKRUg.js +11 -0
- package/dist/core/web/public/next/assets/index-CZamKRUg.js.map +1 -0
- package/dist/core/web/public/next/assets/queries-B8eBnFox.js +2 -0
- package/dist/core/web/public/next/assets/queries-B8eBnFox.js.map +1 -0
- package/dist/core/web/public/next/assets/use-guarded-action-bzrVVAYq.js +2 -0
- package/dist/core/web/public/next/assets/use-guarded-action-bzrVVAYq.js.map +1 -0
- package/dist/core/web/public/next/assets/verse-model-CvtK6vP6.js +2 -0
- package/dist/core/web/public/next/assets/verse-model-CvtK6vP6.js.map +1 -0
- package/dist/core/web/public/next/assets/workspace-model-v0a1gl-C.js +2 -0
- package/dist/core/web/public/next/assets/workspace-model-v0a1gl-C.js.map +1 -0
- package/dist/core/web/public/next/index.html +1 -1
- package/dist/release-dependency-inventory.json +1 -1
- package/node_modules/marked/README.md +8 -0
- package/node_modules/marked/bin/main.js +12 -11
- package/node_modules/marked/lib/marked.d.ts +88 -25
- package/node_modules/marked/lib/marked.esm.js +50 -44
- package/node_modules/marked/lib/marked.esm.js.map +3 -3
- package/node_modules/marked/lib/marked.umd.js +50 -44
- package/node_modules/marked/lib/marked.umd.js.map +3 -3
- package/node_modules/marked/man/marked.1 +1 -1
- package/node_modules/marked/package.json +21 -21
- package/package.json +13 -8
- package/dist/core/web/public/next/assets/App-BCKqSppK.css +0 -1
- package/dist/core/web/public/next/assets/App-CsbPYQqy.js +0 -16
- package/dist/core/web/public/next/assets/App-CsbPYQqy.js.map +0 -1
- package/dist/core/web/public/next/assets/ApprovalsSection-CBZquyLK.js +0 -2
- package/dist/core/web/public/next/assets/ApprovalsSection-CBZquyLK.js.map +0 -1
- package/dist/core/web/public/next/assets/ApprovalsSection-CRP59wSb.css +0 -1
- package/dist/core/web/public/next/assets/AutonomySection-CQVpEdCE.js +0 -2
- package/dist/core/web/public/next/assets/AutonomySection-CQVpEdCE.js.map +0 -1
- package/dist/core/web/public/next/assets/AutonomySection-DTN6m6QE.css +0 -1
- package/dist/core/web/public/next/assets/ChatSection-DiRvNX3Q.css +0 -1
- package/dist/core/web/public/next/assets/ChatSection-DmE9K0Tg.js +0 -77
- package/dist/core/web/public/next/assets/ChatSection-DmE9K0Tg.js.map +0 -1
- package/dist/core/web/public/next/assets/ConfirmDialog-deO0C0iY.js +0 -2
- package/dist/core/web/public/next/assets/ConfirmDialog-deO0C0iY.js.map +0 -1
- package/dist/core/web/public/next/assets/Dialog-CNd7q89m.js +0 -2
- package/dist/core/web/public/next/assets/Dialog-CNd7q89m.js.map +0 -1
- package/dist/core/web/public/next/assets/Dialog-DxN7RgB5.css +0 -1
- package/dist/core/web/public/next/assets/DiffViewer-DTO0KRuG.js +0 -7
- package/dist/core/web/public/next/assets/DiffViewer-DTO0KRuG.js.map +0 -1
- package/dist/core/web/public/next/assets/DiffViewer-hN7X6wGT.css +0 -1
- package/dist/core/web/public/next/assets/Epistemic-53PikaUI.js +0 -2
- package/dist/core/web/public/next/assets/Epistemic-53PikaUI.js.map +0 -1
- package/dist/core/web/public/next/assets/Epistemic-DiyMyeaN.css +0 -1
- package/dist/core/web/public/next/assets/Meter-CGBsbXUX.css +0 -1
- package/dist/core/web/public/next/assets/Meter-DRWZQgr1.js +0 -2
- package/dist/core/web/public/next/assets/Meter-DRWZQgr1.js.map +0 -1
- package/dist/core/web/public/next/assets/MutationTokenDialog-DYF8n_RD.js +0 -2
- package/dist/core/web/public/next/assets/MutationTokenDialog-DYF8n_RD.js.map +0 -1
- package/dist/core/web/public/next/assets/RefreshIndicator-DXJQXKyA.js +0 -2
- package/dist/core/web/public/next/assets/RefreshIndicator-DXJQXKyA.js.map +0 -1
- package/dist/core/web/public/next/assets/RefreshIndicator-O7jUBOmX.css +0 -1
- package/dist/core/web/public/next/assets/ResourcePoolConsoleApp-DLl4DbGG.css +0 -1
- package/dist/core/web/public/next/assets/ResourcePoolConsoleApp-hDSEFdLU.js +0 -7
- package/dist/core/web/public/next/assets/ResourcePoolConsoleApp-hDSEFdLU.js.map +0 -1
- package/dist/core/web/public/next/assets/RouteErrorBoundary-BIpdnxp-.css +0 -1
- package/dist/core/web/public/next/assets/RouteErrorBoundary-CZd7ln8v.js +0 -2
- package/dist/core/web/public/next/assets/RouteErrorBoundary-CZd7ln8v.js.map +0 -1
- package/dist/core/web/public/next/assets/SettingsSection-C9Qs9JWW.js +0 -2
- package/dist/core/web/public/next/assets/SettingsSection-C9Qs9JWW.js.map +0 -1
- package/dist/core/web/public/next/assets/SettingsSection-DGJMdUh2.css +0 -1
- package/dist/core/web/public/next/assets/Skeleton-D2JaTXyv.css +0 -1
- package/dist/core/web/public/next/assets/Skeleton-YkcOpgFb.js +0 -2
- package/dist/core/web/public/next/assets/Skeleton-YkcOpgFb.js.map +0 -1
- package/dist/core/web/public/next/assets/StatusBadge-DJw0LSPg.js +0 -2
- package/dist/core/web/public/next/assets/StatusBadge-DJw0LSPg.js.map +0 -1
- package/dist/core/web/public/next/assets/StatusBadge-TpDqZf6K.css +0 -1
- package/dist/core/web/public/next/assets/TableView-Bj-w1O6o.js +0 -2
- package/dist/core/web/public/next/assets/TableView-Bj-w1O6o.js.map +0 -1
- package/dist/core/web/public/next/assets/TableView-R6Yeztp1.css +0 -1
- package/dist/core/web/public/next/assets/UniverseConsoleApp-Bs2fxaen.js +0 -2
- package/dist/core/web/public/next/assets/UniverseConsoleApp-Bs2fxaen.js.map +0 -1
- package/dist/core/web/public/next/assets/UniverseConsoleApp-CiZZxRPV.css +0 -1
- package/dist/core/web/public/next/assets/UniverseView-B6b2hw-8.js +0 -9
- package/dist/core/web/public/next/assets/UniverseView-B6b2hw-8.js.map +0 -1
- package/dist/core/web/public/next/assets/UniverseView-gBxl6yum.css +0 -1
- package/dist/core/web/public/next/assets/UsageSection-C__ziNkV.js +0 -2
- package/dist/core/web/public/next/assets/UsageSection-C__ziNkV.js.map +0 -1
- package/dist/core/web/public/next/assets/UsageSection-UUYDidOg.css +0 -1
- package/dist/core/web/public/next/assets/VerseConsoleApp-Cu5aG6J6.js +0 -3
- package/dist/core/web/public/next/assets/VerseConsoleApp-Cu5aG6J6.js.map +0 -1
- package/dist/core/web/public/next/assets/VerseConsoleApp-mOAXvWa6.css +0 -1
- package/dist/core/web/public/next/assets/fleet-model-DXCfVtNW.js +0 -2
- package/dist/core/web/public/next/assets/fleet-model-DXCfVtNW.js.map +0 -1
- package/dist/core/web/public/next/assets/format-fggwu_Rs.js +0 -2
- package/dist/core/web/public/next/assets/format-fggwu_Rs.js.map +0 -1
- package/dist/core/web/public/next/assets/global-BHjd6fVZ.js +0 -2
- package/dist/core/web/public/next/assets/global-BHjd6fVZ.js.map +0 -1
- package/dist/core/web/public/next/assets/global-BeRYd1Bu.css +0 -1
- package/dist/core/web/public/next/assets/index-CJ-e8YA9.js +0 -2
- package/dist/core/web/public/next/assets/index-CJ-e8YA9.js.map +0 -1
- package/dist/core/web/public/next/assets/index-CpgkRaTi.js +0 -51
- package/dist/core/web/public/next/assets/index-CpgkRaTi.js.map +0 -1
- package/dist/core/web/public/next/assets/queries-856qUN3Y.js +0 -2
- package/dist/core/web/public/next/assets/queries-856qUN3Y.js.map +0 -1
- package/dist/core/web/public/next/assets/use-guarded-action-Bqa2v0a-.css +0 -1
- package/dist/core/web/public/next/assets/use-guarded-action-DwaESKVy.js +0 -2
- package/dist/core/web/public/next/assets/use-guarded-action-DwaESKVy.js.map +0 -1
- package/dist/core/web/public/next/assets/verse-model-Dllo8rRt.js +0 -2
- package/dist/core/web/public/next/assets/verse-model-Dllo8rRt.js.map +0 -1
- package/dist/core/web/public/next/assets/workspace-model-JgmWDKt4.js +0 -2
- package/dist/core/web/public/next/assets/workspace-model-JgmWDKt4.js.map +0 -1
- /package/node_modules/marked/{LICENSE.md → LICENSE} +0 -0
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import{j as r,r as p}from"./index-CpgkRaTi.js";import{M as Fa}from"./MutationTokenDialog-DYF8n_RD.js";import{u as Ha}from"./RouteErrorBoundary-CZd7ln8v.js";import{j as Cr,f as Xt,w as On,e as Qt,y as Ba,d as Ua,z as qa,B as Wa,C as Ga,E as Ls,F as Ka,u as Va,G as Xa,n as Ya,D as Za,A as Qa}from"./global-BHjd6fVZ.js";import{D as Ir}from"./Dialog-CNd7q89m.js";import{M as Ms}from"./Meter-DRWZQgr1.js";import{s as ln,S as cn,a as $r,b as Lr,g as Kn,E as Jt,f as Mr,p as Vn,c as Ja,i as eo,d as to,e as no,h as so,j as Dr,k as At,l as ro,m as en,n as ao,o as oo}from"./verse-model-Dllo8rRt.js";import{w as io,M as lo,v as co,r as uo,b as ho,c as po}from"./workspace-model-JgmWDKt4.js";import{v as ft,f as fo,S as Pr,P as mo,b as Or,i as zr,c as go,d as _o,C as xo,A as yo,V as bo,T as ko,e as wo,g as Ds,u as To,h as So,j as jo,l as No,k as Eo,r as vo,s as Ao,m as Ro,n as Co,o as Io,p as $o,q as Lo,t as Mo,w as qt,x as Ps,y as Os,z as zs}from"./VerseConsoleApp-Cu5aG6J6.js";import{R as Fr}from"./RefreshIndicator-DXJQXKyA.js";import{S as Ee}from"./Skeleton-YkcOpgFb.js";import{S as Hr}from"./StatusBadge-DJw0LSPg.js";import{p as Br,D as Do,l as Po,t as Oo}from"./DiffViewer-DTO0KRuG.js";import"./index-CJ-e8YA9.js";import"./queries-856qUN3Y.js";const zo={ready:"ready",tight:"tight",exhausted:"blocked","signed-out":"blocked",unknown:"unread"};function Ur(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return null;const n=t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return new Date().toDateString()===t.toDateString()?`resets ${n}`:`resets ${t.toLocaleDateString([],{month:"short",day:"numeric"})} at ${n}`}function Fo(e,t){const n=`${e}_`;let a=t;for(;a.startsWith(n)&&a.length>n.length;)a=a.slice(n.length);return Lr(a)}function Fs(e,t){const n=t.resetDescription??(t.resetsAt===null?null:Ur(t.resetsAt));return{id:t.id,label:Fo(e,t.id),usedPercent:t.limitReached||!t.measured?null:t.usedPercent,limitReached:t.limitReached,resetText:n,resetsAt:t.resetsAt}}function Ho(e){const t=typeof e.usedPercent=="number"&&Number.isFinite(e.usedPercent)?Math.max(0,Math.min(100,e.usedPercent)):null,n=t!==null&&t>=100;return{id:e.id,label:Lr(e.id),usedPercent:n?null:t,limitReached:n,resetText:e.resetsAt===null?null:Ur(e.resetsAt),resetsAt:e.resetsAt}}function Bo(e){if(e===null)return{phrase:null,title:null};if(e.unlimited)return{phrase:"credits unlimited",title:null};if(!e.hasCredits)return{phrase:null,title:null};if(e.balance===null)return{phrase:"credits available",title:null};const t=Number.parseFloat(e.balance);return Number.isFinite(t)?{phrase:`${t.toFixed(2)} credits left`,title:e.balance}:{phrase:"credits available",title:e.balance}}function Uo(e){const t=ln(e),n=e.health.state==="ready",a=t!==null?"blocked":n?"ready":"unread";return{kind:"local",plan:null,cls:a,word:cn[a],summary:t??(n?"runs on this machine":"readiness not reported"),binding:null,others:[],credits:null,creditsTitle:null,notes:e.health.summary===null?[]:[e.health.summary],evidenceSource:null,observedAt:e.health.observedAt,extended:!1}}function qo(e){const t=$r(e),n=e.health.windows.map(Ho),a=n.find(d=>d.limitReached)??null,s=n.filter(d=>d.usedPercent!==null),i=s.length===0?null:s.reduce((d,f)=>(f.usedPercent??0)>(d.usedPercent??0)?f:d),o=a??i,l=ln(e),u=l!==null?"blocked":t.cls;return{kind:"subscription",plan:null,cls:u,word:cn[u],summary:l??t.text,binding:o,others:o===null?n:n.filter(d=>d.id!==o.id),credits:null,creditsTitle:null,notes:[],evidenceSource:null,observedAt:e.health.observedAt,extended:!1}}function nt(e){if(e.engine==="local")return Uo(e);const t=e.capacity;if(t===void 0)return qo(e);const n=t.windows.map(f=>Fs(e.engine,f)),a=t.binding,s=a===null?null:n.find(f=>f.id===a.id)??Fs(e.engine,a),i=s===null?n:n.filter(f=>f.id!==s.id),o=Bo(t.credits),l=ln(e),u=l!==null?"blocked":zo[t.usability];let d;return t.usability==="signed-out"?d="signed out — reconnect this account":l!==null?d=l:s===null?d="no capacity reading":s.limitReached?d=t.usability==="tight"&&o.phrase!==null?`${s.label} limit reached · credits still spendable`:`${s.label} limit reached`:s.usedPercent===null?d="no capacity reading":d=`${Math.round(s.usedPercent)}% of ${s.label} used`,{kind:"subscription",plan:t.planType,cls:u,word:cn[u],summary:d,binding:s,others:i,credits:o.phrase,creditsTitle:o.title,notes:[...t.notes],evidenceSource:t.evidenceSource,observedAt:t.observedAt??e.health.observedAt,extended:!0}}function Wo(e){switch(e){case"collector":return null;case"shared-evidence":return"read from another collector’s shared evidence, not probed here";case"baseline":return"operator-seeded baseline, not a live reading";case"none":return"no evidence source — nothing here was measured";default:return null}}function Xn(e,t){const n=[e.label];return t.plan!==null&&n.push(t.plan),n.push(t.word),n.push(t.summary),t.credits!==null&&n.push(t.credits),t.binding?.resetText!=null&&n.push(t.binding.resetText),n.join(" · ")}function Hs(e){return e==="tight"||e==="blocked"}const Go="_chip_rrd6q_8",Ko="_chipGlyph_rrd6q_22",Vo="_window_rrd6q_35",Xo="_windowLead_rrd6q_36",Yo="_windowLabel_rrd6q_43",Zo="_pct_rrd6q_44",Qo="_flag_rrd6q_60",Jo="_unknownHead_rrd6q_69",ei="_unknownValue_rrd6q_76",ti="_unknownRule_rrd6q_85",ni="_reset_rrd6q_93",si="_note_rrd6q_104",ri="_noteHead_rrd6q_110",ai="_plan_rrd6q_117",oi="_noteSummary_rrd6q_130",ii="_credits_rrd6q_137",ce={chip:Go,chipGlyph:Ko,window:Vo,windowLead:Xo,windowLabel:Yo,pct:Zo,flag:Qo,unknownHead:Jo,unknownValue:ei,unknownRule:ti,reset:ni,note:si,noteHead:ri,plan:ai,noteSummary:oi,credits:ii},li={ready:"✓",tight:"◑",blocked:"▮",unread:"?"};function Yn({view:e,title:t}){return r.jsxs("span",{className:ce.chip,"data-capacity":e.cls,title:t??e.summary,children:[r.jsx("span",{className:ce.chipGlyph,"aria-hidden":"true",children:li[e.cls]}),e.word]})}function qr({windowView:e,ariaPrefix:t,prominent:n=!1}){const a=`${t} ${e.label}`;if(e.limitReached)return r.jsxs("div",{className:n?ce.windowLead:ce.window,children:[r.jsx(Ms,{value:100,max:100,tone:"danger",label:r.jsx("span",{className:ce.windowLabel,children:e.label}),valueText:r.jsx("span",{className:ce.flag,children:"limit reached"}),"aria-label":`${a}: the provider flagged this window as rate-limited, so no percentage was measured`}),e.resetText===null?null:r.jsx("p",{className:ce.reset,children:e.resetText})]});if(e.usedPercent===null)return r.jsxs("div",{className:n?ce.windowLead:ce.window,children:[r.jsxs("div",{className:ce.unknownHead,children:[r.jsx("span",{className:ce.windowLabel,children:e.label}),r.jsx("span",{className:ce.unknownValue,children:"no reading"})]}),r.jsx("hr",{className:ce.unknownRule,"aria-hidden":"true"}),e.resetText===null?null:r.jsx("p",{className:ce.reset,children:e.resetText})]});const s=Math.round(e.usedPercent);return r.jsxs("div",{className:n?ce.windowLead:ce.window,children:[r.jsx(Ms,{value:s,max:100,label:r.jsx("span",{className:ce.windowLabel,children:e.label}),valueText:r.jsxs("span",{className:ce.pct,children:[s,"%"]}),"aria-label":`${a} used`}),e.resetText===null?null:r.jsx("p",{className:ce.reset,children:e.resetText})]})}function ci({seat:e,className:t}){const n=nt(e);return r.jsxs("div",{className:`${ce.note} ${t??""}`,"data-capacity":n.cls,children:[r.jsxs("div",{className:ce.noteHead,children:[r.jsx(Yn,{view:n}),n.plan===null?null:r.jsx("span",{className:ce.plan,children:n.plan}),r.jsx("span",{className:ce.noteSummary,children:n.summary})]}),n.binding===null?null:r.jsx(qr,{windowView:n.binding,ariaPrefix:e.label,prominent:!0}),n.credits===null?null:r.jsxs("p",{className:ce.credits,title:n.creditsTitle??void 0,children:[n.credits," — credits are independent of the window"]})]})}const ui="_composer_1q5ss_5",di="_box_1q5ss_10",hi="_textarea_1q5ss_21",pi="_boxListening_1q5ss_28",fi="_row_1q5ss_47",mi="_spacer_1q5ss_53",gi="_engineDot_1q5ss_60",_i="_seatField_1q5ss_69",xi="_seatFieldCompact_1q5ss_70",yi="_fieldLabel_1q5ss_71",bi="_seatSelect_1q5ss_72",ki="_seatPillWrap_1q5ss_89",wi="_seatPill_1q5ss_89",Ti="_seatPillText_1q5ss_107",Si="_seatMenu_1q5ss_109",ji="_seatMenuHeading_1q5ss_126",Ni="_seatMenuEmpty_1q5ss_134",Ei="_seatMenuItem_1q5ss_135",vi="_seatMenuText_1q5ss_148",Ai="_seatMenuPrimary_1q5ss_149",Ri="_seatMenuSecondary_1q5ss_150",Ci="_seatMenuCapacity_1q5ss_156",Ii="_dictationWrap_1q5ss_167",$i="_dictation_1q5ss_167",Li="_dictationLive_1q5ss_182",Mi="_dictationPulse_1q5ss_183",Di="_dictationHint_1q5ss_191",Pi="_dictationError_1q5ss_212",Oi="_send_1q5ss_215",zi="_stop_1q5ss_216",Fi="_stopIcon_1q5ss_235",Hi="_help_1q5ss_238",Bi="_helpQuiet_1q5ss_246",Ui="_helpError_1q5ss_255",qi="_cost_1q5ss_283",Wi="_costFigure_1q5ss_295",U={composer:ui,box:di,textarea:hi,boxListening:pi,row:fi,spacer:mi,"engine-claude":"_engine-claude_1q5ss_56","engine-codex":"_engine-codex_1q5ss_57","engine-grok":"_engine-grok_1q5ss_58","engine-local":"_engine-local_1q5ss_59",engineDot:gi,seatField:_i,seatFieldCompact:xi,fieldLabel:yi,seatSelect:bi,seatPillWrap:ki,seatPill:wi,seatPillText:Ti,seatMenu:Si,seatMenuHeading:ji,seatMenuEmpty:Ni,seatMenuItem:Ei,seatMenuText:vi,seatMenuPrimary:Ai,seatMenuSecondary:Ri,seatMenuCapacity:Ci,dictationWrap:Ii,dictation:$i,dictationLive:Li,dictationPulse:Mi,"verse-ring":"_verse-ring_1q5ss_1",dictationHint:Di,dictationError:Pi,send:Oi,stop:zi,stopIcon:Fi,help:Hi,helpQuiet:Bi,helpError:Ui,cost:qi,costFigure:Wi};function jn(e){return JSON.stringify([e.seatId,e.model])}function Gi(e){try{const t=JSON.parse(e);if(!Array.isArray(t)||t.length!==2)return null;const[n,a]=t;return typeof n!="string"||typeof a!="string"?null:{seatId:n,model:a}}catch{return null}}function Bs(e){for(const t of Kn(e))for(const n of t.seats)if(!(n.health.state==="unavailable"||n.models.length===0))return{seatId:n.id,model:n.models[0].id};return null}function Ki({seats:e,value:t,onChange:n,disabled:a=!1,label:s="Seat and model",id:i,compact:o=!1}){const l=p.useId(),u=i??l,d=Kn(e),f=t?jn(t):"",y=t&&e.some(m=>m.id===t.seatId&&m.models.some(S=>S.id===t.model));return r.jsxs("label",{className:`${U.seatField} ${o?U.seatFieldCompact:""}`,htmlFor:u,children:[r.jsx("span",{className:o?"visually-hidden":U.fieldLabel,children:s}),r.jsxs("select",{id:u,className:U.seatSelect,value:y?f:"",disabled:a||d.length===0,"aria-label":o?s:void 0,onChange:m=>{const S=Gi(m.target.value);S&&n(S)},children:[y?null:r.jsx("option",{value:"",disabled:!0,children:d.length===0?"No seats discovered":"Choose a seat…"}),d.map(m=>r.jsx("optgroup",{label:Jt[m.engine],children:m.seats.flatMap(S=>{const g=ln(S),_=nt(S),x=g!==null?`unavailable: ${g}`:_.cls==="unread"||_.kind==="local"?null:`${_.plan===null?"":`${_.plan} · `}${_.word} · ${_.summary}`,w=x===null?void 0:x.charAt(0).toUpperCase()+x.slice(1);return S.models.map(k=>r.jsxs("option",{value:jn({seatId:S.id,model:k.id}),disabled:g!==null,title:w,children:[S.label," — ",k.label,x?` (${x})`:""]},jn({seatId:S.id,model:k.id})))})},m.engine))]})]})}const Vi="_width_1185y_1",Xi="_form_1185y_3",Yi="_field_1185y_4",Zi="_label_1185y_5",Qi="_optional_1185y_13",Ji="_select_1185y_15",el="_input_1185y_16",tl="_hint_1185y_40",nl="_error_1185y_41",sl="_actions_1185y_49",rl="_cancel_1185y_50",al="_create_1185y_51",ol="_capacity_1185y_72",il="_rootRow_1185y_78",ll="_removeRoot_1185y_87",cl="_addRoot_1185y_88",oe={width:Vi,form:Xi,field:Yi,label:Zi,optional:Qi,select:Ji,input:el,hint:tl,error:nl,actions:sl,cancel:rl,create:al,capacity:ol,rootRow:il,removeRoot:ll,addRoot:cl},Nn="\0workspace:",yt="\0other";function ul({open:e,onClose:t,projects:n,seats:a,workspaces:s=[],initialProjectPath:i,initialSeat:o,busy:l=!1,error:u,onCreate:d}){const f=p.useId(),y=p.useId(),m=p.useId(),S=p.useId(),g=p.useId(),_=p.useRef(null),[x,w]=p.useState(""),[k,R]=p.useState(""),[j,O]=p.useState(null),[G,pe]=p.useState(""),[de,Q]=p.useState(null),[q,ie]=p.useState([]),te=p.useMemo(()=>[...n].sort((z,F)=>Number(F.enrolled)-Number(z.enrolled)||z.name.localeCompare(F.name)),[n]),fe=p.useRef({initialProjectPath:i,initialSeat:o,projects:n,seats:a,sortedProjects:te});fe.current={initialProjectPath:i,initialSeat:o,projects:n,seats:a,sortedProjects:te},p.useEffect(()=>{if(!e)return;const{initialProjectPath:z,initialSeat:F,projects:ke,seats:Te,sortedProjects:$e}=fe.current,M=z&&ke.some(K=>K.path===z)?z:null;w(M??(z?yt:$e[0]?.path??yt)),R(M?"":z??""),O(F??Bs(Te)),pe(""),Q(null),ie([])},[e]),p.useEffect(()=>{!e||j!==null||a.length===0||O(o??Bs(a))},[e,j,a,o]);const V=Cr(ft);p.useEffect(()=>{e&&V()},[e,V]);const me=x.startsWith(Nn),ne=me?x.slice(Nn.length):null,X=me?"":x===yt?k.trim():x,se=j===null?null:a.find(z=>z.id===j.seatId)??null,J=se?.health.state==="unavailable",N=!l&&(me||X.length>0)&&j!==null&&!J,$=se===null||se.engine!=="grok";function P(z){if(z.preventDefault(),!j){Q("Pick a seat first.");return}if(ne!==null){Q(null);const K={workspaceId:ne,seatId:j.seatId,model:j.model};delete K.projectPath;const be=G.trim();be&&(K.title=be),d(K);return}const F=co(X,q);if(!F.ok){Q(F.error);return}Q(null);const[ke,...Te]=F.roots,$e={projectPath:ke,seatId:j.seatId,model:j.model};Te.length>0&&($e.extraRoots=Te);const M=G.trim();M&&($e.title=M),d($e)}const ye=de??u??null;return r.jsx(Ir,{open:e,onClose:t,titleId:f,title:"New chat",initialFocusRef:_,widthClassName:oe.width,children:r.jsxs("form",{className:oe.form,onSubmit:P,noValidate:!0,children:[r.jsxs("label",{className:oe.field,htmlFor:y,children:[r.jsx("span",{className:oe.label,children:"Project"}),r.jsxs("select",{id:y,ref:_,value:x,onChange:z=>w(z.target.value),className:oe.select,children:[s.length>0?r.jsx("optgroup",{label:"Workspaces",children:s.map(z=>r.jsxs("option",{value:`${Nn}${z.id}`,children:[z.name," — ",io(z)]},z.id))}):null,te.map(z=>r.jsxs("option",{value:z.path,children:[z.name,z.enrolled?"":" (recent)"," — ",z.path]},z.path)),r.jsx("option",{value:yt,children:"Other folder…"})]})]}),x===yt&&!me?r.jsxs("label",{className:oe.field,htmlFor:m,children:[r.jsx("span",{className:oe.label,children:"Folder path"}),r.jsx("input",{id:m,className:oe.input,value:k,onChange:z=>R(z.target.value),placeholder:"/absolute/path/to/project",autoComplete:"off",spellCheck:!1})]}):null,me?null:r.jsxs("div",{className:oe.field,children:[r.jsxs("span",{className:oe.label,children:["Also include ",r.jsx("span",{className:oe.optional,children:"optional"})]}),q.map((z,F)=>r.jsxs("div",{className:oe.rootRow,children:[r.jsx("input",{className:oe.input,value:z,onChange:ke=>ie(q.map((Te,$e)=>$e===F?ke.target.value:Te)),placeholder:"/absolute/path/to/another/folder","aria-label":`Additional folder ${F+1}`,autoComplete:"off",spellCheck:!1}),r.jsx("button",{type:"button",className:oe.removeRoot,onClick:()=>ie(q.filter((ke,Te)=>Te!==F)),"aria-label":`Remove additional folder ${F+1}`,children:"Remove"})]},F)),q.length+1<lo?r.jsx("button",{type:"button",className:oe.addRoot,onClick:()=>ie([...q,""]),children:"Add a folder"}):null,q.length>0?r.jsx("p",{className:oe.hint,children:$?"The agent can read and write these folders for the life of this chat. Enrolment is separate — an unenrolled folder stays out of reach of the autonomous lane.":"This seat’s CLI takes no additional-directory flag, so it will reach only the primary folder. Pick a Claude or Codex seat to use more than one."}):null]}),r.jsx(Ki,{id:g,seats:a,value:j,onChange:O}),se===null?null:r.jsx(ci,{seat:se,className:oe.capacity}),a.length===0?r.jsx("p",{className:oe.hint,children:"No seats yet — connect an account or start Ollama, then reload."}):null,r.jsxs("label",{className:oe.field,htmlFor:S,children:[r.jsxs("span",{className:oe.label,children:["Title ",r.jsx("span",{className:oe.optional,children:"optional"})]}),r.jsx("input",{id:S,className:oe.input,value:G,onChange:z=>pe(z.target.value),placeholder:"Defaults to your first message",maxLength:120})]}),ye?r.jsx("p",{role:"alert",className:oe.error,children:ye}):null,r.jsxs("div",{className:oe.actions,children:[r.jsx("button",{type:"button",className:oe.cancel,onClick:t,children:"Cancel"}),r.jsx("button",{type:"submit",className:oe.create,disabled:!N,children:l?"Creating…":"Start chat"})]})]})})}const dl="_width_k2wwr_1",hl="_input_k2wwr_3",pl="_list_k2wwr_19",fl="_row_k2wwr_27",ml="_rowActive_k2wwr_41",gl="_marker_k2wwr_44",_l="_rowText_k2wwr_50",xl="_rowPrimary_k2wwr_51",yl="_rowSecondary_k2wwr_58",bl="_rowTrailing_k2wwr_67",kl="_emptyRow_k2wwr_76",De={width:dl,input:hl,list:pl,row:fl,rowActive:ml,marker:gl,"engine-claude":"_engine-claude_k2wwr_45","engine-codex":"_engine-codex_k2wwr_46","engine-grok":"_engine-grok_k2wwr_47","engine-local":"_engine-local_k2wwr_48",rowText:_l,rowPrimary:xl,rowSecondary:yl,rowTrailing:bl,emptyRow:kl};function wl({open:e,onClose:t,sessions:n,seats:a,projects:s,onSelectSession:i,onNewChat:o}){const l=p.useId(),u=p.useId(),d=p.useRef(null),[f,y]=p.useState(""),[m,S]=p.useState(0);p.useEffect(()=>{e&&(y(""),S(0))},[e]);const g=p.useMemo(()=>{const x=f.trim().toLowerCase(),w=[...n].sort((j,O)=>O.updatedAt.localeCompare(j.updatedAt)).map(j=>({id:`session:${j.id}`,kind:"session",engine:j.engine,primary:j.title||"Untitled chat",secondary:`${Vn(j.projectPath,s)} · ${Ja(a,j)} · ${j.model}`,trailing:Mr(j.updatedAt),run:()=>{i(j.id),t()}})),k=a.filter(j=>j.health.state!=="unavailable"&&j.models.length>0).map(j=>({id:`seat:${j.id}`,kind:"seat",engine:j.engine,primary:`New chat on ${j.label}`,secondary:j.models[0].label,trailing:"⌘N",run:()=>{o({seatId:j.id,model:j.models[0].id}),t()}})),R=[...w,...k];return x?R.filter(j=>j.primary.toLowerCase().includes(x)||j.secondary.toLowerCase().includes(x)):R},[f,n,a,s,i,o,t]);p.useEffect(()=>{m>=g.length&&S(0)},[g.length,m]);function _(x){x.key==="ArrowDown"?(x.preventDefault(),S(w=>g.length?(w+1)%g.length:0)):x.key==="ArrowUp"?(x.preventDefault(),S(w=>g.length?(w-1+g.length)%g.length:0)):x.key==="Enter"&&(x.preventDefault(),g[m]?.run())}return r.jsxs(Ir,{open:e,onClose:t,titleId:l,title:"Switch chat",initialFocusRef:d,widthClassName:De.width,children:[r.jsx("input",{ref:d,className:De.input,value:f,placeholder:"Search chats or start one on a seat…",role:"combobox","aria-expanded":"true","aria-controls":u,"aria-activedescendant":g[m]?`${u}-${m}`:void 0,"aria-autocomplete":"list",autoComplete:"off",onChange:x=>{y(x.target.value),S(0)},onKeyDown:_}),r.jsx("ul",{id:u,role:"listbox",className:De.list,"aria-label":"Chats and seats",children:g.length===0?r.jsx("li",{className:De.emptyRow,children:"Nothing matches."}):g.map((x,w)=>r.jsxs("li",{id:`${u}-${w}`,role:"option","aria-selected":w===m,className:`${De.row} ${De[`engine-${x.engine}`]??""} ${w===m?De.rowActive:""}`,"data-kind":x.kind,onMouseEnter:()=>S(w),onMouseDown:k=>k.preventDefault(),onClick:x.run,children:[r.jsx("span",{className:De.marker,"aria-hidden":"true"}),r.jsxs("span",{className:De.rowText,children:[r.jsx("span",{className:De.rowPrimary,children:x.primary}),r.jsx("span",{className:De.rowSecondary,children:x.secondary})]}),r.jsx("span",{className:De.rowTrailing,"aria-hidden":"true",children:x.trailing})]},x.id))})]})}const Tl="_roots_1h85g_8",Sl="_title_1h85g_10",jl="_count_1h85g_22",Nl="_workspace_1h85g_30",El="_list_1h85g_36",vl="_root_1h85g_8",Al="_rootHead_1h85g_57",Rl="_name_1h85g_64",Cl="_badge_1h85g_72",Il="_git_1h85g_80",$l="_remote_1h85g_81",Ll="_caveat_1h85g_82",Ml="_note_1h85g_99",Dl="_error_1h85g_100",Ce={roots:Tl,title:Sl,count:jl,workspace:Nl,list:El,root:vl,rootHead:Al,name:Rl,badge:Cl,git:Il,remote:$l,caveat:Ll,note:Ml,error:Dl};function Pl({session:e,refreshKey:t=0}){const[n,a]=p.useState(null),[s,i]=p.useState(null),o=e?.id??null;return p.useEffect(()=>{if(!o){a(null);return}const l=new AbortController;return i(null),fo(o,l.signal).then(u=>a(u)).catch(u=>{l.signal.aborted||(a(null),i(u instanceof Error?u.message:"could not read this chat’s folders"))}),()=>l.abort()},[o,t]),!e||n!==null&&n.roots.length<=1&&n.workspaceId===null?null:r.jsxs("section",{className:Ce.roots,"aria-labelledby":"verse-res-roots",children:[r.jsxs("h3",{id:"verse-res-roots",className:Ce.title,children:["Folders",n?r.jsx("span",{className:Ce.count,children:n.roots.length}):null]}),n?.workspaceName?r.jsxs("p",{className:Ce.workspace,children:["Workspace ",r.jsx("strong",{children:n.workspaceName})]}):null,s?r.jsx("p",{role:"alert",className:Ce.error,children:s}):null,r.jsx("ul",{className:Ce.list,children:(n?.roots??[]).map(l=>{const u=uo(l),d=ho(l);return r.jsxs("li",{className:Ce.root,"data-tone":po(l),children:[r.jsxs("div",{className:Ce.rootHead,children:[r.jsx("span",{className:Ce.name,title:l.path,children:l.name}),r.jsx("span",{className:Ce.badge,children:l.primary?"primary":"added"})]}),r.jsx("p",{className:Ce.git,children:u??"not a git repo"}),l.git?.remote?r.jsx("p",{className:Ce.remote,children:l.git.remote}):null,d?r.jsx("p",{className:Ce.caveat,children:d}):null]},l.path)})}),(n?.notes??[]).map(l=>r.jsx("p",{className:Ce.note,children:l},l))]})}const Wr="ashlr.verse.resources.v1",zn=80,Ol=200;function Yt(){return{collapsedGroups:[],seats:{}}}function zl(e){return e!=="blocked"}function Fl(e,t){return!e.collapsedGroups.includes(t)}function Gr(e,t,n){const a=e.seats[t];return typeof a=="boolean"?a:zl(n)}function Hl(e,t){const n=e.collapsedGroups.includes(t)?e.collapsedGroups.filter(a=>a!==t):[...e.collapsedGroups,t];return{...e,collapsedGroups:n}}function Bl(e,t,n){if(!Kr(t))return e;const a={...e.seats,[t]:!Gr(e,t,n)};return{...e,seats:ql(a)}}function Ul(e){return e.kind==="local"?[]:e.binding===null?[...e.others]:[e.binding,...e.others.filter(t=>t.id!==e.binding.id)]}function Kr(e){return e.length>0&&e.length<=Ol&&e!=="__proto__"&&e!=="constructor"&&e!=="prototype"}function ql(e){const t=Object.entries(e);return t.length<=zn?{...e}:Object.fromEntries(t.slice(t.length-zn))}function Wl(e){if(e===null||e==="")return Yt();let t;try{t=JSON.parse(e)}catch{return Yt()}if(!t||typeof t!="object"||Array.isArray(t))return Yt();const n=t,a=[];if(Array.isArray(n.collapsedGroups))for(const o of n.collapsedGroups)typeof o=="string"&&eo(o)&&!a.includes(o)&&a.push(o);const s={},i=n.seats;if(i&&typeof i=="object"&&!Array.isArray(i)){for(const[o,l]of Object.entries(i))if(!(!Kr(o)||typeof l!="boolean")){if(Object.keys(s).length>=zn)break;Object.defineProperty(s,o,{value:l,enumerable:!0,writable:!0,configurable:!0})}}return{collapsedGroups:a,seats:s}}function Gl(){try{return Wl(localStorage.getItem(Wr))}catch{return Yt()}}function Kl(e){try{localStorage.setItem(Wr,JSON.stringify({collapsedGroups:e.collapsedGroups,seats:e.seats}))}catch{}}const Vr={session:null,events:[],lastSeq:0,loaded:!1,loadError:null,stream:"idle"},tn=new Map,Fn=new Set;function Xr(){for(const e of Fn)e()}function Vl(e){return Fn.add(e),()=>Fn.delete(e)}function st(e){let t=tn.get(e);return t||(t={sessionId:e,...Vr},tn.set(e,t)),t}function mt(e,t){const n=st(e);tn.set(e,{...n,...t}),Xr()}const Xl={sessionId:"",...Vr};function Us(e){return e?st(e):Xl}function Yl(e,t,n){const a=st(e),s=Zr(a.events,n);mt(e,{session:Yr(t,s),events:s,lastSeq:s.length?s[s.length-1].seq:0,loaded:!0,loadError:null})}function Zl(e,t){mt(e,{loadError:t,loaded:!0})}function Wt(e,t){st(e).stream!==t&&mt(e,{stream:t})}function En(e,t,n){const a=st(e);mt(e,{session:Yr(t,a.events,n)})}function Yr(e,t,n){if(e.status!=="running")return e;let a=-1,s=n??null;if(!n){for(const u of t)(u.type==="user-message"||u.type==="turn-started")&&(a=u.seq,s=u.turnId);if(s===null)return e}let i=null,o=null;for(const u of t)u.seq<=a||(u.type==="error"&&u.turnId===s&&(o=u.message),(u.type==="turn-done"||u.type==="cancelled")&&u.turnId===s&&(i=u));if(!i)return e;const l=i.type==="turn-done"&&!i.ok&&o!==null;return{...e,status:l?"error":"idle",lastError:l?o:null,updatedAt:i.at>e.updatedAt?i.at:e.updatedAt}}function qs(e,t){const n=st(e);!n.session||n.session.status===t||mt(e,{session:{...n.session,status:t}})}function Ql(e,t){const n=st(e);if(!Number.isFinite(t.seq)||n.events.some(i=>i.seq===t.seq))return!1;const a=Zr(n.events,[t]);let s=n.session;if(s)switch(t.type){case"turn-started":s={...s,status:"running",lastError:null,updatedAt:t.at};break;case"usage":s={...s,usage:{inputTokens:s.usage.inputTokens+t.usage.inputTokens,outputTokens:s.usage.outputTokens+t.usage.outputTokens,cacheReadTokens:s.usage.cacheReadTokens+t.usage.cacheReadTokens,cacheCreationTokens:s.usage.cacheCreationTokens+t.usage.cacheCreationTokens,contextTokens:t.usage.contextTokens,contextWindow:t.usage.contextWindow??s.usage.contextWindow},updatedAt:t.at};break;case"turn-done":s={...s,status:t.ok?"idle":s.lastError?"error":"idle",turnCount:s.turnCount+1,nativeSessionId:t.nativeSessionId??s.nativeSessionId,updatedAt:t.at};break;case"error":s={...s,status:"error",lastError:t.message,updatedAt:t.at};break;case"cancelled":s={...s,status:"idle",updatedAt:t.at};break}return mt(e,{events:a,lastSeq:Math.max(n.lastSeq,t.seq),session:s}),!0}function Jl(e){tn.delete(e)&&Xr()}function Zr(e,t){if(t.length===0)return e;const n=new Map;for(const a of e)n.set(a.seq,a);for(const a of t)n.has(a.seq)||n.set(a.seq,a);return[...n.values()].sort((a,s)=>a.seq-s.seq)}function Qr(e,t){const n=Date.parse(e),a=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(a)?Math.max(0,a-n):null}function ec(e){const t=[],n=new Map;let a=null,s=!1,i=null;const o=l=>{a&&(t.push({kind:"assistant",key:a.key,turnId:a.turnId,at:a.at,text:a.text,streaming:l}),a=null)};for(const l of e)switch(l.type){case"user-message":o(!1),t.push({kind:"user",key:`u-${l.seq}`,turnId:l.turnId,at:l.at,text:l.text});break;case"turn-started":s=!0;break;case"text-delta":a&&a.turnId!==l.turnId&&o(!1),a||(a={turnId:l.turnId,at:l.at,text:"",key:`d-${l.seq}`}),a.text+=l.text;break;case"assistant-message":a=null,t.push({kind:"assistant",key:`a-${l.seq}`,turnId:l.turnId,at:l.at,text:l.text,streaming:!1});break;case"thinking":o(!1),t.push({kind:"thinking",key:`t-${l.seq}`,turnId:l.turnId,at:l.at,text:l.text});break;case"tool-use":o(!1),n.set(l.toolUseId,t.length),t.push({kind:"tool",key:`tu-${l.seq}`,turnId:l.turnId,at:l.at,toolUseId:l.toolUseId,name:l.name,input:l.input,result:null,durationMs:null});break;case"tool-result":{const u=n.get(l.toolUseId),d=u===void 0?void 0:t[u];d&&d.kind==="tool"?t[u]={...d,result:{output:l.output,isError:l.isError},durationMs:Qr(d.at,l.at)}:t.push({kind:"tool",key:`tr-${l.seq}`,turnId:l.turnId,at:l.at,toolUseId:l.toolUseId,name:"tool",input:null,result:{output:l.output,isError:l.isError},durationMs:null});break}case"usage":i=l.usage;break;case"error":o(!1),t.push({kind:"error",key:`e-${l.seq}`,turnId:l.turnId,at:l.at,message:l.message});break;case"cancelled":o(!1),s=!1,t.push({kind:"cancelled",key:`c-${l.seq}`,turnId:l.turnId,at:l.at});break;case"turn-done":o(!1),s=!1,t.push({kind:"turn-done",key:`td-${l.seq}`,turnId:l.turnId,at:l.at,ok:l.ok,durationMs:l.durationMs});break}return o(s),{items:t,live:s,usage:i}}function tc(e){const t=[];let n=[];const a=()=>{n.length!==0&&(n.length===1?t.push(n[0]):t.push(nc(n)),n=[])};for(const s of e){if((s.kind==="tool"||s.kind==="thinking")&&(n.length===0||n[0].turnId===s.turnId)){n.push(s);continue}a(),s.kind==="tool"||s.kind==="thinking"?n.push(s):t.push(s)}return a(),t}function nc(e){const t=new Map;let n=0,a=!1;for(const l of e)l.kind==="tool"&&(t.set(l.name,(t.get(l.name)??0)+1),l.result===null?a=!0:l.result.isError&&(n+=1));const s=[...t.values()].reduce((l,u)=>l+u,0),i=[...t.entries()].map(([l,u])=>u>1?`${l} ×${u}`:l).join(", "),o=Qr(e[0].at,e[e.length-1].at);return{kind:"toolGroup",key:`g-${e[0].key}`,turnId:e[0].turnId,at:e[0].at,items:e,toolCount:s,summary:i,errorCount:n,pending:a,spanMs:o}}function Oe(e){return e==null||!Number.isFinite(e)?"—":e<1e3?String(Math.round(e)):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`}const sc="_panel_b2xdj_3",rc="_head_b2xdj_10",ac="_title_b2xdj_22",oc="_close_b2xdj_30",ic="_scroll_b2xdj_45",lc="_section_b2xdj_46",cc="_sectionTitle_b2xdj_48",uc="_asOf_b2xdj_64",dc="_refresh_b2xdj_73",hc="_count_b2xdj_89",pc="_skeleton_b2xdj_90",fc="_muted_b2xdj_91",mc="_engineGroup_b2xdj_95",gc="_engineTitle_b2xdj_96",_c="_groupToggle_b2xdj_105",xc="_seatToggle_b2xdj_106",yc="_twist_b2xdj_126",bc="_seatList_b2xdj_137",kc="_models_b2xdj_137",wc="_runningList_b2xdj_137",Tc="_seat_b2xdj_106",Sc="_seatHead_b2xdj_148",jc="_seatLabel_b2xdj_149",Nc="_seatMeta_b2xdj_158",Ec="_seatSummary_b2xdj_166",vc="_plan_b2xdj_169",Ac="_num_b2xdj_170",Rc="_notes_b2xdj_174",Cc="_seatWindows_b2xdj_191",Ic="_credits_b2xdj_192",$c="_local_b2xdj_195",Lc="_mono_b2xdj_196",Mc="_runningRow_b2xdj_209",Dc="_runningOpen_b2xdj_210",Pc="_runningMeta_b2xdj_230",Oc="_runningDot_b2xdj_232",zc="_runningTitle_b2xdj_239",Fc="_stop_b2xdj_255",Hc="_usage_b2xdj_270",D={panel:sc,head:rc,title:ac,close:oc,scroll:ic,section:lc,sectionTitle:cc,asOf:uc,refresh:dc,count:hc,skeleton:pc,muted:fc,engineGroup:mc,engineTitle:gc,groupToggle:_c,seatToggle:xc,twist:yc,seatList:bc,models:kc,runningList:wc,seat:Tc,"engine-claude":"_engine-claude_b2xdj_143","engine-codex":"_engine-codex_b2xdj_144","engine-grok":"_engine-grok_b2xdj_145","engine-local":"_engine-local_b2xdj_146",seatHead:Sc,seatLabel:jc,seatMeta:Nc,seatSummary:Ec,plan:vc,num:Ac,notes:Rc,seatWindows:Cc,credits:Ic,local:$c,mono:Lc,runningRow:Mc,runningOpen:Dc,runningMeta:Pc,runningDot:Oc,"verse-pulse-res":"_verse-pulse-res_b2xdj_1",runningTitle:zc,stop:Fc,usage:Hc};function Bc(e){const[t,n]=p.useState(()=>Date.now());return p.useEffect(()=>{if(!e)return;const a=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(a)},[e]),t}function Uc(e){let t=null;for(const n of e){const a=nt(n).observedAt;a!==null&&(t===null||a>t)&&(t=a)}return t}function qc(){const[e,t]=p.useState(Gl),n=a=>{t(s=>{const i=a(s);return Kl(i),i})};return{state:e,toggleGroup:a=>n(s=>Hl(s,a)),toggleSeat:(a,s)=>n(i=>Bl(i,a.id,s.cls))}}function Wc({seat:e,view:t}){const n=Ul(t),a=Xn(e,t),s=e.contextWindow===null?"ctx n/a":`${Oe(e.contextWindow)} ctx`,i=`${e.models.length} model${e.models.length===1?"":"s"}`,o=Wo(t.evidenceSource),l=o===null?t.notes:[...t.notes,o];return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:D.seatMeta,children:[r.jsx("span",{children:Jt[e.engine]}),t.plan===null?null:r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{className:D.plan,children:t.plan})]}),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{children:i}),r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{className:D.num,children:s})]}),t.kind==="local"||n.length===0?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:D.seatSummary,children:t.summary}),t.kind==="local"||e.health.summary===null||e.health.summary===t.summary?null:r.jsx("p",{className:D.seatSummary,children:e.health.summary})]}):r.jsx("div",{className:D.seatWindows,children:n.map(u=>r.jsx(qr,{windowView:u,ariaPrefix:e.label,prominent:t.binding?.id===u.id},u.id))}),t.credits===null?null:r.jsx("p",{className:D.credits,title:t.creditsTitle??a,children:t.credits}),l.length===0?null:r.jsx("ul",{className:D.notes,children:l.map(u=>r.jsx("li",{children:u},u))})]})}function Gc({seat:e,open:t,onToggle:n}){const a=nt(e),s=Xn(e,a),i=`verse-seat-${e.id.replace(/[^A-Za-z0-9_-]/g,"-")}`;return r.jsxs("li",{className:`${D.seat} ${D[`engine-${e.engine}`]??""}`,"data-engine":e.engine,"data-capacity":a.cls,"data-open":t?"true":"false",children:[r.jsxs("button",{type:"button",className:D.seatToggle,"aria-expanded":t,"aria-controls":i,"aria-label":e.label,onClick:n,children:[r.jsx("span",{className:D.twist,"data-open":t?"":void 0,"aria-hidden":"true"}),r.jsx("span",{className:D.seatLabel,title:s,children:e.label}),a.kind==="local"?r.jsx(Hr,{status:e.health.state,tone:e.health.state==="ready"?"success":e.health.state==="unavailable"?"danger":"unknown"}):r.jsx(Yn,{view:a,title:s})]}),t?r.jsx("div",{id:i,children:r.jsx(Wc,{seat:e,view:a})}):r.jsx("p",{id:i,className:D.seatSummary,children:a.summary})]})}function Kc({bootstrap:e,sessions:t,current:n,onStop:a,onOpen:s,onClose:i}){const o=t.filter(_=>_.status==="running"),l=Bc(o.length>0),u=e?Kn(e.seats):[],d=e?.localRuntime.ollama,f=Xt(ft),y=On(ft),m=e?Uc(e.seats):null,S=m===null?null:no(m),g=qc();return r.jsxs("aside",{className:D.panel,"aria-label":"Resources",children:[r.jsxs("header",{className:D.head,children:[r.jsx("h2",{className:D.title,children:"Resources"}),r.jsx("button",{type:"button",className:D.close,onClick:i,"aria-label":"Hide resources",children:"×"})]}),r.jsxs("div",{className:D.scroll,children:[r.jsxs("section",{className:D.section,"aria-labelledby":"verse-res-seats",children:[r.jsxs("h3",{id:"verse-res-seats",className:D.sectionTitle,children:[r.jsx("span",{children:"Seats"}),r.jsx("span",{className:D.asOf,children:S===null?"no reading yet":`as of ${S}`}),f.status==="refreshing"?r.jsx(Fr,{label:"Refreshing seats"}):null,r.jsx("button",{type:"button",className:D.refresh,onClick:y,children:"Refresh"})]}),e?u.length===0?r.jsxs("p",{className:D.muted,children:["No seats discovered. Connect an account with ",r.jsx("code",{children:"ashlr accounts"})," or start Ollama."]}):u.map(_=>{const x=Fl(g.state,_.engine),w=`verse-res-group-${_.engine}`;return r.jsxs("div",{className:D.engineGroup,children:[r.jsx("h4",{className:D.engineTitle,children:r.jsxs("button",{type:"button",className:D.groupToggle,"aria-expanded":x,"aria-controls":w,"aria-label":`${Jt[_.engine]} seats`,onClick:()=>g.toggleGroup(_.engine),children:[r.jsx("span",{className:D.twist,"data-open":x?"":void 0,"aria-hidden":"true"}),r.jsx("span",{children:Jt[_.engine]}),r.jsx("span",{className:D.count,children:_.seats.length})]})}),x?r.jsx("ul",{id:w,className:D.seatList,children:_.seats.map(k=>{const R=nt(k);return r.jsx(Gc,{seat:k,open:Gr(g.state,k.id,R.cls),onToggle:()=>g.toggleSeat(k,R)},k.id)})}):r.jsx("ul",{id:w,className:D.seatList,hidden:!0})]},_.engine)}):r.jsxs("div",{className:D.skeleton,children:[r.jsx(Ee,{width:"70%"}),r.jsx(Ee,{width:"50%"}),r.jsx(Ee,{width:"64%"})]})]}),r.jsxs("section",{className:D.section,"aria-labelledby":"verse-res-local",children:[r.jsx("h3",{id:"verse-res-local",className:D.sectionTitle,children:"Local runtime"}),d?r.jsxs("div",{className:D.local,children:[r.jsxs("div",{className:D.seatHead,children:[r.jsx("span",{className:D.seatLabel,children:"Ollama"}),r.jsx(Hr,{status:d.reachable?"ready":"unavailable",tone:d.reachable?"success":"danger",children:d.reachable?"reachable":"unreachable"})]}),r.jsx("p",{className:D.mono,title:d.baseUrl,children:d.baseUrl}),d.reachable?d.models.length>0?r.jsx("ul",{className:D.models,children:d.models.map(_=>r.jsx("li",{children:r.jsx("code",{children:_})},_))}):r.jsx("p",{className:D.muted,children:"No models pulled yet."}):r.jsx("p",{className:D.muted,children:"Start Ollama to enable local seats."})]}):r.jsx(Ee,{width:"60%"})]}),r.jsxs("section",{className:D.section,"aria-labelledby":"verse-res-running",children:[r.jsxs("h3",{id:"verse-res-running",className:D.sectionTitle,children:["Running ",r.jsx("span",{className:D.count,children:o.length})]}),o.length===0?r.jsx("p",{className:D.muted,children:"Nothing running."}):r.jsx("ul",{className:D.runningList,children:o.map(_=>r.jsxs("li",{className:D.runningRow,children:[r.jsxs("button",{type:"button",className:D.runningOpen,onClick:()=>s(_.id),title:_.title,children:[r.jsx("span",{className:D.runningDot,role:"img","aria-label":"Running"}),r.jsx("span",{className:D.runningTitle,children:_.title||"Untitled chat"}),r.jsxs("span",{className:D.runningMeta,children:[Vn(_.projectPath,e?.projects??[])," · ",to(l-new Date(_.updatedAt).getTime())]})]}),r.jsx("button",{type:"button",className:D.stop,onClick:()=>a(_.id),"aria-label":`Stop ${_.title||"chat"}`,children:"Stop"})]},_.id))})]}),r.jsx(Pl,{session:n,refreshKey:n?.turnCount??0}),r.jsxs("section",{className:D.section,"aria-labelledby":"verse-res-usage",children:[r.jsx("h3",{id:"verse-res-usage",className:D.sectionTitle,children:"This chat"}),n?r.jsxs("dl",{className:D.usage,children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Input"}),r.jsx("dd",{children:Oe(n.usage.inputTokens)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Output"}),r.jsx("dd",{children:Oe(n.usage.outputTokens)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Cache read"}),r.jsx("dd",{children:Oe(n.usage.cacheReadTokens)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Cache write"}),r.jsx("dd",{children:Oe(n.usage.cacheCreationTokens)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Turns"}),r.jsx("dd",{children:n.turnCount})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Context"}),r.jsxs("dd",{children:[Oe(n.usage.contextTokens),n.usage.contextWindow?` / ${Oe(n.usage.contextWindow)}`:""]})]})]}):r.jsx("p",{className:D.muted,children:"Select a chat to see its usage."})]})]})]})}const Vc="_sidebar_bu0vt_1",Xc="_head_bu0vt_9",Yc="_headDragStrip_bu0vt_40",Zc="_search_bu0vt_51",Qc="_searchIcon_bu0vt_58",Jc="_iconButton_bu0vt_80",eu="_scroll_bu0vt_98",tu="_skeleton_bu0vt_105",nu="_error_bu0vt_106",su="_empty_bu0vt_125",ru="_emptyTitle_bu0vt_131",au="_group_bu0vt_133",ou="_groupTitle_bu0vt_134",iu="_groupName_bu0vt_147",lu="_enrolled_bu0vt_148",cu="_list_bu0vt_150",uu="_session_bu0vt_153",du="_marker_bu0vt_170",hu="_sessionText_bu0vt_181",pu="_running_bu0vt_190",fu="_errored_bu0vt_197",mu="_seatSpent_bu0vt_212",gu="_time_bu0vt_224",_u="_footer_bu0vt_243",xu="_footerButton_bu0vt_251",re={sidebar:Vc,head:Xc,headDragStrip:Yc,search:Zc,searchIcon:Qc,iconButton:Jc,scroll:eu,skeleton:tu,error:nu,empty:su,emptyTitle:ru,group:au,groupTitle:ou,groupName:iu,enrolled:lu,list:cu,session:uu,marker:du,"engine-claude":"_engine-claude_bu0vt_176","engine-codex":"_engine-codex_bu0vt_177","engine-grok":"_engine-grok_bu0vt_178","engine-local":"_engine-local_bu0vt_179",sessionText:hu,running:pu,"verse-pulse":"_verse-pulse_bu0vt_1",errored:fu,seatSpent:mu,time:gu,footer:_u,footerButton:xu};function yu(e){const{sessions:t,sessionsStatus:n,sessionsError:a,projects:s,seats:i,selectedId:o,query:l,onQuery:u,onSelect:d,onNew:f,onRetry:y,onCollapse:m,onDisconnect:S}=e,g=p.useId(),_=so(t,s,l),x=n==="loading"||n==="idle"&&t.length===0;return r.jsxs("nav",{className:re.sidebar,"aria-label":"Chats",children:[r.jsxs("div",{className:re.head,children:[r.jsx("div",{className:re.headDragStrip,"aria-hidden":"true"}),r.jsxs("label",{className:re.search,htmlFor:g,children:[r.jsx("span",{className:re.searchIcon,"aria-hidden":"true",children:r.jsx(Pr,{})}),r.jsx("span",{className:"visually-hidden",children:"Search chats"}),r.jsx("input",{id:g,type:"search",value:l,placeholder:"Search chats",autoComplete:"off",onChange:w=>u(w.target.value)})]}),r.jsx("button",{type:"button",className:re.iconButton,onClick:f,title:"New chat (⌘N)","aria-label":"New chat",children:r.jsx(mo,{})}),r.jsx("button",{type:"button",className:re.iconButton,onClick:m,title:"Hide chat list","aria-label":"Hide chat list",children:r.jsx(Or,{})}),n==="refreshing"?r.jsx(Fr,{label:"Refreshing chats"}):null]}),r.jsx("div",{className:re.scroll,children:x?r.jsxs("div",{className:re.skeleton,"aria-busy":"true",children:[r.jsx(Ee,{width:"48%"}),r.jsx(Ee,{width:"86%"}),r.jsx(Ee,{width:"74%"}),r.jsx(Ee,{width:"40%"}),r.jsx(Ee,{width:"80%"})]}):n==="error"&&t.length===0?r.jsxs("div",{role:"alert",className:re.error,children:[r.jsx("p",{children:a??"Could not load chats."}),r.jsx("button",{type:"button",onClick:y,children:"Retry"})]}):_.length===0?r.jsx("div",{className:re.empty,children:l?r.jsxs("p",{children:["No chats match “",l,"”."]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:re.emptyTitle,children:"No chats yet — ⌘N"}),r.jsx("p",{children:"Start one on any project with any seat."})]})}):_.map(w=>r.jsxs("section",{className:re.group,"aria-label":w.name,children:[r.jsxs("h2",{className:re.groupTitle,title:w.projectPath,children:[r.jsx("span",{className:re.groupName,children:w.name}),w.enrolled?r.jsx("span",{className:re.enrolled,title:"Enrolled repo",children:"enrolled"}):null]}),r.jsx("ul",{className:re.list,children:w.sessions.map(k=>{const R=Dr(i,k.seatId),j=R===void 0?null:nt(R),O=k.status==="running"&&j?.cls==="blocked",G=j===null||j.cls==="ready"||j.cls==="unread"?`${k.title} · ${At(i,k)}`:`${k.title} · ${At(i,k)} · ${j.summary}`;return r.jsx("li",{children:r.jsxs("button",{type:"button",className:`${re.session} ${re[`engine-${k.engine}`]??""}`,"aria-current":k.id===o?"true":void 0,"data-focus-key":`verse-session:${k.id}`,"data-engine":k.engine,onClick:()=>d(k.id),title:G,children:[r.jsx("span",{className:re.marker,"aria-hidden":"true"}),r.jsx("span",{className:re.sessionText,children:k.title||"Untitled chat"}),O&&j!==null?r.jsx("span",{className:re.seatSpent,role:"img","aria-label":`Seat limit reached: ${j.summary}`,children:"▮"}):null,k.status==="running"?r.jsx("span",{className:re.running,role:"img","aria-label":"Running"}):k.status==="error"?r.jsx("span",{className:re.errored,role:"img","aria-label":"Last turn failed",children:"!"}):null,r.jsx("time",{className:re.time,dateTime:k.updatedAt,children:Mr(k.updatedAt)})]})},k.id)})})]},w.projectPath))}),r.jsx("footer",{className:re.footer,children:r.jsx("button",{type:"button",onClick:S,className:re.footerButton,children:"Disconnect"})})]})}const bu=["user-message","turn-started","text-delta","assistant-message","thinking","tool-use","tool-result","usage","turn-done","error","cancelled"];function ku(e){return`${go(e,"/events")}?client=${encodeURIComponent(Ua())}`}function Jr(e){return Math.min(1e3*2**e,15e3)}function wu(e){try{const t=JSON.parse(e);if(!t||typeof t!="object")return null;const n=t;return typeof n.seq!="number"||typeof n.type!="string"?null:t}catch{return null}}function Tu(e){let t=null,n=null,a=0,s=!1;const i=()=>{if(s||typeof EventSource>"u"||Qt().phase!=="authenticated")return;Wt(e,a===0?"connecting":"reconnecting");const o=new EventSource(ku(e),{withCredentials:!0});t=o,o.onopen=()=>{a=0,Wt(e,"open")};for(const l of bu)o.addEventListener(l,u=>{const d=wu(u.data);d&&(Ql(e,d),(d.type==="turn-done"||d.type==="cancelled"||d.type==="error")&&zr())});o.onerror=l=>{typeof MessageEvent<"u"&&l instanceof MessageEvent||(o.close(),t===o&&(t=null),!s&&(Wt(e,"reconnecting"),Qt().phase==="authenticated"&&(n=setTimeout(()=>{n=null,a+=1,i()},Jr(a)))))}};return i(),()=>{s=!0,n&&clearTimeout(n),n=null,t?.close(),t=null,Wt(e,"closed")}}function Su(){let e=null,t=null,n=0,a=!1;const s=()=>{if(a||typeof EventSource>"u"||Qt().phase!=="authenticated")return;const i=new EventSource(Ba(),{withCredentials:!0});e=i,i.onopen=()=>{n=0},i.addEventListener("verse-sessions",()=>zr()),i.onerror=()=>{i.close(),e===i&&(e=null),!(a||Qt().phase!=="authenticated")&&(t=setTimeout(()=>{t=null,n+=1,s()},Jr(n)))}};return s(),()=>{a=!0,t&&clearTimeout(t),t=null,e?.close(),e=null}}function ju(e,t=0){const n=p.useSyncExternalStore(Vl,()=>Us(e),()=>Us(e));p.useEffect(()=>{if(!e)return;const s=new AbortController;_o(e,s.signal).then(o=>{s.signal.aborted||Yl(e,o.session,o.events)}).catch(o=>{s.signal.aborted||Zl(e,o instanceof Error?o.message:"Could not load this chat.")});const i=Tu(e);return()=>{s.abort(),i()}},[e,t]);const a=p.useMemo(()=>ec(n.events),[n.events]);return p.useMemo(()=>({...n,transcript:a}),[n,a])}const Nu="_workspace_yz289_1",Eu="_header_yz289_11",vu="_headerSpacer_yz289_23",Au="_title_yz289_25",Ru="_titleButton_yz289_29",Cu="_titleInput_yz289_59",Iu="_titleSkeleton_yz289_72",$u="_seatPill_yz289_81",Lu="_engineDot_yz289_100",Mu="_seatText_yz289_107",Du="_projectName_yz289_114",Pu="_streamState_yz289_128",Ou="_ghost_yz289_130",zu="_ghostIcon_yz289_131",Fu="_danger_yz289_132",Hu="_confirm_yz289_158",Bu="_confirmText_yz289_159",Uu="_meter_yz289_170",qu="_meterTrack_yz289_183",Wu="_meterFill_yz289_191",Gu="_meterInline_yz289_196",Ku="_meterText_yz289_204",Vu="_meterTokens_yz289_213",Xu="_meterPercent_yz289_217",Yu="_emptyState_yz289_221",Zu="_emptyMark_yz289_232",Qu="_emptyTitle_yz289_233",Ju="_emptyBody_yz289_240",ed="_emptyButton_yz289_241",td="_emptyWarn_yz289_257",W={workspace:Nu,header:Eu,headerSpacer:vu,title:Au,titleButton:Ru,titleInput:Cu,titleSkeleton:Iu,seatPill:$u,engineDot:Lu,seatText:Mu,projectName:Du,"engine-claude":"_engine-claude_yz289_123","engine-codex":"_engine-codex_yz289_124","engine-grok":"_engine-grok_yz289_125","engine-local":"_engine-local_yz289_126",streamState:Pu,ghost:Ou,ghostIcon:zu,danger:Fu,confirm:Hu,confirmText:Bu,meter:Uu,"meter-warn":"_meter-warn_yz289_178","meter-danger":"_meter-danger_yz289_179","meter-unknown":"_meter-unknown_yz289_180",meterTrack:qu,meterFill:Wu,meterInline:Gu,meterText:Ku,meterTokens:Vu,meterPercent:Xu,emptyState:Yu,emptyMark:Zu,emptyTitle:Qu,emptyBody:Ju,emptyButton:ed,emptyWarn:td},ea=70,ta=90;function nd(e){return e===null?"unknown":e>=ta?"danger":e>=ea?"warn":"ok"}function sd({contextTokens:e,contextWindow:t,variant:n="header"}){const a=typeof e=="number"&&Number.isFinite(e)?Math.max(0,e):0,s=typeof t=="number"&&t>0?t:null,i=s?Math.min(100,Math.round(a/s*100)):null,o=nd(i),l=s?`${Oe(a)} / ${Oe(s)}`:`${Oe(a)} / n/a`,u=i===null?"n/a":`${i}%`;return r.jsxs("div",{className:`${W.meter} ${W[`meter-${o}`]??""} ${n==="inline"?W.meterInline:""}`,role:"meter","aria-label":"Context window","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i??void 0,"aria-valuetext":`${l} (${u})`,title:`Context window — ${l} (${u})`,"data-tone":o,children:[r.jsx("div",{className:W.meterTrack,"aria-hidden":"true",children:r.jsx("div",{className:W.meterFill,style:{width:`${i??0}%`}})}),r.jsxs("span",{className:W.meterText,children:[r.jsx("span",{className:W.meterTokens,children:l}),r.jsx("span",{className:W.meterPercent,children:u})]})]})}const Ws="Use Wispr Flow / Superwhisper — system dictation works in this box";function rd(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function ad({disabled:e=!1,onInterim:t,onFinal:n,onListeningChange:a}){const s=rd(),[i,o]=p.useState(!1),[l,u]=p.useState(null),d=p.useRef(null),f=p.useId(),y=p.useRef({onInterim:t,onFinal:n,onListeningChange:a});y.current={onInterim:t,onFinal:n,onListeningChange:a};const m=p.useCallback(()=>{const g=d.current;if(d.current=null,g){g.onresult=null,g.onend=null,g.onerror=null;try{g.stop()}catch{}}o(!1),y.current.onInterim(""),y.current.onListeningChange?.(!1)},[]),S=p.useCallback(()=>{if(!s||d.current)return;let g;try{g=new s}catch{u("Dictation could not start in this browser.");return}g.lang=navigator.language||"en-US",g.continuous=!0,g.interimResults=!0,g.onresult=_=>{let x="",w="";for(let k=_.resultIndex;k<_.results.length;k+=1){const R=_.results[k];if(!R)continue;const j=R[0]?.transcript??"";R.isFinal?w+=j:x+=j}w&&y.current.onFinal(w.trim()),y.current.onInterim(x)},g.onerror=_=>{const x=_.error??"unknown";x==="not-allowed"||x==="service-not-allowed"?u("Microphone access was denied."):x!=="aborted"&&x!=="no-speech"&&u(`Dictation stopped (${x}).`),m()},g.onend=()=>{d.current===g&&m()},d.current=g,u(null);try{g.start()}catch{d.current=null,u("Dictation could not start in this browser.");return}o(!0),y.current.onListeningChange?.(!0)},[s,m]);return p.useEffect(()=>{if(!i)return;function g(_){_.key==="Escape"&&(_.preventDefault(),m())}return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i,m]),p.useEffect(()=>()=>{const g=d.current;d.current=null;try{g?.abort()}catch{}},[]),s?r.jsxs("span",{className:U.dictationWrap,children:[r.jsxs("button",{type:"button",className:`${U.dictation} ${i?U.dictationLive:""}`,disabled:e&&!i,"aria-pressed":i,"aria-label":i?"Stop dictation (Esc)":"Start dictation",title:i?"Stop dictation (Esc)":"Dictate",onClick:()=>i?m():S(),children:[r.jsx(Gs,{}),i?r.jsx("span",{className:U.dictationPulse,"aria-hidden":"true"}):null]}),l?r.jsx("span",{role:"alert",className:U.dictationError,children:l}):null]}):r.jsxs("span",{className:U.dictationWrap,children:[r.jsxs("button",{type:"button",className:U.dictation,disabled:!0,"aria-disabled":"true","aria-describedby":f,title:Ws,children:[r.jsx(Gs,{}),r.jsx("span",{className:"visually-hidden",children:"Dictation unavailable"})]}),r.jsx("span",{role:"tooltip",id:f,className:U.dictationHint,children:Ws})]})}function Gs(){return r.jsxs("svg",{viewBox:"0 0 20 20",width:"16",height:"16","aria-hidden":"true",focusable:"false",children:[r.jsx("rect",{x:"7",y:"2",width:"6",height:"10",rx:"3",fill:"currentColor"}),r.jsx("path",{d:"M4.5 9.5a5.5 5.5 0 0 0 11 0M10 15v3M7 18h6",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}const od=64*1024,id=400,ld=.4,cd=320;function ud({sessionId:e=null,seats:t,seat:n,engine:a,running:s,disabled:i,disabledReason:o,locked:l,hintSeen:u=!1,contextTokens:d=null,contextWindow:f=null,onSend:y,onStop:m,onSeatChange:S,autoFocus:g=!1}){const[_,x]=p.useState(()=>qa(e)),[w,k]=p.useState(""),[R,j]=p.useState(!1),[O,G]=p.useState(!1),[pe,de]=p.useState(!1),[Q,q]=p.useState(-1),[ie]=p.useState(()=>Wa(e)),te=p.useRef(ie),fe=p.useRef(""),V=p.useRef(null),me=p.useRef(null),ne=p.useId(),X=w?`${_}${_&&!_.endsWith(" ")?" ":""}${w}`:_,se=p.useMemo(()=>new TextEncoder().encode(X).length>od,[X]),J=!i&&!s&&!R&&X.trim().length>0&&!se,N=!u&&!pe,$=p.useMemo(()=>Ga(X,d,f,ea,ta),[X,d,f]),P=p.useRef(_),ye=p.useRef(_);ye.current=_;const z=p.useCallback(()=>{P.current!==ye.current&&(P.current=ye.current,Ls(e,ye.current))},[e]);p.useEffect(()=>{if(P.current===_)return;const M=setTimeout(z,id);return()=>clearTimeout(M)},[_,z]),p.useEffect(()=>(window.addEventListener("beforeunload",z),()=>{window.removeEventListener("beforeunload",z),z()}),[z]),p.useEffect(()=>{g&&V.current?.focus()},[g]),p.useEffect(()=>{if(!s)return;const M=K=>{K.key!=="."||!K.metaKey&&!K.ctrlKey||K.shiftKey||K.altKey||(K.preventDefault(),m())};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[s,m]),p.useEffect(()=>{if(s||!g)return;const M=document.activeElement,K=M!==null&&M!==V.current&&me.current?.contains(M)===!0;(M===null||M===document.body||!M.isConnected||K)&&V.current?.focus()},[s,g]),p.useEffect(()=>{const M=V.current;if(!M)return;const K=typeof window>"u"?0:window.innerHeight,be=K>0?Math.round(K*ld):cd;M.style.height="auto",M.style.height=`${Math.min(M.scrollHeight,be)}px`},[X]);const F=p.useCallback(async()=>{if(!J)return;const M=X.trim();j(!0);try{await y(M)&&(te.current[te.current.length-1]!==M&&(te.current=[...te.current,M]),Ka(e,M),q(-1),fe.current="",x(""),P.current="",ye.current="",Ls(e,""),k(""),de(!0))}finally{j(!1),V.current?.focus()}},[J,X,y,e]);function ke(M){const K=te.current;if(K.length===0)return!1;if(Q===-1){if(M>0)return!1;fe.current=_;const He=K.length-1;return q(He),x(K[He]),k(""),!0}const be=Q+M;return be<0?!0:be>=K.length?(q(-1),x(fe.current),!0):(q(be),x(K[be]),!0)}function Te(M){const K=M.currentTarget,be=K.selectionStart===K.selectionEnd;if(M.key==="Enter"&&!M.shiftKey&&!M.nativeEvent.isComposing){M.preventDefault(),F();return}if(M.key==="Enter"&&(M.metaKey||M.ctrlKey)&&!M.nativeEvent.isComposing){M.preventDefault(),F();return}if(M.key==="ArrowUp"&&be&&(Q!==-1||K.selectionStart===0&&!w)){ke(-1)&&M.preventDefault();return}M.key==="ArrowDown"&&be&&Q!==-1&&ke(1)&&M.preventDefault()}const $e=i?o??"Sending is disabled":s?"Draft your next message…":"Message the agent…";return r.jsxs("form",{ref:me,className:U.composer,onSubmit:M=>{M.preventDefault(),F()},"aria-describedby":ne,children:[r.jsxs("div",{className:`${U.box} ${O?U.boxListening:""}`,children:[r.jsx("textarea",{ref:V,className:U.textarea,value:X,rows:1,placeholder:$e,"aria-label":"Message",disabled:i,onChange:M=>{k(""),q(-1),x(M.target.value)},onKeyDown:Te}),r.jsxs("div",{className:U.row,children:[r.jsx(dd,{seats:t,seat:n,engine:a,disabled:i,onNewChat:S}),r.jsx("div",{className:U.spacer}),r.jsx(ad,{disabled:i,onInterim:k,onFinal:M=>x(K=>K&&!K.endsWith(" ")?`${K} ${M}`:`${K}${M}`),onListeningChange:G}),s?r.jsxs("button",{type:"button",className:U.stop,onClick:m,title:"Stop the running turn (⌘.)","aria-label":"Stop the running turn",children:[r.jsx("span",{className:U.stopIcon,"aria-hidden":"true"}),"Stop"]},"stop"):r.jsx("button",{type:"submit",className:U.send,disabled:!J,"aria-label":l?"Send (unlocks first)":"Send message",children:R?"Sending…":l?"Unlock & send":"Send"},"send")]})]}),$?r.jsxs("p",{className:U.cost,"data-tone":$.tone,role:"status",children:[r.jsxs("span",{className:U.costFigure,children:["≈",Oe($.draftTokens)]})," tokens for this message — sending would reach ",r.jsxs("span",{className:U.costFigure,children:[$.projectedPercent,"%"]})," of the context window.",$.tone==="danger"?" Start a new chat to keep the agent sharp.":"",r.jsx("span",{className:"visually-hidden",children:" This is an estimate; the provider counts the real total."})]}):null,r.jsx("p",{id:ne,className:`${U.help} ${N||se||O||s||i||Q!==-1?"":U.helpQuiet}`,children:se?r.jsx("span",{role:"alert",className:U.helpError,children:"Message is over 64 KB — trim it before sending."}):O?"Listening… Esc stops dictation.":i&&o?o:s?r.jsxs(r.Fragment,{children:["Reply in progress — your draft stays here · ",r.jsx("kbd",{children:"⌘."})," or Stop interrupts the turn"]}):Q!==-1?r.jsxs(r.Fragment,{children:["Recalled message ",Q+1," of ",te.current.length," · ",r.jsx("kbd",{children:"↓"})," returns to your draft"]}):N?r.jsxs(r.Fragment,{children:[r.jsx("kbd",{children:"Enter"})," sends · ",r.jsx("kbd",{children:"Shift"}),"+",r.jsx("kbd",{children:"Enter"})," new line · ",r.jsx("kbd",{children:"↑"})," recalls · ",r.jsx("kbd",{children:"⌘N"})," new chat · ",r.jsx("kbd",{children:"⌘K"})," switch"]}):null})]})}function dd({seats:e,seat:t,engine:n,disabled:a,onNewChat:s}){const[i,o]=p.useState(!1),l=p.useRef(null),u=p.useRef(null),d=p.useId(),f=hd(e,t.seatId),y=n??f?.engine,m=At(e,{seatId:t.seatId,engine:y??"claude",model:t.model}),S=e.filter(_=>_.health.state!=="unavailable"&&_.models.length>0);p.useEffect(()=>{if(!i)return;const _=w=>{l.current&&!l.current.contains(w.target)&&o(!1)},x=w=>{w.key==="Escape"&&(w.preventDefault(),o(!1),u.current?.focus())};return document.addEventListener("pointerdown",_),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",_),document.removeEventListener("keydown",x)}},[i]),p.useEffect(()=>{i&&l.current?.querySelector('[role="menuitem"]')?.focus()},[i]);function g(_){if(_.key!=="ArrowDown"&&_.key!=="ArrowUp")return;const x=Array.from(l.current?.querySelectorAll('[role="menuitem"]')??[]);if(x.length===0)return;_.preventDefault();const w=x.indexOf(document.activeElement),k=_.key==="ArrowDown"?(w+1)%x.length:(w-1+x.length)%x.length;x[k]?.focus()}return r.jsxs("div",{ref:l,className:`${U.seatPillWrap} ${y?U[`engine-${y}`]??"":""}`,children:[r.jsxs("button",{ref:u,type:"button",className:U.seatPill,"data-engine":y,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?d:void 0,disabled:a,title:"This chat is bound to one seat — open to start a new chat on another",onClick:()=>o(_=>!_),children:[r.jsx("span",{className:U.engineDot,"aria-hidden":"true"}),r.jsx("span",{className:U.seatPillText,children:m})]}),i?r.jsxs("div",{id:d,role:"menu","aria-label":"Seat",className:U.seatMenu,onKeyDown:g,children:[r.jsxs("p",{className:U.seatMenuHeading,children:["This chat runs on ",r.jsx("strong",{children:m})]}),S.length===0?r.jsx("p",{className:U.seatMenuEmpty,children:"No other seats are available right now."}):null,S.map(_=>{const x=$r(_);return r.jsxs("button",{type:"button",role:"menuitem",className:`${U.seatMenuItem} ${U[`engine-${_.engine}`]??""}`,"data-capacity":x.cls,onClick:()=>{o(!1),s({seatId:_.id,model:_.models[0].id})},children:[r.jsx("span",{className:U.engineDot,"aria-hidden":"true"}),r.jsxs("span",{className:U.seatMenuText,children:[r.jsxs("span",{className:U.seatMenuPrimary,children:["New chat on ",_.label]}),r.jsxs("span",{className:U.seatMenuSecondary,children:[_.models[0].label,_.id===t.seatId?" · same seat":""]}),x.cls==="unread"?null:r.jsxs("span",{className:U.seatMenuCapacity,children:[cn[x.cls]," · ",x.text]})]})]},_.id)})]}):null]})}function hd(e,t){return e.find(n=>n.id===t)}const Ks=1200;function pd(e,t){const n=e.length,a=t.length;if(n===0&&a===0)return[];if(n===0)return t.map(x=>({kind:"add",text:x}));if(a===0)return e.map(x=>({kind:"del",text:x}));if(n>Ks||a>Ks)return[...e.map(x=>({kind:"del",text:x})),...t.map(x=>({kind:"add",text:x}))];let s=0;for(;s<n&&s<a&&e[s]===t[s];)s++;let i=n-1,o=a-1;for(;i>=s&&o>=s&&e[i]===t[o];)i--,o--;const l=e.slice(s,i+1),u=t.slice(s,o+1),d=l.length,f=u.length,y=f+1,m=new Int32Array((d+1)*y);for(let x=d-1;x>=0;x--)for(let w=f-1;w>=0;w--)m[x*y+w]=l[x]===u[w]?m[(x+1)*y+(w+1)]+1:Math.max(m[(x+1)*y+w],m[x*y+(w+1)]);const S=[];for(let x=0;x<s;x++)S.push({kind:"same",text:e[x]});let g=0,_=0;for(;g<d&&_<f;)l[g]===u[_]?(S.push({kind:"same",text:l[g]}),g++,_++):m[(g+1)*y+_]>=m[g*y+(_+1)]?(S.push({kind:"del",text:l[g]}),g++):(S.push({kind:"add",text:u[_]}),_++);for(;g<d;)S.push({kind:"del",text:l[g++]});for(;_<f;)S.push({kind:"add",text:u[_++]});for(let x=i+1;x<n;x++)S.push({kind:"same",text:e[x]});return S}function fd(e,t){const n=Math.max(0,t.context??3),a=t.oldStart??1,s=t.newStart??1;if(e.length===0||!e.some(f=>f.kind!=="same"))return"";const i=[];let o=a,l=s;for(const f of e)i.push({...f,oldNo:o,newNo:l}),f.kind!=="add"&&o++,f.kind!=="del"&&l++;const u=[];for(let f=0;f<i.length;f++){if(i[f].kind==="same")continue;const y=Math.max(0,f-n),m=Math.min(i.length-1,f+n),S=u[u.length-1];S&&y<=S.to+1?S.to=Math.max(S.to,m):u.push({from:y,to:m})}const d=[`--- a/${t.path}`,`+++ b/${t.path}`];for(const f of u){const y=i.slice(f.from,f.to+1),m=y.filter(w=>w.kind!=="add").length,S=y.filter(w=>w.kind!=="del").length,g=y.find(w=>w.kind!=="add")?.oldNo??a,_=y.find(w=>w.kind!=="del")?.newNo??s,x=t.section?` ${t.section}`:"";d.push(`@@ -${m===0?g-1:g},${m} +${S===0?_-1:_},${S} @@${x}`);for(const w of y)d.push(`${w.kind==="add"?"+":w.kind==="del"?"-":" "}${w.text}`)}return d.join(`
|
|
2
|
-
`)}function md(e,t,n){return e===t?"":fd(pd(Rt(e),Rt(t)),n)}function Rt(e){if(e==="")return[];const t=e.split(`
|
|
3
|
-
`);return t[t.length-1]===""&&t.pop(),t}const gd=new Map([["read","read"],["readfile","read"],["read_file","read"],["view","read"],["notebookread","read"],["notebook_read","read"],["cat","read"],["open","read"],["edit","edit"],["multiedit","edit"],["multi_edit","edit"],["notebookedit","edit"],["notebook_edit","edit"],["str_replace","edit"],["str_replace_editor","edit"],["str_replace_based_edit_tool","edit"],["apply_patch","edit"],["patch","edit"],["edit_structural","edit"],["search_replace_regex","edit"],["rename_file","edit"],["update","edit"],["applydiff","edit"],["apply_diff","edit"],["write","create"],["create","create"],["create_file","create"],["writefile","create"],["write_file","create"],["new_file","create"],["delete","delete"],["delete_file","delete"],["remove_file","delete"],["rm","delete"],["bash","command"],["shell","command"],["exec","command"],["run","command"],["run_command","command"],["runcommand","command"],["run_terminal_cmd","command"],["bash_start","command"],["bash_tail","command"],["terminal","command"],["test","command"],["grep","search"],["glob","search"],["search","search"],["find","search"],["codebase_search","search"],["ls","search"],["tree","search"],["list_dir","search"],["task","task"],["agent","task"],["dispatch_agent","task"],["subagent","task"],["webfetch","web"],["websearch","web"],["fetch","web"],["http","web"],["browser","web"]]);function na(e){const t=e.split("__").filter(Boolean);return(t[t.length-1]??e).trim().toLowerCase()}function _d(e){return gd.get(na(e))??"other"}function nn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Zt(e){return typeof e=="string"&&e.length>0?e:null}const xd=["file_path","filePath","notebook_path","notebookPath","target_file","path","file","filename","fileName","relative_workspace_path"];function yd(e){const t=nn(e);if(!t)return[];const n=[],a=i=>{const o=Zt(i);o&&!n.includes(o)&&n.push(o)};for(const i of xd)a(t[i]);const s=t.paths??t.file_paths??t.files;if(Array.isArray(s))for(const i of s)a(typeof i=="string"?i:nn(i)?.path);return n}function bd(e){const t=e.split(/[\\/]/).filter(Boolean);return t[t.length-1]??e}function kd(e){const t=e.split(/[\\/]/);return t.pop(),t.join("/")}const wd=["command","cmd","script","shell_command","commandLine"],Td=/^[ \t]*(?:exit(?:ed)?[ \t]+(?:with[ \t]+)?(?:code|status)|exit[ \t]*code|exit[ \t]*status|command[ \t]+exited[ \t]+with[ \t]+code)[ \t]*[:=]?[ \t]*(\d{1,3})[ \t]*\.?$/im;function Sd(e){const t=Td.exec(e);if(!t)return null;const n=Number(t[1]);return Number.isInteger(n)&&n>=0&&n<=255?n:null}const jd=/^diff --git /m,Nd=/^--- (?:a\/|\/dev\/null|[^\n]*\t)/m,Ed=/^\+\+\+ (?:b\/|\/dev\/null|[^\n]*\t)/m,vd=/^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/m;function Vs(e){return e?jd.test(e)?!0:vd.test(e)&&Nd.test(e)&&Ed.test(e):!1}function Xs(e){const t=e.match(/^diff --git /gm);return t?t.length:(e.match(/^--- /gm)??[]).length}function Ys(e){const t=nn(e);if(!t)return null;const n=t.old_string??t.oldString??t.old_str??t.old??t.search??t.find,a=t.new_string??t.newString??t.new_str??t.new??t.replace??t.replacement;return typeof n!="string"||typeof a!="string"?null:{old:n,next:a}}function Ad(e,t){const n=[];let a=1;return t.forEach((s,i)=>{const o=md(s.old,s.next,{path:e,oldStart:a,newStart:a,section:t.length>1?`edit ${i+1} of ${t.length}`:void 0});a+=Math.max(Rt(s.old).length,Rt(s.next).length)+8,o&&n.push(o.split(`
|
|
4
|
-
`).slice(2).join(`
|
|
5
|
-
`))}),n.length===0?"":[`--- a/${e}`,`+++ b/${e}`,...n].join(`
|
|
6
|
-
`)}function Rd(e,t){const n=Rt(t);return n.length===0?"":["--- /dev/null",`+++ b/${e}`,`@@ -0,0 +1,${n.length} @@`,...n.map(a=>`+${a}`)].join(`
|
|
7
|
-
`)}const vn=2e5;function bt(e){return e.length<=vn?e:`${e.slice(0,vn)}
|
|
8
|
-
… (${e.length-vn} more characters not shown)`}const Cd=/\bhas been updated\b|\bsuccessfully (?:over)?written\b|\bupdated successfully\b/i,Id=/\b(?:file )?created successfully\b|\bnew file created\b/i;function sa({name:e,input:t,result:n}){const a=na(e);let s=_d(e);const i=nn(t),o=n?.output??"",l=n===null;s==="create"&&n&&Cd.test(o)&&!Id.test(o)&&(s="edit");const u=yd(t),d=u[0]??null;let f=null;if(i)for(const g of wd){const _=Zt(i[g]);if(_){f={command:_,exitCode:n?Sd(o):null},s==="other"&&(s="command");break}}let y=null,m=null;if(n&&Vs(o)&&(y={text:bt(o),anchored:!0,multiFile:Xs(o)>1,origin:"output"}),!y&&i){const g=Zt(i.patch)??Zt(i.diff);g&&Vs(g)&&(y={text:bt(g),anchored:!0,multiFile:Xs(g)>1,origin:"payload"})}if(!y&&i&&d){const g=Ys(i),_=i.edits??i.replacements??i.changes,x=Array.isArray(_)?_.map(Ys).filter(k=>k!==null):[],w=x.length>0?x:g?[g]:[];if(w.length>0){const k=Ad(d,w);k&&(y={text:bt(k),anchored:!1,multiFile:!1,origin:"payload"}),s==="other"&&(s="edit")}}if(!y&&i&&d){const g=typeof i.content=="string"?i.content:typeof i.contents=="string"?i.contents:typeof i.text=="string"&&(s==="create"||s==="edit")?i.text:null;if(g!==null)if(s==="create"){const _=Rd(d,g);_&&(y={text:bt(_),anchored:!0,multiFile:!1,origin:"payload"})}else m={path:d,text:bt(g)}}const S=n!==null&&(n.isError||(f?.exitCode??0)>0);return{base:a,action:s,paths:u,command:f,diff:y,written:m,failed:S,pending:l}}function ra(e){return`verse-tool-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function $d(){return{facts:new Map,counts:new Map,toolText:new Map}}function Ld(e,t){const n=t?.facts.get(e.toolUseId);if(n&&!(n.pending&&e.result!==null))return n;const a=sa({name:e.name,input:e.input,result:e.result});return t&&(t.facts.set(e.toolUseId,a),t.counts.delete(e.toolUseId),t.toolText.delete(e.toolUseId)),a}function sn(e){return`verse-note-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}function Md(e){return`verse-turn-${e.replace(/[^A-Za-z0-9_-]/g,"")}`}const Gt={read:0,edit:1,create:2,delete:3};function aa(e){let t=0,n=0;for(const a of Br(e).files)t+=a.additions,n+=a.deletions;return{additions:t,deletions:n}}function Dd(e,t,n){const a=n?.counts.get(e);if(a)return a;const s=aa(t);return n?.counts.set(e,s),s}function Pd(e){return e.kind==="tool"?[e]:e.kind==="toolGroup"?e.items.filter(t=>t.kind==="tool"):[]}function Od(e,t=null){const n=new Map,a=[],s=[];let i=[];const o=()=>{i.length!==0&&(s.push(zd(i,n,a,t)),i=[])};let l;for(const u of e){const d="turnId"in u?u.turnId:null;(u.kind==="user"||l!==void 0&&d!==null&&d!==l)&&o(),(u.kind==="user"||l===void 0||d!==null)&&(l=d),i.push(u)}return o(),{turns:s,facts:n,errorAnchors:a}}function zd(e,t,n,a){const s=e[0],i=new Map;let o=0,l=0,u=0,d=null,f="running",y=null,m=null;const S=g=>{u++,d||(d=g),n.push(g)};for(const g of e){g.kind==="user"&&m===null&&(m=g.text);for(const _ of Pd(g)){o++;const x=Ld(_,a);t.set(_.toolUseId,x),x.action==="command"&&l++,x.failed&&S(`verse-tool-${_.toolUseId.replace(/[^A-Za-z0-9_-]/g,"")}`);const w=x.action;if(w!=="read"&&w!=="edit"&&w!=="create"&&w!=="delete")continue;const k=x.diff?Dd(_.toolUseId,x.diff.text,a):{additions:0,deletions:0};for(const R of x.paths){const j=i.get(R)??{path:R,reads:0,edits:0,creates:0,deletes:0,action:w,anchorToolUseId:_.toolUseId,additions:0,deletions:0,failed:!1};w==="read"?j.reads++:w==="edit"?j.edits++:w==="create"?j.creates++:j.deletes++,Gt[w]>Gt[j.action]&&(j.action=w,j.anchorToolUseId=_.toolUseId),w!=="read"&&(j.additions+=k.additions,j.deletions+=k.deletions),x.failed&&(j.failed=!0),i.set(R,j)}}switch(g.kind){case"error":S(sn(g.key)),f="error";break;case"cancelled":f="stopped";break;case"turn-done":y=g.durationMs>0?g.durationMs:y,g.ok?f=f==="running"?"ok":f:f==="running"&&(f="error",S(sn(g.key)));break}}return{key:s.key,turnId:"turnId"in s?s.turnId:null,items:e,prompt:m,at:s.at,files:[...i.values()].sort((g,_)=>Gt[_.action]-Gt[g.action]||_.additions+_.deletions-(g.additions+g.deletions)||g.path.localeCompare(_.path)),toolCount:o,commandCount:l,errorCount:u,firstErrorAnchor:d,status:f,durationMs:y}}function Fd(e){if(e.length===0)return"";const t={edited:0,created:0,deleted:0,read:0};for(const a of e)a.action==="edit"?t.edited++:a.action==="create"?t.created++:a.action==="delete"?t.deleted++:t.read++;const n=[];return t.created&&n.push(`${t.created} created`),t.edited&&n.push(`${t.edited} edited`),t.deleted&&n.push(`${t.deleted} deleted`),t.read&&n.push(`${t.read} read`),n.join(", ")}const Zs=new WeakMap,An=4e3;function Hd(e,t){const n=t?.toolText.get(e.toolUseId);if(n!==void 0)return n;const a=[e.name];if(typeof e.input=="string")a.push(e.input.slice(0,An));else if(e.input)try{a.push(JSON.stringify(e.input).slice(0,An))}catch{}e.result&&a.push(e.result.output.slice(0,An));const s=a.join(`
|
|
9
|
-
`);return t&&e.result&&t.toolText.set(e.toolUseId,s),s}function Bd(e,t=null){const n=Zs.get(e);if(n!==void 0)return n;const a=[],s=o=>{switch(o.kind){case"user":case"assistant":case"thinking":a.push(o.text);break;case"error":a.push(o.message);break;case"tool":a.push(Hd(o,t));break;case"toolGroup":for(const l of o.items)s(l);break}};for(const o of e.items)s(o);const i=a.join(`
|
|
10
|
-
`);return Zs.set(e,i),i}const Qs=48;function Ud(e,t,n=null){const a=t.trim().toLowerCase();if(a.length===0)return[];const s=[];for(const i of e){const o=Bd(i,n),l=o.toLowerCase().indexOf(a);if(l===-1)continue;const u=Math.max(0,l-Qs),d=Math.min(o.length,l+a.length+Qs),f=`${u>0?"…":""}${o.slice(u,d).replace(/\s+/g," ").trim()}${d<o.length?"…":""}`;s.push({turnKey:i.key,snippet:f})}return s}function qd(e,t=72){const n=e.prompt?.replace(/\s+/g," ").trim();return n?n.length>t?`${n.slice(0,t-1)}…`:n:e.toolCount>0?`${e.toolCount} tool call${e.toolCount===1?"":"s"}`:"Session note"}const Wd="_diff_6z1ga_30",Gd="_visuallyHidden_6z1ga_46",Kd="_diffMulti_6z1ga_58",Vd="_diffHead_6z1ga_60",Xd="_diffPath_6z1ga_68",Yd="_diffOldPath_6z1ga_83",Zd="_diffStatus_6z1ga_101",Qd="_diffStats_6z1ga_110",Jd="_diffAdd_6z1ga_118",eh="_diffDel_6z1ga_119",th="_diffNotice_6z1ga_121",nh="_diffEmpty_6z1ga_130",sh="_diffTable_6z1ga_136",rh="_diffNo_6z1ga_121",ah="_diffMarker_6z1ga_30",oh="_diffText_6z1ga_159",ih="_diffCode_6z1ga_179",lh="_diffRow_add_6z1ga_181",ch="_diffRow_del_6z1ga_182",uh="_diffRow_context_6z1ga_183",dh="_diffHunkRow_6z1ga_185",hh="_diffHunkHead_6z1ga_192",ph="_diffMore_6z1ga_200",fh="_commandMore_6z1ga_201",mh="_activityMore_6z1ga_202",gh="_diffUnanchored_6z1ga_221",_h="_tok_plain_6z1ga_232",xh="_tok_comment_6z1ga_233",yh="_tok_string_6z1ga_234",bh="_tok_number_6z1ga_235",kh="_tok_keyword_6z1ga_236",wh="_command_6z1ga_201",Th="_commandLine_6z1ga_250",Sh="_commandPrompt_6z1ga_257",jh="_commandText_6z1ga_264",Nh="_commandStatus_6z1ga_274",Eh="_commandStatusText_6z1ga_282",vh="_commandMeta_6z1ga_292",Ah="_commandPre_6z1ga_297",Rh="_commandPending_6z1ga_309",Ch="_activity_6z1ga_202",Ih="_activityHead_6z1ga_327",$h="_activityCount_6z1ga_336",Lh="_activityLabel_6z1ga_343",Mh="_activityBreakdown_6z1ga_350",Dh="_activityList_6z1ga_356",Ph="_activityRow_6z1ga_358",Oh="_activityRule_6z1ga_380",zh="_activityVerb_6z1ga_375",Fh="_activityFailed_6z1ga_379",Hh="_activityPath_6z1ga_411",Bh="_activityName_6z1ga_419",Uh="_activityDir_6z1ga_420",qh="_activityTimes_6z1ga_430",Wh="_activityDelta_6z1ga_431",Gh="_activityAdd_6z1ga_439",Kh="_activityDel_6z1ga_431",Vh="_nav_6z1ga_446",Xh="_navSpacer_6z1ga_457",Yh="_navOutlineButton_6z1ga_459",Zh="_navChevron_6z1ga_473",Qh="_navCount_6z1ga_475",Jh="_navWord_6z1ga_481",ep="_navSearch_6z1ga_488",tp="_navSearchIcon_6z1ga_512",np="_navMatches_6z1ga_525",sp="_navStep_6z1ga_532",rp="_navError_6z1ga_545",ap="_navErrorGlyph_6z1ga_563",op="_outline_6z1ga_568",ip="_outlineEmpty_6z1ga_582",lp="_outlineList_6z1ga_587",cp="_outlineRow_6z1ga_588",up="_outlineIndex_6z1ga_602",dp="_outlineBody_6z1ga_609",hp="_outlineTitle_6z1ga_610",pp="_outlineSnippet_6z1ga_617",fp="_outlineMeta_6z1ga_627",mp="_outlineStatus_6z1ga_631",A={diff:Wd,visuallyHidden:Gd,diffMulti:Kd,diffHead:Vd,diffPath:Xd,diffOldPath:Yd,diffStatus:Zd,diffStats:Qd,diffAdd:Jd,diffDel:eh,diffNotice:th,diffEmpty:nh,diffTable:sh,diffNo:rh,diffMarker:ah,diffText:oh,diffCode:ih,diffRow_add:lh,diffRow_del:ch,diffRow_context:uh,diffHunkRow:dh,diffHunkHead:hh,diffMore:ph,commandMore:fh,activityMore:mh,diffUnanchored:gh,tok_plain:_h,tok_comment:xh,tok_string:yh,tok_number:bh,tok_keyword:kh,command:wh,commandLine:Th,commandPrompt:Sh,commandText:jh,commandStatus:Nh,commandStatusText:Eh,commandMeta:vh,commandPre:Ah,commandPending:Rh,activity:Ch,activityHead:Ih,activityCount:$h,activityLabel:Lh,activityBreakdown:Mh,activityList:Dh,activityRow:Ph,activityRule:Oh,activityVerb:zh,activityFailed:Fh,activityPath:Hh,activityName:Bh,activityDir:Uh,activityTimes:qh,activityDelta:Wh,activityAdd:Gh,activityDel:Kh,nav:Vh,navSpacer:Xh,navOutlineButton:Yh,navChevron:Zh,navCount:Qh,navWord:Jh,navSearch:ep,navSearchIcon:tp,navMatches:np,navStep:sp,navError:rp,navErrorGlyph:ap,outline:op,outlineEmpty:ip,outlineList:lp,outlineRow:cp,outlineIndex:up,outlineBody:dp,outlineTitle:hp,outlineSnippet:pp,outlineMeta:fp,outlineStatus:mp},Js=8,er={read:"read",edit:"edited",create:"created",delete:"deleted"};function gp({files:e,onJump:t}){const[n,a]=p.useState(!1);if(e.length===0)return null;const s=n||e.length<=Js?e:e.slice(0,Js),i=e.length-s.length;return r.jsxs("section",{className:A.activity,"aria-label":"Files this turn touched",children:[r.jsxs("h3",{className:A.activityHead,children:[r.jsx("span",{className:A.activityCount,children:e.length}),r.jsxs("span",{className:A.activityLabel,children:["file",e.length===1?"":"s"]}),r.jsx("span",{className:A.activityBreakdown,children:Fd(e)})]}),r.jsx("ul",{className:A.activityList,children:s.map(o=>{const l=o.reads+o.edits+o.creates+o.deletes,u=`${er[o.action]} ${o.path}${l>1?`, ${l} calls`:""}${o.additions||o.deletions?`, +${o.additions} −${o.deletions}`:""}${o.failed?", a call on this file failed":""}`;return r.jsx("li",{children:r.jsxs("button",{type:"button",className:A.activityRow,"data-action":o.action,"data-failed":o.failed?"true":void 0,onClick:()=>t(o.anchorToolUseId),"aria-label":u,title:o.path,children:[r.jsx("span",{className:A.activityRule,"aria-hidden":"true"}),r.jsx("span",{className:A.activityVerb,children:er[o.action]}),r.jsxs("span",{className:A.activityPath,children:[r.jsx("span",{className:A.activityName,children:bd(o.path)}),r.jsx("span",{className:A.activityDir,children:kd(o.path)})]}),o.failed?r.jsx("span",{className:A.activityFailed,"aria-hidden":"true",children:"! failed"}):null,l>1?r.jsxs("span",{className:A.activityTimes,children:["×",l]}):null,r.jsxs("span",{className:A.activityDelta,children:[o.additions>0?r.jsxs("span",{className:A.activityAdd,children:["+",o.additions]}):null,o.deletions>0?r.jsxs("span",{className:A.activityDel,children:["−",o.deletions]}):null]})]})},o.path)})}),i>0||n?r.jsx("button",{type:"button",className:A.activityMore,"aria-expanded":n,onClick:()=>a(o=>!o),children:n?"Show fewer files":`Show ${i} more file${i===1?"":"s"}`}):null]})}const tr={running:"•",ok:"",error:"!",stopped:"×"},_p={running:"running",ok:"completed",error:"failed",stopped:"stopped"};function xp(e){const{turns:t,query:n,onQuery:a,matches:s,matchIndex:i,onStepMatch:o,errorCount:l,onJumpError:u,onJumpTurn:d,focusToken:f}=e,[y,m]=p.useState(!1),S=p.useRef(null),g=p.useId(),_=p.useId(),x=n.trim().length>0;p.useEffect(()=>{f>0&&(S.current?.focus(),S.current?.select())},[f]),p.useEffect(()=>{if(!y)return;const R=j=>{j.key==="Escape"&&m(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[y]);const w=x?t.filter(R=>s.some(j=>j.turnKey===R.key)):t,k=R=>s.find(j=>j.turnKey===R)?.snippet??null;return r.jsxs("div",{className:A.nav,children:[r.jsxs("button",{type:"button",className:A.navOutlineButton,"aria-expanded":y,"aria-controls":y?g:void 0,onClick:()=>m(R=>!R),children:[r.jsx("span",{className:A.navChevron,"data-open":y?"true":void 0,"aria-hidden":"true",children:r.jsx(xo,{size:12})}),r.jsx("span",{className:A.navCount,children:t.length}),r.jsxs("span",{className:A.navWord,children:["turn",t.length===1?"":"s"]})]}),r.jsxs("label",{className:A.navSearch,htmlFor:_,children:[r.jsx("span",{className:A.navSearchIcon,"aria-hidden":"true",children:r.jsx(Pr,{size:12})}),r.jsx("span",{className:"visually-hidden",children:"Search this chat"}),r.jsx("input",{ref:S,id:_,type:"search",value:n,placeholder:"Find in chat",autoComplete:"off",onChange:R=>a(R.target.value),onKeyDown:R=>{R.key==="Enter"?(R.preventDefault(),o(R.shiftKey?-1:1)):R.key==="Escape"&&(R.preventDefault(),a(""))}})]}),x?r.jsx("span",{className:A.navMatches,role:"status",children:s.length===0?"no matches":`${i<0?1:i+1} of ${s.length}`}):null,x&&s.length>0?r.jsxs("span",{className:A.navStep,children:[r.jsx("button",{type:"button",onClick:()=>o(-1),"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:"↑"}),r.jsx("button",{type:"button",onClick:()=>o(1),"aria-label":"Next match",title:"Next match (Enter)",children:"↓"})]}):null,r.jsx("span",{className:A.navSpacer}),l>0?r.jsxs("button",{type:"button",className:A.navError,onClick:u,children:[r.jsx("span",{className:A.navErrorGlyph,"aria-hidden":"true",children:"!"}),l," error",l===1?"":"s",r.jsx("span",{className:"visually-hidden",children:" — jump to the first one"})]}):null,y?r.jsx("div",{id:g,className:A.outline,role:"group","aria-label":"Turns in this chat",children:w.length===0?r.jsxs("p",{className:A.outlineEmpty,children:["No turn matches “",n.trim(),"”."]}):r.jsx("ol",{className:A.outlineList,children:w.map(R=>{const j=t.indexOf(R)+1,O=k(R.key);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:A.outlineRow,"data-status":R.status,onClick:()=>{m(!1),d(R.key)},children:[r.jsx("span",{className:A.outlineIndex,children:j}),r.jsxs("span",{className:A.outlineBody,children:[r.jsx("span",{className:A.outlineTitle,children:qd(R)}),O?r.jsx("span",{className:A.outlineSnippet,children:O}):null,r.jsxs("span",{className:A.outlineMeta,children:[R.toolCount>0?`${R.toolCount} tool${R.toolCount===1?"":"s"}`:"no tools",R.files.length>0?` · ${R.files.length} file${R.files.length===1?"":"s"}`:"",R.status!=="ok"?` · ${_p[R.status]}`:""]})]}),tr[R.status]?r.jsx("span",{className:A.outlineStatus,"aria-hidden":"true",children:tr[R.status]}):null]})},R.key)})})}):null]})}/*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE */function nr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function yp(e){if(Array.isArray(e))return e}function bp(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var a,s,i,o,l=[],u=!0,d=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(a=i.call(n)).done)&&(l.push(a.value),l.length!==t);u=!0);}catch(f){d=!0,s=f}finally{try{if(!u&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(d)throw s}}return l}}function kp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
11
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wp(e,t){return yp(e)||bp(e,t)||Tp(e,t)||kp()}function Tp(e,t){if(e){if(typeof e=="string")return nr(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nr(e,t):void 0}}const oa=Object.entries,sr=Object.setPrototypeOf,Sp=Object.isFrozen,jp=Object.getPrototypeOf,Np=Object.getOwnPropertyDescriptor;let _e=Object.freeze,xe=Object.seal,ht=Object.create,ia=typeof Reflect<"u"&&Reflect,Hn=ia.apply,Bn=ia.construct;_e||(_e=function(t){return t});xe||(xe=function(t){return t});Hn||(Hn=function(t,n){for(var a=arguments.length,s=new Array(a>2?a-2:0),i=2;i<a;i++)s[i-2]=arguments[i];return t.apply(n,s)});Bn||(Bn=function(t){for(var n=arguments.length,a=new Array(n>1?n-1:0),s=1;s<n;s++)a[s-1]=arguments[s];return new t(...a)});const et=ge(Array.prototype.forEach),Ep=ge(Array.prototype.lastIndexOf),rr=ge(Array.prototype.pop),kt=ge(Array.prototype.push),vp=ge(Array.prototype.splice),pt=Array.isArray,Nt=ge(String.prototype.toLowerCase),Rn=ge(String.prototype.toString),ar=ge(String.prototype.match),wt=ge(String.prototype.replace),or=ge(String.prototype.indexOf),Ap=ge(String.prototype.trim),Rp=ge(Number.prototype.toString),Cp=ge(Boolean.prototype.toString),ir=typeof BigInt>"u"?null:ge(BigInt.prototype.toString),lr=typeof Symbol>"u"?null:ge(Symbol.prototype.toString),Ie=ge(Object.prototype.hasOwnProperty),Tt=ge(Object.prototype.toString),we=ge(RegExp.prototype.test),Je=Ip(TypeError);function ge(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,a=new Array(n>1?n-1:0),s=1;s<n;s++)a[s-1]=arguments[s];return Hn(e,t,a)}}function Ip(e){return function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return Bn(e,n)}}function Y(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Nt;if(sr&&sr(e,null),!pt(t))return e;let a=t.length;for(;a--;){let s=t[a];if(typeof s=="string"){const i=n(s);i!==s&&(Sp(t)||(t[a]=i),s=i)}e[s]=!0}return e}function $p(e){for(let t=0;t<e.length;t++)Ie(e,t)||(e[t]=null);return e}function Me(e){const t=ht(null);for(const a of oa(e)){var n=wp(a,2);const s=n[0],i=n[1];Ie(e,s)&&(pt(i)?t[s]=$p(i):i&&typeof i=="object"&&i.constructor===Object?t[s]=Me(i):t[s]=i)}return t}function Lp(e){switch(typeof e){case"string":return e;case"number":return Rp(e);case"boolean":return Cp(e);case"bigint":return ir?ir(e):"0";case"symbol":return lr?lr(e):"Symbol()";case"undefined":return Tt(e);case"function":case"object":{if(e===null)return Tt(e);const t=e,n=Pe(t,"toString");if(typeof n=="function"){const a=n(t);return typeof a=="string"?a:Tt(a)}return Tt(e)}default:return Tt(e)}}function Pe(e,t){for(;e!==null;){const a=Np(e,t);if(a){if(a.get)return ge(a.get);if(typeof a.value=="function")return ge(a.value)}e=jp(e)}function n(){return null}return n}function Mp(e){try{return we(e,""),!0}catch{return!1}}const cr=_e(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Cn=_e(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),In=_e(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Dp=_e(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),$n=_e(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Pp=_e(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ur=_e(["#text"]),dr=_e(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ln=_e(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),hr=_e(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Kt=_e(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Op=xe(/{{[\w\W]*|^[\w\W]*}}/g),zp=xe(/<%[\w\W]*|^[\w\W]*%>/g),Fp=xe(/\${[\w\W]*/g),Hp=xe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Bp=xe(/^aria-[\-\w]+$/),pr=xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Up=xe(/^(?:\w+script|data):/i),qp=xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Wp=xe(/^html$/i),Gp=xe(/^[a-z][.\w]*(-[.\w]+)+$/i),fr=xe(/<[/\w!]/g),mr=xe(/<[/\w]/g),Kp=xe(/<\/no(script|embed|frames)/i),Vp=xe(/\/>/i),Le={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},la=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Xp=_e(Y({},la)),Yp=(function(){const e={};return et(la,t=>{e[t]=xe(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),_e(e)})(),Zp=function(){return typeof window>"u"?null:window},Qp=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let a=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(a=n.getAttribute(s));const i="dompurify"+(a?"#"+a:"");try{return t.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},gr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Xe=function(t,n,a,s){return Ie(t,n)&&pt(t[n])?Y(s.base?Me(s.base):{},t[n],s.transform):a},Mn=function(t,n,a){const s=Ie(t,n)?t[n]:void 0;return s&&typeof s=="object"?Me(s):a()};function ca(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zp();const t=T=>ca(T);if(t.version="3.4.15",t.removed=[],!e||!e.document||e.document.nodeType!==Le.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const a=n,s=a.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,o=e.Node,l=e.Element,u=e.NodeFilter,d=e.NamedNodeMap;d===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const f=e.DOMParser,y=e.trustedTypes,m=l.prototype,S=Pe(m,"cloneNode"),g=Pe(m,"remove"),_=Pe(m,"removeAttributeNode"),x=Pe(m,"nextSibling"),w=Pe(m,"childNodes"),k=Pe(m,"parentNode"),R=Pe(m,"shadowRoot"),j=Pe(m,"attributes"),O=o&&o.prototype?Pe(o.prototype,"nodeType"):null,G=o&&o.prototype?Pe(o.prototype,"nodeName"):null,pe=o&&o.prototype?Pe(o.prototype,"ownerDocument"):null,de=function(c){return O?O(c):c.nodeType},Q=function(c){return G?G(c):c.nodeName};if(typeof i=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let q,ie="",te,fe=!1,V=0;const me=function(){if(V>0)throw Je('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ne=function(c){me(),V++;try{return q.createHTML(c)}finally{V--}},X=function(c){me(),V++;try{return q.createScriptURL(c)}finally{V--}},se=function(){return fe||(te=Qp(y,s),fe=!0),te},J=n,N=J.implementation,$=J.createNodeIterator,P=J.createDocumentFragment,ye=J.getElementsByTagName,z=a.importNode;let F=gr();t.isSupported=typeof oa=="function"&&typeof k=="function"&&N&&N.createHTMLDocument!==void 0;const ke=Op,Te=zp,$e=Fp,M=Hp,K=Bp,be=Up,He=qp,gt=Gp;let C=pr,v=null;const le=Y({},[...cr,...Cn,...In,...$n,...ur]);let B=null;const Se=Y({},[...dr,...Ln,...hr,...Kt]);let je=Object.seal(ht(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),We=null,os=null;const Ge=Object.seal(ht(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let is=!0,hn=!0,ls=!1,cs=!0,Ke=!1,Ye=!0,Ze=!1,pn=!1,It=null,$t=null,fn=!1,at=!1,Lt=!1,Mt=!1,us=!0,ds=!1;const hs="user-content-";let mn=!0,gn=!1,ot={},it=null;const ps=Y({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let fs=null;const ms=Y({},["audio","video","img","source","image","track"]);let gs=null;const _s=Y({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Dt="http://www.w3.org/1998/Math/MathML",Pt="http://www.w3.org/2000/svg",Be="http://www.w3.org/1999/xhtml";let lt=Be,_n=!1,xn=null;const Sa=Y({},[Dt,Pt,Be],Rn),xs=_e(["mi","mo","mn","ms","mtext"]);let yn=Y({},xs);const ys=_e(["annotation-xml"]);let bn=Y({},ys);const ja=Y({},["title","style","font","a","script"]);let _t=null;const Na=["application/xhtml+xml","text/html"],Ea="text/html";let he=null,ct=null;const va=n.createElement("form"),bs=function(c){return c instanceof RegExp||c instanceof Function},kn=function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ct&&ct===c)return;(!c||typeof c!="object")&&(c={}),c=Me(c),_t=Na.indexOf(c.PARSER_MEDIA_TYPE)===-1?Ea:c.PARSER_MEDIA_TYPE,he=_t==="application/xhtml+xml"?Rn:Nt,v=Xe(c,"ALLOWED_TAGS",le,{transform:he}),B=Xe(c,"ALLOWED_ATTR",Se,{transform:he}),xn=Xe(c,"ALLOWED_NAMESPACES",Sa,{transform:Rn}),gs=Xe(c,"ADD_URI_SAFE_ATTR",_s,{transform:he,base:_s}),fs=Xe(c,"ADD_DATA_URI_TAGS",ms,{transform:he,base:ms}),it=Xe(c,"FORBID_CONTENTS",ps,{transform:he}),We=Xe(c,"FORBID_TAGS",Me({}),{transform:he}),os=Xe(c,"FORBID_ATTR",Me({}),{transform:he}),ot=Ie(c,"USE_PROFILES")?c.USE_PROFILES&&typeof c.USE_PROFILES=="object"?Me(c.USE_PROFILES):c.USE_PROFILES:!1,is=c.ALLOW_ARIA_ATTR!==!1,hn=c.ALLOW_DATA_ATTR!==!1,ls=c.ALLOW_UNKNOWN_PROTOCOLS||!1,cs=c.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ke=c.SAFE_FOR_TEMPLATES||!1,Ye=c.SAFE_FOR_XML!==!1,Ze=c.WHOLE_DOCUMENT||!1,at=c.RETURN_DOM||!1,Lt=c.RETURN_DOM_FRAGMENT||!1,Mt=c.RETURN_TRUSTED_TYPE||!1,fn=c.FORCE_BODY||!1,us=c.SANITIZE_DOM!==!1,ds=c.SANITIZE_NAMED_PROPS||!1,mn=c.KEEP_CONTENT!==!1,gn=c.IN_PLACE||!1,C=Mp(c.ALLOWED_URI_REGEXP)?c.ALLOWED_URI_REGEXP:pr,lt=typeof c.NAMESPACE=="string"?c.NAMESPACE:Be,yn=Mn(c,"MATHML_TEXT_INTEGRATION_POINTS",()=>Y({},xs)),bn=Mn(c,"HTML_INTEGRATION_POINTS",()=>Y({},ys));const h=Mn(c,"CUSTOM_ELEMENT_HANDLING",()=>ht(null));if(je=ht(null),Ie(h,"tagNameCheck")&&bs(h.tagNameCheck)&&(je.tagNameCheck=h.tagNameCheck),Ie(h,"attributeNameCheck")&&bs(h.attributeNameCheck)&&(je.attributeNameCheck=h.attributeNameCheck),Ie(h,"allowCustomizedBuiltInElements")&&typeof h.allowCustomizedBuiltInElements=="boolean"&&(je.allowCustomizedBuiltInElements=h.allowCustomizedBuiltInElements),xe(je),Ke&&(hn=!1),Lt&&(at=!0),ot&&(v=Y({},ur),B=ht(null),ot.html===!0&&(Y(v,cr),Y(B,dr)),ot.svg===!0&&(Y(v,Cn),Y(B,Ln),Y(B,Kt)),ot.svgFilters===!0&&(Y(v,In),Y(B,Ln),Y(B,Kt)),ot.mathMl===!0&&(Y(v,$n),Y(B,hr),Y(B,Kt))),Ge.tagCheck=null,Ge.attributeCheck=null,Ie(c,"ADD_TAGS")&&(typeof c.ADD_TAGS=="function"?Ge.tagCheck=c.ADD_TAGS:pt(c.ADD_TAGS)&&(v===le&&(v=Me(v)),Y(v,c.ADD_TAGS,he))),Ie(c,"ADD_ATTR")&&(typeof c.ADD_ATTR=="function"?Ge.attributeCheck=c.ADD_ATTR:pt(c.ADD_ATTR)&&(B===Se&&(B=Me(B)),Y(B,c.ADD_ATTR,he))),Ie(c,"ADD_FORBID_CONTENTS")&&pt(c.ADD_FORBID_CONTENTS)&&(it===ps&&(it=Me(it)),Y(it,c.ADD_FORBID_CONTENTS,he)),mn&&(v["#text"]=!0),Ze&&Y(v,["html","head","body"]),v.table&&(Y(v,["tbody"]),delete We.tbody),c.TRUSTED_TYPES_POLICY){if(typeof c.TRUSTED_TYPES_POLICY.createHTML!="function")throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof c.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const b=q;q=c.TRUSTED_TYPES_POLICY;try{ie=ne("")}catch(I){throw q=b,I}}else c.TRUSTED_TYPES_POLICY===null?(q=void 0,ie=""):(q===void 0&&(q=se()),q&&typeof ie=="string"&&(ie=ne("")));_e&&_e(c),ct=c},ks=Y({},[...Cn,...In,...Dp]),ws=Y({},[...$n,...Pp]),Aa=function(c,h,b){return h.namespaceURI===Be?c==="svg":h.namespaceURI===Dt?c==="svg"&&(b==="annotation-xml"||yn[b]):!!ks[c]},Ra=function(c,h,b){return h.namespaceURI===Be?c==="math":h.namespaceURI===Pt?c==="math"&&bn[b]:!!ws[c]},Ca=function(c,h,b){return h.namespaceURI===Pt&&!bn[b]||h.namespaceURI===Dt&&!yn[b]?!1:!ws[c]&&(ja[c]||!ks[c])},Ia=function(c){let h=k(c);(!h||!h.tagName)&&(h={namespaceURI:lt,tagName:"template"});const b=Nt(c.tagName),I=Nt(h.tagName);return xn[c.namespaceURI]?c.namespaceURI===Pt?Aa(b,h,I):c.namespaceURI===Dt?Ra(b,h,I):c.namespaceURI===Be?Ca(b,h,I):!!(_t==="application/xhtml+xml"&&xn[c.namespaceURI]):!1},Ve=function(c){kt(t.removed,{element:c});try{k(c).removeChild(c)}catch{if(g(c),!k(c))throw Je("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ts=function(c,h,b){try{_(c,h)}catch{try{c.removeAttribute(b)}catch{}}},Ot=function(c){zt(c);const h=w(c);if(h){const I=[];et(h,L=>{kt(I,L)}),et(I,L=>{try{g(L)}catch{}})}const b=j(c);if(b)for(let I=b.length-1;I>=0;--I){const L=b[I],H=L&&L.name;typeof H=="string"&&Ts(c,L,H)}},Qe=function(c,h,b){if(!b)try{b=h.getAttributeNode(c)}catch{b=null}kt(t.removed,{attribute:b||null,from:h});try{b?_(h,b):h.removeAttribute(c)}catch{try{h.removeAttribute(c)}catch{}}if(c==="is")if(at||Lt)try{Ve(h)}catch{}else try{h.setAttribute(c,"")}catch{}},$a=function(c){const h=j(c);if(h)for(let b=h.length-1;b>=0;--b){const I=h[b],L=I&&I.name;typeof L!="string"||B[he(L)]||Ts(c,I,L)}},zt=function(c){const h=[c];for(;h.length>0;){const b=h.pop();de(b)===Le.element&&$a(b);const L=w(b);if(L)for(let H=L.length-1;H>=0;--H)h.push(L[H])}},Ss=function(c,h){return Ye?c==="patchsrc"?!0:c==="for"&&h!=="label"&&h!=="output":!1},La=function(c){if(!Ye)return;const h=[c];for(;h.length>0;){const b=h.pop(),I=de(b);if(I===Le.processingInstruction||I===Le.comment&&we(mr,b.data)){try{g(b)}catch{}continue}if(I===Le.element){const H=b,ae=he(Q(b));try{H.hasAttribute&&H.hasAttribute("patchsrc")&&H.removeAttribute("patchsrc"),H.hasAttribute&&H.hasAttribute("for")&&Ss("for",ae)&&H.removeAttribute("for")}catch{}}const L=w(b);if(L)for(let H=L.length-1;H>=0;--H)h.push(L[H])}},js=function(c){let h=null,b=null;if(fn)c="<remove></remove>"+c;else{const H=ar(c,/^[\r\n\t ]+/);b=H&&H[0]}_t==="application/xhtml+xml"&<===Be&&(c='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+c+"</body></html>");const I=q?ne(c):c;if(lt===Be)try{h=new f().parseFromString(I,_t)}catch{}if(!h||!h.documentElement){h=N.createDocument(lt,"template",null);try{h.documentElement.innerHTML=_n?ie:I}catch{}}const L=h.body||h.documentElement;return c&&b&&L.insertBefore(n.createTextNode(b),L.childNodes[0]||null),lt===Be?ye.call(h,Ze?"html":"body")[0]:Ze?h.documentElement:L},Ns=function(c){const h=pe?pe(c):c.ownerDocument;return $.call(h||c,c,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ft=function(c){return c=wt(c,ke," "),c=wt(c,Te," "),c=wt(c,$e," "),c},wn=function(c){var h;c.normalize();const b=pe?pe(c):c.ownerDocument,I=$.call(b||c,c,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let L=I.nextNode();for(;L;)L.data=Ft(L.data),L=I.nextNode();const H=(h=c.querySelectorAll)===null||h===void 0?void 0:h.call(c,"template");H&&et(H,ae=>{ut(ae.content)&&wn(ae.content)})},Ht=function(c){const h=G?G(c):null;return typeof h!="string"||he(h)!=="form"?!1:typeof c.nodeName!="string"||typeof c.textContent!="string"||typeof c.removeChild!="function"||c.attributes!==j(c)||typeof c.removeAttribute!="function"||typeof c.removeAttributeNode!="function"||typeof c.getAttributeNode!="function"||typeof c.setAttribute!="function"||typeof c.namespaceURI!="string"||typeof c.insertBefore!="function"||typeof c.hasChildNodes!="function"||c.nodeType!==O(c)||c.childNodes!==w(c)},ut=function(c){if(!O||typeof c!="object"||c===null)return!1;try{return O(c)===Le.documentFragment}catch{return!1}},xt=function(c){if(!O||typeof c!="object"||c===null)return!1;try{return typeof O(c)=="number"}catch{return!1}};function Ue(T,c,h){T.length!==0&&et(T,b=>{b.call(t,c,h,ct)})}const Ma=function(c,h){return!!(Ye&&c.hasChildNodes()&&!xt(c.firstElementChild)&&we(fr,c.textContent)&&we(fr,c.innerHTML)||Ye&&c.namespaceURI===Be&&Xp[h]&&(xt(c.firstElementChild)||typeof c.textContent=="string"&&we(Yp[h],c.textContent))||c.nodeType===Le.processingInstruction||Ye&&c.nodeType===Le.comment&&we(mr,c.data))},Bt=function(c,h){if(c instanceof RegExp)return we(c,h);if(c instanceof Function){for(var b=arguments.length,I=new Array(b>2?b-2:0),L=2;L<b;L++)I[L-2]=arguments[L];return!!c(h,...I)}return!1},Da=function(c,h,b){if(!We[h]&&Cs(h)&&Bt(je.tagNameCheck,h))return!1;if(mn&&!it[h]){const I=k(c),L=w(c);if(L&&I){const H=L.length;for(let ae=H-1;ae>=0;--ae){const ue=c===b?S(L[ae],!0):L[ae];I.insertBefore(ue,x(c))}}}return Ve(c),!0},Es=function(c,h,b,I){return c.length===0?h:h===b||h===I?Me(h):h},vs=function(c,h){return c===h||k(c)!==null?!1:(gn&&zt(c),!0)},As=function(c,h){if(Ue(F.beforeSanitizeElements,c,null),vs(c,h))return!0;if(Ht(c))return Ve(c),!0;const b=he(Q(c));if(v=Es(F.uponSanitizeElement,v,le,It),Ue(F.uponSanitizeElement,c,{tagName:b,allowedTags:v}),vs(c,h))return!0;if(Ma(c,b))return Ve(c),!0;if(We[b]||!(Ge.tagCheck instanceof Function&&Ge.tagCheck(b))&&!v[b]){const L=Da(c,b,h);return L===!1&&Ue(F.afterSanitizeElements,c,null),L}if(de(c)===Le.element&&!Ia(c)||(b==="noscript"||b==="noembed"||b==="noframes")&&we(Kp,c.innerHTML))return Ve(c),!0;if(Ke&&c.nodeType===Le.text){const L=Ft(c.textContent);c.textContent!==L&&(kt(t.removed,{element:c.cloneNode()}),c.textContent=L)}return Ue(F.afterSanitizeElements,c,null),!1},Rs=function(c,h,b){if(os[h]||Ss(h,c)||us&&(h==="id"||h==="name")&&(b in n||b in va))return!1;const I=B[h]||Ge.attributeCheck instanceof Function&&Ge.attributeCheck(h,c);return hn&&we(M,h)||is&&we(K,h)?!0:I?gs[h]||we(C,wt(b,He,""))||(h==="src"||h==="xlink:href"||h==="href")&&c!=="script"&&or(b,"data:")===0&&fs[c]||ls&&!we(be,wt(b,He,""))?!0:!b:Cs(c)&&Bt(je.tagNameCheck,c)&&Bt(je.attributeNameCheck,h,c)||h==="is"&&je.allowCustomizedBuiltInElements&&Bt(je.tagNameCheck,b)},Pa=Y({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Cs=function(c){return!Pa[Nt(c)]&&we(gt,c)},Oa=function(c,h,b,I){if(q&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!b)switch(y.getAttributeType(c,h)){case"TrustedHTML":return ne(I);case"TrustedScriptURL":return X(I)}return I},za=function(c,h,b,I){try{return b?c.setAttributeNS(b,h,I):c.setAttribute(h,I),Ht(c)?(Ve(c),!1):!0}catch{return Qe(h,c),!1}},Is=function(c){Ue(F.beforeSanitizeAttributes,c,null);const h=c.attributes;if(!h||Ht(c))return;B=Es(F.uponSanitizeAttribute,B,Se,$t);const b={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let I=h.length;const L=he(c.nodeName);for(;I--;){const H=h[I],ae=H.name,ue=H.namespaceURI,Ae=H.value,Re=he(ae),Sn=Ae;let Ne=ae==="value"?Sn:Ap(Sn),$s=!1;if(b.attrName=Re,b.attrValue=Ne,b.keepAttr=!0,b.forceKeepAttr=void 0,Ue(F.uponSanitizeAttribute,c,b),Ne=b.attrValue,ds&&(Re==="id"||Re==="name")&&or(Ne,hs)!==0&&(Qe(ae,c,H),Ne=hs+Ne,$s=!0),Ye&&we(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ne)){Qe(ae,c,H);continue}if(Re==="attributename"&&ar(Ne,"href")){Qe(ae,c,H);continue}if(!b.forceKeepAttr){if(!b.keepAttr){Qe(ae,c,H);continue}if(!cs&&we(Vp,Ne)){Qe(ae,c,H);continue}if(Ke&&(Ne=Ft(Ne)),!Rs(L,Re,Ne)){Qe(ae,c,H);continue}Ne=Oa(L,Re,ue,Ne),Ne!==Sn&&za(c,ae,ue,Ne)&&$s&&rr(t.removed)}}Ue(F.afterSanitizeAttributes,c,null)},Ut=function(c){let h=null;const b=Ns(c);for(Ue(F.beforeSanitizeShadowDOM,c,null);h=b.nextNode();)if(Ue(F.uponSanitizeShadowNode,h,null),As(h,c),Is(h),ut(h.content)&&Ut(h.content),de(h)===Le.element){const I=R(h);ut(I)&&(Tn(I),Ut(I))}Ue(F.afterSanitizeShadowDOM,c,null)},Tn=function(c){const h=[{node:c,shadow:null}];for(;h.length>0;){const b=h.pop();if(b.shadow){Ut(b.shadow);continue}const I=b.node,H=de(I)===Le.element,ae=w(I);if(ae)for(let ue=ae.length-1;ue>=0;--ue)h.push({node:ae[ue],shadow:null});if(H){const ue=G?G(I):null;if(typeof ue=="string"&&he(ue)==="template"){const Ae=I.content;ut(Ae)&&h.push({node:Ae,shadow:null})}}if(H){const ue=R(I);ut(ue)&&h.push({node:null,shadow:ue},{node:ue,shadow:null})}}};return t.sanitize=function(T){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=null,b=null,I=null,L=null;if(_n=!T,_n&&(T="<!-->"),typeof T!="string"&&!xt(T)&&(T=Lp(T),typeof T!="string"))throw Je("dirty is not a string, aborting");if(!t.isSupported)return T;pn?(v=It,B=$t):kn(c),(F.uponSanitizeElement.length>0||F.uponSanitizeAttribute.length>0)&&(v=Me(v)),F.uponSanitizeAttribute.length>0&&(B=Me(B)),t.removed=[];const H=gn&&typeof T!="string"&&xt(T);if(H){La(T);const Ae=Q(T);if(typeof Ae=="string"){const Re=he(Ae);if(!v[Re]||We[Re])throw Ot(T),Je("root node is forbidden and cannot be sanitized in-place")}if(Ht(T))throw Ot(T),Je("root node is clobbered and cannot be sanitized in-place");try{Tn(T)}catch(Re){throw Ot(T),Re}}else if(xt(T))h=js("<!---->"),b=h.ownerDocument.importNode(T,!0),b.nodeType===Le.element&&b.nodeName==="BODY"||b.nodeName==="HTML"?h=b:h.appendChild(b),Tn(h);else{if(!at&&!Ke&&!Ze&&T.indexOf("<")===-1)return q&&Mt?ne(T):T;if(h=js(T),!h)return at?null:Mt?ie:""}h&&fn&&Ve(h.firstChild);const ae=H?T:h;try{const Ae=Ns(ae);for(;I=Ae.nextNode();)As(I,ae),Is(I),ut(I.content)&&Ut(I.content)}catch(Ae){throw H&&(Ot(T),et(t.removed,Re=>{Re.element&&zt(Re.element)})),Ae}if(H)return et(t.removed,Ae=>{Ae.element&&zt(Ae.element)}),Ke&&wn(T),T;if(at){if(Ke&&wn(h),Lt)for(L=P.call(h.ownerDocument);h.firstChild;)L.appendChild(h.firstChild);else L=h;return(B.shadowroot||B.shadowrootmode)&&(L=z.call(a,L,!0)),L}let ue=Ze?h.outerHTML:h.innerHTML;return Ze&&v["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&we(Wp,h.ownerDocument.doctype.name)&&(ue="<!DOCTYPE "+h.ownerDocument.doctype.name+`>
|
|
12
|
-
`+ue),Ke&&(ue=Ft(ue)),q&&Mt?ne(ue):ue},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};kn(T),pn=!0,It=v,$t=B},t.clearConfig=function(){ct=null,pn=!1,It=null,$t=null,q=te,ie=""},t.isValidAttribute=function(T,c,h){ct||kn({});const b=he(T),I=he(c);return Rs(b,I,h)},t.addHook=function(T,c){typeof c=="function"&&Ie(F,T)&&kt(F[T],c)},t.removeHook=function(T,c){if(Ie(F,T)){if(c!==void 0){const h=Ep(F[T],c);return h===-1?void 0:vp(F[T],h,1)[0]}return rr(F[T])}},t.removeHooks=function(T){Ie(F,T)&&(F[T]=[])},t.removeAllHooks=function(){F=gr()},t}var ua=ca();function Zn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var rt=Zn();function da(e){rt=e}var vt={exec:()=>null};function Z(e,t=""){let n=typeof e=="string"?e:e.source,a={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(ve.caret,"$1"),n=n.replace(s,o),a},getRegex:()=>new RegExp(n,t)};return a}var Jp=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ve={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,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},ef=/^(?:[ \t]*(?:\n|$))+/,tf=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,nf=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ct=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sf=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Qn=/(?:[*+-]|\d{1,9}[.)])/,ha=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,pa=Z(ha).replace(/bull/g,Qn).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(),rf=Z(ha).replace(/bull/g,Qn).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(),Jn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,af=/^[^\n]+/,es=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,of=Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",es).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),lf=Z(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Qn).getRegex(),un="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",ts=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,cf=Z("^ {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",ts).replace("tag",un).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fa=Z(Jn).replace("hr",Ct).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",un).getRegex(),uf=Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",fa).getRegex(),ns={blockquote:uf,code:tf,def:of,fences:nf,heading:sf,hr:Ct,html:cf,lheading:pa,list:lf,newline:ef,paragraph:fa,table:vt,text:af},_r=Z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ct).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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",un).getRegex(),df={...ns,lheading:rf,table:_r,paragraph:Z(Jn).replace("hr",Ct).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",_r).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",un).getRegex()},hf={...ns,html:Z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ts).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:vt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(Jn).replace("hr",Ct).replace("heading",` *#{1,6} *[^
|
|
13
|
-
]`).replace("lheading",pa).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},pf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ff=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ma=/^( {2,}|\\)\n(?!\s*$)/,mf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,dn=/[\p{P}\p{S}]/u,ss=/[\s\p{P}\p{S}]/u,ga=/[^\s\p{P}\p{S}]/u,gf=Z(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ss).getRegex(),_a=/(?!~)[\p{P}\p{S}]/u,_f=/(?!~)[\s\p{P}\p{S}]/u,xf=/(?:[^\s\p{P}\p{S}]|~)/u,yf=Z(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Jp?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),xa=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,bf=Z(xa,"u").replace(/punct/g,dn).getRegex(),kf=Z(xa,"u").replace(/punct/g,_a).getRegex(),ya="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wf=Z(ya,"gu").replace(/notPunctSpace/g,ga).replace(/punctSpace/g,ss).replace(/punct/g,dn).getRegex(),Tf=Z(ya,"gu").replace(/notPunctSpace/g,xf).replace(/punctSpace/g,_f).replace(/punct/g,_a).getRegex(),Sf=Z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ga).replace(/punctSpace/g,ss).replace(/punct/g,dn).getRegex(),jf=Z(/\\(punct)/,"gu").replace(/punct/g,dn).getRegex(),Nf=Z(/^<(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(),Ef=Z(ts).replace("(?:-->|$)","-->").getRegex(),vf=Z("^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",Ef).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),rn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Af=Z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",rn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ba=Z(/^!?\[(label)\]\[(ref)\]/).replace("label",rn).replace("ref",es).getRegex(),ka=Z(/^!?\[(ref)\](?:\[\])?/).replace("ref",es).getRegex(),Rf=Z("reflink|nolink(?!\\()","g").replace("reflink",ba).replace("nolink",ka).getRegex(),xr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,rs={_backpedal:vt,anyPunctuation:jf,autolink:Nf,blockSkip:yf,br:ma,code:ff,del:vt,emStrongLDelim:bf,emStrongRDelimAst:wf,emStrongRDelimUnd:Sf,escape:pf,link:Af,nolink:ka,punctuation:gf,reflink:ba,reflinkSearch:Rf,tag:vf,text:mf,url:vt},Cf={...rs,link:Z(/^!?\[(label)\]\((.*?)\)/).replace("label",rn).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",rn).getRegex()},Un={...rs,emStrongRDelimAst:Tf,emStrongLDelim:kf,url:Z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",xr).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:Z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",xr).getRegex()},If={...Un,br:Z(ma).replace("{2,}","*").getRegex(),text:Z(Un.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Vt={normal:ns,gfm:df,pedantic:hf},St={normal:rs,gfm:Un,breaks:If,pedantic:Cf},$f={"&":"&","<":"<",">":">",'"':""","'":"'"},yr=e=>$f[e];function qe(e,t){if(t){if(ve.escapeTest.test(e))return e.replace(ve.escapeReplace,yr)}else if(ve.escapeTestNoEncode.test(e))return e.replace(ve.escapeReplaceNoEncode,yr);return e}function br(e){try{e=encodeURI(e).replace(ve.percentDecode,"%")}catch{return null}return e}function kr(e,t){let n=e.replace(ve.findPipe,(i,o,l)=>{let u=!1,d=o;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),a=n.split(ve.splitPipe),s=0;if(a[0].trim()||a.shift(),a.length>0&&!a.at(-1)?.trim()&&a.pop(),t)if(a.length>t)a.splice(t);else for(;a.length<t;)a.push("");for(;s<a.length;s++)a[s]=a[s].trim().replace(ve.slashPipe,"|");return a}function jt(e,t,n){let a=e.length;if(a===0)return"";let s=0;for(;s<a&&e.charAt(a-s-1)===t;)s++;return e.slice(0,a-s)}function Lf(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let a=0;a<e.length;a++)if(e[a]==="\\")a++;else if(e[a]===t[0])n++;else if(e[a]===t[1]&&(n--,n<0))return a;return n>0?-2:-1}function wr(e,t,n,a,s){let i=t.href,o=t.title||null,l=e[1].replace(s.other.outputLinkReplace,"$1");a.state.inLink=!0;let u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:l,tokens:a.inlineTokens(l)};return a.state.inLink=!1,u}function Mf(e,t,n){let a=e.match(n.other.indentCodeCompensation);if(a===null)return t;let s=a[1];return t.split(`
|
|
14
|
-
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[l]=o;return l.length>=s.length?i.slice(s.length):i}).join(`
|
|
15
|
-
`)}var an=class{options;rules;lexer;constructor(e){this.options=e||rt}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 n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:jt(n,`
|
|
16
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],a=Mf(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:a}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let a=jt(n,"#");(this.options.pedantic||!a||this.rules.other.endingSpaceChar.test(a))&&(n=a.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:jt(t[0],`
|
|
17
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=jt(t[0],`
|
|
18
|
-
`).split(`
|
|
19
|
-
`),a="",s="",i=[];for(;n.length>0;){let o=!1,l=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))l.push(n[u]),o=!0;else if(!o)l.push(n[u]);else break;n=n.slice(u);let d=l.join(`
|
|
20
|
-
`),f=d.replace(this.rules.other.blockquoteSetextReplace,`
|
|
21
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");a=a?`${a}
|
|
22
|
-
${d}`:d,s=s?`${s}
|
|
23
|
-
${f}`:f;let y=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,i,!0),this.lexer.state.top=y,n.length===0)break;let m=i.at(-1);if(m?.type==="code")break;if(m?.type==="blockquote"){let S=m,g=S.raw+`
|
|
24
|
-
`+n.join(`
|
|
25
|
-
`),_=this.blockquote(g);i[i.length-1]=_,a=a.substring(0,a.length-S.raw.length)+_.raw,s=s.substring(0,s.length-S.text.length)+_.text;break}else if(m?.type==="list"){let S=m,g=S.raw+`
|
|
26
|
-
`+n.join(`
|
|
27
|
-
`),_=this.list(g);i[i.length-1]=_,a=a.substring(0,a.length-m.raw.length)+_.raw,s=s.substring(0,s.length-S.raw.length)+_.raw,n=g.substring(i.at(-1).raw.length).split(`
|
|
28
|
-
`);continue}}return{type:"blockquote",raw:a,tokens:i,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),a=n.length>1,s={type:"list",raw:"",ordered:a,start:a?+n.slice(0,-1):"",loose:!1,items:[]};n=a?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=a?n:"[*+-]");let i=this.rules.other.listItemRegex(n),o=!1;for(;e;){let u=!1,d="",f="";if(!(t=i.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let y=t[2].split(`
|
|
29
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,x=>" ".repeat(3*x.length)),m=e.split(`
|
|
30
|
-
`,1)[0],S=!y.trim(),g=0;if(this.options.pedantic?(g=2,f=y.trimStart()):S?g=t[1].length+1:(g=t[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,f=y.slice(g),g+=t[1].length),S&&this.rules.other.blankLine.test(m)&&(d+=m+`
|
|
31
|
-
`,e=e.substring(m.length+1),u=!0),!u){let x=this.rules.other.nextBulletRegex(g),w=this.rules.other.hrRegex(g),k=this.rules.other.fencesBeginRegex(g),R=this.rules.other.headingBeginRegex(g),j=this.rules.other.htmlBeginRegex(g);for(;e;){let O=e.split(`
|
|
32
|
-
`,1)[0],G;if(m=O,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),G=m):G=m.replace(this.rules.other.tabCharGlobal," "),k.test(m)||R.test(m)||j.test(m)||x.test(m)||w.test(m))break;if(G.search(this.rules.other.nonSpaceChar)>=g||!m.trim())f+=`
|
|
33
|
-
`+G.slice(g);else{if(S||y.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||k.test(y)||R.test(y)||w.test(y))break;f+=`
|
|
34
|
-
`+m}!S&&!m.trim()&&(S=!0),d+=O+`
|
|
35
|
-
`,e=e.substring(O.length+1),y=G.slice(g)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(o=!0));let _=null;this.options.gfm&&(_=this.rules.other.listIsTask.exec(f),_&&(f=f.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:d,task:!!_,loose:!1,text:f,tokens:[]}),s.raw+=d}let l=s.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let u of s.items){if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),u.task){let d=this.rules.other.listTaskCheckbox.exec(u.raw);if(d){let f={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};u.checked=f.checked,s.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=f.raw+u.tokens[0].raw,u.tokens[0].text=f.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(f)):u.tokens.unshift({type:"paragraph",raw:f.raw,text:f.raw,tokens:[f]}):u.tokens.unshift(f)}}if(!s.loose){let d=u.tokens.filter(y=>y.type==="space"),f=d.length>0&&d.some(y=>this.rules.other.anyLine.test(y.raw));s.loose=f}}if(s.loose)for(let u of s.items){u.loose=!0;for(let d of u.tokens)d.type==="text"&&(d.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),a=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:a,title:s}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=kr(t[1]),a=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
36
|
-
`):[],i={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===a.length){for(let o of a)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<n.length;o++)i.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:i.align[o]});for(let o of s)i.rows.push(kr(o,i.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[u]})));return i}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
37
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=jt(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=Lf(t[2],"()");if(i===-2)return;if(i>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let a=t[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(a);i&&(a=i[1],s=i[3])}else s=t[3]?t[3].slice(1,-1):"";return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?a=a.slice(1):a=a.slice(1,-1)),wr(t,{href:a&&a.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let a=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[a.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return wr(n,s,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let a=this.rules.inline.emStrongLDelim.exec(e);if(!(!a||a[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(a[1]||a[2])||!n||this.rules.inline.punctuation.exec(n))){let s=[...a[0]].length-1,i,o,l=s,u=0,d=a[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+s);(a=d.exec(t))!=null;){if(i=a[1]||a[2]||a[3]||a[4]||a[5]||a[6],!i)continue;if(o=[...i].length,a[3]||a[4]){l+=o;continue}else if((a[5]||a[6])&&s%3&&!((s+o)%3)){u+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+u);let f=[...a[0]][0].length,y=e.slice(0,s+a.index+f+o);if(Math.min(s,o)%2){let S=y.slice(1,-1);return{type:"em",raw:y,text:S,tokens:this.lexer.inlineTokens(S)}}let m=y.slice(2,-2);return{type:"strong",raw:y,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),a=this.rules.other.nonSpaceChar.test(n),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return a&&s&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,a;return t[2]==="@"?(n=t[1],a="mailto:"+n):(n=t[1],a=n),{type:"link",raw:t[0],text:n,href:a,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,a;if(t[2]==="@")n=t[0],a="mailto:"+n;else{let s;do s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(s!==t[0]);n=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:n,href:a,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ze=class qn{tokens;options;state;tokenizer;inlineQueue;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||rt,this.options.tokenizer=this.options.tokenizer||new an,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ve,block:Vt.normal,inline:St.normal};this.options.pedantic?(n.block=Vt.pedantic,n.inline=St.pedantic):this.options.gfm&&(n.block=Vt.gfm,this.options.breaks?n.inline=St.breaks:n.inline=St.gfm),this.tokenizer.rules=n}static get rules(){return{block:Vt,inline:St}}static lex(t,n){return new qn(n).lex(t)}static lexInline(t,n){return new qn(n).inlineTokens(t)}lex(t){t=t.replace(ve.carriageReturn,`
|
|
38
|
-
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let a=this.inlineQueue[n];this.inlineTokens(a.src,a.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],a=!1){for(this.options.pedantic&&(t=t.replace(ve.tabCharGlobal," ").replace(ve.spaceLine,""));t;){let s;if(this.options.extensions?.block?.some(o=>(s=o.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length);let o=n.at(-1);s.raw.length===1&&o!==void 0?o.raw+=`
|
|
39
|
-
`:n.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
40
|
-
`)?"":`
|
|
41
|
-
`)+s.raw,o.text+=`
|
|
42
|
-
`+s.text,this.inlineQueue.at(-1).src=o.text):n.push(s);continue}if(s=this.tokenizer.fences(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(t)){t=t.substring(s.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
43
|
-
`)?"":`
|
|
44
|
-
`)+s.raw,o.text+=`
|
|
45
|
-
`+s.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},n.push(s));continue}if(s=this.tokenizer.table(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(t)){t=t.substring(s.raw.length),n.push(s);continue}let i=t;if(this.options.extensions?.startBlock){let o=1/0,l=t.slice(1),u;this.options.extensions.startBlock.forEach(d=>{u=d.call({lexer:this},l),typeof u=="number"&&u>=0&&(o=Math.min(o,u))}),o<1/0&&o>=0&&(i=t.substring(0,o+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){let o=n.at(-1);a&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
|
|
46
|
-
`)?"":`
|
|
47
|
-
`)+s.raw,o.text+=`
|
|
48
|
-
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s),a=i.length!==t.length,t=t.substring(s.raw.length);continue}if(s=this.tokenizer.text(t)){t=t.substring(s.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
49
|
-
`)?"":`
|
|
50
|
-
`)+s.raw,o.text+=`
|
|
51
|
-
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let a=t,s=null;if(this.tokens.links){let u=Object.keys(this.tokens.links);if(u.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)u.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(a))!=null;)a=a.slice(0,s.index)+"++"+a.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)i=s[2]?s[2].length:0,a=a.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);a=this.options.hooks?.emStrongMask?.call({lexer:this},a)??a;let o=!1,l="";for(;t;){o||(l=""),o=!1;let u;if(this.options.extensions?.inline?.some(f=>(u=f.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.escape(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.tag(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.link(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(u.raw.length);let f=n.at(-1);u.type==="text"&&f?.type==="text"?(f.raw+=u.raw,f.text+=u.text):n.push(u);continue}if(u=this.tokenizer.emStrong(t,a,l)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.codespan(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.br(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.del(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.autolink(t)){t=t.substring(u.raw.length),n.push(u);continue}if(!this.state.inLink&&(u=this.tokenizer.url(t))){t=t.substring(u.raw.length),n.push(u);continue}let d=t;if(this.options.extensions?.startInline){let f=1/0,y=t.slice(1),m;this.options.extensions.startInline.forEach(S=>{m=S.call({lexer:this},y),typeof m=="number"&&m>=0&&(f=Math.min(f,m))}),f<1/0&&f>=0&&(d=t.substring(0,f+1))}if(u=this.tokenizer.inlineText(d)){t=t.substring(u.raw.length),u.raw.slice(-1)!=="_"&&(l=u.raw.slice(-1)),o=!0;let f=n.at(-1);f?.type==="text"?(f.raw+=u.raw,f.text+=u.text):n.push(u);continue}if(t){let f="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return n}},on=class{options;parser;constructor(e){this.options=e||rt}space(e){return""}code({text:e,lang:t,escaped:n}){let a=(t||"").match(ve.notSpaceStart)?.[0],s=e.replace(ve.endingNewline,"")+`
|
|
52
|
-
`;return a?'<pre><code class="language-'+qe(a)+'">'+(n?s:qe(s,!0))+`</code></pre>
|
|
53
|
-
`:"<pre><code>"+(n?s:qe(s,!0))+`</code></pre>
|
|
54
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
55
|
-
${this.parser.parse(e)}</blockquote>
|
|
56
|
-
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
57
|
-
`}hr(e){return`<hr>
|
|
58
|
-
`}list(e){let t=e.ordered,n=e.start,a="";for(let o=0;o<e.items.length;o++){let l=e.items[o];a+=this.listitem(l)}let s=t?"ol":"ul",i=t&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
|
|
59
|
-
`+a+"</"+s+`>
|
|
60
|
-
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
61
|
-
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
62
|
-
`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let a="";for(let s=0;s<e.rows.length;s++){let i=e.rows[s];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[o]);a+=this.tablerow({text:n})}return a&&(a=`<tbody>${a}</tbody>`),`<table>
|
|
63
|
-
<thead>
|
|
64
|
-
`+t+`</thead>
|
|
65
|
-
`+a+`</table>
|
|
66
|
-
`}tablerow({text:e}){return`<tr>
|
|
67
|
-
${e}</tr>
|
|
68
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
69
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${qe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let a=this.parser.parseInline(n),s=br(e);if(s===null)return a;e=s;let i='<a href="'+e+'"';return t&&(i+=' title="'+qe(t)+'"'),i+=">"+a+"</a>",i}image({href:e,title:t,text:n,tokens:a}){a&&(n=this.parser.parseInline(a,this.parser.textRenderer));let s=br(e);if(s===null)return qe(n);e=s;let i=`<img src="${e}" alt="${n}"`;return t&&(i+=` title="${qe(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:qe(e.text)}},as=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Fe=class Wn{options;renderer;textRenderer;constructor(t){this.options=t||rt,this.options.renderer=this.options.renderer||new on,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new as}static parse(t,n){return new Wn(n).parse(t)}static parseInline(t,n){return new Wn(n).parseInline(t)}parse(t){let n="";for(let a=0;a<t.length;a++){let s=t[a];if(this.options.extensions?.renderers?.[s.type]){let o=s,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=l||"";continue}}let i=s;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){let a="";for(let s=0;s<t.length;s++){let i=t[s];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){a+=l||"";continue}}let o=i;switch(o.type){case"escape":{a+=n.text(o);break}case"html":{a+=n.html(o);break}case"link":{a+=n.link(o);break}case"image":{a+=n.image(o);break}case"checkbox":{a+=n.checkbox(o);break}case"strong":{a+=n.strong(o);break}case"em":{a+=n.em(o);break}case"codespan":{a+=n.codespan(o);break}case"br":{a+=n.br(o);break}case"del":{a+=n.del(o);break}case"text":{a+=n.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return a}},Et=class{options;block;constructor(e){this.options=e||rt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ze.lex:ze.lexInline}provideParser(){return this.block?Fe.parse:Fe.parseInline}},Df=class{defaults=Zn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Fe;Renderer=on;TextRenderer=as;Lexer=ze;Tokenizer=an;Hooks=Et;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let a of e)switch(n=n.concat(t.call(this,a)),a.type){case"table":{let s=a;for(let i of s.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of s.rows)for(let o of i)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let s=a;n=n.concat(this.walkTokens(s.items,t));break}default:{let s=a;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{let o=s[i].flat(1/0);n=n.concat(this.walkTokens(o,t))}):s.tokens&&(n=n.concat(this.walkTokens(s.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let a={...n};if(a.async=this.defaults.async||a.async||!1,n.extensions&&(n.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=t.renderers[s.name];i?t.renderers[s.name]=function(...o){let l=s.renderer.apply(this,o);return l===!1&&(l=i.apply(this,o)),l}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=t[s.level];i?i.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),a.extensions=t),n.renderer){let s=this.defaults.renderer||new on(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,l=n.renderer[o],u=s[o];s[o]=(...d)=>{let f=l.apply(s,d);return f===!1&&(f=u.apply(s,d)),f||""}}a.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new an(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,l=n.tokenizer[o],u=s[o];s[o]=(...d)=>{let f=l.apply(s,d);return f===!1&&(f=u.apply(s,d)),f}}a.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new Et;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,l=n.hooks[o],u=s[o];Et.passThroughHooks.has(i)?s[o]=d=>{if(this.defaults.async&&Et.passThroughHooksRespectAsync.has(i))return(async()=>{let y=await l.call(s,d);return u.call(s,y)})();let f=l.call(s,d);return u.call(s,f)}:s[o]=(...d)=>{if(this.defaults.async)return(async()=>{let y=await l.apply(s,d);return y===!1&&(y=await u.apply(s,d)),y})();let f=l.apply(s,d);return f===!1&&(f=u.apply(s,d)),f}}a.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;a.walkTokens=function(o){let l=[];return l.push(i.call(this,o)),s&&(l=l.concat(s.call(this,o))),l}}this.defaults={...this.defaults,...a}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ze.lex(e,t??this.defaults)}parser(e,t){return Fe.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let a={...n},s={...this.defaults,...a},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&a.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(t):t,l=await(s.hooks?await s.hooks.provideLexer():e?ze.lex:ze.lexInline)(o,s),u=s.hooks?await s.hooks.processAllTokens(l):l;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let d=await(s.hooks?await s.hooks.provideParser():e?Fe.parse:Fe.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(d):d})().catch(i);try{s.hooks&&(t=s.hooks.preprocess(t));let o=(s.hooks?s.hooks.provideLexer():e?ze.lex:ze.lexInline)(t,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let l=(s.hooks?s.hooks.provideParser():e?Fe.parse:Fe.parseInline)(o,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(o){return i(o)}}}onError(e,t){return n=>{if(n.message+=`
|
|
70
|
-
Please report this to https://github.com/markedjs/marked.`,e){let a="<p>An error occurred:</p><pre>"+qe(n.message+"",!0)+"</pre>";return t?Promise.resolve(a):a}if(t)return Promise.reject(n);throw n}}},tt=new Df;function ee(e,t){return tt.parse(e,t)}ee.options=ee.setOptions=function(e){return tt.setOptions(e),ee.defaults=tt.defaults,da(ee.defaults),ee};ee.getDefaults=Zn;ee.defaults=rt;ee.use=function(...e){return tt.use(...e),ee.defaults=tt.defaults,da(ee.defaults),ee};ee.walkTokens=function(e,t){return tt.walkTokens(e,t)};ee.parseInline=tt.parseInline;ee.Parser=Fe;ee.parser=Fe.parse;ee.Renderer=on;ee.TextRenderer=as;ee.Lexer=ze;ee.lexer=ze.lex;ee.Tokenizer=an;ee.Hooks=Et;ee.parse=ee;ee.options;ee.setOptions;ee.use;ee.walkTokens;ee.parseInline;Fe.parse;ze.lex;const Pf="_transcriptWrap_yy5uu_5",Of="_transcript_yy5uu_5",zf="_list_yy5uu_14",Ff="_item_yy5uu_24",Hf="_skeleton_yy5uu_26",Bf="_skeletonUser_yy5uu_38",Uf="_loadError_yy5uu_39",qf="_empty_yy5uu_62",Wf="_emptyTitle_yy5uu_63",Gf="_emptyBody_yy5uu_72",Kf="_user_yy5uu_75",Vf="_userText_yy5uu_76",Xf="_assistant_yy5uu_87",Yf="_markdown_yy5uu_31",Zf="_codeHead_yy5uu_182",Qf="_codeLang_yy5uu_199",Jf="_copy_yy5uu_198",em="_caret_yy5uu_224",tm="_streaming_yy5uu_225",nm="_thinking_yy5uu_238",sm="_thinkingSummary_yy5uu_239",rm="_thinkingBody_yy5uu_251",am="_tool_yy5uu_262",om="_toolRun_yy5uu_263",im="_toolLine_yy5uu_265",lm="_toolArg_yy5uu_283",cm="_toolState_yy5uu_283",um="_toolGlyph_yy5uu_294",dm="_toolName_yy5uu_304",hm="_toolFailed_yy5uu_328",pm="_toolBody_yy5uu_331",fm="_toolRunBody_yy5uu_332",mm="_toolRunList_yy5uu_339",gm="_toolLabel_yy5uu_341",_m="_toolPre_yy5uu_350",xm="_toolPending_yy5uu_365",ym="_note_yy5uu_368",bm="_noteError_yy5uu_374",km="_meta_yy5uu_375",wm="_noteDuration_yy5uu_376",Tm="_metaText_yy5uu_380",Sm="_jump_yy5uu_387",jm="_jumpUnseen_yy5uu_410",Nm="_turn_yy5uu_435",Em="_turnItems_yy5uu_457",vm="_turnErrorJump_yy5uu_493",Am="_toolDelta_yy5uu_511",Rm="_toolAdd_yy5uu_519",Cm="_toolDel_yy5uu_511",Im="_toolNote_yy5uu_522",E={transcriptWrap:Pf,transcript:Of,list:zf,item:Ff,skeleton:Hf,skeletonUser:Bf,loadError:Uf,empty:qf,emptyTitle:Wf,emptyBody:Gf,user:Kf,userText:Vf,assistant:Xf,markdown:Yf,codeHead:Zf,codeLang:Qf,copy:Jf,caret:em,streaming:tm,thinking:nm,thinkingSummary:sm,thinkingBody:rm,tool:am,toolRun:om,toolLine:im,toolArg:lm,toolState:cm,toolGlyph:um,toolName:dm,toolFailed:hm,toolBody:pm,toolRunBody:fm,toolRunList:mm,toolLabel:gm,toolPre:_m,toolPending:xm,note:ym,noteError:bm,meta:km,noteDuration:wm,metaText:Tm,jump:Sm,jumpUnseen:jm,turn:Nm,turnItems:Em,turnErrorJump:vm,toolDelta:Am,toolAdd:Rm,toolDel:Cm,toolNote:Im};let Tr=!1;function $m(){Tr||(Tr=!0,ua.addHook("afterSanitizeAttributes",e=>{e.tagName==="A"&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))}))}const Lm={USE_PROFILES:{html:!0},ADD_ATTR:["target"],FORBID_TAGS:["style","form","input","button","iframe","object","embed"]};function Mm(e){$m();const t=ee.parse(e,{async:!1,gfm:!0,breaks:!1});return ua.sanitize(t,Lm)}const Sr="Copy",Dm="Copied";function Pm(e){return/(?:^|\s)(?:language|lang)-([\w+#.-]+)/.exec(e?.className??"")?.[1]??""}function Om({text:e,streaming:t=!1}){const n=p.useMemo(()=>Mm(e),[e]),a=p.useRef(null);p.useEffect(()=>{const i=a.current;if(i)for(const o of i.querySelectorAll("pre")){if(o.querySelector("[data-code-head]"))continue;const l=document.createElement("div");l.className=E.codeHead,l.setAttribute("data-code-head","");const u=Pm(o.querySelector("code")),d=document.createElement("span");d.className=E.codeLang,d.textContent=u,l.append(d);const f=document.createElement("button");f.type="button",f.className=E.copy,f.setAttribute("data-copy",""),f.setAttribute("aria-label","Copy code"),f.textContent=Sr,l.append(f),o.prepend(l)}},[n]);function s(i){const l=i.target?.closest("[data-copy]");if(!l)return;i.preventDefault();const u=l.closest("pre"),d=u?.querySelector("code"),f=u?.querySelector("[data-code-head]"),y=d?d.textContent??"":Array.from(u?.childNodes??[]).filter(m=>m!==f).map(m=>m.textContent??"").join("");zm(y).then(m=>{l.textContent=m?Dm:"Copy failed",setTimeout(()=>{l.textContent=Sr},1500)})}return r.jsx("div",{ref:a,className:`${E.markdown} ${t?E.streaming:""}`,onClick:s,dangerouslySetInnerHTML:{__html:n}})}async function zm(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();const n=document.execCommand("copy");return t.remove(),n}catch{return!1}}const Fm=/\u001B\[[0-9;:?]*[ -/]*[@-~]/g,Hm=/\u001B\][\s\S]*?(?:\u0007|\u001B\\)/g,Bm=/\u001B[@-Z\\-_]/g,Um=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g;function qm(e){return e.includes("\x1B")}function Wm(e){return e.replace(Hm,"").replace(Fm,"").replace(Bm,"").replace(Um,"")}function Gm(e){return e.includes("\r")?e.split(`
|
|
71
|
-
`).map(t=>{if(!t.includes("\r"))return t;let n="";for(const a of t.split("\r"))n=a.length>=n.length?a:a+n.slice(a.length);return n}).join(`
|
|
72
|
-
`):e}function Km(e){return Gm(Wm(e)).replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function jr(e){if(e.length===0)return 0;let t=1;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return t}function Vm(e,t){const n=e.split(`
|
|
73
|
-
`);return n.length<=t?{head:e,hidden:0}:{head:n.slice(0,t).join(`
|
|
74
|
-
`),hidden:n.length-t}}const Xm=20,Dn=2e5;function Ym({command:e,output:t,isError:n,pending:a,body:s}){const[i,o]=p.useState(!1),l=p.useMemo(()=>{const m=Km(t);return m.length>Dn?`${m.slice(0,Dn)}
|
|
75
|
-
… (${m.length-Dn} more characters not shown)`:m},[t]),{head:u,hidden:d}=p.useMemo(()=>Vm(l,Xm),[l]),f=i?l:u,y=e?.exitCode??null;return r.jsxs("div",{className:A.command,"data-failed":n?"true":void 0,children:[e?r.jsxs("div",{className:A.commandLine,children:[r.jsx("span",{className:A.commandPrompt,"aria-hidden":"true",children:"$"}),r.jsx("code",{className:A.commandText,children:e.command})]}):null,r.jsxs("div",{className:A.commandStatus,children:[r.jsx("span",{className:A.commandStatusText,"data-tone":a?"pending":n?"bad":"ok",children:a?"running…":y!==null?`exit ${y}`:n?"failed — no exit code reported":"completed — no exit code reported"}),!a&&!s&&l.length===0?r.jsx("span",{className:A.commandMeta,children:"no output"}):null,!a&&!s&&l.length>0?r.jsxs("span",{className:A.commandMeta,children:[jr(l)," line",jr(l)===1?"":"s",qm(t)?" · colour codes stripped":""]}):null]}),a?r.jsx("p",{className:A.commandPending,children:"Waiting for the command to finish…"}):s||(l.length>0?r.jsxs(r.Fragment,{children:[r.jsx("pre",{className:A.commandPre,children:f}),d>0?r.jsx("button",{type:"button",className:A.commandMore,"aria-expanded":i,onClick:()=>o(m=>!m),children:i?"Collapse output":`Show ${d} more line${d===1?"":"s"}`}):null]}):null)]})}const Zm=28,Qm=18,Nr=4e3;function Er({diff:e,path:t=null}){const n=p.useMemo(()=>Br(e.text),[e.text]);if(n.files.length===0)return null;if(e.multiFile||n.files.length>1)return r.jsx("div",{className:A.diffMulti,children:r.jsx(Do,{diff:e.text,proposalKind:"tool call"})});const a=n.files[0];return r.jsx(eg,{file:a,anchored:e.anchored,path:t??a.displayPath})}function Jm(e){switch(e.status){case"renamed":return"Renamed. The contents did not change, so there are no lines to show.";case"added":return"New file. It was added with no contents to diff against.";case"deleted":return"Deleted. The file is gone, so there are no lines to show.";default:return null}}function eg({file:e,anchored:t,path:n}){const[a,s]=p.useState(!1),i=Po(n),o=p.useMemo(()=>tg(e.hunks),[e.hunks]),l=o.length>Zm,u=l&&!a?o.slice(0,Qm):o,d=o.length-u.length,f=e.status==="renamed"?e.oldPath:null,y=Jm(e);return r.jsxs("div",{className:A.diff,"data-anchored":t?"true":"false","data-status":e.status,children:[r.jsxs("div",{className:A.diffHead,children:[f?r.jsxs("span",{className:A.diffOldPath,title:f,children:[f,r.jsx("span",{className:A.visuallyHidden,children:" renamed to"})]}):null,r.jsx("span",{className:A.diffPath,title:n,children:n}),e.status!=="modified"?r.jsx("span",{className:A.diffStatus,children:e.status}):null,r.jsxs("span",{className:A.diffStats,children:[e.additions>0?r.jsxs("span",{className:A.diffAdd,children:["+",e.additions]}):null,e.deletions>0?r.jsxs("span",{className:A.diffDel,children:["−",e.deletions]}):null]})]}),e.unparsedNotice?r.jsx("pre",{className:A.diffNotice,children:e.unparsedNotice}):null,o.length===0?r.jsx("p",{className:A.diffEmpty,children:y??"No line-level changes in this call."}):r.jsxs(r.Fragment,{children:[r.jsx("table",{className:A.diffTable,children:r.jsx("tbody",{children:u.map(m=>m.kind==="hunk"?r.jsxs("tr",{className:A.diffHunkRow,children:[t?r.jsx("td",{className:A.diffNo,"aria-hidden":"true"}):null,r.jsx("td",{className:A.diffMarker,"aria-hidden":"true"}),r.jsx("td",{className:A.diffHunkHead,children:m.label})]},m.key):r.jsxs("tr",{className:A[`diffRow_${m.line.kind}`],children:[t?r.jsx("td",{className:A.diffNo,children:m.line.newLineNo??m.line.oldLineNo??""}):null,r.jsx("td",{className:A.diffMarker,"aria-hidden":"true",children:m.line.kind==="add"?"+":m.line.kind==="del"?"−":""}),r.jsx("td",{className:A.diffText,children:r.jsx(ng,{text:m.line.text,lang:i})})]},m.key))})}),l?r.jsx("button",{type:"button",className:A.diffMore,onClick:()=>s(m=>!m),"aria-expanded":a,children:a?"Collapse diff":`Show ${d} more line${d===1?"":"s"}`}):null]}),t?null:r.jsx("p",{className:A.diffUnanchored,children:"Line numbers are not shown — this tool call reported what it replaced, not where in the file."})]})}function tg(e){const t=[];let n=!1;return e.forEach((a,s)=>{if(n)return;const i=a.header.replace(/^@@[^@]*@@/,"").trim();(i||e.length>1)&&t.push({kind:"hunk",key:`h${s}`,label:i||`hunk ${s+1}`});for(let o=0;o<a.lines.length;o++){if(t.length>=Nr){n=!0,t.push({kind:"hunk",key:"truncated",label:`diff truncated at ${Nr} lines`});return}t.push({kind:"line",key:`h${s}l${o}`,line:a.lines[o]})}}),t}function ng({text:e,lang:t}){const n=Oo(e,t);return r.jsx("code",{className:A.diffCode,children:n.map((a,s)=>r.jsx("span",{className:A[`tok_${a.kind}`],children:a.text},s))})}const Pn=2e4;function wa({name:e,input:t,result:n,toolUseId:a,durationMs:s=null,facts:i}){const o=p.useMemo(()=>i??sa({name:e,input:t,result:n}),[i,e,t,n]),l=ro(t),u=o.failed||n?.isError===!0,d=n===null,f=d?"running":u?"error":s!==null&&s>0?en(s):"done",y=p.useMemo(()=>o.diff?aa(o.diff.text):null,[o.diff]),m=n?n.output.length>Pn?`${n.output.slice(0,Pn)}
|
|
76
|
-
… (${n.output.length-Pn} more characters)`:n.output:"";return r.jsxs("details",{id:ra(a),className:`${E.tool} ${u?E.toolFailed:""}`,"data-state-key":`tool:${a}`,"data-action":o.action,children:[r.jsxs("summary",{className:E.toolLine,"aria-label":`${e}${l?`: ${l}`:""} (${f})`,children:[r.jsx("span",{className:E.toolGlyph,"aria-hidden":"true"}),r.jsx("span",{className:E.toolName,children:e}),l?r.jsx("span",{className:E.toolArg,title:l,children:l}):null,y&&(y.additions>0||y.deletions>0)?r.jsxs("span",{className:E.toolDelta,"aria-hidden":"true",children:[y.additions>0?r.jsxs("span",{className:E.toolAdd,children:["+",y.additions]}):null,y.deletions>0?r.jsxs("span",{className:E.toolDel,children:["−",y.deletions]}):null]}):null,r.jsx("span",{className:E.toolState,children:f})]}),r.jsx("div",{className:E.toolBody,children:r.jsx(sg,{input:t,output:m,facts:o,pending:d,isError:u})})]})}function sg({input:e,output:t,facts:n,pending:a,isError:s}){return n.command?r.jsx(Ym,{command:n.command,output:t,isError:s,pending:a,body:n.diff?r.jsx(Er,{diff:n.diff,path:n.paths[0]??null}):void 0}):n.diff?r.jsxs(r.Fragment,{children:[r.jsx(Er,{diff:n.diff,path:n.paths[0]??null}),a?r.jsx("p",{className:E.toolPending,children:"Waiting for the tool to finish…"}):null,s&&t?r.jsxs("section",{children:[r.jsx("h4",{className:E.toolLabel,children:"Error"}),r.jsx("pre",{className:E.toolPre,children:t})]}):null]}):n.written?r.jsxs(r.Fragment,{children:[r.jsxs("section",{children:[r.jsxs("h4",{className:E.toolLabel,children:["Contents written to ",n.written.path]}),r.jsx("pre",{className:E.toolPre,children:n.written.text}),r.jsx("p",{className:E.toolNote,children:"The previous contents were not in this tool call, so there is nothing to diff against."})]}),r.jsxs("section",{children:[r.jsx("h4",{className:E.toolLabel,children:s?"Error":"Result"}),a?r.jsx("p",{className:E.toolPending,children:"Waiting for the tool to finish…"}):r.jsx("pre",{className:E.toolPre,children:t||"(empty)"})]})]}):r.jsxs(r.Fragment,{children:[e!=null?r.jsxs("section",{children:[r.jsx("h4",{className:E.toolLabel,children:"Input"}),r.jsx("pre",{className:E.toolPre,children:ao(e)})]}):null,r.jsxs("section",{children:[r.jsx("h4",{className:E.toolLabel,children:s?"Error":"Result"}),a?r.jsx("p",{className:E.toolPending,children:"Waiting for the tool to finish…"}):r.jsx("pre",{className:E.toolPre,children:t||"(empty)"})]})]})}const rg=48,vr=3,ag=1400;function og({transcript:e,loaded:t,loadError:n,onRetry:a,emptyHint:s}){const i=p.useRef(null),o=p.useRef(new Map),l=p.useRef(null),[u,d]=p.useState(!0),[f,y]=p.useState(!1),[m,S]=p.useState(""),[g,_]=p.useState(-1),[x,w]=p.useState(0),k=p.useRef(0),R=p.useRef($d()),j=p.useMemo(()=>tc(e.items),[e.items]),O=p.useMemo(()=>Od(j,R.current),[j]),G=p.useMemo(()=>Ud(O.turns,m,R.current),[O.turns,m]),pe=p.useMemo(()=>new Set(G.map(N=>N.turnKey)),[G]),de=p.useMemo(()=>{const N=new Set;let $=null;for(const P of e.items)P.kind==="turn-done"&&!P.ok&&$&&$.turnId===P.turnId&&($.kind==="cancelled"||$.kind==="error")&&N.add(P.key),$={turnId:P.turnId,kind:P.kind};return N},[e.items]),Q=p.useCallback((N="auto")=>{const $=i.current;$&&(typeof $.scrollTo=="function"?$.scrollTo({top:$.scrollHeight,behavior:N}):$.scrollTop=$.scrollHeight)},[]);function q(){const N=i.current;if(!N)return;const P=N.scrollHeight-N.scrollTop-N.clientHeight<=rg;d(P),P&&y(!1)}const ie=p.useCallback(N=>{N&&(d(!1),typeof N.scrollIntoView=="function"&&N.scrollIntoView({block:"center",behavior:"smooth"}),typeof N.focus=="function"&&N.focus({preventScroll:!0}),N.setAttribute("data-flash","true"),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>N.removeAttribute("data-flash"),ag))},[]);p.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]);const te=p.useCallback(N=>{ie(o.current.get(N)??null)},[ie]),fe=p.useCallback(N=>{const $=i.current?.ownerDocument?.getElementById(N)??null;if($){for(let P=$;P&&(P instanceof HTMLDetailsElement&&(P.open=!0),P!==i.current);P=P.parentElement);ie($)}},[ie]),V=p.useCallback(N=>fe(ra(N)),[fe]),me=p.useCallback(()=>{const N=O.errorAnchors[0];N&&fe(N)},[O.errorAnchors,fe]),ne=p.useCallback(N=>{if(G.length===0)return;const $=g<0?N>0?0:G.length-1:(g+N+G.length)%G.length;_($),te(G[$].turnKey)},[G,g,te]);p.useEffect(()=>{_(-1)},[m]);const X=p.useCallback(N=>{const $=O.turns;if($.length===0)return;const P=i.current?.ownerDocument?.activeElement,ye=P instanceof HTMLElement?P.getAttribute("data-turn-key"):null,z=ye?$.findIndex(ke=>ke.key===ye):-1,F=z<0?N>0?0:$.length-1:Math.max(0,Math.min($.length-1,z+N));te($[F].key)},[O.turns,te]);p.useEffect(()=>{if(O.turns.length===0)return;const N=$=>{const P=$.target,ye=P instanceof HTMLTextAreaElement||P instanceof HTMLInputElement||P?.isContentEditable===!0;if(($.metaKey||$.ctrlKey)&&!$.shiftKey&&!$.altKey&&$.key.toLowerCase()==="f"){if(O.turns.length<vr)return;$.preventDefault(),w(z=>z+1);return}$.altKey&&!$.metaKey&&!$.ctrlKey&&!ye&&($.key==="ArrowDown"?($.preventDefault(),X(1)):$.key==="ArrowUp"&&($.preventDefault(),X(-1)))};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[O.turns.length,X]);function se(N){N.target?.hasAttribute("data-turn-key")&&(N.key==="ArrowDown"?(N.preventDefault(),X(1)):N.key==="ArrowUp"?(N.preventDefault(),X(-1)):N.key==="Home"?(N.preventDefault(),te(O.turns[0].key)):N.key==="End"&&(N.preventDefault(),te(O.turns[O.turns.length-1].key)))}if(p.useLayoutEffect(()=>{const N=e.items.length,$=e.items[N-1],P=N!==k.current||$?.kind==="assistant"&&$.streaming;k.current=N,P&&(u?Q():y(!0))},[e,u,Q]),p.useEffect(()=>{t&&Q()},[t,Q]),!t&&!n)return r.jsx("div",{className:E.transcript,"aria-busy":"true",children:r.jsxs("div",{className:E.skeleton,children:[r.jsx("div",{className:E.skeletonUser,children:r.jsx(Ee,{width:"42%"})}),r.jsx(Ee,{width:"88%"}),r.jsx(Ee,{width:"72%"}),r.jsx(Ee,{width:"80%"}),r.jsx("div",{className:E.skeletonUser,children:r.jsx(Ee,{width:"30%"})}),r.jsx(Ee,{width:"64%"})]})});if(n)return r.jsx("div",{className:E.transcript,children:r.jsxs("div",{role:"alert",className:E.loadError,children:[r.jsx("p",{children:n}),a?r.jsx("button",{type:"button",onClick:a,children:"Retry"}):null]})});const J=g>=0?G[g]?.turnKey??null:null;return r.jsxs("div",{className:E.transcriptWrap,children:[O.turns.length>=vr?r.jsx(xp,{turns:O.turns,query:m,onQuery:S,matches:G,matchIndex:g,onStepMatch:ne,errorCount:O.errorAnchors.length,onJumpError:me,onJumpTurn:te,focusToken:x}):null,r.jsxs("div",{ref:i,className:E.transcript,onScroll:q,role:"log","aria-live":"polite","aria-relevant":"additions text",children:[e.items.length===0?r.jsxs("div",{className:E.empty,children:[r.jsx("p",{className:E.emptyTitle,children:"Say something to begin."}),r.jsx("p",{className:E.emptyBody,children:s??"The agent can read and edit this project. Ask for a change, a review, or an explanation."})]}):null,r.jsxs("ol",{className:E.list,onKeyDown:se,children:[O.turns.map((N,$)=>r.jsxs("li",{id:Md(N.key),ref:P=>{P?o.current.set(N.key,P):o.current.delete(N.key)},className:E.turn,"data-turn-key":N.key,"data-status":N.status,"data-match":pe.has(N.key)?N.key===J?"active":"true":void 0,tabIndex:-1,"aria-label":`Turn ${$+1} of ${O.turns.length}`,children:[r.jsx("ol",{className:E.turnItems,children:N.items.map(P=>ig(P,O.facts,de))}),N.files.length>0?r.jsx(gp,{files:N.files,onJump:V}):null,N.errorCount>0&&N.firstErrorAnchor?r.jsxs("button",{type:"button",className:E.turnErrorJump,onClick:()=>fe(N.firstErrorAnchor),children:[N.errorCount," failure",N.errorCount===1?"":"s"," in this turn — jump to the first"]}):null]},N.key)),e.live&&!e.items.some(N=>N.kind==="assistant"&&N.streaming)?r.jsx("li",{className:`${E.item} ${E.assistant}`,"data-kind":"pending","aria-label":"Waiting for the agent",children:r.jsx("span",{className:E.caret,"aria-hidden":"true"})}):null]})]}),u?null:r.jsxs("button",{type:"button",className:`${E.jump} ${f?E.jumpUnseen:""}`,onClick:()=>{d(!0),y(!1),Q("smooth")},children:[r.jsx(yo,{size:12})," Jump to latest"]})]})}function ig(e,t,n){switch(e.kind){case"user":return r.jsx("li",{className:`${E.item} ${E.user}`,"data-kind":"user",children:r.jsx("div",{className:E.userText,children:e.text})},e.key);case"assistant":return r.jsx("li",{className:`${E.item} ${E.assistant}`,"data-kind":"assistant","data-streaming":e.streaming||void 0,children:r.jsx(Om,{text:e.text,streaming:e.streaming})},e.key);case"thinking":return r.jsx("li",{className:E.item,"data-kind":"thinking",children:r.jsx(Ta,{item:e})},e.key);case"tool":return r.jsx("li",{className:E.item,"data-kind":"tool",children:r.jsx(wa,{name:e.name,input:e.input,result:e.result,toolUseId:e.toolUseId,durationMs:e.durationMs,facts:t.get(e.toolUseId)})},e.key);case"toolGroup":return r.jsx("li",{className:E.item,"data-kind":"tool-group",children:r.jsx(lg,{item:e,facts:t})},e.key);case"error":return r.jsx("li",{className:E.item,"data-kind":"error",children:r.jsx("div",{id:sn(e.key),role:"alert",className:`${E.note} ${E.noteError}`,children:e.message})},e.key);case"cancelled":return r.jsx("li",{className:E.item,"data-kind":"cancelled",children:r.jsx("div",{className:E.note,children:"Stopped."})},e.key);case"turn-done":return e.ok||n.has(e.key)?e.durationMs>0?r.jsx("li",{className:`${E.item} ${E.meta}`,"data-kind":"turn-done",children:r.jsx("span",{className:E.metaText,children:en(e.durationMs)})},e.key):null:r.jsx("li",{className:E.item,"data-kind":"turn-done",children:r.jsxs("div",{id:sn(e.key),className:`${E.note} ${E.noteError}`,children:["Turn ended without a result (",r.jsx("span",{className:E.noteDuration,children:en(e.durationMs)}),")."]})},e.key);default:return null}}function Ta({item:e}){return r.jsxs("details",{className:E.thinking,"data-state-key":`thinking:${e.key}`,children:[r.jsx("summary",{className:E.thinkingSummary,children:"Thinking"}),r.jsx("div",{className:E.thinkingBody,children:e.text})]})}function lg({item:e,facts:t}){const n=e.pending?"running":e.errorCount>0?`${e.errorCount} failed`:e.spanMs!==null&&e.spanMs>0?en(e.spanMs):"done",a=`${e.toolCount} tool${e.toolCount===1?"":"s"}`;return r.jsxs("details",{className:`${E.toolRun} ${e.errorCount>0?E.toolFailed:""}`,"data-state-key":`toolgroup:${e.key}`,children:[r.jsxs("summary",{className:E.toolLine,"aria-label":`${a}: ${e.summary} (${n})`,children:[r.jsx("span",{className:E.toolGlyph,"aria-hidden":"true"}),r.jsx("span",{className:E.toolName,children:a}),e.summary?r.jsx("span",{className:E.toolArg,title:e.summary,children:e.summary}):null,r.jsx("span",{className:E.toolState,children:n})]}),r.jsx("div",{className:E.toolRunBody,children:r.jsx("ol",{className:E.toolRunList,children:e.items.map(s=>r.jsx("li",{"data-member":s.kind,children:s.kind==="tool"?r.jsx(wa,{name:s.name,input:s.input,result:s.result,toolUseId:s.toolUseId,durationMs:s.durationMs,facts:t.get(s.toolUseId)}):r.jsx(Ta,{item:s})},s.key))})})]})}const cg=3e4;function ug(e=!0){const t=Cr(ft);p.useEffect(()=>{if(!e)return;const n=()=>{typeof document<"u"&&document.visibilityState==="hidden"||t()},a=window.setInterval(n,cg);return document.addEventListener("visibilitychange",n),()=>{window.clearInterval(a),document.removeEventListener("visibilitychange",n)}},[e,t])}function dg(e){const{view:t,seats:n,projects:a,dispatchEnabled:s,locked:i,hasAnySessions:o,onSend:l,onStop:u,onRename:d,onDelete:f,onSeatChange:y,onNew:m,onRetry:S,sidebarCollapsed:g,onToggleSidebar:_,resourcesOpen:x,onToggleResources:w}=e,k=t.session,[R,j]=p.useState(!1),[O,G]=p.useState(""),[pe,de]=p.useState(!1),[Q,q]=p.useState(!1),ie=p.useRef(null),te=p.useId();ug(),p.useEffect(()=>{j(!1),de(!1)},[t.sessionId]),p.useEffect(()=>{R&&ie.current?.select()},[R]);const fe=r.jsx(r.Fragment,{children:g?r.jsx("button",{type:"button",className:W.ghostIcon,onClick:_,title:"Show chat list","aria-label":"Show chat list",children:r.jsx(Or,{})}):null});if(!t.sessionId)return r.jsxs("section",{className:W.workspace,"aria-label":"Chat",children:[r.jsxs("header",{className:W.header,"data-app-region":"drag",children:[fe,r.jsx("div",{className:W.headerSpacer}),r.jsx(Ar,{open:x,onToggle:w})]}),r.jsxs("div",{className:W.emptyState,children:[r.jsx("span",{className:W.emptyMark,"aria-hidden":"true",children:r.jsx(bo,{size:36})}),r.jsx("h1",{className:W.emptyTitle,children:o?"Pick a chat, or start a new one":"No chats yet — ⌘N"}),r.jsx("p",{className:W.emptyBody,children:"Open a project, choose a seat — a Claude or Codex account, Grok, or a local Ollama model — and talk to an agent that can edit that project."}),r.jsxs("button",{type:"button",className:W.emptyButton,onClick:m,children:["New chat ",r.jsx("kbd",{children:"⌘N"})]}),s?null:r.jsxs("p",{className:W.emptyWarn,role:"status",children:["This server was started without dispatch, so chats are read-only here. Run ",r.jsx("code",{children:"ashlr verse"})," to enable sending."]})]})]});async function V(){const P=O.trim();if(j(!1),!(!k||!P||P===k.title)){q(!0);try{await d(P)}finally{q(!1)}}}function me(P){P.key==="Enter"?(P.preventDefault(),V()):P.key==="Escape"&&(P.preventDefault(),j(!1))}const ne=k?.status==="running",X=k?oo(n,k):null,se=k?Dr(n,k.seatId)??null:null,J=se===null?null:nt(se),N=k===null?"":`${se===null||J===null?At(n,k):Xn(se,J)} · ${k.projectPath}`,$=s?null:"Sending is disabled: this server was started without dispatch.";return r.jsxs("section",{className:W.workspace,"aria-labelledby":te,children:[r.jsxs("header",{className:W.header,"data-app-region":"drag",children:[fe,k?R?r.jsx("input",{ref:ie,className:W.titleInput,value:O,"aria-label":"Chat title",onChange:P=>G(P.target.value),onBlur:()=>{V()},onKeyDown:me,maxLength:120}):r.jsx("h1",{id:te,className:W.title,children:r.jsx("button",{type:"button",className:W.titleButton,title:"Rename chat",disabled:Q||!s,onClick:()=>{G(k.title),j(!0)},children:k.title||"Untitled chat"})}):r.jsx("h1",{id:te,className:`${W.title} skeleton ${W.titleSkeleton}`,"aria-label":"Loading chat"}),k?r.jsxs("span",{className:`${W.seatPill} ${W[`engine-${k.engine}`]??""}`,"data-engine":k.engine,"data-seat-capacity":J!==null&&Hs(J.cls)?J.cls:void 0,title:N,children:[r.jsx("span",{className:W.engineDot,"aria-hidden":"true"}),r.jsx("span",{className:W.seatText,children:At(n,k)}),r.jsx("span",{className:W.projectName,children:Vn(k.projectPath,a)}),J!==null&&Hs(J.cls)?r.jsx(Yn,{view:J}):null]}):null,r.jsx("div",{className:W.headerSpacer}),t.stream==="reconnecting"?r.jsx("span",{className:W.streamState,role:"status",children:"reconnecting…"}):null,k?r.jsx(sd,{contextTokens:k.usage.contextTokens,contextWindow:X}):null,k?pe?r.jsxs("span",{className:W.confirm,role:"group","aria-label":"Confirm delete",children:[r.jsx("span",{className:W.confirmText,children:"Delete this chat?"}),r.jsx("button",{type:"button",className:W.danger,disabled:Q,onClick:async()=>{q(!0);try{await f()||de(!1)}finally{q(!1)}},children:"Delete"}),r.jsx("button",{type:"button",className:W.ghost,onClick:()=>de(!1),children:"Keep"})]}):r.jsx("button",{type:"button",className:W.ghostIcon,onClick:()=>de(!0),disabled:!s||ne,"aria-label":"Delete chat",title:ne?"Stop the turn before deleting":"Delete chat",children:r.jsx(ko,{})}):null,r.jsx(Ar,{open:x,onToggle:w})]}),r.jsx(og,{transcript:t.transcript,loaded:t.loaded,loadError:t.loadError,onRetry:S}),k?r.jsx(ud,{sessionId:k.id,seats:n,seat:{seatId:k.seatId,model:k.model},engine:k.engine,running:ne,disabled:!s,disabledReason:$,locked:i,hintSeen:k.turnCount>0,contextTokens:k.usage.contextTokens,contextWindow:X,onSend:l,onStop:u,onSeatChange:y,autoFocus:!0},k.id):null]})}function Ar({open:e,onToggle:t}){return r.jsx("button",{type:"button",className:W.ghostIcon,onClick:t,"aria-pressed":e,title:e?"Hide resources":"Show resources","aria-label":"Resources",children:r.jsx(wo,{})})}const hg="_chat_fzgvr_6",pg="_main_fzgvr_30",fg="_banner_fzgvr_40",mg="_bannerWarn_fzgvr_41",gg="_resize_fzgvr_75",_g="_scrim_fzgvr_94",dt={chat:hg,main:pg,banner:fg,bannerWarn:mg,resize:gg,scrim:_g},Gn="ashlr.verse.selected.v1";function xg(){try{return localStorage.getItem(Gn)}catch{return null}}function Rr(e){return e instanceof Za?"This server was started without dispatch — run `ashlr verse` to chat.":e instanceof Qa?e.status===409?"A turn is already running in this chat. Stop it first.":e.status===413?"That message is too large (64 KB max).":e.status===401?"Mutation token was rejected. Unlock again with the token ashlr verse printed.":e.message:e instanceof Error?e.message:"Something went wrong."}function Mg(){const e=Xt(ft),t=Xt(Ds),n=On(Ds),a=On(ft),s=Va(),i=Ha(),o=To(),[l,u]=p.useState(xg),[d,f]=p.useState(""),[y,m]=p.useState({open:!1}),[S,g]=p.useState(!1),[_,x]=p.useState(null),[w,k]=p.useState(!1),[R,j]=p.useState(0),[O,G]=p.useState({open:!1,reason:""}),pe=p.useRef(null),de=p.useRef(null),Q=p.useMemo(()=>e.data?.seats??[],[e.data]),q=p.useMemo(()=>e.data?.projects??[],[e.data]),ie=Xt(So),te=p.useMemo(()=>ie.data?.workspaces??[],[ie.data]),fe=e.data?.dispatchEnabled??!0,V=ju(l,R),me=p.useMemo(()=>{const C=t.data??e.data?.sessions??[];if(!V.session)return C;const v=V.session;return C.some(le=>le.id===v.id)?C.map(le=>le.id===v.id?v:le):[v,...C]},[t.data,e.data,V.session]),ne=p.useCallback(C=>{u(C);try{C?localStorage.setItem(Gn,C):localStorage.removeItem(Gn)}catch{}},[]);p.useEffect(()=>{!l||!t.data||!t.data.some(C=>C.id===l)&&!V.session&&ne(null)},[l,t.data,V.session,ne]),p.useEffect(()=>Su(),[]);const X=p.useCallback((C,v)=>s.hasHold?v():new Promise(le=>{pe.current={run:()=>{v().then(le)},cancel:()=>le(null)},G({open:!0,reason:C})}),[s.hasHold]),se=p.useCallback(C=>{C instanceof jo||i.show(Rr(C),"danger")},[i]),J=p.useCallback((C={})=>{x(null);const v=V.session,le=C.projectPath!==void 0?C.projectPath:v?.projectPath??null,B=v&&le===v.projectPath?{seatId:v.seatId,model:v.model}:null,Se=C.seat??B??No(le);m({open:!0,projectPath:le,seat:Se})},[V.session]),N=p.useCallback(async C=>{await X("Starting a chat spawns an agent process for this project.",async()=>{g(!0),x(null);try{const v=await Eo(C);vo(v.projectPath,{seatId:v.seatId,model:v.model}),En(v.id,v),m({open:!1}),ne(v.id),i.show(`Started “${v.title}”`,"success")}catch(v){x(Rr(v))}finally{g(!1)}})},[X,ne,i]),$=p.useCallback(async C=>{const v=l;return v?await X("Sending a message runs the agent against this project.",async()=>{qs(v,"running");try{const B=await Ao(v,C);return En(v,B.session,B.turnId),!0}catch(B){return qs(v,"idle"),se(B),!1}})===!0:!1},[l,X,se]),P=p.useCallback((C=l)=>{C&&X("Stopping the running turn.",async()=>{try{await Ro(C)}catch(v){se(v)}})},[l,X,se]),ye=p.useCallback(async C=>{const v=l;return v?await X("Renaming a chat.",async()=>{try{const B=await Co(v,C);return En(v,B),!0}catch(B){return se(B),!1}})===!0:!1},[l,X,se]),z=p.useCallback(async()=>{const C=l;return C?await X("Deleting a chat removes its transcript from disk.",async()=>{try{return await Io(C),Jl(C),Xa(C),ne(null),i.show("Chat deleted.","neutral"),!0}catch(le){return se(le),!1}})===!0:!1},[l,X,se,ne,i]),F=p.useCallback(C=>{const v=V.session;v&&(J({projectPath:v.projectPath,seat:C}),i.show("Chats are bound to one seat — starting a new chat on the same project.","neutral"))},[V.session,J,i]),ke=p.useRef(0);p.useEffect(()=>{const C=o.command;!C||C.nonce===ke.current||(ke.current=C.nonce,C.name==="quick-switcher"?k(!0):J(),$o())},[o.command,V.session,J]);const Te=p.useCallback((C,v)=>{C==="sidebar"?Lo(v):Mo(v)},[]);function $e(C){return v=>{const le=C==="sidebar"?Os:zs,B=C==="sidebar"?o.sidebarWidth:o.resourcesWidth,Se=C==="sidebar"?v.key==="ArrowRight":v.key==="ArrowLeft",je=C==="sidebar"?v.key==="ArrowLeft":v.key==="ArrowRight",We=Se?B+20:je?B-20:v.key==="Home"?le.min:v.key==="End"?le.max:null;We!==null&&(v.preventDefault(),Te(C,We))}}function M(C){const v=C==="sidebar"?Os:zs,le=C==="sidebar"?o.sidebarWidth:o.resourcesWidth;return r.jsx("div",{className:dt.resize,role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":C==="sidebar"?"Resize chat list":"Resize resources panel","aria-valuemin":v.min,"aria-valuemax":v.max,"aria-valuenow":le,onKeyDown:$e(C),onPointerDown:B=>{de.current={id:B.pointerId,x:B.clientX,start:le,side:C},B.currentTarget.setPointerCapture?.(B.pointerId)},onPointerMove:B=>{const Se=de.current;if(!Se||Se.id!==B.pointerId)return;const je=B.clientX-Se.x;Te(Se.side,Se.side==="sidebar"?Se.start+je:Se.start-je)},onPointerUp:()=>{de.current=null},onPointerCancel:()=>{de.current=null}})}const K={"--verse-sidebar-width":`${o.sidebarWidth}px`,"--verse-resources-width":`${o.resourcesWidth}px`},be=e.data?!e.data.dispatchEnabled:!1,He=o.resourcesOpen,gt=o.sidebarCollapsed;return r.jsxs("div",{className:dt.chat,style:K,"data-sidebar":gt?"collapsed":"open","data-resources":He?"open":"closed",children:[r.jsx(yu,{sessions:me,sessionsStatus:t.status,sessionsError:t.error?.message??null,projects:q,seats:Q,selectedId:l,query:d,onQuery:f,onSelect:C=>{ne(C),window.matchMedia?.("(max-width: 760px)")?.matches===!0&&qt(!0)},onNew:()=>J(),onRetry:()=>{n(),a()},onCollapse:()=>qt(!0),onDisconnect:()=>{Ya()}}),M("sidebar"),r.jsx("button",{type:"button",className:dt.scrim,"aria-label":"Close chat list",tabIndex:-1,onClick:()=>qt(!0)}),r.jsxs("div",{className:dt.main,children:[e.status==="error"&&!e.data?r.jsxs("div",{role:"alert",className:dt.banner,children:[r.jsx("span",{children:e.error?.message??"Could not load Verse."}),r.jsx("button",{type:"button",onClick:a,children:"Retry"})]}):be?r.jsxs("div",{role:"status",className:dt.bannerWarn,children:["Read-only: this server was started without dispatch. Run ",r.jsx("code",{children:"ashlr verse"})," to send messages."]}):null,r.jsx(dg,{view:V,seats:Q,projects:q,dispatchEnabled:fe,locked:!s.hasHold,hasAnySessions:me.length>0,onSend:$,onStop:()=>P(),onRename:ye,onDelete:z,onSeatChange:F,onNew:()=>J(),onRetry:()=>j(C=>C+1),sidebarCollapsed:gt,onToggleSidebar:()=>qt(!gt),resourcesOpen:He,onToggleResources:()=>Ps(!He)})]}),He?r.jsxs(r.Fragment,{children:[M("resources"),r.jsx(Kc,{bootstrap:e.data,sessions:me,current:V.session,onStop:C=>P(C),onOpen:ne,onClose:()=>Ps(!1)})]}):null,r.jsx(ul,{open:y.open,onClose:()=>m({open:!1}),projects:q,seats:Q,workspaces:te,initialProjectPath:y.projectPath??null,initialSeat:y.seat??null,busy:S,error:_,onCreate:N}),r.jsx(wl,{open:w,onClose:()=>k(!1),sessions:me,seats:Q,projects:q,onSelectSession:ne,onNewChat:C=>J({projectPath:V.session?.projectPath??null,seat:C})}),r.jsx(Fa,{open:O.open,reason:O.reason,tokenLabel:"Mutation token",tokenHelp:"the mutation token ashlr verse printed",onClose:()=>{G({open:!1,reason:""});const C=pe.current;C&&setTimeout(()=>{pe.current===C&&(pe.current=null,C.cancel())},0)},onUnlocked:()=>{const C=pe.current;pe.current=null,C?.run()}})]})}export{Mg as ChatSection};
|
|
77
|
-
//# sourceMappingURL=ChatSection-DmE9K0Tg.js.map
|