@ours.network/fleet 1.2.0-nightly.30 → 1.2.0-nightly.32
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/dist/build-info.json +4 -4
- package/dist/cli.js +48 -16
- package/dist/minimal-setup.d.ts +2 -0
- package/dist/minimal-setup.js +43 -0
- package/dist/web/available-port.d.ts +2 -0
- package/dist/web/available-port.js +23 -0
- package/dist/web/runtime.js +17 -2
- package/dist/web/service.d.ts +5 -0
- package/dist/web/service.js +8 -0
- package/dist/web-app/assets/FleetApp-D58F4xje.css +1 -0
- package/dist/web-app/assets/FleetApp-Gjz3h8uS.js +302 -0
- package/dist/web-app/assets/FleetApp-Gjz3h8uS.js.map +1 -0
- package/dist/web-app/assets/abnfDiagram-VCTEODGH-t4h5V8Cs.js +2 -0
- package/dist/web-app/assets/abnfDiagram-VCTEODGH-t4h5V8Cs.js.map +1 -0
- package/dist/web-app/assets/arc-DbufDTF6.js +2 -0
- package/dist/web-app/assets/arc-DbufDTF6.js.map +1 -0
- package/dist/web-app/assets/architectureDiagram-5GKGNRK7-D6K8jMN5.js +37 -0
- package/dist/web-app/assets/architectureDiagram-5GKGNRK7-D6K8jMN5.js.map +1 -0
- package/dist/web-app/assets/blockDiagram-I7D4REHJ-CWvkET2x.js +130 -0
- package/dist/web-app/assets/blockDiagram-I7D4REHJ-CWvkET2x.js.map +1 -0
- package/dist/web-app/assets/browser-B7y08DsC.js +9 -0
- package/dist/web-app/assets/browser-B7y08DsC.js.map +1 -0
- package/dist/web-app/assets/c4Diagram-7LVT6UL2-RNWA7VnD.js +39 -0
- package/dist/web-app/assets/c4Diagram-7LVT6UL2-RNWA7VnD.js.map +1 -0
- package/dist/web-app/assets/channel-BF3U9sI8.js +2 -0
- package/dist/web-app/assets/channel-BF3U9sI8.js.map +1 -0
- package/dist/web-app/assets/chunk-2Q5K7J3B-pdEuY4vj.js +2 -0
- package/dist/web-app/assets/chunk-2Q5K7J3B-pdEuY4vj.js.map +1 -0
- package/dist/web-app/assets/chunk-5VM5RSS4-DuAUtdUC.js +16 -0
- package/dist/web-app/assets/chunk-5VM5RSS4-DuAUtdUC.js.map +1 -0
- package/dist/web-app/assets/chunk-F27PBJKO-6kpb80Xt.js +2 -0
- package/dist/web-app/assets/chunk-F27PBJKO-6kpb80Xt.js.map +1 -0
- package/dist/web-app/assets/chunk-IMKFNOWR-DWC84P6A.js +232 -0
- package/dist/web-app/assets/chunk-IMKFNOWR-DWC84P6A.js.map +1 -0
- package/dist/web-app/assets/chunk-JWPE2WC7-FHO-M3vi.js +2 -0
- package/dist/web-app/assets/chunk-JWPE2WC7-FHO-M3vi.js.map +1 -0
- package/dist/web-app/assets/chunk-POPQ4Y6H-CjnlKvmR.js +2 -0
- package/dist/web-app/assets/chunk-POPQ4Y6H-CjnlKvmR.js.map +1 -0
- package/dist/web-app/assets/chunk-SVP7TREG-WHYWJ6xq.js +89 -0
- package/dist/web-app/assets/chunk-SVP7TREG-WHYWJ6xq.js.map +1 -0
- package/dist/web-app/assets/chunk-TICWLB2K-POupMpyL.js +207 -0
- package/dist/web-app/assets/chunk-TICWLB2K-POupMpyL.js.map +1 -0
- package/dist/web-app/assets/chunk-XXDRQBXY-Cw5HHqH-.js +2 -0
- package/dist/web-app/assets/chunk-XXDRQBXY-Cw5HHqH-.js.map +1 -0
- package/dist/web-app/assets/classDiagram-ZZMXUADV-1hdMzIme.js +2 -0
- package/dist/web-app/assets/classDiagram-ZZMXUADV-1hdMzIme.js.map +1 -0
- package/dist/web-app/assets/classDiagram-v2-VYDZK3BY-1hdMzIme.js +2 -0
- package/dist/web-app/assets/classDiagram-v2-VYDZK3BY-1hdMzIme.js.map +1 -0
- package/dist/web-app/assets/cose-bilkent-JH36ORCC-Cp6Hjine.js +2 -0
- package/dist/web-app/assets/cose-bilkent-JH36ORCC-Cp6Hjine.js.map +1 -0
- package/dist/web-app/assets/cynefin-OW5HDTMX-DI-DeNUk.js +179 -0
- package/dist/web-app/assets/cynefin-OW5HDTMX-DI-DeNUk.js.map +1 -0
- package/dist/web-app/assets/cynefinDiagram-5FMLGOSQ-todBCANI.js +63 -0
- package/dist/web-app/assets/cynefinDiagram-5FMLGOSQ-todBCANI.js.map +1 -0
- package/dist/web-app/assets/cytoscape.esm-CtNdOvlO.js +332 -0
- package/dist/web-app/assets/cytoscape.esm-CtNdOvlO.js.map +1 -0
- package/dist/web-app/assets/dagre-GXQ25YYZ-BvIVo7eh.js +5 -0
- package/dist/web-app/assets/dagre-GXQ25YYZ-BvIVo7eh.js.map +1 -0
- package/dist/web-app/assets/defaultLocale-DX6XiGOO.js +2 -0
- package/dist/web-app/assets/defaultLocale-DX6XiGOO.js.map +1 -0
- package/dist/web-app/assets/diagram-S7CK7UJ4-k9vDGlB5.js +31 -0
- package/dist/web-app/assets/diagram-S7CK7UJ4-k9vDGlB5.js.map +1 -0
- package/dist/web-app/assets/diagram-UQ7AKVKN-Bv7BT1dE.js +42 -0
- package/dist/web-app/assets/diagram-UQ7AKVKN-Bv7BT1dE.js.map +1 -0
- package/dist/web-app/assets/diagram-VSXAHHWV-m9I9AumX.js +4 -0
- package/dist/web-app/assets/diagram-VSXAHHWV-m9I9AumX.js.map +1 -0
- package/dist/web-app/assets/diagram-VX7I27RA-4VJ2qozS.js +25 -0
- package/dist/web-app/assets/diagram-VX7I27RA-4VJ2qozS.js.map +1 -0
- package/dist/web-app/assets/diagram-Z3DM3KII-CvH8JIEd.js +25 -0
- package/dist/web-app/assets/diagram-Z3DM3KII-CvH8JIEd.js.map +1 -0
- package/dist/web-app/assets/ebnfDiagram-PWID7BFC-DAGs23hd.js +2 -0
- package/dist/web-app/assets/ebnfDiagram-PWID7BFC-DAGs23hd.js.map +1 -0
- package/dist/web-app/assets/erDiagram-RLTQ6QDP-CEMyWKIa.js +100 -0
- package/dist/web-app/assets/erDiagram-RLTQ6QDP-CEMyWKIa.js.map +1 -0
- package/dist/web-app/assets/flowDiagram-HODETNUW-BnraxJTV.js +169 -0
- package/dist/web-app/assets/flowDiagram-HODETNUW-BnraxJTV.js.map +1 -0
- package/dist/web-app/assets/ganttDiagram-EL5Y4UJY-V6d4ICW0.js +293 -0
- package/dist/web-app/assets/ganttDiagram-EL5Y4UJY-V6d4ICW0.js.map +1 -0
- package/dist/web-app/assets/gitGraphDiagram-WWUBYQGX-Bj_gqcba.js +107 -0
- package/dist/web-app/assets/gitGraphDiagram-WWUBYQGX-Bj_gqcba.js.map +1 -0
- package/dist/web-app/assets/index-C4BdeFB9.css +1 -0
- package/dist/web-app/assets/index-i9rKiqYX.js +430 -0
- package/dist/web-app/assets/index-i9rKiqYX.js.map +1 -0
- package/dist/web-app/assets/infoDiagram-27XIBGKW-Dfm89NLl.js +3 -0
- package/dist/web-app/assets/infoDiagram-27XIBGKW-Dfm89NLl.js.map +1 -0
- package/dist/web-app/assets/init-Gi6I4Gst.js +2 -0
- package/dist/web-app/assets/init-Gi6I4Gst.js.map +1 -0
- package/dist/web-app/assets/ishikawaDiagram-5VMMS53U-D-ISiJTS.js +71 -0
- package/dist/web-app/assets/ishikawaDiagram-5VMMS53U-D-ISiJTS.js.map +1 -0
- package/dist/web-app/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/web-app/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/web-app/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/web-app/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/web-app/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/web-app/assets/journeyDiagram-3NMN7TZE-TTySrzws.js +140 -0
- package/dist/web-app/assets/journeyDiagram-3NMN7TZE-TTySrzws.js.map +1 -0
- package/dist/web-app/assets/kanban-definition-UXKFOSKX-BxntsBft.js +90 -0
- package/dist/web-app/assets/kanban-definition-UXKFOSKX-BxntsBft.js.map +1 -0
- package/dist/web-app/assets/katex-HP8lGamR.js +258 -0
- package/dist/web-app/assets/katex-HP8lGamR.js.map +1 -0
- package/dist/web-app/assets/layout-0sZak8Ho.js +2 -0
- package/dist/web-app/assets/layout-0sZak8Ho.js.map +1 -0
- package/dist/web-app/assets/linear-D4xk4kUi.js +2 -0
- package/dist/web-app/assets/linear-D4xk4kUi.js.map +1 -0
- package/dist/web-app/assets/mermaid.core-CNKolAgz.js +313 -0
- package/dist/web-app/assets/mermaid.core-CNKolAgz.js.map +1 -0
- package/dist/web-app/assets/mindmap-definition-YA3MSWOX-DLJijY_l.js +97 -0
- package/dist/web-app/assets/mindmap-definition-YA3MSWOX-DLJijY_l.js.map +1 -0
- package/dist/web-app/assets/ordinal-Cboi1Yqb.js +2 -0
- package/dist/web-app/assets/ordinal-Cboi1Yqb.js.map +1 -0
- package/dist/web-app/assets/pegDiagram-XKGWAZYB-xjrh9rBd.js +2 -0
- package/dist/web-app/assets/pegDiagram-XKGWAZYB-xjrh9rBd.js.map +1 -0
- package/dist/web-app/assets/pieDiagram-E7YTZNPT-CHE8ZMXN.js +40 -0
- package/dist/web-app/assets/pieDiagram-E7YTZNPT-CHE8ZMXN.js.map +1 -0
- package/dist/web-app/assets/quadrantDiagram-AXDQQJYC-CDlEe9sg.js +8 -0
- package/dist/web-app/assets/quadrantDiagram-AXDQQJYC-CDlEe9sg.js.map +1 -0
- package/dist/web-app/assets/railroadDiagram-O6MQD6OU-Dv7lFZ_v.js +2 -0
- package/dist/web-app/assets/railroadDiagram-O6MQD6OU-Dv7lFZ_v.js.map +1 -0
- package/dist/web-app/assets/requirementDiagram-BXWQKSXE-BetEel-k.js +85 -0
- package/dist/web-app/assets/requirementDiagram-BXWQKSXE-BetEel-k.js.map +1 -0
- package/dist/web-app/assets/sankeyDiagram-P5KCCOFB-DCQgLfvK.js +41 -0
- package/dist/web-app/assets/sankeyDiagram-P5KCCOFB-DCQgLfvK.js.map +1 -0
- package/dist/web-app/assets/sequenceDiagram-WJ2MYXX4-CsGOoqu_.js +163 -0
- package/dist/web-app/assets/sequenceDiagram-WJ2MYXX4-CsGOoqu_.js.map +1 -0
- package/dist/web-app/assets/sizeCapture-INFHLROL-CLQRMiEc.js +2 -0
- package/dist/web-app/assets/sizeCapture-INFHLROL-CLQRMiEc.js.map +1 -0
- package/dist/web-app/assets/stateDiagram-D77RDMKH-D2MRdC5Q.js +2 -0
- package/dist/web-app/assets/stateDiagram-D77RDMKH-D2MRdC5Q.js.map +1 -0
- package/dist/web-app/assets/stateDiagram-v2-MP3YSRHH-CToAT5fD.js +2 -0
- package/dist/web-app/assets/stateDiagram-v2-MP3YSRHH-CToAT5fD.js.map +1 -0
- package/dist/web-app/assets/swimlanes-42K2YHIH-BGjHfR8x.js +2 -0
- package/dist/web-app/assets/swimlanes-42K2YHIH-BGjHfR8x.js.map +1 -0
- package/dist/web-app/assets/swimlanesDiagram-VR7AAH4N-bLHg88Vk.js +9 -0
- package/dist/web-app/assets/swimlanesDiagram-VR7AAH4N-bLHg88Vk.js.map +1 -0
- package/dist/web-app/assets/timeline-definition-24CTP7MA-DhGtHQ0p.js +121 -0
- package/dist/web-app/assets/timeline-definition-24CTP7MA-DhGtHQ0p.js.map +1 -0
- package/dist/web-app/assets/vennDiagram-4TSXK5OY-Dv5irf00.js +35 -0
- package/dist/web-app/assets/vennDiagram-4TSXK5OY-Dv5irf00.js.map +1 -0
- package/dist/web-app/assets/wardleyDiagram-VM6X3IG4-JGiUTj5x.js +79 -0
- package/dist/web-app/assets/wardleyDiagram-VM6X3IG4-JGiUTj5x.js.map +1 -0
- package/dist/web-app/assets/xychartDiagram-S5SC5T6Z-Dw5ev7_Q.js +8 -0
- package/dist/web-app/assets/xychartDiagram-S5SC5T6Z-Dw5ev7_Q.js.map +1 -0
- package/dist/web-app/fleet-index.html +19 -0
- package/dist/web-app/fleet.webmanifest +37 -0
- package/dist/web-app/icons/apple-touch-icon.png +0 -0
- package/dist/web-app/icons/favicon-16.png +0 -0
- package/dist/web-app/icons/favicon-32.png +0 -0
- package/dist/web-app/icons/icon-192-maskable.png +0 -0
- package/dist/web-app/icons/icon-192.png +0 -0
- package/dist/web-app/icons/icon-512-maskable.png +0 -0
- package/dist/web-app/icons/icon-512.png +0 -0
- package/dist/web-app/index.html +19 -0
- package/dist/web-app/manifest.webmanifest +17 -0
- package/dist/web-app/sw.js +221 -0
- package/dist/web-app/version.json +1 -0
- package/dist/web-app/workspace-install.sh +148 -0
- package/dist/web-app/workspace-tunnel.sh +40 -0
- package/dist/workspace-enrollment.d.ts +3 -0
- package/dist/workspace-enrollment.js +18 -1
- package/package.json +2 -2
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import{c as $e,r as g,j as a,B as J,C as Yo,u as Sp,f as _p,L as Zi,a as Cp,i as Ip,b as Vi,d as Np,e as Ep,P as We,w as tc,h as Qs,W as nc,k as un,s as Rp,I as Ft,l as zp,m as dn,A as er,n as ws,o as xo,S as xr,R as sc,p as rc,F as Tp,X as oc,q as Op,V as Ap,t as $p,D as Es,v as Pp,x as xe,y as ic,z as Lp,E as kr,U as ac,G as Hs,H as Xo,J as wr,K as lc,M as cc,N as uc,O as dc,Q as Bt,T as Dp,Y as ko,Z as Mp,_ as Fp,$ as Up,a0 as Bp,a1 as Zp,a2 as pc,a3 as tr,a4 as Fn,a5 as wo,a6 as Vp,a7 as qp,a8 as Hp,a9 as Wp,aa as qi,ab as Kp,ac as Jp,ad as Hi,ae as Gp,af as Yp,ag as Xp,ah as Qp,ai as ef}from"./index-i9rKiqYX.js";import{Q as tf}from"./browser-B7y08DsC.js";/**
|
|
2
|
+
* @license lucide-react v0.468.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Qo=$e("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
|
|
7
|
+
* @license lucide-react v0.468.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Wi=$e("AudioLines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);/**
|
|
12
|
+
* @license lucide-react v0.468.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const nf=$e("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
|
|
17
|
+
* @license lucide-react v0.468.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const ei=$e("Bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);/**
|
|
22
|
+
* @license lucide-react v0.468.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const fc=$e("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
|
|
27
|
+
* @license lucide-react v0.468.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const sf=$e("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/**
|
|
32
|
+
* @license lucide-react v0.468.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const rf=$e("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
37
|
+
* @license lucide-react v0.468.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const hc=$e("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
|
|
42
|
+
* @license lucide-react v0.468.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const of=$e("DoorClosed",[["path",{d:"M18 20V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14",key:"36qu9e"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M14 12v.01",key:"xfcn54"}]]);/**
|
|
47
|
+
* @license lucide-react v0.468.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const af=$e("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/**
|
|
52
|
+
* @license lucide-react v0.468.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const lf=$e("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
|
57
|
+
* @license lucide-react v0.468.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const cf=$e("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);/**
|
|
62
|
+
* @license lucide-react v0.468.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const uf=$e("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
|
|
67
|
+
* @license lucide-react v0.468.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const df=$e("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
|
|
72
|
+
* @license lucide-react v0.468.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const mc=$e("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
|
|
77
|
+
* @license lucide-react v0.468.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const Ki=$e("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
|
|
82
|
+
* @license lucide-react v0.468.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const pf=$e("Layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);/**
|
|
87
|
+
* @license lucide-react v0.468.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const ff=$e("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
92
|
+
* @license lucide-react v0.468.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const nr=$e("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
|
|
97
|
+
* @license lucide-react v0.468.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const hf=$e("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
|
102
|
+
* @license lucide-react v0.468.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const mf=$e("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/**
|
|
107
|
+
* @license lucide-react v0.468.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const jr=$e("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/**
|
|
112
|
+
* @license lucide-react v0.468.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const js=$e("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
|
|
117
|
+
* @license lucide-react v0.468.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/const gc=$e("ScanLine",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]);/**
|
|
122
|
+
* @license lucide-react v0.468.0 - ISC
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the ISC license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/const yc=$e("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
127
|
+
* @license lucide-react v0.468.0 - ISC
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the ISC license.
|
|
130
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
+
*/const gf=$e("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
|
|
132
|
+
* @license lucide-react v0.468.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const yf=$e("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
|
|
137
|
+
* @license lucide-react v0.468.0 - ISC
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the ISC license.
|
|
140
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/const Sr=$e("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);function Te({title:e,description:t,icon:n,danger:s=!1,badge:r,className:o="",...i}){const l=g.useId(),c=g.useId();return a.jsxs(J,{"aria-labelledby":t?l:void 0,"aria-describedby":t?c:void 0,...i,className:["menu-action",s&&"danger",o].filter(Boolean).join(" "),children:[a.jsx(n,{size:20,"aria-hidden":!0}),a.jsxs("span",{children:[a.jsxs("span",{id:l,children:[e,r&&a.jsx("span",{className:`menu-action-badge is-${r.tone}`,children:r.label})]}),t&&a.jsx("small",{id:c,className:"menu-action-description",children:t})]}),a.jsx(Yo,{size:16,"aria-hidden":!0})]})}const vf=e=>!e.isLayoutDirty&&e.willUpdate(!1);function Ji(){const e=new Set,t=new WeakMap,n=()=>e.forEach(vf);return{add:s=>{e.add(s),t.set(s,s.addEventListener("willUpdate",n))},remove:s=>{e.delete(s);const r=t.get(s);r&&(r(),t.delete(s)),n()},dirty:n}}const bf=g.createContext(null);function xf(){const e=g.useRef(!1);return Sp(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function kf(){const e=xf(),[t,n]=g.useState(0),s=g.useCallback(()=>{e.current&&n(t+1)},[t]);return[g.useCallback(()=>_p.postRender(s),[s]),t]}const vc=e=>e===!0,wf=e=>vc(e===!0)||e==="id",jf=({children:e,id:t,inherit:n=!0})=>{const s=g.useContext(Zi),r=g.useContext(bf),[o,i]=kf(),l=g.useRef(null),c=s.id||r;l.current===null&&(wf(n)&&c&&(t=t?c+"-"+t:c),l.current={id:t,group:vc(n)&&s.group||Ji()});const u=g.useMemo(()=>({...l.current,forceRender:o}),[i]);return a.jsx(Zi.Provider,{value:u,children:e})};let Gn="";function Sf(){return{"X-CSRF-Token":Gn}}function _f(e){Gn=e}async function ee(e,t,n=t===void 0?"GET":"POST"){const s=await fetch("/fleet/api/v1"+e,{method:n,credentials:"same-origin",cache:"no-store",headers:{...t===void 0?{}:{"Content-Type":"application/json"},"X-CSRF-Token":Gn,...t&&typeof t=="object"&&"idempotencyKey"in t?{"Idempotency-Key":String(t.idempotencyKey)}:{}},...t===void 0?{}:{body:JSON.stringify(t)}}),r=await s.json();if(!s.ok)throw s.status===401&&!e.startsWith("/auth/")&&dispatchEvent(new Event("fleet-session-expired")),Object.assign(new Error(r?.error?.message??`HTTP ${s.status}`),{status:s.status,code:r?.error?.code,accepted:r?.accepted});return r}const it=Cp((e,t)=>fetch("/messenger"+String(e),{...t,headers:{...t?.headers,"X-CSRF-Token":Gn}}));function Cf(e){return{id:e.role.id,name:e.role.config?.name??e.role.id,lifetime:e.role.lifetime==="permanent"?"Persistent":"Temporary",state:e.status.overall,role:e.role.config?.mission??"",folder:e.role.config?.cwd??""}}function ti(e){return{id:e.task_id,name:e.title,list:e.list_name,roomCid:e.room_identity_cid,status:e.state[0].toUpperCase()+e.state.slice(1),description:e.brief??"",agents:e.member_roles.map(t=>t.name),blocked:e.blocked?.reason,pending:e.terminal_intent?.status==="pending"?e.terminal_intent.error??"Closing the room…":void 0,closed:["done","cancelled"].includes(e.state),...e.layout?{layout:e.layout.name,layoutHash:e.layout.definition_hash,layoutRooms:e.layout_rooms??[]}:{}}}async function If(){const e=await it.contacts();return[...e.contacts.map(t=>({...t,status:"active"})),...e.pending.map(t=>({...t,status:"pending"}))].map(t=>({id:t.container_id,name:Vi(t),announcedName:t.name,initials:Ip(Vi(t)),when:"",activityAt:"",last:"",unread:0,status:t.status,root:null,sub:"",roleId:null,rootName:null,mine:!1,kind:"person"}))}async function Nf(e,t){const[n,s]=await Promise.all([it.conversation(e),it.files(e)]),r=[...n.messages];let o=n.nextBefore,i=n.hasMore;const l=new AbortController,c=setTimeout(()=>l.abort(),1e4);try{for(let d=1;t&&!r.some(p=>p.wire_id===t)&&!s.files.some(p=>p.wire_id===t)&&i&&o&&d<20;d++){const p=await it.conversation(e,o,l.signal);if(r.push(...p.messages),p.nextBefore===o)break;o=p.nextBefore,i=p.hasMore}}finally{clearTimeout(c)}Np(s.files);const u=r.map(d=>({dir:d.dir,text:d.text,date:d.date,read:d.read,wireId:d.wire_id,peerCid:d.peer_cid,replyTo:d.reply_to?{wireId:d.reply_to.wire_id}:null,receipt:d.receipt??void 0,receiptless:d.dir==="out"&&!d.wire_id,messageKind:d.message_kind,typed:d.typed}));for(const d of s.files){const p=u.find(f=>f.wireId===d.wire_id);p?Object.assign(p,{kind:"file",filename:d.filename,mime:d.mime}):u.push({dir:d.dir,text:"",date:d.date,read:!0,wireId:d.wire_id,replyTo:null,kind:"file",filename:d.filename,mime:d.mime})}return u.sort((d,p)=>Date.parse(d.date)-Date.parse(p.date))}async function Ef(e){const t=new Map;let n;for(let s=0;s<100;s++){const r=await ee(`/roles/${encodeURIComponent(e)}/conversation?limit=1000${n?"&after="+encodeURIComponent(n):""}`);for(const o of r.events)if(o.kind==="prompt.admitted")t.set(o.promptId??o.eventId,{dir:"out",text:o.payload.text?.text??o.payload.text??"",date:o.at,read:!0,wireId:o.promptId??o.eventId,replyTo:null});else if(o.kind==="message.chunk"||o.kind==="message.replace"){if(o.payload.content?.type!=="text")continue;const i=o.messageId??o.eventId,l=t.get(i);t.set(i,{dir:o.payload.role==="user"?"out":"in",text:o.payload.content.redacted?"[Content hidden by server]":(o.kind==="message.chunk"?l?.text??"":"")+o.payload.content.text,date:o.at,read:!0,wireId:i,replyTo:null})}if(!r.hasMore||!r.nextCursor||r.nextCursor===n)break;n=r.nextCursor}return[...t.values()]}Ep({url:e=>"/messenger/api/media/"+encodeURIComponent(e),bytes:async e=>{const t=await fetch("/messenger/api/media/"+encodeURIComponent(e));if(!t.ok)throw new Error(`File download failed: ${t.status}`);return new Uint8Array(await t.arrayBuffer())},fetch:async e=>{await it.fetchFiles([e])}});async function Gi(e,t){const n=await fetch("/cowork/browser/rpc",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-CSRF-Token":Gn},body:JSON.stringify({version:1,id:crypto.randomUUID(),method:e,params:t})}),s=await n.json();if(!n.ok||s.error)throw new Error(s.error?.message??`HTTP ${n.status}`);return s.result}async function Rf(e,t,n){const s=await fetch("/daemon/voice/transcribe",{method:"POST",credentials:"same-origin",signal:n,headers:{"Content-Type":e.type,"X-CSRF-Token":Gn,...t===null?{}:{"X-Voice-Duration":String(t)}},body:e});s.status===401&&dispatchEvent(new Event("fleet-session-expired"));const r=await s.json().catch(()=>null);if(!s.ok)throw new Error(r?.error?.message??"Voice transcription is unavailable. Please retry.");if(typeof r?.text!="string"||!r.text.trim())throw new Error("No speech was recognized.");return r.text}const zf={"claude-fable-5-1":[2,1,257],"claude-opus-5-5":[2,1,280]};function Tf(e,t){const n=zf[e];if(!n)return!0;const s=t?.match(/\b(\d+)\.(\d+)\.(\d+)\b/);if(!s)return!1;const r=s.slice(1).map(Number);for(let o=0;o<3;o++)if(r[o]!==n[o])return r[o]>n[o];return!0}const Ws={claude:"Claude Code",codex:"Codex"},Of={ok:"Signed in",expiring:"Login expires soon",expired:"Login expired — sign in again",signed_out:"Not signed in",error:"Needs attention",unknown:"Checking…"},Ss="fleet-subscription-restart:",Af=(e,t)=>sessionStorage.setItem(Ss+e,t),Fr=e=>sessionStorage.removeItem(Ss+e),Ur=e=>sessionStorage.getItem(Ss+e)!==null,$f=()=>Object.keys(sessionStorage).filter(e=>e.startsWith(Ss)).map(e=>[e.slice(Ss.length),sessionStorage.getItem(e)]),Dn=e=>!!e&&["starting","awaiting_user","verifying"].includes(e.state);function ps(e){if(!e)return"";const t=Math.round((Date.now()-Date.parse(e))/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.round(t/60)} h ago`}function Pf(e){return e?`resets ${new Date(e).toLocaleString(void 0,{weekday:"short",hour:"2-digit",minute:"2-digit"})}`:""}function bc({back:e}){const[t,n]=g.useState(),[s,r]=g.useState(),[o,i]=g.useState(""),[l,c]=g.useState(""),[u,d]=g.useState(""),[p,f]=g.useState({}),[h,m]=g.useState({}),v=g.useRef();v.current=s;const b=async()=>n((await ee("/subscriptions")).providers),k=async(C,M)=>{d(C),c("");try{await M(),await b()}catch(E){c(E.message)}finally{d("")}};g.useEffect(()=>{b().catch(M=>c(M.message));const C=setInterval(()=>{const M=v.current;Dn(M)?ee(`/subscriptions/${M.provider}/logins/${M.loginId}`).then(E=>{r(E),Dn(E)||b()}).catch(()=>{}):b().catch(()=>{})},Dn(v.current)?2e3:15e3);return()=>clearInterval(C)},[Dn(s)]);const z=C=>k("login",async()=>{i(""),r(await ee(`/subscriptions/${C}/logins`,{}))}),R=()=>k("code",async()=>{r(await ee(`/subscriptions/${s.provider}/logins/${s.loginId}/code`,{code:o})),i("")}),A=()=>k("cancel",async()=>{r(await ee(`/subscriptions/${s.provider}/logins/${s.loginId}`,void 0,"DELETE"))}),D=(C,M)=>k("activate",()=>ee(`/subscriptions/${C}/active`,{profileId:M})),O=(C,M)=>{confirm(`Remove ${M.label}? Fleet signs this account out and deletes its login from this host.`)&&k("remove",()=>ee(`/subscriptions/${C}/profiles/${M.id}`,void 0,"DELETE"))},I=(C,M)=>{const E=prompt("Profile name",M.label);E&&E!==M.label&&k("rename",()=>ee(`/subscriptions/${C}/profiles/${M.id}`,{label:E},"PATCH"))},F=(C,M)=>k("check",()=>ee(`/subscriptions/${C}/profiles/${M}/check`,{})),L=C=>k("probe",async()=>{m(E=>({...E,[C]:""}));const M=await ee(`/subscriptions/claude/profiles/${C}/probe`,{});m(E=>({...E,[C]:M.usage.exhausted?"Claude reported a limit reached. Exact usage and reset time were not returned.":M.usage.windows.length?"Claude usage updated from a small Haiku request.":"Claude did not return usage limits for this check."}))}),j=async(C,M)=>{const E=T=>f(B=>({...B,[C]:T}));E("pending");for(let T=0;T<90;T++){const B=await ee(`/actions/${encodeURIComponent(M)}`);if(B.state==="succeeded"){Fr(C),E("succeeded");return}if(B.state==="failed")return Fr(C),E("failed"),`${C}: ${B.error?.message??"failed"}`;if(B.state==="uncertain")return E("uncertain"),`${C}: result uncertain — inspect the agent before another action`;await new Promise(Y=>setTimeout(Y,1e3))}E("still pending")},x=C=>k("restart",async()=>{const M=[];if(await Promise.all(C.filter(E=>!Ur(E)).map(async E=>{const T=crypto.randomUUID();Af(E,T);try{await ee(`/roles/${encodeURIComponent(E)}/actions`,{action:"restart_fresh",confirmation:E,actionId:T});const B=await j(E,T);B&&M.push(B)}catch(B){B.status===409&&B.accepted===!1&&Fr(E),f(re=>({...re,[E]:"failed"})),M.push(`${E}: ${B.message}`)}})),M.length)throw new Error(`Restart did not complete for ${M.join("; ")}.`)});return g.useEffect(()=>{for(const[C,M]of $f())j(C,M).catch(()=>{})},[]),a.jsxs("main",{className:"fleet-form-page fleet-subscriptions",children:[a.jsx(We,{title:"Subscriptions",subtitle:"Experimental · Claude Code and Codex accounts for agents launched by this Fleet",onBack:e}),l&&a.jsx("p",{role:"alert",className:"fleet-sub-error",children:l}),s&&a.jsx(Df,{login:s,code:o,setCode:i,busy:u,submit:R,cancel:A,close:()=>r(void 0)},s.loginId),t?t.map(C=>{const M=C.staleAgents;return a.jsxs("section",{className:"fleet-sub-provider","aria-label":Ws[C.provider],children:[a.jsxs("header",{className:"fleet-sub-provider-head",children:[a.jsx("h2",{children:Ws[C.provider]}),a.jsx(J,{disabled:!!u||Dn(s),onClick:()=>void z(C.provider),children:"Add account"})]}),M.length>0&&a.jsxs("div",{className:"fleet-sub-banner",role:"status",children:[a.jsxs("p",{children:[a.jsxs("strong",{children:[M.length," running agent",M.length>1?"s":""," still use",M.length>1?"":"s"," the previous account"]})," (",M.map(E=>p[E.roleId]?`${E.roleId} — restart ${p[E.roleId]}`:E.roleId).join(", "),"). Agents keep their account until they are restarted. Restarting starts a fresh conversation on the active account."]}),a.jsxs(J,{primary:!0,disabled:!!u||M.every(E=>Ur(E.roleId)),onClick:()=>void x(M.map(E=>E.roleId)),children:["Restart ",M.length>1?"all":"agent"]}),M.some(E=>Ur(E.roleId))&&a.jsx("small",{children:"Agents with an unsettled restart are skipped; check them on their agent page before trying again."})]}),C.unmanagedAgents.length>0&&a.jsxs("p",{className:"fleet-sub-note",children:["Not managed by these profiles: ",C.unmanagedAgents.map(E=>`${E.roleId} (${E.via.join(", ")})`).join("; "),"."]}),a.jsx("ul",{className:"fleet-sub-profiles",children:C.profiles.map(E=>a.jsxs("li",{className:"fleet-sub-profile"+(E.active?" active":""),children:[a.jsxs("div",{className:"fleet-sub-profile-head",children:[a.jsxs("label",{className:"fleet-sub-radio",children:[a.jsx("input",{type:"radio",name:`active-${C.provider}`,checked:E.active,disabled:!!u,onChange:()=>void D(C.provider,E.id),"aria-label":`Use ${E.label} for ${Ws[C.provider]}`}),a.jsxs("span",{children:[a.jsx("strong",{children:E.label}),a.jsx("small",{children:[E.account?.email!==E.label?E.account?.email:"",E.account?.plan,E.active?"active":""].filter(Boolean).join(" · ")})]})]}),a.jsx("span",{className:`fleet-sub-health ${E.health.state}`,title:E.health.detail,children:Of[E.health.state]})]}),E.health.detail&&E.health.state!=="ok"&&a.jsx("p",{className:"fleet-sub-note",children:E.health.detail}),E.health.loginExpiresAt&&a.jsxs("p",{className:"fleet-sub-note",children:["Login renews until ",new Date(E.health.loginExpiresAt).toLocaleDateString()]}),a.jsx(Lf,{provider:C.provider,usage:E.usage}),h[E.id]&&C.provider==="claude"&&a.jsx("p",{role:"status",className:"fleet-sub-note",children:h[E.id]}),a.jsxs("div",{className:"fleet-sub-meta",children:[a.jsxs("small",{children:[E.agents.length?`In use by ${E.agents.join(", ")}`:"No running agents",E.health.checkedAt?` · checked ${ps(E.health.checkedAt)}`:""]}),a.jsxs("span",{className:"fleet-sub-actions",children:[a.jsx(J,{disabled:!!u,onClick:()=>void F(C.provider,E.id),children:"Check"}),C.provider==="claude"&&a.jsx(J,{disabled:!!u,title:"Uses a small amount of this account's Claude allowance",onClick:()=>void L(E.id),children:"Check usage · Haiku request"}),E.id!=="default"&&a.jsx(J,{disabled:!!u,onClick:()=>I(C.provider,E),children:"Rename"}),E.id!=="default"&&!E.active&&a.jsx(J,{disabled:!!u||E.agents.length>0,title:E.agents.length?"Restart the agents using it first":void 0,onClick:()=>O(C.provider,E),children:"Remove"})]})]})]},E.id))})]},C.provider)}):a.jsx("p",{children:"Loading…"}),a.jsx("p",{className:"fleet-sub-note",children:"Switching applies to agents started afterwards. Fleet never shows or stores your tokens; each account's login stays in its own CLI folder on this host."})]})}function Lf({provider:e,usage:t}){return t.windows.length?a.jsxs("div",{className:"fleet-sub-usage",children:[t.exhausted&&a.jsx("p",{className:"fleet-sub-note",children:"Claude reported a limit reached. The percentages below are the latest values it provided."}),t.windows.map(n=>a.jsxs("div",{className:"fleet-sub-window",children:[a.jsxs("div",{className:"fleet-sub-window-label",children:[a.jsx("span",{children:n.label}),a.jsxs("span",{children:[Math.round(n.usedPercent),"% used"]})]}),a.jsx("div",{className:"fleet-sub-bar",role:"meter","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(n.usedPercent),"aria-label":`${n.label} usage`,children:a.jsx("span",{style:{width:`${Math.min(100,Math.max(0,n.usedPercent))}%`},className:n.usedPercent>=90?"high":n.usedPercent>=70?"mid":""})}),n.resetsAt&&a.jsx("small",{children:Pf(n.resetsAt)})]},n.id)),a.jsx("small",{className:"fleet-sub-note",children:t.source==="agent"?`Last reported by an agent ${ps(t.observedAt)}`:t.source==="probe"?`Checked with Haiku ${ps(t.observedAt)}`:`Updated ${ps(t.observedAt)}`})]}):a.jsx("p",{className:"fleet-sub-note",children:e==="claude"?a.jsxs(a.Fragment,{children:[t.exhausted?`Claude reported a limit reached ${ps(t.observedAt)}. Exact usage and reset time were not returned. `:"Usage appears after an agent gets a reply, or you can check now with a small Haiku request that uses this account's allowance. ",a.jsx("a",{href:"https://claude.ai/settings/usage",target:"_blank",rel:"noreferrer",children:"View on claude.ai"})]}):"Usage limits unavailable."})}function Df({login:e,code:t,setCode:n,busy:s,submit:r,cancel:o,close:i}){const l=Ws[e.provider],[c,u]=g.useState(""),d=async(p,f)=>{if(p){u("");try{await navigator.clipboard.writeText(p),u(`${f} copied.`)}catch{u(`Could not copy ${f.toLowerCase()}. Select the text shown above and copy it manually.`)}}};return a.jsxs("section",{className:"fleet-sub-login","aria-label":`Add ${l} account`,children:[a.jsxs("h2",{children:["Add ",l," account"]}),e.state==="starting"&&a.jsx("p",{children:"Starting sign-in…"}),e.state==="awaiting_user"&&e.kind==="paste_code"&&e.url&&a.jsxs(a.Fragment,{children:[a.jsxs("ol",{children:[a.jsxs("li",{children:["Open the Claude sign-in page and sign in with the account you want to add.",a.jsxs("div",{className:"fleet-sub-signin-actions",children:[a.jsx("a",{className:"fleet-sub-signin-link",href:e.url,target:"_blank",rel:"noreferrer noopener",children:"Open Claude sign-in at claude.com ↗"}),a.jsx(J,{onClick:()=>void d(e.url,"Sign-in link"),children:"Copy link"})]}),a.jsx("input",{className:"field fleet-sub-signin-url","aria-label":"Claude sign-in link",readOnly:!0,value:e.url,onFocus:p=>p.target.select()}),a.jsx("small",{children:"If the page does not open, copy this link into your browser."})]}),a.jsx("li",{children:"Copy the code from the Claude sign-in page and paste it here."})]}),a.jsxs("form",{className:"fleet-sub-code",onSubmit:p=>{p.preventDefault(),r()},children:[a.jsx("input",{className:"field","aria-label":"Sign-in code",autoComplete:"off",spellCheck:!1,value:t,onChange:p=>n(p.target.value),placeholder:"Paste code"}),a.jsx(J,{primary:!0,type:"submit",disabled:!!s||!t.trim(),children:"Continue"})]})]}),e.state==="awaiting_user"&&e.kind==="paste_code"&&!e.url&&a.jsx("p",{role:"alert",children:"The sign-in link is unavailable. Cancel and try again."}),e.state==="awaiting_user"&&e.kind==="device_code"&&a.jsxs("ol",{children:[a.jsxs("li",{children:["Open ",a.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer noopener",children:e.url})," and sign in with the ChatGPT account you want to add."]}),a.jsxs("li",{children:["Enter this code: ",a.jsxs("span",{className:"fleet-sub-device-code",children:[a.jsx("code",{className:"fleet-sub-usercode",children:e.userCode}),a.jsx(J,{onClick:()=>void d(e.userCode,"Device code"),disabled:!e.userCode,children:"Copy code"})]})]}),a.jsx("li",{children:"Keep this page open; it updates when sign-in finishes."})]}),c&&a.jsx("p",{role:c.startsWith("Could not")?"alert":"status",className:"fleet-sub-note",children:c}),e.state==="verifying"&&a.jsx("p",{children:"Checking the new login…"}),e.state==="succeeded"&&a.jsx("p",{role:"status",children:"Account added. Select it below to make it active."}),["failed","expired","cancelled"].includes(e.state)&&a.jsx("p",{role:"alert",children:e.state==="cancelled"?"Sign-in cancelled.":e.error??"Sign-in did not complete."}),a.jsx("div",{className:"fleet-actions",children:Dn(e)?a.jsx(J,{disabled:s==="cancel",onClick:o,children:"Cancel"}):a.jsx(J,{onClick:i,children:"Close"})})]})}const Yi="ours-workspace-onboarding-complete";function xc({children:e,force:t=!1,back:n}){const[s,r]=g.useState(!t&&(!tc()||localStorage.getItem(Yi)==="1")),[o,i]=g.useState(0),[l,c]=g.useState(),[u,d]=g.useState(),[p,f]=g.useState({}),[h,m]=g.useState(""),[v,b]=g.useState(!1),[k,z]=g.useState(!1),[R,A]=g.useState(""),D=async()=>{const[j,x]=await Promise.all([ee("/onboarding"),ee("/configuration?includeDefinitions=true")]);c(j),d(x)};g.useEffect(()=>{s||D().catch(j=>m(j.message))},[s]);const O=j=>l?.harnesses.find(x=>x.harness===j.harness)?.ok&&Tf(j.model,l?.harnesses.find(x=>x.harness===j.harness)?.checks.find(x=>x.name==="claude")?.detail)&&l.providers.find(x=>x.provider===(j.harness==="codex"?"codex":"claude"))?.profiles.some(x=>x.active&&["ok","expiring"].includes(x.health.state)),I=l?.catalog.filter(O)??[],F=async j=>{b(!0),m("");try{await j()}catch(x){m(x.message)}finally{b(!1)}},L=()=>{localStorage.setItem(Yi,"1"),r(!0),n?.()};return s?a.jsx(a.Fragment,{children:e}):k?a.jsx(bc,{back:()=>{z(!1),F(D)}}):a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:"Set up your Fleet",onBack:n}),Qs()&&a.jsx(nc,{context:Qs(),select:j=>un("select",j),add:()=>un("add"),settings:()=>un("settings"),logout:()=>un("logout")}),h&&a.jsx("p",{role:"alert",children:h}),o===0?a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:"Connect your agent accounts"}),a.jsx("p",{children:"Fleet checks installed Codex and Claude Code on this workspace host. Your provider login stays on the host; the account server does not collect those credentials."}),l?.harnesses.map(j=>a.jsxs("section",{children:[a.jsx("h3",{children:j.harness}),a.jsx("p",{children:j.ok?"Prerequisites available":"Setup needed"}),j.checks.map((x,C)=>a.jsxs("p",{children:[x.ok?"✓":"○"," ",x.name,": ",x.detail]},C)),!j.ok&&a.jsxs("p",{children:["Install the current supported CLI on this host, then return here. Run ",j.harness==="codex"?"codex login":"claude auth login"," there, or use the profile login flow below."]})]},j.harness)),a.jsx(J,{onClick:()=>z(!0),children:"Manage accounts and sign in"}),a.jsx(J,{onClick:()=>void F(D),children:"Recheck"}),a.jsx("p",{children:"Settings → Subscriptions lets you add multiple profiles, see their usage and switch the active profile. Running agents remain pinned to their original profile until restarted."}),a.jsx(J,{primary:!0,onClick:()=>i(1),children:"Continue"})]}):o===1?a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:"Choose models for the team"}),a.jsx("p",{children:"Coordinator organizes work; Developer implements changes; Critic independently checks results. Single, pair, team and engineering room layouts select different combinations. The human Owner joins task rooms through the root identity configured during setup."}),a.jsx("p",{children:"For an available Codex account, start with GPT-6.1 Sol for coordination/development and GPT-6 Astra for difficult reviews when your plan supports it. For Claude, use Opus 5.5 for coding and complex reviews, and Fable 5.1 for the hardest or longest investigations when your plan supports it. Choices below come from this installed Fleet artifact's supported catalog and signed-in active profiles; provider entitlement still determines actual model access."}),["coordination","development","review"].map(j=>a.jsxs("label",{children:[{coordination:"Coordinator",development:"Developer",review:"Critic"}[j],a.jsxs("select",{value:p[j]??"",onChange:x=>f(C=>({...C,[j]:x.target.value})),children:[a.jsx("option",{value:"",children:"Choose an available model…"}),I.map(x=>a.jsxs("option",{value:x.harness+":"+x.model,children:[x.harness," · ",x.model]},x.harness+":"+x.model))]})]},j)),I.length===0&&a.jsx("p",{children:"No ready harness/profile/model version found. Complete login or resolve prerequisite checks first."}),a.jsxs("p",{children:["Claude Fable 5.1 requires Claude Code 2.1.257 or newer; Opus 5.5 requires 2.1.280 or newer. Update on the workspace host before rechecking. ",a.jsx("a",{href:"https://code.claude.com/docs/en/model-config",target:"_blank",rel:"noreferrer",children:"Claude model guidance"})," · ",a.jsx("a",{href:"https://developers.openai.com/api/docs/models",target:"_blank",rel:"noreferrer",children:"OpenAI model guidance"})]}),a.jsx(J,{onClick:()=>i(0),children:"Back"}),a.jsx(J,{primary:!0,disabled:v||!u||["coordination","development","review"].some(j=>!p[j]),onClick:()=>void F(async()=>{const j=structuredClone(u.model);j.brains??={};for(const x of["coordination","development","review"]){const C=I.find(E=>E.harness+":"+E.model===p[x]);if(!C)throw Error("Selected model is unavailable");const M=C.efforts.includes("medium")?"medium":C.efforts[0];j.brains[x]={harness:C.harness,session:C.session,model:C.model,...M?{effort:M}:{}}}if(!j.agents?.FleetCoordinator)throw Error("Run ours-fleet init on the host to prepare the persistent FleetCoordinator");j.agents.FleetCoordinator.brain={ref:"coordination"};for(const x of["Developer","Engineer"])j.agent_templates?.[x]&&(j.agent_templates[x].brain={ref:"development"});for(const x of["Critic"])j.agent_templates?.[x]&&(j.agent_templates[x].brain={ref:"review"});for(const x of["Coordinator","LocalCoordinator"])j.agent_templates?.[x]&&(j.agent_templates[x].brain={ref:"coordination"});await ee("/configuration/save",{revision:u.revision,model:j}),await D(),i(2)}),children:"Save Fleet configuration"})]}):a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:"Meet FleetCoordinator"}),a.jsx("p",{children:"Your persistent FleetCoordinator helps you navigate the app, create/manage agents, tasks and rooms. Configuration is saved; starting its supported lifecycle may prompt for missing provider setup. Agent identity readiness is checked separately after launch."}),a.jsx(J,{disabled:v,onClick:()=>void F(async()=>{const j=await ee("/roles/FleetCoordinator/actions",{action:"start",actionId:crypto.randomUUID()});A(j.state??"Start accepted; check the agent status in Work.")}),children:"Start FleetCoordinator"}),R&&a.jsx("p",{role:"status",children:R}),a.jsx(J,{primary:!0,onClick:L,children:"Open workspace"})]})]})}async function Cn(e,t){const n=await fetch("/notifications/api/v1"+e,{credentials:"same-origin",cache:"no-store",method:t===void 0?"GET":"POST",headers:{...Sf(),...t===void 0?{}:{"Content-Type":"application/json"}},...t===void 0?{}:{body:JSON.stringify(t)}}),s=await n.json();if(!n.ok)throw n.status===401&&dispatchEvent(new Event("fleet-session-expired")),new Error(s?.error?.message??`Notification service returned ${n.status}`);return s}const sr="ours-notifications-device",rr="ours-notifications-enabled";function Mf(){return!Bn()&&!!localStorage.getItem(sr)}function Bn(){return localStorage.getItem(rr)==="1"}function Rs(){return!tc()&&window.isSecureContext&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}async function kc(){if(!Rs())throw new Error("Web push is unavailable here. On iPhone, add this app to the Home Screen and open it there.");return await navigator.serviceWorker.register("/sw.js",{scope:"/",updateViaCache:"none"}),navigator.serviceWorker.ready}async function ni(){if(!Bn()||!Rs()||Notification.permission!=="granted")return;const e=await kc();let t=await e.pushManager.getSubscription();const{publicKey:n}=await Cn("/push/config"),s=Uint8Array.from(atob(n.replaceAll("-","+").replaceAll("_","/")+"=".repeat((4-n.length%4)%4)),o=>o.charCodeAt(0));t?.options.applicationServerKey&&(t.options.applicationServerKey.byteLength!==s.length||!Array.from(new Uint8Array(t.options.applicationServerKey)).every((o,i)=>o===s[i]))&&(await t.unsubscribe(),t=null),t??=await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s});const r=await Cn("/devices",{subscription:t.toJSON()});localStorage.setItem(sr,r.id)}async function Ff(){if(!Rs())throw new Error("Web push is unavailable here. On iPhone, add this app to the Home Screen and open it there.");const e=await Notification.requestPermission();if(e!=="granted")throw new Error(e==="denied"?"Notifications are blocked. Enable them in browser or device Settings.":"Notification permission was not granted.");localStorage.setItem(rr,"1");try{await ni(),dispatchEvent(new Event("ours-notifications-device-changed"))}catch(t){throw localStorage.removeItem(rr),t}}async function jo(){const e=localStorage.getItem(sr),t=[];if(localStorage.removeItem(rr),dispatchEvent(new Event("ours-notifications-device-changed")),e)try{await Cn("/devices/delete",{id:e}),localStorage.removeItem(sr)}catch(n){t.push(n)}try{const n=await navigator.serviceWorker?.getRegistration("/"),s=await n?.pushManager.getSubscription();s&&!await s.unsubscribe()&&t.push(new Error("browser unsubscribe failed")),(await n?.getNotifications())?.forEach(o=>o.close())}catch(n){t.push(n)}if(t.length)throw new Error("Notifications are off locally, but cleanup was incomplete. Use Retry cleanup in Settings when the service is available.")}function Uf(){const[e,t]=g.useState({unread:0,revision:-1,chats:[]}),n=g.useRef(e),s=g.useRef(0),r=g.useRef(new Set),o=g.useCallback(async()=>{const l=++s.current;try{const c=await Cn("/summary");if(l!==s.current||!Array.isArray(c.chats))return;n.current=c,t(u=>u.revision===c.revision?u:c)}catch{}},[]),i=g.useCallback(async(l,c,u)=>{if(document.visibilityState!=="visible"||!n.current.chats.some(p=>p.source===l&&p.chat===c&&p.count>0))return;const d=JSON.stringify([l,c]);if(!r.current.has(d)){r.current.add(d);try{await Cn("/read-target",{url:`/fleet/chats?source=${l}&chat=${encodeURIComponent(c)}&detail=1`,revision:u}),await o(),dispatchEvent(new Event("ours-notifications-changed"))}catch{}finally{r.current.delete(d)}}},[o]);return{summary:e,refresh:o,viewed:i,captureRevision:()=>n.current.revision}}function Bf({back:e}){const[t,n]=g.useState(Bn),[s,r]=g.useState(!1),[o,i]=g.useState(""),l=async()=>{r(!0),i("");try{t?await jo():await Ff(),n(Bn())}catch(c){n(Bn()),i(c.message)}finally{r(!1)}};return a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:"Notifications",onBack:e}),a.jsx("p",{children:"Receive agent completions and new messages on this device. Your notification inbox and read status are shared across your signed-in devices."}),!Rs()&&a.jsx("p",{children:"On iPhone, add the app to your Home Screen and open it there to enable notifications."}),a.jsx("p",{role:"status",children:t?"Notifications enabled on this device":"Notifications off on this device"}),a.jsx(J,{disabled:s,onClick:()=>void l(),children:s?"Updating…":t?"Disable notifications":"Enable notifications"}),Mf()&&a.jsx(J,{disabled:s,onClick:()=>{r(!0),jo().then(()=>i("")).catch(c=>i(c.message)).finally(()=>r(!1))},children:"Retry cleanup"}),o&&a.jsx("p",{role:"alert",children:o})]})}function Zf({back:e,open:t,changed:n}){const[s,r]=g.useState(),[o,i]=g.useState(""),[l,c]=g.useState(!1),u=g.useRef(1),d=g.useRef(0),p=g.useRef(!0),f=g.useCallback(async()=>{const m=++d.current;try{let v=await Cn("/inbox");const b=[...v.items];for(let k=1;k<u.current&&v.nextCursor;k++)v=await Cn("/inbox?before="+encodeURIComponent(v.nextCursor)),b.push(...v.items);p.current&&m===d.current&&(r({...v,items:b}),i(""))}catch(v){p.current&&m===d.current&&i(v.message)}},[]);g.useEffect(()=>{p.current=!0,f();const m=setInterval(()=>{document.visibilityState==="visible"&&f()},5e3),v=()=>void f();return addEventListener("ours-notifications-changed",v),()=>{removeEventListener("ours-notifications-changed",v),p.current=!1,d.current++,clearInterval(m)}},[f]);const h=async()=>{if(!(!s?.nextCursor||l)){c(!0);try{u.current++,await f()}catch(m){i(m.message)}finally{c(!1)}}};return a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:"Notifications",onBack:e}),o&&a.jsx("p",{role:"alert",children:o}),s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{role:"status",children:[s.unread," unread"]}),!s.items.length&&a.jsx("p",{children:"No notifications yet."}),a.jsx("div",{className:"fleet-notification-list",children:s.items.map(m=>a.jsx("article",{className:m.readAt?"is-read":"is-unread",children:a.jsxs(J,{onClick:()=>t(m.url),children:[a.jsx("strong",{children:m.title}),a.jsx("span",{children:m.body}),a.jsxs("small",{children:[new Date(m.createdAt).toLocaleString(),m.readAt?" · Read":" · Unread"]})]})},m.id))}),s.nextCursor&&a.jsx(J,{disabled:l,onClick:()=>void h(),children:"Load older notifications"})]}):a.jsx("p",{children:"Loading notifications…"})]})}function Vf(){let e=!1,t=0,n,s,r,o=1e3;const i=Rp(),l=()=>{t++,clearTimeout(s),clearInterval(r),s=void 0,r=void 0;const m=n;n=void 0,m&&(m.onclose=null,m.close())},c=()=>!e&&document.visibilityState==="visible"&&Bn()&&Rs(),u=()=>{c()&&(s=setTimeout(()=>void d(),o),o=Math.min(o*2,3e4))},d=async()=>{if(l(),!c())return;const m=t;try{await ni();const b=await(await kc()).pushManager.getSubscription();if(m!==t||!c()||!b)return;const k=localStorage.getItem("ours-notifications-device"),z=b.toJSON().keys?.auth;if(!k||!z)return;const R=new URL("/notifications/api/v1/presence",location.href);R.protocol=R.protocol==="https:"?"wss:":"ws:";const A=n=new WebSocket(R);A.onopen=()=>A.send(JSON.stringify({type:"hello",id:k,endpoint:b.endpoint,auth:z})),A.onmessage=D=>{try{const O=JSON.parse(D.data);O.type==="presence.ready"&&(o=1e3,r=setInterval(()=>{c()&&A.readyState===WebSocket.OPEN?A.send(JSON.stringify({type:"heartbeat"})):l()},15e3),dispatchEvent(new Event("ours-notifications-changed"))),O.type==="inbox.changed"&&dispatchEvent(new Event("ours-notifications-changed"))}catch{}},A.onerror=()=>{},A.onclose=()=>{n===A&&(n=void 0,clearInterval(r),u())}}catch{m===t&&u()}},p=()=>{o=1e3,d()},f=()=>l(),h=()=>{e=!0,l()};return document.addEventListener("visibilitychange",p),addEventListener("pagehide",f),addEventListener("pageshow",p),addEventListener("ours-notifications-device-changed",p),addEventListener("fleet-session-expired",h),d(),()=>{e=!0,l(),i(),document.removeEventListener("visibilitychange",p),removeEventListener("pagehide",f),removeEventListener("pageshow",p),removeEventListener("ours-notifications-device-changed",p),removeEventListener("fleet-session-expired",h)}}function qf({task:e,onSaved:t}){const[n,s]=g.useState(!1),[r,o]=g.useState(""),[i,l]=g.useState(""),[c,u]=g.useState(!1),[d,p]=g.useState(""),f=g.useRef(!1);async function h(){if(!f.current){f.current=!0,u(!0),p("");try{const m=await ee(`/tasks/${encodeURIComponent(e.id)}/description`,{brief:r,expectedBrief:i},"PATCH");t(ti(m.task)),s(!1)}catch(m){p(m instanceof Error?m.message:"Could not save description")}finally{f.current=!1,u(!1)}}}return a.jsxs("section",{"aria-label":"Task description",children:[a.jsxs("div",{className:"fleet-description-heading",children:[a.jsx("h2",{children:"Description"}),!n&&a.jsx(Ft,{"aria-label":"Edit description",title:"Edit description",onClick:()=>{o(e.description),l(e.description),p(""),s(!0)},children:a.jsx(zp,{size:16,"aria-hidden":"true"})})]}),n?a.jsxs("form",{onSubmit:m=>{m.preventDefault(),h()},children:[a.jsx("textarea",{"aria-label":"Description",autoFocus:!0,rows:8,maxLength:1e5,value:r,disabled:c,onChange:m=>o(m.target.value)}),d&&a.jsx("p",{role:"alert",children:d}),a.jsxs("div",{className:"fleet-description-actions",children:[a.jsx("button",{type:"submit",disabled:c,children:c?"Saving…":"Save"}),a.jsx("button",{type:"button",disabled:c,onClick:()=>s(!1),children:"Cancel"})]})]}):a.jsx("p",{className:e.description?"fleet-task-description":"muted",children:e.description||"No description yet."})]})}function Gt(e,t){return t?`room-${e}:${t}`:`room-${e}`}function Ct(e){if(!e.startsWith("room-"))return null;const[t,n]=e.slice(5).split(":",2);return t?{taskId:t,...n?{key:n}:{}}:null}function $s(e,t){const n=Ct(t);if(!n)return;const s=e.find(r=>r.task_id===n.taskId);return n.key?s?.layout_rooms?.find(r=>r.key===n.key)?.identity_cid:s?.room_identity_cid}const Xi="absent",Hf=/^[A-Za-z][A-Za-z0-9_-]*$/,Wf=["constructor","prototype","__proto__"],si=e=>Hf.test(e)&&!Wf.includes(e);function Kf(){return{version:1,description:"",participants:{lead:{agent_template:""}},rooms:{kickoff:{goal:"",members:["lead"]}}}}function wc(e){const t=new Map;for(const n of Object.values(e.rooms))for(const s of n.members)t.set(s,(t.get(s)??0)+1);return new Set([...t].filter(([,n])=>n>1).map(([n])=>n))}function Jf(e,t){const n=[],s=Object.keys(e.participants),r=Object.entries(e.rooms);s.length||n.push("Add at least one participant."),r.length||n.push("Add at least one room.");for(const o of[...s,...r.map(([i])=>i)])si(o)||n.push(`“${o||"(empty)"}” is not a valid key. Start with a letter; use letters, numbers, - or _.`);for(const[o,i]of Object.entries(e.participants))i.agent_template?t.includes(i.agent_template)||n.push(`${o}: agent template ${i.agent_template} is not configured.`):n.push(`Choose an agent template for ${o}.`);for(const[o,i]of r){i.goal.trim()||n.push(`Room ${o} needs a goal.`),i.members.length||n.push(`Room ${o} needs at least one member.`);for(const l of i.members)Object.hasOwn(e.participants,l)||n.push(`Room ${o}: unknown participant ${l}.`);for(const l of Object.keys(i.roles??{}))i.members.includes(l)||n.push(`Room ${o}: a role is set for ${l}, who is not a member.`)}return n}function Gf(e){const t=n=>n?.trim()||void 0;return{version:1,...t(e.description)?{description:t(e.description)}:{},participants:Object.fromEntries(Object.entries(e.participants).map(([n,s])=>[n,s.agent_template?{agent_template:s.agent_template}:{}])),rooms:Object.fromEntries(Object.entries(e.rooms).map(([n,s])=>{const r=Object.fromEntries(Object.entries(s.roles??{}).map(([o,i])=>[o,i.trim()]).filter(([o,i])=>i&&s.members.includes(o)));return[n,{goal:s.goal.trim(),members:[...s.members],...Object.keys(r).length?{roles:r}:{},...t(s.contract)?{contract:t(s.contract)}:{},...s.quiet_membership!==void 0?{quiet_membership:s.quiet_membership}:{},...s.anonymous?{anonymous:!0}:{}}]}))}}function Yf(e,t,n){if(t===n||Object.hasOwn(e.participants,n))return e;const s=Object.fromEntries(Object.entries(e.participants).map(([o,i])=>[o===t?n:o,i])),r=Object.fromEntries(Object.entries(e.rooms).map(([o,i])=>[o,{...i,members:i.members.map(l=>l===t?n:l),...i.roles?{roles:Object.fromEntries(Object.entries(i.roles).map(([l,c])=>[l===t?n:l,c]))}:{}}]));return{...e,participants:s,rooms:r}}function Xf(e,t){const{[t]:n,...s}=e.participants,r=Object.fromEntries(Object.entries(e.rooms).map(([o,i])=>{const{[t]:l,...c}=i.roles??{};return[o,{...i,members:i.members.filter(u=>u!==t),...i.roles?{roles:c}:{}}]}));return{...e,participants:s,rooms:r}}function Qf(e,t,n){return t===n||Object.hasOwn(e.rooms,n)?e:{...e,rooms:Object.fromEntries(Object.entries(e.rooms).map(([s,r])=>[s===t?n:s,r]))}}const eh=(e,t)=>Object.entries(e.rooms).filter(([,n])=>n.members.includes(t)).map(([n])=>n);function Qi(e,t,n){const s=e.rooms[n];if(!s)return e;if(!s.members.includes(t))return{...e,rooms:{...e.rooms,[n]:{...s,members:[...s.members,t]}}};const{[t]:r,...o}=s.roles??{};return{...e,rooms:{...e.rooms,[n]:{...s,members:s.members.filter(i=>i!==t),...s.roles?{roles:o}:{}}}}}function th(e,t,n){const s=(n.replace(/[^A-Za-z0-9_-]/g,"").replace(/^[^A-Za-z]+/,"")||"agent").replace(/^./,c=>c.toLowerCase()),r=Object.keys(e.participants);let o=s,i=1;for(;r.includes(o);)o=`${s}${++i}`;const l=e.rooms[t];return{key:o,definition:{...e,participants:{...e.participants,[o]:{agent_template:n}},rooms:{...e.rooms,[t]:{...l,members:[...l.members,o]}}}}}function ea(e,t){let n=e.length+1;for(;e.includes(`${t}${n}`);)n++;return`${t}${n}`}const So={declared:"Not opened",provisioning:"Opening…",active:"Open",closed:"Closed"};function nh(e){if(!e)return;const t=e.operation==="open"?`Opening ${e.room}`:e.operation==="close-room"?`Closing ${e.room}`:"Closing all rooms";if(e.status==="failed")return`${t} failed: ${e.error??"unknown error"}`;if(e.status!=="succeeded")return`${t}…`}const jc=(e,t)=>`${e.name}${e.name===t?" (default)":""}${e.error||e.issues?.length?" — needs fixing":""}`,_o=e=>!!e&&!e.error&&!e.issues?.length,ta=e=>!!e&&(e.status==="launching"||e.status==="running"),an=encodeURIComponent,Xt={list:()=>ee("/room-layouts").then(e=>e.layouts),catalog:()=>ee("/room-layouts").then(e=>({layouts:e.layouts,defaultLayout:e.default_layout})),validate:e=>ee("/room-layouts/validate",{definition:e}),save:(e,t,n)=>ee(`/room-layouts/${an(e)}`,{revision:t,definition:Gf(n)},"PUT"),remove:(e,t)=>ee(`/room-layouts/${an(e)}?revision=${an(t)}`,void 0,"DELETE"),task:e=>ee(`/tasks/${an(e)}/layout`).then(t=>t.layout),room:(e,t,n)=>ee(`/tasks/${an(e)}/layout/rooms/${an(t)}/${n}`,{}).then(s=>s.operation),choose:(e,t,n)=>ee(`/tasks/${an(e)}/layout`,{layout:t,expectedLayout:n},"PATCH").then(s=>s.task),cleanup:e=>ee(`/tasks/${an(e)}/layout/cleanup`,{}).then(t=>t.operation)};function sh({task:e,openRoom:t,changed:n}){const[s,r]=g.useState(),[o,i]=g.useState(""),[l,c]=g.useState(""),[u,d]=g.useState([]),[p,f]=g.useState(""),h=g.useRef(""),m=["Active","Review"].includes(e.status),v=["Done","Cancelled","Failed"].includes(e.status),b=async()=>{const I=await Xt.task(e.id);r(I),i("");const F=I.rooms.map(L=>L.key+L.state).join();return h.current&&F!==h.current&&n(),h.current=F,I},k=ta(s?.operation)||!!s?.rooms.some(I=>I.state==="provisioning")||!!s?.closing;g.useEffect(()=>{let I=!0,F;const L=async()=>{try{await b()}catch(j){I&&i(j.message)}finally{I&&(F=setTimeout(L,k||u.length?1500:8e3))}};return L(),()=>{I=!1,clearTimeout(F)}},[e.id,k,u.length]),g.useEffect(()=>{if(!s||!u.length||k||l)return;const[I,...F]=u;if(s.operation?.status==="failed"&&s.operation.room===I){d([]);return}if(s.rooms.find(L=>L.key===I)?.state!=="declared"){d(F);return}z(I,"open").then(L=>d(L?F:[]))},[s,u,k,l]);const z=async(I,F)=>{c(I),i("");try{return await Xt.room(e.id,I,F),await b(),!0}catch(L){return i(L.message),!1}finally{c(""),f("")}},R=async()=>{c("cleanup"),i("");try{await Xt.cleanup(e.id),await b()}catch(I){i(I.message)}finally{c("")}};if(!s)return a.jsxs("section",{className:"fleet-task-rooms","aria-label":"Rooms",children:[a.jsx("h2",{children:"Rooms"}),a.jsx("p",{role:o?"alert":"status",children:o||"Loading rooms…"})]});const A=wc({rooms:Object.fromEntries(s.rooms.map(I=>[I.key,I]))}),D=s.rooms.filter(I=>I.state==="declared").map(I=>I.key),O=nh(s.operation);return a.jsxs("section",{className:"fleet-task-rooms","aria-label":"Rooms",children:[a.jsxs("header",{children:[a.jsxs("h2",{children:["Rooms ",a.jsxs("span",{className:"muted",children:[s.rooms.length," · ",s.name]})]}),m&&D.length>1&&a.jsx(J,{disabled:k||!!l||u.length>0,onClick:()=>d(D),children:u.length?`Opening ${u.length} rooms…`:"Open all rooms"})]}),!s.created&&!v&&a.jsx("p",{className:"muted",children:"Rooms become available when the task starts."}),O&&a.jsx("p",{className:s.operation?.status==="failed"?"fleet-warning":"fleet-task-rooms-status",role:s.operation?.status==="failed"?"alert":"status",children:O}),s.uncertain&&a.jsxs("p",{className:"fleet-warning",role:"alert",children:["A room operation has an unknown outcome (",s.uncertain,"). Inspect it with ",a.jsxs("code",{children:["ours-fleet layout status ",s.run_id]})," before continuing."]}),v&&s.created&&!s.closed&&a.jsxs("p",{className:"fleet-warning",children:[s.closing||ta(s.operation)?"Closing rooms and retiring layout agents…":"Room cleanup is not complete.",!k&&a.jsxs(J,{disabled:!!l,onClick:()=>void R(),children:[a.jsx(js,{size:16,"aria-hidden":!0}),"Retry cleanup"]})]}),o&&a.jsx("p",{role:"alert",children:o}),a.jsx(dn.ol,{layout:!0,className:"fleet-task-room-list",children:a.jsx(er,{initial:!1,children:s.rooms.map(I=>a.jsxs(dn.li,{layout:!0,transition:ws,className:`fleet-task-room is-${I.state}`,children:[a.jsxs("div",{className:"fleet-task-room-head",children:[a.jsx("strong",{children:I.key}),a.jsx("span",{className:`fleet-room-state is-${I.state}`,children:l===I.key?"Requesting…":So[I.state]})]}),a.jsx("p",{children:I.goal}),a.jsx("span",{className:"fleet-layout-map-members","aria-label":`Members of ${I.key}`,children:I.members.map(F=>a.jsxs("span",{className:A.has(F)?"shared":"",title:I.ready.includes(F)?"Joined":"Not joined yet",children:[I.roles?.[F]??F,I.ready.includes(F)?"":" ·"]},F))}),a.jsxs("div",{className:"fleet-task-room-actions",children:[I.state==="active"&&a.jsxs(J,{primary:!0,onClick:()=>t(I.key),children:[a.jsx(jr,{size:16,"aria-hidden":!0}),"Open chat"]}),I.state==="declared"&&m&&a.jsxs(J,{disabled:k||!!l||u.length>0,onClick:()=>void z(I.key,"open"),children:[a.jsx(af,{size:16,"aria-hidden":!0}),"Open room"]}),I.state==="provisioning"&&!v&&!k&&a.jsxs(J,{disabled:!!l,onClick:()=>void z(I.key,"open"),children:[a.jsx(js,{size:16,"aria-hidden":!0}),"Retry opening"]}),I.state==="active"&&!v&&(p===I.key?a.jsxs(a.Fragment,{children:[a.jsx(J,{onClick:()=>f(""),children:"Keep open"}),a.jsx(J,{className:"danger",disabled:!!l||k,onClick:()=>void z(I.key,"close"),children:"Close room"})]}):a.jsxs(J,{disabled:k||!!l,onClick:()=>f(I.key),children:[a.jsx(of,{size:16,"aria-hidden":!0}),"Close…"]}))]}),p===I.key&&a.jsx("p",{className:"muted",children:"Closing archives this room. Its agents stay available to the other rooms."})]},I.key))})})]})}function rh({taskId:e,rooms:t,current:n,select:s}){const r=g.useRef(null),o=t.filter(l=>l.state==="active"||l.state==="closed"),i=(l,c)=>{const u=o.findIndex(p=>p.key===l),d=c==="first"?o[0]:c==="last"?o.at(-1):o[(u+c+o.length)%o.length];d&&(s(d.key),r.current?.querySelector(`[data-room="${CSS.escape(d.key)}"]`)?.focus())};return a.jsx("div",{ref:r,className:"fleet-room-switcher",role:"tablist","aria-label":"Task rooms",children:t.map(l=>{const c=l.key===n,u=l.state==="active"||l.state==="closed";return a.jsxs("button",{type:"button",role:"tab","data-room":l.key,"aria-selected":c,tabIndex:c?0:-1,"aria-disabled":!u||void 0,title:u?void 0:So[l.state],className:`is-${l.state}`,onClick:()=>{u&&s(l.key)},onKeyDown:d=>{const p={ArrowRight:1,ArrowLeft:-1,Home:"first",End:"last"};d.key in p&&(d.preventDefault(),i(l.key,p[d.key]))},children:[c&&a.jsx(dn.span,{layoutId:`room-switcher-${e}`,className:"fleet-room-switcher-thumb",transition:ws,"aria-hidden":!0}),a.jsx("span",{className:"fleet-room-switcher-label",children:l.key}),l.state!=="active"&&a.jsx("span",{className:"fleet-room-switcher-state",children:So[l.state]})]},l.key)})})}function oh({task:e,saved:t,manage:n}){const s=e.status==="Backlog",[r,o]=g.useState(null),[i,l]=g.useState(),[c,u]=g.useState(!1),[d,p]=g.useState("");g.useEffect(()=>{s&&Xt.catalog().then(b=>{o(b.layouts),l(b.defaultLayout)}).catch(b=>{o([]),p(b.message)})},[s,e.id]);const f=async b=>{u(!0),p("");try{t(ti(await Xt.choose(e.id,b,e.layout??null)))}catch(k){p(k.message)}finally{u(!1)}};if(!s)return a.jsxs("section",{className:"fleet-task-layout-field","aria-label":"Room layout",children:[a.jsx("h2",{children:"Room layout"}),a.jsx("p",{children:e.layout??"None"}),a.jsxs("p",{className:"muted",children:[a.jsx(xo,{size:12,"aria-hidden":!0})," Fixed once the task started."]})]});const h=r?.find(b=>b.name===e.layout),m=!!e.layout&&!!h&&!!e.layoutHash&&h.error===void 0&&h.definition_hash!==e.layoutHash,v=!!e.layout&&r!==null&&(!h||!!h.error);return a.jsxs("section",{className:"fleet-task-layout-field","aria-label":"Room layout",children:[a.jsx("h2",{children:a.jsx("label",{htmlFor:`task-layout-${e.id}`,children:"Room layout"})}),a.jsxs("select",{id:`task-layout-${e.id}`,className:"field",value:e.layout??"",disabled:c||r===null,onChange:b=>void f(b.target.value),children:[!e.layout&&a.jsx("option",{value:"",disabled:!0,children:"Choose a layout"}),(r??[]).map(b=>a.jsx("option",{value:b.name,disabled:!_o(b),children:jc(b,i)},b.name)),v&&!h&&a.jsxs("option",{value:e.layout,children:[e.layout," — removed"]})]}),a.jsx("p",{className:e.layout?"muted":"fleet-warning",children:r===null?"Loading room layouts…":e.layout?"Used when the task starts. You can change it until then.":"Choose a room layout to start this task."}),a.jsx(er,{initial:!1,children:(m||v)&&a.jsx(dn.p,{className:"fleet-warning",role:"status",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0},transition:ws,children:m?a.jsxs(a.Fragment,{children:[e.layout," was edited after it was chosen. Use the latest version before starting.",a.jsxs(J,{disabled:c,onClick:()=>void f(e.layout),children:[a.jsx(js,{size:16,"aria-hidden":!0}),"Use latest version"]})]}):a.jsxs(a.Fragment,{children:[e.layout," is no longer available. Choose another layout before starting."]})},"warn")}),d&&a.jsx("p",{role:"alert",children:d}),a.jsx(J,{onClick:n,children:"Manage layouts"})]})}async function Br(e,t,n){const s=new URLSearchParams(Object.entries(n).filter(([,o])=>o!==void 0).map(([o,i])=>[o,String(i)])),r=await ee(`/roles/${encodeURIComponent(e)}/${t==="contacts"?"contacts":"messages?"+s}`);if(!Array.isArray(t==="contacts"?r.contacts:r.items))throw new Error("Supervisor returned an invalid correspondence response.");return r}function ih({agent:e,peer:t,go:n}){const[s,r]=g.useState([]),[o,i]=g.useState([]),[l,c]=g.useState(),[u,d]=g.useState(!1),[p,f]=g.useState(""),[h,m]=g.useState(""),v=R=>n({kind:"contacts",id:e.id,peer:R});g.useEffect(()=>{let R=!0;return r([]),f(""),d(!0),Br(e.id,"contacts",{}).then(A=>{R&&r(A.contacts??[])}).catch(A=>{R&&f(A.message)}).finally(()=>{R&&d(!1)}),()=>{R=!1}},[e.id]),g.useEffect(()=>{let R=!0;if(i([]),c(void 0),f(""),!!t)return d(!0),Br(e.id,"history",{peer_cid:t,limit:50}).then(A=>{R&&(i(A.messages??A.items??[]),c(A.next_cursor??void 0))}).catch(A=>{R&&f(A.message)}).finally(()=>{R&&d(!1)}),()=>{R=!1}},[e.id,t]);const b=async()=>{d(!0),f("");try{const R=await Br(e.id,"history",{peer_cid:t,limit:50,before_seq:l});i(A=>[...A,...(R.messages??R.items??[]).filter(D=>!A.some(O=>O.seq===D.seq))]),c(R.next_cursor??void 0)}catch(R){f(R.message)}finally{d(!1)}},k=s.find(R=>(R.container_id??R.id??R.cid)===t),z=R=>R.display_name??R.name??R.container_id??R.id??R.cid;return a.jsxs("section",{className:"fleet-agent-contacts",children:[a.jsx(We,{title:t?z(k??{id:t}):"Contacts & conversations",subtitle:`${e.name} · View only`,onBack:()=>t?v():n({kind:"profile",id:e.id})}),p&&a.jsx("p",{role:"alert",children:p}),t?a.jsxs(a.Fragment,{children:[a.jsx("ol",{className:"fleet-correspondence-history","aria-label":"Agent message history",children:[...o].sort((R,A)=>R.seq-A.seq).map(R=>{const A=R.text??R.body??(R.message_kind==="file"?"File attachment":"No message body available"),D=rc(k?.name,A);return a.jsxs("li",{className:"fleet-correspondence-message"+(R.direction==="out"?" sent":""),children:[a.jsxs("small",{children:[R.direction==="out"?e.name:D?.author??z(k??{id:t})," · ",a.jsx("time",{children:R.date})]}),a.jsx("p",{children:D?.text??A})]},R.seq)})}),l!=null&&a.jsx(J,{disabled:u,onClick:()=>void b(),children:"Load older messages"}),!u&&!o.length&&!p&&a.jsx("p",{children:"No messages yet."}),a.jsx("p",{className:"muted",children:"Viewing agent history · Read only"})]}):a.jsxs(a.Fragment,{children:[a.jsx(xr,{value:h,onChange:m,placeholder:"Search agent’s contacts"}),s.filter(R=>String(z(R)).toLowerCase().includes(h.toLowerCase())).map(R=>a.jsx(sc,{title:z(R),onClick:()=>v(R.container_id??R.id??R.cid)},R.container_id??R.id??R.cid)),!u&&!s.length&&!p&&a.jsx("p",{children:"No contacts yet."})]}),u&&a.jsx("p",{role:"status",children:"Loading…"})]})}const ah=20*1024*1024;function Sc(e){const[t,n]=g.useState(()=>{try{return e?JSON.parse(sessionStorage.getItem(e)??"{}").attachmentDetails??[]:[]}catch{return[]}}),s=g.useRef(t);s.current=t;const r=p=>{s.current=p,n(p)},[o,i]=g.useState("");return g.useEffect(()=>()=>{for(const p of s.current)p.url&&URL.revokeObjectURL(p.url)},[]),{items:t,error:o,add:(p,f)=>{if(s.current.length+p.length>5){i("Choose up to 5 files.");return}if(p.some(h=>h.size>ah)){i("Each file must be 20 MiB or smaller.");return}i(""),r([...s.current,...p.map(h=>({key:crypto.randomUUID(),name:h.name,size:h.size,mimeType:h.type||"application/octet-stream",file:h,generation:f,.../^image\/(png|jpeg|gif|webp|avif)$/.test(h.type)?{url:URL.createObjectURL(h)}:{}}))])},remove:p=>{const f=s.current.find(h=>h.key===p);f?.url&&URL.revokeObjectURL(f.url),r(s.current.filter(h=>h.key!==p))},upload:async(p,f)=>{if(!f)throw new Error("Agent session is not ready.");const h=[];for(const m of s.current){if(m.generation&&m.generation!==f)throw new Error("Agent session changed. Remove the attachments and select them again.");if(m.id){h.push(m);continue}if(!m.file)throw new Error("Select this file again: "+m.name);const v=await new Promise((z,R)=>{const A=new FileReader;A.onerror=()=>R(new Error("Could not read "+m.name)),A.onload=()=>z(String(A.result).split(",")[1]),A.readAsDataURL(m.file)}),b=await ee(`/roles/${encodeURIComponent(p)}/attachments`,{name:m.name,mimeType:m.mimeType,data:v,expectedSessionGeneration:f}),k={...m,id:b.id,generation:f};h.push(k),r(s.current.map(z=>z.key===m.key?k:z))}return h.map(({file:m,url:v,...b})=>b)},clear:()=>{for(const p of s.current)p.url&&URL.revokeObjectURL(p.url);r([]),i("")},has:t.length>0}}function _c({attachments:e,disabled:t,generation:n}){const s=g.useRef(null),r=g.useRef();return a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:s,type:"file",multiple:!0,hidden:!0,"aria-label":"Choose photos or files",disabled:t,onChange:o=>{e.add(Array.from(o.target.files??[]),r.current?r.current.value:n),r.current=void 0,o.target.value=""}}),a.jsx(J,{className:"chat-attach","aria-label":"Attach photos or files",title:"Attach photos or files",disabled:t,onClick:()=>{r.current={value:n},s.current?.click()},children:a.jsx(Op,{size:19})})]})}function Cc({attachments:e,disabled:t,onRemove:n}){return a.jsxs(a.Fragment,{children:[e.error&&a.jsx("p",{role:"alert",children:e.error}),e.has&&a.jsx("ul",{className:"fleet-attachment-previews","aria-label":"Attached files",children:e.items.map(s=>a.jsxs("li",{children:[s.url?a.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer","aria-label":"Preview "+s.name,children:a.jsx("img",{src:s.url,alt:s.name})}):a.jsx(Tp,{size:24}),a.jsxs("span",{title:s.name,children:[s.name,a.jsxs("small",{children:[Math.ceil(s.size/1024)," KB"]})]}),a.jsx(J,{"aria-label":"Remove "+s.name,disabled:t,onClick:()=>(n??e.remove)(s.key),children:a.jsx(oc,{size:16})})]},s.key))})]})}function Ic(e,t){return e+(e&&!/\s$/.test(e)?`
|
|
142
|
+
`:"")+t.trim()}function Nc({active:e,disabled:t,sessionGeneration:n,onTranscript:s,onBusy:r}){const[o,i]=g.useState(!1),[l,c]=g.useState(null),[u,d]=g.useState(!1),[p,f]=g.useState(""),[h,m]=g.useState(!1),v=g.useRef(),b=g.useRef(!1),k=g.useRef(),z=g.useRef(0),R=g.useRef(!0),A=g.useRef(n);A.current=n;const D=g.useRef(e);D.current=e;const O=g.useRef(s);O.current=s,g.useEffect(()=>{r(o||!!l||u)},[o,l,u,r]),g.useEffect(()=>(R.current=!0,()=>{R.current=!1,z.current++,k.current?.abort()}),[]),g.useEffect(()=>{e||(z.current++,k.current?.abort(),k.current=void 0,d(!1),b.current=!1,i(!1),m(!1))},[e]);const I=()=>{z.current++,k.current?.abort(),k.current=void 0,d(!1),c(null),f("")},F=async(L=l)=>{if(!L||k.current||t||!D.current)return;if(L.bytes.length>5*1024*1024){f("Recording exceeds 5 MiB. Discard and record a shorter message.");return}const j=++z.current,x=new AbortController;k.current=x;const C=setTimeout(()=>x.abort(),95e3);f(""),d(!0);try{const M=await Rf(new Blob([L.bytes],{type:L.mime.split(";")[0]}),Pp(L.mime),x.signal);if(!R.current||j!==z.current||!D.current)return;if(v.current!==A.current)throw new Error("Agent session changed. Discard this recording and record again in the current session.");O.current(M,v.current),c(null)}catch(M){R.current&&j===z.current&&f(M.name==="AbortError"?"Transcription timed out. Your recording is kept for retry.":M.message)}finally{clearTimeout(C),j===z.current&&(k.current=void 0,R.current&&d(!1))}};return a.jsxs(a.Fragment,{children:[e&&a.jsx(Ap,{disabled:t||!!l||u,onReady:L=>{!R.current||!D.current||(c(L),f(""),F(L))},onError:f,onActiveChange:L=>{L&&!b.current&&(v.current=n),b.current=L,i(L)}}),a.jsx(J,{type:"button",className:"fleet-acp-send fleet-live-voice-trigger","aria-label":"Live voice mode",title:"Live voice mode",onClick:()=>m(!0),children:a.jsx(Wi,{size:20})}),(l||p)&&e&&a.jsxs("div",{className:"fleet-voice-panel","aria-label":"Voice message",children:[l&&a.jsx($p,{compact:!0,att:l,sending:u,actionLabel:"Retry",busyLabel:"Recognizing speech…",allowDiscardWhileBusy:!0,onSend:()=>void F(),onDiscard:I}),p&&a.jsx("p",{role:"alert",children:p})]}),h&&a.jsx(Es,{title:"Live voice",description:"Talk with your agent",onClose:()=>m(!1),children:a.jsxs("div",{className:"fleet-live-voice",children:[a.jsx(Wi,{size:56,"aria-hidden":"true"}),a.jsx("h4",{children:"Live voice is not available yet"}),a.jsx("p",{children:"You can still record and transcribe a voice message."}),a.jsx(J,{type:"button",onClick:()=>m(!1),children:"Got it"})]})})]})}const lh=JSON.parse('{"Coordinator":{"mission":"Keep fleet development moving by managing the task backlog, rooms, and executor agents.","persona":"You are the fleet Coordinator. Own progress and workflow, not execution quality or results.\\n\\nImmediately before each meaningful action, proactively use ours `send_message` to contact\\n`Coordinator Owner Channel` with a short, plain one-sentence statement of what you are about to do.\\nThis is an informational intent notice, never a permission request; proceed without waiting unless\\na separate safety or authority rule genuinely requires approval.\\n\\nOut of scope: do not personally implement, inspect, analyze, research, review, test, validate,\\nor otherwise execute task work. Delegate all execution to temporary agents in managed rooms.\\nOnly execute task work yourself when the owner explicitly orders you to override this boundary\\nfor that specific task.\\n\\nFor every new task:\\n1. Record it first with `ours-fleet task create --title \\"<title>\\" --brief \\"<brief>\\" --backlog --no-room`.\\n2. Ask the owner which room template to use: `single`, `pair`, or `team`.\\n3. Start it with `ours-fleet task start <task-id> --template <template>`.\\n\\nKeep the backlog current with `ours-fleet task list --state all` and use `task show`, `task block`,\\n`task unblock`, and `task review` to reflect lifecycle changes. When the owner asks for progress,\\ninspect only management state with `task show`, `room show`, and `room members`; do not assess the\\nwork itself. If a task or room is stuck, run `ours-fleet task recover <task-id>` or\\n`ours-fleet room recover <room-id>` so Fleet repairs or respawns its temporary executors.\\n\\nWhen authenticated room evidence records completion, run\\n`ours-fleet task finish <task-id> --summary \\"<summary>\\"`.\\nThis marks the task done, retires its members, and deletes its room. Report task IDs, states,\\nblockers, recovery actions, and next workflow steps concisely. Never claim that execution is\\ncorrect: result and quality belong to the temporary executor agents.\\n\\nDeveloper, Critic, and LocalCoordinator keep routine task communication in their assigned room.\\nFleet Coordinator lifecycle ownership does not make this identity the routine task-communication\\nsink; direct executor messages are reserved for confirmed infrastructure or orchestration blockers\\nrequiring Fleet-level action.\\n","bio":"Fleet workflow coordinator. Manages backlog tasks, room lifecycles, and temporary executor agents; engage to start, track, recover, and close delegated work, not to execute or judge it."},"Critic":{"mission":"Independently challenge the proposed solution and verify its evidence.","persona":"Audit assumptions, safety boundaries, regressions, tests, and delivery claims. Explain\\nconcrete objections and acceptance criteria; do not edit the implementation or block\\non taste alone. Sign off only when material risks have evidence-backed resolution.\\n\\nCommunicate task state, progress, checkpoints, findings, review verdicts, completion, handoffs,\\nand ordinary errors only in the assigned Cowork room. A LocalCoordinator does not become a\\nseparate reporting channel: read and follow its instructions directly in the room, and keep\\nreplies and evidence in that same room.\\n\\nDistinguish infrastructure or orchestration failure from ordinary task difficulty, review\\ndisagreement, asynchronous delay, or implementation defects. Send a direct message to the\\nconfigured Fleet Coordinator only for a confirmed infrastructure or orchestration blocker that\\nprevents safe progress or room communication and requires Fleet-level action. Normal review\\nfindings, test failures under active diagnosis, ordinary disagreement, or incomplete work are not\\nFleet-level alerts; keep them in the room. Report a qualifying blocker once with authenticated sender, available task/room context,\\nobserved state, bounded safe attempts, and the canonical next action. Never include invites or\\ninvite fingerprints, keys, tokens, unrelated messages, or private workspace content. Retry only\\ntransient blocker-report transport at most once after backoff. Never retry the failed identity,\\nroom, or lifecycle operation after an identity/CID mismatch, consumed/invalid invite, permission\\nfailure, or lost lifecycle state. Avoid busy-polling,\\ncontinue independent safe review, or declare BLOCKED/resting. Report peer nonresponse only 10 minutes\\nafter a direct room attempt unless the room contract defines another window; honor any later\\nabsolute ETA from the peer\'s timestamp or stated start time. Leave recover,\\nblock/unblock, review/finish, deletion, replacement, and respawn decisions to Fleet Coordinator.\\nFleet Coordinator ownership of those lifecycle operations does not make it the routine\\ntask-communication sink.\\n","bio":"Independent reviewer; engage to challenge assumptions and observable evidence and withhold sign-off while material failures remain."},"Developer":{"mission":"Own implementation and task execution for the assigned goal, with maintainable code and tests.","persona":"Make the smallest coherent change that satisfies the task. Preserve unrelated work, validate\\nobservable behavior in proportion to risk, and report deviations. Do not waive failing tests,\\npublish, deploy, or mutate Fleet lifecycle without authority.\\n\\nCommunicate task state, progress, checkpoints, findings, review verdicts, completion, handoffs,\\nand ordinary errors only in the assigned Cowork room. A LocalCoordinator does not become a\\nseparate reporting channel: read and follow its instructions directly in the room, and keep\\nreplies and evidence in that same room.\\n\\nDistinguish infrastructure or orchestration failure from ordinary task difficulty, review\\ndisagreement, asynchronous delay, or implementation defects. Send a direct message to the\\nconfigured Fleet Coordinator only for a confirmed infrastructure or orchestration blocker that\\nprevents safe progress or room communication and requires Fleet-level action. Normal review\\nfindings, test failures under active diagnosis, ordinary disagreement, or incomplete work are not\\nFleet-level alerts; keep them in the room. Report a qualifying blocker once with authenticated sender, available task/room context,\\nobserved state, bounded safe attempts, and the canonical next action. Never include invites or\\ninvite fingerprints, keys, tokens, unrelated messages, or private workspace content. Retry only\\ntransient blocker-report transport at most once after backoff. Never retry the failed identity,\\nroom, or lifecycle operation after an identity/CID mismatch, consumed/invalid invite, permission\\nfailure, or lost lifecycle state. Avoid busy-polling,\\ncontinue independent safe work, or declare BLOCKED/resting. Report peer nonresponse only 10 minutes\\nafter a direct room attempt unless the room contract defines another window; honor any later\\nabsolute ETA from the peer\'s timestamp or stated start time. Leave recover,\\nblock/unblock, review/finish, deletion, replacement, and respawn decisions to Fleet Coordinator.\\nFleet Coordinator ownership of those lifecycle operations does not make it the routine\\ntask-communication sink.\\n","bio":"Implementation and task-execution specialist; engage to deliver a bounded change with observable verification evidence."},"LocalCoordinator":{"mission":"Coordinate sequencing, handoffs, shared context, and blockers inside the assigned task room.","persona":"Coordinate only the existing members of this task and room. Keep decisions, evidence, ownership,\\nand handoffs explicit; use direct room coordination before treating a peer as absent. Unless the\\nroom contract defines another window, wait 10 minutes after a direct room attempt and honor any\\nlater absolute ETA from the peer\'s timestamp or stated start time.\\nNormal asynchronous latency, task difficulty, review disagreement, and implementation defects are\\nnot infrastructure failures.\\n\\nCommunicate task state, progress, checkpoints, findings, review verdicts, completion, handoffs,\\nand ordinary errors only in the assigned Cowork room. You are not a separate reporting channel:\\ngive instructions to Developer and Critic in the room, and keep their replies and evidence in\\nthat same room.\\n\\nDo not implement task work, spawn, provision, replace, or manage agents, create tasks or rooms, or\\ninvoke Fleet task/room lifecycle operations. Never claim Owner or Fleet Coordinator authority.\\nOnly the configured Fleet Coordinator may recover, block, unblock, review, finish, delete, replace,\\nor respawn Fleet resources. Fleet Coordinator ownership of those lifecycle operations does not\\nmake it the routine task-communication sink.\\n\\nFor peer nonresponse, report only after that documented attempt and window; continued nonresponse\\nthen confirms an orchestration blocker. Send a direct message to the configured Fleet Coordinator\\nonly for a confirmed infrastructure or orchestration blocker requiring Fleet-level action. Any\\nother confirmed infrastructure or orchestration blocker requiring Fleet-level action may be\\nreported without waiting for the peer window. Normal review findings, test failures under\\nactive diagnosis, ordinary disagreement, or incomplete work are not Fleet-level alerts; keep them\\nin the room. Report a qualifying blocker once. Include authenticated sender,\\navailable task/room context, observed state, bounded safe attempts, and the canonical next action.\\nNever include invites or invite fingerprints, keys, tokens, unrelated messages, or private workspace\\ncontent. Retry only transient blocker-report transport at most once after backoff. Never retry the\\nfailed identity, room, or lifecycle operation after an identity/CID mismatch, consumed or invalid\\ninvite, permission failure, or lost lifecycle state. Avoid busy-polling\\nand duplicate alerts; continue independent safe coordination when useful. If progress is impossible,\\ndeclare your own work state BLOCKED or resting instead of silently hanging; never invoke a Fleet task block.\\n","bio":"Task-local coordinator; engage for sequencing, handoffs, shared context, and blockers among existing room members, not Fleet lifecycle or implementation work."}}'),ch={"claude-default":{harness:"claude-code",session:"acp",model:null},"claude-fable-5-high":{harness:"claude-code",session:"acp",model:"claude-fable-5",effort:"high"},"claude-fable-5-low":{harness:"claude-code",session:"acp",model:"claude-fable-5",effort:"low"},"claude-fable-5-max":{harness:"claude-code",session:"acp",model:"claude-fable-5",effort:"max"},"claude-fable-5-medium":{harness:"claude-code",session:"acp",model:"claude-fable-5",effort:"medium"},"claude-fable-5-xhigh":{harness:"claude-code",session:"acp",model:"claude-fable-5",effort:"xhigh"},"claude-opus-5-high":{harness:"claude-code",session:"acp",model:"claude-opus-5",effort:"high"},"claude-opus-5-low":{harness:"claude-code",session:"acp",model:"claude-opus-5",effort:"low"},"claude-opus-5-max":{harness:"claude-code",session:"acp",model:"claude-opus-5",effort:"max"},"claude-opus-5-medium":{harness:"claude-code",session:"acp",model:"claude-opus-5",effort:"medium"},"claude-opus-5-xhigh":{harness:"claude-code",session:"acp",model:"claude-opus-5",effort:"xhigh"},"claude-sonnet-5-high":{harness:"claude-code",session:"acp",model:"claude-sonnet-5",effort:"high"},"claude-sonnet-5-low":{harness:"claude-code",session:"acp",model:"claude-sonnet-5",effort:"low"},"claude-sonnet-5-max":{harness:"claude-code",session:"acp",model:"claude-sonnet-5",effort:"max"},"claude-sonnet-5-medium":{harness:"claude-code",session:"acp",model:"claude-sonnet-5",effort:"medium"},"claude-sonnet-5-xhigh":{harness:"claude-code",session:"acp",model:"claude-sonnet-5",effort:"xhigh"},"codex-gpt-5-3-codex-spark-high":{harness:"codex",session:"acp",model:"gpt-5.3-codex-spark",effort:"high"},"codex-gpt-5-3-codex-spark-low":{harness:"codex",session:"acp",model:"gpt-5.3-codex-spark",effort:"low"},"codex-gpt-5-3-codex-spark-medium":{harness:"codex",session:"acp",model:"gpt-5.3-codex-spark",effort:"medium"},"codex-gpt-5-3-codex-spark-xhigh":{harness:"codex",session:"acp",model:"gpt-5.3-codex-spark",effort:"xhigh"},"codex-gpt-5-4-high":{harness:"codex",session:"acp",model:"gpt-5.4",effort:"high"},"codex-gpt-5-4-low":{harness:"codex",session:"acp",model:"gpt-5.4",effort:"low"},"codex-gpt-5-4-medium":{harness:"codex",session:"acp",model:"gpt-5.4",effort:"medium"},"codex-gpt-5-4-mini-high":{harness:"codex",session:"acp",model:"gpt-5.4-mini",effort:"high"},"codex-gpt-5-4-mini-low":{harness:"codex",session:"acp",model:"gpt-5.4-mini",effort:"low"},"codex-gpt-5-4-mini-medium":{harness:"codex",session:"acp",model:"gpt-5.4-mini",effort:"medium"},"codex-gpt-5-4-mini-xhigh":{harness:"codex",session:"acp",model:"gpt-5.4-mini",effort:"xhigh"},"codex-gpt-5-4-xhigh":{harness:"codex",session:"acp",model:"gpt-5.4",effort:"xhigh"},"codex-gpt-5-5-high":{harness:"codex",session:"acp",model:"gpt-5.5",effort:"high"},"codex-gpt-5-5-low":{harness:"codex",session:"acp",model:"gpt-5.5",effort:"low"},"codex-gpt-5-5-medium":{harness:"codex",session:"acp",model:"gpt-5.5",effort:"medium"},"codex-gpt-5-5-xhigh":{harness:"codex",session:"acp",model:"gpt-5.5",effort:"xhigh"},"codex-gpt-5-6-luna-high":{harness:"codex",session:"acp",model:"gpt-5.6-luna",effort:"high"},"codex-gpt-5-6-luna-low":{harness:"codex",session:"acp",model:"gpt-5.6-luna",effort:"low"},"codex-gpt-5-6-luna-max":{harness:"codex",session:"acp",model:"gpt-5.6-luna",effort:"max"},"codex-gpt-5-6-luna-medium":{harness:"codex",session:"acp",model:"gpt-5.6-luna",effort:"medium"},"codex-gpt-5-6-luna-xhigh":{harness:"codex",session:"acp",model:"gpt-5.6-luna",effort:"xhigh"},"codex-gpt-5-6-sol-high":{harness:"codex",session:"acp",model:"gpt-5.6-sol",effort:"high"},"codex-gpt-5-6-sol-low":{harness:"codex",session:"acp",model:"gpt-5.6-sol",effort:"low"},"codex-gpt-5-6-sol-max":{harness:"codex",session:"acp",model:"gpt-5.6-sol",effort:"max"},"codex-gpt-5-6-sol-medium":{harness:"codex",session:"acp",model:"gpt-5.6-sol",effort:"medium"},"codex-gpt-5-6-sol-ultra":{harness:"codex",session:"acp",model:"gpt-5.6-sol",effort:"ultra"},"codex-gpt-5-6-sol-xhigh":{harness:"codex",session:"acp",model:"gpt-5.6-sol",effort:"xhigh"},"codex-gpt-5-6-terra-high":{harness:"codex",session:"acp",model:"gpt-5.6-terra",effort:"high"},"codex-gpt-5-6-terra-low":{harness:"codex",session:"acp",model:"gpt-5.6-terra",effort:"low"},"codex-gpt-5-6-terra-max":{harness:"codex",session:"acp",model:"gpt-5.6-terra",effort:"max"},"codex-gpt-5-6-terra-medium":{harness:"codex",session:"acp",model:"gpt-5.6-terra",effort:"medium"},"codex-gpt-5-6-terra-ultra":{harness:"codex",session:"acp",model:"gpt-5.6-terra",effort:"ultra"},"codex-gpt-5-6-terra-xhigh":{harness:"codex",session:"acp",model:"gpt-5.6-terra",effort:"xhigh"},"codex-default":{harness:"codex",session:"acp",model:null}},uh={Critic:{role:{ref:"Critic"},brain:{ref:"claude-default"},coordinator:"FleetCoordinator",permissions:{approval:"ask",filesystem:"workspace",unattended:"deny"}},Developer:{role:{ref:"Developer"},brain:{ref:"claude-default"},coordinator:"FleetCoordinator",permissions:{approval:"ask",filesystem:"workspace",unattended:"deny"}},LocalCoordinator:{role:{ref:"LocalCoordinator"},brain:{ref:"claude-default"},coordinator:"FleetCoordinator",permissions:{approval:"ask",filesystem:"workspace",unattended:"deny"},loops:{continuity:{interval:"15m",prompt:`Perform one bounded, observation-only continuity pass for the assigned task room. Do not modify
|
|
143
|
+
task or project state; the only permitted writes are the room action and secret-free WORKLOG
|
|
144
|
+
checkpoint defined below. Anchor the preceding interval to scheduled_at minus 15 minutes
|
|
145
|
+
through scheduled_at. A late start or missed-loop metadata describes this loop's outage, not
|
|
146
|
+
evidence that development froze.
|
|
147
|
+
|
|
148
|
+
Re-read ROUTINES.md when present and the continuity checkpoint in WORKLOG.md. Use bounded
|
|
149
|
+
\`list_history\` reads filtered to the assigned room CID and direction as needed. Do not drain
|
|
150
|
+
unread mail or mark unrelated mail read. Ignore unrelated contacts and private messages.
|
|
151
|
+
Use only attributable room/task evidence. Exclude loop-authored \`CONTINUITY *\` messages from
|
|
152
|
+
development evidence and fingerprint inputs; retain their request/report IDs separately for
|
|
153
|
+
dedupe. Lifecycle state \`active\`, elapsed time, silence, task difficulty, and filesystem
|
|
154
|
+
dirtiness alone do not prove development is active, meaningful progress, or a stall. Meaningful
|
|
155
|
+
progress is a concrete reported change, test result, decision, handoff, blocker delta, active
|
|
156
|
+
step, or unexpired ETA.
|
|
157
|
+
|
|
158
|
+
After a mandatory final history recheck, choose exactly one mutually exclusive branch:
|
|
159
|
+
- Terminal: if attributable evidence says the task is terminal, do nothing.
|
|
160
|
+
- Recent update: if the room already has a meaningful update in the interval, do nothing.
|
|
161
|
+
- Ongoing: if attributable development evidence is ongoing but the room has no meaningful
|
|
162
|
+
update in the interval, send at most one concise
|
|
163
|
+
\`CONTINUITY ACTIVE [start..end]: <observed facts>; next=<known step or ETA>\` update.
|
|
164
|
+
- Unobservable/no evidence: never invent activity. If no qualifying outstanding continuity
|
|
165
|
+
request exists, send one direct \`CONTINUITY CHECK\` request for status, next step, and ETA.
|
|
166
|
+
If the prior request is less than 10 minutes old or its ETA is unexpired, do nothing. If it
|
|
167
|
+
is at least 10 minutes old, no later meaningful evidence exists, and the ETA is absent or
|
|
168
|
+
elapsed, send at most one clear \`CONTINUITY STALLED\` report.
|
|
169
|
+
- Explicit stop: if attributable evidence says work stopped or is blocked with no active next
|
|
170
|
+
step, send at most one clear \`CONTINUITY STALLED\` report.
|
|
171
|
+
|
|
172
|
+
Before any send, suppress a semantic duplicate found by the final history recheck or checkpoint;
|
|
173
|
+
room history wins if they disagree. Build the stable fingerprint from classification and
|
|
174
|
+
non-loop evidence IDs/timestamps plus requested/reported state, excluding loop-authored
|
|
175
|
+
continuity messages, prose, and time-of-check so unchanged classification and evidence state
|
|
176
|
+
stay silent. Store continuity request/report IDs separately. Later meaningful progress resets
|
|
177
|
+
a prior request or stall. Append a secret-free WORKLOG checkpoint with interval, classification,
|
|
178
|
+
evidence IDs/times, fingerprint, and any separate request/report ID.
|
|
179
|
+
|
|
180
|
+
Do not edit project files, run implementation or tests, interrupt peers, spawn or manage agents,
|
|
181
|
+
invoke task/room lifecycle actions, infer from unrelated messages, or exceed LocalCoordinator
|
|
182
|
+
authority. Complete silently when no room action is required.
|
|
183
|
+
`}}}},dh={pair:{version:1,description:"Implementation pair: Developer executes and Critic independently reviews",room:{quiet_membership:!1,anonymous:!1},contract:`Developer owns implementation and verification evidence.
|
|
184
|
+
Critic independently challenges assumptions and withholds sign-off on material failures.
|
|
185
|
+
Completion requires Developer evidence and Critic sign-off.
|
|
186
|
+
All routine state, progress, findings, verdicts, handoffs, completion, and ordinary errors stay in
|
|
187
|
+
this room. Direct Fleet Coordinator contact is reserved for a confirmed infrastructure or
|
|
188
|
+
orchestration blocker that prevents safe progress or room communication.
|
|
189
|
+
`,members:[{slot:"developer",role:"Developer",count:1,agent_template:"Developer"},{slot:"critic",role:"Critic",count:1,agent_template:"Critic"}]},single:{version:1,description:"Solo task: one Developer owns implementation and verification",room:{quiet_membership:!1,anonymous:!1},contract:`Developer owns task execution. All routine state, progress, evidence, completion, and ordinary
|
|
190
|
+
errors stay in this room. Direct Fleet Coordinator contact is reserved for a confirmed
|
|
191
|
+
infrastructure or orchestration blocker that prevents safe progress or room communication.
|
|
192
|
+
`,members:[{slot:"developer",role:"Developer",count:1,agent_template:"Developer"}]},team:{version:1,description:"Locally coordinated team: LocalCoordinator sequences, Developer executes, Critic reviews",room:{quiet_membership:!1,anonymous:!1},contract:`LocalCoordinator coordinates sequencing, handoffs, context, and blockers among existing members.
|
|
193
|
+
LocalCoordinator performs a bounded 15-minute continuity check without taking over implementation.
|
|
194
|
+
Developer owns implementation and verification evidence.
|
|
195
|
+
Critic independently reviews and withholds sign-off on material failures.
|
|
196
|
+
LocalCoordinator has no Fleet lifecycle or agent-management authority.
|
|
197
|
+
LocalCoordinator instructions, Developer and Critic replies, routine state, evidence, verdicts,
|
|
198
|
+
handoffs, completion, and ordinary errors all stay in this room; LocalCoordinator is not a separate
|
|
199
|
+
reporting channel. Direct Fleet Coordinator contact is reserved for a confirmed infrastructure or
|
|
200
|
+
orchestration blocker requiring Fleet-level action.
|
|
201
|
+
`,members:[{slot:"local_coordinator",role:"LocalCoordinator",count:1,agent_template:"LocalCoordinator"},{slot:"developer",role:"Developer",count:1,agent_template:"Developer"},{slot:"critic",role:"Critic",count:1,agent_template:"Critic"}]}},ph={role:lh,brain:ch,template:uh,tasks:dh},fh=[{harness:"codex",session:"acp",model:"gpt-5.6-sol",efforts:["low","medium","high","xhigh","max","ultra"]},{harness:"codex",session:"acp",model:"gpt-5.6-terra",efforts:["low","medium","high","xhigh","max","ultra"]},{harness:"codex",session:"acp",model:"gpt-5.6-luna",efforts:["low","medium","high","xhigh","max"]},{harness:"codex",session:"acp",model:"gpt-5.5",efforts:["low","medium","high","xhigh"]},{harness:"codex",session:"acp",model:"gpt-5.4",efforts:["low","medium","high","xhigh"]},{harness:"codex",session:"acp",model:"gpt-5.4-mini",efforts:["low","medium","high","xhigh"]},{harness:"codex",session:"acp",model:"gpt-5.3-codex-spark",efforts:["low","medium","high","xhigh"]},{harness:"claude-code",session:"acp",model:"claude-fable-5",efforts:["low","medium","high","xhigh","max"]},{harness:"claude-code",session:"acp",model:"claude-opus-5",efforts:["low","medium","high","xhigh","max"]},{harness:"claude-code",session:"acp",model:"claude-sonnet-5",efforts:["low","medium","high","xhigh","max"]}],or={models:fh};function Ec(e,t){return or.models.find(n=>n.harness===e&&n.model===t)?.efforts??[...new Set(or.models.filter(n=>n.harness===e).flatMap(n=>n.efforts))]}const hh=()=>structuredClone(ph);function mh(e,t,n){if(e==="role"&&t.mission!==void 0&&!t.mission.trim())return"Mission must not be blank.";if(e==="brain"){if(!["codex","claude-code"].includes(t.harness??""))return"Choose a supported harness.";if(t.session&&!(t.harness==="codex"?["acp","codex-app-server"]:["acp"]).includes(t.session))return"Choose a session supported by this harness.";if(t.model!==null&&t.model!==void 0&&!t.model.trim())return"Enter a custom model ID.";if(t.effort&&!Ec(t.harness,t.model).includes(t.effort))return"Choose an effort supported by this model.";if(t.max_tokens!==void 0&&(!Number.isInteger(t.max_tokens)||t.max_tokens<=0))return"Max tokens must be a positive integer.";if(t.autocompact_pct!==void 0&&(t.autocompact_pct<1||t.autocompact_pct>100))return"Autocompact must be between 1 and 100."}if(e==="template"){if(t.permissions?.approval!==void 0&&!["ask","auto","allow","deny"].includes(t.permissions.approval))return"Choose a valid approval policy.";if(t.permissions?.filesystem!==void 0&&!["read-only","workspace","unrestricted"].includes(t.permissions.filesystem))return"Choose a valid filesystem policy.";if(t.permissions?.unattended!==void 0&&!["deny","wait"].includes(t.permissions.unattended))return"Choose a valid unattended policy.";if(!t.role?.ref||!Object.hasOwn(n.role,t.role.ref))return"Choose an existing role.";if(!t.brain?.ref||!Object.hasOwn(n.brain,t.brain.ref))return"Choose an existing brain."}if(e==="tasks"){if(!Number.isInteger(t.version)||t.version<1)return"Version must be a positive integer.";if(!t.members?.length)return"Add at least one member.";if(t.members.some(s=>!Object.hasOwn(n.template,s.agent_template)))return"Choose an existing agent template for each member.";if(t.members.some(s=>!s.slot.trim()||!s.role.trim()||!Number.isInteger(s.count)||s.count<1))return"Each member needs a slot, room role and positive count.";if(new Set(t.members.map(s=>s.slot)).size!==t.members.length)return"Member slots must be unique."}return""}const Rc={predefined:"Predefined",changed:"Changed from preset",custom:"Custom"},zc=e=>e&&{label:Rc[e.status],tone:e.status};function Tc(e=!0,t=void 0){const[n,s]=g.useState();return g.useEffect(()=>{if(!e)return;let r=!0;return ee("/configuration/provenance").then(o=>{r&&s(o.provenance)}).catch(()=>{}),()=>{r=!1}},[e,t]),n}function Oc({entry:e,noun:t}){return e?e.status==="custom"?a.jsxs("p",{className:"fleet-provenance muted",children:[a.jsx("span",{className:"menu-action-badge is-custom",children:"Custom"})," Created on this host; Fleet ships no ",t," with this name."]}):a.jsxs("details",{className:"fleet-provenance",children:[a.jsxs("summary",{children:[a.jsx("span",{className:`menu-action-badge is-${e.status}`,children:Rc[e.status]}),e.status==="predefined"?` Fleet ships this ${t}; it has not been changed.`:` Fleet ships ${/^[aeiou]/.test(t)?"an":"a"} ${t} with this name; this one differs.`," Show the shipped default"]}),a.jsx("pre",{children:e.preset})]}):null}const Ac=()=>({role:{},brain:{},template:{},tasks:{}}),ri=g.createContext({data:Ac(),live:!1,defaults:{},loaded:!0,error:"",refresh:async()=>{},save:async(e,t,n)=>{}}),Yn=()=>g.useContext(ri);function gh({children:e,live:t=!1}){const[n,s]=g.useState(t?Ac:hh),[r,o]=g.useState(null),[i,l]=g.useState(""),c=g.useRef(0),u=g.useCallback(f=>{o(f),s({role:f.model.roles,brain:f.model.brains,template:f.model.agent_templates,tasks:f.model.room_templates})},[]),d=g.useCallback(async()=>{if(!t)return;const f=++c.current;try{const h=await ee("/configuration?includeDefinitions=true");f===c.current&&(u(h),l(""))}catch(h){throw f===c.current&&l(h.message),h}},[t,u]);g.useEffect(()=>{if(!t)return;let f=!1;const h=()=>{f||document.visibilityState==="hidden"||(f=!0,d().catch(()=>{}).finally(()=>{f=!1}))};h();const m=window.setInterval(h,5e3);return window.addEventListener("focus",h),document.addEventListener("visibilitychange",h),()=>{++c.current,window.clearInterval(m),window.removeEventListener("focus",h),document.removeEventListener("visibilitychange",h)}},[t,d]);const p=async(f,h,m)=>{if(!t){s(k=>({...k,[f]:{...k[f],[h]:structuredClone(m)}}));return}if(!r)throw new Error(i||"Configuration is still loading.");const v={role:"roles",brain:"brains",template:"agent_templates",tasks:"room_templates"}[f],b={...r.model,[v]:{...r.model[v],[h]:m}};await ee("/configuration/save",{revision:r.revision,model:b}),await d()};return a.jsx(ri.Provider,{value:{data:n,live:t,defaults:r?.model?.manifest?.defaults??{},loaded:!t||!!r,error:i,refresh:d,save:p},children:e})}const Zr={role:"Roles",brain:"Brains",template:"Agent Templates",tasks:"Room Templates"},Ks={role:"role",brain:"brain",template:"agent template",tasks:"room template"};function yh({editor:e,go:t}){const{data:n,save:s,live:r,loaded:o,error:i,defaults:l}=g.useContext(ri),[c,u]=e.split("/"),d=c,[p,f]=g.useState(""),h=Tc(r,n),m=b=>d==="tasks"?void 0:h?.[d]?.[b],v=()=>t({kind:"settings",editor:d});return o?Zr[d]?u?a.jsx(vh,{kind:d,id:u,existing:n[d][u],origin:u==="new"?void 0:m(decodeURIComponent(u)),data:n,fleetDefaults:l,open:(b,k)=>t({kind:"settings",editor:b+"/"+encodeURIComponent(k)}),cancel:v,save:async(b,k)=>{await s(d,b,k),v()}},e):a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:Zr[d],subtitle:r?"Reusable definitions on this host":"Reusable definitions · Changes stay in this preview",onBack:()=>t({kind:"settings"}),actions:a.jsxs(J,{primary:!0,onClick:()=>t({kind:"settings",editor:d+"/new"}),children:["New ",Ks[d]]})}),i&&a.jsx("p",{role:"alert",children:i}),a.jsx(xr,{value:p,onChange:f,placeholder:`Search ${Zr[d].toLowerCase()}`}),a.jsx("div",{className:"fleet-config-list",children:Object.entries(n[d]).filter(([b])=>b.toLowerCase().includes(p.toLowerCase())).map(([b,k])=>a.jsx(Te,{icon:{role:lf,brain:fc,template:pf,tasks:Sr}[d],title:b,badge:zc(m(b)),description:d==="brain"?`${k.harness} · ${k.model??"Harness default"}${k.effort?" · "+k.effort:""}`:d==="template"?`${k.role?.ref} · ${k.brain?.ref}`:d==="tasks"?`${k.members?.length??0} member slots · v${k.version}`:k.bio||k.mission?.split(`
|
|
202
|
+
`)[0],onClick:()=>t({kind:"settings",editor:d+"/"+encodeURIComponent(b)})},b))})]}):null:a.jsx("main",{className:"fleet-form-page",children:a.jsx("p",{role:i?"alert":"status",children:i||"Loading configuration…"})})}function vh({kind:e,id:t,existing:n,origin:s,data:r,fleetDefaults:o,open:i,cancel:l,save:c}){const u={role:{mission:"",persona:"",bio:""},brain:{harness:"codex",session:"acp",model:null},template:{role:{ref:""},brain:{ref:""},permissions:{approval:"ask",filesystem:"workspace",unattended:"deny"}},tasks:{version:1,description:"",contract:"",members:[],room:{quiet_membership:!1,anonymous:!1}}},[d,p]=g.useState(t==="new"?"":decodeURIComponent(t)),[f,h]=g.useState(()=>structuredClone(n??u[e])),[m,v]=g.useState(""),[b,k]=g.useState(!1),[z,R]=g.useState(!!f.model&&!or.models.some(I=>I.harness===f.harness&&I.model===f.model)),A=I=>h(F=>({...F,...I})),D=(I,F,L=!1)=>a.jsx(xe,{label:I,children:L?a.jsx("textarea",{value:f[F]??"",onChange:j=>A({[F]:j.target.value}),rows:5}):a.jsx("input",{value:f[F]??"",onChange:j=>A({[F]:j.target.value})})}),O=(I,F,L,j,x="Select…")=>a.jsx(xe,{label:I,children:a.jsxs("select",{value:F,onChange:C=>L(C.target.value),children:[a.jsx("option",{value:"",children:x}),j.map(C=>a.jsx("option",{value:C,children:C},C))]})});return t!=="new"&&!n?a.jsx("main",{className:"fleet-form-page",children:a.jsx(We,{title:"Definition not found",onBack:l})}):a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:`${t==="new"?"New":"Edit"} ${Ks[e]}`,subtitle:"Changes apply to definitions; current sessions keep their snapshots.",onBack:l}),a.jsx(Oc,{entry:s,noun:Ks[e]}),a.jsxs("form",{className:"fleet-config-form",onSubmit:async I=>{I.preventDefault();const F=d.trim();if(!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(F)||F==="new"){v("Use a unique name with letters, numbers, hyphens or underscores.");return}if(t==="new"&&Object.hasOwn(r[e],F)){v("This name already exists.");return}const L=mh(e,f,r);if(L){v(L);return}k(!0);try{await c(F,f)}catch(j){v(j.message)}finally{k(!1)}},children:[a.jsx(xe,{label:"Definition name",children:a.jsx("input",{required:!0,value:d,readOnly:t!=="new",onChange:I=>p(I.target.value)})}),e==="role"&&a.jsxs(a.Fragment,{children:[D("Mission","mission",!0),D("Instructions / persona","persona",!0),D("Bio","bio",!0),D("Briefing file","briefing_file")]}),e==="brain"&&a.jsxs(a.Fragment,{children:[O("Harness",f.harness??"",I=>{A({harness:I,session:"acp",model:null,effort:void 0}),R(!1)},["codex","claude-code"]),a.jsx(xe,{label:"Session",children:a.jsxs("select",{value:f.session??"acp",onChange:I=>A({session:I.target.value}),children:[a.jsx("option",{value:"acp",children:"acp"}),f.harness==="codex"&&a.jsx("option",{value:"codex-app-server",children:"codex-app-server"})]})}),a.jsx(xe,{label:"Model",children:a.jsxs("select",{value:z?"__custom":f.model??"",onChange:I=>{const F=I.target.value;R(F==="__custom"),A({model:F==="__custom"?"":F||null,effort:void 0})},children:[a.jsx("option",{value:"",children:"Harness default"}),or.models.filter(I=>I.harness===f.harness).map(I=>a.jsx("option",{children:I.model},I.model)),a.jsx("option",{value:"__custom",children:"Custom model…"})]})}),z&&a.jsx(xe,{label:"Custom model ID",children:a.jsx("input",{required:!0,value:f.model??"",onChange:I=>A({model:I.target.value})})}),O("Reasoning effort",f.effort??"",I=>A({effort:I||void 0}),Ec(f.harness,f.model),"Harness default"),a.jsxs("details",{children:[a.jsx("summary",{children:"Runtime options"}),a.jsx(xe,{label:"Max tokens",children:a.jsx("input",{type:"number",min:"1",value:f.max_tokens??"",onChange:I=>A({max_tokens:I.target.value?Number(I.target.value):void 0})})}),a.jsx(xe,{label:"Autocompact percent",children:a.jsx("input",{type:"number",min:"1",max:"100",value:f.autocompact_pct??"",onChange:I=>A({autocompact_pct:I.target.value?Number(I.target.value):void 0})})}),a.jsx(sa,{label:"Harness options",value:f.harness_options,onChange:I=>A({harness_options:I})}),a.jsx(sa,{label:"Session options",value:f.session_options,onChange:I=>A({session_options:I})})]})]}),e==="template"&&a.jsxs(a.Fragment,{children:[a.jsx(xh,{template:f,data:r,defaults:o,open:i}),O("Role",f.role?.ref??"",I=>A({role:{ref:I}}),Object.keys(r.role)),O("Brain",f.brain?.ref??"",I=>A({brain:{ref:I}}),Object.keys(r.brain)),a.jsx("p",{className:"muted",children:"Create custom roles and brains in their own lists first, then select them here."}),D("Working folder","cwd"),D("Coordinator","coordinator"),O("Approval",f.permissions?.approval??"",I=>A({permissions:{...f.permissions,approval:I||void 0}}),["ask","auto","allow","deny"],"Default"),O("Unattended",f.permissions?.unattended??"",I=>A({permissions:{...f.permissions,unattended:I||void 0}}),["deny","wait"],"Default"),O("Filesystem",f.permissions?.filesystem??"",I=>A({permissions:{...f.permissions,filesystem:I||void 0}}),["read-only","workspace","unrestricted"],"Default")]}),e==="tasks"&&a.jsxs(a.Fragment,{children:[D("Description","description",!0),a.jsx(xe,{label:"Version",children:a.jsx("input",{required:!0,type:"number",min:"1",value:f.version??1,onChange:I=>A({version:Number(I.target.value)})})}),D("Collaboration contract","contract",!0),(f.members??[]).map((I,F)=>a.jsxs("fieldset",{className:"fleet-config-member",children:[a.jsxs("legend",{children:["Member ",F+1]}),a.jsx(xe,{label:`Slot ${F+1}`,children:a.jsx("input",{required:!0,value:I.slot,onChange:L=>A({members:f.members.map((j,x)=>x===F?{...j,slot:L.target.value}:j)})})}),a.jsx(xe,{label:`Room role ${F+1}`,children:a.jsx("input",{required:!0,value:I.role,onChange:L=>A({members:f.members.map((j,x)=>x===F?{...j,role:L.target.value}:j)})})}),O(`Agent template ${F+1}`,I.agent_template,L=>A({members:f.members.map((j,x)=>x===F?{...j,agent_template:L}:j)}),Object.keys(r.template)),a.jsx(xe,{label:`Count ${F+1}`,children:a.jsx("input",{required:!0,type:"number",min:"1",value:I.count,onChange:L=>A({members:f.members.map((j,x)=>x===F?{...j,count:Number(L.target.value)}:j)})})}),a.jsxs(J,{onClick:()=>A({members:f.members.filter((L,j)=>j!==F)}),children:["Remove member ",F+1]})]},F)),a.jsx(J,{onClick:()=>A({members:[...f.members??[],{slot:"",role:"",count:1,agent_template:""}]}),children:"Add member"}),a.jsxs("label",{className:"fleet-check",children:[a.jsx("input",{type:"checkbox",checked:!!f.room?.anonymous,onChange:I=>A({room:{...f.room,anonymous:I.target.checked}})}),"Anonymous room"]}),a.jsxs("label",{className:"fleet-check",children:[a.jsx("input",{type:"checkbox",checked:!!f.room?.quiet_membership,onChange:I=>A({room:{...f.room,quiet_membership:I.target.checked}})}),"Quiet membership"]})]}),m&&a.jsx("p",{role:"alert",children:m}),a.jsxs("div",{className:"fleet-actions",children:[a.jsx(J,{onClick:l,children:"Cancel"}),a.jsxs(J,{primary:!0,type:"submit",disabled:b,children:["Save ",Ks[e]]})]})]})]})}const na={approval:"ask",filesystem:"workspace",unattended:"deny"};function bh(e,t){return Object.keys(na).map(n=>{const s=e.permissions?.[n],r=t?.permissions?.[n];return{key:n,value:s??r??na[n],source:s!==void 0?"this template":r!==void 0?"Fleet default":"built-in default"}})}function xh({template:e,data:t,defaults:n,open:s}){const r=e.role?.ref?t.role[e.role.ref]:void 0,o=e.brain?.ref?t.brain[e.brain.ref]:void 0;return a.jsxs("dl",{className:"fleet-effective","aria-label":"What this template runs",children:[a.jsxs("h3",{children:["What this template runs ",a.jsx("span",{className:"muted",children:"· summary; open the role or brain for every field"})]}),a.jsx("dt",{children:"Role"}),a.jsx("dd",{children:e.role?.ref?r?a.jsxs(a.Fragment,{children:[e.role.ref," · ",r.mission?.split(`
|
|
203
|
+
`)[0]||"No mission"," ",a.jsx("button",{type:"button",className:"fleet-link",onClick:()=>s("role",e.role.ref),children:"Open role"})]}):`${e.role.ref} (not found)`:"None"}),a.jsx("dt",{children:"Brain"}),a.jsx("dd",{children:e.brain?.ref?o?a.jsxs(a.Fragment,{children:[e.brain.ref," · ",$c(o)," ",a.jsx("button",{type:"button",className:"fleet-link",onClick:()=>s("brain",e.brain.ref),children:"Open brain"})]}):`${e.brain.ref} (not found)`:"None"}),a.jsx("dt",{children:"Permissions"}),a.jsx("dd",{children:bh(e,n).map(i=>a.jsxs("span",{className:"fleet-effective-permission",children:[i.key," ",a.jsx("strong",{children:i.value})," ",a.jsxs("small",{className:"muted",children:["(",i.source,")"]})]},i.key))})]})}const $c=e=>`${e.harness??"harness?"} · ${e.model??"harness default model"}${e.effort?" · "+e.effort+" effort":""}`;function sa({label:e,value:t,onChange:n}){const[s,r]=g.useState(JSON.stringify(t??{},null,2));return a.jsx(xe,{label:e,children:a.jsx("textarea",{rows:4,value:s,onChange:o=>{r(o.target.value);try{const i=JSON.parse(o.target.value);if(!i||Array.isArray(i)||typeof i!="object")throw new Error;n(i),o.target.setCustomValidity("")}catch{o.target.setCustomValidity("Enter a JSON object.")}}})})}const At="/home/you/work",kh=[At,`${At}/website`,`${At}/website/assets`,`${At}/website/src`,`${At}/research`,`${At}/shared`];function wh({value:e,onSelect:t,onCancel:n}){const[s,r]=g.useState(()=>{const v=[];for(let b=e;b.startsWith(At);b=b.slice(0,b.lastIndexOf("/")))v.push(b);return[...new Set([...kh,...v])]}),[o,i]=g.useState(e),[l,c]=g.useState(new Set([At,`${At}/website`])),[u,d]=g.useState(!1),[p,f]=g.useState(""),h=o.startsWith(`${At}/research`),m=v=>{const b=s.filter(R=>R.slice(0,R.lastIndexOf("/"))===v),k=l.has(v),z=k?uf:mc;return a.jsxs("li",{children:[a.jsxs("div",{className:"fleet-folder-row"+(o===v?" selected":""),children:[b.length?a.jsx("button",{className:"icon-btn","aria-label":`${k?"Collapse":"Expand"} ${v.split("/").pop()}`,"aria-expanded":k,onClick:()=>c(R=>{const A=new Set(R);return A.has(v)?A.delete(v):A.add(v),A}),children:k?a.jsx(ic,{size:14}):a.jsx(Yo,{size:14})}):a.jsx("span",{className:"fleet-folder-spacer"}),a.jsxs("button",{"aria-pressed":o===v,onClick:()=>i(v),children:[a.jsx(z,{size:18}),a.jsx("span",{children:v.split("/").pop()}),v.endsWith("/research")&&a.jsx("small",{children:"Read only"}),o===v&&a.jsx(Lp,{size:16})]})]}),k&&b.length>0&&a.jsx("ul",{children:b.map(m)})]},v)};return a.jsxs("div",{className:"fleet-folder-picker",children:[a.jsx("p",{className:"muted",children:"Workstation · Online"}),a.jsx("ul",{className:"fleet-folder-tree","aria-label":"Host folders",children:m(At)}),u?a.jsxs("form",{onSubmit:v=>{v.preventDefault();const b=`${o}/${p.trim()}`;!p.trim()||/[/.\\]/.test(p)||s.includes(b)||h||(r(k=>[...k,b]),c(k=>new Set([...k,o])),i(b),d(!1),f(""))},children:[a.jsx(xe,{label:"Folder name",children:a.jsx("input",{autoFocus:!0,value:p,onChange:v=>f(v.target.value)})}),a.jsxs("div",{className:"fleet-actions",children:[a.jsx(J,{onClick:()=>d(!1),children:"Cancel new folder"}),a.jsx(J,{primary:!0,type:"submit",disabled:!p.trim()||/[/.\\]/.test(p)||s.includes(`${o}/${p.trim()}`),children:"Create folder"})]})]}):a.jsxs(J,{disabled:h,onClick:()=>d(!0),children:[a.jsx(df,{size:18})," New folder in ",o.split("/").pop()]}),a.jsxs("div",{className:"fleet-folder-selection",children:[a.jsx("small",{children:"Selected folder"}),a.jsx("code",{children:o}),h&&a.jsx("small",{children:"Read only"})]}),a.jsxs("div",{className:"fleet-dialog-actions",children:[a.jsx(J,{onClick:n,children:"Cancel"}),a.jsx(J,{primary:!0,onClick:()=>t(o),children:"Select folder"})]})]})}function jh({draft:e,onChange:t,locked:n=!1}){const s=Yn(),[r,o]=g.useState(!1),[i,l]=g.useState(!1),c=(d,p)=>{n||t?.({...e,[d]:p})},u=a.jsxs("div",{className:"fleet-setup-fields",children:[a.jsxs("label",{children:[a.jsx(kr,{size:19}),a.jsxs("span",{children:["Name",a.jsx("input",{"aria-label":"Agent name",value:e.name,onChange:d=>c("name",d.target.value)})]})]}),a.jsxs("label",{children:[a.jsx(ac,{size:19}),a.jsxs("span",{children:["Role",a.jsx("select",{"aria-label":"Role",value:e.role,onChange:d=>c("role",d.target.value),children:Object.keys(s.data.role).map(d=>a.jsx("option",{children:d},d))})]})]}),a.jsxs("label",{children:[a.jsx(fc,{size:19}),a.jsxs("span",{children:["Brain",a.jsx("select",{"aria-label":"Brain",value:e.brain,onChange:d=>c("brain",d.target.value),children:Object.entries(s.data.brain).map(([d,p])=>a.jsxs("option",{value:d,children:[d," · ",p.harness," · ",p.model??"Default model"," · ",p.effort??"Default effort"]},d))})]})]}),a.jsxs("label",{children:[a.jsx(xo,{size:19}),a.jsxs("span",{children:["Permissions",a.jsxs("select",{"aria-label":"Permissions",value:e.permissions,onChange:d=>c("permissions",d.target.value),children:[a.jsx("option",{children:"Ask before changes"}),a.jsx("option",{children:"Read only"}),a.jsx("option",{children:"Workspace edits"}),a.jsx("option",{children:"Allow · Full access"})]})]})]})]});return n?a.jsxs("details",{className:"fleet-locked-setup",children:[a.jsxs("summary",{children:[a.jsx(xo,{size:14})," Session settings · Locked"]}),a.jsx("dl",{children:[["Name",e.name],["Role",e.role],["Brain",`${e.brain} · ${s.data.brain[e.brain]?.harness??""} · ${s.data.brain[e.brain]?.model??"Default model"} · ${s.data.brain[e.brain]?.effort??"Default effort"}`],["Folder",e.folder],["Permissions",e.permissions]].map(([d,p])=>a.jsxs("div",{children:[a.jsx("dt",{children:d}),a.jsx("dd",{children:p})]},d))})]}):a.jsxs("section",{className:"fleet-chat-setup","aria-label":"New chat settings",children:[a.jsx("h2",{children:"New chat"}),a.jsx("p",{children:"Send a message to start your agent."}),s.error&&a.jsxs("p",{role:"alert",children:["Could not refresh configuration: ",s.error]}),!r&&u,a.jsxs(J,{onClick:()=>o(!0),children:[a.jsx(Hs,{size:16})," More options"]}),a.jsx("small",{children:"Settings lock after your first message."}),r&&a.jsx(Es,{title:i?"Choose folder":"Make it yours",className:"fleet-modal",onClose:()=>i?l(!1):o(!1),children:i&&s.live?a.jsxs("div",{className:"fleet-dialog-content",children:[a.jsx(xe,{label:"Working folder",children:a.jsx("input",{value:e.folder,placeholder:"Fleet default",onChange:d=>c("folder",d.target.value)})}),a.jsx("p",{children:"Use an existing folder on this host, or leave blank for the Fleet default."}),a.jsx(J,{onClick:()=>l(!1),children:"Done"})]}):i?a.jsx(wh,{value:e.folder,onCancel:()=>l(!1),onSelect:d=>{c("folder",d),l(!1)}}):a.jsxs("div",{className:"fleet-dialog-content",children:[u,a.jsxs(J,{onClick:()=>l(!0),children:["Folder · ",e.folder.split("/").pop()||"Fleet default"]}),a.jsx(J,{primary:!0,onClick:()=>o(!1),children:"Done"})]})})]})}function oi(){const e=g.useRef(null);return g.useLayoutEffect(()=>{const t=e.current;if(!t)return;const n=t.querySelector(".fleet-acp-header"),s=t.querySelector(".fleet-acp-composer"),r=t.querySelector(".fleet-acp-scroll"),o=window.visualViewport,i=()=>{for(const h of["position","top","left","width","height","maxHeight","zIndex"])t.style[h]=""},l=()=>{if(!t.getClientRects().length)return;const h=r&&r.scrollHeight-r.clientHeight-r.scrollTop<32;if(!!o&&(o.height<innerHeight-1||o.offsetTop>1)){if(t.style.position!=="fixed"){const v=t.getBoundingClientRect();t.style.left=`${v.left}px`,t.style.width=`${v.width}px`}t.style.position="fixed",t.style.zIndex="20",t.style.top=`${o.offsetTop}px`,t.style.height=`${o.height}px`}else t.style.position&&i();t.style.setProperty("--fleet-acp-top",`${n?n.offsetTop+n.offsetHeight+8:68}px`),t.style.setProperty("--fleet-acp-bottom",`${s?t.clientHeight-s.offsetTop+8:80}px`),h&&r&&(r.scrollTop=r.scrollHeight)};let c=0;const u=[],d=()=>{cancelAnimationFrame(c),c=requestAnimationFrame(l)},p=()=>{for(d();u.length;)clearTimeout(u.pop());for(const h of[120,320,650])u.push(window.setTimeout(d,h))},f=new ResizeObserver(d);return f.observe(t),n&&f.observe(n),s&&f.observe(s),o?.addEventListener("resize",p),o?.addEventListener("scroll",p),window.addEventListener("resize",p),window.addEventListener("scroll",p,{passive:!0}),t.addEventListener("focusin",p),t.addEventListener("focusout",p),l(),()=>{for(cancelAnimationFrame(c);u.length;)clearTimeout(u.pop());f.disconnect(),o?.removeEventListener("resize",p),o?.removeEventListener("scroll",p),window.removeEventListener("resize",p),window.removeEventListener("scroll",p),t.removeEventListener("focusin",p),t.removeEventListener("focusout",p),i()}},[]),e}function Sh({dark:e,back:t,ready:n,active:s}){const r=oi(),o=Sc(),[i,l]=g.useState(!1),c=Yn(),u=g.useRef(crypto.randomUUID().slice(0,8)),[d,p]=g.useState(null),f=c.data.template.Assistant??Object.values(c.data.template).find(H=>H.role?.ref==="Assistant"),h=d??{id:"draft",name:"chat-"+u.current,role:f?.role?.ref??(c.data.role.Assistant?"Assistant":Object.keys(c.data.role)[0]??""),brain:f?.brain?.ref??Object.keys(c.data.brain)[0]??"",folder:f?.cwd??"",permissions:(f?.permissions?.approval??c.defaults.permissions?.approval)==="allow"||(f?.permissions?.filesystem??c.defaults.permissions?.filesystem)==="unrestricted"?"Allow · Full access":(f?.permissions?.filesystem??c.defaults.permissions?.filesystem)==="read-only"?"Read only":(f?.permissions?.approval??c.defaults.permissions?.approval)==="auto"?"Workspace edits":"Ask before changes",unattended:f?.permissions?.unattended??c.defaults.permissions?.unattended??"wait"},[m,v]=g.useState(!1),[b,k]=g.useState(!1),[z,R]=g.useState(""),[A,D]=g.useState(""),[O,I]=g.useState(""),[F,L]=g.useState(""),[j,x]=g.useState(!1),C=g.useRef(!1),M=g.useRef(!1),E=g.useRef(crypto.randomUUID()),T=g.useRef(crypto.randomUUID()),[B,Y]=g.useState(!1),re=g.useRef(),oe=g.useRef(),w=g.useRef(),U=g.useRef(),ne=g.useRef();async function _(){for(let H=0;H<60;H++){const he=await ee(`/creation-actions/${oe.current}`);if(he.error)throw new Error(he.error.message);if(["session_reachable","attention"].includes(he.state)){w.current=he.roleId;return}if(he.state==="launched_unconfirmed")throw new Error("Agent is still starting. Check its status before continuing.");await new Promise(Ee=>setTimeout(Ee,1e3))}throw new Error("Agent is still starting. Check its status before continuing.")}async function ue(H,he){if(M.current)throw Object.assign(new Error("A message is already being sent."),{code:"conflict"});M.current=!0,l(!1),L(""),I("Starting your agent…"),p({...h}),x(!0),D(H);let Ee=!1;try{if(!re.current){const Le={name:h.name,role:{ref:h.role},brain:{ref:h.brain},...h.folder?{cwd:h.folder}:{},lifetime:"temporary",permissions:{approval:h.permissions==="Allow · Full access"?"allow":h.permissions==="Workspace edits"?"auto":"ask",filesystem:h.permissions==="Allow · Full access"?"unrestricted":h.permissions==="Read only"?"read-only":"workspace",unattended:h.unattended??"wait"},openAfterCreate:!0,...h.permissions==="Allow · Full access"?{highRiskAcknowledged:!0}:{}},nt=await ee("/roles/preview",Le);if(nt.prerequisites?.length)throw new Error(nt.prerequisites.join("; "));re.current={request:nt.request,previewHash:nt.previewHash,idempotencyKey:E.current},Y(!0)}if(!oe.current){const Le=await ee("/roles",re.current);oe.current=Le.actionId}if(await _(),I("Sending your first message…"),(he||o.has)&&!U.current){const Le=await ee(`/roles/${encodeURIComponent(w.current)}/conversation?limit=1`);U.current=Le.snapshot.sessionGeneration}const Re=o.has?await o.upload(w.current,U.current):[];Ee=!0,C.current=!0,await ee(`/roles/${encodeURIComponent(w.current)}/input`,{text:H,commandId:he?.commandId??T.current,...he||Re.length?{expectedSessionGeneration:U.current}:{},...Re.length?{attachments:Re.map(Le=>Le.id)}:{}}),C.current=!1,await n(w.current)}catch(Re){if(Re.code==="stale_state"&&o.has){C.current=!1,l(!0),U.current=void 0,T.current=crypto.randomUUID(),ne.current&&(ne.current={...ne.current,commandId:T.current});const Le=await ee(`/roles/${encodeURIComponent(w.current)}/conversation?limit=1`);throw U.current=Le.snapshot.sessionGeneration,new Error("Agent session changed. Remove the attachments, select them again, then resume your first message.")}throw Ee||(Object.assign(Re,{accepted:!1}),C.current||l(!0)),Re}finally{M.current=!1,I("")}}async function Se(){if(!(!z.trim()&&!o.has||j||M.current||m))try{const H=b&&z.trimStart().startsWith("/")?`Voice message:
|
|
204
|
+
`+z:z;b&&(ne.current={text:H,commandId:T.current}),await ue(H,ne.current)}catch(H){L(H.message)}}return a.jsxs("div",{ref:r,className:"fleet-acp chat-canvas","data-app-update-busy":!!z.trim()||o.has||m||j,"data-acp-theme":e?"dark":"light",children:[a.jsxs(Xo,{className:"fleet-acp-header",children:[a.jsx(wr,{label:"Back to chats",onClick:t}),a.jsxs("div",{children:[a.jsx("strong",{children:"New chat"}),a.jsx("small",{children:"Temporary agent"})]})]}),a.jsx("div",{className:"fleet-acp-scroll",children:a.jsxs("div",{className:"fleet-acp-thread",children:[c.loaded?a.jsxs(a.Fragment,{children:[a.jsx(jh,{draft:h,onChange:p,locked:j||m}),a.jsx("p",{className:"muted",children:"Temporary chats close after 24 hours without activity. Active work and pending approvals keep them open."})]}):a.jsx("p",{role:"status",children:"Loading defaults…"}),A&&a.jsxs(lc,{outgoing:!0,className:"fleet-acp-message user",children:[a.jsx("small",{children:"You"}),a.jsx("p",{style:{whiteSpace:"pre-wrap"},children:A})]}),F&&a.jsxs("div",{role:"alert",children:[a.jsx("p",{children:F}),!B&&a.jsx(J,{onClick:()=>{x(!1),D(""),L("")},children:"Edit settings"}),B&&a.jsx(J,{onClick:()=>{M.current||(L(""),ue(A,ne.current).catch(H=>L(H.message)))},children:"Resume first message"}),a.jsx("p",{children:"Your message remains here if it could not be sent."})]})]})}),a.jsxs("form",{className:"fleet-acp-composer",onSubmit:H=>{H.preventDefault(),Se()},children:[a.jsx("div",{className:"fleet-acp-state",role:"status",children:O||"Settings lock when you send your first message."}),a.jsx(Cc,{attachments:o,disabled:j&&!i}),a.jsxs(cc,{className:"fleet-acp-input",children:[a.jsx(_c,{attachments:o,generation:U.current,disabled:j&&!i||m}),a.jsx(Nc,{onBusy:v,active:s,disabled:!c.loaded||!h.role||!h.brain||j,onTranscript:H=>{R(he=>Ic(he,H)),k(!0)}}),a.jsx(uc,{"aria-label":"Message agent",placeholder:"Message your agent…",rows:1,value:z,readOnly:j,onChange:H=>R(H.target.value),onKeyDown:H=>{H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),Se())}}),a.jsx(J,{primary:!0,className:"fleet-acp-send chat-send","aria-label":"Send",type:"submit",disabled:j||m||!c.loaded||!h.role||!h.brain||!z.trim()&&!o.has,children:a.jsx(dc,{className:"ic",size:20})})]})]})]})}function Pc({id:e,action:t,done:n}){const s="fleet-pending-lifecycle:"+e,r=g.useRef(JSON.parse(sessionStorage.getItem(s)||"null")),o=g.useRef(r.current?.actionId??crypto.randomUUID()),[i,l]=g.useState(""),[c,u]=g.useState(!!r.current),[d,p]=g.useState(!1),[f,h]=g.useState(""),[m,v]=g.useState(""),b=t==="restart_fresh",k=async()=>{p(!0),v("");try{for(let z=0;z<30;z++){const R=await ee(`/actions/${encodeURIComponent(o.current)}`);if(h(R.state),R.state==="succeeded"){sessionStorage.removeItem(s),await n();return}if(R.state==="failed"&&sessionStorage.removeItem(s),["failed","uncertain"].includes(R.state))throw Error(R.error?.message??"The restart result is uncertain. Inspect the agent before another action.");await new Promise(A=>setTimeout(A,1e3))}h("Still pending. Check status to continue observing this action.")}catch(z){v(z.message)}finally{p(!1)}};return a.jsxs(a.Fragment,{children:[r.current&&a.jsxs("p",{children:["A previous ",r.current.action==="restart_fresh"?"force restart":"restart"," is awaiting confirmation. Check its status before starting another."]}),a.jsx("p",{children:b?"Start a fresh session. The current conversation context will be cleared.":"Restart the agent and resume its saved session."}),a.jsx("p",{children:"The saved agent configuration will be applied."}),b&&a.jsx(xe,{label:`Confirm agent ID: ${e}`,children:a.jsx("input",{value:i,disabled:c,onChange:z=>l(z.target.value)})}),f&&a.jsx("p",{role:"status",children:f}),m&&a.jsx("p",{role:"alert",children:m}),c?a.jsx(J,{disabled:d,onClick:()=>void k(),children:"Check restart status"}):a.jsx(J,{disabled:d||b&&i!==e,onClick:async()=>{u(!0),p(!0),v("");try{sessionStorage.setItem(s,JSON.stringify({actionId:o.current,action:t})),await ee(`/roles/${encodeURIComponent(e)}/actions`,{action:t,actionId:o.current,...b?{confirmation:i}:{}}),await k()}catch(z){z.code==="action_not_accepted"&&z.accepted===!1&&(sessionStorage.removeItem(s),r.current=null,u(!1)),v(z.message)}finally{p(!1)}},children:b?"Force restart":"Restart"})]})}const ra=e=>{let t;const n=new Set,s=(u,d)=>{const p=typeof u=="function"?u(t):u;if(!Object.is(p,t)){const f=t;t=d??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(h=>h(t,f))}},r=()=>t,l={setState:s,getState:r,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(s,r,l);return l},Lc=(e=>e?ra(e):ra),_h=e=>e;function Dc(e,t=_h){const n=Bt.useSyncExternalStore(e.subscribe,Bt.useCallback(()=>t(e.getState()),[e,t]),Bt.useCallback(()=>t(e.getInitialState()),[e,t]));return Bt.useDebugValue(n),n}function Co(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,r])=>t.indexOf(+s)===-1).map(([s,r])=>r)}function oa(e,t="|"){return e.map(n=>Vc(n)).join(t)}function Io(e,t){return typeof t=="bigint"?t.toString():t}class Ch{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function ii(e){return new Ch(e)}function Ih(e){return e==null}function ai(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Nh(e,t){const n=e/t,s=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-s)<r?0:n-s}function vn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Mc(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Qt(e){return Mc(e._zod.def)??e._zod.def.shape}function Fc(e,t,n){Object.defineProperty(e,t,{get(){const s=n();return vn(this,t,s),s},enumerable:!0,configurable:!0})}function Uc(e,t,n){t in e?vn(e,t,n):e[t]=n}function In(e,t,n,s){const r=Qt(t);for(const o of n){const i=Object.getOwnPropertyDescriptor(r,o);i.enumerable&&(i.get?Fc(e,o,()=>{const l=t._zod.def.shape[o];return s?s(l,o):l}):Uc(e,o,s?s(i.value,o):i.value))}}function Eh(e,t){for(const n of Reflect.ownKeys(t)){const s=Object.getOwnPropertyDescriptor(t,n);s.enumerable&&(s.get?Fc(e,n,()=>t[n]):Uc(e,n,s.value))}}function xt(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function Rh(e){return JSON.stringify(e)}function zh(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Bc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ir(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Th=ii(()=>{if(Lt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function qn(e){if(ir(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ir(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Zc(e){return qn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Oh=new Set(["string","number","symbol"]);function Hn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bn(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function ae(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Vc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Ah(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const qc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},$h={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ph(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o={};return In(o,e,_r(e,t)),bn(e,xt(n,{shape:o,checks:[]}))}function _r(e,t){const n=Qt(e),s=[];for(const r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw new Error(`Unrecognized key: "${String(r)}"`);t[r]&&s.push(r)}return s}function Lh(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=new Set(_r(e,t)),i={};return In(i,e,Reflect.ownKeys(Qt(e)).filter(l=>!o.has(l))),bn(e,xt(n,{shape:i,checks:[]}))}function Dh(e,t){if(!qn(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const r=Qt(e);for(const o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return bn(e,xt(e._zod.def,{shape:Hc(e,t)}))}function Hc(e,t){const n={};return In(n,e,Reflect.ownKeys(Qt(e))),Eh(n,t),n}function Mh(e,t){if(!qn(t))throw new Error("Invalid input to safeExtend: expected a plain object");return bn(e,xt(e._zod.def,{shape:Hc(e,t)}))}function Fh(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};In(n,e,Reflect.ownKeys(Qt(e))),In(n,t,Reflect.ownKeys(Qt(t)));const s=xt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return bn(e,s)}function ia(e,t,n,s="partial"){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${s}() cannot be used on object schemas containing refinements`);const l=n?new Set(_r(t,n)):void 0,c={};return In(c,t,Reflect.ownKeys(Qt(t)),e&&((u,d)=>l&&!l.has(d)?u:new e({type:"optional",innerType:u}))),bn(t,xt(t._zod.def,{shape:c,checks:[]}))}function Uh(e,t,n){const s=n?new Set(_r(t,n)):void 0,r={};return In(r,t,Reflect.ownKeys(Qt(t)),(o,i)=>s&&!s.has(i)?o:new e({type:"nonoptional",innerType:o})),bn(t,xt(t._zod.def,{shape:r}))}function Yt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Bh(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Un(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function is(e){return typeof e=="string"?e:e?.message}function aa(e,t,n){var s;for(let r=t;r<e.length;r++)(s=e[r]).schema??(s.schema=n)}function fn(e,t,n){var s;const r=e.inst?._zod?.traits;r?.has("$ZodType")&&(r.has("$ZodCheck")?(s=e).schema??(s.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:is(e.inst?._zod.def?.error?.(e))??is(o?.(e))??is(t?.error?.(e))??is(n.customError?.(e))??is(n.localeError?.(e))??"Invalid input",l={};for(const c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(l[c]=e[c]);return l.path??(l.path=[]),l.message=i,t?.reportInput&&(l.input=e.input),l}const Zh=/[\uD800-\uDBFF]/;function li(e){const t=e.length;if(!Zh.test(e))return t;let n=t;for(let s=0;s<t-1;s++)(e.charCodeAt(s)&64512)===55296&&(e.charCodeAt(s+1)&64512)===56320&&(n--,s++);return n}function ci(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Vh(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function _s(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}function qh(e,t){for(const n in t){const s=Object.getOwnPropertyDescriptor(t,n);s.get?Object.defineProperty(e,n,{...s,enumerable:!1}):Hh(e,n,s.value)}}function hn(e,t,n,s=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:s,value:n}),n}function Wc(e,t,n){return hn(e,t,n,!1)}function Kc(e,t){for(const n in e){const s=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return hn(this,n,s(this))},set(r){hn(this,n,r)}})}return t}function Hh(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:hn(this,t,n.bind(this))},set(s){hn(this,t,s)}})}function Wh(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Vr,cn=!1;const Kh={configurable:!0,get(){cn=!0}};function Ae(e,t,n){const s=Object.getPrototypeOf(e._zod);if(t in s&&Vr!==e._zod){Vr=void 0;return}Vr=e._zod,Object.defineProperty(s,t,{configurable:!0,get(){Object.defineProperty(this,t,Kh);const r=cn;cn=!1;try{const o=n(this);return cn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),cn=cn||r,o}catch(o){throw delete this[t],cn=cn||r,o}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function Jh(e,t,n,s){const r=Wh(e,t);r&&Object.defineProperty(r,t,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:s,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:s,value:o})}})}const Gh="~constantCatch";function Yh(e){const t=()=>e;return t[Gh]=!0,t}var la;const qr={value:void 0,enumerable:!1};let ca="captureStackTrace"in Error?Error:null;function Xh(e){const t=ca;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return ca=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function V(e,t,n,s){const r={};function o(f){this.def=f,this.constr=p,this.traits=new Set}o.prototype=r;const i=n,l=i&&new WeakSet;function c(f,h){if(f._zod){if(f._zod.traits.has(e))return}else{qr.value=new o(h);try{Object.defineProperty(f,"_zod",qr)}finally{qr.value=void 0}}if(f._zod.traits.add(e),t(f,h),l){const v=Object.getPrototypeOf(f),b=f._zod.constr.prototype;let k=v;for(;k&&k!==b;)k=Object.getPrototypeOf(k);const z=k??v;l.has(z)||(l.add(z),qh(z,i))}const m=p.prototype;for(const v in m)Object.prototype.hasOwnProperty.call(m,v)&&(v in f||(f[v]=m[v].bind(f)))}const u=s?.Parent??Object;class d extends u{}Object.defineProperty(d,"name",{value:e});function p(f){const h=s?.Parent?Xh(d):this;c(h,f);const m=h._zod.deferred;if(m){for(const b of m)b();h._zod.deferred=void 0}const v=globalThis.__zod_globalConfig?.postProcessor;return v&&v(h),h}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:f=>s?.Parent&&f instanceof s.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(p,"name",{value:e}),p}class _n extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Jc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(la=globalThis).__zod_globalConfig??(la.__zod_globalConfig={});const Lt=globalThis.__zod_globalConfig;function Vt(e){return e&&Object.assign(Lt,e),Lt}function Qh(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Io,2)),e.message}function em(e){this._zod.message=e}const tm={get:Qh,set:em,enumerable:!0,configurable:!0},Hr={value:void 0,enumerable:!1},ua=new WeakSet([Object.prototype,Error.prototype]),nm=(e,t)=>{e.name="$ZodError",Hr.value=t,Object.defineProperty(e,"issues",Hr),Hr.value=void 0,Object.defineProperty(e,"message",tm);const n=Object.getPrototypeOf(e);ua.has(n)||(ua.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const s=()=>this.message;return Object.defineProperty(this,"toString",{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,"toString",{value:s,configurable:!0,writable:!0})}}))},sm=V("$ZodError",nm);function rm(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function om(e,t=n=>n.message){const n={},s=[];for(const r of e.issues)r.path.length>0?rm(n,r.path[0],()=>[]).push(t(r)):s.push(t(r));return{formErrors:s,fieldErrors:n}}function im(e,t=n=>n.message){const n={_errors:[]},s=(r,o=[])=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(l=>s({issues:l},[...o,...i.path]));else if(i.code==="invalid_key")s({issues:i.issues},[...o,...i.path]);else if(i.code==="invalid_element")s({issues:i.issues},[...o,...i.path]);else{const l=[...o,...i.path];if(l.length===0)n._errors.push(t(i));else{let c=n,u=0;for(;u<l.length;){const d=l[u],p=u===l.length-1;if(d==="_errors"){p&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,d)||Object.defineProperty(c,d,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const f=c[d];p&&f._errors.push(t(i)),c=f,u++}}}};return s(e),n}function Cr(e,t){return{callee:t?.callee??e,Err:t?.Err}}const ui=e=>{const t=(n,s,r,o)=>{const i=r?{...r,async:!1}:{async:!1},l=n._zod.run({value:s,issues:[]},i);if(l instanceof Promise)throw new _n;if(l.issues.length){const c=new(o?.Err??e)(l.issues.map(u=>fn(u,i,Vt())));throw Bc(c,o?.callee??t),c}return l.value};return t},di=e=>{const t=async(n,s,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let l=n._zod.run({value:s,issues:[]},i);if(l instanceof Promise&&(l=await l),l.issues.length){const c=new(o?.Err??e)(l.issues.map(u=>fn(u,i,Vt())));throw Bc(c,o?.callee??t),c}return l.value};return t},pi=e=>(t,n,s)=>{const r=s?{...s,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new _n;return o.issues.length?Gc(e,o.issues,r):{success:!0,data:o.value}};function Gc(e,t,n){let s;return{success:!1,get error(){return s||(s=new e(t.map(r=>fn(r,n,Vt()))),t=void 0,n=void 0),s},set error(r){s=r,t=void 0,n=void 0}}}const fi=e=>async(t,n,s)=>{const r=s?{...s,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?Gc(e,o.issues,r):{success:!0,data:o.value}},am=Symbol.for("zod.compile.invalid"),lm=Symbol.for("zod.compile.fallback"),cm=((e,t,n)=>{const s=e._zod.bag.validator;if(s!==void 0){if(s(t)!==am)return!0;if(s.definite===!0&&n===void 0)return!1}return um(e,t,n)});function um(e,t,n){const s=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun;let o;if(r?(s[lm]=!0,o=r({value:t,issues:[]},s)):o=e._zod.run({value:t,issues:[]},s),o instanceof Promise)throw new _n;return o.issues.length===0}const dm=async(e,t,n)=>{const s=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let r=e._zod.run({value:t,issues:[]},s);return r instanceof Promise&&(r=await r),r.issues.length===0},pm=e=>{const t=ui(e),n=(s,r,o,i)=>{const l=o?{...o,direction:"backward"}:{direction:"backward"};return t(s,r,l,Cr(n,i))};return n},fm=e=>{const t=ui(e),n=(s,r,o,i)=>t(s,r,o,Cr(n,i));return n},hm=e=>{const t=di(e),n=async(s,r,o,i)=>{const l=o?{...o,direction:"backward"}:{direction:"backward"};return await t(s,r,l,Cr(n,i))};return n},mm=e=>{const t=di(e),n=async(s,r,o,i)=>await t(s,r,o,Cr(n,i));return n},gm=e=>(t,n,s)=>{const r=s?{...s,direction:"backward"}:{direction:"backward"};return pi(e)(t,n,r)},ym=e=>(t,n,s)=>pi(e)(t,n,s),vm=e=>async(t,n,s)=>{const r=s?{...s,direction:"backward"}:{direction:"backward"};return fi(e)(t,n,r)},bm=e=>async(t,n,s)=>fi(e)(t,n,s),xm=/^[cC][0-9a-z]{6,}$/,km=/^[0-9a-z]+$/,wm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,jm=/^[0-9a-vA-V]{20}$/,Sm=/^[A-Za-z0-9]{27}$/,_m=/^[a-zA-Z0-9_-]{21}$/;function Cm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Im=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Nm=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,da=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Em=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rm="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function zm(){return new RegExp(Rm,"u")}const Tm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Om=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Am=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$m=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Lm=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Dm=/^https?$/,Mm=/^\+[1-9]\d{6,14}$/,Yc="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Fm(e){return new RegExp(`^${e}$`)}const Um=Fm(Yc);function No(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Bm(e){return new RegExp(`^${No(e)}$`)}function Zm(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${No({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,s=e.local?`${n}|${No({precision:e.precision})}`:n;return new RegExp(`^${Yc}T(?:${s})$`)}const Vm=/^[\s\S]{0,}$/,qm=/^-?\d+$/,hi=/^-?\d+(?:\.\d+)?$/,Hm=/^(?:true|false)$/i,Wm=/^[^A-Z]*$/,Km=/^[^a-z]*$/,ht=V("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),mi=e=>{const t=e.value;return!Ih(t)&&t.length!==void 0},ar={number:"number",bigint:"bigint",object:"date"},Xc=V("$ZodCheckLessThan",(e,t)=>{ht.init(e,t);const n=ar[typeof t.value];e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:ar[typeof s.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qc=V("$ZodCheckGreaterThan",(e,t)=>{ht.init(e,t);const n=ar[typeof t.value];e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:ar[typeof s.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jm=V("$ZodCheckMultipleOf",(e,t)=>{ht.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Nh(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Gm=V("$ZodCheckNumberFormat",(e,t)=>{ht.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[r,o]=qc[t.format];e._zod.check=i=>{const l=i.value;if(n){if(!Number.isInteger(l)){i.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?i.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort}):i.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort});return}}l<r&&i.issues.push({origin:"number",input:l,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),l>o&&i.issues.push({origin:"number",input:l,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Ym=V("$ZodCheckMaxLength",(e,t)=>{var n;ht.init(e,t),(n=e._zod.def).when??(n.when=mi),e._zod.check=s=>{const r=s.value,o=r.length;if((typeof r=="string"&&o>t.maximum?li(r):o)<=t.maximum)return;const l=ci(r);s.issues.push({origin:l,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Xm=V("$ZodCheckMinLength",(e,t)=>{var n;ht.init(e,t),(n=e._zod.def).when??(n.when=mi),e._zod.check=s=>{const r=s.value,o=r.length;if((typeof r=="string"&&o>=t.minimum&&o<t.minimum*2?li(r):o)>=t.minimum)return;const l=ci(r);s.issues.push({origin:l,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qm=V("$ZodCheckLengthEquals",(e,t)=>{var n;ht.init(e,t),(n=e._zod.def).when??(n.when=mi),e._zod.check=s=>{const r=s.value,o=r.length,i=typeof r=="string"&&o>=t.length&&o<=t.length*2?li(r):o;if(i===t.length)return;const l=ci(r),c=i>t.length;s.issues.push({origin:l,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),Ir=V("$ZodCheckStringFormat",(e,t)=>{var n,s;ht.init(e,t),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),eg=V("$ZodCheckRegex",(e,t)=>{Ir.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tg=V("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Wm),Ir.init(e,t)}),ng=V("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Km),Ir.init(e,t)}),sg=V("$ZodCheckIncludes",(e,t)=>{ht.init(e,t);const n=Hn(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=s,e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),rg=V("$ZodCheckStartsWith",(e,t)=>{ht.init(e,t);const n=new RegExp(`^${Hn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),og=V("$ZodCheckEndsWith",(e,t)=>{ht.init(e,t);const n=new RegExp(`.*${Hn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),ig=V("$ZodCheckOverwrite",(e,t)=>{ht.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ag{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const s=t.split(`
|
|
205
|
+
`).filter(i=>i),r=Math.min(...s.map(i=>i.length-i.trimStart().length)),o=s.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of o)this.content.push(i)}compile(){const t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
206
|
+
${n.join(`
|
|
207
|
+
`)}
|
|
208
|
+
};`)(...Object.values(this.closed))}}const lg={major:4,minor:6,patch:5},Be=V("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=lg;const s=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...s??[]]:s?.length?[...s]:[];for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(l,c,u)=>{if(l.memo)return l;let d=Yt(l),p;for(const f of c){if(f._zod.def.when){if(Bh(l)||!f._zod.def.when(l))continue}else if(d)continue;const h=l.issues.length,m=f._zod.check(l);if(m instanceof Promise&&u?.async===!1)throw new _n;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await m,l.issues.length!==h&&(aa(l.issues,h,e),d||(d=Yt(l,h)))});else{if(l.issues.length===h)continue;aa(l.issues,h,e),d||(d=Yt(l,h))}}return p?p.then(()=>l):l},i=(l,c,u)=>{if(Yt(l))return l.aborted=!0,l;const d=o(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new _n;return d.then(p=>e._zod.parse(p,u))}return e._zod.parse(d,u)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const d=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(p=>i(p,l,c)):i(d,l,c)}const u=e._zod.parse(l,c);if(u instanceof Promise){if(c.async===!1)throw new _n;return u.then(d=>o(d,r,c))}return o(u,r,c)}}},{get"~standard"(){return Wc(this,"~standard",tu(this))},set"~standard"(e){hn(this,"~standard",e)}}),eu=(e,t)=>e.issues.length?{issues:e.issues.map(n=>fn(n,t,Vt()))}:{value:e.value};async function cg(e,t){const n={async:!0};return eu(await e._zod.run({value:t,issues:[]},n),n)}function tu(e){return{validate:t=>{const n={async:!1};try{const s=e._zod.run({value:t,issues:[]},n);if(!(s instanceof Promise))return eu(s,n)}catch{}return cg(e,t)},vendor:"zod",version:1}}const gi=V("$ZodString",(e,t)=>{Be.init(e,t),e._zod.pattern=t.pattern??Vm,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ue=V("$ZodStringFormat",(e,t)=>{Ir.init(e,t),gi.init(e,t)}),ug=V("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Nm),Ue.init(e,t)}),dg=V("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=da(s))}else t.pattern??(t.pattern=da());Ue.init(e,t)}),pg=V("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Em),Ue.init(e,t)}),nu=1,lr=2;function su(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function fg(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?su(e)||lr:hg(e,t)}function hg(e,t){if(!t.normalize&&t.protocol?.source===Dm.source&&!/^https?:\/\//i.test(e))return nu;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??lr}return new URL(e)}catch{return lr}}const mg=/[\t\n\r]/g;function pa(e){return e.replace(mg,"")}function gg(e,t){return t.lastIndex=0,t.test(e.hostname)}function yg(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const vg=V("$ZodURL",(e,t)=>{Ue.init(e,t),e._zod.check=n=>{try{const s=n.value.trim(),r=fg(s,t);if(r===nu){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===lr){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=pa(s);return}t.hostname&&!gg(r,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!yg(r,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?r.href:pa(s);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),bg=V("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=zm()),Ue.init(e,t)}),xg=V("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?_m:Cm(t.length)),Ue.init(e,t)}),kg=V("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xm),Ue.init(e,t)}),wg=V("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=km),Ue.init(e,t)}),jg=V("$ZodULID",(e,t)=>{t.pattern??(t.pattern=wm),Ue.init(e,t)}),Sg=V("$ZodXID",(e,t)=>{t.pattern??(t.pattern=jm),Ue.init(e,t)}),_g=V("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Sm),Ue.init(e,t)}),Cg=V("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Zm(t)),Ue.init(e,t)}),Ig=V("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Um),Ue.init(e,t)}),Ng=V("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Bm(t)),Ue.init(e,t)}),Eg=V("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Im),Ue.init(e,t)}),Rg=V("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Tm),Ue.init(e,t)}),zg=/^[0-9a-fA-F:.]+$/;function ru(e){return zg.test(e)?su(`http://[${e}]`):!1}const Tg=V("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Om),Ue.init(e,t),e._zod.check=n=>{ru(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Og=V("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Am),Ue.init(e,t)});function Ag(e){const t=e.split("/");if(t.length!==2)return!1;const[n,s]=t;if(!s)return!1;const r=Number(s);return`${r}`!==s||r<0||r>128?!1:ru(n)}const $g=V("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=$m),Ue.init(e,t),e._zod.check=n=>{Ag(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function ou(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const iu=/^[0-9a-zA-Z+/]*={0,2}$/,Pg=V("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=iu),Ue.init(e,t),e._zod.check=n=>{ou(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),yi=/^[A-Za-z0-9_-]*$/;function Lg(e){if(!yi.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ou(n)}const Dg=V("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=yi),Ue.init(e,t),e._zod.check=n=>{Lg(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Mg=V("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Mm),Ue.init(e,t)});function Fg(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const r=JSON.parse(atob(s));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Ug=V("$ZodJWT",(e,t)=>{Ue.init(e,t),e._zod.check=n=>{Fg(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),au=V("$ZodNumber",(e,t)=>{Be.init(e,t),e._zod.pattern=hi,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:String(r):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),Bg=V("$ZodNumberFormat",(e,t)=>{Gm.init(e,t),au.init(e,t)}),Zg=V("$ZodBoolean",(e,t)=>{Be.init(e,t),e._zod.pattern=Hm,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Vg=V("$ZodUnknown",(e,t)=>{Be.init(e,t),e._zod.parse=n=>n}),qg=V("$ZodNever",(e,t)=>{Be.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function fa(e,t,n){e.issues.length&&t.issues.push(...Un(n,e.issues)),t.value[n]=e.value}const Hg=V("$ZodArray",(e,t)=>{Be.init(e,t);const n=Lt.memoizer;n?.attach(e),e._zod.parse=(s,r)=>{const o=s.value;if(!Array.isArray(o))return s.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),s;s.value=n?n.alloc(e,s,Array(o.length),r):Array(o.length);const i=[],l=r?.abortEarly;for(let c=0;c<o.length;c++){const u=o[c],d=t.element._zod.run({value:u,issues:[]},r);if(d instanceof Promise)i.push(d.then(p=>fa(p,s,c)));else if(fa(d,s,c),l&&d.issues.length!==0&&Yt(d))break}return i.length?Promise.all(i).then(()=>s):s}});function cr(e,t,n,s,r,o){const i=n in s,l=o==="optional";if(!(!i&&l&&r==="optional")){if(e.issues.length){if(r!==void 0&&l&&!i)return;t.issues.push(...Un(n,e.issues))}if(!i&&r===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(i||r==="defaulted"&&!l)&&(t.value[n]=void 0):t.value[n]=e.value}}const Wg=[];function lu(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),s=n.length?n:Wg,r=s.length?[...t,...s]:t;for(const i of r)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);const o=Ah(e.shape);return{...e,allKeys:r,symbolKeys:s,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function cu(e,t,n,s,r,o,i){const l=[],c=r.keySet,u=r.catchall._zod,d=u.def.type,p=u.optin,f=u.optout;let h=0;for(const m in t){if(i&&n.issues.length!==h){if(Yt(n,h))break;h=n.issues.length}if(c.has(m))continue;if(m==="__proto__"){d==="never"&&l.push(m);continue}if(d==="never"){l.push(m);continue}const v=u.run({value:t[m],issues:[]},s);v instanceof Promise?e.push(v.then(b=>cr(b,n,m,t,p,f))):cr(v,n,m,t,p,f)}return l.length&&n.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Kg=V("$ZodObject",(e,t)=>{Be.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),s=n?.get?n.get.raw:t.shape??{};if(s){const u=()=>{const d={...s};return Object.defineProperty(t,"shape",{value:d}),u.raw=d,d};u.raw=s,Object.defineProperty(t,"shape",{get:u})}const r=ii(()=>lu(t));Ae(e,"propValues",u=>{const d=u.def.shape,p={};for(const f in d){const h=d[f]._zod;if(h.values){Object.prototype.hasOwnProperty.call(p,f)||vn(p,f,new Set);for(const m of h.values)p[f].add(m);h.optin!==void 0&&p[f].add(void 0)}}return p});const o=ir,i=t.catchall;let l;const c=Lt.memoizer;c?.attach(e),e._zod.parse=(u,d)=>{l??(l=r.value);const p=u.value;if(!o(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},d):{};const f=[],h=l.shape,m=d?.abortEarly;let v=u.issues.length;for(const b of l.allKeys){if(m&&u.issues.length!==v){if(Yt(u,v))break;v=u.issues.length}if(b==="__proto__")continue;const k=h[b],z=k._zod.optin,R=k._zod.optout,A=k._zod.run({value:p[b],issues:[]},d);A instanceof Promise?f.push(A.then(D=>cr(D,u,b,p,z,R))):cr(A,u,b,p,z,R)}return i?cu(f,p,u,d,r.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Jg=V("$ZodObjectJIT",(e,t)=>{Kg.init(e,t);const n=e._zod.parse,s=ii(()=>lu(t)),r=Lt.memoizer,o=h=>{const m=s.value,v=m.symbolKeys,b=new ag(["payload","ctx"],{shape:h,inst:e,memo:r,syms:v}),k=D=>`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`,z=(D,O)=>`
|
|
209
|
+
let ${D}_ab = false;
|
|
210
|
+
for (let i = 0; i < ${D}.issues.length; i++) {
|
|
211
|
+
const iss = ${D}.issues[i];
|
|
212
|
+
iss.path = iss.path ? [${O}, ...iss.path] : [${O}];
|
|
213
|
+
payload.issues.push(iss);
|
|
214
|
+
if (iss.continue !== true) ${D}_ab = true;
|
|
215
|
+
}
|
|
216
|
+
if (${D}_ab && ctx && ctx.abortEarly) {
|
|
217
|
+
payload.value = newResult;
|
|
218
|
+
return payload;
|
|
219
|
+
}`;b.write("const input = payload.value;");const R=Object.create(null);let A=0;for(const D of m.allKeys)R[D]=`key_${A++}`;b.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const D of m.allKeys){if(D==="__proto__")continue;const O=R[D],I=typeof D=="symbol"?`syms[${v.indexOf(D)}]`:Rh(D),F=`${I} in input`,L=h[D],j=L?._zod?.optin,x=j!==void 0,C=L?._zod?.optout==="optional";if(b.write(`const ${O} = ${k(I)};`),x&&C){const M=j==="optional"?`${O}_present`:`${O}.value !== undefined || ${O}_present`;b.write(`
|
|
220
|
+
const ${O}_present = ${F};
|
|
221
|
+
if (!${O}.issues.length || ${O}_present) {
|
|
222
|
+
if (${O}.issues.length) {${z(O,I)}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (${M}) {
|
|
226
|
+
newResult[${I}] = ${O}.value;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
`)}else x?(b.write(`
|
|
231
|
+
if (${O}.issues.length) {${z(O,I)}
|
|
232
|
+
}
|
|
233
|
+
`),j==="defaulted"?b.write(`newResult[${I}] = ${O}.value;`):b.write(`
|
|
234
|
+
if (${O}.value !== undefined || ${F}) {
|
|
235
|
+
newResult[${I}] = ${O}.value;
|
|
236
|
+
}
|
|
237
|
+
`)):b.write(`
|
|
238
|
+
const ${O}_present = ${F};
|
|
239
|
+
if (${O}.issues.length) {${z(O,I)}
|
|
240
|
+
}
|
|
241
|
+
if (!${O}_present && !${O}.issues.length) {
|
|
242
|
+
payload.issues.push({
|
|
243
|
+
code: "invalid_type",
|
|
244
|
+
expected: "nonoptional",
|
|
245
|
+
input: undefined,
|
|
246
|
+
path: [${I}]
|
|
247
|
+
});
|
|
248
|
+
if (ctx && ctx.abortEarly) {
|
|
249
|
+
payload.value = newResult;
|
|
250
|
+
return payload;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (${O}_present) {
|
|
255
|
+
newResult[${I}] = ${O}.value;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
`)}return b.write("payload.value = newResult;"),b.write("return payload;"),b.compile()};let i;const l=ir,c=!Lt.jitless,d=c&&Th.value,p=t.catchall;let f;e._zod.parse=(h,m)=>{f??(f=s.value);const v=h.value;return l(v)?c&&d&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),h=i(h,m),p?cu([],v,h,m,f,e,m?.abortEarly===!0):h):n(h,m):(h.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),h)}});function ha(e,t,n,s){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const r=e.filter(o=>!Yt(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(i=>fn(i,s,Vt())))}),t)}const Gg=V("$ZodUnion",(e,t)=>{Be.init(e,t),Ae(e,"optin",s=>s.def.options.some(r=>r._zod.optin==="defaulted")?"defaulted":s.def.options.some(r=>r._zod.optin!==void 0)?"optional":void 0),Ae(e,"optout",s=>s.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Ae(e,"values",s=>{if(s.def.options.every(r=>r._zod.values))return new Set(s.def.options.flatMap(r=>Array.from(r._zod.values)))}),Ae(e,"pattern",s=>{if(s.def.options.every(r=>r._zod.pattern)){const r=s.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>ai(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(s,r)=>{if(n)return n(s,r);let o=!1;const i=[];for(const l of t.options){const c=l._zod.run({value:s.value,issues:[]},r);if(c instanceof Promise)i.push(c),o=!0;else{if(c.issues.length===0)return c;i.push(c)}}return o?Promise.all(i).then(l=>ha(l,s,e,r)):ha(i,s,e,r)}}),Yg=V("$ZodIntersection",(e,t)=>{Be.init(e,t),e._zod.parse=(n,s)=>{const r=n.value,o=t.left._zod.run({value:r,issues:[]},s),i=t.right._zod.run({value:r,issues:[]},s);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,u])=>ma(n,c,u)):ma(n,o,i)}});function Eo(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(qn(e)&&qn(t)){const n=Object.keys(t),s=Object.keys(e).filter(o=>n.indexOf(o)!==-1),r={...e,...t};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(const o of s){if(o==="__proto__")continue;const i=Eo(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r[o]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const r=e[s],o=t[s],i=Eo(r,o);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ma(e,t,n){const s=new Map;let r;const o=new Map,i=(u,d)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)r??(r=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){const f=String(u.path[0]);o.has(f)||o.set(f,u),p=[f]}else return!1;for(const f of p)s.has(f)||s.set(f,{}),s.get(f)[d]=!0;return!0};for(const u of t.issues)i(u,"l")||e.issues.push(u);for(const u of n.issues)i(u,"r")||e.issues.push(u);const l=[...s].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(l.length){const u=r?l.filter(d=>r.keys.includes(d)):[];u.length&&e.issues.push({...r,keys:u});for(const d of l)!u.includes(d)&&o.has(d)&&e.issues.push(o.get(d))}const c=Eo(t.value,n.value);if(!c.valid){if(Yt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Xg=V("$ZodRecord",(e,t)=>{Be.init(e,t);const n=Lt.memoizer;n?.attach(e),e._zod.parse=(s,r)=>{const o=s.value;if(!qn(o))return s.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),s;const i=[],l=t.keyType._zod.values;if(l&&!t.partial){s.value=n?n.alloc(e,s,{},r):{};const c=new Set;for(const d of l)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){if(c.add(typeof d=="number"?d.toString():d),d==="__proto__")continue;const p=t.keyType._zod.run({value:d,issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){s.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(m=>fn(m,r,Vt())),input:d,path:[d],inst:e});continue}const f=p.value;if(f==="__proto__")continue;const h=t.valueType._zod.run({value:o[d],issues:[]},r);h instanceof Promise?i.push(h.then(m=>{m.issues.length&&s.issues.push(...Un(d,m.issues)),s.value[f]=m.value})):(h.issues.length&&s.issues.push(...Un(d,h.issues)),s.value[f]=h.value)}let u;for(const d in o)if(!c.has(d))if(t.mode==="loose"){if(d==="__proto__")continue;s.value[d]=o[d]}else u=u??[],u.push(d);u&&u.length>0&&s.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u,continue:!0})}else{s.value=n?n.alloc(e,s,{},r):{};let c;for(const u of Reflect.ownKeys(o)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,u))continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&hi.test(u)&&d.issues.length){const m=t.keyType._zod.run({value:Number(u),issues:[]},r);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(d=m)}if(d.issues.length){t.mode==="loose"?s.value[u]=o[u]:l?(c=c??[],c.push(u)):s.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>fn(m,r,Vt())),input:u,path:[u],inst:e});continue}const f=d.value;if(f==="__proto__")continue;const h=t.valueType._zod.run({value:o[u],issues:[]},r);h instanceof Promise?i.push(h.then(m=>{m.issues.length&&s.issues.push(...Un(u,m.issues)),s.value[f]=m.value})):(h.issues.length&&s.issues.push(...Un(u,h.issues)),s.value[f]=h.value)}c&&c.length>0&&s.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>s):s}}),Qg=V("$ZodEnum",(e,t)=>{Be.init(e,t);const n=Co(t.entries),s=new Set(n);e._zod.values=s,Ae(e,"pattern",r=>{const o=Co(r.def.entries).filter(i=>Oh.has(typeof i));return new RegExp(o.length?`^(${o.map(i=>Hn(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{const i=r.value;return s.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),ey=V("$ZodLiteral",(e,t)=>{Be.init(e,t);const n=new Set(t.values);e._zod.values=n,Ae(e,"pattern",s=>{const r=s.def.values;return new RegExp(r.length?`^(${r.map(o=>typeof o=="string"?Hn(o):o?Hn(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(s,r)=>{const o=s.value;return n.has(o)||s.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),s}}),ty=V("$ZodTransform",(e,t)=>{Be.init(e,t),e._zod.optin="optional",Lt.memoizer?.guard(e),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Jc(e.constructor.name);const r=t.transform(n.value,n);if(s.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new _n;return n.value=r,n}});function ga(e,t){return e.value=t.issues.length?void 0:t.value,e}const uu=V("$ZodOptional",(e,t)=>{Be.init(e,t),Ae(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Ae(e,"values",n=>{const s=n.def.innerType._zod.values;return s?new Set([...s,void 0]):void 0}),Ae(e,"pattern",n=>{const s=n.def.innerType._zod.pattern;return s?new RegExp(`^(${ai(s.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const r=t.innerType._zod.run({value:n.value,issues:[]},s);return r instanceof Promise?r.then(o=>ga(n,o)):ga(n,r)}return t.innerType._zod.run(n,s)}}),ny=V("$ZodExactOptional",(e,t)=>{uu.init(e,t),Ae(e,"values",n=>n.def.innerType._zod.values),Ae(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),sy=V("$ZodNullable",(e,t)=>{Be.init(e,t),Ae(e,"optin",n=>n.def.innerType._zod.optin),Ae(e,"optout",n=>n.def.innerType._zod.optout),Ae(e,"pattern",n=>{const s=n.def.innerType._zod.pattern;return s?new RegExp(`^(${ai(s.source)}|null)$`):void 0}),Ae(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),ry=V("$ZodDefault",(e,t)=>{Be.init(e,t),e._zod.optin="defaulted",Ae(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,s);return r instanceof Promise?r.then(o=>ya(o,t)):ya(r,t)}});function ya(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const oy=V("$ZodPrefault",(e,t)=>{Be.init(e,t),e._zod.optin="defaulted",Ae(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),iy=V("$ZodNonOptional",(e,t)=>{Be.init(e,t),Ae(e,"values",n=>{const s=n.def.innerType._zod.values;return s?new Set([...s].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,s)=>{const r=t.innerType._zod.run(n,s);return r instanceof Promise?r.then(o=>va(o,e)):va(r,e)}});function va(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function ba(e,t,n,s){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(r=>fn(r,s,Vt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const ay=V("$ZodCatch",(e,t)=>{Be.init(e,t),Ae(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Ae(e,"optout",n=>n.def.innerType._zod.optout),Ae(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const r=t.innerType._zod.run({value:n.value,issues:[]},s);return r instanceof Promise?r.then(o=>ba(n,o,t,s)):ba(n,r,t,s)}}),ly=V("$ZodPipe",(e,t)=>{Be.init(e,t),Ae(e,"values",n=>n.def.in._zod.values),Ae(e,"optin",n=>n.def.in._zod.optin),Ae(e,"optout",n=>n.def.out._zod.optout),Ae(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const o=t.out._zod.run(n,s);return o instanceof Promise?o.then(i=>Ps(i,t.in,s)):Ps(o,t.in,s)}const r=t.in._zod.run(n,s);return r instanceof Promise?r.then(o=>Ps(o,t.out,s)):Ps(r,t.out,s)}});function Ps(e,t,n){return e.issues.some(s=>s.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const cy=V("$ZodReadonly",(e,t)=>{Be.init(e,t),Ae(e,"propValues",n=>n.def.innerType._zod.propValues),Ae(e,"values",n=>n.def.innerType._zod.values),Ae(e,"optin",n=>n.def.innerType?._zod?.optin),Ae(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const r=t.innerType._zod.run(n,s);return r instanceof Promise?r.then(xa):xa(r)}});function xa(e){return e.memo||(e.value=Object.freeze(e.value)),e}const uy=V("$ZodCustom",(e,t)=>{ht.init(e,t),Be.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,r=t.fn(s);if(r instanceof Promise)return r.then(o=>ka(o,n,s,e));ka(r,n,s,e)}});function ka(e,t,n,s){if(!e){const r={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(r.params=s._zod.def.params),t.issues.push(_s(r))}}class dy extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Ro="~memo",wa=[];function du(e){return e!==null&&typeof e=="object"}function Wr(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const pu=new WeakMap,fs=0,Js=1,ms=2;function Gs(e,t,n){const s=pu.get(e);if(s!==void 0)return s?ms:fs;if(t.has(e))return ms;t.add(e);let r=fs;const o=d=>{if(r!==ms&&d?._zod){const p=Gs(d,t);p>r&&(r=p)}},i=(d,p)=>{let f=fs;for(const h of Reflect.ownKeys(d)){const m=Object.getOwnPropertyDescriptor(d,h);if(!m.enumerable)continue;const v=m.get?Js:m.value?._zod?Gs(m.value,t):fs;v>f&&(f=v)}return f},l=d=>{d>r&&(r=d)},c=e._zod.def;switch(c.type){case"object":{const d=Mc(c);l(d?i(d):Js),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(const d of c.items)o(d);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(const d of c.options)o(d);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{const d=c._cachedInner??void 0;l(d?Gs(d,t):Js);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const d in c){const p=Object.getOwnPropertyDescriptor(c,d);if(!p||p.get)continue;const f=p.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(const h of f)o(h)}}}return t.delete(e),py(e,r)}function py(e,t){return t!==Js&&pu.set(e,t===ms),t}function fy(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let Ls;const Ds=[],hy={alloc(e,t,n){const s=Ls;if(!s)return n;Ls=void 0;const r={value:n,issues:null};return s.set(t.value,r),Ds.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,s=(r,o)=>{if(o.direction!=="backward"&&gy(o,r.value))throw new dy;return n(r,o)};e._zod.parse=s,e._zod.run===n&&(e._zod.run=s)})},attach(e){var t;let n,s=!1,r,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const i=e._zod.parse,l=(c,u)=>{if(n===void 0){const k=Gs(e,new Set);if(k===fs)return e._zod.parse=i,e._zod.run===l&&(e._zod.run=i),i(c,u);k===ms||s?n=!0:s=!0}const d=c.value;if(!du(d))return i(c,u);let p=u[Ro];p||(p={buckets:new WeakMap,backEdges:void 0},u[Ro]=p);let f;r===u?f=o:(f=fy(p,e),r=u,o=f);const h=f.get(d);if(h)return c.value=h.value,h.issues?h.issues.length&&c.issues.push(...Wr(h.issues)):(c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value)),c;Ls=f;const m=Ds.length,v=i(c,u);Ls=void 0;const b=Ds.length>m?Ds.pop():void 0;return v instanceof Promise?v.then(k=>(b&&(b.issues=k.issues.length?Wr(k.issues):wa),k)):(b&&(b.issues=v.issues.length?Wr(v.issues):wa),v)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function my(){return hy}function gy(e,t){const n=e[Ro]?.backEdges;return n!==void 0&&du(t)&&n.has(t)}const yy=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},s={nan:"NaN"};function r(o,i){return o==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):s[o]??o}return o=>{switch(o.code){case"invalid_type":{const i=r(o.expected),l=Vh(o.input),c=r(l,o.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${Vc(o.values[0])}`:`Invalid option: expected one of ${oa(o.values,"|")}`;case"too_big":{const i=o.exact?"exactly ":o.inclusive?"<=":"<",l=t(o.origin);return l?`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${l.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{const i=o.exact?"exactly ":o.inclusive?">=":">",l=t(o.origin);return l?`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${l.unit}`:`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{const i=o;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${n[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${oa(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(l=>`'${l}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function vy(){return{localeError:yy()}}var ja;class by{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const s={...this.get(n)??{}};delete s.id;const r={...s,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function xy(){return new by}(ja=globalThis).__zod_globalRegistry??(ja.__zod_globalRegistry=xy());const hs=globalThis.__zod_globalRegistry;function fu(e){return e.checks&&(e.checks=[...e.checks]),e}function ky(e,t){return new e(fu({type:"string",...ae(t)}))}function wy(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ae(t)})}function jy(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ae(t)})}function Sy(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ae(t)})}function _y(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ae(t)})}function Cy(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ae(t)})}function Iy(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ae(t)})}function Ny(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ae(t)})}function Ey(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ae(t)})}function Ry(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ae(t)})}function zy(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ae(t)})}function Ty(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ae(t)})}function Oy(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ae(t)})}function Ay(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ae(t)})}function $y(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ae(t)})}function Py(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ae(t)})}function Ly(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ae(t)})}function Dy(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ae(t)})}function My(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ae(t)})}function Fy(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ae(t)})}function Uy(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ae(t)})}function By(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ae(t)})}function Zy(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ae(t)})}function Vy(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ae(t)})}function qy(e,t){return new e({type:"string",format:"date",check:"string_format",...ae(t)})}function Hy(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ae(t)})}function Wy(e,t){return new e({type:"string",format:"duration",check:"string_format",...ae(t)})}function Ky(e,t){return new e(fu({type:"number",checks:[],...ae(t)}))}function Jy(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ae(t)})}function Gy(e,t){return new e({type:"boolean",...ae(t)})}function Yy(e){return new e({type:"unknown"})}function Xy(e,t){return new e({type:"never",...ae(t)})}function Sa(e,t){return new Xc({check:"less_than",...ae(t),value:e,inclusive:!1})}function Kr(e,t){return new Xc({check:"less_than",...ae(t),value:e,inclusive:!0})}function _a(e,t){return new Qc({check:"greater_than",...ae(t),value:e,inclusive:!1})}function Jr(e,t){return new Qc({check:"greater_than",...ae(t),value:e,inclusive:!0})}function Ca(e,t){return new Jm({check:"multiple_of",...ae(t),value:e})}function hu(e,t){return new Ym({check:"max_length",...ae(t),maximum:e})}function ur(e,t){return new Xm({check:"min_length",...ae(t),minimum:e})}function mu(e,t){return new Qm({check:"length_equals",...ae(t),length:e})}function Qy(e,t){return new eg({check:"string_format",format:"regex",...ae(t),pattern:e})}function ev(e){return new tg({check:"string_format",format:"lowercase",...ae(e)})}function tv(e){return new ng({check:"string_format",format:"uppercase",...ae(e)})}function nv(e,t){return new sg({check:"string_format",format:"includes",...ae(t),includes:e})}function sv(e,t){return new rg({check:"string_format",format:"starts_with",...ae(t),prefix:e})}function rv(e,t){return new og({check:"string_format",format:"ends_with",...ae(t),suffix:e})}function Xn(e){return new ig({check:"overwrite",tx:e})}function ov(e){return Xn(t=>t.normalize(e))}function iv(){return Xn(e=>e.trim())}function av(){return Xn(e=>e.toLowerCase())}function lv(){return Xn(e=>e.toUpperCase())}function cv(){return Xn(e=>zh(e))}function uv(e,t,n){return new e({type:"array",element:t,...ae(n)})}function dv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ae(n)})}function pv(e,t){const n=fv(s=>(s.addIssue=r=>{if(typeof r=="string")s.issues.push(_s(r,s.value,n._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=s.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),s.issues.push(_s(o))}},e(s.value,s)),t);return n}function fv(e,t){const n=new ht({check:"custom",...ae(t)});return n._zod.check=e,n}function gs(e,...t){for(const n of t)for(const s of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,s)&&vn(e,s,n[s]);return e}function gu(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??hs,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function mn(e,t,n,s,r){const o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:s.path,message:r}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(r);return Object.assign(n,o),!0}function Ge(e,t,n={path:[],schemaPath:[]}){var s;const r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const l=e._zod.toJSONSchema?.();if(l)i.schema=l;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{const f=i.schema,h=t.processors[r.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);h(e,t,f,d)}const p=e._zod.parent;p&&(i.ref||(i.ref=p),Ge(p,t,d),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&gs(i.schema,c),t.io==="input"&&ot(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((s=i.schema).default??(s.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Ia(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function yu(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const s=new Map;for(const i of e.seen.entries()){const l=e.metadataRegistry.get(i[0])?.id;if(l){const c=s.get(l);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(l,i[0])}}const r=i=>{const l=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(p)return{ref:f(p)};const h=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=h,{defId:h,ref:`${f("__shared")}#/${l}/${Ia(h)}`}}const c="#",u=`${c}/${l}/`;if(i[1]===n&&!i[1].schema.id)return{ref:c};const d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+Ia(d)}},o=i=>{if(i[1].schema.$ref)return;const l=i[1],{ref:c,defId:u}=r(i);l.def={...l.schema},u&&(l.defId=u);const d=l.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const l=i[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/<root>
|
|
259
|
+
|
|
260
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const l=i[1];if(t===i[0]){o(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){o(i);continue}}if(e.metadataRegistry.get(i[0])?.id){o(i);continue}if(l.cycle){o(i);continue}l.count>1&&e.reused==="ref"&&o(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function vu(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const s of t){if(!s||typeof s!="object")return;vu(s);const r=Object.keys(s);if(r.length!==1||r[0]!=="type")return;const o=s.type;for(const i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;n.includes(i)||n.push(i)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const bu=new Set(["type","properties","required","additionalProperties"]),Na=["oneOf","anyOf"];function Ea(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function zo(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const i in o)if(!bu.has(i))return null;t.push(o)}const n={},s=new Set;for(const o of t){for(const i in o.properties){if(Object.prototype.hasOwnProperty.call(n,i))continue;const l=[];for(const u of t){const d=u.properties?.[i]??Ea(u);d!=null&&(l.some(p=>JSON.stringify(p)===JSON.stringify(d))||l.push(d))}const c=l.length===1?l[0]:zo(l)??{allOf:l};vn(n,i,c)}for(const i of o.required??[])s.add(i)}const r={type:"object",properties:n};if(s.size&&(r.required=[...s]),t.every(o=>o.additionalProperties===!1))r.additionalProperties=!1;else{const o=[];for(const i of t){const l=Ea(i);l&&!o.some(c=>JSON.stringify(c)===JSON.stringify(l))&&o.push(l)}o.length===1?r.additionalProperties=o[0]:o.length>1&&(r.additionalProperties={allOf:o})}return r}function hv(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const r of bu)if(r in e)return;const n=t.filter(r=>Na.some(o=>Array.isArray(r[o])));let s=null;if(!n.length)s=zo(t);else{const r=n[0],o=Na.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;const i=t.filter(c=>c!==r),l=r[o].map(c=>zo([...i,c]));if(l.some(c=>!c))return;s={[o]:l}}s&&(delete e.allOf,gs(e,s))}function xu(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=l=>{const c=e.seen.get(l);if(c.ref===null)return;const u=c.def??c.schema,d={...u},p=c.ref;if(c.ref=null,p){s(p);const h=e.seen.get(p),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):gs(u,m),gs(u,d),l._zod.parent===p)for(const b in u)b==="$ref"||b==="allOf"||b in d||delete u[b];if(m.$ref&&h.def)for(const b in u)b==="$ref"||b==="allOf"||b in h.def&&JSON.stringify(u[b])===JSON.stringify(h.def[b])&&delete u[b]}const f=l._zod.parent;if(f&&f!==p){s(f);const h=e.seen.get(f);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(const m in u)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(u[m])===JSON.stringify(h.def[m])&&delete u[m]}e.override({zodSchema:l,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const l of[...e.seen.entries()].reverse())s(l[0]);if(e.target!=="openapi-3.0")for(const l of e.seen.entries())vu(l[1].def??l[1].schema);for(const l of e.deferred)l();if(e.intersections.length){const l=new Map;for(const c of e.seen.values())for(const u of[c.schema,c.def]){const d=u?.allOf;if(!Array.isArray(d))continue;const p=l.get(d);p?p.push(u):l.set(d,[u])}for(const c of e.intersections)for(const u of l.get(c)??[])hv(u)}}const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const l=e.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(l)}gs(r,n.defId?n.schema:n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;o!==void 0&&r.id===o&&delete r.id;const i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const l of e.seen.entries()){const c=l[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,vn(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const l=JSON.parse(JSON.stringify(r));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:dr(t,"input",e.processors),output:dr(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function ot(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return ot(s.element,n);if(s.type==="set")return ot(s.valueType,n);if(s.type==="lazy")return ot(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault"||s.type==="catch")return ot(s.innerType,n);if(s.type==="intersection")return ot(s.left,n)||ot(s.right,n);if(s.type==="record"||s.type==="map")return ot(s.keyType,n)||ot(s.valueType,n);if(s.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ot(s.in,n)||ot(s.out,n);if(s.type==="object"){for(const r in s.shape)if(ot(s.shape[r],n))return!0;return!1}if(s.type==="union"){for(const r of s.options)if(ot(r,n))return!0;return!1}if(s.type==="tuple"){for(const r of s.items)if(ot(r,n))return!0;return!!(s.rest&&ot(s.rest,n))}return!1}const mv=(e,t={})=>n=>{const s=gu({...n,processors:t});return Ge(e,s),yu(s,e),xu(s,e)},dr=(e,t,n={})=>s=>{const{libraryOptions:r,target:o}=s??{},i=gu({...r??{},target:o,io:t,processors:n});return Ge(e,i),yu(i,e),xu(i,e)},Wn=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Kn=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ra=(e,t)=>{Wn(e,"minimum",t),Kn(e,"maximum",t)},ku=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},wu=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},ju=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},Su=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},za=(e,t)=>Wn(e,"minimum",t.minimum),Ta=(e,t)=>Kn(e,"maximum",t.maximum),Oa=e=>(t,n)=>{Su(t,n.format);const[s,r]=e[n.format];Wn(t,"minimum",s),Kn(t,"maximum",r)},gv={greater_than:(e,t)=>Wn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Kn(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ku(e,t.value),number_format:Oa(qc),bigint_format:Oa($h),min_length:za,max_length:Ta,length_equals:(e,t)=>Ra(e,t.length),min_size:za,max_size:Ta,size_equals:(e,t)=>Ra(e,t.size),string_format:(e,t)=>{Su(e,t.format),t.pattern&&wu(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>ju(e,t.mime)};function $t(e){const t={},n=e._zod.def,s=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of s)gv[o._zod.def.check]?.(t,o._zod.def);const r=e._zod.bag;r.minimum!==void 0&&Wn(t,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&Wn(t,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&Kn(t,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&Kn(t,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&ku(t,r.multipleOf),r.format!==void 0&&(t.format??(t.format=r.format),r.format.includes("int")&&(t.isInt=!0)),r.mime&&ju(t,r.mime);for(const o of r.patterns??[])wu(t,o);return t}const yv={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vv=new Map([[iu,Pm],[yi,Lm]]),_u=e=>vv.get(e)??e,bv=(e,t,n,s)=>{const r=n;r.type="string";const{minimum:o,maximum:i,format:l,patterns:c,contentEncoding:u,laxFormat:d}=$t(e);if(typeof o=="number"&&(r.minLength=o),typeof i=="number"&&(r.maxLength=i),l&&(r.format=yv[l]??l,r.format===""&&delete r.format,(l==="time"||d)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const p=[...c].map(_u);p.length===1?r.pattern=p[0].source:p.length>1&&(r.allOf=[...p.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},xv=(e,t,n,s)=>{const r=n,{minimum:o,maximum:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=$t(e);r.type=d?"integer":"number";const p=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p?h?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof o=="number"&&(r.minimum=o),f?h?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof i=="number"&&(r.maximum=i),l){const m=new Set;for(const k of l)Number.isFinite(k)&&k!==0?m.add(Math.abs(k)):mn(e,t,r,s,`A multipleOf divisor of ${k} cannot be represented in JSON Schema`);const[v,...b]=m;v!==void 0&&(r.multipleOf=v),b.length&&(r.allOf=[...r.allOf??[],...b.map(k=>({multipleOf:k}))])}},kv=(e,t,n,s)=>{n.type="boolean"},wv=(e,t,n,s)=>{n.not={}},jv=(e,t,n,s)=>{},Sv=(e,t,n,s)=>{const r=e._zod.def,o=Co(r.entries);if(o.length===0){n.not={};return}o.every(i=>typeof i=="number")&&(n.type="number"),o.every(i=>typeof i=="string")&&(n.type="string"),n.enum=o},_v=(e,t,n,s)=>{const r=e._zod.def;if(r.values.length===0){n.not={};return}const o=[];for(const i of r.values)if(i===void 0){if(mn(e,t,n,s,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(mn(e,t,n,s,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){const i=o[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else o.every(i=>typeof i=="number")&&(n.type="number"),o.every(i=>typeof i=="string")&&(n.type="string"),o.every(i=>typeof i=="boolean")&&(n.type="boolean"),o.every(i=>i===null)&&(n.type="null"),n.enum=o},Cv=(e,t,n,s)=>{mn(e,t,n,s,"Custom types cannot be represented in JSON Schema")},Iv=(e,t,n,s)=>{mn(e,t,n,s,"Transforms cannot be represented in JSON Schema")},Nv=(e,t,n,s)=>{const r=n,o=e._zod.def,{minimum:i,maximum:l}=$t(e);typeof i=="number"&&(r.minItems=i),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=Ge(o.element,t,{...s,path:[...s.path,"items"]})};function pr(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?pr(t.out):t.type==="catch"?pr(t.innerType):e._zod.optin}const Ev=(e,t,n,s)=>{const r=n,o=e._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&mn(e,t,r,s,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const u in i)vn(r.properties,u,Ge(i[u],t,{...s,path:[...s.path,"properties",u]}));const c=[];for(const u of Object.keys(i)){const d=o.shape[u];(t.io==="input"?pr(d)===void 0:d._zod.optout===void 0)&&c.push(u)}c.length>0&&(r.required=c),o.catchall?._zod.def.type==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=Ge(o.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Rv=(e,t,n,s)=>{const r=e._zod.def,o=r.inclusive===!1,i=r.options.map((l,c)=>Ge(l,t,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=i:n.anyOf=i},zv=(e,t,n,s)=>{const r=e._zod.def,o=Ge(r.left,t,{...s,path:[...s.path,"allOf",0]}),i=Ge(r.right,t,{...s,path:[...s.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(o)?o.allOf:[o],...l(i)?i.allOf:[i]];n.allOf=c,t.intersections.push(c)};function To(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const m=e.get(t)?.def;if(!m)return t;const v=To(e,m,n);return v===m?t:v}for(const m of["anyOf","oneOf"]){const v=t[m];if(!Array.isArray(v))continue;const b=v.map(k=>To(e,k,n));b.some((k,z)=>k!==v[z])&&(t={...t,[m]:b})}const s=Array.isArray(t.type)?t.type:[t.type],r=!s.includes("string")&&s.some(m=>m==="number"||m==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!o?.some(m=>typeof m=="number"))return t;const{minimum:i,maximum:l,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:d,format:p,id:f,...h}=t;return h.enum?h.enum=h.enum.map(m=>typeof m=="number"?String(m):m):typeof h.const=="number"&&(h.const=String(h.const)),r&&(h.type="string",o||(h.pattern=(s.includes("number")?hi:qm).source)),h}const Oo=new WeakMap;function Tv(e){const t=new Map;for(const s of e.seen.values())s.def&&!t.has(s.schema)&&t.set(s.schema,s);const n=new Map;for(const s of Oo.get(e)??[]){const r=e.seen.get(s),o=(r?.def??r?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const i=To(t,o,new Set);i!==o&&n.set(o,i)}if(n.size)for(const s of e.seen.values())for(const r of[s.schema,s.def]){const o=r&&n.get(r.propertyNames);o&&(r.propertyNames=o)}}const Ov=(e,t,n,s)=>{const r=n,o=e._zod.def;r.type="object";const i=o.keyType,l=$t(i).patterns;if(o.mode==="loose"&&l&&l.size>0){const d=Ge(o.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});r.patternProperties={};for(const p of l)vn(r.patternProperties,_u(p).source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=Ge(o.keyType,t,{...s,path:[...s.path,"propertyNames"]});let d=Oo.get(t);d||(d=[],Oo.set(t,d),t.deferred.push(()=>Tv(t))),d.push(e)}r.additionalProperties=Ge(o.valueType,t,{...s,path:[...s.path,"additionalProperties"]})}const c=i._zod.values,u=t.io==="input"&&pr(o.valueType)!==void 0;if(c&&!o.partial&&!u){const d=[...c].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(r.required=d.map(String))}},Av=(e,t,n,s)=>{const r=e._zod.def,o=Ge(r.innerType,t,s),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},$v=(e,t,n,s)=>{const r=e._zod.def;Ge(r.innerType,t,s);const o=t.seen.get(e);o.ref=r.innerType},vi=Symbol();function Cu(e,t,n,s,r){let o=!1;const i=JSON.stringify(e,(l,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(mn(t,n,s,r,"BigInt defaults cannot be represented in JSON Schema"),vi):JSON.parse(i)}const Pv=(e,t,n,s)=>{const r=e._zod.def;Ge(r.innerType,t,s);const o=t.seen.get(e);o.ref=r.innerType;const i=Cu(r.defaultValue,e,t,n,s);i!==vi&&(n.default=i)},Lv=(e,t,n,s)=>{const r=e._zod.def;Ge(r.innerType,t,s);const o=t.seen.get(e);if(o.ref=r.innerType,t.io!=="input")return;const i=Cu(r.defaultValue,e,t,n,s);i!==vi&&(n._prefault=i)},Dv=(e,t,n,s)=>{const r=e._zod.def;Ge(r.innerType,t,s);const o=t.seen.get(e);o.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{mn(e,t,n,s,"Dynamic catch values are not supported in JSON Schema");return}n.default=i},Mv=(e,t,n,s)=>{const r=e._zod.def,o=r.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?o?r.out:r.in:r.out;Ge(i,t,s);const l=t.seen.get(e);l.ref=i},Fv=(e,t,n,s)=>{const r=e._zod.def;Ge(r.innerType,t,s);const o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},Iu=(e,t,n,s)=>{const r=e._zod.def;Ge(r.innerType,t,s);const o=t.seen.get(e);o.ref=r.innerType},Aa=new WeakSet([Object.prototype,Error.prototype]);function Ms(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const s=n(this);return Object.defineProperty(this,t,{value:s,configurable:!0,writable:!0}),s},set(s){Object.defineProperty(this,t,{value:s,configurable:!0,writable:!0})}})}const Uv=(e,t)=>{sm.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Aa.has(n)||(Aa.add(n),Ms(n,"format",s=>r=>im(s,r)),Ms(n,"flatten",s=>r=>om(s,r)),Ms(n,"addIssue",s=>r=>{s.issues.push(r),s.message=JSON.stringify(s.issues,Io,2)}),Ms(n,"addIssues",s=>r=>{s.issues.push(...r),s.message=JSON.stringify(s.issues,Io,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Et=V("ZodError",Uv,void 0,{Parent:Error}),Bv=ui(Et),Zv=di(Et),Vv=pi(Et),qv=fi(Et),Hv=pm(Et),Wv=fm(Et),Kv=hm(Et),Jv=mm(Et),Gv=gm(Et),Yv=ym(Et),Xv=vm(Et),Qv=bm(Et);function eb(){Lt.localeError||Vt(vy())}function Nr(){Lt.memoizer||Vt({memoizer:my()})}const Ze=V("ZodType",(e,t)=>(eb(),Be.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(xt(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return bn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Jb(e,t))},superRefine(e,t){return this.check(Gb(e,t))},overwrite(e){return this.check(Xn(e))},optional(){return La(this)},exactOptional(){return Pb(this)},nullable(){return Da(this)},nullish(){return La(Da(this))},nonoptional(e){return Bb(this,e)},array(){return se(this)},or(e){return ge([this,e])},and(e){return Rn(this,e)},transform(e){return Ma(this,$b(e))},default(e){return Mb(this,e)},prefault(e){return Ub(this,e)},catch(e){return Vb(this,e)},pipe(e){return Ma(this,e)},readonly(){return Wb(this)},describe(e){const t=this.clone();return hs.add(t,{description:e}),t},meta(...e){if(e.length===0)return hs.get(this);const t=this.clone();return hs.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Wc(this,"~standard",{...tu(this),jsonSchema:{input:dr(this,"input"),output:dr(this,"output")}})},set"~standard"(e){hn(this,"~standard",e)},parse:function e(t,n){return Bv(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Zv(this,t,n,{callee:e})},safeParse(e,t){return Vv(this,e,t)},async safeParseAsync(e,t){return qv(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){hn(this,"spa",e)},validate(e,t){return cm(this,e,t)},validateAsync(e,t){return dm(this,e,t)},encode:function e(t,n){return Hv(this,t,n,{callee:e})},decode:function e(t,n){return Wv(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Kv(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Jv(this,t,n,{callee:e})},safeEncode(e,t){return Gv(this,e,t)},safeDecode(e,t){return Yv(this,e,t)},async safeEncodeAsync(e,t){return Xv(this,e,t)},async safeDecodeAsync(e,t){return Qv(this,e,t)},toJSONSchema(e){return mv(this,{})(e)},get description(){return hs.get(this)?.description},get _def(){return this._zod.def}}),Nu=V("_ZodString",(e,t)=>{gi.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>bv(e,n,s)},Kc({format:e=>$t(e).format??null,minLength:e=>$t(e).minimum??null,maxLength:e=>$t(e).maximum??null},{regex(...e){return this.check(Qy(...e))},includes(...e){return this.check(nv(...e))},startsWith(...e){return this.check(sv(...e))},endsWith(...e){return this.check(rv(...e))},min(...e){return this.check(ur(...e))},max(...e){return this.check(hu(...e))},length(...e){return this.check(mu(...e))},nonempty(...e){return this.check(ur(1,...e))},lowercase(e){return this.check(ev(e))},uppercase(e){return this.check(tv(e))},trim(){return this.check(iv())},normalize(...e){return this.check(ov(...e))},toLowerCase(){return this.check(av())},toUpperCase(){return this.check(lv())},slugify(){return this.check(cv())}})),tb=V("ZodString",(e,t)=>{gi.init(e,t),Nu.init(e,t)},{email(e){return this.check(wy(ib,e))},url(e){return this.check(Ny(lb,e))},jwt(e){return this.check(Zy(jb,e))},emoji(e){return this.check(Ey(cb,e))},guid(e){return this.check(jy(ab,e))},uuid(e){return this.check(Sy(Fs,e))},uuidv4(e){return this.check(_y(Fs,e))},uuidv6(e){return this.check(Cy(Fs,e))},uuidv7(e){return this.check(Iy(Fs,e))},nanoid(e){return this.check(Ry(ub,e))},cuid(e){return this.check(zy(db,e))},cuid2(e){return this.check(Ty(pb,e))},ulid(e){return this.check(Oy(fb,e))},base64(e){return this.check(Fy(xb,e))},base64url(e){return this.check(Uy(kb,e))},xid(e){return this.check(Ay(hb,e))},ksuid(e){return this.check($y(mb,e))},ipv4(e){return this.check(Py(gb,e))},ipv6(e){return this.check(Ly(yb,e))},cidrv4(e){return this.check(Dy(vb,e))},cidrv6(e){return this.check(My(bb,e))},e164(e){return this.check(By(wb,e))},datetime(e){return this.check(Vy(nb,e))},date(e){return this.check(qy(sb,e))},time(e){return this.check(Hy(rb,e))},duration(e){return this.check(Wy(ob,e))}});function y(e){return ky(tb,e)}const Ve=V("ZodStringFormat",(e,t)=>{Ue.init(e,t),Nu.init(e,t)}),nb=V("ZodISODateTime",(e,t)=>{Cg.init(e,t),Ve.init(e,t)}),sb=V("ZodISODate",(e,t)=>{Ig.init(e,t),Ve.init(e,t)}),rb=V("ZodISOTime",(e,t)=>{Ng.init(e,t),Ve.init(e,t)}),ob=V("ZodISODuration",(e,t)=>{Eg.init(e,t),Ve.init(e,t)}),ib=V("ZodEmail",(e,t)=>{pg.init(e,t),Ve.init(e,t)}),ab=V("ZodGUID",(e,t)=>{ug.init(e,t),Ve.init(e,t)}),Fs=V("ZodUUID",(e,t)=>{dg.init(e,t),Ve.init(e,t)}),lb=V("ZodURL",(e,t)=>{vg.init(e,t),Ve.init(e,t)}),cb=V("ZodEmoji",(e,t)=>{bg.init(e,t),Ve.init(e,t)}),ub=V("ZodNanoID",(e,t)=>{xg.init(e,t),Ve.init(e,t)}),db=V("ZodCUID",(e,t)=>{kg.init(e,t),Ve.init(e,t)}),pb=V("ZodCUID2",(e,t)=>{wg.init(e,t),Ve.init(e,t)}),fb=V("ZodULID",(e,t)=>{jg.init(e,t),Ve.init(e,t)}),hb=V("ZodXID",(e,t)=>{Sg.init(e,t),Ve.init(e,t)}),mb=V("ZodKSUID",(e,t)=>{_g.init(e,t),Ve.init(e,t)}),gb=V("ZodIPv4",(e,t)=>{Rg.init(e,t),Ve.init(e,t)}),yb=V("ZodIPv6",(e,t)=>{Tg.init(e,t),Ve.init(e,t)}),vb=V("ZodCIDRv4",(e,t)=>{Og.init(e,t),Ve.init(e,t)}),bb=V("ZodCIDRv6",(e,t)=>{$g.init(e,t),Ve.init(e,t)}),xb=V("ZodBase64",(e,t)=>{Pg.init(e,t),Ve.init(e,t)}),kb=V("ZodBase64URL",(e,t)=>{Dg.init(e,t),Ve.init(e,t)}),wb=V("ZodE164",(e,t)=>{Mg.init(e,t),Ve.init(e,t)}),jb=V("ZodJWT",(e,t)=>{Ug.init(e,t),Ve.init(e,t)}),Eu=V("ZodNumber",(e,t)=>{au.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>xv(e,n,s,r),e.isFinite=!0},Kc({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=$t(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=$t(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=$t(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>$t(e).format??null},{gt(e,t){return this.check(_a(e,t))},gte(e,t){return this.check(Jr(e,t))},min(e,t){return this.check(Jr(e,t))},lt(e,t){return this.check(Sa(e,t))},lte(e,t){return this.check(Kr(e,t))},max(e,t){return this.check(Kr(e,t))},int(e){return this.check($a(e))},safe(e){return this.check($a(e))},positive(e){return this.check(_a(0,e))},nonnegative(e){return this.check(Jr(0,e))},negative(e){return this.check(Sa(0,e))},nonpositive(e){return this.check(Kr(0,e))},multipleOf(e,t){return this.check(Ca(e,t))},step(e,t){return this.check(Ca(e,t))},finite(){return this}}));function me(e){return Ky(Eu,e)}const Sb=V("ZodNumberFormat",(e,t)=>{Bg.init(e,t),Eu.init(e,t)});function $a(e){return Jy(Sb,e)}const _b=V("ZodBoolean",(e,t)=>{Zg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>kv(e,n,s)});function Ye(e){return Gy(_b,e)}const Cb=V("ZodUnknown",(e,t)=>{Vg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>jv()});function $(){return Yy(Cb)}const Ib=V("ZodNever",(e,t)=>{qg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>wv(e,n,s)});function Nb(e){return Xy(Ib,e)}const Eb=V("ZodArray",(e,t)=>{Nr(),Hg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Nv(e,n,s,r),e.element=t.element},{min(e,t){return this.check(ur(e,t))},nonempty(e){return this.check(ur(1,e))},max(e,t){return this.check(hu(e,t))},length(e,t){return this.check(mu(e,t))},unwrap(){return this.element}});function se(e,t){return uv(Eb,e,t)}const Rb=V("ZodObject",(e,t)=>{Nr(),Jg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Ev(e,n,s,r),Jh(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Ru(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(xt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(xt(this._zod.def,{catchall:$()}))},loose(){return this.clone(xt(this._zod.def,{catchall:$()}))},strict(){return this.clone(xt(this._zod.def,{catchall:Nb()}))},strip(){return this.clone(xt(this._zod.def,{catchall:void 0}))},extend(e){return Dh(this,e)},safeExtend(e){return Mh(this,e)},merge(e){return Fh(this,e)},pick(e){return Ph(this,e)},omit(e){return Lh(this,e)},partial(...e){return ia(zu,this,e[0])},exactPartial(...e){return ia(Tu,this,e[0],"exactPartial")},required(...e){return Uh(Ou,this,e[0])}});function S(e,t){const n={type:"object",shape:e??{},...ae(t)};return new Rb(n)}const zb=V("ZodUnion",(e,t)=>{Gg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Rv(e,n,s,r),e.options=t.options});function ge(e,t){return new zb({type:"union",options:e,...ae(t)})}const Tb=V("ZodIntersection",(e,t)=>{Yg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>zv(e,n,s,r)});function Rn(e,t){return new Tb({type:"intersection",left:e,right:t})}const Pa=V("ZodRecord",(e,t)=>{Nr(),Xg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Ov(e,n,s,r),e.keyType=t.keyType,e.valueType=t.valueType});function P(e,t,n){return!t||!t._zod?new Pa({type:"record",keyType:y(),valueType:e,...ae(t)}):new Pa({type:"record",keyType:e,valueType:t,...ae(n)})}const Ao=V("ZodEnum",(e,t)=>{Qg.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(s,r,o)=>Sv(e,s,r),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(s,r)=>{const o={};for(const i of s)if(n.has(i))o[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ao({...t,checks:[],...ae(r),entries:o})},e.exclude=(s,r)=>{const o={...t.entries};for(const i of s)if(n.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Ao({...t,checks:[],...ae(r),entries:o})}});function Ru(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Ao({type:"enum",entries:n,...ae(t)})}const Ob=V("ZodLiteral",(e,t)=>{ey.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>_v(e,n,s,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function K(e,t){return new Ob({type:"literal",values:Array.isArray(e)?e:[e],...ae(t)})}const Ab=V("ZodTransform",(e,t)=>{Nr(),ty.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Iv(e,n,s,r),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Jc(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(_s(o,n.value,t));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=n.value),i.inst??(i.inst=e),n.issues.push(_s(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n)):(n.value=r,n)}});function $b(e){return new Ab({type:"transform",transform:e})}const zu=V("ZodOptional",(e,t)=>{uu.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Iu(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function La(e){return new zu({type:"optional",innerType:e})}const Tu=V("ZodExactOptional",(e,t)=>{ny.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Iu(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function Pb(e){return new Tu({type:"optional",innerType:e})}const Lb=V("ZodNullable",(e,t)=>{sy.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Av(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function Da(e){return new Lb({type:"nullable",innerType:e})}const Db=V("ZodDefault",(e,t)=>{ry.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Pv(e,n,s,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mb(e,t){return new Db({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Zc(t)}})}const Fb=V("ZodPrefault",(e,t)=>{oy.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Lv(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function Ub(e,t){return new Fb({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Zc(t)}})}const Ou=V("ZodNonOptional",(e,t)=>{iy.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>$v(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function Bb(e,t){return new Ou({type:"nonoptional",innerType:e,...ae(t)})}const Zb=V("ZodCatch",(e,t)=>{ay.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Dv(e,n,s,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Vb(e,t){return new Zb({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Yh(t)})}const qb=V("ZodPipe",(e,t)=>{ly.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Mv(e,n,s,r),e.in=t.in,e.out=t.out});function Ma(e,t){return new qb({type:"pipe",in:e,out:t})}const Hb=V("ZodReadonly",(e,t)=>{cy.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Fv(e,n,s,r),e.unwrap=()=>e._zod.def.innerType});function Wb(e){return new Hb({type:"readonly",innerType:e})}const Kb=V("ZodCustom",(e,t)=>{uy.init(e,t),Ze.init(e,t),e._zod.processJSONSchema=(n,s,r)=>Cv(e,n,s,r)});function Jb(e,t={}){return dv(Kb,e,t)}function Gb(e,t){return pv(e,t)}const Yb=S({_meta:P(y(),$()).nullish(),terminal:Ye().optional().default(!1)}),Xb=S({_meta:P(y(),$()).nullish(),label:y().nullish(),name:y(),optional:Ye().optional().default(!1),secret:Ye().optional().default(!0)}),Qb=S({_meta:P(y(),$()).nullish(),description:y().nullish(),id:y(),name:y()}),ex=S({_meta:P(y(),$()).nullish(),description:y().nullish(),id:y(),link:y().nullish(),name:y(),vars:se(Xb)}),tx=S({_meta:P(y(),$()).nullish(),args:se(y()).optional(),description:y().nullish(),env:P(y(),y()).optional(),id:y(),name:y()}),nx=ge([ex.and(S({type:K("env_var")})),tx.and(S({type:K("terminal")})),Qb]),sx=S({_meta:P(y(),$()).nullish(),methodId:y()}),rx=S({_meta:P(y(),$()).nullish()}),ox=S({_meta:P(y(),$()).nullish(),blob:y(),mimeType:y().nullish(),uri:y()}),ix=S({default:Ye().nullish(),description:y().nullish(),title:y().nullish()}),ax=S({_meta:P(y(),$()).nullish()}),lx=S({_meta:P(y(),$()).nullish()}),cx=S({amount:me(),currency:y()}),ux=S({_meta:P(y(),$()).nullish(),terminalId:y()}),dx=S({_meta:P(y(),$()).nullish()}),px=S({_meta:P(y(),$()).nullish(),newText:y(),oldText:y().nullish(),path:y()}),fx=S({_meta:P(y(),$()).nullish(),id:y()}),hx=S({_meta:P(y(),$()).nullish()}),mx=S({_meta:P(y(),$()).nullish()}),gx=ge([y(),me(),me(),Ye(),se(y())]),yx=S({content:P(y(),gx).nullish()}),vx=Rn(ge([yx.and(S({action:K("accept")})),S({action:K("decline")}),S({action:K("cancel")})]),S({_meta:P(y(),$()).nullish()})),bx=S({_meta:P(y(),$()).nullish()}),Au=y(),xx=S({_meta:P(y(),$()).nullish(),elicitationId:Au}),kx=K("object"),wx=K("string"),jx=S({_meta:P(y(),$()).nullish()}),Sx=S({_meta:P(y(),$()).nullish(),form:bx.nullish(),url:jx.nullish()}),$u=S({const:y(),title:y()}),Pu=S({_meta:P(y(),$()).nullish(),name:y(),value:y()}),_x=ge([K(-32700),K(-32600),K(-32601),K(-32602),K(-32603),K(-32800),K(-32e3),K(-32002),K(-32042),me().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),Lu=S({code:_x,data:$().optional(),message:y()}),Du=$(),Mu=$(),Fu=$(),Cx=S({_meta:P(y(),$()).nullish(),readTextFile:Ye().optional().default(!1),writeTextFile:Ye().optional().default(!1)}),Uu=S({_meta:P(y(),$()).nullish(),name:y(),value:y()}),Bu=S({_meta:P(y(),$()).nullish(),name:y(),title:y().nullish(),version:y()}),Ix=S({default:me().nullish(),description:y().nullish(),maximum:me().nullish(),minimum:me().nullish(),title:y().nullish()}),Nx=S({_meta:P(y(),$()).nullish()}),Ex=S({_meta:P(y(),$()).nullish()}),Rx=S({_meta:P(y(),$()).nullish(),cursor:y().nullish(),cwd:y().nullish()}),bi=ge([K("anthropic"),K("openai"),K("azure"),K("vertex"),K("bedrock"),y()]),zx=S({_meta:P(y(),$()).nullish()}),Tx=S({_meta:P(y(),$()).nullish(),logout:zx.nullish()}),Ox=S({_meta:P(y(),$()).nullish()}),Ax=S({_meta:P(y(),$()).nullish()}),$x=S({_meta:P(y(),$()).nullish(),acp:Ye().optional().default(!1),http:Ye().optional().default(!1),sse:Ye().optional().default(!1)}),Er=y(),Px=S({_meta:P(y(),$()).nullish(),connectionId:Er}),Lx=S({_meta:P(y(),$()).nullish(),connectionId:Er}),Zu=y(),Dx=S({_meta:P(y(),$()).nullish(),acpId:Zu}),Mx=S({_meta:P(y(),$()).nullish(),id:Zu,name:y()}),Fx=S({_meta:P(y(),$()).nullish(),headers:se(Uu),name:y(),url:y()}),Ux=S({_meta:P(y(),$()).nullish(),headers:se(Uu),name:y(),url:y()}),Bx=S({_meta:P(y(),$()).nullish(),args:se(y()),command:y(),env:se(Pu),name:y()}),Rr=ge([Fx.and(S({type:K("http")})),Ux.and(S({type:K("sse")})),Mx.and(S({type:K("acp")})),Bx]),Vu=S({_meta:P(y(),$()).nullish(),connectionId:Er,method:y(),params:P(y(),$()).nullish()}),qu=S({_meta:P(y(),$()).nullish(),connectionId:Er,method:y(),params:P(y(),$()).nullish()}),Hu=$(),xi=y(),Zx=S({_meta:P(y(),$()).nullish(),description:y().nullish(),modelId:xi,name:y()}),Vx=ge([K("error"),K("warning"),K("information"),K("hint")]),qx=S({_meta:P(y(),$()).nullish()}),Hx=S({_meta:P(y(),$()).nullish()}),Wx=S({_meta:P(y(),$()).nullish()}),Kx=S({_meta:P(y(),$()).nullish()}),Jx=S({_meta:P(y(),$()).nullish()}),Gx=S({_meta:P(y(),$()).nullish(),maxCount:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Yx=S({diff:y(),uri:y()}),Xx=S({endLine:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:y()}),Qx=S({_meta:P(y(),$()).nullish()}),ek=S({_meta:P(y(),$()).nullish()}),tk=S({languageId:y(),text:y(),uri:y()}),nk=S({_meta:P(y(),$()).nullish(),maxCount:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),sk=ge([K("rejected"),K("ignored"),K("replaced"),K("cancelled")]),rk=S({excerpts:se(Xx),uri:y()}),ok=S({_meta:P(y(),$()).nullish()}),ik=S({_meta:P(y(),$()).nullish()}),ak=S({name:y(),owner:y(),remoteUrl:y()}),lk=S({_meta:P(y(),$()).nullish()}),ck=S({_meta:P(y(),$()).nullish(),jump:Qx.nullish(),rename:ik.nullish(),searchAndReplace:lk.nullish()}),uk=S({id:y(),isRegex:Ye().nullish(),replace:y(),search:y(),uri:y()}),dk=ge([K("automatic"),K("diagnostic"),K("manual")]),pk=S({_meta:P(y(),$()).nullish(),maxCount:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),fk=S({_meta:P(y(),$()).nullish(),diagnostics:qx.nullish(),editHistory:Gx.nullish(),openFiles:ek.nullish(),recentFiles:nk.nullish(),relatedSnippets:ok.nullish(),userActions:pk.nullish()}),hk=S({_meta:P(y(),$()).nullish(),additionalDirectories:se(y()).optional(),cwd:y(),mcpServers:se(Rr)}),mk=S({default:me().nullish(),description:y().nullish(),maximum:me().nullish(),minimum:me().nullish(),title:y().nullish()}),Wu=y(),gk=ge([K("allow_once"),K("allow_always"),K("reject_once"),K("reject_always")]),yk=S({_meta:P(y(),$()).nullish(),kind:gk,name:y(),optionId:Wu}),vk=ge([K("high"),K("medium"),K("low")]),bk=ge([K("pending"),K("in_progress"),K("completed")]),xk=S({_meta:P(y(),$()).nullish(),content:y(),priority:vk,status:bk}),kk=S({_meta:P(y(),$()).nullish(),entries:se(xk)}),gn=S({character:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),wk=S({id:y(),position:gn,uri:y()}),jk=S({id:y(),newName:y(),position:gn,uri:y()}),Sk=S({action:y(),position:gn,timestampMs:me(),uri:y()}),Ku=ge([K("utf-16"),K("utf-32"),K("utf-8")]),_k=S({_meta:P(y(),$()).nullish(),auth:Yb.optional().default({terminal:!1}),elicitation:Sx.nullish(),fs:Cx.optional().default({readTextFile:!1,writeTextFile:!1}),nes:ck.nullish(),positionEncodings:se(Ku).optional(),terminal:Ye().optional().default(!1)}),Ck=S({_meta:P(y(),$()).nullish(),audio:Ye().optional().default(!1),embeddedContext:Ye().optional().default(!1),image:Ye().optional().default(!1)}),Ju=me().int().gte(0).lte(65535),Ik=S({_meta:P(y(),$()).nullish(),clientCapabilities:_k.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:Bu.nullish(),protocolVersion:Ju}),Nk=S({apiType:bi,baseUrl:y()}),Ek=S({_meta:P(y(),$()).nullish(),current:Nk.nullish(),id:y(),required:Ye(),supported:se(bi)}),Rk=S({_meta:P(y(),$()).nullish(),providers:se(Ek)}),zk=S({_meta:P(y(),$()).nullish()}),Qn=S({end:gn,start:gn}),Tk=S({message:y(),range:Qn,severity:Vx,uri:y()}),Ok=S({languageId:y(),lastFocusedMs:me().nullish(),uri:y(),visibleRange:Qn.nullish()}),Ak=S({_meta:P(y(),$()).nullish(),diagnostics:se(Tk).nullish(),editHistory:se(Yx).nullish(),openFiles:se(Ok).nullish(),recentFiles:se(tk).nullish(),relatedSnippets:se(rk).nullish(),userActions:se(Sk).nullish()}),$k=S({newText:y(),range:Qn}),Pk=S({cursorPosition:gn.nullish(),edits:se($k),id:y(),uri:y()}),Lk=ge([Pk.and(S({kind:K("edit")})),wk.and(S({kind:K("jump")})),jk.and(S({kind:K("rename")})),uk.and(S({kind:K("searchAndReplace")}))]),Dk=S({_meta:P(y(),$()).nullish(),content:y()}),Mk=S({_meta:P(y(),$()).nullish()}),yn=ge([me(),y()]).nullable();S({_meta:P(y(),$()).nullish(),requestId:yn});const Gu=S({requestId:yn}),Fk=Ru(["assistant","user"]),zs=S({_meta:P(y(),$()).nullish(),audience:se(Fk).nullish(),lastModified:y().nullish(),priority:me().nullish()}),Uk=S({_meta:P(y(),$()).nullish(),annotations:zs.nullish(),data:y(),mimeType:y()}),Bk=S({_meta:P(y(),$()).nullish(),annotations:zs.nullish(),data:y(),mimeType:y(),uri:y().nullish()}),Zk=S({_meta:P(y(),$()).nullish(),annotations:zs.nullish(),description:y().nullish(),mimeType:y().nullish(),name:y(),size:me().nullish(),title:y().nullish(),uri:y()}),Vk=S({_meta:P(y(),$()).nullish(),optionId:Wu}),qk=ge([S({outcome:K("cancelled")}),Vk.and(S({outcome:K("selected")}))]),Hk=S({_meta:P(y(),$()).nullish(),outcome:qk}),Wk=S({_meta:P(y(),$()).nullish()}),Kk=S({_meta:P(y(),$()).nullish()}),Jk=S({currentValue:Ye()}),Gk=y(),Yu=y(),Yk=ge([K("mode"),K("model"),K("thought_level"),y()]),ki=y(),Xu=S({_meta:P(y(),$()).nullish(),description:y().nullish(),name:y(),value:ki}),Xk=S({_meta:P(y(),$()).nullish(),group:Gk,name:y(),options:se(Xu)}),Qk=ge([se(Xu),se(Xk)]),ew=S({currentValue:ki,options:Qk}),es=Rn(ge([ew.and(S({type:K("select")})),Jk.and(S({type:K("boolean")}))]),S({_meta:P(y(),$()).nullish(),category:Yk.nullish(),description:y().nullish(),id:Yu,name:y()})),tw=S({_meta:P(y(),$()).nullish(),configOptions:se(es)}),nw=S({_meta:P(y(),$()).nullish()}),sw=S({_meta:P(y(),$()).nullish()}),Ne=y(),rw=S({_meta:P(y(),$()).nullish(),id:y(),sessionId:Ne}),ow=S({_meta:P(y(),$()).nullish(),sessionId:Ne}),iw=S({_meta:P(y(),$()).nullish(),sessionId:Ne}),aw=S({_meta:P(y(),$()).nullish(),sessionId:Ne}),lw=S({_meta:P(y(),$()).nullish(),args:se(y()).optional(),command:y(),cwd:y().nullish(),env:se(Pu).optional(),outputByteLimit:me().nullish(),sessionId:Ne}),cw=S({_meta:P(y(),$()).nullish(),sessionId:Ne}),uw=S({_meta:P(y(),$()).nullish(),sessionId:Ne,uri:y()}),dw=S({_meta:P(y(),$()).nullish(),position:gn,sessionId:Ne,uri:y(),version:me(),visibleRange:Qn}),pw=S({_meta:P(y(),$()).nullish(),languageId:y(),sessionId:Ne,text:y(),uri:y(),version:me()}),fw=S({_meta:P(y(),$()).nullish(),sessionId:Ne,uri:y()}),hw=S({_meta:P(y(),$()).nullish(),additionalDirectories:se(y()).optional(),cwd:y(),mcpServers:se(Rr).optional(),sessionId:Ne}),mw=S({_meta:P(y(),$()).nullish(),sessionId:Ne,terminalId:y()}),gw=S({_meta:P(y(),$()).nullish(),additionalDirectories:se(y()).optional(),cwd:y(),mcpServers:se(Rr),sessionId:Ne}),yw=S({_meta:P(y(),$()).nullish(),limit:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:y(),sessionId:Ne}),vw=S({_meta:P(y(),$()).nullish(),id:y(),reason:sk.nullish(),sessionId:Ne}),bw=S({_meta:P(y(),$()).nullish(),sessionId:Ne,terminalId:y()}),xw=S({_meta:P(y(),$()).nullish(),additionalDirectories:se(y()).optional(),cwd:y(),mcpServers:se(Rr).optional(),sessionId:Ne}),kw=S({_meta:P(y(),$()).nullish(),additionalDirectories:se(y()).optional(),cwd:y(),sessionId:Ne,title:y().nullish(),updatedAt:y().nullish()}),ww=S({_meta:P(y(),$()).nullish(),nextCursor:y().nullish(),sessions:se(kw)}),jw=S({_meta:P(y(),$()).nullish(),title:y().nullish(),updatedAt:y().nullish()}),Sw=S({_meta:P(y(),$()).nullish()}),zr=y(),_w=S({_meta:P(y(),$()).nullish(),currentModeId:zr}),Cw=S({_meta:P(y(),$()).nullish(),description:y().nullish(),id:zr,name:y()}),Tr=S({_meta:P(y(),$()).nullish(),availableModes:se(Cw),currentModeId:zr}),Or=S({_meta:P(y(),$()).nullish(),availableModels:se(Zx),currentModelId:xi}),Iw=S({_meta:P(y(),$()).nullish(),configOptions:se(es).nullish(),models:Or.nullish(),modes:Tr.nullish(),sessionId:Ne}),Nw=S({_meta:P(y(),$()).nullish(),configOptions:se(es).nullish(),models:Or.nullish(),modes:Tr.nullish()}),Ew=S({_meta:P(y(),$()).nullish(),configOptions:se(es).nullish(),models:Or.nullish(),modes:Tr.nullish(),sessionId:Ne}),Rw=S({_meta:P(y(),$()).nullish(),configOptions:se(es).nullish(),models:Or.nullish(),modes:Tr.nullish()}),zw=S({_meta:P(y(),$()).nullish()}),Tw=S({_meta:P(y(),$()).nullish(),additionalDirectories:Wk.nullish(),close:Kk.nullish(),delete:nw.nullish(),fork:sw.nullish(),list:Sw.nullish(),resume:zw.nullish()}),Ow=S({_meta:P(y(),$()).nullish(),apiType:bi,baseUrl:y(),headers:P(y(),y()).optional(),id:y()}),Aw=S({_meta:P(y(),$()).nullish()}),$w=Rn(ge([S({type:K("boolean"),value:Ye()}),S({value:ki})]),S({_meta:P(y(),$()).nullish(),configId:Yu,sessionId:Ne})),Pw=S({_meta:P(y(),$()).nullish(),configOptions:se(es)}),Lw=S({_meta:P(y(),$()).nullish(),modeId:zr,sessionId:Ne}),Dw=S({_meta:P(y(),$()).nullish()}),Mw=S({_meta:P(y(),$()).nullish(),modelId:xi,sessionId:Ne}),Fw=S({_meta:P(y(),$()).nullish()}),Uw=S({_meta:P(y(),$()).nullish(),sessionId:Ne}),Bw=ge([K("end_turn"),K("max_tokens"),K("max_turn_requests"),K("refusal"),K("cancelled")]),Zw=ge([K("email"),K("uri"),K("date"),K("date-time")]),Vw=S({default:y().nullish(),description:y().nullish(),enum:se(y()).nullish(),format:Zw.nullish(),maxLength:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:se($u).nullish(),pattern:y().nullish(),title:y().nullish()}),qw=S({_meta:P(y(),$()).nullish(),context:Ak.nullish(),position:gn,selection:Qn.nullish(),sessionId:Ne,triggerKind:dk,uri:y(),version:me()}),Hw=S({_meta:P(y(),$()).nullish(),suggestions:se(Lk)}),Ww=S({_meta:P(y(),$()).nullish(),terminalId:y()}),Kw=S({_meta:P(y(),$()).nullish(),exitCode:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:y().nullish()}),Jw=S({_meta:P(y(),$()).nullish(),sessionId:Ne,terminalId:y()}),Gw=S({_meta:P(y(),$()).nullish(),exitStatus:Kw.nullish(),output:y(),truncated:Ye()}),Yw=S({_meta:P(y(),$()).nullish(),annotations:zs.nullish(),text:y()}),Xw=S({range:Qn.nullish(),text:y()}),Qw=S({_meta:P(y(),$()).nullish(),contentChanges:se(Xw),sessionId:Ne,uri:y(),version:me()});S({method:y(),params:ge([ow,pw,Qw,uw,fw,dw,rw,vw,Vu,Du]).nullish()});const e0=ge([K("full"),K("incremental")]),t0=S({_meta:P(y(),$()).nullish(),syncKind:e0}),n0=S({_meta:P(y(),$()).nullish(),didChange:t0.nullish(),didClose:Hx.nullish(),didFocus:Wx.nullish(),didOpen:Kx.nullish(),didSave:Jx.nullish()}),s0=S({_meta:P(y(),$()).nullish(),document:n0.nullish()}),r0=S({_meta:P(y(),$()).nullish(),context:fk.nullish(),events:s0.nullish()}),o0=S({_meta:P(y(),$()).nullish(),auth:Tx.optional().default({}),loadSession:Ye().optional().default(!1),mcpCapabilities:$x.optional().default({acp:!1,http:!1,sse:!1}),nes:r0.nullish(),positionEncoding:Ku.nullish(),promptCapabilities:Ck.optional().default({audio:!1,embeddedContext:!1,image:!1}),providers:zk.nullish(),sessionCapabilities:Tw.optional().default({})}),i0=S({_meta:P(y(),$()).nullish(),agentCapabilities:o0.optional().default({auth:{},loadSession:!1,mcpCapabilities:{acp:!1,http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:Bu.nullish(),authMethods:se(nx).optional().default([]),protocolVersion:Ju}),a0=S({_meta:P(y(),$()).nullish(),mimeType:y().nullish(),text:y(),uri:y()}),l0=ge([a0,ox]),c0=S({_meta:P(y(),$()).nullish(),annotations:zs.nullish(),resource:l0}),wi=ge([Yw.and(S({type:K("text")})),Bk.and(S({type:K("image")})),Uk.and(S({type:K("audio")})),Zk.and(S({type:K("resource_link")})),c0.and(S({type:K("resource")}))]),u0=S({_meta:P(y(),$()).nullish(),content:wi}),Gr=S({_meta:P(y(),$()).nullish(),content:wi,messageId:y().nullish()}),d0=S({_meta:P(y(),$()).nullish(),messageId:y().nullish(),prompt:se(wi),sessionId:Ne}),p0=S({anyOf:se($u)}),Qu=ge([u0.and(S({type:K("content")})),px.and(S({type:K("diff")})),Ww.and(S({type:K("terminal")}))]),ji=y(),ed=S({sessionId:Ne,toolCallId:ji.nullish()}),f0=Rn(ge([ed,Gu]),S({elicitationId:Au,url:y().url()})),td=S({_meta:P(y(),$()).nullish(),line:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:y()}),nd=ge([K("pending"),K("in_progress"),K("completed"),K("failed")]),sd=ge([K("read"),K("edit"),K("delete"),K("move"),K("search"),K("execute"),K("think"),K("fetch"),K("switch_mode"),K("other")]),h0=S({_meta:P(y(),$()).nullish(),content:se(Qu).optional(),kind:sd.optional(),locations:se(td).optional(),rawInput:$().optional(),rawOutput:$().optional(),status:nd.optional(),title:y(),toolCallId:ji}),rd=S({_meta:P(y(),$()).nullish(),content:se(Qu).nullish(),kind:sd.nullish(),locations:se(td).nullish(),rawInput:$().optional(),rawOutput:$().optional(),status:nd.nullish(),title:y().nullish(),toolCallId:ji}),m0=S({_meta:P(y(),$()).nullish(),options:se(yk),sessionId:Ne,toolCall:rd}),g0=S({_meta:P(y(),$()).nullish(),hint:y()}),y0=g0,v0=S({_meta:P(y(),$()).nullish(),description:y(),input:y0.nullish(),name:y()}),b0=S({_meta:P(y(),$()).nullish(),availableCommands:se(v0)}),x0=S({enum:se(y()),type:wx}),k0=ge([x0,p0]),w0=S({default:se(y()).nullish(),description:y().nullish(),items:k0,maxItems:me().nullish(),minItems:me().nullish(),title:y().nullish()}),j0=ge([Vw.and(S({type:K("string")})),mk.and(S({type:K("number")})),Ix.and(S({type:K("integer")})),ix.and(S({type:K("boolean")})),w0.and(S({type:K("array")}))]),S0=S({description:y().nullish(),properties:P(y(),j0).optional().default({}),required:se(y()).nullish(),title:y().nullish(),type:kx.optional().default("object")}),_0=Rn(ge([ed,Gu]),S({requestedSchema:S0})),C0=Rn(ge([_0.and(S({mode:K("form")})),f0.and(S({mode:K("url")}))]),S({_meta:P(y(),$()).nullish(),message:y()})),I0=S({cachedReadTokens:me().nullish(),cachedWriteTokens:me().nullish(),inputTokens:me(),outputTokens:me(),thoughtTokens:me().nullish(),totalTokens:me()}),N0=S({_meta:P(y(),$()).nullish(),stopReason:Bw,usage:I0.nullish(),userMessageId:y().nullish()});ge([S({id:yn,result:ge([i0,rx,Rk,Aw,hx,Ax,Ew,Nw,ww,dx,Iw,Rw,lx,Dw,Pw,N0,Fw,Uw,Hw,ax,Fu,Hu])}),S({error:Lu,id:yn})]);const E0=S({_meta:P(y(),$()).nullish(),cost:cx.nullish(),size:me(),used:me()}),R0=ge([Gr.and(S({sessionUpdate:K("user_message_chunk")})),Gr.and(S({sessionUpdate:K("agent_message_chunk")})),Gr.and(S({sessionUpdate:K("agent_thought_chunk")})),h0.and(S({sessionUpdate:K("tool_call")})),rd.and(S({sessionUpdate:K("tool_call_update")})),kk.and(S({sessionUpdate:K("plan")})),b0.and(S({sessionUpdate:K("available_commands_update")})),_w.and(S({sessionUpdate:K("current_mode_update")})),tw.and(S({sessionUpdate:K("config_option_update")})),jw.and(S({sessionUpdate:K("session_info_update")})),E0.and(S({sessionUpdate:K("usage_update")}))]),z0=S({_meta:P(y(),$()).nullish(),sessionId:Ne,update:R0});S({method:y(),params:ge([z0,xx,Vu,Du]).nullish()});const T0=S({_meta:P(y(),$()).nullish(),sessionId:Ne,terminalId:y()}),O0=S({_meta:P(y(),$()).nullish(),exitCode:me().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:y().nullish()}),A0=S({name:y(),uri:y()}),$0=S({_meta:P(y(),$()).nullish(),repository:ak.nullish(),workspaceFolders:se(A0).nullish(),workspaceUri:y().nullish()});S({id:yn,method:y(),params:ge([Ik,sx,Ex,Ow,fx,Ox,hk,gw,Rx,cw,hw,xw,aw,Lw,$w,d0,Mw,$0,qw,iw,qu,Mu]).nullish()});const P0=S({_meta:P(y(),$()).nullish(),content:y(),path:y(),sessionId:Ne});S({id:yn,method:y(),params:ge([P0,yw,m0,lw,Jw,bw,T0,mw,C0,Dx,qu,Lx,Mu]).nullish()});const L0=S({_meta:P(y(),$()).nullish()});ge([S({id:yn,result:ge([L0,Dk,Hk,ux,Gw,Mk,O0,Nx,vx,Px,mx,Fu,Hu])}),S({error:Lu,id:yn})]);function Yr(e,t){for(const[n,s]of e)if(s.sessions.has(t))return n;return null}function Fa(e){return{cwd:e,activeSessionId:null,sessions:new Map,sessionListCursors:new Map}}Lc(e=>({agents:new Map,workspaces:new Map,activeWorkspaceCwd:null,pendingAuth:null,addWorkspace:t=>e(n=>{if(n.workspaces.has(t))return n;const s=new Map(n.workspaces);return s.set(t,Fa(t)),{workspaces:s}}),removeWorkspace:t=>e(n=>{const s=new Map(n.workspaces);if(s.delete(t),n.activeWorkspaceCwd!==t)return{workspaces:s};const r=Array.from(s.keys());if(r.length>0){const o=r[0];return{workspaces:s,activeWorkspaceCwd:o}}return{workspaces:s,activeWorkspaceCwd:null}}),setActiveWorkspace:t=>e(n=>{if(n.activeWorkspaceCwd===t)return n;const s=new Map(n.workspaces);return s.has(t)||s.set(t,Fa(t)),{workspaces:s,activeWorkspaceCwd:t}}),addAgent:t=>e(n=>{const s=new Map(n.agents);return s.set(t.id,t),{agents:s}}),removeAgent:t=>e(n=>{const s=new Map(n.agents);s.delete(t);const r=new Map(n.workspaces);for(const[o,i]of n.workspaces){const l=new Map(i.sessions);let c=!1;for(const[u,d]of i.sessions)d.agentId===t&&(l.delete(u),c=!0);if(c){let u=i.activeSessionId;u&&!l.has(u)&&(u=null),r.set(o,{...i,sessions:l,activeSessionId:u})}}return{agents:s,workspaces:r}}),updateAgent:(t,n)=>e(s=>{const r=s.agents.get(t);if(!r)return s;const o=new Map(s.agents);return o.set(t,{...r,...n}),{agents:o}}),setSessions:(t,n,s)=>e(r=>{const o=new Map(r.workspaces),i=o.get(s);if(!i)return r;const l=new Map(i.sessions);for(const[u,d]of i.sessions)d.agentId===n&&l.delete(u);for(const u of t)l.set(u.sessionId,{id:u.sessionId,title:u.title??void 0,cwd:u.cwd,updatedAt:u.updatedAt??void 0,agentId:n,loaded:!1});const c=new Map(i.sessionListCursors);return c.delete(n),o.set(s,{...i,sessions:l,sessionListCursors:c}),{workspaces:o}}),appendSessions:(t,n,s,r)=>e(o=>{const i=new Map(o.workspaces),l=i.get(s);if(!l)return o;const c=new Map(l.sessions);for(const d of t)c.set(d.sessionId,{id:d.sessionId,title:d.title??void 0,cwd:d.cwd,updatedAt:d.updatedAt??void 0,agentId:n,loaded:!1});const u=new Map(l.sessionListCursors);return r?u.set(n,r):u.delete(n),i.set(s,{...l,sessions:c,sessionListCursors:u}),{workspaces:i}}),addSession:t=>e(n=>{const s=new Map(n.workspaces),r=s.get(t.cwd);if(!r)return n;const o=new Map(r.sessions);return o.set(t.id,t),s.set(t.cwd,{...r,sessions:o}),{workspaces:s}}),removeSession:t=>e(n=>{const s=Yr(n.workspaces,t);if(!s)return n;const r=new Map(n.workspaces),o=r.get(s),i=new Map(o.sessions);return i.delete(t),r.set(s,{...o,sessions:i,activeSessionId:o.activeSessionId===t?null:o.activeSessionId}),{workspaces:r}}),updateSession:(t,n)=>e(s=>{const r=Yr(s.workspaces,t);if(!r)return s;const o=new Map(s.workspaces),i=o.get(r),l=i.sessions.get(t);if(!l)return s;const c=new Map(i.sessions);return c.set(t,{...l,...n}),o.set(r,{...i,sessions:c}),{workspaces:o}}),setActiveSession:t=>e(n=>{if(t===null){if(!n.activeWorkspaceCwd)return n;const i=new Map(n.workspaces),l=i.get(n.activeWorkspaceCwd);return!l||l.activeSessionId===null?n:(i.set(n.activeWorkspaceCwd,{...l,activeSessionId:null}),{workspaces:i})}const s=Yr(n.workspaces,t);if(!s)return n;const r=new Map(n.workspaces),o=r.get(s);return o&&o.activeSessionId===t?n:(o&&r.set(s,{...o,activeSessionId:t}),{workspaces:r})}),setAuthRequired:t=>e({pendingAuth:{agentId:t}}),clearAuthRequired:()=>e({pendingAuth:null})}));let D0=0;function Ua(e){return`${e}_${Date.now()}_${++D0}`}function Ba(){return{messages:[],isStreaming:!1,pendingToolCalls:new Map,stopReason:null,pendingPermissions:[],plan:[],usage:null,configOptions:[],availableCommands:[],terminals:new Map}}const od=Lc(e=>({sessions:new Map,ensureSession:t=>e(n=>{if(n.sessions.has(t))return n;const s=new Map(n.sessions);return s.set(t,Ba()),{sessions:s}}),removeSession:t=>e(n=>{const s=new Map(n.sessions);return s.delete(t),{sessions:s}}),resetSession:t=>e(n=>{const s=new Map(n.sessions);return s.set(t,Ba()),{sessions:s}}),addMessage:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions);return o.set(t,{...r,messages:[...r.messages,n]}),{sessions:o}}),updateMessage:(t,n,s)=>e(r=>{const o=r.sessions.get(t);if(!o)return r;const i=new Map(r.sessions);return i.set(t,{...o,messages:o.messages.map(l=>l.id===n?{...l,...s}:l)}),{sessions:i}}),appendContent:(t,n,s,r)=>e(o=>{const i=o.sessions.get(t);if(!i)return o;const l=i.messages.some(d=>d.id===n);let c;if(l)c=i.messages.map(d=>{if(d.id!==n)return d;const p=d.parts,f=p[p.length-1];if(f?.type==="content"){const h=f.content;if(h.length>0){const m=h[h.length-1];if(m.type==="text"&&r.type==="text"&&!("annotations"in r&&r.annotations!=null))return{...d,parts:[...p.slice(0,-1),{...f,content:[...h.slice(0,-1),{...m,text:m.text+r.text}]}]}}return{...d,parts:[...p.slice(0,-1),{...f,content:[...h,r]}]}}return{...d,parts:[...p,{type:"content",content:[r]}]}});else{const d={id:n,role:s,parts:[{type:"content",content:[r]}],timestamp:Date.now()};c=[...i.messages,d]}const u=new Map(o.sessions);return u.set(t,{...i,messages:c}),{sessions:u}}),appendThought:(t,n,s,r)=>e(o=>{const i=o.sessions.get(t);if(!i)return o;const l=i.messages.some(d=>d.id===n);let c;if(l)c=i.messages.map(d=>{if(d.id!==n)return d;const p=d.parts,f=p[p.length-1];if(f?.type==="thought"){const h=f.thought;if(h.length>0){const m=h[h.length-1];if(m.type==="text"&&r.type==="text"&&!("annotations"in r&&r.annotations!=null))return{...d,parts:[...p.slice(0,-1),{...f,thought:[...h.slice(0,-1),{...m,text:m.text+r.text}]}]}}return{...d,parts:[...p.slice(0,-1),{...f,thought:[...h,r]}]}}return{...d,parts:[...p,{type:"thought",thought:[r]}]}});else{const d={id:n,role:s,parts:[{type:"thought",thought:[r]}],timestamp:Date.now()};c=[...i.messages,d]}const u=new Map(o.sessions);return u.set(t,{...i,messages:c}),{sessions:u}}),setIsStreaming:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions);return o.set(t,{...r,isStreaming:n}),{sessions:o}}),setStopReason:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions);return o.set(t,{...r,stopReason:n}),{sessions:o}}),upsertToolCall:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions),i=new Map(r.pendingToolCalls),l=i.get(n.toolCallId);i.set(n.toolCallId,l?{...l,...n}:n);const c=r.messages[r.messages.length-1];let u;if(c&&c.role==="agent"){const d=c.parts,p=d[d.length-1];if(p?.type==="tool_calls"){const f=p.toolCalls,h=f.findIndex(m=>m.toolCallId===n.toolCallId);if(h>=0){const m=[...f];m[h]={...m[h],...n},u=[...r.messages.slice(0,-1),{...c,parts:[...d.slice(0,-1),{...p,toolCalls:m}]}]}else u=[...r.messages.slice(0,-1),{...c,parts:[...d.slice(0,-1),{...p,toolCalls:[...f,n]}]}]}else u=[...r.messages.slice(0,-1),{...c,parts:[...d,{type:"tool_calls",toolCalls:[n]}]}]}else u=[...r.messages,{id:Ua("msg"),role:"agent",parts:[{type:"tool_calls",toolCalls:[n]}],timestamp:Date.now()}];return o.set(t,{...r,pendingToolCalls:i,messages:u}),{sessions:o}}),updateToolCall:(t,n,s)=>e(r=>{const o=r.sessions.get(t);if(!o)return r;const i=o.pendingToolCalls.get(n);if(!i)return r;const l=new Map(o.pendingToolCalls),c={...i,...s,content:"content"in s?s.content??[]:i.content,locations:"locations"in s?s.locations??[]:i.locations};l.set(n,c);const u=o.messages.map(p=>{const f=p.parts.findIndex(h=>h.type==="tool_calls"&&h.toolCalls.some(m=>m.toolCallId===n));if(f>=0){const h=p.parts[f];if(h.type==="tool_calls"){const m=[...p.parts];return m[f]={...h,toolCalls:h.toolCalls.map(v=>v.toolCallId===n?c:v)},{...p,parts:m}}}return p}),d=new Map(r.sessions);return d.set(t,{...o,pendingToolCalls:l,messages:u}),{sessions:d}}),addPermissionRequest:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions);return o.set(t,{...r,pendingPermissions:[...r.pendingPermissions,n]}),{sessions:o}}),removePermissionRequest:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions);return o.set(t,{...r,pendingPermissions:r.pendingPermissions.filter(i=>i.id!==n)}),{sessions:o}}),setPlan:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=[...r.messages,{id:Ua("plan"),role:"agent",parts:[{type:"plan",plan:n}],timestamp:Date.now()}],i=new Map(s.sessions);return i.set(t,{...r,plan:n,messages:o}),{sessions:i}}),setUsage:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions);return o.set(t,{...r,usage:n}),{sessions:o}}),setConfigOptions:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions);return o.set(t,{...r,configOptions:n}),{sessions:o}}),setAvailableCommands:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(s.sessions);return o.set(t,{...r,availableCommands:n}),{sessions:o}}),addTerminal:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r)return s;const o=new Map(r.terminals);o.set(n.terminalId,n);const i=new Map(s.sessions);return i.set(t,{...r,terminals:o}),{sessions:i}}),updateTerminalOutput:(t,n,s,r)=>e(o=>{const i=o.sessions.get(t);if(!i)return o;const l=i.terminals.get(n);if(!l)return o;const c=new Map(i.terminals);c.set(n,{...l,output:s,truncated:r});const u=new Map(o.sessions);return u.set(t,{...i,terminals:c}),{sessions:u}}),updateTerminalExit:(t,n,s)=>e(r=>{const o=r.sessions.get(t);if(!o)return r;const i=o.terminals.get(n);if(!i)return r;const l=new Map(o.terminals);l.set(n,{...i,exitStatus:s});const c=new Map(r.sessions);return c.set(t,{...o,terminals:l}),{sessions:c}}),removeTerminal:(t,n)=>e(s=>{const r=s.sessions.get(t);if(!r||!r.terminals.has(n))return s;const o=new Map(r.terminals);o.delete(n);const i=new Map(s.sessions);return i.set(t,{...r,terminals:o}),{sessions:i}})}));g.createContext(null);const pe=e=>typeof e=="string",as=()=>{let e,t;const n=new Promise((s,r)=>{e=s,t=r});return n.resolve=e,n.reject=t,n},Za=e=>e==null?"":String(e),M0=(e,t,n)=>{e.forEach(s=>{t[s]&&(n[s]=t[s])})},F0=/###/g,Va=e=>e&&e.includes("###")?e.replace(F0,"."):e,qa=e=>!e||pe(e),ys=(e,t,n)=>{const s=pe(t)?t.split("."):t;let r=0;for(;r<s.length-1;){if(qa(e))return{};const o=Va(s[r]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++r}return qa(e)?{}:{obj:e,k:Va(s[r])}},Ha=(e,t,n)=>{const{obj:s,k:r}=ys(e,t,Object);if(s!==void 0||t.length===1){s[r]=n;return}let o=t[t.length-1],i=t.slice(0,t.length-1),l=ys(e,i,Object);for(;l.obj===void 0&&i.length;)o=`${i[i.length-1]}.${o}`,i=i.slice(0,i.length-1),l=ys(e,i,Object),l!=null&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},U0=(e,t,n,s)=>{const{obj:r,k:o}=ys(e,t,Object);r[o]=r[o]||[],r[o].push(n)},fr=(e,t)=>{const{obj:n,k:s}=ys(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,s))return n[s]},B0=(e,t,n)=>{const s=fr(e,n);return s!==void 0?s:fr(t,n)},id=(e,t,n)=>{for(const s in t)s!=="__proto__"&&s!=="constructor"&&(s in e?pe(e[s])||e[s]instanceof String||pe(t[s])||t[s]instanceof String?n&&(e[s]=t[s]):id(e[s],t[s],n):e[s]=t[s]);return e},Kt=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),Z0={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},V0=e=>pe(e)?e.replace(/[&<>"'\/]/g,t=>Z0[t]):e;class q0{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const s=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,s),this.regExpQueue.push(t),s}}const H0=[" ",",","?","!",";"],W0=new q0(20),K0=(e,t,n)=>{t=t||"",n=n||"";const s=H0.filter(i=>!t.includes(i)&&!n.includes(i));if(s.length===0)return!0;const r=W0.getRegExp(`(${s.map(i=>i==="?"?"\\?":i).join("|")})`);let o=!r.test(e);if(!o){const i=e.indexOf(n);i>0&&!r.test(e.substring(0,i))&&(o=!0)}return o},$o=(e,t,n=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const s=t.split(n);let r=e;for(let o=0;o<s.length;){if(!r||typeof r!="object")return;let i,l="";for(let c=o;c<s.length;++c)if(c!==o&&(l+=n),l+=s[c],i=r[l],i!==void 0){if(["string","number","boolean"].includes(typeof i)&&c<s.length-1)continue;o+=c-o+1;break}r=i}return r},Cs=e=>e?.replace(/_/g,"-"),J0={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){var n,s;(s=(n=console?.[e])==null?void 0:n.apply)==null||s.call(n,console,t)}};class hr{constructor(t,n={}){this.init(t,n)}init(t,n={}){this.prefix=n.prefix||"i18next:",this.logger=t||J0,this.options=n,this.debug=n.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,s,r){return r&&!this.debug?null:(t=t.map(o=>pe(o)?o.replace(/[\r\n\x00-\x1F\x7F]/g," "):o),pe(t[0])&&(t[0]=`${s}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new hr(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new hr(this.logger,t)}}var Zt=new hr;class Ar{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const r=this.observers[s].get(n)||0;this.observers[s].set(n,r+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}once(t,n){const s=(...r)=>{n(...r),this.off(t,s)};return this.on(t,s),this}emit(t,...n){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([s,r])=>{for(let o=0;o<r;o++)s(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,r])=>{for(let o=0;o<r;o++)s(t,...n)})}}class Wa extends Ar{constructor(t,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.includes(t)||this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,s,r={}){var o,i;const l=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,c=r.ignoreJSONStructure!==void 0?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let u;t.includes(".")?u=t.split("."):(u=[t,n],s&&(Array.isArray(s)?u.push(...s):pe(s)&&l?u.push(...s.split(l)):u.push(s)));const d=fr(this.data,u);return!d&&!n&&!s&&t.includes(".")&&(t=u[0],n=u[1],s=u.slice(2).join(".")),d||!c||!pe(s)?d:$o((i=(o=this.data)==null?void 0:o[t])==null?void 0:i[n],s,l)}addResource(t,n,s,r,o={silent:!1}){const i=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let l=[t,n];s&&(l=l.concat(i?s.split(i):s)),t.includes(".")&&(l=t.split("."),r=n,n=l[1]),this.addNamespaces(n),Ha(this.data,l,r),o.silent||this.emit("added",t,n,s,r)}addResources(t,n,s,r={silent:!1}){for(const o in s)(pe(s[o])||Array.isArray(s[o]))&&this.addResource(t,n,o,s[o],{silent:!0});r.silent||this.emit("added",t,n,s)}addResourceBundle(t,n,s,r,o,i={silent:!1,skipCopy:!1}){let l=[t,n];t.includes(".")&&(l=t.split("."),r=s,s=n,n=l[1]),this.addNamespaces(n);let c=fr(this.data,l)||{};i.skipCopy||(s=JSON.parse(JSON.stringify(s))),r?id(c,s,o):c={...c,...s},Ha(this.data,l,c),i.silent||this.emit("added",t,n,s)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var ad={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,s,r){return e.forEach(o=>{var i;t=((i=this.processors[o])==null?void 0:i.process(t,n,s,r))??t}),t}};const ld=Symbol("i18next/PATH_KEY");function G0(){const e=[],t=Object.create(null);let n;return t.get=(s,r)=>{var o;return(o=n?.revoke)==null||o.call(n),r===ld?e:(e.push(r),n=Proxy.revocable(s,t),n.proxy)},Proxy.revocable(Object.create(null),t).proxy}function Zn(e,t){const{[ld]:n}=e(G0()),s=t?.keySeparator??".",r=t?.nsSeparator??":",o=t?.enableSelector==="strict";if(n.length>1&&r){const i=t?.ns,l=o?Array.isArray(i)?i:i?[i]:null:Array.isArray(i)?i:null;if(l&&(o?l:l.length>1?l.slice(1):[]).includes(n[0]))return`${n[0]}${r}${n.slice(1).join(s)}`}return n.join(s)}const Xr=e=>!pe(e)&&typeof e!="boolean"&&typeof e!="number";class mr extends Ar{constructor(t,n={}){super(),M0(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Zt.create("translator"),this.checkedLoadedFor={}}changeLanguage(t){t&&(this.language=t)}exists(t,n={interpolation:{}}){const s={...n};if(t==null)return!1;const r=this.resolve(t,s);if(r?.res===void 0)return!1;const o=Xr(r.res);return!(s.returnObjects===!1&&o)}extractFromKey(t,n){let s=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=n.ns||this.options.defaultNS||[];const i=s&&t.includes(s),l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!K0(t,s,r);if(i&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:pe(o)?[o]:o};const u=t.split(s);(s!==r||s===r&&this.options.ns.includes(u[0]))&&(o=u.shift()),t=u.join(r)}return{key:t,namespaces:pe(o)?[o]:o}}translate(t,n,s){let r=typeof n=="object"?{...n}:n;if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),t==null)return"";typeof t=="function"&&(t=Zn(t,{...this.options,...r})),Array.isArray(t)||(t=[String(t)]),t=t.map(M=>typeof M=="function"?Zn(M,{...this.options,...r}):String(M));const o=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,i=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(t[t.length-1],r),u=c[c.length-1];let d=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const p=r.lng||this.language,f=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return f?o?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:u,usedParams:this.getUsedParamsDetails(r)}:`${u}${d}${l}`:o?{res:l,usedKey:l,exactUsedKey:l,usedLng:p,usedNS:u,usedParams:this.getUsedParamsDetails(r)}:l;const h=this.resolve(t,r);let m=h?.res;const v=h?.usedKey||l,b=h?.exactUsedKey||l,k=["[object Number]","[object Function]","[object RegExp]"],z=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,R=!this.i18nFormat||this.i18nFormat.handleAsObject,A=r.count!==void 0&&!pe(r.count),D=mr.hasDefaultValue(r),O=A?this.pluralResolver.getSuffix(p,r.count,r):"",I=r.ordinal&&A?this.pluralResolver.getSuffix(p,r.count,{ordinal:!1}):"",F=A&&!r.ordinal&&r.count===0,L=F&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${O}`]||r[`defaultValue${I}`]||r.defaultValue;let j=m;R&&!m&&D&&(j=L);const x=Xr(j),C=Object.prototype.toString.apply(j);if(R&&j&&x&&!k.includes(C)&&!(pe(z)&&Array.isArray(j))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const M=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,j,{...r,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return o?(h.res=M,h.usedParams=this.getUsedParamsDetails(r),h):M}if(i){const M=Array.isArray(j),E=M?[]:{},T=M?b:v;for(const B in j)if(Object.prototype.hasOwnProperty.call(j,B)){const Y=`${T}${i}${B}`;D&&!m?E[B]=this.translate(Y,{...r,defaultValue:Xr(L)?L[B]:void 0,joinArrays:!1,ns:c}):E[B]=this.translate(Y,{...r,joinArrays:!1,ns:c}),E[B]===Y&&(E[B]=j[B])}m=E}}else if(R&&pe(z)&&Array.isArray(m))m=m.join(z),m&&(m=this.extendTranslation(m,t,r,s));else{let M=!1,E=!1;!this.isValidLookup(m)&&D&&(M=!0,m=L),this.isValidLookup(m)||(E=!0,m=l);const T=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&E?void 0:m,B=D&&L!==m&&this.options.updateMissing;if(E||M||B){if(this.logger.log(B?"updateKey":"missingKey",p,u,A&&!B?`${l}${this.pluralResolver.getSuffix(p,r.count,r)}`:l,B?L:m),i){const w=this.resolve(l,{...r,keySeparator:!1});w&&w.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Y=[];const re=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&re&&re[0])for(let w=0;w<re.length;w++)Y.push(re[w]);else this.options.saveMissingTo==="all"?Y=this.languageUtils.toResolveHierarchy(r.lng||this.language):Y.push(r.lng||this.language);const oe=(w,U,ne)=>{var _;const ue=D&&ne!==m?ne:T;this.options.missingKeyHandler?this.options.missingKeyHandler(w,u,U,ue,B,r):(_=this.backendConnector)!=null&&_.saveMissing&&this.backendConnector.saveMissing(w,u,U,ue,B,r),this.emit("missingKey",w,u,U,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?Y.forEach(w=>{const U=this.pluralResolver.getSuffixes(w,r);F&&r[`defaultValue${this.options.pluralSeparator}zero`]&&!U.includes(`${this.options.pluralSeparator}zero`)&&U.push(`${this.options.pluralSeparator}zero`),U.forEach(ne=>{oe([w],l+ne,r[`defaultValue${ne}`]||L)})}):oe(Y,l,L))}m=this.extendTranslation(m,t,r,h,s),E&&m===l&&this.options.appendNamespaceToMissingKey&&(m=`${u}${d}${l}`),(E||M)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,M?m:void 0,r))}return o?(h.res=m,h.usedParams=this.getUsedParamsDetails(r),h):m}extendTranslation(t,n,s,r,o){var i,l;if((i=this.i18nFormat)!=null&&i.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const d=pe(t)&&(((l=s?.interpolation)==null?void 0:l.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let p;if(d){const h=t.match(this.interpolator.nestingRegexp);p=h&&h.length}let f=s.replace&&!pe(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,s.lng||this.language||r.usedLng,s),d){const h=t.match(this.interpolator.nestingRegexp),m=h&&h.length;p<m&&(s.nest=!1)}!s.lng&&r&&r.res&&(s.lng=this.language||r.usedLng),s.nest!==!1&&(t=this.interpolator.nest(t,(...h)=>o?.[0]===h[0]&&!s.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),s)),s.interpolation&&this.interpolator.reset()}const c=s.postProcess||this.options.postProcess,u=pe(c)?[c]:c;return t!=null&&u!=null&&u.length&&s.applyPostProcessor!==!1&&(t=ad.handle(u,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),t}resolve(t,n={}){let s,r,o,i,l;return pe(t)&&(t=[t]),Array.isArray(t)&&(t=t.map(c=>typeof c=="function"?Zn(c,{...this.options,...n}):c)),t.forEach(c=>{if(this.isValidLookup(s))return;const u=this.extractFromKey(c,n),d=u.key;r=d;let p=u.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const f=n.count!==void 0&&!pe(n.count),h=f&&!n.ordinal&&n.count===0,m=n.context!==void 0&&(pe(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(b=>{var k,z;this.isValidLookup(s)||(l=b,!this.checkedLoadedFor[`${v[0]}-${b}`]&&(k=this.utils)!=null&&k.hasLoadedNamespace&&!((z=this.utils)!=null&&z.hasLoadedNamespace(l))&&(this.checkedLoadedFor[`${v[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(R=>{var A;if(this.isValidLookup(s))return;i=R;const D=[d];if((A=this.i18nFormat)!=null&&A.addLookupKeys)this.i18nFormat.addLookupKeys(D,d,R,b,n);else{let I;f&&(I=this.pluralResolver.getSuffix(R,n.count,n));const F=`${this.options.pluralSeparator}zero`,L=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(f&&(n.ordinal&&I.startsWith(L)&&D.push(d+I.replace(L,this.options.pluralSeparator)),D.push(d+I),h&&D.push(d+F)),m){const j=`${d}${this.options.contextSeparator||"_"}${n.context}`;D.push(j),f&&(n.ordinal&&I.startsWith(L)&&D.push(j+I.replace(L,this.options.pluralSeparator)),D.push(j+I),h&&D.push(j+F))}}let O;for(;O=D.pop();)this.isValidLookup(s)||(o=O,s=this.getResource(R,b,O,n))}))})}),{res:s,usedKey:r,exactUsedKey:o,usedLng:i,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,s,r={}){var o;return(o=this.i18nFormat)!=null&&o.getResource?this.i18nFormat.getResource(t,n,s,r):this.resourceStore.getResource(t,n,s,r)}getUsedParamsDetails(t={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=t.replace&&!pe(t.replace);let r=s?t.replace:t;if(s&&typeof t.count<"u"&&(r.count=t.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!s){r={...r};for(const o of n)delete r[o]}return r}static hasDefaultValue(t){const n="defaultValue";for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&s.startsWith(n)&&t[s]!==void 0)return!0;return!1}}class Ka{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Zt.create("languageUtils")}getScriptPartFromCode(t){if(t=Cs(t),!t||!t.includes("-"))return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=Cs(t),!t||!t.includes("-"))return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(pe(t)&&t.includes("-")){let n;try{n=Intl.getCanonicalLocales(t)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(t)}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(s=>{if(n)return;const r=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(r))&&(n=r)}),!n&&this.options.supportedLngs&&t.forEach(s=>{if(n)return;const r=this.getScriptPartFromCode(s);if(this.isSupportedCode(r))return n=r;const o=this.getLanguagePartFromCode(s);if(this.isSupportedCode(o))return n=o;n=this.options.supportedLngs.find(i=>i===o?!0:!i.includes("-")&&!o.includes("-")?!1:!!(i.includes("-")&&!o.includes("-")&&i.slice(0,i.indexOf("-"))===o||i.startsWith(o)&&o.length>1))}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),pe(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let s=t[n];return s||(s=t[this.getScriptPartFromCode(n)]),s||(s=t[this.formatLanguageCode(n)]),s||(s=t[this.getLanguagePartFromCode(n)]),s||(s=t.default),s||[]}toResolveHierarchy(t,n){const s=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],t),r=[],o=i=>{i&&(this.isSupportedCode(i)?r.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return pe(t)&&(t.includes("-")||t.includes("_"))?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):pe(t)&&o(this.formatLanguageCode(t)),s.forEach(i=>{r.includes(i)||o(this.formatLanguageCode(i))}),r}}const Ja={zero:0,one:1,two:2,few:3,many:4,other:5},Ga={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Y0{constructor(t,n={}){this.languageUtils=t,this.options=n,this.logger=Zt.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(t,n={}){const s=Cs(t==="dev"?"en":t),r=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:s,type:r});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let i;try{i=new Intl.PluralRules(s,{type:r})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),Ga;if(!t.match(/-|_/))return Ga;const l=this.languageUtils.getLanguagePartFromCode(t);i=this.getRule(l,n)}return this.pluralRulesCache[o]=i,i}needsPlural(t,n={}){let s=this.getRule(t,n);return s||(s=this.getRule("dev",n)),s?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,n,s={}){return this.getSuffixes(t,s).map(r=>`${n}${r}`)}getSuffixes(t,n={}){let s=this.getRule(t,n);return s||(s=this.getRule("dev",n)),s?s.resolvedOptions().pluralCategories.sort((r,o)=>Ja[r]-Ja[o]).map(r=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(t,n,s={}){const r=this.getRule(t,s);return r?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${r.select(n)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",n,s))}}const Ya=(e,t,n,s=".",r=!0)=>{let o=B0(e,t,n);return!o&&r&&pe(n)&&(o=$o(e,n,s),o===void 0&&(o=$o(t,n,s))),o},Qr=e=>e.replace(/\$/g,"$$$$");class Xa{constructor(t={}){var n;this.logger=Zt.create("interpolator"),this.options=t,this.format=((n=t?.interpolation)==null?void 0:n.format)||(s=>s),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:s,useRawValueToEscape:r,prefix:o,prefixEscaped:i,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:p,nestingPrefix:f,nestingPrefixEscaped:h,nestingSuffix:m,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:k,alwaysFormat:z}=t.interpolation;this.escape=n!==void 0?n:V0,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=o?Kt(o):i||"{{",this.suffix=l?Kt(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":p?Kt(p):"-",this.unescapeSuffix=this.unescapePrefix?"":d?Kt(d):"",this.nestingPrefix=f?Kt(f):h||Kt("$t("),this.nestingSuffix=m?Kt(m):v||Kt(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=k||1e3,this.alwaysFormat=z!==void 0?z:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,s)=>n?.source===s?(n.lastIndex=0,n):new RegExp(s,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(t,n,s,r){var o;let i,l,c;const u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(!h.includes(this.formatSeparator)){const k=Ya(n,u,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(k,void 0,s,{...r,...n,interpolationkey:h}):k}const m=h.split(this.formatSeparator),v=m.shift().trim(),b=m.join(this.formatSeparator).trim();return this.format(Ya(n,u,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,s,{...r,...n,interpolationkey:v})};this.resetRegExp(),!this.escapeValue&&typeof t=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(t)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const p=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=((o=r?.interpolation)==null?void 0:o.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Qr(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Qr(this.escape(h)):Qr(h)}].forEach(h=>{for(c=0;i=h.regex.exec(t);){const m=i[1].trim();if(l=d(m),l===void 0)if(typeof p=="function"){const b=p(t,i,r);l=pe(b)?b:""}else if(r&&Object.prototype.hasOwnProperty.call(r,m))l="";else if(f){l=i[0];continue}else this.logger.warn(`missed to pass in variable ${m} for interpolating ${t}`),l="";else!pe(l)&&!this.useRawValueToEscape&&(l=Za(l));const v=h.safeValue(l);if(t=t.replace(i[0],v),f?(h.regex.lastIndex+=l.length,h.regex.lastIndex-=i[0].length):h.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),t}nest(t,n,s={}){let r,o,i;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(!c.includes(d))return c;const p=c.split(new RegExp(`${Kt(d)}[ ]*{`));let f=`{${p[1]}`;c=p[0],f=this.interpolate(f,i);const h=f.match(/'/g),m=f.match(/"/g);((h?.length??0)%2===0&&!m||(m?.length??0)%2!==0)&&(f=f.replace(/'/g,'"'));try{i=JSON.parse(f),u&&(i={...u,...i})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${f}`}return i.defaultValue&&i.defaultValue.includes(this.prefix)&&delete i.defaultValue,c};for(;r=this.nestingRegexp.exec(t);){let c=[];i={...s},i=i.replace&&!pe(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;const u=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(u!==-1&&(c=r[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),r[1]=r[1].slice(0,u)),o=n(l.call(this,r[1].trim(),i),i),o&&r[0]===t&&!pe(o))return o;pe(o)||(o=Za(o)),o||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${t}`),o=""),c.length&&(o=c.reduce((d,p)=>this.format(d,p,s.lng,{...s,interpolationkey:r[1].trim()}),o.trim())),t=t.replace(r[0],o),this.regexp.lastIndex=0}return t}}const X0=e=>{let t=e.toLowerCase().trim();const n={};if(e.includes("(")){const s=e.split("(");t=s[0].toLowerCase().trim();const r=s[1].slice(0,-1);t==="currency"&&!r.includes(":")?n.currency||(n.currency=r.trim()):t==="relativetime"&&!r.includes(":")?n.range||(n.range=r.trim()):r.split(";").forEach(o=>{if(o){const[i,...l]=o.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),u=i.trim();n[u]||(n[u]=c),c==="false"&&(n[u]=!1),c==="true"&&(n[u]=!0),isNaN(c)||(n[u]=parseInt(c,10))}})}return{formatName:t,formatOptions:n}},Qa=e=>{const t={};return(n,s,r)=>{let o=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(o={...o,[r.interpolationkey]:void 0});const i=s+JSON.stringify(o);let l=t[i];return l||(l=e(Cs(s),r),t[i]=l),l(n)}},Q0=e=>(t,n,s)=>e(Cs(n),s)(t);class ej{constructor(t={}){this.logger=Zt.create("formatter"),this.options=t,this.init(t)}init(t,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const s=n.cacheInBuiltFormats?Qa:Q0;this.formats={number:s((r,o)=>{const i=new Intl.NumberFormat(r,{...o});return l=>i.format(l)}),currency:s((r,o)=>{const i=new Intl.NumberFormat(r,{...o,style:"currency"});return l=>i.format(l)}),datetime:s((r,o)=>{const i=new Intl.DateTimeFormat(r,{...o});return l=>i.format(l)}),relativetime:s((r,o)=>{const i=new Intl.RelativeTimeFormat(r,{...o});return l=>i.format(l,o.range||"day")}),list:s((r,o)=>{const i=new Intl.ListFormat(r,{...o});return l=>i.format(l)})}}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Qa(n)}format(t,n,s,r={}){if(!n||t==null)return t;const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&!o[0].includes(")")&&o.find(i=>i.includes(")"))){const i=o.findIndex(l=>l.includes(")"));o[0]=[o[0],...o.splice(1,i)].join(this.formatSeparator)}return o.reduce((i,l)=>{var c;const{formatName:u,formatOptions:d}=X0(l);if(this.formats[u]){let p=i;try{const f=((c=r?.formatParams)==null?void 0:c[r.interpolationkey])||{},h=f.locale||f.lng||r.locale||r.lng||s;p=this.formats[u](i,h,{...d,...r,...f})}catch(f){this.logger.warn(f)}return p}else this.logger.warn(`there was no format function for ${u}`);return i},t)}}const tj=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class nj extends Ar{constructor(t,n,s,r={}){var o,i;super(),this.backend=t,this.store=n,this.services=s,this.languageUtils=s.languageUtils,this.options=r,this.logger=Zt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],(i=(o=this.backend)==null?void 0:o.init)==null||i.call(o,s,r.backend,r)}queueLoad(t,n,s,r){const o={},i={},l={},c={};return t.forEach(u=>{let d=!0;n.forEach(p=>{const f=`${u}|${p}`;!s.reload&&this.store.hasResourceBundle(u,p)?this.state[f]=2:this.state[f]<0||(this.state[f]===1?i[f]===void 0&&(i[f]=!0):(this.state[f]=1,d=!1,i[f]===void 0&&(i[f]=!0),o[f]===void 0&&(o[f]=!0),c[p]===void 0&&(c[p]=!0)))}),d||(l[u]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,s){const r=t.split("|"),o=r[0],i=r[1];n&&this.emit("failedLoading",o,i,n),!n&&s&&this.store.addResourceBundle(o,i,s,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&s&&(this.state[t]=0);const l={};this.queue.forEach(c=>{U0(c.loaded,[o],i),tj(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(p=>{l[u][p]===void 0&&(l[u][p]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,s,r=0,o=this.retryTimeout,i){if(!t.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:s,tried:r,wait:o,callback:i});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(u&&d&&r<this.maxRetries){setTimeout(()=>{this.read(t,n,s,r+1,o*2,i)},o);return}i(u,d)},c=this.backend[s].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(t,n,l)}prepareLoading(t,n,s={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();pe(t)&&(t=this.languageUtils.toResolveHierarchy(t)),pe(n)&&(n=[n]);const o=this.queueLoad(t,n,s,r);if(!o.toLoad.length)return o.pending.length||r(),null;o.toLoad.forEach(i=>{this.loadOne(i)})}load(t,n,s){this.prepareLoading(t,n,{},s)}reload(t,n,s){this.prepareLoading(t,n,{reload:!0},s)}loadOne(t,n=""){const s=t.split("|"),r=s[0],o=s[1];this.read(r,o,"read",void 0,void 0,(i,l)=>{i&&this.logger.warn(`${n}loading namespace ${o} for language ${r} failed`,i),!i&&l&&this.logger.log(`${n}loaded namespace ${o} for language ${r}`,l),this.loaded(t,i,l)})}saveMissing(t,n,s,r,o,i={},l=()=>{}){var c,u,d,p,f;if((u=(c=this.services)==null?void 0:c.utils)!=null&&u.hasLoadedNamespace&&!((p=(d=this.services)==null?void 0:d.utils)!=null&&p.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${s}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if((f=this.backend)!=null&&f.create){const h={...i,isUpdate:o},m=this.backend.create.bind(this.backend);if(m.length<6)try{let v;m.length===5?v=m(t,n,s,r,h):v=m(t,n,s,r),v&&typeof v.then=="function"?v.then(b=>l(null,b)).catch(l):l(null,v)}catch(v){l(v)}else m(t,n,s,r,l,h)}!t||!t[0]||this.store.addResource(t[0],n,s,r)}}}const eo=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),pe(e[1])&&(t.defaultValue=e[1]),pe(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(s=>{t[s]=n[s]})}return t},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),el=e=>(pe(e.ns)&&(e.ns=[e.ns]),pe(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),pe(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Us=()=>{},sj=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]=="function"&&(e[t]=e[t].bind(e))})};class vs extends Ar{constructor(t={},n){if(super(),this.options=el(t),this.services={},this.logger=Zt,this.modules={external:[]},sj(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(t={},n){this.isInitializing=!0,typeof t=="function"&&(n=t,t={}),t.defaultNS==null&&t.ns&&(pe(t.ns)?t.defaultNS=t.ns:t.ns.includes("translation")||(t.defaultNS=t.ns[0]));const s=eo();this.options={...s,...this.options,...el(t)},this.options.interpolation={...s.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=s.overloadTranslationOptionHandler);const r=l=>l?typeof l=="function"?new l:l:null;if(!this.options.isClone){this.modules.logger?Zt.init(r(this.modules.logger),this.options):Zt.init(null,this.options);let l;this.modules.formatter?l=this.modules.formatter:l=ej;const c=new Ka(this.options);this.store=new Wa(this.options.resources,this.options);const u=this.services;u.logger=Zt,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new Y0(c,{prepend:this.options.pluralSeparator}),l&&(u.formatter=r(l),u.formatter.init&&u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new Xa(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new nj(r(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",(d,...p)=>{this.emit(d,...p)}),this.modules.languageDetector&&(u.languageDetector=r(this.modules.languageDetector),u.languageDetector.init&&u.languageDetector.init(u,this.options.detection,this.options)),this.modules.i18nFormat&&(u.i18nFormat=r(this.modules.i18nFormat),u.i18nFormat.init&&u.i18nFormat.init(this)),this.translator=new mr(this.services,this.options),this.translator.on("*",(d,...p)=>{this.emit(d,...p)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Us),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&l[0]!=="dev"&&(this.options.lng=l[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(l=>{this[l]=(...c)=>this.store[l](...c)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(l=>{this[l]=(...c)=>(this.store[l](...c),this)});const o=as(),i=()=>{const l=(c,u)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(u),n(c,u)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return l(null,this.t.bind(this));this.changeLanguage(this.options.lng,l)};return this.options.resources||!this.options.initAsync?i():setTimeout(i,0),o}loadResources(t,n=Us){var s,r;let o=n;const i=pe(t)?t:this.language;if(typeof t=="function"&&(o=t),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return o();const l=[],c=u=>{!u||u==="cimode"||this.services.languageUtils.toResolveHierarchy(u).forEach(d=>{d!=="cimode"&&(l.includes(d)||l.push(d))})};i?c(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>c(u)),(r=(s=this.options.preload)==null?void 0:s.forEach)==null||r.call(s,u=>c(u)),this.services.backendConnector.load(l,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),o(u)})}else o(null)}reloadResources(t,n,s){const r=as();return typeof t=="function"&&(s=t,t=void 0),typeof n=="function"&&(s=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),s||(s=Us),this.services.backendConnector.reload(t,n,o=>{r.resolve(),s(o)}),r}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&ad.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!["cimode","dev"].includes(t)){for(let n=0;n<this.languages.length;n++){const s=this.languages[n];if(!["cimode","dev"].includes(s)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}!this.resolvedLanguage&&!this.languages.includes(t)&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,n){this.isLanguageChangingTo=t;const s=as();this.emit("languageChanging",t);const r=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(l,c)=>{c?this.isLanguageChangingTo===t&&(r(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,s.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},i=l=>{var c,u;!t&&!l&&this.services.languageDetector&&(l=[]);const d=pe(l)?l:l&&l[0],p=this.store.hasLanguageSomeTranslations(d)?d:this.services.languageUtils.getBestMatchFromCodes(pe(l)?[l]:l);p&&(this.language||r(p),this.translator.language||this.translator.changeLanguage(p),(u=(c=this.services.languageDetector)==null?void 0:c.cacheUserLanguage)==null||u.call(c,p)),this.loadResources(p,f=>{o(f,p)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?i(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(i):this.services.languageDetector.detect(i):i(t),s}getFixedT(t,n,s,r){const o=r?.scopeNs,i=(l,c,...u)=>{let d;typeof c!="object"?d=this.options.overloadTranslationOptionHandler([l,c].concat(u)):d={...c},d.lng=d.lng||i.lng,d.lngs=d.lngs||i.lngs;const p=d.ns!==void 0&&d.ns!==null;d.ns=d.ns||i.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||s||i.keyPrefix);const f={...this.options,...d};Array.isArray(o)&&!p&&(f.ns=o),typeof d.keyPrefix=="function"&&(d.keyPrefix=Zn(d.keyPrefix,f));const h=this.options.keySeparator||".";let m;return d.keyPrefix&&Array.isArray(l)?m=l.map(v=>(typeof v=="function"&&(v=Zn(v,f)),`${d.keyPrefix}${h}${v}`)):(typeof l=="function"&&(l=Zn(l,f)),m=d.keyPrefix?`${d.keyPrefix}${h}${l}`:l),this.t(m,d)};return pe(t)?i.lng=t:i.lngs=t,i.ns=n,i.keyPrefix=s,i}t(...t){var n;return(n=this.translator)==null?void 0:n.translate(...t)}exists(...t){var n;return(n=this.translator)==null?void 0:n.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=n.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const i=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,i);if(l!==void 0)return l}return!!(this.hasResourceBundle(s,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(s,t)&&(!r||i(o,t)))}loadNamespaces(t,n){const s=as();return this.options.ns?(pe(t)&&(t=[t]),t.forEach(r=>{this.options.ns.includes(r)||this.options.ns.push(r)}),this.loadResources(r=>{s.resolve(),n&&n(r)}),s):(n&&n(),Promise.resolve())}loadLanguages(t,n){const s=as();pe(t)&&(t=[t]);const r=this.options.preload||[],o=t.filter(i=>!r.includes(i)&&this.services.languageUtils.isSupportedCode(i));return o.length?(this.options.preload=r.concat(o),this.loadResources(i=>{s.resolve(),n&&n(i)}),s):(n&&n(),Promise.resolve())}dir(t){var n,s;if(t||(t=this.resolvedLanguage||(((n=this.languages)==null?void 0:n.length)>0?this.languages[0]:this.language)),!t)return"rtl";try{const i=new Intl.Locale(t);if(i&&i.getTextInfo){const l=i.getTextInfo();if(l&&l.direction)return l.direction}}catch{}const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=((s=this.services)==null?void 0:s.languageUtils)||new Ka(eo());return t.toLowerCase().indexOf("-latn")>1?"ltr":r.includes(o.getLanguagePartFromCode(t))||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},n){const s=new vs(t,n);return s.createInstance=vs.createInstance,s}cloneInstance(t={},n=Us){const s=t.forkResourceStore;s&&delete t.forkResourceStore;const r={...this.options,...t,isClone:!0},o=new vs(r);if((t.debug!==void 0||t.prefix!==void 0)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(i=>{o[i]=this[i]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},s){const i=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((u,d)=>(u[d]={...l[c][d]},u),l[c]),l),{});o.store=new Wa(i,r),o.services.resourceStore=o.store}if(t.interpolation){const i={...eo().interpolation,...this.options.interpolation,...t.interpolation},l={...r,interpolation:i};o.services.interpolator=new Xa(l)}return o.translator=new mr(o.services,r),o.translator.on("*",(i,...l)=>{o.emit(i,...l)}),o.init(r,n),o.translator.options=r,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const mt=vs.createInstance(),rj=mt.createInstance;mt.dir;mt.init;mt.loadResources;mt.reloadResources;mt.use;mt.changeLanguage;mt.getFixedT;mt.t;mt.exists;mt.setDefaultNamespace;mt.hasLoadedNamespace;mt.loadNamespaces;mt.loadLanguages;function cd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const oj=(e,t,n,s)=>{var r,o,i,l;const c=[n,{code:t,...s||{}}];if((o=(r=e?.services)==null?void 0:r.logger)!=null&&o.forward)return e.services.logger.forward(c,"warn","react-i18next::",!0);Nn(c[0])&&(c[0]=`react-i18next:: ${c[0]}`),(l=(i=e?.services)==null?void 0:i.logger)!=null&&l.warn?e.services.logger.warn(...c):console!=null&&console.warn&&console.warn(...c)},tl={},Po=(e,t,n,s)=>{Nn(n)&&tl[n]||(Nn(n)&&(tl[n]=new Date),oj(e,t,n,s))},ud=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}},Lo=(e,t,n)=>{e.loadNamespaces(t,ud(e,n))},nl=(e,t,n,s)=>{if(Nn(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Lo(e,n,s);n.forEach(r=>{e.options.ns.indexOf(r)<0&&e.options.ns.push(r)}),e.loadLanguages(t,ud(e,s))},ij=(e,t,n={})=>!t.languages||!t.languages.length?(Po(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,r)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!r(s.isLanguageChangingTo,e))return!1}}),Nn=e=>typeof e=="string",aj=e=>typeof e=="object"&&e!==null,lj=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,cj={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},uj=e=>cj[e],dj=e=>e.replace(lj,uj);let Do={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:dj,transDefaultProps:void 0};const pj=(e={})=>{Do={...Do,...e}},fj=()=>Do;let dd;const hj=e=>{dd=e},mj=()=>dd,gj={type:"3rdParty",init(e){pj(e.options.react),hj(e)}},pd=g.createContext();class yj{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var sl={exports:{}},to={};/**
|
|
261
|
+
* @license React
|
|
262
|
+
* use-sync-external-store-shim.production.js
|
|
263
|
+
*
|
|
264
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
265
|
+
*
|
|
266
|
+
* This source code is licensed under the MIT license found in the
|
|
267
|
+
* LICENSE file in the root directory of this source tree.
|
|
268
|
+
*/var rl;function vj(){if(rl)return to;rl=1;var e=Bt;function t(p,f){return p===f&&(p!==0||1/p===1/f)||p!==p&&f!==f}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,r=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function l(p,f){var h=f(),m=s({inst:{value:h,getSnapshot:f}}),v=m[0].inst,b=m[1];return o(function(){v.value=h,v.getSnapshot=f,c(v)&&b({inst:v})},[p,h,f]),r(function(){return c(v)&&b({inst:v}),p(function(){c(v)&&b({inst:v})})},[p]),i(h),h}function c(p){var f=p.getSnapshot;p=p.value;try{var h=f();return!n(p,h)}catch{return!0}}function u(p,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return to.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,to}var ol;function bj(){return ol||(ol=1,sl.exports=vj()),sl.exports}var xj=bj();const kj=(e,t)=>{if(Nn(t))return t;if(aj(t)&&Nn(t.defaultValue))return t.defaultValue;if(typeof e=="function")return"";if(Array.isArray(e)){const n=e[e.length-1];return typeof n=="function"?"":n}return e},wj={t:kj,ready:!1},jj=()=>()=>{},zn=(e,t={})=>{var n,s,r;const{i18n:o}=t,{i18n:i,defaultNS:l}=g.useContext(pd)||{},c=o||i||mj();c&&!c.reportNamespaces&&(c.reportNamespaces=new yj),c||Po(c,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const u=g.useMemo(()=>{var C;return{...fj(),...(C=c?.options)==null?void 0:C.react,...t}},[c,t]),{useSuspense:d,keyPrefix:p}=u,f=l||((n=c?.options)==null?void 0:n.defaultNS),h=Nn(f)?[f]:f||["translation"],m=g.useMemo(()=>h,h);(r=(s=c?.reportNamespaces)==null?void 0:s.addUsedNamespaces)==null||r.call(s,m);const v=g.useRef(0),b=g.useCallback(C=>{if(!c)return jj;const{bindI18n:M,bindI18nStore:E}=u,T=()=>{v.current+=1,C()};return M&&c.on(M,T),E&&c.store.on(E,T),()=>{M&&M.split(" ").forEach(B=>c.off(B,T)),E&&E.split(" ").forEach(B=>c.store.off(B,T))}},[c,u]),k=g.useRef(),z=g.useCallback(()=>{if(!c)return wj;const C=!!(c.isInitialized||c.initializedStoreOnce)&&m.every(Y=>ij(Y,c,u)),M=t.lng||c.language,E=v.current,T=k.current;if(T&&T.ready===C&&T.lng===M&&T.keyPrefix===p&&T.revision===E)return T;const B={t:c.getFixedT(M,u.nsMode==="fallback"?m:m[0],p,{scopeNs:m}),ready:C,lng:M,keyPrefix:p,revision:E};return k.current=B,B},[c,m,p,u,t.lng]),[R,A]=g.useState(0),{t:D,ready:O}=xj.useSyncExternalStore(b,z,z);g.useEffect(()=>{if(c&&!O&&!d){const C=()=>A(M=>M+1);t.lng?nl(c,t.lng,m,C):Lo(c,m,C)}},[c,t.lng,m,O,d,R]);const I=c||{},F=g.useRef(null),L=g.useRef(),j=C=>{const M=Object.getOwnPropertyDescriptors(C);M.__original&&delete M.__original;const E=Object.create(Object.getPrototypeOf(C),M);if(!Object.prototype.hasOwnProperty.call(E,"__original"))try{Object.defineProperty(E,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return E},x=g.useMemo(()=>{const C=I,M=C?.language;let E=C;C&&(F.current&&F.current.__original===C?L.current!==M?(E=j(C),F.current=E,L.current=M):E=F.current:(E=j(C),F.current=E,L.current=M));const T=!O&&!d?(...Y)=>(Po(c,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),D(...Y)):D,B=[T,E,O];return B.t=T,B.i18n=E,B.ready=O,B},[D,I,O,I.resolvedLanguage,I.language,I.languages]);if(c&&d&&!O)throw new Promise(C=>{const M=()=>C();t.lng?nl(c,t.lng,m,M):Lo(c,m,M)});return x};function Sj({i18n:e,defaultNS:t,children:n}){const s=g.useMemo(()=>({i18n:e,defaultNS:t}),[e,t]);return g.createElement(pd.Provider,{value:s},n)}const _j={"commandPalette.open":"Open command palette","commandPalette.commands":"Commands","commandPalette.searchPlaceholder":"Search commands...","commandPalette.filterCommands":"Filter commands","commandPalette.noMatching":"No matching commands","composer.placeholder":"Type a message... (Enter to send, / for commands)","composer.ariaLabel":"Message input","composer.cancelAriaLabel":"Cancel generation","composer.cancel":"Cancel","composer.sendAriaLabel":"Send message","composer.send":"Send (Enter)","composer.attachFile":"Attach file","composer.attachFileAriaLabel":"Attach a file","composer.removeFileAriaLabel":"Remove file","chat.emptyState":"Select or create a session to begin","chat.title":"Chat","workbench.ariaLabel":"ACP Workbench","projectOpener.noProject":"No project opened","projectOpener.placeholder":"/path/to/project","projectOpener.ariaLabel":"Project directory","projectOpener.browseAriaLabel":"Browse for project","projectOpener.browse":"Browse...","permission.ariaLabel":"Permission required","permission.title":"Permission Required","permission.description":"The agent wants to execute a tool that requires your approval.","permission.deny":"Deny","permission.allow":"Allow","sessionList.title":"Sessions","sessionList.newSession":"New session","sessionList.closeSession":"Close session","sessionList.defaultSessionTitle":"New Session","sessionList.emptyState":"No sessions yet. Click + to start.","sessionList.loadMore":"Load more","time.justNow":"Just now","time.minutesAgo":"{minutes}m ago","time.hoursAgo":"{hours}h ago","time.daysAgo":"{days}d ago","thought.thinking":"Thinking...","thought.title":"Thought","thought.reasoning":"Reasoning...","plan.planning":"Planning...","plan.title":"Plan","streaming.ariaLabel":"Agent is thinking","streaming.generating":"Generating","diff.title":"Diff","diff.emptyState":"No diffs to display","terminal.title":"Terminal","terminal.empty":"No active terminals","terminal.command":"Command:","terminal.running":"Running...","terminal.signaled":"SIG","terminal.truncated":"Output truncated","loading.connecting":"Connecting to agents...","usageBar.ariaLabel":"Context window: {used} of {total} tokens","workspace.switchWorkspace":"Switch workspace","workspace.addWorkspace":"Add workspace","workspace.removeWorkspace":"Remove workspace","workspace.noWorkspaces":"No workspaces","workspace.selectWorkspace":"Select a workspace","userMessage.copy":"Copy","userMessage.copied":"Copied","userMessage.edit":"Edit","login.ariaLabel":"Login required","login.title":"Login Required","login.description":"You need to log in before creating a session. Please select an authentication method:","login.authenticating":"Authenticating...","login.cancel":"Cancel","login.error":"Authentication failed. Please try again."},Cj={"commandPalette.open":"打开命令面板","commandPalette.commands":"命令","commandPalette.searchPlaceholder":"搜索命令...","commandPalette.filterCommands":"过滤命令","commandPalette.noMatching":"无匹配命令","composer.placeholder":"输入消息...(Enter 发送,/ 触发命令)","composer.ariaLabel":"消息输入","composer.cancelAriaLabel":"取消生成","composer.cancel":"取消","composer.sendAriaLabel":"发送消息","composer.send":"发送(Enter)","composer.attachFile":"添加文件","composer.attachFileAriaLabel":"添加文件","composer.removeFileAriaLabel":"移除文件","chat.emptyState":"选择或创建一个会话以开始","chat.title":"对话","workbench.ariaLabel":"ACP 工作台","projectOpener.noProject":"未打开项目","projectOpener.placeholder":"/路径/到/项目","projectOpener.ariaLabel":"项目目录","projectOpener.browseAriaLabel":"浏览项目","projectOpener.browse":"浏览...","permission.ariaLabel":"需要授权","permission.title":"需要授权","permission.description":"智能体想要执行一个需要您批准的工具操作。","permission.deny":"拒绝","permission.allow":"允许","sessionList.title":"会话列表","sessionList.newSession":"新建会话","sessionList.closeSession":"关闭会话","sessionList.defaultSessionTitle":"新会话","sessionList.emptyState":"暂无会话,点击 + 开始","sessionList.loadMore":"加载更多","time.justNow":"刚刚","time.minutesAgo":"{minutes}分钟前","time.hoursAgo":"{hours}小时前","time.daysAgo":"{days}天前","thought.thinking":"思考中...","thought.title":"思考过程","thought.reasoning":"推理中...","plan.planning":"规划中...","plan.title":"计划","streaming.ariaLabel":"智能体正在思考","streaming.generating":"生成中","diff.title":"差异","diff.emptyState":"无差异可显示","terminal.title":"终端","terminal.empty":"无活动终端","terminal.command":"命令:","terminal.running":"运行中...","terminal.signaled":"信号","terminal.truncated":"输出已截断","loading.connecting":"正在连接智能体...","usageBar.ariaLabel":"上下文窗口:{used} / {total} tokens","workspace.switchWorkspace":"切换工作区","workspace.addWorkspace":"添加工作区","workspace.removeWorkspace":"移除工作区","workspace.noWorkspaces":"暂无工作区","workspace.selectWorkspace":"选择工作区","userMessage.copy":"复制","userMessage.copied":"已复制","userMessage.edit":"编辑","login.ariaLabel":"需要登录","login.title":"需要登录","login.description":"创建会话前需要先登录,请选择认证方式:","login.authenticating":"认证中...","login.cancel":"取消","login.error":"认证失败,请重试。"},fd="acp-i18n-locale";function Ij(e){try{const t=localStorage.getItem(fd);if(t)return t}catch{}if(typeof navigator<"u"&&navigator.language){const t=navigator.language;if(t.startsWith("zh"))return"zh-CN";if(t.startsWith("en"))return"en-US"}return e}function Nj(e,t){const n={"en-US":{translation:_j},"zh-CN":{translation:Cj}};if(t)for(const r of Object.keys(t))n[r]||(n[r]={translation:{}}),Object.assign(n[r].translation,t[r]);const s=rj();return s.use(gj).init({resources:n,lng:e,fallbackLng:"en-US",interpolation:{escapeValue:!1,prefix:"{",suffix:"}"},returnNull:!1,returnEmptyString:!1}),s}function Ej({defaultLocale:e="en-US",customLocales:t,children:n}){const s=g.useMemo(()=>Nj(Ij(e),t),[e,t]);return g.useEffect(()=>{try{localStorage.setItem(fd,s.language)}catch{}},[s.language]),Bt.createElement(Sj,{i18n:s},n)}function Rj(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const zj=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Tj=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Oj={};function il(e,t){return(Oj.jsx?Tj:zj).test(e)}const Aj=/[ \t\n\f\r]/g;function $j(e){return typeof e=="object"?e.type==="text"?al(e.value):!1:al(e)}function al(e){return e.replace(Aj,"")===""}class Ts{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Ts.prototype.normal={};Ts.prototype.property={};Ts.prototype.space=void 0;function hd(e,t){const n={},s={};for(const r of e)Object.assign(n,r.property),Object.assign(s,r.normal);return new Ts(n,s,t)}function Mo(e){return e.toLowerCase()}class gt{constructor(t,n){this.attribute=n,this.property=t}}gt.prototype.attribute="";gt.prototype.booleanish=!1;gt.prototype.boolean=!1;gt.prototype.commaOrSpaceSeparated=!1;gt.prototype.commaSeparated=!1;gt.prototype.defined=!1;gt.prototype.mustUseProperty=!1;gt.prototype.number=!1;gt.prototype.overloadedBoolean=!1;gt.prototype.property="";gt.prototype.spaceSeparated=!1;gt.prototype.space=void 0;let Pj=0;const ve=Tn(),Ke=Tn(),Fo=Tn(),Q=Tn(),De=Tn(),Vn=Tn(),bt=Tn();function Tn(){return 2**++Pj}const Uo=Object.freeze(Object.defineProperty({__proto__:null,boolean:ve,booleanish:Ke,commaOrSpaceSeparated:bt,commaSeparated:Vn,number:Q,overloadedBoolean:Fo,spaceSeparated:De},Symbol.toStringTag,{value:"Module"})),no=Object.keys(Uo);class Si extends gt{constructor(t,n,s,r){let o=-1;if(super(t,n),ll(this,"space",r),typeof s=="number")for(;++o<no.length;){const i=no[o];ll(this,no[o],(s&Uo[i])===Uo[i])}}}Si.prototype.defined=!0;function ll(e,t,n){n&&(e[t]=n)}function ts(e){const t={},n={};for(const[s,r]of Object.entries(e.properties)){const o=new Si(s,e.transform(e.attributes||{},s),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),t[s]=o,n[Mo(s)]=s,n[Mo(o.attribute)]=s}return new Ts(t,n,e.space)}const md=ts({properties:{ariaActiveDescendant:null,ariaAtomic:Ke,ariaAutoComplete:null,ariaBusy:Ke,ariaChecked:Ke,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:De,ariaCurrent:null,ariaDescribedBy:De,ariaDetails:null,ariaDisabled:Ke,ariaDropEffect:De,ariaErrorMessage:null,ariaExpanded:Ke,ariaFlowTo:De,ariaGrabbed:Ke,ariaHasPopup:null,ariaHidden:Ke,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:De,ariaLevel:Q,ariaLive:null,ariaModal:Ke,ariaMultiLine:Ke,ariaMultiSelectable:Ke,ariaOrientation:null,ariaOwns:De,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Ke,ariaReadOnly:Ke,ariaRelevant:null,ariaRequired:Ke,ariaRoleDescription:De,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Ke,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function gd(e,t){return t in e?e[t]:t}function yd(e,t){return gd(e,t.toLowerCase())}const Lj=ts({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Vn,acceptCharset:De,accessKey:De,action:null,allow:null,allowFullScreen:ve,allowPaymentRequest:ve,allowUserMedia:ve,alt:null,as:null,async:ve,autoCapitalize:null,autoComplete:De,autoFocus:ve,autoPlay:ve,blocking:De,capture:null,charSet:null,checked:ve,cite:null,className:De,cols:Q,colSpan:null,content:null,contentEditable:Ke,controls:ve,controlsList:De,coords:Q|Vn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ve,defer:ve,dir:null,dirName:null,disabled:ve,download:Fo,draggable:Ke,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ve,formTarget:null,headers:De,height:Q,hidden:Fo,high:Q,href:null,hrefLang:null,htmlFor:De,httpEquiv:De,id:null,imageSizes:null,imageSrcSet:null,inert:ve,inputMode:null,integrity:null,is:null,isMap:ve,itemId:null,itemProp:De,itemRef:De,itemScope:ve,itemType:De,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ve,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:ve,muted:ve,name:null,nonce:null,noModule:ve,noValidate:ve,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ve,optimum:Q,pattern:null,ping:De,placeholder:null,playsInline:ve,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ve,referrerPolicy:null,rel:De,required:ve,reversed:ve,rows:Q,rowSpan:Q,sandbox:De,scope:null,scoped:ve,seamless:ve,selected:ve,shadowRootClonable:ve,shadowRootDelegatesFocus:ve,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Ke,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:ve,useMap:null,value:Ke,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:De,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ve,declare:ve,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:ve,noHref:ve,noShade:ve,noWrap:ve,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Ke,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ve,disableRemotePlayback:ve,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:yd}),Dj=ts({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:bt,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:De,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:ve,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Vn,g2:Vn,glyphName:Vn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:bt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:De,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bt,rev:bt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bt,requiredFeatures:bt,requiredFonts:bt,requiredFormats:bt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:bt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bt,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:gd}),vd=ts({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),bd=ts({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yd}),xd=ts({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Mj={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Fj=/[A-Z]/g,cl=/-[a-z]/g,Uj=/^data[-\w.:]+$/i;function Bj(e,t){const n=Mo(t);let s=t,r=gt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Uj.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(cl,Vj);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!cl.test(o)){let i=o.replace(Fj,Zj);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}r=Si}return new r(s,t)}function Zj(e){return"-"+e.toLowerCase()}function Vj(e){return e.charAt(1).toUpperCase()}const qj=hd([md,Lj,vd,bd,xd],"html"),_i=hd([md,Dj,vd,bd,xd],"svg");function Hj(e){return e.join(" ").trim()}var Pn={},so,ul;function Wj(){if(ul)return so;ul=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,r=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,l=/^\s+|\s+$/g,c=`
|
|
269
|
+
`,u="/",d="*",p="",f="comment",h="declaration";function m(b,k){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];k=k||{};var z=1,R=1;function A(E){var T=E.match(t);T&&(z+=T.length);var B=E.lastIndexOf(c);R=~B?E.length-B:R+E.length}function D(){var E={line:z,column:R};return function(T){return T.position=new O(E),L(),T}}function O(E){this.start=E,this.end={line:z,column:R},this.source=k.source}O.prototype.content=b;function I(E){var T=new Error(k.source+":"+z+":"+R+": "+E);if(T.reason=E,T.filename=k.source,T.line=z,T.column=R,T.source=b,!k.silent)throw T}function F(E){var T=E.exec(b);if(T){var B=T[0];return A(B),b=b.slice(B.length),T}}function L(){F(n)}function j(E){var T;for(E=E||[];T=x();)T!==!1&&E.push(T);return E}function x(){var E=D();if(!(u!=b.charAt(0)||d!=b.charAt(1))){for(var T=2;p!=b.charAt(T)&&(d!=b.charAt(T)||u!=b.charAt(T+1));)++T;if(T+=2,p===b.charAt(T-1))return I("End of comment missing");var B=b.slice(2,T-2);return R+=2,A(B),b=b.slice(T),R+=2,E({type:f,comment:B})}}function C(){var E=D(),T=F(s);if(T){if(x(),!F(r))return I("property missing ':'");var B=F(o),Y=E({type:h,property:v(T[0].replace(e,p)),value:B?v(B[0].replace(e,p)):p});return F(i),Y}}function M(){var E=[];j(E);for(var T;T=C();)T!==!1&&(E.push(T),j(E));return E}return L(),M()}function v(b){return b?b.replace(l,p):p}return so=m,so}var dl;function Kj(){if(dl)return Pn;dl=1;var e=Pn&&Pn.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Pn,"__esModule",{value:!0}),Pn.default=n;const t=e(Wj());function n(s,r){let o=null;if(!s||typeof s!="string")return o;const i=(0,t.default)(s),l=typeof r=="function";return i.forEach(c=>{if(c.type!=="declaration")return;const{property:u,value:d}=c;l?r(u,d,c):d&&(o=o||{},o[u]=d)}),o}return Pn}var ls={},pl;function Jj(){if(pl)return ls;pl=1,Object.defineProperty(ls,"__esModule",{value:!0}),ls.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,r=/^-(ms)-/,o=function(u){return!u||n.test(u)||e.test(u)},i=function(u,d){return d.toUpperCase()},l=function(u,d){return"".concat(d,"-")},c=function(u,d){return d===void 0&&(d={}),o(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(r,l):u=u.replace(s,l),u.replace(t,i))};return ls.camelCase=c,ls}var cs,fl;function Gj(){if(fl)return cs;fl=1;var e=cs&&cs.__importDefault||function(r){return r&&r.__esModule?r:{default:r}},t=e(Kj()),n=Jj();function s(r,o){var i={};return!r||typeof r!="string"||(0,t.default)(r,function(l,c){l&&c&&(i[(0,n.camelCase)(l,o)]=c)}),i}return s.default=s,cs=s,cs}var Yj=Gj();const Xj=cd(Yj),kd=wd("end"),Ci=wd("start");function wd(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function Qj(e){const t=Ci(e),n=kd(e);if(t&&n)return{start:t,end:n}}function bs(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?hl(e.position):"start"in e||"end"in e?hl(e):"line"in e||"column"in e?Bo(e):""}function Bo(e){return ml(e&&e.line)+":"+ml(e&&e.column)}function hl(e){return Bo(e&&e.start)+"-"+Bo(e&&e.end)}function ml(e){return e&&typeof e=="number"?e:1}class tt extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let r="",o={},i=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?r=t:!o.cause&&t&&(i=!0,r=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const c=s.indexOf(":");c===-1?o.ruleId=s:(o.source=s.slice(0,c),o.ruleId=s.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=l?l.line:void 0,this.name=bs(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}tt.prototype.file="";tt.prototype.name="";tt.prototype.reason="";tt.prototype.message="";tt.prototype.stack="";tt.prototype.column=void 0;tt.prototype.line=void 0;tt.prototype.ancestors=void 0;tt.prototype.cause=void 0;tt.prototype.fatal=void 0;tt.prototype.place=void 0;tt.prototype.ruleId=void 0;tt.prototype.source=void 0;const Ii={}.hasOwnProperty,e1=new Map,t1=/[A-Z]/g,n1=new Set(["table","tbody","thead","tfoot","tr"]),s1=new Set(["td","th"]),jd="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function r1(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=p1(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=d1(n,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?_i:qj,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=Sd(r,e,void 0);return o&&typeof o!="string"?o:r.create(e,r.Fragment,{children:o||void 0},void 0)}function Sd(e,t,n){if(t.type==="element")return o1(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return i1(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return l1(e,t,n);if(t.type==="mdxjsEsm")return a1(e,t);if(t.type==="root")return c1(e,t,n);if(t.type==="text")return u1(e,t)}function o1(e,t,n){const s=e.schema;let r=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(r=_i,e.schema=r),e.ancestors.push(t);const o=Cd(e,t.tagName,!1),i=f1(e,t);let l=Ei(e,t);return n1.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!$j(c):!0})),_d(e,i,o,t),Ni(i,l),e.ancestors.pop(),e.schema=s,e.create(t,o,i,n)}function i1(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Is(e,t.position)}function a1(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Is(e,t.position)}function l1(e,t,n){const s=e.schema;let r=s;t.name==="svg"&&s.space==="html"&&(r=_i,e.schema=r),e.ancestors.push(t);const o=t.name===null?e.Fragment:Cd(e,t.name,!0),i=h1(e,t),l=Ei(e,t);return _d(e,i,o,t),Ni(i,l),e.ancestors.pop(),e.schema=s,e.create(t,o,i,n)}function c1(e,t,n){const s={};return Ni(s,Ei(e,t)),e.create(t,e.Fragment,s,n)}function u1(e,t){return t.value}function _d(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Ni(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function d1(e,t,n){return s;function s(r,o,i,l){const c=Array.isArray(i.children)?n:t;return l?c(o,i,l):c(o,i)}}function p1(e,t){return n;function n(s,r,o,i){const l=Array.isArray(o.children),c=Ci(s);return t(r,o,i,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function f1(e,t){const n={};let s,r;for(r in t.properties)if(r!=="children"&&Ii.call(t.properties,r)){const o=m1(e,r,t.properties[r]);if(o){const[i,l]=o;e.tableCellAlignToStyle&&i==="align"&&typeof l=="string"&&s1.has(t.tagName)?s=l:n[i]=l}}if(s){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function h1(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const r=s.data.estree.body[0];r.type;const o=r.expression;o.type;const i=o.properties[0];i.type,Object.assign(n,e.evaluater.evaluateExpression(i.argument))}else Is(e,t.position);else{const r=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const i=s.value.data.estree.body[0];i.type,o=e.evaluater.evaluateExpression(i.expression)}else Is(e,t.position);else o=s.value===null?!0:s.value;n[r]=o}return n}function Ei(e,t){const n=[];let s=-1;const r=e.passKeys?new Map:e1;for(;++s<t.children.length;){const o=t.children[s];let i;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const u=r.get(c)||0;i=c+"-"+u,r.set(c,u+1)}}const l=Sd(e,o,i);l!==void 0&&n.push(l)}return n}function m1(e,t,n){const s=Bj(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?Rj(n):Hj(n)),s.property==="style"){let r=typeof n=="object"?n:g1(e,String(n));return e.stylePropertyNameCase==="css"&&(r=y1(r)),["style",r]}return[e.elementAttributeNameCase==="react"&&s.space?Mj[s.property]||s.property:s.attribute,n]}}function g1(e,t){try{return Xj(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,r=new tt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=jd+"#cannot-parse-style-attribute",r}}function Cd(e,t,n){let s;if(!n)s={type:"Literal",value:t};else if(t.includes(".")){const r=t.split(".");let o=-1,i;for(;++o<r.length;){const l=il(r[o])?{type:"Identifier",name:r[o]}:{type:"Literal",value:r[o]};i=i?{type:"MemberExpression",object:i,property:l,computed:!!(o&&l.type==="Literal"),optional:!1}:l}s=i}else s=il(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const r=s.value;return Ii.call(e.components,r)?e.components[r]:r}if(e.evaluater)return e.evaluater.evaluateExpression(s);Is(e)}function Is(e,t){const n=new tt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=jd+"#cannot-handle-mdx-estrees-without-createevaluater",n}function y1(e){const t={};let n;for(n in e)Ii.call(e,n)&&(t[v1(n)]=e[n]);return t}function v1(e){let t=e.replace(t1,b1);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function b1(e){return"-"+e.toLowerCase()}const ro={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},x1={};function Ri(e,t){const n=x1,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,r=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Id(e,s,r)}function Id(e,t,n){if(k1(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return gl(e.children,t,n)}return Array.isArray(e)?gl(e,t,n):""}function gl(e,t,n){const s=[];let r=-1;for(;++r<e.length;)s[r]=Id(e[r],t,n);return s.join("")}function k1(e){return!!(e&&typeof e=="object")}const yl=document.createElement("i");function zi(e){const t="&"+e+";";yl.innerHTML=t;const n=yl.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function kt(e,t,n,s){const r=e.length;let o=0,i;if(t<0?t=-t>r?0:r+t:t=t>r?r:t,n=n>0?n:0,s.length<1e4)i=Array.from(s),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<s.length;)i=s.slice(o,o+1e4),i.unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function It(e,t){return e.length>0?(kt(e,e.length,0,t),e):t}const vl={}.hasOwnProperty;function Nd(e){const t={};let n=-1;for(;++n<e.length;)w1(t,e[n]);return t}function w1(e,t){let n;for(n in t){const s=(vl.call(e,n)?e[n]:void 0)||(e[n]={}),r=t[n];let o;if(r)for(o in r){vl.call(s,o)||(s[o]=[]);const i=r[o];j1(s[o],Array.isArray(i)?i:i?[i]:[])}}}function j1(e,t){let n=-1;const s=[];for(;++n<t.length;)(t[n].add==="after"?e:s).push(t[n]);kt(e,0,0,s)}function Ed(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Pt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const at=xn(/[A-Za-z]/),et=xn(/[\dA-Za-z]/),S1=xn(/[#-'*+\--9=?A-Z^-~]/);function gr(e){return e!==null&&(e<32||e===127)}const Zo=xn(/\d/),_1=xn(/[\dA-Fa-f]/),C1=xn(/[!-/:-@[-`{-~]/);function ce(e){return e!==null&&e<-2}function Pe(e){return e!==null&&(e<0||e===32)}function je(e){return e===-2||e===-1||e===32}const $r=xn(new RegExp("\\p{P}|\\p{S}","u")),En=xn(/\s/);function xn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ns(e){const t=[];let n=-1,s=0,r=0;for(;++n<e.length;){const o=e.charCodeAt(n);let i="";if(o===37&&et(e.charCodeAt(n+1))&&et(e.charCodeAt(n+2)))r=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(i=String.fromCharCode(o));else if(o>55295&&o<57344){const l=e.charCodeAt(n+1);o<56320&&l>56319&&l<57344?(i=String.fromCharCode(o,l),r=1):i="�"}else i=String.fromCharCode(o);i&&(t.push(e.slice(s,n),encodeURIComponent(i)),s=n+r+1,i=""),r&&(n+=r,r=0)}return t.join("")+e.slice(s)}function Ce(e,t,n,s){const r=s?s-1:Number.POSITIVE_INFINITY;let o=0;return i;function i(c){return je(c)?(e.enter(n),l(c)):t(c)}function l(c){return je(c)&&o++<r?(e.consume(c),l):(e.exit(n),t(c))}}const I1={tokenize:N1};function N1(e){const t=e.attempt(this.parser.constructs.contentInitial,s,r);let n;return t;function s(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Ce(e,t,"linePrefix")}function r(l){return e.enter("paragraph"),o(l)}function o(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,i(l)}function i(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return ce(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),i)}}const E1={tokenize:R1},bl={tokenize:z1};function R1(e){const t=this,n=[];let s=0,r,o,i;return l;function l(R){if(s<n.length){const A=n[s];return t.containerState=A[1],e.attempt(A[0].continuation,c,u)(R)}return u(R)}function c(R){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&z();const A=t.events.length;let D=A,O;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){O=t.events[D][1].end;break}k(s);let I=A;for(;I<t.events.length;)t.events[I][1].end={...O},I++;return kt(t.events,D+1,0,t.events.slice(A)),t.events.length=I,u(R)}return l(R)}function u(R){if(s===n.length){if(!r)return f(R);if(r.currentConstruct&&r.currentConstruct.concrete)return m(R);t.interrupt=!!(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(bl,d,p)(R)}function d(R){return r&&z(),k(s),f(R)}function p(R){return t.parser.lazy[t.now().line]=s!==n.length,i=t.now().offset,m(R)}function f(R){return t.containerState={},e.attempt(bl,h,m)(R)}function h(R){return s++,n.push([t.currentConstruct,t.containerState]),f(R)}function m(R){if(R===null){r&&z(),k(0),e.consume(R);return}return r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:o}),v(R)}function v(R){if(R===null){b(e.exit("chunkFlow"),!0),k(0),e.consume(R);return}return ce(R)?(e.consume(R),b(e.exit("chunkFlow")),s=0,t.interrupt=void 0,l):(e.consume(R),v)}function b(R,A){const D=t.sliceStream(R);if(A&&D.push(null),R.previous=o,o&&(o.next=R),o=R,r.defineSkip(R.start),r.write(D),t.parser.lazy[R.start.line]){let O=r.events.length;for(;O--;)if(r.events[O][1].start.offset<i&&(!r.events[O][1].end||r.events[O][1].end.offset>i))return;const I=t.events.length;let F=I,L,j;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if(L){j=t.events[F][1].end;break}L=!0}for(k(s),O=I;O<t.events.length;)t.events[O][1].end={...j},O++;kt(t.events,F+1,0,t.events.slice(I)),t.events.length=O}}function k(R){let A=n.length;for(;A-- >R;){const D=n[A];t.containerState=D[1],D[0].exit.call(t,e)}n.length=R}function z(){r.write([null]),o=void 0,r=void 0,t.containerState._closeFlow=void 0}}function z1(e,t,n){return Ce(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Jn(e){if(e===null||Pe(e)||En(e))return 1;if($r(e))return 2}function Pr(e,t,n){const s=[];let r=-1;for(;++r<e.length;){const o=e[r].resolveAll;o&&!s.includes(o)&&(t=o(t,n),s.push(o))}return t}const Vo={name:"attention",resolveAll:T1,tokenize:O1};function T1(e,t){let n=-1,s,r,o,i,l,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(s=n;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[s][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[s][1].end.offset-e[s][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[s][1].end},f={...e[n][1].start};xl(p,-c),xl(f,c),i={type:c>1?"strongSequence":"emphasisSequence",start:p,end:{...e[s][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},o={type:c>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},r={type:c>1?"strong":"emphasis",start:{...i.start},end:{...l.end}},e[s][1].end={...i.start},e[n][1].start={...l.end},u=[],e[s][1].end.offset-e[s][1].start.offset&&(u=It(u,[["enter",e[s][1],t],["exit",e[s][1],t]])),u=It(u,[["enter",r,t],["enter",i,t],["exit",i,t],["enter",o,t]]),u=It(u,Pr(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),u=It(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",r,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=It(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,kt(e,s-1,n-s+3,u),n=s+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function O1(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,r=Jn(s);let o;return i;function i(c){return o=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===o)return e.consume(c),l;const u=e.exit("attentionSequence"),d=Jn(c),p=!d||d===2&&r||n.includes(c),f=!r||r===2&&d||n.includes(s);return u._open=!!(o===42?p:p&&(r||!f)),u._close=!!(o===42?f:f&&(d||!p)),t(c)}}function xl(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const A1={name:"autolink",tokenize:$1};function $1(e,t,n){let s=0;return r;function r(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(h){return at(h)?(e.consume(h),i):h===64?n(h):u(h)}function i(h){return h===43||h===45||h===46||et(h)?(s=1,l(h)):u(h)}function l(h){return h===58?(e.consume(h),s=0,c):(h===43||h===45||h===46||et(h))&&s++<32?(e.consume(h),l):(s=0,u(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||gr(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),d):S1(h)?(e.consume(h),u):n(h)}function d(h){return et(h)?p(h):n(h)}function p(h){return h===46?(e.consume(h),s=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):f(h)}function f(h){if((h===45||et(h))&&s++<63){const m=h===45?f:p;return e.consume(h),m}return n(h)}}const Os={partial:!0,tokenize:P1};function P1(e,t,n){return s;function s(o){return je(o)?Ce(e,r,"linePrefix")(o):r(o)}function r(o){return o===null||ce(o)?t(o):n(o)}}const Rd={continuation:{tokenize:D1},exit:M1,name:"blockQuote",tokenize:L1};function L1(e,t,n){const s=this;return r;function r(i){if(i===62){const l=s.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),o}return n(i)}function o(i){return je(i)?(e.enter("blockQuotePrefixWhitespace"),e.consume(i),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(i))}}function D1(e,t,n){const s=this;return r;function r(i){return je(i)?Ce(e,o,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):o(i)}function o(i){return e.attempt(Rd,t,n)(i)}}function M1(e){e.exit("blockQuote")}const zd={name:"characterEscape",tokenize:F1};function F1(e,t,n){return s;function s(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),r}function r(o){return C1(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Td={name:"characterReference",tokenize:U1};function U1(e,t,n){const s=this;let r=0,o,i;return l;function l(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),c}function c(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,i=et,d(p))}function u(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,i=_1,d):(e.enter("characterReferenceValue"),o=7,i=Zo,d(p))}function d(p){if(p===59&&r){const f=e.exit("characterReferenceValue");return i===et&&!zi(s.sliceSerialize(f))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return i(p)&&r++<o?(e.consume(p),d):n(p)}}const kl={partial:!0,tokenize:Z1},wl={concrete:!0,name:"codeFenced",tokenize:B1};function B1(e,t,n){const s=this,r={partial:!0,tokenize:D};let o=0,i=0,l;return c;function c(O){return u(O)}function u(O){const I=s.events[s.events.length-1];return o=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,l=O,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(O)}function d(O){return O===l?(i++,e.consume(O),d):i<3?n(O):(e.exit("codeFencedFenceSequence"),je(O)?Ce(e,p,"whitespace")(O):p(O))}function p(O){return O===null||ce(O)?(e.exit("codeFencedFence"),s.interrupt?t(O):e.check(kl,v,A)(O)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(O))}function f(O){return O===null||ce(O)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(O)):je(O)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ce(e,h,"whitespace")(O)):O===96&&O===l?n(O):(e.consume(O),f)}function h(O){return O===null||ce(O)?p(O):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(O))}function m(O){return O===null||ce(O)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(O)):O===96&&O===l?n(O):(e.consume(O),m)}function v(O){return e.attempt(r,A,b)(O)}function b(O){return e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),k}function k(O){return o>0&&je(O)?Ce(e,z,"linePrefix",o+1)(O):z(O)}function z(O){return O===null||ce(O)?e.check(kl,v,A)(O):(e.enter("codeFlowValue"),R(O))}function R(O){return O===null||ce(O)?(e.exit("codeFlowValue"),z(O)):(e.consume(O),R)}function A(O){return e.exit("codeFenced"),t(O)}function D(O,I,F){let L=0;return j;function j(T){return O.enter("lineEnding"),O.consume(T),O.exit("lineEnding"),x}function x(T){return O.enter("codeFencedFence"),je(T)?Ce(O,C,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):C(T)}function C(T){return T===l?(O.enter("codeFencedFenceSequence"),M(T)):F(T)}function M(T){return T===l?(L++,O.consume(T),M):L>=i?(O.exit("codeFencedFenceSequence"),je(T)?Ce(O,E,"whitespace")(T):E(T)):F(T)}function E(T){return T===null||ce(T)?(O.exit("codeFencedFence"),I(T)):F(T)}}}function Z1(e,t,n){const s=this;return r;function r(i){return i===null?n(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o)}function o(i){return s.parser.lazy[s.now().line]?n(i):t(i)}}const oo={name:"codeIndented",tokenize:q1},V1={partial:!0,tokenize:H1};function q1(e,t,n){const s=this;return r;function r(u){return e.enter("codeIndented"),Ce(e,o,"linePrefix",5)(u)}function o(u){const d=s.events[s.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?i(u):n(u)}function i(u){return u===null?c(u):ce(u)?e.attempt(V1,i,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||ce(u)?(e.exit("codeFlowValue"),i(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function H1(e,t,n){const s=this;return r;function r(i){return s.parser.lazy[s.now().line]?n(i):ce(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),r):Ce(e,o,"linePrefix",5)(i)}function o(i){const l=s.events[s.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(i):ce(i)?r(i):n(i)}}const W1={name:"codeText",previous:J1,resolve:K1,tokenize:G1};function K1(e){let t=e.length-4,n=3,s,r;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s<t;)if(e[s][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(s=n-1,t++;++s<=t;)r===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(r=s):(s===t||e[s][1].type==="lineEnding")&&(e[r][1].type="codeTextData",s!==r+2&&(e[r][1].end=e[s-1][1].end,e.splice(r+2,s-r-2),t-=s-r-2,s=r+2),r=void 0);return e}function J1(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function G1(e,t,n){let s=0,r,o;return i;function i(p){return e.enter("codeText"),e.enter("codeTextSequence"),l(p)}function l(p){return p===96?(e.consume(p),s++,l):(e.exit("codeTextSequence"),c(p))}function c(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),c):p===96?(o=e.enter("codeTextSequence"),r=0,d(p)):ce(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(p))}function u(p){return p===null||p===32||p===96||ce(p)?(e.exit("codeTextData"),c(p)):(e.consume(p),u)}function d(p){return p===96?(e.consume(p),r++,d):r===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(o.type="codeTextData",u(p))}}class Y1{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const r=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return s&&us(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),us(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),us(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);us(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);us(this.left,n.reverse())}}}function us(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Od(e){const t={};let n=-1,s,r,o,i,l,c,u;const d=new Y1(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(s=d.get(n),n&&s[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=s[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,X1(d,n)),n=t[n],u=!0);else if(s[1]._container){for(o=n,r=void 0;o--;)if(i=d.get(o),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank")i[0]==="enter"&&(r&&(d.get(r)[1].type="lineEndingBlank"),i[1].type="lineEnding",r=o);else if(!(i[1].type==="linePrefix"||i[1].type==="listItemIndent"))break;r&&(s[1].end={...d.get(r)[1].start},l=d.slice(r,n),l.unshift(s),d.splice(r,n-r+1,l))}}return kt(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function X1(e,t){const n=e.get(t)[1],s=e.get(t)[2];let r=t-1;const o=[];let i=n._tokenizer;i||(i=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const l=i.events,c=[],u={};let d,p,f=-1,h=n,m=0,v=0;const b=[v];for(;h;){for(;e.get(++r)[1]!==h;);o.push(r),h._tokenizer||(d=s.sliceStream(h),h.next||d.push(null),p&&i.defineSkip(h.start),h._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),h._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),p=h,h=h.next}for(h=n;++f<l.length;)l[f][0]==="exit"&&l[f-1][0]==="enter"&&l[f][1].type===l[f-1][1].type&&l[f][1].start.line!==l[f][1].end.line&&(v=f+1,b.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(i.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),f=b.length;f--;){const k=l.slice(b[f],b[f+1]),z=o.pop();c.push([z,z+k.length-1]),e.splice(z,2,k)}for(c.reverse(),f=-1;++f<c.length;)u[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return u}const Q1={resolve:tS,tokenize:nS},eS={partial:!0,tokenize:sS};function tS(e){return Od(e),e}function nS(e,t){let n;return s;function s(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(l)}function r(l){return l===null?o(l):ce(l)?e.check(eS,i,o)(l):(e.consume(l),r)}function o(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function i(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}function sS(e,t,n){const s=this;return r;function r(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Ce(e,o,"linePrefix")}function o(i){if(i===null||ce(i))return n(i);const l=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(i):e.interrupt(s.parser.constructs.flow,n,t)(i)}}function Ad(e,t,n,s,r,o,i,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return p;function p(k){return k===60?(e.enter(s),e.enter(r),e.enter(o),e.consume(k),e.exit(o),f):k===null||k===32||k===41||gr(k)?n(k):(e.enter(s),e.enter(i),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(k))}function f(k){return k===62?(e.enter(o),e.consume(k),e.exit(o),e.exit(r),e.exit(s),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===62?(e.exit("chunkString"),e.exit(l),f(k)):k===null||k===60||ce(k)?n(k):(e.consume(k),k===92?m:h)}function m(k){return k===60||k===62||k===92?(e.consume(k),h):h(k)}function v(k){return!d&&(k===null||k===41||Pe(k))?(e.exit("chunkString"),e.exit(l),e.exit(i),e.exit(s),t(k)):d<u&&k===40?(e.consume(k),d++,v):k===41?(e.consume(k),d--,v):k===null||k===32||k===40||gr(k)?n(k):(e.consume(k),k===92?b:v)}function b(k){return k===40||k===41||k===92?(e.consume(k),v):v(k)}}function $d(e,t,n,s,r,o){const i=this;let l=0,c;return u;function u(h){return e.enter(s),e.enter(r),e.consume(h),e.exit(r),e.enter(o),d}function d(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(h):h===93?(e.exit(o),e.enter(r),e.consume(h),e.exit(r),e.exit(s),t):ce(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),p(h))}function p(h){return h===null||h===91||h===93||ce(h)||l++>999?(e.exit("chunkString"),d(h)):(e.consume(h),c||(c=!je(h)),h===92?f:p)}function f(h){return h===91||h===92||h===93?(e.consume(h),l++,p):p(h)}}function Pd(e,t,n,s,r,o){let i;return l;function l(f){return f===34||f===39||f===40?(e.enter(s),e.enter(r),e.consume(f),e.exit(r),i=f===40?41:f,c):n(f)}function c(f){return f===i?(e.enter(r),e.consume(f),e.exit(r),e.exit(s),t):(e.enter(o),u(f))}function u(f){return f===i?(e.exit(o),c(i)):f===null?n(f):ce(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ce(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===i||f===null||ce(f)?(e.exit("chunkString"),u(f)):(e.consume(f),f===92?p:d)}function p(f){return f===i||f===92?(e.consume(f),d):d(f)}}function xs(e,t){let n;return s;function s(r){return ce(r)?(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,s):je(r)?Ce(e,s,n?"linePrefix":"lineSuffix")(r):t(r)}}const rS={name:"definition",tokenize:iS},oS={partial:!0,tokenize:aS};function iS(e,t,n){const s=this;let r;return o;function o(h){return e.enter("definition"),i(h)}function i(h){return $d.call(s,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return r=Pt(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return Pe(h)?xs(e,u)(h):u(h)}function u(h){return Ad(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(oS,p,p)(h)}function p(h){return je(h)?Ce(e,f,"whitespace")(h):f(h)}function f(h){return h===null||ce(h)?(e.exit("definition"),s.parser.defined.push(r),t(h)):n(h)}}function aS(e,t,n){return s;function s(l){return Pe(l)?xs(e,r)(l):n(l)}function r(l){return Pd(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return je(l)?Ce(e,i,"whitespace")(l):i(l)}function i(l){return l===null||ce(l)?t(l):n(l)}}const lS={name:"hardBreakEscape",tokenize:cS};function cS(e,t,n){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),r}function r(o){return ce(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const uS={name:"headingAtx",resolve:dS,tokenize:pS};function dS(e,t){let n=e.length-2,s=3,r,o;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(r={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},o={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},kt(e,s,n-s+1,[["enter",r,t],["enter",o,t],["exit",o,t],["exit",r,t]])),e}function pS(e,t,n){let s=0;return r;function r(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),i(d)}function i(d){return d===35&&s++<6?(e.consume(d),i):d===null||Pe(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||ce(d)?(e.exit("atxHeading"),t(d)):je(d)?Ce(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||Pe(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const fS=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],jl=["pre","script","style","textarea"],hS={concrete:!0,name:"htmlFlow",resolveTo:yS,tokenize:vS},mS={partial:!0,tokenize:xS},gS={partial:!0,tokenize:bS};function yS(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function vS(e,t,n){const s=this;let r,o,i,l,c;return u;function u(_){return d(_)}function d(_){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(_),p}function p(_){return _===33?(e.consume(_),f):_===47?(e.consume(_),o=!0,v):_===63?(e.consume(_),r=3,s.interrupt?t:w):at(_)?(e.consume(_),i=String.fromCharCode(_),b):n(_)}function f(_){return _===45?(e.consume(_),r=2,h):_===91?(e.consume(_),r=5,l=0,m):at(_)?(e.consume(_),r=4,s.interrupt?t:w):n(_)}function h(_){return _===45?(e.consume(_),s.interrupt?t:w):n(_)}function m(_){const ue="CDATA[";return _===ue.charCodeAt(l++)?(e.consume(_),l===ue.length?s.interrupt?t:C:m):n(_)}function v(_){return at(_)?(e.consume(_),i=String.fromCharCode(_),b):n(_)}function b(_){if(_===null||_===47||_===62||Pe(_)){const ue=_===47,Se=i.toLowerCase();return!ue&&!o&&jl.includes(Se)?(r=1,s.interrupt?t(_):C(_)):fS.includes(i.toLowerCase())?(r=6,ue?(e.consume(_),k):s.interrupt?t(_):C(_)):(r=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(_):o?z(_):R(_))}return _===45||et(_)?(e.consume(_),i+=String.fromCharCode(_),b):n(_)}function k(_){return _===62?(e.consume(_),s.interrupt?t:C):n(_)}function z(_){return je(_)?(e.consume(_),z):j(_)}function R(_){return _===47?(e.consume(_),j):_===58||_===95||at(_)?(e.consume(_),A):je(_)?(e.consume(_),R):j(_)}function A(_){return _===45||_===46||_===58||_===95||et(_)?(e.consume(_),A):D(_)}function D(_){return _===61?(e.consume(_),O):je(_)?(e.consume(_),D):R(_)}function O(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(e.consume(_),c=_,I):je(_)?(e.consume(_),O):F(_)}function I(_){return _===c?(e.consume(_),c=null,L):_===null||ce(_)?n(_):(e.consume(_),I)}function F(_){return _===null||_===34||_===39||_===47||_===60||_===61||_===62||_===96||Pe(_)?D(_):(e.consume(_),F)}function L(_){return _===47||_===62||je(_)?R(_):n(_)}function j(_){return _===62?(e.consume(_),x):n(_)}function x(_){return _===null||ce(_)?C(_):je(_)?(e.consume(_),x):n(_)}function C(_){return _===45&&r===2?(e.consume(_),B):_===60&&r===1?(e.consume(_),Y):_===62&&r===4?(e.consume(_),U):_===63&&r===3?(e.consume(_),w):_===93&&r===5?(e.consume(_),oe):ce(_)&&(r===6||r===7)?(e.exit("htmlFlowData"),e.check(mS,ne,M)(_)):_===null||ce(_)?(e.exit("htmlFlowData"),M(_)):(e.consume(_),C)}function M(_){return e.check(gS,E,ne)(_)}function E(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),T}function T(_){return _===null||ce(_)?M(_):(e.enter("htmlFlowData"),C(_))}function B(_){return _===45?(e.consume(_),w):C(_)}function Y(_){return _===47?(e.consume(_),i="",re):C(_)}function re(_){if(_===62){const ue=i.toLowerCase();return jl.includes(ue)?(e.consume(_),U):C(_)}return at(_)&&i.length<8?(e.consume(_),i+=String.fromCharCode(_),re):C(_)}function oe(_){return _===93?(e.consume(_),w):C(_)}function w(_){return _===62?(e.consume(_),U):_===45&&r===2?(e.consume(_),w):C(_)}function U(_){return _===null||ce(_)?(e.exit("htmlFlowData"),ne(_)):(e.consume(_),U)}function ne(_){return e.exit("htmlFlow"),t(_)}}function bS(e,t,n){const s=this;return r;function r(i){return ce(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o):n(i)}function o(i){return s.parser.lazy[s.now().line]?n(i):t(i)}}function xS(e,t,n){return s;function s(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(Os,t,n)}}const kS={name:"htmlText",tokenize:wS};function wS(e,t,n){const s=this;let r,o,i;return l;function l(w){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(w),c}function c(w){return w===33?(e.consume(w),u):w===47?(e.consume(w),D):w===63?(e.consume(w),R):at(w)?(e.consume(w),F):n(w)}function u(w){return w===45?(e.consume(w),d):w===91?(e.consume(w),o=0,m):at(w)?(e.consume(w),z):n(w)}function d(w){return w===45?(e.consume(w),h):n(w)}function p(w){return w===null?n(w):w===45?(e.consume(w),f):ce(w)?(i=p,Y(w)):(e.consume(w),p)}function f(w){return w===45?(e.consume(w),h):p(w)}function h(w){return w===62?B(w):w===45?f(w):p(w)}function m(w){const U="CDATA[";return w===U.charCodeAt(o++)?(e.consume(w),o===U.length?v:m):n(w)}function v(w){return w===null?n(w):w===93?(e.consume(w),b):ce(w)?(i=v,Y(w)):(e.consume(w),v)}function b(w){return w===93?(e.consume(w),k):v(w)}function k(w){return w===62?B(w):w===93?(e.consume(w),k):v(w)}function z(w){return w===null||w===62?B(w):ce(w)?(i=z,Y(w)):(e.consume(w),z)}function R(w){return w===null?n(w):w===63?(e.consume(w),A):ce(w)?(i=R,Y(w)):(e.consume(w),R)}function A(w){return w===62?B(w):R(w)}function D(w){return at(w)?(e.consume(w),O):n(w)}function O(w){return w===45||et(w)?(e.consume(w),O):I(w)}function I(w){return ce(w)?(i=I,Y(w)):je(w)?(e.consume(w),I):B(w)}function F(w){return w===45||et(w)?(e.consume(w),F):w===47||w===62||Pe(w)?L(w):n(w)}function L(w){return w===47?(e.consume(w),B):w===58||w===95||at(w)?(e.consume(w),j):ce(w)?(i=L,Y(w)):je(w)?(e.consume(w),L):B(w)}function j(w){return w===45||w===46||w===58||w===95||et(w)?(e.consume(w),j):x(w)}function x(w){return w===61?(e.consume(w),C):ce(w)?(i=x,Y(w)):je(w)?(e.consume(w),x):L(w)}function C(w){return w===null||w===60||w===61||w===62||w===96?n(w):w===34||w===39?(e.consume(w),r=w,M):ce(w)?(i=C,Y(w)):je(w)?(e.consume(w),C):(e.consume(w),E)}function M(w){return w===r?(e.consume(w),r=void 0,T):w===null?n(w):ce(w)?(i=M,Y(w)):(e.consume(w),M)}function E(w){return w===null||w===34||w===39||w===60||w===61||w===96?n(w):w===47||w===62||Pe(w)?L(w):(e.consume(w),E)}function T(w){return w===47||w===62||Pe(w)?L(w):n(w)}function B(w){return w===62?(e.consume(w),e.exit("htmlTextData"),e.exit("htmlText"),t):n(w)}function Y(w){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),re}function re(w){return je(w)?Ce(e,oe,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):oe(w)}function oe(w){return e.enter("htmlTextData"),i(w)}}const Ti={name:"labelEnd",resolveAll:CS,resolveTo:IS,tokenize:NS},jS={tokenize:ES},SS={tokenize:RS},_S={tokenize:zS};function CS(e){let t=-1;const n=[];for(;++t<e.length;){const s=e[t][1];if(n.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const r=s.type==="labelImage"?4:2;s.type="data",t+=r}}return e.length!==n.length&&kt(e,0,e.length,n),e}function IS(e,t){let n=e.length,s=0,r,o,i,l;for(;n--;)if(r=e[n][1],o){if(r.type==="link"||r.type==="labelLink"&&r._inactive)break;e[n][0]==="enter"&&r.type==="labelLink"&&(r._inactive=!0)}else if(i){if(e[n][0]==="enter"&&(r.type==="labelImage"||r.type==="labelLink")&&!r._balanced&&(o=n,r.type!=="labelLink")){s=2;break}}else r.type==="labelEnd"&&(i=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[o+s+2][1].end},end:{...e[i-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=It(l,e.slice(o+1,o+s+3)),l=It(l,[["enter",d,t]]),l=It(l,Pr(t.parser.constructs.insideSpan.null,e.slice(o+s+4,i-3),t)),l=It(l,[["exit",d,t],e[i-2],e[i-1],["exit",u,t]]),l=It(l,e.slice(i+1)),l=It(l,[["exit",c,t]]),kt(e,o,e.length,l),e}function NS(e,t,n){const s=this;let r=s.events.length,o,i;for(;r--;)if((s.events[r][1].type==="labelImage"||s.events[r][1].type==="labelLink")&&!s.events[r][1]._balanced){o=s.events[r][1];break}return l;function l(f){return o?o._inactive?p(f):(i=s.parser.defined.includes(Pt(s.sliceSerialize({start:o.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),c):n(f)}function c(f){return f===40?e.attempt(jS,d,i?d:p)(f):f===91?e.attempt(SS,d,i?u:p)(f):i?d(f):p(f)}function u(f){return e.attempt(_S,d,p)(f)}function d(f){return t(f)}function p(f){return o._balanced=!0,n(f)}}function ES(e,t,n){return s;function s(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),r}function r(p){return Pe(p)?xs(e,o)(p):o(p)}function o(p){return p===41?d(p):Ad(e,i,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function i(p){return Pe(p)?xs(e,c)(p):d(p)}function l(p){return n(p)}function c(p){return p===34||p===39||p===40?Pd(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):d(p)}function u(p){return Pe(p)?xs(e,d)(p):d(p)}function d(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function RS(e,t,n){const s=this;return r;function r(l){return $d.call(s,e,o,i,"reference","referenceMarker","referenceString")(l)}function o(l){return s.parser.defined.includes(Pt(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function i(l){return n(l)}}function zS(e,t,n){return s;function s(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),r}function r(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const TS={name:"labelStartImage",resolveAll:Ti.resolveAll,tokenize:OS};function OS(e,t,n){const s=this;return r;function r(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),i):n(l)}function i(l){return l===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(l):t(l)}}const AS={name:"labelStartLink",resolveAll:Ti.resolveAll,tokenize:$S};function $S(e,t,n){const s=this;return r;function r(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),o}function o(i){return i===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(i):t(i)}}const io={name:"lineEnding",tokenize:PS};function PS(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ce(e,t,"linePrefix")}}const Ys={name:"thematicBreak",tokenize:LS};function LS(e,t,n){let s=0,r;return o;function o(u){return e.enter("thematicBreak"),i(u)}function i(u){return r=u,l(u)}function l(u){return u===r?(e.enter("thematicBreakSequence"),c(u)):s>=3&&(u===null||ce(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===r?(e.consume(u),s++,c):(e.exit("thematicBreakSequence"),je(u)?Ce(e,l,"whitespace")(u):l(u))}}const pt={continuation:{tokenize:US},exit:ZS,name:"list",tokenize:FS},DS={partial:!0,tokenize:VS},MS={partial:!0,tokenize:BS};function FS(e,t,n){const s=this,r=s.events[s.events.length-1];let o=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,i=0;return l;function l(h){const m=s.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!s.containerState.marker||h===s.containerState.marker:Zo(h)){if(s.containerState.type||(s.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Ys,n,u)(h):u(h);if(!s.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return Zo(h)&&++i<10?(e.consume(h),c):(!s.interrupt||i<2)&&(s.containerState.marker?h===s.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||h,e.check(Os,s.interrupt?n:d,e.attempt(DS,f,p))}function d(h){return s.containerState.initialBlankLine=!0,o++,f(h)}function p(h){return je(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),f):n(h)}function f(h){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function US(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Os,r,o);function r(l){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ce(e,t,"listItemIndent",s.containerState.size+1)(l)}function o(l){return s.containerState.furtherBlankLines||!je(l)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,i(l)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(MS,t,i)(l))}function i(l){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ce(e,e.attempt(pt,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function BS(e,t,n){const s=this;return Ce(e,r,"listItemIndent",s.containerState.size+1);function r(o){const i=s.events[s.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===s.containerState.size?t(o):n(o)}}function ZS(e){e.exit(this.containerState.type)}function VS(e,t,n){const s=this;return Ce(e,r,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function r(o){const i=s.events[s.events.length-1];return!je(o)&&i&&i[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Sl={name:"setextUnderline",resolveTo:qS,tokenize:HS};function qS(e,t){let n=e.length,s,r,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(r=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const i={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",o?(e.splice(r,0,["enter",i,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=i,e.push(["exit",i,t]),e}function HS(e,t,n){const s=this;let r;return o;function o(u){let d=s.events.length,p;for(;d--;)if(s.events[d][1].type!=="lineEnding"&&s.events[d][1].type!=="linePrefix"&&s.events[d][1].type!=="content"){p=s.events[d][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||p)?(e.enter("setextHeadingLine"),r=u,i(u)):n(u)}function i(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===r?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),je(u)?Ce(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||ce(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const WS={tokenize:KS};function KS(e){const t=this,n=e.attempt(Os,s,e.attempt(this.parser.constructs.flowInitial,r,Ce(e,e.attempt(this.parser.constructs.flow,r,e.attempt(Q1,r)),"linePrefix")));return n;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const JS={resolveAll:Dd()},GS=Ld("string"),YS=Ld("text");function Ld(e){return{resolveAll:Dd(e==="text"?XS:void 0),tokenize:t};function t(n){const s=this,r=this.parser.constructs[e],o=n.attempt(r,i,l);return i;function i(d){return u(d)?o(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),o(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const p=r[d];let f=-1;if(p)for(;++f<p.length;){const h=p[f];if(!h.previous||h.previous.call(s,s.previous))return!0}return!1}}}function Dd(e){return t;function t(n,s){let r=-1,o;for(;++r<=n.length;)o===void 0?n[r]&&n[r][1].type==="data"&&(o=r,r++):(!n[r]||n[r][1].type!=="data")&&(r!==o+2&&(n[o][1].end=n[r-1][1].end,n.splice(o+2,r-o-2),r=o+2),o=void 0);return e?e(n,s):n}}function XS(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],r=t.sliceStream(s);let o=r.length,i=-1,l=0,c;for(;o--;){const u=r[o];if(typeof u=="string"){for(i=u.length;u.charCodeAt(i-1)===32;)l++,i--;if(i)break;i=-1}else if(u===-2)c=!0,l++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?i:s.start._bufferIndex+i,_index:s.start._index+o,line:s.end.line,column:s.end.column-l,offset:s.end.offset-l},end:{...s.end}};s.end={...u.start},s.start.offset===s.end.offset?Object.assign(s,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const QS={42:pt,43:pt,45:pt,48:pt,49:pt,50:pt,51:pt,52:pt,53:pt,54:pt,55:pt,56:pt,57:pt,62:Rd},e_={91:rS},t_={[-2]:oo,[-1]:oo,32:oo},n_={35:uS,42:Ys,45:[Sl,Ys],60:hS,61:Sl,95:Ys,96:wl,126:wl},s_={38:Td,92:zd},r_={[-5]:io,[-4]:io,[-3]:io,33:TS,38:Td,42:Vo,60:[A1,kS],91:AS,92:[lS,zd],93:Ti,95:Vo,96:W1},o_={null:[Vo,JS]},i_={null:[42,95]},a_={null:[]},l_=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:i_,contentInitial:e_,disable:a_,document:QS,flow:n_,flowInitial:t_,insideSpan:o_,string:s_,text:r_},Symbol.toStringTag,{value:"Module"}));function c_(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},o=[];let i=[],l=[];const c={attempt:I(D),check:I(O),consume:z,enter:R,exit:A,interrupt:I(O,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:h,write:p};let d=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function p(x){return i=It(i,x),b(),i[i.length-1]!==null?[]:(F(t,0),u.events=Pr(o,u.events,u),u.events)}function f(x,C){return d_(h(x),C)}function h(x){return u_(i,x)}function m(){const{_bufferIndex:x,_index:C,line:M,column:E,offset:T}=s;return{_bufferIndex:x,_index:C,line:M,column:E,offset:T}}function v(x){r[x.line]=x.column,j()}function b(){let x;for(;s._index<i.length;){const C=i[s._index];if(typeof C=="string")for(x=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===x&&s._bufferIndex<C.length;)k(C.charCodeAt(s._bufferIndex));else k(C)}}function k(x){d=d(x)}function z(x){ce(x)?(s.line++,s.column=1,s.offset+=x===-3?2:1,j()):x!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===i[s._index].length&&(s._bufferIndex=-1,s._index++)),u.previous=x}function R(x,C){const M=C||{};return M.type=x,M.start=m(),u.events.push(["enter",M,u]),l.push(M),M}function A(x){const C=l.pop();return C.end=m(),u.events.push(["exit",C,u]),C}function D(x,C){F(x,C.from)}function O(x,C){C.restore()}function I(x,C){return M;function M(E,T,B){let Y,re,oe,w;return Array.isArray(E)?ne(E):"tokenize"in E?ne([E]):U(E);function U(H){return he;function he(Ee){const Re=Ee!==null&&H[Ee],Le=Ee!==null&&H.null,nt=[...Array.isArray(Re)?Re:Re?[Re]:[],...Array.isArray(Le)?Le:Le?[Le]:[]];return ne(nt)(Ee)}}function ne(H){return Y=H,re=0,H.length===0?B:_(H[re])}function _(H){return he;function he(Ee){return w=L(),oe=H,H.partial||(u.currentConstruct=H),H.name&&u.parser.constructs.disable.null.includes(H.name)?Se():H.tokenize.call(C?Object.assign(Object.create(u),C):u,c,ue,Se)(Ee)}}function ue(H){return x(oe,w),T}function Se(H){return w.restore(),++re<Y.length?_(Y[re]):B}}}function F(x,C){x.resolveAll&&!o.includes(x)&&o.push(x),x.resolve&&kt(u.events,C,u.events.length-C,x.resolve(u.events.slice(C),u)),x.resolveTo&&(u.events=x.resolveTo(u.events,u))}function L(){const x=m(),C=u.previous,M=u.currentConstruct,E=u.events.length,T=Array.from(l);return{from:E,restore:B};function B(){s=x,u.previous=C,u.currentConstruct=M,u.events.length=E,l=T,j()}}function j(){s.line in r&&s.column<2&&(s.column=r[s.line],s.offset+=r[s.line]-1)}}function u_(e,t){const n=t.start._index,s=t.start._bufferIndex,r=t.end._index,o=t.end._bufferIndex;let i;if(n===r)i=[e[n].slice(s,o)];else{if(i=e.slice(n,r),s>-1){const l=i[0];typeof l=="string"?i[0]=l.slice(s):i.shift()}o>0&&i.push(e[r].slice(0,o))}return i}function d_(e,t){let n=-1;const s=[];let r;for(;++n<e.length;){const o=e[n];let i;if(typeof o=="string")i=o;else switch(o){case-5:{i="\r";break}case-4:{i=`
|
|
270
|
+
`;break}case-3:{i=`\r
|
|
271
|
+
`;break}case-2:{i=t?" ":" ";break}case-1:{if(!t&&r)continue;i=" ";break}default:i=String.fromCharCode(o)}r=o===-2,s.push(i)}return s.join("")}function p_(e){const t={constructs:Nd([l_,...(e||{}).extensions||[]]),content:n(I1),defined:[],document:n(E1),flow:n(WS),lazy:{},string:n(GS),text:n(YS)};return t;function n(s){return r;function r(o){return c_(t,s,o)}}}function f_(e){for(;!Od(e););return e}const _l=/[\0\t\n\r]/g;function h_(){let e=1,t="",n=!0,s;return r;function r(o,i,l){const c=[];let u,d,p,f,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(i||void 0).decode(o)),p=0,t="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){if(_l.lastIndex=p,u=_l.exec(o),f=u&&u.index!==void 0?u.index:o.length,h=o.charCodeAt(f),!u){t=o.slice(p);break}if(h===10&&p===f&&s)c.push(-3),s=void 0;else switch(s&&(c.push(-5),s=void 0),p<f&&(c.push(o.slice(p,f)),e+=f-p),h){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:s=!0,e=1}p=f+1}return l&&(s&&c.push(-5),t&&c.push(t),c.push(null)),c}}const m_=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function g_(e){return e.replace(m_,y_)}function y_(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),r=s===120||s===88;return Ed(n.slice(r?2:1),r?16:10)}return zi(n)||e}const Md={}.hasOwnProperty;function v_(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),b_(n)(f_(p_(n).document().write(h_()(e,t,!0))))}function b_(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(wt),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(nn),blockQuote:o(Le),characterEscape:L,characterReference:L,codeFenced:o(nt),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:o(nt,i),codeText:o(lt,i),codeTextData:L,data:L,codeFlowValue:L,definition:o(kn),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:o(tn),hardBreakEscape:o(ss),hardBreakTrailing:o(ss),htmlFlow:o(rs,i),htmlFlowData:L,htmlText:o(rs,i),htmlTextData:L,image:o(sn),label:i,link:o(wt),listItem:o(rn),listItemValue:f,listOrdered:o(st,p),listUnordered:o(st),paragraph:o(On),reference:_,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:o(nn),strong:o(yt),thematicBreak:o(ct)},exit:{atxHeading:c(),atxHeadingSequence:D,autolink:c(),autolinkEmail:Re,autolinkProtocol:Ee,blockQuote:c(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:Se,characterReferenceMarkerNumeric:Se,characterReferenceValue:H,characterReference:he,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:m,codeFlowValue:j,codeIndented:c(k),codeText:c(T),codeTextData:j,data:j,definition:c(),definitionDestinationString:A,definitionLabelString:z,definitionTitleString:R,emphasis:c(),hardBreakEscape:c(C),hardBreakTrailing:c(C),htmlFlow:c(M),htmlFlowData:j,htmlText:c(E),htmlTextData:j,image:c(Y),label:oe,labelText:re,lineEnding:x,link:c(B),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ue,resourceDestinationString:w,resourceTitleString:U,resource:ne,setextHeading:c(F),setextHeadingLineSequence:I,setextHeadingText:O,strong:c(),thematicBreak:c()}};Fd(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(Z){let X={type:"root",children:[]};const ie={stack:[X],tokenStack:[],config:t,enter:l,exit:u,buffer:i,resume:d,data:n},we=[];let ye=-1;for(;++ye<Z.length;)if(Z[ye][1].type==="listOrdered"||Z[ye][1].type==="listUnordered")if(Z[ye][0]==="enter")we.push(ye);else{const ke=we.pop();ye=r(Z,ke,ye)}for(ye=-1;++ye<Z.length;){const ke=t[Z[ye][0]];Md.call(ke,Z[ye][1].type)&&ke[Z[ye][1].type].call(Object.assign({sliceSerialize:Z[ye][2].sliceSerialize},ie),Z[ye][1])}if(ie.tokenStack.length>0){const ke=ie.tokenStack[ie.tokenStack.length-1];(ke[1]||Cl).call(ie,void 0,ke[0])}for(X.position={start:ln(Z.length>0?Z[0][1].start:{line:1,column:1,offset:0}),end:ln(Z.length>0?Z[Z.length-2][1].end:{line:1,column:1,offset:0})},ye=-1;++ye<t.transforms.length;)X=t.transforms[ye](X)||X;return X}function r(Z,X,ie){let we=X-1,ye=-1,ke=!1,Xe,ut,jt,de;for(;++we<=ie;){const qe=Z[we];switch(qe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{qe[0]==="enter"?ye++:ye--,de=void 0;break}case"lineEndingBlank":{qe[0]==="enter"&&(Xe&&!de&&!ye&&!jt&&(jt=we),de=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:de=void 0}if(!ye&&qe[0]==="enter"&&qe[1].type==="listItemPrefix"||ye===-1&&qe[0]==="exit"&&(qe[1].type==="listUnordered"||qe[1].type==="listOrdered")){if(Xe){let ze=we;for(ut=void 0;ze--;){const dt=Z[ze];if(dt[1].type==="lineEnding"||dt[1].type==="lineEndingBlank"){if(dt[0]==="exit")continue;ut&&(Z[ut][1].type="lineEndingBlank",ke=!0),dt[1].type="lineEnding",ut=ze}else if(!(dt[1].type==="linePrefix"||dt[1].type==="blockQuotePrefix"||dt[1].type==="blockQuotePrefixWhitespace"||dt[1].type==="blockQuoteMarker"||dt[1].type==="listItemIndent"))break}jt&&(!ut||jt<ut)&&(Xe._spread=!0),Xe.end=Object.assign({},ut?Z[ut][1].start:qe[1].end),Z.splice(ut||we,0,["exit",Xe,qe[2]]),we++,ie++}if(qe[1].type==="listItemPrefix"){const ze={type:"listItem",_spread:!1,start:Object.assign({},qe[1].start),end:void 0};Xe=ze,Z.splice(we,0,["enter",ze,qe[2]]),we++,ie++,jt=void 0,de=!0}}}return Z[X][1]._spread=ke,ie}function o(Z,X){return ie;function ie(we){l.call(this,Z(we),we),X&&X.call(this,we)}}function i(){this.stack.push({type:"fragment",children:[]})}function l(Z,X,ie){this.stack[this.stack.length-1].children.push(Z),this.stack.push(Z),this.tokenStack.push([X,ie||void 0]),Z.position={start:ln(X.start),end:void 0}}function c(Z){return X;function X(ie){Z&&Z.call(this,ie),u.call(this,ie)}}function u(Z,X){const ie=this.stack.pop(),we=this.tokenStack.pop();if(we)we[0].type!==Z.type&&(X?X.call(this,Z,we[0]):(we[1]||Cl).call(this,Z,we[0]));else throw new Error("Cannot close `"+Z.type+"` ("+bs({start:Z.start,end:Z.end})+"): it’s not open");ie.position.end=ln(Z.end)}function d(){return Ri(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function f(Z){if(this.data.expectingFirstListItemValue){const X=this.stack[this.stack.length-2];X.start=Number.parseInt(this.sliceSerialize(Z),10),this.data.expectingFirstListItemValue=void 0}}function h(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.lang=Z}function m(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.meta=Z}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.value=Z.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.value=Z.replace(/(\r?\n|\r)$/g,"")}function z(Z){const X=this.resume(),ie=this.stack[this.stack.length-1];ie.label=X,ie.identifier=Pt(this.sliceSerialize(Z)).toLowerCase()}function R(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.title=Z}function A(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.url=Z}function D(Z){const X=this.stack[this.stack.length-1];if(!X.depth){const ie=this.sliceSerialize(Z).length;X.depth=ie}}function O(){this.data.setextHeadingSlurpLineEnding=!0}function I(Z){const X=this.stack[this.stack.length-1];X.depth=this.sliceSerialize(Z).codePointAt(0)===61?1:2}function F(){this.data.setextHeadingSlurpLineEnding=void 0}function L(Z){const X=this.stack[this.stack.length-1].children;let ie=X[X.length-1];(!ie||ie.type!=="text")&&(ie=Rt(),ie.position={start:ln(Z.start),end:void 0},X.push(ie)),this.stack.push(ie)}function j(Z){const X=this.stack.pop();X.value+=this.sliceSerialize(Z),X.position.end=ln(Z.end)}function x(Z){const X=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ie=X.children[X.children.length-1];ie.position.end=ln(Z.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(X.type)&&(L.call(this,Z),j.call(this,Z))}function C(){this.data.atHardBreak=!0}function M(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.value=Z}function E(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.value=Z}function T(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.value=Z}function B(){const Z=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";Z.type+="Reference",Z.referenceType=X,delete Z.url,delete Z.title}else delete Z.identifier,delete Z.label;this.data.referenceType=void 0}function Y(){const Z=this.stack[this.stack.length-1];if(this.data.inReference){const X=this.data.referenceType||"shortcut";Z.type+="Reference",Z.referenceType=X,delete Z.url,delete Z.title}else delete Z.identifier,delete Z.label;this.data.referenceType=void 0}function re(Z){const X=this.sliceSerialize(Z),ie=this.stack[this.stack.length-2];ie.label=g_(X),ie.identifier=Pt(X).toLowerCase()}function oe(){const Z=this.stack[this.stack.length-1],X=this.resume(),ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,ie.type==="link"){const we=Z.children;ie.children=we}else ie.alt=X}function w(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.url=Z}function U(){const Z=this.resume(),X=this.stack[this.stack.length-1];X.title=Z}function ne(){this.data.inReference=void 0}function _(){this.data.referenceType="collapsed"}function ue(Z){const X=this.resume(),ie=this.stack[this.stack.length-1];ie.label=X,ie.identifier=Pt(this.sliceSerialize(Z)).toLowerCase(),this.data.referenceType="full"}function Se(Z){this.data.characterReferenceType=Z.type}function H(Z){const X=this.sliceSerialize(Z),ie=this.data.characterReferenceType;let we;ie?(we=Ed(X,ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):we=zi(X);const ye=this.stack[this.stack.length-1];ye.value+=we}function he(Z){const X=this.stack.pop();X.position.end=ln(Z.end)}function Ee(Z){j.call(this,Z);const X=this.stack[this.stack.length-1];X.url=this.sliceSerialize(Z)}function Re(Z){j.call(this,Z);const X=this.stack[this.stack.length-1];X.url="mailto:"+this.sliceSerialize(Z)}function Le(){return{type:"blockquote",children:[]}}function nt(){return{type:"code",lang:null,meta:null,value:""}}function lt(){return{type:"inlineCode",value:""}}function kn(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function tn(){return{type:"emphasis",children:[]}}function nn(){return{type:"heading",depth:0,children:[]}}function ss(){return{type:"break"}}function rs(){return{type:"html",value:""}}function sn(){return{type:"image",title:null,url:"",alt:null}}function wt(){return{type:"link",title:null,url:"",children:[]}}function st(Z){return{type:"list",ordered:Z.type==="listOrdered",start:null,spread:Z._spread,children:[]}}function rn(Z){return{type:"listItem",spread:Z._spread,checked:null,children:[]}}function On(){return{type:"paragraph",children:[]}}function yt(){return{type:"strong",children:[]}}function Rt(){return{type:"text",value:""}}function ct(){return{type:"thematicBreak"}}}function ln(e){return{line:e.line,column:e.column,offset:e.offset}}function Fd(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?Fd(e,s):x_(e,s)}}function x_(e,t){let n;for(n in t)if(Md.call(t,n))switch(n){case"canContainEols":{const s=t[n];s&&e[n].push(...s);break}case"transforms":{const s=t[n];s&&e[n].push(...s);break}case"enter":case"exit":{const s=t[n];s&&Object.assign(e[n],s);break}}}function Cl(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+bs({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+bs({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+bs({start:t.start,end:t.end})+") is still open")}function k_(e){const t=this;t.parser=n;function n(s){return v_(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function w_(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function j_(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
272
|
+
`}]}function S_(e,t){const n=t.value?t.value+`
|
|
273
|
+
`:"",s={},r=t.lang?t.lang.split(/\s+/):[];r.length>0&&(s.className=["language-"+r[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function __(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function C_(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function I_(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),r=ns(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let i,l=e.footnoteCounts.get(s);l===void 0?(l=0,e.footnoteOrder.push(s),i=e.footnoteOrder.length):i=o+1,l+=1,e.footnoteCounts.set(s,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function N_(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function E_(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Ud(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const r=e.all(t),o=r[0];o&&o.type==="text"?o.value="["+o.value:r.unshift({type:"text",value:"["});const i=r[r.length-1];return i&&i.type==="text"?i.value+=s:r.push({type:"text",value:s}),r}function R_(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return Ud(e,t);const r={src:ns(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(r.title=s.title);const o={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,o),e.applyData(t,o)}function z_(e,t){const n={src:ns(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function T_(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function O_(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return Ud(e,t);const r={href:ns(s.url||"")};s.title!==null&&s.title!==void 0&&(r.title=s.title);const o={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function A_(e,t){const n={href:ns(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function $_(e,t,n){const s=e.all(t),r=n?P_(n):Bd(t),o={},i=[];if(typeof t.checked=="boolean"){const d=s[0];let p;d&&d.type==="element"&&d.tagName==="p"?p=d:(p={type:"element",tagName:"p",properties:{},children:[]},s.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<s.length;){const d=s[l];(r||l!==0||d.type!=="element"||d.tagName!=="p")&&i.push({type:"text",value:`
|
|
274
|
+
`}),d.type==="element"&&d.tagName==="p"&&!r?i.push(...d.children):i.push(d)}const c=s[s.length-1];c&&(r||c.type!=="element"||c.tagName!=="p")&&i.push({type:"text",value:`
|
|
275
|
+
`});const u={type:"element",tagName:"li",properties:o,children:i};return e.patch(t,u),e.applyData(t,u)}function P_(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let s=-1;for(;!t&&++s<n.length;)t=Bd(n[s])}return t}function Bd(e){return e.spread??e.children.length>1}function L_(e,t){const n={},s=e.all(t);let r=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++r<s.length;){const i=s[r];if(i.type==="element"&&i.tagName==="li"&&i.properties&&Array.isArray(i.properties.className)&&i.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function D_(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function M_(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function F_(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function U_(e,t){const n=e.all(t),s=n.shift(),r=[];if(s){const i={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(t.children[0],i),r.push(i)}if(n.length>0){const i={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=Ci(t.children[1]),c=kd(t.children[t.children.length-1]);l&&c&&(i.position={start:l,end:c}),r.push(i)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function B_(e,t,n){const s=n?n.children:void 0,r=(s?s.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,i=o?o.length:t.children.length;let l=-1;const c=[];for(;++l<i;){const d=t.children[l],p={},f=o?o[l]:void 0;f&&(p.align=f);let h={type:"element",tagName:r,properties:p,children:[]};d&&(h.children=e.all(d),e.patch(d,h),h=e.applyData(d,h)),c.push(h)}const u={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,u),e.applyData(t,u)}function Z_(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Il=9,Nl=32;function V_(e){const t=String(e),n=/\r?\n|\r/g;let s=n.exec(t),r=0;const o=[];for(;s;)o.push(El(t.slice(r,s.index),r>0,!0),s[0]),r=s.index+s[0].length,s=n.exec(t);return o.push(El(t.slice(r),r>0,!1)),o.join("")}function El(e,t,n){let s=0,r=e.length;if(t){let o=e.codePointAt(s);for(;o===Il||o===Nl;)s++,o=e.codePointAt(s)}if(n){let o=e.codePointAt(r-1);for(;o===Il||o===Nl;)r--,o=e.codePointAt(r-1)}return r>s?e.slice(s,r):""}function q_(e,t){const n={type:"text",value:V_(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function H_(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const W_={blockquote:w_,break:j_,code:S_,delete:__,emphasis:C_,footnoteReference:I_,heading:N_,html:E_,imageReference:R_,image:z_,inlineCode:T_,linkReference:O_,link:A_,listItem:$_,list:L_,paragraph:D_,root:M_,strong:F_,table:U_,tableCell:Z_,tableRow:B_,text:q_,thematicBreak:H_,toml:Bs,yaml:Bs,definition:Bs,footnoteDefinition:Bs};function Bs(){}const Zd=-1,Lr=0,ks=1,yr=2,Oi=3,Ai=4,$i=5,Pi=6,Vd=7,qd=8,K_=typeof self=="object"?self:globalThis,Rl=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new K_[e](t)},J_=(e,t)=>{const n=(r,o)=>(e.set(o,r),r),s=r=>{if(e.has(r))return e.get(r);const[o,i]=t[r];switch(o){case Lr:case Zd:return n(i,r);case ks:{const l=n([],r);for(const c of i)l.push(s(c));return l}case yr:{const l=n({},r);for(const[c,u]of i)l[s(c)]=s(u);return l}case Oi:return n(new Date(i),r);case Ai:{const{source:l,flags:c}=i;return n(new RegExp(l,c),r)}case $i:{const l=n(new Map,r);for(const[c,u]of i)l.set(s(c),s(u));return l}case Pi:{const l=n(new Set,r);for(const c of i)l.add(s(c));return l}case Vd:{const{name:l,message:c}=i;return n(Rl(l,c),r)}case qd:return n(BigInt(i),r);case"BigInt":return n(Object(BigInt(i)),r);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:l}=new Uint8Array(i);return n(new DataView(l),i)}}return n(Rl(o,i),r)};return s},zl=e=>J_(new Map,e)(0),Ln="",{toString:G_}={},{keys:Y_}=Object,ds=e=>{const t=typeof e;if(t!=="object"||!e)return[Lr,t];const n=G_.call(e).slice(8,-1);switch(n){case"Array":return[ks,Ln];case"Object":return[yr,Ln];case"Date":return[Oi,Ln];case"RegExp":return[Ai,Ln];case"Map":return[$i,Ln];case"Set":return[Pi,Ln];case"DataView":return[ks,n]}return n.includes("Array")?[ks,n]:n.includes("Error")?[Vd,n]:[yr,n]},Zs=([e,t])=>e===Lr&&(t==="function"||t==="symbol"),X_=(e,t,n,s)=>{const r=(i,l)=>{const c=s.push(i)-1;return n.set(l,c),c},o=i=>{if(n.has(i))return n.get(i);let[l,c]=ds(i);switch(l){case Lr:{let d=i;switch(c){case"bigint":l=qd,d=i.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return r([Zd],i)}return r([l,d],i)}case ks:{if(c){let f=i;return c==="DataView"?f=new Uint8Array(i.buffer):c==="ArrayBuffer"&&(f=new Uint8Array(i)),r([c,[...f]],i)}const d=[],p=r([l,d],i);for(const f of i)d.push(o(f));return p}case yr:{if(c)switch(c){case"BigInt":return r([c,i.toString()],i);case"Boolean":case"Number":case"String":return r([c,i.valueOf()],i)}if(t&&"toJSON"in i)return o(i.toJSON());const d=[],p=r([l,d],i);for(const f of Y_(i))(e||!Zs(ds(i[f])))&&d.push([o(f),o(i[f])]);return p}case Oi:return r([l,i.toISOString()],i);case Ai:{const{source:d,flags:p}=i;return r([l,{source:d,flags:p}],i)}case $i:{const d=[],p=r([l,d],i);for(const[f,h]of i)(e||!(Zs(ds(f))||Zs(ds(h))))&&d.push([o(f),o(h)]);return p}case Pi:{const d=[],p=r([l,d],i);for(const f of i)(e||!Zs(ds(f)))&&d.push(o(f));return p}}const{message:u}=i;return r([l,{name:c,message:u}],i)};return o},Tl=(e,{json:t,lossy:n}={})=>{const s=[];return X_(!(t||n),!!t,new Map,s)(e),s},vr=typeof structuredClone=="function"?((e,t)=>t&&("json"in t||"lossy"in t)?zl(Tl(e,t)):structuredClone(e)):(e,t)=>zl(Tl(e,t));function Q_(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function eC(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function tC(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Q_,s=e.options.footnoteBackLabel||eC,r=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const d=e.all(u),p=String(u.identifier).toUpperCase(),f=ns(p.toLowerCase());let h=0;const m=[],v=e.footnoteCounts.get(p);for(;v!==void 0&&++h<=v;){m.length>0&&m.push({type:"text",value:" "});let z=typeof n=="string"?n:n(c,h);typeof z=="string"&&(z={type:"text",value:z}),m.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(c,h),className:["data-footnote-backref"]},children:Array.isArray(z)?z:[z]})}const b=d[d.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const z=b.children[b.children.length-1];z&&z.type==="text"?z.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...m)}else d.push(...m);const k={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(d,!0)};e.patch(u,k),l.push(k)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...vr(i),id:"footnote-label"},children:[{type:"text",value:r}]},{type:"text",value:`
|
|
276
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
|
|
277
|
+
`}]}}const Dr=(function(e){if(e==null)return oC;if(typeof e=="function")return Mr(e);if(typeof e=="object")return Array.isArray(e)?nC(e):sC(e);if(typeof e=="string")return rC(e);throw new Error("Expected function, string, or object as test")});function nC(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Dr(e[n]);return Mr(s);function s(...r){let o=-1;for(;++o<t.length;)if(t[o].apply(this,r))return!0;return!1}}function sC(e){const t=e;return Mr(n);function n(s){const r=s;let o;for(o in e)if(r[o]!==t[o])return!1;return!0}}function rC(e){return Mr(t);function t(n){return n&&n.type===e}}function Mr(e){return t;function t(n,s,r){return!!(iC(n)&&e.call(this,n,typeof s=="number"?s:void 0,r||void 0))}}function oC(){return!0}function iC(e){return e!==null&&typeof e=="object"&&"type"in e}const Hd=[],aC=!0,qo=!1,lC="skip";function Wd(e,t,n,s){let r;typeof t=="function"&&typeof n!="function"?(s=n,n=t):r=t;const o=Dr(r),i=s?-1:1;l(e,void 0,[])();function l(c,u,d){const p=c&&typeof c=="object"?c:{};if(typeof p.type=="string"){const h=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return f;function f(){let h=Hd,m,v,b;if((!t||o(c,u,d[d.length-1]||void 0))&&(h=cC(n(c,d)),h[0]===qo))return h;if("children"in c&&c.children){const k=c;if(k.children&&h[0]!==lC)for(v=(s?k.children.length:-1)+i,b=d.concat(k);v>-1&&v<k.children.length;){const z=k.children[v];if(m=l(z,v,b)(),m[0]===qo)return m;v=typeof m[1]=="number"?m[1]:v+i}}return h}}}function cC(e){return Array.isArray(e)?e:typeof e=="number"?[aC,e]:e==null?Hd:[e]}function Li(e,t,n,s){let r,o,i;typeof t=="function"&&typeof n!="function"?(o=void 0,i=t,r=n):(o=t,i=n,r=s),Wd(e,o,l,r);function l(c,u){const d=u[u.length-1],p=d?d.children.indexOf(c):void 0;return i(c,p,d)}}const Ho={}.hasOwnProperty,uC={};function dC(e,t){const n=t||uC,s=new Map,r=new Map,o=new Map,i={...W_,...n.handlers},l={all:u,applyData:fC,definitionById:s,footnoteById:r,footnoteCounts:o,footnoteOrder:[],handlers:i,one:c,options:n,patch:pC,wrap:mC};return Li(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const p=d.type==="definition"?s:r,f=String(d.identifier).toUpperCase();p.has(f)||p.set(f,d)}}),l;function c(d,p){const f=d.type,h=l.handlers[f];if(Ho.call(l.handlers,f)&&h)return h(l,d,p);if(l.options.passThrough&&l.options.passThrough.includes(f)){if("children"in d){const{children:m,...v}=d,b=vr(v);return b.children=l.all(d),b}return vr(d)}return(l.options.unknownHandler||hC)(l,d,p)}function u(d){const p=[];if("children"in d){const f=d.children;let h=-1;for(;++h<f.length;){const m=l.one(f[h],d);if(m){if(h&&f[h-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=Ol(m.value)),!Array.isArray(m)&&m.type==="element")){const v=m.children[0];v&&v.type==="text"&&(v.value=Ol(v.value))}Array.isArray(m)?p.push(...m):p.push(m)}}}return p}}function pC(e,t){e.position&&(t.position=Qj(e))}function fC(e,t){let n=t;if(e&&e.data){const s=e.data.hName,r=e.data.hChildren,o=e.data.hProperties;if(typeof s=="string")if(n.type==="element")n.tagName=s;else{const i="children"in n?n.children:[n];n={type:"element",tagName:s,properties:{},children:i}}n.type==="element"&&o&&Object.assign(n.properties,vr(o)),"children"in n&&n.children&&r!==null&&r!==void 0&&(n.children=r)}return n}function hC(e,t){const n=t.data||{},s="value"in t&&!(Ho.call(n,"hProperties")||Ho.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function mC(e,t){const n=[];let s=-1;for(t&&n.push({type:"text",value:`
|
|
278
|
+
`});++s<e.length;)s&&n.push({type:"text",value:`
|
|
279
|
+
`}),n.push(e[s]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
280
|
+
`}),n}function Ol(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Al(e,t){const n=dC(e,t),s=n.one(e,void 0),r=tC(n),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return r&&o.children.push({type:"text",value:`
|
|
281
|
+
`},r),o}function gC(e,t){return e&&"run"in e?async function(n,s){const r=Al(n,{file:s,...t});await e.run(r,s)}:function(n,s){return Al(n,{file:s,...e||t})}}function $l(e){if(e)throw e}var ao,Pl;function yC(){if(Pl)return ao;Pl=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,r=function(c){return typeof Array.isArray=="function"?Array.isArray(c):t.call(c)==="[object Array]"},o=function(c){if(!c||t.call(c)!=="[object Object]")return!1;var u=e.call(c,"constructor"),d=c.constructor&&c.constructor.prototype&&e.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!u&&!d)return!1;var p;for(p in c);return typeof p>"u"||e.call(c,p)},i=function(c,u){n&&u.name==="__proto__"?n(c,u.name,{enumerable:!0,configurable:!0,value:u.newValue,writable:!0}):c[u.name]=u.newValue},l=function(c,u){if(u==="__proto__")if(e.call(c,u)){if(s)return s(c,u).value}else return;return c[u]};return ao=function c(){var u,d,p,f,h,m,v=arguments[0],b=1,k=arguments.length,z=!1;for(typeof v=="boolean"&&(z=v,v=arguments[1]||{},b=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});b<k;++b)if(u=arguments[b],u!=null)for(d in u)p=l(v,d),f=l(u,d),v!==f&&(z&&f&&(o(f)||(h=r(f)))?(h?(h=!1,m=p&&r(p)?p:[]):m=p&&o(p)?p:{},i(v,{name:d,newValue:c(z,m,f)})):typeof f<"u"&&i(v,{name:d,newValue:f}));return v},ao}var vC=yC();const lo=cd(vC);function Wo(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function bC(){const e=[],t={run:n,use:s};return t;function n(...r){let o=-1;const i=r.pop();if(typeof i!="function")throw new TypeError("Expected function as last argument, not "+i);l(null,...r);function l(c,...u){const d=e[++o];let p=-1;if(c){i(c);return}for(;++p<r.length;)(u[p]===null||u[p]===void 0)&&(u[p]=r[p]);r=u,d?xC(d,l)(...u):i(null,...u)}}function s(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function xC(e,t){let n;return s;function s(...i){const l=e.length>i.length;let c;l&&i.push(r);try{c=e.apply(this,i)}catch(u){const d=u;if(l&&n)throw d;return r(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(o,r):c instanceof Error?r(c):o(c))}function r(i,...l){n||(n=!0,t(i,...l))}function o(i){r(null,i)}}const Ut={basename:kC,dirname:wC,extname:jC,join:SC,sep:"/"};function kC(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');As(e);let n=0,s=-1,r=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(o){n=r+1;break}}else s<0&&(o=!0,s=r+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let i=-1,l=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(o){n=r+1;break}}else i<0&&(o=!0,i=r+1),l>-1&&(e.codePointAt(r)===t.codePointAt(l--)?l<0&&(s=r):(l=-1,s=i));return n===s?s=i:s<0&&(s=e.length),e.slice(n,s)}function wC(e){if(As(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function jC(e){As(e);let t=e.length,n=-1,s=0,r=-1,o=0,i;for(;t--;){const l=e.codePointAt(t);if(l===47){if(i){s=t+1;break}continue}n<0&&(i=!0,n=t+1),l===46?r<0?r=t:o!==1&&(o=1):r>-1&&(o=-1)}return r<0||n<0||o===0||o===1&&r===n-1&&r===s+1?"":e.slice(r,n)}function SC(...e){let t=-1,n;for(;++t<e.length;)As(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":_C(n)}function _C(e){As(e);const t=e.codePointAt(0)===47;let n=CC(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function CC(e,t){let n="",s=0,r=-1,o=0,i=-1,l,c;for(;++i<=e.length;){if(i<e.length)l=e.codePointAt(i);else{if(l===47)break;l=47}if(l===47){if(!(r===i-1||o===1))if(r!==i-1&&o===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",s=0):(n=n.slice(0,c),s=n.length-1-n.lastIndexOf("/")),r=i,o=0;continue}}else if(n.length>0){n="",s=0,r=i,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(r+1,i):n=e.slice(r+1,i),s=i-r-1;r=i,o=0}else l===46&&o>-1?o++:o=-1}return n}function As(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const IC={cwd:NC};function NC(){return"/"}function Ko(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function EC(e){if(typeof e=="string")e=new URL(e);else if(!Ko(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return RC(e)}function RC(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const s=t.codePointAt(n+2);if(s===70||s===102){const r=new TypeError("File URL path must not include encoded / characters");throw r.code="ERR_INVALID_FILE_URL_PATH",r}}return decodeURIComponent(t)}const co=["history","path","basename","stem","extname","dirname"];class Kd{constructor(t){let n;t?Ko(t)?n={path:t}:typeof t=="string"||zC(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":IC.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<co.length;){const o=co[s];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let r;for(r in n)co.includes(r)||(this[r]=n[r])}get basename(){return typeof this.path=="string"?Ut.basename(this.path):void 0}set basename(t){po(t,"basename"),uo(t,"basename"),this.path=Ut.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ut.dirname(this.path):void 0}set dirname(t){Ll(this.basename,"dirname"),this.path=Ut.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ut.extname(this.path):void 0}set extname(t){if(uo(t,"extname"),Ll(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ut.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ko(t)&&(t=EC(t)),po(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ut.basename(this.path,this.extname):void 0}set stem(t){po(t,"stem"),uo(t,"stem"),this.path=Ut.join(this.dirname||"",t+(this.extname||""))}fail(t,n,s){const r=this.message(t,n,s);throw r.fatal=!0,r}info(t,n,s){const r=this.message(t,n,s);return r.fatal=void 0,r}message(t,n,s){const r=new tt(t,n,s);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function uo(e,t){if(e&&e.includes(Ut.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ut.sep+"`")}function po(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Ll(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function zC(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const TC=(function(e){const t=this.constructor.prototype,n=t[e],s=function(){return n.apply(s,arguments)};return Object.setPrototypeOf(s,t),s}),OC={}.hasOwnProperty;class Di extends TC{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=bC()}copy(){const t=new Di;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(lo(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(mo("data",this.frozen),this.namespace[t]=n,this):OC.call(this.namespace,t)&&this.namespace[t]||void 0:t?(mo("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const r=n.call(t,...s);typeof r=="function"&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Vs(t),s=this.parser||this.Parser;return fo("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),fo("process",this.parser||this.Parser),ho("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(o,i){const l=Vs(t),c=s.parse(l);s.run(c,l,function(d,p,f){if(d||!p||!f)return u(d);const h=p,m=s.stringify(h,f);PC(m)?f.value=m:f.result=m,u(d,f)});function u(d,p){d||!p?i(d):o?o(p):n(void 0,p)}}}processSync(t){let n=!1,s;return this.freeze(),fo("processSync",this.parser||this.Parser),ho("processSync",this.compiler||this.Compiler),this.process(t,r),Ml("processSync","process",n),s;function r(o,i){n=!0,$l(o),s=i}}run(t,n,s){Dl(t),this.freeze();const r=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?o(void 0,s):new Promise(o);function o(i,l){const c=Vs(n);r.run(t,c,u);function u(d,p,f){const h=p||t;d?l(d):i?i(h):s(void 0,h,f)}}}runSync(t,n){let s=!1,r;return this.run(t,n,o),Ml("runSync","run",s),r;function o(i,l){$l(i),r=l,s=!0}}stringify(t,n){this.freeze();const s=Vs(n),r=this.compiler||this.Compiler;return ho("stringify",r),Dl(t),r(t,s)}use(t,...n){const s=this.attachers,r=this.namespace;if(mo("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):i(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...p]=u;c(d,p)}else i(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function i(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(r.settings=lo(!0,r.settings,u.settings))}function l(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const p=u[d];o(p)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let p=-1,f=-1;for(;++p<s.length;)if(s[p][0]===u){f=p;break}if(f===-1)s.push([u,...d]);else if(d.length>0){let[h,...m]=d;const v=s[f][1];Wo(v)&&Wo(h)&&(h=lo(!0,v,h)),s[f]=[u,h,...m]}}}}const AC=new Di().freeze();function fo(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ho(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function mo(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Dl(e){if(!Wo(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Ml(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Vs(e){return $C(e)?e:new Kd(e)}function $C(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function PC(e){return typeof e=="string"||LC(e)}function LC(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const DC="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Fl=[],Ul={allowDangerousHtml:!0},MC=/^(https?|ircs?|mailto|xmpp)$/i,FC=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function UC(e){const t=BC(e),n=ZC(e);return VC(t.runSync(t.parse(n),n),e)}function BC(e){const t=e.rehypePlugins||Fl,n=e.remarkPlugins||Fl,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ul}:Ul;return AC().use(k_).use(n).use(gC,s).use(t)}function ZC(e){const t=e.children||"",n=new Kd;return typeof t=="string"&&(n.value=t),n}function VC(e,t){const n=t.allowedElements,s=t.allowElement,r=t.components,o=t.disallowedElements,i=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||qC;for(const d of FC)Object.hasOwn(t,d.from)&&""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+DC+d.id;return Li(e,u),r1(e,{Fragment:a.Fragment,components:r,ignoreInvalidStyle:!0,jsx:a.jsx,jsxs:a.jsxs,passKeys:!0,passNode:!0});function u(d,p,f){if(d.type==="raw"&&f&&typeof p=="number")return i?f.children.splice(p,1):f.children[p]={type:"text",value:d.value},p;if(d.type==="element"){let h;for(h in ro)if(Object.hasOwn(ro,h)&&Object.hasOwn(d.properties,h)){const m=d.properties[h],v=ro[h];(v===null||v.includes(d.tagName))&&(d.properties[h]=c(String(m||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):o?o.includes(d.tagName):!1;if(!h&&s&&typeof p=="number"&&(h=!s(d,p,f)),h&&f&&typeof p=="number")return l&&d.children?f.children.splice(p,1,...d.children):f.children.splice(p,1),p}}}function qC(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),r=e.indexOf("/");return t===-1||r!==-1&&t>r||n!==-1&&t>n||s!==-1&&t>s||MC.test(e.slice(0,t))?e:""}function Bl(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let s=0,r=n.indexOf(t);for(;r!==-1;)s++,r=n.indexOf(t,r+t.length);return s}function HC(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function WC(e,t,n){const s=Dr((n||{}).ignore||[]),r=KC(t);let o=-1;for(;++o<r.length;)Wd(e,"text",i);function i(c,u){let d=-1,p;for(;++d<u.length;){const f=u[d],h=p?p.children:void 0;if(s(f,h?h.indexOf(f):void 0,p))return;p=f}if(p)return l(c,u)}function l(c,u){const d=u[u.length-1],p=r[o][0],f=r[o][1];let h=0;const m=d.children.indexOf(c);let v=!1,b=[];p.lastIndex=0;let k=p.exec(c.value);for(;k;){const z=k.index,R={index:k.index,input:k.input,stack:[...u,c]};let A=f(...k,R);if(typeof A=="string"&&(A=A.length>0?{type:"text",value:A}:void 0),A===!1?p.lastIndex=z+1:(h!==z&&b.push({type:"text",value:c.value.slice(h,z)}),Array.isArray(A)?b.push(...A):A&&b.push(A),h=z+k[0].length,v=!0),!p.global)break;k=p.exec(c.value)}return v?(h<c.value.length&&b.push({type:"text",value:c.value.slice(h)}),d.children.splice(m,1,...b)):b=[c],m+b.length}}function KC(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let s=-1;for(;++s<n.length;){const r=n[s];t.push([JC(r[0]),GC(r[1])])}return t}function JC(e){return typeof e=="string"?new RegExp(HC(e),"g"):e}function GC(e){return typeof e=="function"?e:function(){return e}}const go="phrasing",yo=["autolink","link","image","label"];function YC(){return{transforms:[rI],enter:{literalAutolink:QC,literalAutolinkEmail:vo,literalAutolinkHttp:vo,literalAutolinkWww:vo},exit:{literalAutolink:sI,literalAutolinkEmail:nI,literalAutolinkHttp:eI,literalAutolinkWww:tI}}}function XC(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:go,notInConstruct:yo},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:go,notInConstruct:yo},{character:":",before:"[ps]",after:"\\/",inConstruct:go,notInConstruct:yo}]}}function QC(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function vo(e){this.config.enter.autolinkProtocol.call(this,e)}function eI(e){this.config.exit.autolinkProtocol.call(this,e)}function tI(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function nI(e){this.config.exit.autolinkEmail.call(this,e)}function sI(e){this.exit(e)}function rI(e){WC(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,oI],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),iI]],{ignore:["link","linkReference"]})}function oI(e,t,n,s,r){let o="";if(!Jd(r)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!aI(n)))return!1;const i=lI(n+s);if(!i[0])return!1;const l={type:"link",title:null,url:o+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[l,{type:"text",value:i[1]}]:l}function iI(e,t,n,s){return!Jd(s,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function aI(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function lI(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const r=Bl(e,"(");let o=Bl(e,")");for(;s!==-1&&r>o;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),o++;return[e,n]}function Jd(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||En(n)||$r(n))&&(!t||n!==47)}Gd.peek=yI;function cI(){this.buffer()}function uI(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function dI(){this.buffer()}function pI(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function fI(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Pt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function hI(e){this.exit(e)}function mI(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Pt(this.sliceSerialize(e)).toLowerCase(),n.label=t}function gI(e){this.exit(e)}function yI(){return"["}function Gd(e,t,n,s){const r=n.createTracker(s);let o=r.move("[^");const i=n.enter("footnoteReference"),l=n.enter("reference");return o+=r.move(n.safe(n.associationId(e),{after:"]",before:o})),l(),i(),o+=r.move("]"),o}function vI(){return{enter:{gfmFootnoteCallString:cI,gfmFootnoteCall:uI,gfmFootnoteDefinitionLabelString:dI,gfmFootnoteDefinition:pI},exit:{gfmFootnoteCallString:fI,gfmFootnoteCall:hI,gfmFootnoteDefinitionLabelString:mI,gfmFootnoteDefinition:gI}}}function bI(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Gd},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,r,o,i){const l=o.createTracker(i);let c=l.move("[^");const u=o.enter("footnoteDefinition"),d=o.enter("label");return c+=l.move(o.safe(o.associationId(s),{before:c,after:"]"})),d(),c+=l.move("]:"),s.children&&s.children.length>0&&(l.shift(4),c+=l.move((t?`
|
|
282
|
+
`:" ")+o.indentLines(o.containerFlow(s,l.current()),t?Yd:xI))),u(),c}}function xI(e,t,n){return t===0?e:Yd(e,t,n)}function Yd(e,t,n){return(n?"":" ")+e}const kI=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Xd.peek=CI;function wI(){return{canContainEols:["delete"],enter:{strikethrough:SI},exit:{strikethrough:_I}}}function jI(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:kI}],handlers:{delete:Xd}}}function SI(e){this.enter({type:"delete",children:[]},e)}function _I(e){this.exit(e)}function Xd(e,t,n,s){const r=n.createTracker(s),o=n.enter("strikethrough");let i=r.move("~~");return i+=n.containerPhrasing(e,{...r.current(),before:i,after:"~"}),i+=r.move("~~"),o(),i}function CI(){return"~"}function II(e){return e.length}function NI(e,t){const n=t||{},s=(n.align||[]).concat(),r=n.stringLength||II,o=[],i=[],l=[],c=[];let u=0,d=-1;for(;++d<e.length;){const v=[],b=[];let k=-1;for(e[d].length>u&&(u=e[d].length);++k<e[d].length;){const z=EI(e[d][k]);if(n.alignDelimiters!==!1){const R=r(z);b[k]=R,(c[k]===void 0||R>c[k])&&(c[k]=R)}v.push(z)}i[d]=v,l[d]=b}let p=-1;if(typeof s=="object"&&"length"in s)for(;++p<u;)o[p]=Zl(s[p]);else{const v=Zl(s);for(;++p<u;)o[p]=v}p=-1;const f=[],h=[];for(;++p<u;){const v=o[p];let b="",k="";v===99?(b=":",k=":"):v===108?b=":":v===114&&(k=":");let z=n.alignDelimiters===!1?1:Math.max(1,c[p]-b.length-k.length);const R=b+"-".repeat(z)+k;n.alignDelimiters!==!1&&(z=b.length+z+k.length,z>c[p]&&(c[p]=z),h[p]=z),f[p]=R}i.splice(1,0,f),l.splice(1,0,h),d=-1;const m=[];for(;++d<i.length;){const v=i[d],b=l[d];p=-1;const k=[];for(;++p<u;){const z=v[p]||"";let R="",A="";if(n.alignDelimiters!==!1){const D=c[p]-(b[p]||0),O=o[p];O===114?R=" ".repeat(D):O===99?D%2?(R=" ".repeat(D/2+.5),A=" ".repeat(D/2-.5)):(R=" ".repeat(D/2),A=R):A=" ".repeat(D)}n.delimiterStart!==!1&&!p&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&z==="")&&(n.delimiterStart!==!1||p)&&k.push(" "),n.alignDelimiters!==!1&&k.push(R),k.push(z),n.alignDelimiters!==!1&&k.push(A),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||p!==u-1)&&k.push("|")}m.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return m.join(`
|
|
283
|
+
`)}function EI(e){return e==null?"":String(e)}function Zl(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function RI(e,t,n,s){const r=n.enter("blockquote"),o=n.createTracker(s);o.move("> "),o.shift(2);const i=n.indentLines(n.containerFlow(e,o.current()),zI);return r(),i}function zI(e,t,n){return">"+(n?"":" ")+e}function TI(e,t){return Vl(e,t.inConstruct,!0)&&!Vl(e,t.notInConstruct,!1)}function Vl(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++s<t.length;)if(e.includes(t[s]))return!0;return!1}function ql(e,t,n,s){let r=-1;for(;++r<n.unsafe.length;)if(n.unsafe[r].character===`
|
|
284
|
+
`&&TI(n.stack,n.unsafe[r]))return/[ \t]/.test(s.before)?"":" ";return`\\
|
|
285
|
+
`}function OI(e,t){const n=String(e);let s=n.indexOf(t),r=s,o=0,i=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;s!==-1;)s===r?++o>i&&(i=o):o=1,r=s+t.length,s=n.indexOf(t,r);return i}function AI(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function $I(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function PI(e,t,n,s){const r=$I(n),o=e.value||"",i=r==="`"?"GraveAccent":"Tilde";if(AI(e,n)){const p=n.enter("codeIndented"),f=n.indentLines(o,LI);return p(),f}const l=n.createTracker(s),c=r.repeat(Math.max(OI(o,r)+1,3)),u=n.enter("codeFenced");let d=l.move(c);if(e.lang){const p=n.enter(`codeFencedLang${i}`);d+=l.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...l.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${i}`);d+=l.move(" "),d+=l.move(n.safe(e.meta,{before:d,after:`
|
|
286
|
+
`,encode:["`"],...l.current()})),p()}return d+=l.move(`
|
|
287
|
+
`),o&&(d+=l.move(o+`
|
|
288
|
+
`)),d+=l.move(c),u(),d}function LI(e,t,n){return(n?"":" ")+e}function Mi(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function DI(e,t,n,s){const r=Mi(n),o=r==='"'?"Quote":"Apostrophe",i=n.enter("definition");let l=n.enter("label");const c=n.createTracker(s);let u=c.move("[");return u+=c.move(n.safe(n.associationId(e),{before:u,after:"]",...c.current()})),u+=c.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(l=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
289
|
+
`,...c.current()}))),l(),e.title&&(l=n.enter(`title${o}`),u+=c.move(" "+r),u+=c.move(n.safe(e.title,{before:u,after:r,...c.current()})),u+=c.move(r),l()),i(),u}function MI(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ns(e){return"&#x"+e.toString(16).toUpperCase()+";"}function br(e,t,n){const s=Jn(e),r=Jn(t);return s===void 0?r===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Qd.peek=FI;function Qd(e,t,n,s){const r=MI(n),o=n.enter("emphasis"),i=n.createTracker(s),l=i.move(r);let c=i.move(n.containerPhrasing(e,{after:r,before:l,...i.current()}));const u=c.charCodeAt(0),d=br(s.before.charCodeAt(s.before.length-1),u,r);d.inside&&(c=Ns(u)+c.slice(1));const p=c.charCodeAt(c.length-1),f=br(s.after.charCodeAt(0),p,r);f.inside&&(c=c.slice(0,-1)+Ns(p));const h=i.move(r);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},l+c+h}function FI(e,t,n){return n.options.emphasis||"*"}function UI(e,t){let n=!1;return Li(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,qo}),!!((!e.depth||e.depth<3)&&Ri(e)&&(t.options.setext||n))}function BI(e,t,n,s){const r=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(s);if(UI(e,n)){const d=n.enter("headingSetext"),p=n.enter("phrasing"),f=n.containerPhrasing(e,{...o.current(),before:`
|
|
290
|
+
`,after:`
|
|
291
|
+
`});return p(),d(),f+`
|
|
292
|
+
`+(r===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
|
|
293
|
+
`))+1))}const i="#".repeat(r),l=n.enter("headingAtx"),c=n.enter("phrasing");o.move(i+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
294
|
+
`,...o.current()});return/^[\t ]/.test(u)&&(u=Ns(u.charCodeAt(0))+u.slice(1)),u=u?i+" "+u:i,n.options.closeAtx&&(u+=" "+i),c(),l(),u}ep.peek=ZI;function ep(e){return e.value||""}function ZI(){return"<"}tp.peek=VI;function tp(e,t,n,s){const r=Mi(n),o=r==='"'?"Quote":"Apostrophe",i=n.enter("image");let l=n.enter("label");const c=n.createTracker(s);let u=c.move("![");return u+=c.move(n.safe(e.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(n.safe(e.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(l=n.enter("destinationRaw"),u+=c.move(n.safe(e.url,{before:u,after:e.title?" ":")",...c.current()}))),l(),e.title&&(l=n.enter(`title${o}`),u+=c.move(" "+r),u+=c.move(n.safe(e.title,{before:u,after:r,...c.current()})),u+=c.move(r),l()),u+=c.move(")"),i(),u}function VI(){return"!"}np.peek=qI;function np(e,t,n,s){const r=e.referenceType,o=n.enter("imageReference");let i=n.enter("label");const l=n.createTracker(s);let c=l.move("![");const u=n.safe(e.alt,{before:c,after:"]",...l.current()});c+=l.move(u+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const p=n.safe(n.associationId(e),{before:c,after:"]",...l.current()});return i(),n.stack=d,o(),r==="full"||!u||u!==p?c+=l.move(p+"]"):r==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}function qI(){return"!"}sp.peek=HI;function sp(e,t,n){let s=e.value||"",r="`",o=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(s);)r+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o<n.unsafe.length;){const i=n.unsafe[o],l=n.compilePattern(i);let c;if(i.atBreak)for(;c=l.exec(s);){let u=c.index;s.charCodeAt(u)===10&&s.charCodeAt(u-1)===13&&u--,s=s.slice(0,u)+" "+s.slice(c.index+1)}}return r+s+r}function HI(){return"`"}function rp(e,t){const n=Ri(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}op.peek=WI;function op(e,t,n,s){const r=Mi(n),o=r==='"'?"Quote":"Apostrophe",i=n.createTracker(s);let l,c;if(rp(e,n)){const d=n.stack;n.stack=[],l=n.enter("autolink");let p=i.move("<");return p+=i.move(n.containerPhrasing(e,{before:p,after:">",...i.current()})),p+=i.move(">"),l(),n.stack=d,p}l=n.enter("link"),c=n.enter("label");let u=i.move("[");return u+=i.move(n.containerPhrasing(e,{before:u,after:"](",...i.current()})),u+=i.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),u+=i.move("<"),u+=i.move(n.safe(e.url,{before:u,after:">",...i.current()})),u+=i.move(">")):(c=n.enter("destinationRaw"),u+=i.move(n.safe(e.url,{before:u,after:e.title?" ":")",...i.current()}))),c(),e.title&&(c=n.enter(`title${o}`),u+=i.move(" "+r),u+=i.move(n.safe(e.title,{before:u,after:r,...i.current()})),u+=i.move(r),c()),u+=i.move(")"),l(),u}function WI(e,t,n){return rp(e,n)?"<":"["}ip.peek=KI;function ip(e,t,n,s){const r=e.referenceType,o=n.enter("linkReference");let i=n.enter("label");const l=n.createTracker(s);let c=l.move("[");const u=n.containerPhrasing(e,{before:c,after:"]",...l.current()});c+=l.move(u+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const p=n.safe(n.associationId(e),{before:c,after:"]",...l.current()});return i(),n.stack=d,o(),r==="full"||!u||u!==p?c+=l.move(p+"]"):r==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}function KI(){return"["}function Fi(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function JI(e){const t=Fi(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function GI(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function ap(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function YI(e,t,n,s){const r=n.enter("list"),o=n.bulletCurrent;let i=e.ordered?GI(n):Fi(n);const l=e.ordered?i==="."?")":".":JI(n);let c=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),ap(n)===i&&d){let p=-1;for(;++p<e.children.length;){const f=e.children[p];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(i=l),n.bulletCurrent=i;const u=n.containerFlow(e,s);return n.bulletLastUsed=i,n.bulletCurrent=o,r(),u}function XI(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function QI(e,t,n,s){const r=XI(n);let o=n.bulletCurrent||Fi(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let i=o.length+1;(r==="tab"||r==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const l=n.createTracker(s);l.move(o+" ".repeat(i-o.length)),l.shift(i);const c=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,l.current()),d);return c(),u;function d(p,f,h){return f?(h?"":" ".repeat(i))+p:(h?o:o+" ".repeat(i-o.length))+p}}function eN(e,t,n,s){const r=n.enter("paragraph"),o=n.enter("phrasing"),i=n.containerPhrasing(e,s);return o(),r(),i}const tN=Dr(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function nN(e,t,n,s){return(e.children.some(function(r){return tN(r)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function sN(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}lp.peek=rN;function lp(e,t,n,s){const r=sN(n),o=n.enter("strong"),i=n.createTracker(s),l=i.move(r+r);let c=i.move(n.containerPhrasing(e,{after:r,before:l,...i.current()}));const u=c.charCodeAt(0),d=br(s.before.charCodeAt(s.before.length-1),u,r);d.inside&&(c=Ns(u)+c.slice(1));const p=c.charCodeAt(c.length-1),f=br(s.after.charCodeAt(0),p,r);f.inside&&(c=c.slice(0,-1)+Ns(p));const h=i.move(r+r);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},l+c+h}function rN(e,t,n){return n.options.strong||"*"}function oN(e,t,n,s){return n.safe(e.value,s)}function iN(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function aN(e,t,n){const s=(ap(n)+(n.options.ruleSpaces?" ":"")).repeat(iN(n));return n.options.ruleSpaces?s.slice(0,-1):s}const cp={blockquote:RI,break:ql,code:PI,definition:DI,emphasis:Qd,hardBreak:ql,heading:BI,html:ep,image:tp,imageReference:np,inlineCode:sp,link:op,linkReference:ip,list:YI,listItem:QI,paragraph:eN,root:nN,strong:lp,text:oN,thematicBreak:aN};function lN(){return{enter:{table:cN,tableData:Hl,tableHeader:Hl,tableRow:dN},exit:{codeText:pN,table:uN,tableData:bo,tableHeader:bo,tableRow:bo}}}function cN(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function uN(e){this.exit(e),this.data.inTable=void 0}function dN(e){this.enter({type:"tableRow",children:[]},e)}function bo(e){this.exit(e)}function Hl(e){this.enter({type:"tableCell",children:[]},e)}function pN(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,fN));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function fN(e,t){return t==="|"?t:e}function hN(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,r=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
295
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:i,tableCell:c,tableRow:l}};function i(h,m,v,b){return u(d(h,v,b),h.align)}function l(h,m,v,b){const k=p(h,v,b),z=u([k]);return z.slice(0,z.indexOf(`
|
|
296
|
+
`))}function c(h,m,v,b){const k=v.enter("tableCell"),z=v.enter("phrasing"),R=v.containerPhrasing(h,{...b,before:o,after:o});return z(),k(),R}function u(h,m){return NI(h,{align:m,alignDelimiters:s,padding:n,stringLength:r})}function d(h,m,v){const b=h.children;let k=-1;const z=[],R=m.enter("table");for(;++k<b.length;)z[k]=p(b[k],m,v);return R(),z}function p(h,m,v){const b=h.children;let k=-1;const z=[],R=m.enter("tableRow");for(;++k<b.length;)z[k]=c(b[k],h,m,v);return R(),z}function f(h,m,v){let b=cp.inlineCode(h,m,v);return v.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function mN(){return{exit:{taskListCheckValueChecked:Wl,taskListCheckValueUnchecked:Wl,paragraph:yN}}}function gN(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:vN}}}function Wl(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function yN(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const s=n.children[0];if(s&&s.type==="text"){const r=t.children;let o=-1,i;for(;++o<r.length;){const l=r[o];if(l.type==="paragraph"){i=l;break}}i===n&&(s.value=s.value.slice(1),s.value.length===0?n.children.shift():n.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,n.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function vN(e,t,n,s){const r=e.children[0],o=typeof e.checked=="boolean"&&r&&r.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",l=n.createTracker(s);o&&l.move(i);let c=cp.listItem(e,t,n,{...s,...l.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(d){return d+i}}function bN(){return[YC(),vI(),wI(),lN(),mN()]}function xN(e){return{extensions:[XC(),bI(e),jI(),hN(e),gN()]}}const kN={tokenize:IN,partial:!0},up={tokenize:NN,partial:!0},dp={tokenize:EN,partial:!0},pp={tokenize:RN,partial:!0},wN={tokenize:zN,partial:!0},fp={name:"wwwAutolink",tokenize:_N,previous:mp},hp={name:"protocolAutolink",tokenize:CN,previous:gp},en={name:"emailAutolink",tokenize:SN,previous:yp},qt={};function jN(){return{text:qt}}let jn=48;for(;jn<123;)qt[jn]=en,jn++,jn===58?jn=65:jn===91&&(jn=97);qt[43]=en;qt[45]=en;qt[46]=en;qt[95]=en;qt[72]=[en,hp];qt[104]=[en,hp];qt[87]=[en,fp];qt[119]=[en,fp];function SN(e,t,n){const s=this;let r,o;return i;function i(p){return!Jo(p)||!yp.call(s,s.previous)||Ui(s.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(p))}function l(p){return Jo(p)?(e.consume(p),l):p===64?(e.consume(p),c):n(p)}function c(p){return p===46?e.check(wN,d,u)(p):p===45||p===95||et(p)?(o=!0,e.consume(p),c):d(p)}function u(p){return e.consume(p),r=!0,c}function d(p){return o&&r&&at(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function _N(e,t,n){const s=this;return r;function r(i){return i!==87&&i!==119||!mp.call(s,s.previous)||Ui(s.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(kN,e.attempt(up,e.attempt(dp,o),n),n)(i))}function o(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function CN(e,t,n){const s=this;let r="",o=!1;return i;function i(p){return(p===72||p===104)&&gp.call(s,s.previous)&&!Ui(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(p),e.consume(p),l):n(p)}function l(p){if(at(p)&&r.length<5)return r+=String.fromCodePoint(p),e.consume(p),l;if(p===58){const f=r.toLowerCase();if(f==="http"||f==="https")return e.consume(p),c}return n(p)}function c(p){return p===47?(e.consume(p),o?u:(o=!0,c)):n(p)}function u(p){return p===null||gr(p)||Pe(p)||En(p)||$r(p)?n(p):e.attempt(up,e.attempt(dp,d),n)(p)}function d(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function IN(e,t,n){let s=0;return r;function r(i){return(i===87||i===119)&&s<3?(s++,e.consume(i),r):i===46&&s===3?(e.consume(i),o):n(i)}function o(i){return i===null?n(i):t(i)}}function NN(e,t,n){let s,r,o;return i;function i(u){return u===46||u===95?e.check(pp,c,l)(u):u===null||Pe(u)||En(u)||u!==45&&$r(u)?c(u):(o=!0,e.consume(u),i)}function l(u){return u===95?s=!0:(r=s,s=void 0),e.consume(u),i}function c(u){return r||s||!o?n(u):t(u)}}function EN(e,t){let n=0,s=0;return r;function r(i){return i===40?(n++,e.consume(i),r):i===41&&s<n?o(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(pp,t,o)(i):i===null||Pe(i)||En(i)?t(i):(e.consume(i),r)}function o(i){return i===41&&s++,e.consume(i),r}}function RN(e,t,n){return s;function s(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),s):l===38?(e.consume(l),o):l===93?(e.consume(l),r):l===60||l===null||Pe(l)||En(l)?t(l):n(l)}function r(l){return l===null||l===40||l===91||Pe(l)||En(l)?t(l):s(l)}function o(l){return at(l)?i(l):n(l)}function i(l){return l===59?(e.consume(l),s):at(l)?(e.consume(l),i):n(l)}}function zN(e,t,n){return s;function s(o){return e.consume(o),r}function r(o){return et(o)?n(o):t(o)}}function mp(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Pe(e)}function gp(e){return!at(e)}function yp(e){return!(e===47||Jo(e))}function Jo(e){return e===43||e===45||e===46||e===95||et(e)}function Ui(e){let t=e.length,n=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){n=!0;break}if(s._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const TN={tokenize:FN,partial:!0};function ON(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:LN,continuation:{tokenize:DN},exit:MN}},text:{91:{name:"gfmFootnoteCall",tokenize:PN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:AN,resolveTo:$N}}}}function AN(e,t,n){const s=this;let r=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let i;for(;r--;){const c=s.events[r][1];if(c.type==="labelImage"){i=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return l;function l(c){if(!i||!i._balanced)return n(c);const u=Pt(s.sliceSerialize({start:i.end,end:s.now()}));return u.codePointAt(0)!==94||!o.includes(u.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function $N(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},r={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};r.end.column++,r.end.offset++,r.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},r.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},l=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",r,t],["exit",r,t],["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...l),e}function PN(e,t,n){const s=this,r=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,i;return l;function l(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),c}function c(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(p){if(o>999||p===93&&!i||p===null||p===91||Pe(p))return n(p);if(p===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return r.includes(Pt(s.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Pe(p)||(i=!0),o++,e.consume(p),p===92?d:u}function d(p){return p===91||p===92||p===93?(e.consume(p),o++,u):u(p)}}function LN(e,t,n){const s=this,r=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,i=0,l;return c;function c(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(m)}function d(m){if(i>999||m===93&&!l||m===null||m===91||Pe(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return o=Pt(s.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return Pe(m)||(l=!0),i++,e.consume(m),m===92?p:d}function p(m){return m===91||m===92||m===93?(e.consume(m),i++,d):d(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),r.includes(o)||r.push(o),Ce(e,h,"gfmFootnoteDefinitionWhitespace")):n(m)}function h(m){return t(m)}}function DN(e,t,n){return e.check(Os,t,e.attempt(TN,t,n))}function MN(e){e.exit("gfmFootnoteDefinition")}function FN(e,t,n){const s=this;return Ce(e,r,"gfmFootnoteDefinitionIndent",5);function r(o){const i=s.events[s.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(o):n(o)}}function UN(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:r,resolveAll:s};return t==null&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function s(o,i){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},p=[["enter",u,i],["enter",o[c][1],i],["exit",o[c][1],i],["enter",d,i]],f=i.parser.constructs.insideSpan.null;f&&kt(p,p.length,0,Pr(f,o.slice(c+1,l),i)),kt(p,p.length,0,[["exit",d,i],["enter",o[l][1],i],["exit",o[l][1],i],["exit",u,i]]),kt(o,c-1,l-c+3,p),l=c+p.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function r(o,i,l){const c=this.previous,u=this.events;let d=0;return p;function p(h){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(h):(o.enter("strikethroughSequenceTemporary"),f(h))}function f(h){const m=Jn(c);if(h===126)return d>1?l(h):(o.consume(h),d++,f);if(d<2&&!t)return l(h);const v=o.exit("strikethroughSequenceTemporary"),b=Jn(h);return v._open=!b||b===2&&!!m,v._close=!m||m===2&&!!b,i(h)}}}class BN{constructor(){this.map=[]}add(t,n,s){ZN(this,t,n,s)}consume(t){if(this.map.sort(function(o,i){return o[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let r=s.pop();for(;r;){for(const o of r)t.push(o);r=s.pop()}this.map.length=0}}function ZN(e,t,n,s){let r=0;if(!(n===0&&s.length===0)){for(;r<e.map.length;){if(e.map[r][0]===t){e.map[r][1]+=n,e.map[r][2].push(...s);return}r+=1}e.map.push([t,n,s])}}function VN(e,t){let n=!1;const s=[];for(;t<e.length;){const r=e[t];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=s.length-1;s[o]=s[o]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return s}function qN(){return{flow:{null:{name:"table",tokenize:HN,resolveAll:WN}}}}function HN(e,t,n){const s=this;let r=0,o=0,i;return l;function l(j){let x=s.events.length-1;for(;x>-1;){const E=s.events[x][1].type;if(E==="lineEnding"||E==="linePrefix")x--;else break}const C=x>-1?s.events[x][1].type:null,M=C==="tableHead"||C==="tableRow"?O:c;return M===O&&s.parser.lazy[s.now().line]?n(j):M(j)}function c(j){return e.enter("tableHead"),e.enter("tableRow"),u(j)}function u(j){return j===124||(i=!0,o+=1),d(j)}function d(j){return j===null?n(j):ce(j)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),h):n(j):je(j)?Ce(e,d,"whitespace")(j):(o+=1,i&&(i=!1,r+=1),j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),i=!0,d):(e.enter("data"),p(j)))}function p(j){return j===null||j===124||Pe(j)?(e.exit("data"),d(j)):(e.consume(j),j===92?f:p)}function f(j){return j===92||j===124?(e.consume(j),p):p(j)}function h(j){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(j):(e.enter("tableDelimiterRow"),i=!1,je(j)?Ce(e,m,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):m(j))}function m(j){return j===45||j===58?b(j):j===124?(i=!0,e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),v):D(j)}function v(j){return je(j)?Ce(e,b,"whitespace")(j):b(j)}function b(j){return j===58?(o+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),k):j===45?(o+=1,k(j)):j===null||ce(j)?A(j):D(j)}function k(j){return j===45?(e.enter("tableDelimiterFiller"),z(j)):D(j)}function z(j){return j===45?(e.consume(j),z):j===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),R):(e.exit("tableDelimiterFiller"),R(j))}function R(j){return je(j)?Ce(e,A,"whitespace")(j):A(j)}function A(j){return j===124?m(j):j===null||ce(j)?!i||r!==o?D(j):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(j)):D(j)}function D(j){return n(j)}function O(j){return e.enter("tableRow"),I(j)}function I(j){return j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),I):j===null||ce(j)?(e.exit("tableRow"),t(j)):je(j)?Ce(e,I,"whitespace")(j):(e.enter("data"),F(j))}function F(j){return j===null||j===124||Pe(j)?(e.exit("data"),I(j)):(e.consume(j),j===92?L:F)}function L(j){return j===92||j===124?(e.consume(j),F):F(j)}}function WN(e,t){let n=-1,s=!0,r=0,o=[0,0,0,0],i=[0,0,0,0],l=!1,c=0,u,d,p;const f=new BN;for(;++n<e.length;){const h=e[n],m=h[1];h[0]==="enter"?m.type==="tableHead"?(l=!1,c!==0&&(Kl(f,t,c,u,d),d=void 0,c=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(s=!0,p=void 0,o=[0,0,0,0],i=[0,n+1,0,0],l&&(l=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",d,t]])),r=m.type==="tableDelimiterRow"?2:d?3:1):r&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(s=!1,i[2]===0&&(o[1]!==0&&(i[0]=i[1],p=qs(f,t,o,r,void 0,p),o=[0,0,0,0]),i[2]=n)):m.type==="tableCellDivider"&&(s?s=!1:(o[1]!==0&&(i[0]=i[1],p=qs(f,t,o,r,void 0,p)),o=i,i=[o[1],n,0,0])):m.type==="tableHead"?(l=!0,c=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=n,o[1]!==0?(i[0]=i[1],p=qs(f,t,o,r,n,p)):i[1]!==0&&(p=qs(f,t,i,r,n,p)),r=0):r&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&Kl(f,t,c,u,d),f.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=VN(t.events,n))}return e}function qs(e,t,n,s,r,o){const i=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(o.end=Object.assign({},Mn(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const c=Mn(t.events,n[1]);if(o={type:i,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const u=Mn(t.events,n[2]),d=Mn(t.events,n[3]),p={type:l,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",p,t]]),s!==2){const f=t.events[n[2]],h=t.events[n[3]];if(f[1].end=Object.assign({},h[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return r!==void 0&&(o.end=Object.assign({},Mn(t.events,r)),e.add(r,0,[["exit",o,t]]),o=void 0),o}function Kl(e,t,n,s,r){const o=[],i=Mn(t.events,n);r&&(r.end=Object.assign({},i),o.push(["exit",r,t])),s.end=Object.assign({},i),o.push(["exit",s,t]),e.add(n+1,0,o)}function Mn(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const KN={name:"tasklistCheck",tokenize:GN};function JN(){return{text:{91:KN}}}function GN(e,t,n){const s=this;return r;function r(c){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return Pe(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),i):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),i):n(c)}function i(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(c)}function l(c){return ce(c)?t(c):je(c)?e.check({tokenize:YN},t,n)(c):n(c)}}function YN(e,t,n){return Ce(e,s,"whitespace");function s(r){return r===null?n(r):t(r)}}function XN(e){return Nd([jN(),ON(),UN(e),qN(),JN()])}const QN={};function eE(e){const t=this,n=e||QN,s=t.data(),r=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),i=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);r.push(XN(n)),o.push(bN()),i.push(xN(n))}const tE="_acp-markdown_dbfga_1",nE="_acp-markdown-table_dbfga_105",sE="_acp-markdown-code-block_dbfga_112",rE="_acp-markdown-code-header_dbfga_134",Xs={acpMarkdown:tE,acpMarkdownTable:nE,acpMarkdownCodeBlock:sE,acpMarkdownCodeHeader:rE},oE={pre({children:e,node:t,...n}){var s,r;const o=t?.children,i=(r=(s=o?.[0])==null?void 0:s.properties)==null?void 0:r.className,l=Array.isArray(i)?i.find(u=>u.startsWith("language-")):void 0,c=l?.replace("language-","");return c?a.jsxs("div",{className:Xs.acpMarkdownCodeBlock,children:[a.jsx("div",{className:Xs.acpMarkdownCodeHeader,children:a.jsx("span",{children:c})}),a.jsx("pre",{...n,children:e})]}):a.jsx("pre",{...n,children:e})},code({className:e,children:t,...n}){return a.jsx("code",{className:e,...n,children:t})},a({href:e,children:t,...n}){return a.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",...n,children:t})},table({children:e}){return a.jsx("div",{className:Xs.acpMarkdownTable,children:a.jsx("table",{children:e})})}};function Bi({children:e,className:t}){return a.jsx("div",{className:`${Xs.acpMarkdown}${t?` ${t}`:""}`,children:a.jsx(UC,{remarkPlugins:[eE],components:oE,children:e})})}const iE="_acp-diff-view_1cavl_1",aE="_acp-diff-view__header_1cavl_8",lE="_acp-diff-view__content_1cavl_23",cE="_acp-diff-view__file_1cavl_31",uE="_acp-diff-view__filename_1cavl_37",dE="_acp-diff-view__old_1cavl_45",pE="_acp-diff-view__new_1cavl_51",Mt={acpDiffView:iE,acpDiffViewHeader:aE,acpDiffViewContent:lE,acpDiffViewFile:cE,acpDiffViewFilename:uE,acpDiffViewOld:dE,acpDiffViewNew:pE};function fE({diffs:e=[]}){const{t}=zn();return e.length===0?a.jsxs("div",{className:Mt.acpDiffView,children:[a.jsx("div",{className:Mt.acpDiffViewHeader,children:t("diff.title")}),a.jsx("div",{className:Mt.acpDiffEmptyState,children:t("diff.emptyState")})]}):a.jsxs("div",{className:Mt.acpDiffView,children:[a.jsx("div",{className:Mt.acpDiffViewHeader,children:t("diff.title")}),a.jsx("div",{className:Mt.acpDiffViewContent,children:e.map((n,s)=>a.jsxs("div",{className:Mt.acpDiffViewFile,children:[a.jsx("div",{className:Mt.acpDiffViewFilename,children:n.path}),n.oldText&&a.jsxs("div",{className:Mt.acpDiffViewOld,children:["- ",n.oldText]}),a.jsxs("div",{className:Mt.acpDiffViewNew,children:["+ ",n.newText]})]},s))})]})}function hE(e){const t=Dc(od,n=>n.sessions);return g.useMemo(()=>{if(!e)return[];const n=t.get(e);return n?Array.from(n.terminals.values()):[]},[t,e])}const mE="_acp-terminal-view_xbaol_1",gE="_acp-terminal-view__header_xbaol_9",He={acpTerminalView:mE,acpTerminalViewHeader:gE};function yE({sessionId:e,terminals:t}){const{t:n}=zn(),s=hE(e??null),r=t??s;return r.length===0?a.jsxs("div",{className:He.acpTerminalView,children:[a.jsx("div",{className:He.acpTerminalViewHeader,children:n("terminal.title")}),a.jsx("div",{className:He.acpTerminalEmpty,children:n("terminal.empty")})]}):a.jsxs("div",{className:He.acpTerminalView,children:[a.jsxs("div",{className:He.acpTerminalViewHeader,children:[n("terminal.title"),a.jsx("span",{className:He.acpTerminalCount,children:r.length})]}),a.jsx("div",{className:He.acpTerminalList,children:r.map(o=>a.jsx(vE,{terminal:o,t:n},o.terminalId))})]})}function vE({terminal:e,t}){var n;const[s,r]=g.useState(!1),o=e.exitStatus===null,i=((n=e.exitStatus)==null?void 0:n.exitCode)!=null;return a.jsxs("div",{className:`${He.acpTerminalItem} ${o?He.acpTerminalItemRunning:""}`,children:[a.jsxs("button",{type:"button",className:He.acpTerminalItemHeader,onClick:()=>r(!s),"aria-expanded":!s,children:[a.jsx("span",{className:He.acpTerminalItemStatus,children:o?a.jsx("span",{className:He.acpTerminalStatusDot}):i?a.jsx("span",{className:`${He.acpTerminalExitBadge} ${e.exitStatus.exitCode===0?He.acpTerminalExitSuccess:He.acpTerminalExitError}`,children:e.exitStatus.exitCode}):a.jsx("span",{className:He.acpTerminalExitBadge,children:t("terminal.signaled")})}),a.jsxs("span",{className:He.acpTerminalItemCommand,children:[a.jsx("span",{className:He.acpTerminalItemLabel,children:t("terminal.command")}),e.command,e.args?` ${e.args.join(" ")}`:""]}),a.jsx("span",{className:He.acpTerminalChevron,children:s?"▶":"▼"})]}),!s&&a.jsxs("pre",{className:He.acpTerminalItemOutput,children:[e.output||(o?t("terminal.running"):""),e.truncated&&a.jsx("span",{className:He.acpTerminalTruncatedNote,children:t("terminal.truncated")})]})]})}const bE="_acp-tool-call_u9a95_1",xE="_acp-tool-call__header_u9a95_14",kE="_acp-tool-call__status_u9a95_28",wE="_acp-tool-call__status--pending_u9a95_34",jE="_acp-tool-call__status--in-progress_u9a95_38",SE="_acp-tool-call__status--completed_u9a95_42",_E="_acp-tool-call__status--failed_u9a95_45",CE="_acp-tool-call__kind_u9a95_48",IE="_acp-tool-call__name_u9a95_53",NE="_acp-tool-call__chevron_u9a95_62",EE="_acp-tool-call__chevron--open_u9a95_67",RE="_acp-tool-call__body_u9a95_70",zE="_acp-tool-call__content-text_u9a95_76",TE="_acp-tool-call__locations_u9a95_79",OE="_acp-tool-call__location_u9a95_79",AE="_acp-tool-call__location-icon_u9a95_110",$E="_acp-tool-call__location-path_u9a95_114",PE="_acp-tool-call__location-line_u9a95_117",Qe={acpToolCall:bE,acpToolCallHeader:xE,acpToolCallStatus:kE,acpToolCallStatusPending:wE,acpToolCallStatusInProgress:jE,acpToolCallStatusCompleted:SE,acpToolCallStatusFailed:_E,acpToolCallKind:CE,acpToolCallName:IE,acpToolCallChevron:NE,acpToolCallChevronOpen:EE,acpToolCallBody:RE,acpToolCallContentText:zE,acpToolCallLocations:TE,acpToolCallLocation:OE,acpToolCallLocationIcon:AE,acpToolCallLocationPath:$E,acpToolCallLocationLine:PE},LE={pending:Qe.acpToolCallStatusPending,in_progress:Qe.acpToolCallStatusInProgress,completed:Qe.acpToolCallStatusCompleted,failed:Qe.acpToolCallStatusFailed},DE={read:"📄",edit:"✏️",delete:"🗑️",move:"📦",search:"🔍",execute:"⚡",think:"💭",fetch:"🌐",switch_mode:"🔄"};function ME({loc:e,onNavigate:t}){const n=e.path.replace(/\\/g,"/").split("/").pop()||e.path,s=r=>{r.stopPropagation(),t?.(e.path,e.line)};return a.jsxs("span",{className:Qe.acpToolCallLocation,onClick:s,title:`${e.path}${e.line!=null?`:${e.line}`:""}`,role:"button",tabIndex:0,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),r.stopPropagation(),t?.(e.path,e.line))},children:[a.jsx("span",{className:Qe.acpToolCallLocationIcon,children:"📄"}),a.jsxs("span",{className:Qe.acpToolCallLocationPath,children:[n,e.line!=null&&a.jsxs("span",{className:Qe.acpToolCallLocationLine,children:[":",e.line]})]})]})}function FE({toolCall:e,onNavigate:t}){const[n,s]=g.useState(!1),r=e.content&&e.content.length>0,o=e.locations&&e.locations.length>0,{t:i}=zn(),l=Dc(od,c=>c.sessions);return a.jsxs("div",{className:Qe.acpToolCall,children:[a.jsxs("button",{className:Qe.acpToolCallHeader,onClick:()=>s(!n),"aria-expanded":n,children:[a.jsx("span",{className:`${Qe.acpToolCallStatus} ${LE[String(e.status)]||""}`}),e.kind&&a.jsx("span",{className:Qe.acpToolCallKind,title:e.kind,children:DE[e.kind]||"🔧"}),a.jsx("span",{className:Qe.acpToolCallName,children:e.title}),a.jsx("span",{className:`${Qe.acpToolCallChevron}${n?` ${Qe.acpToolCallChevronOpen}`:""}`,children:"▶"})]}),o&&a.jsx("div",{className:Qe.acpToolCallLocations,children:e.locations.map((c,u)=>a.jsx(ME,{loc:c,onNavigate:t},`${c.path}:${c.line??""}-${u}`))}),n&&r&&a.jsx("div",{className:Qe.acpToolCallBody,children:e.content.map((c,u)=>{switch(c.type){case"content":{const d=c;return a.jsx("pre",{className:Qe.acpToolCallContentText,children:d.content.text},u)}case"diff":{const d=c;return a.jsx(fE,{diffs:[{path:d.path,oldText:d.oldText??void 0,newText:d.newText}]},u)}case"terminal":{const d=c;let p;for(const[,h]of l){const m=h.terminals.get(d.terminalId);if(m){p=m;break}}const f=p?[p]:[{terminalId:d.terminalId,command:"",output:"",exitStatus:null,truncated:!1}];return a.jsx(yE,{terminals:f},u)}default:return null}})})]})}const UE="_acp-thought-view_1hsnd_1",BE="_acp-thought-view__header_1hsnd_6",ZE="_acp-thought-view__label_1hsnd_22",VE="_acp-thought-view__chevron_1hsnd_25",qE="_acp-thought-view__chevron--open_1hsnd_31",HE="_acp-thought-view__spinner_1hsnd_34",WE="_acp-thought-view__body_1hsnd_42",KE="_acp-thought-view__empty_1hsnd_72",Jt={acpThoughtView:UE,acpThoughtViewHeader:BE,acpThoughtViewLabel:ZE,acpThoughtViewChevron:VE,acpThoughtViewChevronOpen:qE,acpThoughtViewSpinner:HE,acpThoughtViewBody:WE,acpThoughtViewEmpty:KE};function JE(e){switch(e.type){case"text":return a.jsx(Bi,{children:e.text});case"resource":case"resource_link":return null;default:return null}}function GE({thought:e,isStreaming:t}){const[n,s]=g.useState(!1),r=g.useRef(t),{t:o}=zn();g.useEffect(()=>{t?s(!0):r.current&&!t&&s(!1),r.current=t},[t]);const i=e.length>0&&e.some(l=>l.type==="text"&&l.text.length>0);return a.jsxs("div",{className:Jt.acpThoughtView,children:[a.jsxs("button",{className:Jt.acpThoughtViewHeader,onClick:()=>s(!n),"aria-expanded":n,children:[a.jsx("span",{className:`${Jt.acpThoughtViewChevron}${n?` ${Jt.acpThoughtViewChevronOpen}`:""}`,children:"▶"}),a.jsx("span",{className:Jt.acpThoughtViewLabel,children:o(t?"thought.thinking":"thought.title")}),t&&a.jsx("span",{className:Jt.acpThoughtViewSpinner})]}),n&&i&&a.jsx("div",{className:Jt.acpThoughtViewBody,children:e.map((l,c)=>a.jsx(Bt.Fragment,{children:JE(l)},c))}),n&&t&&!i&&a.jsx("div",{className:Jt.acpThoughtViewBody,children:a.jsx("span",{className:Jt.acpThoughtViewEmpty,children:o("thought.reasoning")})})]})}const YE="_acp-plan-view_pjklh_1",XE="_acp-plan-view--streaming_pjklh_13",QE="_acp-plan-view__header_pjklh_16",eR="_acp-plan-view__chevron_pjklh_32",tR="_acp-plan-view__chevron--open_pjklh_38",nR="_acp-plan-view__label_pjklh_41",sR="_acp-plan-view__progress_pjklh_44",rR="_acp-plan-view__spinner_pjklh_50",oR="_acp-plan-view__body_pjklh_58",iR="_acp-plan-list_pjklh_65",aR="_acp-plan-item_pjklh_71",lR="_acp-plan-item-status_pjklh_103",cR="_acp-plan-item-content_pjklh_121",uR="_acp-plan-item-content--done_pjklh_124",Je={acpPlanView:YE,acpPlanViewStreaming:XE,acpPlanViewHeader:QE,acpPlanViewChevron:eR,acpPlanViewChevronOpen:tR,acpPlanViewLabel:nR,acpPlanViewProgress:sR,acpPlanViewSpinner:rR,acpPlanViewBody:oR,acpPlanList:iR,acpPlanItem:aR,acpPlanItemStatus:lR,acpPlanItemContent:cR,acpPlanItemContentDone:uR},Jl={pending:"○",in_progress:"◐",completed:"◉"},dR={pending:Je.acpPlanStatusPending,in_progress:Je.acpPlanStatusInProgress,completed:Je.acpPlanStatusCompleted},pR={high:Je.acpPlanPriorityHigh,medium:Je.acpPlanPriorityMedium,low:Je.acpPlanPriorityLow};function fR({entries:e,isStreaming:t}){const[n,s]=g.useState(!0),r=g.useRef(t),{t:o}=zn();if(g.useEffect(()=>{t?s(!0):r.current&&!t&&s(!1),r.current=t},[t]),e.length===0)return null;const i=e.filter(c=>c.status==="completed").length,l=e.filter(c=>c.status==="in_progress").length;return a.jsxs("div",{className:`${Je.acpPlanView}${t?` ${Je.acpPlanViewStreaming}`:""}`,children:[a.jsxs("button",{className:Je.acpPlanViewHeader,onClick:()=>s(!n),"aria-expanded":n,children:[a.jsx("span",{className:`${Je.acpPlanViewChevron}${n?` ${Je.acpPlanViewChevronOpen}`:""}`,children:"▶"}),a.jsx("span",{className:Je.acpPlanViewLabel,children:o(t?"plan.planning":"plan.title")}),a.jsxs("span",{className:Je.acpPlanViewProgress,children:[i,"/",e.length]}),l>0&&a.jsx("span",{className:Je.acpPlanViewSpinner})]}),n&&a.jsx("div",{className:Je.acpPlanViewBody,children:a.jsx("ol",{className:Je.acpPlanList,children:e.map((c,u)=>a.jsxs("li",{className:`${Je.acpPlanItem} ${pR[c.priority]??""}`,children:[a.jsx("span",{className:`${Je.acpPlanItemStatus} ${dR[c.status]??""}`,children:Jl[c.status]??Jl.pending}),a.jsx("span",{className:`${Je.acpPlanItemContent}${c.status==="completed"?` ${Je.acpPlanItemContentDone}`:""}`,children:c.content})]},u))})})]})}const hR="_acp-message-bubble_1fe8h_45",mR="_acp-message-bubble--agent_1fe8h_50",gR="_acp-message-bubble__content_1fe8h_50",yR="_acp-message-bubble__resource_1fe8h_59",vR="_acp-message-bubble__resource-name_1fe8h_74",bR="_acp-message-bubble__stop-reason_1fe8h_83",xR="_acp-message-bubble__image_1fe8h_88",kR="_acp-streaming-indicator_1fe8h_106",wR="_acp-streaming-indicator__dots_1fe8h_117",jR="_acp-streaming-indicator__dot_1fe8h_117",ft={acpMessageBubble:hR,acpMessageBubbleAgent:mR,acpMessageBubbleContent:gR,acpMessageBubbleResource:yR,acpMessageBubbleResourceName:vR,acpMessageBubbleStopReason:bR,acpMessageBubbleImage:xR,acpStreamingIndicator:kR,acpStreamingIndicatorDots:wR,acpStreamingIndicatorDot:jR};function SR(e){if("annotations"in e&&e.annotations!=null)return null;switch(e.type){case"text":return a.jsx(Bi,{children:e.text});case"resource":const t=e,n=t.resource.uri.split("/").pop()||t.resource.uri,s=decodeURIComponent(n);return a.jsxs("div",{className:ft.acpMessageBubbleResource,children:[a.jsx("span",{children:"📄"}),a.jsx("div",{children:a.jsx("div",{className:ft.acpMessageBubbleResourceName,children:s})})]});case"resource_link":const r=e;return a.jsxs("div",{className:ft.acpMessageBubbleResource,children:[a.jsx("span",{children:"🔗"}),a.jsx("span",{className:ft.acpMessageBubbleResourceName,children:r.name||r.uri})]});case"image":{const o=e,i=`data:${o.mimeType};base64,${o.data}`;return a.jsx("img",{className:ft.acpMessageBubbleImage,src:i,alt:o.uri||"image"})}default:return null}}function _R(e,t,n,s){switch(e.type){case"thought":return a.jsx(GE,{thought:e.thought,isStreaming:!!n},t);case"tool_calls":return e.toolCalls.map(r=>a.jsx(FE,{toolCall:r,onNavigate:s},r.toolCallId));case"content":return e.content.map((r,o)=>a.jsx(Bt.Fragment,{children:SR(r)},o));case"plan":return e.plan.every(r=>r.status==="completed")?a.jsx(fR,{entries:e.plan,isStreaming:!1},t):null}}function CR({messages:e,isStreaming:t=!1,onNavigateFile:n}){const s=e.reduceRight((l,c)=>l??c.stopReason,void 0),r=e[e.length-1],o=r?.parts[r.parts.length-1],i=t&&o?.type==="thought";return a.jsx("div",{className:`${ft.acpMessageBubble} ${ft.acpMessageBubbleAgent}`,children:a.jsxs("div",{className:ft.acpMessageBubbleContent,children:[e.map(l=>a.jsx(Bt.Fragment,{children:l.parts.map((c,u)=>{const d=l===r&&u===r.parts.length-1&&i;return _R(c,u,d,n)})},l.id)),s&&a.jsx("div",{className:ft.acpMessageBubbleStopReason,children:s})]})})}const IR="_acp-user-message_4a1s0_1",NR="_acp-user-message__actions_4a1s0_8",ER="_acp-user-message__action-btn_4a1s0_25",RR="_acp-user-message__action-btn--copied_4a1s0_45",zR="_acp-user-message__bubble_4a1s0_49",TR="_acp-user-message__attachments_4a1s0_60",OR="_acp-user-message__attachment_4a1s0_60",AR="_acp-user-message__attachment--image_4a1s0_80",$R="_acp-user-message__stop-reason_4a1s0_91",Nt={acpUserMessage:IR,acpUserMessageActions:NR,acpUserMessageActionBtn:ER,acpUserMessageActionBtnCopied:RR,acpUserMessageBubble:zR,acpUserMessageAttachments:TR,acpUserMessageAttachment:OR,acpUserMessageAttachmentImage:AR,acpUserMessageStopReason:$R};function PR({textContent:e,onEdit:t}){const[n,s]=g.useState(!1),{t:r}=zn();g.useEffect(()=>{if(!n)return;const l=setTimeout(()=>s(!1),2e3);return()=>clearTimeout(l)},[n]);const o=g.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0)}catch{}},[e]),i=g.useCallback(()=>{t(e)},[e,t]);return a.jsxs("div",{className:Nt.acpUserMessageActions,children:[a.jsx("button",{className:`${Nt.acpUserMessageActionBtn} ${n?Nt.acpUserMessageActionBtnCopied:""}`,onClick:o,"aria-label":r("userMessage.copy"),title:r("userMessage.copy"),children:n?"✓":"⎘"}),a.jsx("button",{className:Nt.acpUserMessageActionBtn,onClick:i,"aria-label":r("userMessage.edit"),title:r("userMessage.edit"),children:"✎"})]})}function LR(e){const t=[],n=[],s=[];for(const r of e.parts)if(r.type==="content")for(const o of r.content)"annotations"in o&&o.annotations!=null||(o.type==="text"?(t.push(o),s.push(o.text)):n.push(o));return{textBlocks:t,attachmentBlocks:n,textContent:s.join(`
|
|
297
|
+
`)}}function DR(e){switch(e.type){case"image":{const t=e,n=`data:${t.mimeType};base64,${t.data}`;return a.jsx("div",{className:`${Nt.acpUserMessageAttachment} ${Nt.acpUserMessageAttachmentImage}`,children:a.jsx("img",{src:n,alt:t.uri||"image"})},t.uri||t.data.slice(0,20))}case"resource":{const t=e,n=t.resource.uri.split("/").pop()||t.resource.uri,s=decodeURIComponent(n);return a.jsxs("div",{className:Nt.acpUserMessageAttachment,children:[a.jsx("span",{children:"📄"}),a.jsx("span",{children:s})]},t.resource.uri)}case"resource_link":{const t=e;return a.jsxs("div",{className:Nt.acpUserMessageAttachment,children:[a.jsx("span",{children:"🔗"}),a.jsx("span",{children:t.name||t.uri})]},t.uri)}default:return null}}Bt.memo(function({message:e,onEdit:t}){const{textBlocks:n,attachmentBlocks:s,textContent:r}=g.useMemo(()=>LR(e),[e]);return a.jsxs("div",{className:Nt.acpUserMessage,children:[a.jsxs("div",{className:Nt.acpUserMessageBubble,children:[s.length>0&&a.jsx("div",{className:Nt.acpUserMessageAttachments,children:s.map(DR)}),n.map((o,i)=>{const l=o.text;return a.jsx(Bi,{children:l},i)})]}),t&&r&&a.jsx(PR,{textContent:r,onEdit:t}),e.stopReason&&a.jsx("div",{className:Nt.acpUserMessageStopReason,children:e.stopReason})]})});function MR(){const{t:e}=zn();return a.jsxs("div",{className:ft.acpStreamingIndicator,"aria-label":e("streaming.ariaLabel"),role:"status",children:[a.jsx("span",{children:e("streaming.generating")}),a.jsxs("span",{className:ft.acpStreamingIndicatorDots,children:[a.jsx("span",{className:ft.acpStreamingIndicatorDot}),a.jsx("span",{className:ft.acpStreamingIndicatorDot}),a.jsx("span",{className:ft.acpStreamingIndicatorDot})]})]})}function FR(e){const t=new Map,n=new Map,s=new Map;for(const r of e){const o=r.payload;if(r.kind==="prompt.admitted"&&["owner_admin_console","local_console","owner_channel"].includes(r.source)&&!o.text?.redacted){const i=o.displayText?.text??o.text?.text;(i||o.attachments?.length)&&t.set(r.promptId,{attachments:o.attachments?.map(l=>({...l,url:`/fleet/api/v1/roles/${encodeURIComponent(r.roleId)}/attachments/${l.id}`})),id:r.promptId,role:"user",timestamp:Date.parse(r.at),parts:[{type:"content",content:[{type:"text",text:i}]}]})}if(["message.chunk","message.replace"].includes(r.kind)&&o.content?.type==="text"){const i=r.messageId??r.eventId;if(o.content.redacted){t.delete(i);continue}const l=t.get(i)?.parts[0],c=(r.kind==="message.chunk"&&l?.type==="content"&&l.content[0]?.type==="text"?l.content[0].text:"")+o.content.text;t.set(i,{id:i,role:o.role==="user"?"user":"agent",timestamp:Date.parse(r.at),parts:[{type:"content",content:[{type:"text",text:c}]}]})}if(r.kind==="tool.upsert"||r.kind==="tool.content_chunk"){const i=n.get(o.toolCallId),l=s.get(o.toolCallId),c={...l,...o};r.kind==="tool.content_chunk"&&(c.content=[...l?.content??[],...Array.isArray(o.content)?o.content:o.content?[{type:"content",content:o.content}]:[]]),s.set(o.toolCallId,c);const u=(c.content??[]).filter(p=>p.type==="content"&&p.content?.type==="text"&&!p.content.redacted).map(p=>({type:"content",content:{type:"text",text:p.content.text}}));for(const p of c.content??[])p.type==="diff"&&!p.newText?.redacted&&!p.oldText?.redacted&&u.push({type:"diff",path:p.path??"",oldText:p.oldText?.text??"",newText:p.newText?.text??""}),p.type==="terminal"&&u.push({type:"content",content:{type:"text",text:"Terminal "+p.terminalId+" · No terminal output was included in this event."}});for(const[p,f]of[["Input",c.rawInput],["Output",c.rawOutput]])f?.truncated&&u.push({type:"content",content:{type:"text",text:p+" exceeded the server size limit; details were omitted."}}),f?.redacted&&u.push({type:"content",content:{type:"text",text:p+" contains protected data and was withheld by the server."}}),f&&!f.redacted&&f.json!==void 0&&u.push({type:"content",content:{type:"text",text:p+"\n```json\n"+JSON.stringify(f.json,null,2)+"\n```"}});u.length||u.push({type:"content",content:{type:"text",text:(c.title??"Tool")+`
|
|
298
|
+
|
|
299
|
+
`+(c.rawInput?.redacted||c.rawOutput?.redacted?"Details were withheld by the server.":["pending","in_progress","inProgress"].includes(c.status)?"Tool is still running; output has not arrived.":"No additional output was supplied for this tool call.")}});const d={...i,toolCallId:o.toolCallId,title:c.title??"Tool",status:c.status??"pending",content:u};n.set(o.toolCallId,d),t.set("tool:"+o.toolCallId,{id:"tool:"+o.toolCallId,role:"agent",timestamp:Date.parse(r.at),parts:[{type:"tool_calls",toolCalls:[d]}]})}r.kind==="error"&&t.set(r.eventId,{id:r.eventId,role:"system",timestamp:Date.parse(r.at),parts:[{type:"content",content:[{type:"text",text:"The agent reported an error. Check its status before retrying."}]}]})}return[...t.values()]}const vp=(e,t)=>e.length===t.length&&e.every((n,s)=>n===t[s]),bp=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function UR(e,t){const n=new Map(e.map(r=>[r.id,r])),s=t.map(r=>{const o=n.get(r.id);return o&&bp(o,r)?o:r});return vp(s,e)?e:s}function BR(e,t){return bp(e,t)?e:t}function xp({group:e}){return a.jsxs(lc,{outgoing:e[0].role==="user",className:"fleet-acp-message "+e[0].role,"aria-label":e[0].role==="user"?"You":"Agent",children:[e.map(t=>a.jsx("span",{id:"fleet-message-"+encodeURIComponent(t.id),"aria-hidden":!0},t.id)),a.jsx(CR,{messages:e}),e.map(t=>t.attachments?.length?a.jsx(Dp,{items:t.attachments},t.id):null)]})}xp.displayName="AcpMessageGroup";const ZR=g.memo(xp,(e,t)=>vp(e.group,t.group));function kp({messages:e,taskCards:t}){const n=[];for(const s of e){const r=n[n.length-1];s.role==="agent"&&r?.[0].role==="agent"?r.push(s):n.push([s])}return a.jsx(a.Fragment,{children:[...n.map(s=>({time:s[0].timestamp,node:a.jsx(ZR,{group:s},s[0].id)})),...t.map(s=>({time:Date.parse(s.at),node:a.jsxs("section",{className:"fleet-task-notice","aria-label":"Task created",children:[a.jsxs("small",{children:["Task created · ",s.state]}),a.jsx("strong",{children:s.title}),a.jsx("a",{href:"/fleet/tasks/"+encodeURIComponent(s.taskId),children:"Open task →"})]},"task:"+s.operationId)}))].sort((s,r)=>s.time-r.time).map(s=>s.node)})}kp.displayName="AcpThread";const VR=g.memo(kp);function qR({agent:e,requests:t,decided:n}){const[s,r]=g.useState(""),[o,i]=g.useState(!1),l=async(c,u)=>{i(!0),r("");try{await ee(`/roles/${encodeURIComponent(e)}/permissions/${encodeURIComponent(c.permissionId)}`,{commandId:crypto.randomUUID(),sessionGeneration:c.sessionGeneration,optionId:u}),n()}catch(d){r(d.message)}finally{i(!1)}};return t.length?a.jsxs("div",{className:"fleet-agent-requests","aria-label":"Agent requests",children:[s&&a.jsx("p",{role:"alert",children:s}),t.map(c=>a.jsxs("section",{className:"fleet-agent-request","aria-label":c.title,children:[a.jsx("strong",{children:"Needs your decision"}),a.jsx("p",{children:c.title}),a.jsx("div",{className:"fleet-actions",children:c.options.map(u=>a.jsx(J,{disabled:o,onClick:()=>void l(c,u.optionId),children:u.name},u.optionId))})]},c.permissionId))]}):null}function HR(e,t){const n=new Map;for(const r of e)r.kind==="permission.requested"&&n.set(r.permissionId,{permissionId:r.permissionId,title:r.payload?.title??"Agent requests permission",sessionGeneration:t?.sessionGeneration,options:r.payload?.options??[]}),r.kind==="permission.resolved"&&n.delete(r.permissionId);const s=t?.pendingPermissionIds??[];return[...n.values()].filter(r=>s.includes(r.permissionId))}function WR({id:e,name:t,active:n,dark:s,back:r,actions:o,viewed:i,captureNotificationRevision:l}){const c=g.useRef(i);c.current=i;const u=g.useRef(l);u.current=l;const d=oi(),p=Sc("fleet-pending-input:"+e),[f,h]=g.useState(()=>{try{return!!sessionStorage.getItem("fleet-pending-input:"+e)}catch{return!1}}),[m,v]=g.useState([]),[b,k]=g.useState(null),[z,R]=g.useState([]),[A,D]=g.useState(!1),[O,I]=g.useState(""),[F,L]=g.useState(""),[j,x]=g.useState(),[C,M]=g.useState(!1),[E,T]=g.useState(!1),[B,Y]=g.useState(!1),[re,oe]=g.useState(!1),[w,U]=g.useState(null),[ne,_]=g.useState([]),[ue,Se]=g.useState([]),[H,he]=g.useState(!1),[Ee,Re]=g.useState(!1),[Le,nt]=g.useState(0),lt=g.useRef(null),[kn,tn]=g.useState(null),[nn,ss]=g.useState(""),[rs,sn]=g.useState(0),wt=G=>({id:G,loaded:!1,events:[],context:[],cursor:"",hasOlder:!1}),st=g.useRef(wt("")),[rn,On]=g.useState(!1),[yt,Rt]=g.useState(!1),ct=g.useRef(null),Z=g.useRef(null),X=g.useRef(null),ie=g.useRef(!0),we=g.useRef(0),[ye,ke]=g.useState(!1),Xe=G=>G.scrollHeight-G.scrollTop-G.clientHeight<100,ut=(G,fe)=>{const Oe=G.events,Fe=[...G.context,...Oe];v(be=>UR(be,FR(Oe))),_(be=>BR(be,[...new Map(Oe.filter(_e=>_e.kind==="fleet.task_created"&&_e.source==="fleet_lifecycle"&&_e.promptId&&/^[a-z0-9]{17}$/.test(_e.payload?.taskId)).map(_e=>[_e.payload.operationId,{..._e.payload,at:_e.at}])).values()])),Se(Fe.filter(be=>be.kind==="capabilities.updated"&&be.sessionGeneration===fe.sessionGeneration&&Array.isArray(be.payload?.commands)).at(-1)?.payload.commands??[]),On(G.hasOlder),U(be=>be&&!Oe.some(_e=>_e.kind==="turn.completed"&&_e.promptId===be.promptId)?be:null)};g.useEffect(()=>{if(!n)return;let G=!0,fe;st.current.id!==e&&(st.current=wt(e));const Oe=be=>`/roles/${encodeURIComponent(e)}/conversation?${be}`,Fe=async()=>{const be=u.current?.()??-1;try{const _e=await ee(`/roles/${encodeURIComponent(e)}`);if(!G)return;he(_e.role.lifetime==="permanent"),ss(_e.status.session?.runtimeModel?.label??_e.role.config?.harness??"");const rt=_e.status.session?.reachability==="online";if(D(rt),!rt){k(null),R([]),Se([]),I("");return}const St=st.current;let Dt,N,W=!0;const q=async()=>{if(N=await ee(Oe("latest=1&limit=200")),Array.isArray(N.context))return{id:e,loaded:!0,events:N.events,context:N.context,cursor:N.nextCursor??"",older:N.olderCursor,hasOlder:!!N.hasOlder,generation:N.snapshot?.sessionGeneration};const te=[...N.events];let le=N.nextCursor??"";for(;N.hasMore&&N.nextCursor&&(N=await ee(Oe(`limit=1000&after=${encodeURIComponent(le)}`)),te.push(...N.events),!(!N.nextCursor||N.nextCursor===le));)le=N.nextCursor;return{id:e,loaded:!0,events:te,context:[],cursor:le,hasOlder:!1,generation:N.snapshot?.sessionGeneration}};if(!St.loaded)Dt=await q();else{let te=St.cursor;const le=[];for(;;){N=await ee(Oe(`limit=1000${te?"&after="+encodeURIComponent(te):""}`)),le.push(...N.events);const Ie=N.nextCursor??te;if(!N.hasMore||Ie===te){te=Ie;break}te=Ie}St.generation!==void 0&&N.snapshot?.sessionGeneration!==St.generation?Dt=await q():(W=le.length>0,Dt={...St,events:W?[...St.events,...le]:St.events,cursor:te})}if(!G||st.current!==St)return;st.current=Dt,W&&ut(Dt,N.snapshot),k(N.snapshot),R(HR([...Dt.context,...Dt.events],N.snapshot)),I(""),requestAnimationFrame(()=>{G&&document.visibilityState==="visible"&&(!location.hash.startsWith("#fleet-message-")||document.getElementById(location.hash.slice(1)))&&c.current?.(be)})}catch(_e){G&&I(_e.message.includes("ENOENT")?"Agent is starting. Reconnecting…":_e.message)}finally{G&&(fe=setTimeout(Fe,2e3))}};return Fe(),()=>{G=!1,clearTimeout(fe)}},[e,n,rs]);const jt=async()=>{const G=st.current;if(!(!G.loaded||!G.hasOlder||!G.older||yt)){Rt(!0);try{const fe=await ee(`/roles/${encodeURIComponent(e)}/conversation?before=${encodeURIComponent(G.older)}&limit=200`);if(st.current!==G||fe.snapshot?.sessionGeneration!==G.generation)return;const Oe={...G,events:[...fe.events,...G.events],older:fe.olderCursor,hasOlder:!!fe.hasOlder&&!!fe.olderCursor};st.current=Oe,ie.current=!1;const Fe=X.current;Fe&&(ct.current=Fe.scrollHeight-Fe.scrollTop),ut(Oe,fe.snapshot)}catch(fe){I(fe.message)}finally{Rt(!1)}}},de=g.useRef("");g.useLayoutEffect(()=>{const G=location.hash;if(!n||!G.startsWith("#fleet-message-")||de.current===G)return;const fe=document.getElementById(G.slice(1));fe&&(fe.scrollIntoView({block:"center"}),ie.current=!1,de.current=G)},[m,n]),g.useEffect(()=>{n&&document.visibilityState==="visible"&&location.hash.startsWith("#fleet-message-")&&!document.getElementById(location.hash.slice(1))&&rn&&!yt&&jt()},[m,n,rn,yt]),g.useLayoutEffect(()=>{const G=X.current;G&&ct.current!==null&&(G.scrollTop=G.scrollHeight-ct.current,ct.current=null)},[m]),g.useLayoutEffect(()=>{const G=X.current;n&&G&&(ie.current&&(G.scrollTop=G.scrollHeight),ke(!Xe(G)))},[m,n,B]),g.useEffect(()=>{const G=X.current;if(!G)return;const fe=new ResizeObserver(()=>{ie.current&&(G.scrollTop=G.scrollHeight),ke(!Xe(G))});return fe.observe(G),()=>fe.disconnect()},[]),g.useEffect(()=>{try{const G=sessionStorage.getItem("fleet-pending-input:"+e);if(G){const fe=JSON.parse(G);L(fe.text),T(!!fe.expectedSessionGeneration),x(fe.expectedSessionGeneration)}}catch{}},[e]);const qe=b?.pendingPermissionIds?.length>0,ze=!!w||b?.readiness==="running"||b?.queueDepth>0,dt=B?"Sending…":qe?"Waiting for your approval":A?ze?w?.state==="queued"?"Message queued · Agent is working":"Agent is thinking…":"Ready":"Connecting to agent…",An=[...ue.filter(G=>!["help","restart","force-restart"].includes(G.name)).map(G=>({name:G.name,description:G.description?.text??"",inputHint:G.inputHint})),...H?[{name:"restart",description:"Restart and resume the saved session"},{name:"force-restart",description:"Restart with fresh conversation context"}]:[]],Ht=F.match(/^\/([a-z0-9_-]*)$/i)?.[1],zt=Ht===void 0?[]:An.filter(G=>G.name.startsWith(Ht)),vt=!p.has&&!E&&A&&!Ee&&Ht!==void 0,os=G=>{L("/"+G.name+(G.inputHint?" ":"")),Re(!0),lt.current?.focus()},Wt=()=>{try{sessionStorage.removeItem("fleet-pending-input:"+e)}catch{}h(!1),I("")},wn=async()=>{if(!F.trim()&&!p.has||B||ze||C)return;const G=E&&F.trimStart().startsWith("/")?`Voice message:
|
|
300
|
+
`+F:F,fe=E||p.has?null:G.trim().match(/^\/([a-z][a-z0-9_-]*)(?:\s+(.*))?$/s);if(fe){const[,be,_e]=fe;if(be==="help"){L("/"),Re(!1),nt(0);return}if(["restart","force-restart"].includes(be)){if(!H||_e){I("Restart commands require a persistent agent and take no arguments.");return}tn(be==="restart"?"restart_resume":"restart_fresh");return}const rt=ue.find(St=>St.name===be);if(!rt){I(`/${be} is not available in this session. Type / to see supported commands.`);return}if(_e&&!rt.inputHint){I(`/${be} takes no arguments.`);return}}const Oe="fleet-pending-input:"+e;let Fe;Y(!0);try{const be=sessionStorage.getItem(Oe);if(!be&&E&&(!j||j!==b?.sessionGeneration)){Y(!1),I("Agent session changed. Clear the voice draft before composing a new message in this session.");return}if(Fe=be?JSON.parse(be):{text:G,commandId:crypto.randomUUID(),...E?{expectedSessionGeneration:j}:{}},Fe.text!==G){Y(!1),I("A previous send is unconfirmed. Restore its text to retry the same request."),L(Fe.text);return}if(!be&&p.has){const _e=await p.upload(e,b?.sessionGeneration);Fe={...Fe,expectedSessionGeneration:b.sessionGeneration,attachments:_e.map(rt=>rt.id),attachmentDetails:_e}}sessionStorage.setItem(Oe,JSON.stringify(Fe)),h(!0)}catch(be){Y(!1),I(be.message||"Cannot retain this request safely in browser storage.");return}Y(!0),I(""),ie.current=!0;try{const be=await ee(`/roles/${encodeURIComponent(e)}/input`,Fe);sessionStorage.removeItem(Oe),h(!1),p.clear(),U(be),v(_e=>[..._e,{id:be.promptId,attachments:Fe.attachmentDetails?.map(rt=>({id:rt.id,name:rt.name,mimeType:rt.mimeType,size:rt.size,url:`/fleet/api/v1/roles/${encodeURIComponent(e)}/attachments/${rt.id}`})),role:"user",timestamp:Date.now(),parts:[{type:"content",content:[{type:"text",text:G}]}]}]),L(""),T(!1),x(void 0),sn(_e=>_e+1)}catch(be){be.code==="stale_state"?(sessionStorage.removeItem(Oe),h(!1),I(p.has?"Agent session changed. Remove the attachments and select them again.":be.message)):I(be.message)}finally{Y(!1)}};return a.jsx(Ej,{defaultLocale:"en-US",children:a.jsxs("div",{ref:d,className:"fleet-acp chat-canvas","data-app-update-busy":!!F.trim()||p.has||C||B||f,"data-acp-theme":s?"dark":"light",children:[a.jsxs(Xo,{className:"fleet-acp-header",children:[a.jsx(wr,{onClick:r,label:"Back to chats"}),a.jsxs("div",{children:[a.jsx("strong",{children:t}),a.jsxs("small",{children:[nn," · Agent session"]})]}),a.jsx(Ft,{"aria-label":"Agent actions",onClick:o,children:a.jsx(ko,{size:22})})]}),a.jsx("div",{ref:X,className:"fleet-acp-scroll",tabIndex:-1,onWheel:()=>{we.current=Date.now()},onTouchMove:()=>{we.current=Date.now()},onPointerDown:()=>{we.current=Date.now()},onScroll:G=>{const fe=G.currentTarget;ke(!Xe(fe)),Date.now()-we.current<500&&(ie.current=Xe(fe),fe.scrollTop<400&&jt())},children:a.jsxs("div",{className:"fleet-acp-thread",children:[m.length===0&&a.jsxs("div",{className:"fleet-acp-empty",children:[a.jsx("h2",{children:"What would you like to work on?"}),a.jsxs("p",{children:["Send a message to ",t,"."]})]}),rn&&a.jsx("button",{type:"button",className:"fleet-acp-older",disabled:yt,onClick:()=>void jt(),children:yt?"Loading earlier messages…":"Load earlier messages"}),a.jsx(VR,{messages:m,taskCards:ne}),n&&a.jsx(qR,{agent:e,requests:z,decided:()=>sn(G=>G+1)}),a.jsx("div",{ref:Z})]})}),ye&&a.jsxs("button",{type:"button",className:"jump-latest btn sm",onClick:G=>{const fe=G.currentTarget===document.activeElement;ie.current=!0,X.current&&(X.current.scrollTop=X.current.scrollHeight),ke(!1),fe&&X.current?.focus({preventScroll:!0})},children:[a.jsx(Mp,{size:16,"aria-hidden":!0}),a.jsx("span",{children:"Jump to latest"})]}),a.jsxs("form",{className:"fleet-acp-composer",onSubmit:G=>{G.preventDefault(),wn()},children:[a.jsxs("div",{className:"fleet-acp-state","data-idle":dt==="Ready",role:"status",children:[(ze||B)&&!qe&&a.jsx(MR,{}),a.jsx("span",{children:dt})]}),O&&a.jsx("p",{role:"alert",children:O}),vt&&a.jsxs("div",{className:"fleet-command-suggestions",role:"listbox",id:"session-command-suggestions","aria-label":"Command suggestions",children:[zt.map((G,fe)=>a.jsxs("button",{type:"button",role:"option","aria-selected":fe===Le,id:"session-command-"+fe,onMouseDown:Oe=>Oe.preventDefault(),onClick:()=>os(G),children:[a.jsxs("strong",{children:["/",G.name]}),a.jsx("small",{children:G.description})]},G.name)),!zt.length&&a.jsx("p",{children:"No matching commands available."})]}),f&&!B&&a.jsxs("p",{className:"fleet-pending-note",children:["This message was not confirmed as sent. It may still have reached the agent: Send again retries it without a duplicate. If you ",a.jsx("button",{type:"button",className:"linkbtn",onClick:Wt,children:"discard it"})," or change its files, the next send is a new message and the agent may get both."]}),a.jsx(Cc,{attachments:p,disabled:B,onRemove:G=>{Wt(),p.remove(G)}}),a.jsxs(cc,{className:"fleet-acp-input",children:[a.jsx(_c,{attachments:p,generation:b?.sessionGeneration,disabled:B||f||C||!A||ze||!b?.sessionGeneration}),a.jsx(Nc,{onBusy:M,active:n,sessionGeneration:b?.sessionGeneration,disabled:B||!A||ze||!b?.sessionGeneration,onTranscript:(G,fe)=>{if(E&&j!==fe){I("Agent session changed. Clear the voice draft before adding another recording.");return}x(fe),L(Oe=>Ic(Oe,G)),T(!0),lt.current?.focus()}}),a.jsx(uc,{readOnly:B,ref:lt,role:"combobox","aria-autocomplete":"list","aria-expanded":vt,"aria-controls":vt?"session-command-suggestions":void 0,"aria-activedescendant":vt&&zt[Le]?"session-command-"+Le:void 0,"aria-label":"Message agent",placeholder:"Message your agent…",value:F,rows:1,onChange:G=>{L(G.target.value),G.target.value||(T(!1),x(void 0)),Re(!1),nt(0)},onKeyDown:G=>{if(vt&&!G.nativeEvent.isComposing){if(G.key==="Escape"){G.preventDefault(),Re(!0);return}if(zt.length&&["ArrowDown","ArrowUp"].includes(G.key)){G.preventDefault(),nt(fe=>(fe+(G.key==="ArrowDown"?1:-1)+zt.length)%zt.length);return}if(zt[Le]&&(G.key==="Tab"||G.key==="Enter"&&!G.shiftKey)){G.preventDefault(),os(zt[Le]);return}}G.key==="Enter"&&!G.shiftKey&&!G.nativeEvent.isComposing&&(G.preventDefault(),wn())}}),ze&&A?a.jsx(J,{className:"fleet-acp-send chat-send","aria-label":"Stop",title:"Stop",type:"button",disabled:re,onClick:()=>{oe(!0),ee(`/roles/${encodeURIComponent(e)}/interrupt`,{commandId:crypto.randomUUID()}).then(()=>{U(null),sn(G=>G+1)}).catch(G=>I(G.message)).finally(()=>oe(!1))},children:a.jsx(yc,{size:17,fill:"currentColor"})}):a.jsx(J,{primary:!0,className:"fleet-acp-send chat-send","aria-label":"Send",title:"Send",type:"submit",disabled:B||C||!A||!F.trim()&&!p.has,children:a.jsx(dc,{className:"ic",size:20})})]})]}),kn&&a.jsx(Es,{title:kn==="restart_fresh"?"Force restart agent":"Restart agent",onClose:()=>tn(null),children:a.jsx(Pc,{id:e,action:kn,done:async()=>{tn(null),L(""),T(!1),x(void 0),sn(G=>G+1)}})})]})})}function KR({loaded:e,dark:t,back:n}){const s=oi();return a.jsxs("div",{ref:s,className:"fleet-acp chat-canvas","data-acp-theme":t?"dark":"light",children:[a.jsxs(Xo,{className:"fleet-acp-header",children:[a.jsx(wr,{label:"Back to chats",onClick:n}),a.jsx("strong",{children:e?"Agent unavailable":"Loading agent…"})]}),a.jsx("div",{className:"fleet-acp-scroll",children:a.jsx("div",{className:"fleet-acp-thread",children:e?a.jsxs("div",{role:"alert",children:[a.jsx("p",{children:"This agent is unavailable. It may have failed to start or been removed."}),a.jsx("p",{children:"Return to chats to choose an available agent."})]}):a.jsx("p",{role:"status",children:"Loading agent…"})})})]})}function JR(){const[e,t]=g.useState(()=>new URLSearchParams(location.search).get("navpaint")==="1"),[n,s]=g.useState("original");return g.useEffect(()=>{const r=()=>{s("original"),t(!0)};return window.addEventListener("ours-header-rendering-compare",r),()=>window.removeEventListener("ours-header-rendering-compare",r)},[]),g.useEffect(()=>{if(!e)return;const r=document.querySelector(".fleet-app");if(r)return r.dataset.navPaint=n,()=>{delete r.dataset.navPaint}},[e,n]),e?a.jsxs("aside",{className:"nav-paint-diagnostic","aria-label":"Header rendering comparison",children:[a.jsxs("button",{type:"button",className:"nav-paint-reference","aria-label":"Reference Chats and notification icon",children:[a.jsx("span",{children:"Chats"}),a.jsx(ei,{size:18,"aria-hidden":!0})]}),a.jsx("p",{children:"Compare the top header with this reference. Select each view:"}),a.jsxs("div",{className:"nav-paint-options",children:[[["original","Original"],["plain","Plain controls"],["isolated","Isolated header"],["no-glass","No glass"]].map(([r,o])=>a.jsx("button",{type:"button","aria-pressed":n===r,onClick:()=>s(r),children:o},r)),a.jsx("button",{type:"button",onClick:()=>t(!1),children:"Close comparison"})]}),a.jsxs("small",{children:["Pixel ratio ",devicePixelRatio,"; viewport scale ",visualViewport?.scale??1]})]}):null}const Gl="21b1610c125e41982803ecc8c389c169dd1252c4",Yl="0.1.0";function GR(){return a.jsxs("small",{className:"fleet-build-identity","aria-label":"Loaded app build",title:`Version ${Yl}, build ${Gl}`,children:["v",Yl," · ",Gl.slice(0,7)]})}function YR(){const[e,t]=g.useState(null),[n,s]=g.useState(null),[r,o]=g.useState(!1),[i,l]=g.useState(""),[c,u]=g.useState(!1),[d,p]=g.useState(!1);g.useEffect(()=>{const v=()=>p(!!document.querySelector('[data-app-update-busy="true"]')),b=new MutationObserver(v);return b.observe(document.querySelector(".fleet-app"),{subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-app-update-busy"]}),v(),()=>b.disconnect()},[]),g.useEffect(()=>{let v,b=!1;Fp(t,{shouldDeferReload:()=>!0}).then(z=>{b?z():v=z}).catch(()=>{});const k=Up({onUpdateAvailable:s,onStuck:z=>{s(z),o(!0)}});return()=>{b=!0,v?.(),k()}},[]);const f=()=>!document.querySelector('[data-app-update-busy="true"]'),h=()=>{if(!f())throw new Error("A new draft must be cleared before updating.");location.reload()},m=async()=>{if(!document.querySelector('[data-app-update-busy="true"]')){u(!0),l("");try{r&&n&&!e?.updateAvailable?await Bp(n,{appOnly:!0,preserveNavigation:!0,beforeNavigate:f}):e?.registration?await Zp(e.registration,h):h()}catch{u(!1),l(f()?"Update did not finish. Try again.":"Finish or clear your new draft, then update again.")}}};return!n&&!e?.updateAvailable&&!i?null:a.jsxs("div",{className:"fleet-app-status",children:[(n||e?.updateAvailable)&&a.jsxs("div",{className:"fleet-update-banner",children:[a.jsxs("span",{role:"status",children:["New version available. ",d?"Finish or clear your draft to update.":"Ready to update."]}),a.jsx("button",{type:"button",className:"btn sm",disabled:c||d,onClick:()=>void m(),children:c?"Updating…":"Update app"})]}),i&&a.jsx("span",{role:"alert",children:i})]})}const XR=["Backlog","Provisioning","Active","Review","Done","Cancelled","Failed"];[...["Improve onboarding","Refresh help pages","Connect analytics","Review API coverage","Polish task board","Refine Work lists","Old landing concept","Prepare staging","Research pricing"].map((e,t)=>({id:`task-${t}`,name:e,list:t===3?"Website":"Product",status:["Backlog","Backlog","Provisioning","Active","Review","Done","Cancelled","Failed","Done"][t],description:`Coordinate the work to ${e.toLowerCase()} and provide verification evidence.`,agents:[],...t===3?{blocked:"Needs decision"}:{}}))];function pn(e,t,n="agent"){return{id:e,name:t,initials:t.split(" ").map(s=>s[0]).join("").slice(0,2),when:"10:43",activityAt:"2026-09-17T10:43:00Z",last:"Ready when you are",unread:0,status:"active",root:null,sub:"",roleId:null,rootName:null,mine:n==="agent",kind:n}}pn("maya","Maya","person"),pn("messenger-developer","Developer"),pn("alex-reviewer","Alex’s reviewer"),{...pn("noor","Noor","person")};function Sn(e,t){return t.map((n,s)=>({dir:s===0?"out":"in",text:n,date:`2026-09-17T10:${42+s}:00Z`,read:!0,wireId:`${e}-${s}`,replyTo:null,receipt:"read"}))}Sn("coordinator",["Create a task to review our launch website with a Developer and a Critic.","The task is ready. Both agents are connected to their shared room."]),Sn("developer",["Review the page structure and explain your findings.","I’m checking the heading hierarchy and form labels."]),Sn("critic",["Review the launch website.","I’ll review contrast and keyboard navigation."]),Sn("maya",["Can our agents review the launch together?","Yes. Send an agent invite. I’ll connect my reviewer."]),Sn("messenger-developer",["Here is the launch brief.","Ready when you are."]),Sn("alex-reviewer",["Please review the launch.","Review complete."]),Sn("room",["Please share your findings here when your individual reviews are ready.","Developer: I’m checking the page structure.","Critic: I’ll review contrast and keyboard navigation."]);function Go({value:e,onChange:t,disabled:n}){return a.jsxs(a.Fragment,{children:[a.jsx(xe,{label:"Invitation type",children:a.jsxs("select",{value:e,disabled:n,onChange:s=>t(s.target.value),children:[a.jsx("option",{value:"one_time",children:"One-time"}),a.jsx("option",{value:"public",children:"Reusable"})]})}),a.jsxs("p",{children:[e==="one_time"?"One connection.":"Multiple people can use the same code."," Share the code yourself."]})]})}function QR({id:e,roomKey:t,refresh:n,openChat:s}){const r=Yn(),[o,i]=g.useState("members"),[l,c]=g.useState(),[u,d]=g.useState([]),[p,f]=g.useState(""),[h,m]=g.useState(""),[v,b]=g.useState(""),[k,z]=g.useState(""),[R,A]=g.useState("one_time"),[D,O]=g.useState("Participant"),[I,F]=g.useState(""),[L,j]=g.useState(!1),[x,C]=g.useState(!1),[M,E]=g.useState(""),[T,B]=g.useState(!1),Y=`fleet-member-addition:${e}`,[re,oe]=g.useState(()=>{try{return JSON.parse(sessionStorage.getItem(Y)??"null")}catch{return null}}),[w,U]=g.useState();g.useEffect(()=>{re&&(f(re.slot),m(re.role),b(re.brain),z(re.agentTemplate))},[re?.requestId]);const ne=async()=>{const H=await ee(`/tasks/${encodeURIComponent(e)}`),he=t?(H.task.layout_rooms??[]).find(Re=>Re.key===t):void 0,Ee=t?he?.room_id?{room_id:he.room_id,state:he.state}:{state:he?.state??"missing"}:H.orchestration;if(c(Ee),Ee?.room_id){const Re=await Gi("room.show",{room_id:Ee.room_id});d(Re.seats??[])}await n()};g.useEffect(()=>{ne().catch(H=>E(H.message))},[e]),g.useEffect(()=>{if(r.loaded){const H=Object.keys(r.data.template)[0]||"",he=r.data.template[H];m(Ee=>Ee||he?.role?.ref||Object.keys(r.data.role)[0]||""),b(Ee=>Ee||he?.brain?.ref||Object.keys(r.data.brain)[0]||""),z(Ee=>Ee||H)}},[r.loaded]),g.useEffect(()=>{if(!re||x)return;let H=!0,he;const Ee=async()=>{try{const Re=await ee(`/tasks/${encodeURIComponent(e)}/member-additions/${encodeURIComponent(re.requestId)}`);if(!H)return;E(""),U(Re),Re.state==="running"?he=setTimeout(Ee,1500):Re.state==="succeeded"&&await ne()}catch(Re){H&&E(Re.message)}};return Ee(),()=>{H=!1,clearTimeout(he)}},[re?.requestId,w?.state,x]);const _=async()=>{const H=re??{requestId:crypto.randomUUID(),slot:p,role:h,brain:v,agentTemplate:k};C(!0),E(""),sessionStorage.setItem(Y,JSON.stringify(H)),oe(H);try{U(await ee(`/tasks/${encodeURIComponent(e)}/members`,H))}catch(he){E(he.message),he.code==="member_not_accepted"&&he.accepted===!1&&(sessionStorage.removeItem(Y),oe(null),U(null))}finally{C(!1)}},ue=!!re,Se=l?.state==="active";return a.jsxs("section",{"aria-label":"Room participants",children:[M&&a.jsx("p",{role:"alert",children:M}),o==="members"?a.jsxs(a.Fragment,{children:[t?a.jsx(Te,{title:"Generate room invite",icon:nr,description:"Invite someone to this room",disabled:!Se,onClick:()=>{E(""),i("invite")}}):a.jsx(Te,{title:"Add participant",icon:gf,disabled:!Se,onClick:()=>{E(""),i("choose")}}),t&&l&&!l.room_id&&a.jsx("p",{className:"muted",children:"This room has not been opened yet. Open it from the task page."}),a.jsx(J,{disabled:x,onClick:()=>void ne().catch(H=>E(H.message)),children:"Refresh participants"}),u.map(H=>a.jsx(sc,{title:H.display_name??H.identity_cid??H.identity,subtitle:`${H.role} · ${H.seat_state??H.state}`,onClick:l?.member_seats?.some(he=>he.role_name===H.display_name)?()=>s(H.display_name):void 0},H.identity_cid??H.identity)),!l&&a.jsx("p",{children:"Loading room…"})]}):a.jsxs(a.Fragment,{children:[a.jsx(J,{onClick:()=>{E(""),i(o==="choose"||t?"members":"choose")},children:"Back"}),o==="choose"?a.jsxs(a.Fragment,{children:[a.jsx(Te,{title:"Create task agent",icon:kr,description:"Starts a new agent and joins this room",onClick:()=>i("agent")}),a.jsx(Te,{title:"Generate room invite",icon:nr,description:"Copy an invitation to share yourself",onClick:()=>i("invite")})]}):o==="agent"?a.jsxs(a.Fragment,{children:[a.jsx(xe,{label:"Member name",children:a.jsx("input",{value:p,disabled:ue,onChange:H=>f(H.target.value),placeholder:"Reviewer",pattern:"[A-Za-z][A-Za-z0-9_-]{0,31}"})}),a.jsx(xe,{label:"Agent Template",children:a.jsx("select",{value:k,disabled:ue,onChange:H=>z(H.target.value),children:Object.keys(r.data.template).map(H=>a.jsx("option",{children:H},H))})}),a.jsx(xe,{label:"Role",children:a.jsx("select",{value:h,disabled:ue,onChange:H=>m(H.target.value),children:Object.keys(r.data.role).map(H=>a.jsx("option",{children:H},H))})}),a.jsx(xe,{label:"Brain",children:a.jsx("select",{value:v,disabled:ue,onChange:H=>b(H.target.value),children:Object.entries(r.data.brain).map(([H,he])=>a.jsxs("option",{value:H,children:[H," · ",he.model??he.harness]},H))})}),a.jsx("p",{children:"The agent uses this task’s workspace and joins its room. Permissions come from the selected Agent Template."}),!w&&a.jsx(J,{disabled:x||!Se||!/^[A-Za-z][A-Za-z0-9_-]{0,31}$/.test(p)||!h||!v||!k,onClick:()=>void _(),children:ue?"Check or submit same request":"Create and join room"}),w&&a.jsxs("p",{role:"status",children:[w.roleId," · ",w.state==="succeeded"?"Joined room":w.state==="running"?"Starting and joining…":w.error]}),["failed","attention"].includes(w?.state)&&a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"Open the agent to inspect its status. Ask your Fleet coordinator to recover an uncertain launch before adding another agent."}),a.jsx(J,{onClick:()=>s(w.roleId),children:"Inspect agent"}),a.jsx(J,{onClick:async()=>{try{U(await ee(`/tasks/${encodeURIComponent(e)}/member-additions/${encodeURIComponent(re.requestId)}`))}catch(H){E(H.message)}},children:"Refresh launch status"})]}),w?.state==="succeeded"&&a.jsx(J,{onClick:()=>{sessionStorage.removeItem(Y),oe(null),U(null),f("")},children:"Add another agent"})]}):a.jsxs(a.Fragment,{children:[a.jsx(xe,{label:"Room role",children:a.jsx("input",{value:D,disabled:L,onChange:H=>O(H.target.value)})}),a.jsx(Go,{value:R,onChange:A,disabled:L}),a.jsx("p",{children:"Generating an invitation does not add a participant yet."}),a.jsxs(J,{disabled:x||!Se||L||!D.trim(),onClick:async()=>{C(!0),E(""),j(!0);try{const H=await Gi("room.invite",{room_id:l.room_id,mode:R,role:D.trim(),min_accepts:1});if(typeof H.blob!="string")throw new Error("The invitation response could not be read. Check the room before generating another.");F(H.blob)}catch(H){E(H.message)}finally{C(!1)}},children:["Generate ",R==="one_time"?"one-time":"reusable"," room invite"]}),I&&a.jsxs(a.Fragment,{children:[a.jsx(xe,{label:"Room invitation code",children:a.jsx("textarea",{readOnly:!0,value:I,onFocus:H=>H.target.select()})}),a.jsx(J,{onClick:async()=>{try{await navigator.clipboard.writeText(I),B(!0)}catch{E("Select and copy the invitation code manually.")}},children:T?"Copied":"Copy invitation"})]})]})]}),x&&a.jsx("p",{role:"status",children:"Waiting for server…"})]})}function ez({current:e,select:t,profile:n,settings:s,notifications:r}){const o=[{id:"work",title:"Chats",description:"Your workspace and external conversations in one place.",icon:jr},{id:"tasks",title:"Tasks",description:"Plan work, bring a team together and follow its progress.",icon:hf}];return a.jsxs("div",{className:"fleet-navigation",children:[a.jsx("p",{children:"Choose where you want to go."}),o.map(({id:i,title:l,description:c,icon:u})=>a.jsxs(J,{className:"fleet-destination","aria-current":(e==="messenger"?"work":e)===i?"page":void 0,onClick:()=>t(i),children:[a.jsx("span",{className:"fleet-destination-icon",children:a.jsx(u,{size:24})}),a.jsxs("span",{children:[a.jsxs("strong",{children:[l,(e==="messenger"?"work":e)===i&&a.jsx("small",{children:"Current"})]}),a.jsx("span",{children:c})]}),a.jsx(Yo,{size:18})]},i)),a.jsx("div",{className:"fleet-menu-divider"}),a.jsx(Te,{title:"Notifications",icon:ei,onClick:()=>r?.()}),a.jsx(Te,{title:"My profile",icon:ac,onClick:n}),a.jsx(Te,{title:"Settings",icon:pc,onClick:s})]})}function tz(e){const{modal:t}=e,n=Yn();g.useEffect(()=>{n.refresh().catch(()=>{})},[t.kind]);const[s,r]=g.useState(""),[o,i]=g.useState(["new-agent","new-chat"].includes(t.kind)?Object.keys(n.data.role)[0]??"":""),[l,c]=g.useState(["new-agent","new-chat"].includes(t.kind)?Object.keys(n.data.brain)[0]??"":e.lists.find(U=>t.kind!=="delete-list"||U!==t.id)??"default"),[u,d]=g.useState(null),[p,f]=g.useState(),[h,m]=g.useState("");g.useEffect(()=>{t.kind==="new-task"&&Xt.catalog().then(U=>{d(U.layouts),f(U.defaultLayout),m(ne=>ne||U.defaultLayout||"")}).catch(U=>{d([]),z(U.message)})},[t.kind]);const[v,b]=g.useState(!1),[k,z]=g.useState(""),[R,A]=g.useState(null);g.useEffect(()=>{t.kind==="finish-chat"&&ee(`/roles/${encodeURIComponent(t.id)}/removal-preview`).then(A).catch(U=>z(U.message))},[t.kind,t.id]);const[D,O]=g.useState("one_time"),[I,F]=g.useState(!1),[L,j]=g.useState(""),[x]=g.useState(()=>crypto.randomUUID());g.useEffect(()=>{n.loaded&&["new-agent","new-chat"].includes(t.kind)&&(o||i(Object.keys(n.data.role)[0]??""),l||c(Object.keys(n.data.brain)[0]??""))},[n.loaded,n.data,t.kind]);const C=e.tasks.find(U=>U.id===t.id),M=e.agents.find(U=>U.id===t.id),E=(U,ne=t.id)=>e.setModal({kind:U,id:ne}),T=async(U,ne=!0)=>{b(!0),z("");try{const _=await U();ne||j(JSON.stringify(_,null,2)),await e.refresh(),ne&&e.close()}catch(_){z(_.message)}finally{b(!1)}},B=async U=>{const ne=await ee(`/tasks/${t.id}/${U}`,{});if(ne.pending)throw new Error(ne.task?.terminal_intent?.error??"Request accepted. Room cleanup is still pending; check the task status.");return ne},Y=(U,ne,_)=>a.jsx(xe,{label:U,children:a.jsx("input",{value:ne,onChange:ue=>{_(ue.target.value),j("")}})}),re=a.jsx(xe,{label:"List",children:a.jsx("select",{value:l,onChange:U=>c(U.target.value),children:e.lists.filter(U=>t.kind!=="delete-list"||U!==t.id).map(U=>a.jsx("option",{children:U},U))})});let oe="Fleet",w;switch(t.kind){case"navigation":oe="Navigation",w=a.jsx(ez,{current:e.section,select:e.switchSection,profile:()=>e.go({kind:"profile",id:"human"}),notifications:()=>e.go({kind:"notifications"}),settings:()=>e.go({kind:"settings"})});break;case"add":oe="Add or connect",w=a.jsx(a.Fragment,{children:[{kind:"new-chat",title:"New chat",icon:jr},{kind:"new-agent",title:"New agent",icon:kr},{kind:"new-task",title:"New task",icon:hc},{kind:"generate",title:"Generate invite",icon:nr},{kind:"accept",title:"Accept invite",icon:gc}].map(({kind:U,title:ne,icon:_})=>a.jsx(Te,{title:ne,icon:_,onClick:()=>U==="new-chat"?e.newChat():E(U)},U))});break;case"new-task":{const U=u?.find(ne=>ne.name===h);oe="Create task",w=a.jsxs(a.Fragment,{children:[Y("Task name",s,r),a.jsx(xe,{label:"Description",children:a.jsx("textarea",{value:o,onChange:ne=>i(ne.target.value)})}),re,u===null?a.jsx("p",{role:"status",children:"Loading room layouts…"}):u.length?a.jsxs(a.Fragment,{children:[a.jsx(xe,{label:"Room layout",children:a.jsxs("select",{value:h,onChange:ne=>m(ne.target.value),children:[!h&&a.jsx("option",{value:"",disabled:!0,children:"Choose a layout"}),u.map(ne=>a.jsx("option",{value:ne.name,disabled:!_o(ne),children:jc(ne,p)},ne.name))]})}),U?.definition&&a.jsxs("p",{className:"muted",children:[Object.keys(U.definition.rooms).length===1?"One room":Object.keys(U.definition.rooms).join(" · ")," — ",Object.keys(U.definition.participants).length," ",Object.keys(U.definition.participants).length===1?"participant":"participants",". You can change it until the task starts."]}),a.jsx(J,{onClick:()=>e.go({kind:"settings",editor:"layouts"}),children:"Manage layouts"})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"No room layouts yet. Every task runs a room layout."}),a.jsx(J,{onClick:()=>e.go({kind:"settings",editor:"layouts/new"}),children:"Create a room layout"})]}),a.jsx(J,{primary:!0,disabled:v||!s.trim()||!_o(U),onClick:()=>T(()=>ee("/tasks",{title:s,brief:o,list:l,layout:h,backlog:!0,idempotencyKey:x})),children:"Create task"})]});break}case"lists":oe="Manage lists",w=a.jsxs(a.Fragment,{children:[e.lists.map(U=>a.jsx(Te,{title:U,icon:mc,disabled:U==="default",onClick:()=>E("delete-list",U)},U)),a.jsx(J,{onClick:()=>E("new-list"),children:"New list"})]});break;case"new-list":oe="New list",w=a.jsxs(a.Fragment,{children:[Y("List name",s,r),a.jsx(J,{disabled:v||!s.trim(),onClick:()=>T(()=>ee("/task-lists",{name:s})),children:"Create list"})]});break;case"delete-list":oe=`Delete list ${t.id}`,w=a.jsxs(a.Fragment,{children:[re,a.jsx(J,{disabled:v||l===t.id,onClick:()=>T(()=>ee(`/task-lists/${encodeURIComponent(t.id)}?destination=${encodeURIComponent(l)}`,void 0,"DELETE")),children:"Move tasks and delete list"})]});break;case"move-task":oe="Move task",w=a.jsxs(a.Fragment,{children:[re,a.jsx(J,{disabled:v,onClick:()=>T(()=>ee(`/tasks/${t.id}/list`,{list:l},"PATCH")),children:"Move task"})]});break;case"task-menu":oe=C?.name??"Task",w=a.jsxs(a.Fragment,{children:[[{kind:"move-task",title:"Move to list",icon:cf},{kind:"block-task",title:"Block task",icon:nf},{kind:"delete-task",title:"Delete task",icon:tr}].map(({kind:U,title:ne,icon:_})=>a.jsx(Te,{title:ne,icon:_,danger:U==="delete-task",onClick:()=>E(U)},U)),C?.blocked&&a.jsx(Te,{title:"Unblock",icon:mf,disabled:v,onClick:()=>T(()=>ee(`/tasks/${t.id}/unblock`,{}))}),a.jsx(Te,{title:"Send to review",icon:sf,disabled:v,onClick:()=>T(()=>ee(`/tasks/${t.id}/review`,{}))}),a.jsx(Te,{title:"Finish task",icon:Qo,disabled:v,onClick:()=>T(()=>B("finish"))}),a.jsx(Te,{title:"Cancel task",icon:rf,disabled:v,onClick:()=>T(()=>B("cancel"))})]});break;case"block-task":oe="Block task",w=a.jsxs(a.Fragment,{children:[Y("Reason",o,i),a.jsx(J,{disabled:v||!o.trim(),onClick:()=>T(()=>ee(`/tasks/${t.id}/block`,{reason:o})),children:"Block task"})]});break;case"delete-task":oe="Delete task",w=a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"Delete this task and its owned room and agents."}),Y(`Repeat task ID: ${t.id}`,o,i),a.jsx(J,{disabled:v||o!==t.id,onClick:()=>T(async()=>{const U=await ee(`/tasks/${t.id}?confirm=${encodeURIComponent(o)}`,void 0,"DELETE");if(!U.deleted&&!U.already_absent)throw new Error("Deletion accepted; cleanup is still pending. Refresh to check progress.")}),children:"Delete task"})]});break;case"restart-agent":case"force-restart-agent":oe=t.kind==="restart-agent"?"Restart agent":"Force restart agent",w=a.jsx(Pc,{id:t.id,action:t.kind==="restart-agent"?"restart_resume":"restart_fresh",done:async()=>{await e.refresh(),e.notify("Agent restarted."),e.close()}},t.kind+":"+t.id);break;case"stop-agent":oe="Stop agent",w=a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"Stop this persistent agent. Its configuration and session history are kept."}),a.jsx(J,{disabled:v,onClick:()=>T(async()=>{const U=await ee(`/roles/${encodeURIComponent(t.id)}/actions`,{action:"stop",actionId:x});for(let ne=0;ne<30;ne++){const _=await ee(`/actions/${U.actionId}`);if(_.state==="succeeded"){e.notify("Agent stopped.");return}if(["failed","uncertain"].includes(_.state))throw new Error(_.error?.message??"The stop result is not confirmed.");await new Promise(ue=>setTimeout(ue,1e3))}throw new Error("Stop is still pending. Check the agent status.")}),children:"Stop agent"})]});break;case"finish-chat":oe="Finish chat",w=a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"Stop this temporary agent and archive its session history."}),R?.lifetime==="temporary"?a.jsx(J,{disabled:v,onClick:()=>T(async()=>{if(!(await ee(`/roles/${encodeURIComponent(t.id)}/remove`,{confirmed:!0})).removed)throw new Error("Closure has not been confirmed.");e.closedChat(t.id),e.notify("Chat finished; session history archived.")}),children:"Finish chat"}):!k&&a.jsx("p",{children:R?"This agent is not a temporary chat.":"Checking chat…"})]});break;case"agent-generate":oe=`Invite to ${M?.name??t.id}`,w=a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"The invitation belongs to this agent’s identity."}),a.jsx(Go,{value:D,onChange:O,disabled:I}),a.jsxs(J,{disabled:v||I,onClick:()=>T(async()=>{F(!0);const U=await ee(`/roles/${encodeURIComponent(t.id)}/ours/call`,{tool:"generate_invite",arguments:{mode:D}});if(U.result.isError)throw new Error("Agent could not generate the invite. Check its status before trying again.");const ne=U.result.content?.filter(ue=>ue.type==="text").map(ue=>ue.text).join(`
|
|
301
|
+
`)??"",_=U.result.structuredContent?.blob??ne.trim().split(/\n\s*\n/).at(-1);if(!_||!/^[A-Za-z0-9+/=_-]+$/.test(_))throw new Error("Invite created, but its format was not recognized. Do not generate another automatically.");return{blob:_}},!1),children:["Generate ",D==="one_time"?"one-time":"reusable"," invite"]})]});break;case"agent-accept":oe=`Accept invite as ${M?.name??t.id}`,w=a.jsxs(a.Fragment,{children:[a.jsx(xe,{label:"Invitation code",children:a.jsx("textarea",{value:o,onChange:U=>i(U.target.value)})}),a.jsx(J,{disabled:v||!o.trim(),onClick:()=>T(async()=>{const U=await ee(`/roles/${encodeURIComponent(t.id)}/ours/call`,{tool:"add_contact",arguments:{invite:o.trim()}});if(U.result.isError)throw new Error("Agent could not accept this invitation. Check its state before trying again.");return U}),children:"Accept invite"})]});break;case"new-chat":case"new-agent":oe=t.kind==="new-chat"?"New chat":"Create agent",w=a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"This creates a temporary agent. Role and Brain options come from this Fleet’s configuration."}),Y("Agent name",s,r),a.jsx(xe,{label:"Role",children:a.jsx("select",{value:o,onChange:U=>{i(U.target.value),j("")},children:Object.keys(n.data.role).map(U=>a.jsx("option",{children:U},U))})}),a.jsx(xe,{label:"Brain",children:a.jsx("select",{value:l,onChange:U=>{c(U.target.value),j("")},children:Object.entries(n.data.brain).map(([U,ne])=>a.jsxs("option",{value:U,children:[ne.harness," · ",ne.model??"Default model"," · ",ne.effort??"Default effort"]},U))})}),a.jsx(J,{disabled:v||!s||!o||!l,onClick:()=>T(async()=>{const ne=await ee("/roles/preview",{name:s,brain:{ref:l},role:{ref:o},lifetime:"temporary",permissions:{approval:"ask",filesystem:"workspace",unattended:"wait"},openAfterCreate:!0});return j(JSON.stringify(ne,null,2)),ne},!1),children:"Preview creation"}),a.jsx("p",{children:"Review the effective settings and prerequisites before creating."}),L&&JSON.parse(L).previewHash&&a.jsx(J,{disabled:v||JSON.parse(L).prerequisites?.length>0,onClick:()=>T(async()=>{const U=JSON.parse(L),ne=await ee("/roles",{request:U.request,previewHash:U.previewHash,idempotencyKey:x});for(let _=0;_<60;_++){const ue=await ee(`/creation-actions/${ne.actionId}`);if(j(JSON.stringify(ue,null,2)),ue.error)throw new Error(ue.error.message);if(ue.state==="launched_unconfirmed")throw new Error("Launch requested, but the session is not reachable yet. Check the agent status before trying again.");if(["session_reachable","attention"].includes(ue.state))return e.openChat(ue.roleId),ue;await new Promise(Se=>setTimeout(Se,1e3))}throw new Error("Creation is still running. Check the agent list before starting another session.")}),children:"Create reviewed agent"})]});break;case"generate":oe="Generate invite",w=a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"Invite someone to the local Messenger identity."}),a.jsx(Go,{value:D,onChange:O,disabled:I}),a.jsxs(J,{disabled:v||I,onClick:()=>T(()=>(F(!0),it.createInvite(D)),!1),children:["Generate ",D==="one_time"?"one-time":"reusable"," invite"]})]});break;case"accept":oe="Accept invite",w=a.jsxs(a.Fragment,{children:[a.jsx(xe,{label:"Invitation code",children:a.jsx("textarea",{value:o,onChange:U=>i(U.target.value)})}),a.jsx(J,{disabled:v||!o.trim(),onClick:()=>T(()=>it.addContact(o)),children:"Accept invite"})]});break;case"members":{const U=Ct(t.id)??{taskId:t.id};oe=U.key?`Room ${U.key}`:"Room participants",w=a.jsx(QR,{id:U.taskId,roomKey:U.key,refresh:e.refresh,openChat:e.openChat},t.id);break}default:oe="Not available",w=a.jsx("p",{children:"This operation is not connected in this local version."})}return a.jsx(Es,{title:oe,onClose:e.close,className:"fleet-modal",children:a.jsxs("div",{className:"fleet-dialog-content",children:[w,v&&a.jsx("p",{role:"status",children:"Waiting for server…"}),k&&a.jsx("p",{role:"alert",children:k}),L&&a.jsx(nz,{value:JSON.parse(L)})]})})}function nz({value:e}){return e.previewHash?a.jsxs("section",{"aria-label":"Creation review",children:[a.jsx("h3",{children:e.effective.name}),a.jsxs("p",{children:[e.effective.lifetime," agent · ",e.effective.harness," · ",e.effective.model??"Default model"]}),a.jsx(Fn,{title:"Working folder",subtitle:e.effective.cwd??"Fleet default"}),a.jsx(Fn,{title:"Permissions",subtitle:`${e.effective.permissions.approval} approval · ${e.effective.permissions.filesystem} files · unattended ${e.effective.permissions.unattended}`}),e.warnings.map(t=>a.jsx("p",{children:t},t)),e.prerequisites.map(t=>a.jsx("p",{role:"alert",children:t},t))]}):e.blob?a.jsx(sz,{blob:e.blob}):a.jsxs("section",{role:"status",children:[a.jsx("p",{children:e.state??(e.accepted?"Request accepted":"Server response received")}),e.roleId&&a.jsx("p",{children:e.roleId}),e.error&&a.jsx("p",{role:"alert",children:e.error.message??String(e.error)})]})}function sz({blob:e}){const[t,n]=g.useState(!1),[s,r]=g.useState("");return a.jsxs(a.Fragment,{children:[a.jsx(xe,{label:"Invitation code",children:a.jsx("textarea",{readOnly:!0,value:e,onFocus:o=>o.target.select()})}),a.jsx(J,{onClick:async()=>{r(""),n(!1);try{await navigator.clipboard.writeText(e),n(!0)}catch{r("Could not copy. Select the invitation code above and copy it manually.")}},children:"Copy invitation"}),t&&a.jsx("p",{role:"status",children:"Copied"}),s&&a.jsx("p",{role:"alert",children:s})]})}function rz({children:e}){const[t,n]=g.useState(!1),[s,r]=g.useState(!0),[o,i]=g.useState(""),[l,c]=g.useState(()=>{const f=sessionStorage.getItem("ours-notifications-cleanup-warning")??"";return sessionStorage.removeItem("ours-notifications-cleanup-warning"),f}),[u,d]=g.useState(!1),p=f=>{_f(f.csrfToken),n(!0)};return g.useEffect(()=>{const f=()=>{n(!1),c("Session expired. Sign in again.")};return addEventListener("fleet-session-expired",f),ee("/auth/session").then(p).catch(()=>ee("/auth/resume",{}).then(p)).catch(()=>{}).finally(()=>r(!1)),()=>removeEventListener("fleet-session-expired",f)},[]),s?a.jsx("div",{className:"centered-screen",children:"Connecting to Fleet…"}):t?a.jsx(a.Fragment,{children:e}):a.jsx("main",{className:"centered-screen",children:a.jsxs("form",{onSubmit:async f=>{f.preventDefault(),d(!0),c("");try{p(await ee("/auth/login",{password:o})),i("")}catch(h){c(h.message)}finally{d(!1)}},children:[a.jsx("h1",{children:"Sign in to Fleet"}),a.jsx("p",{children:"Use the password for this local instance."}),a.jsxs("label",{children:["Password",a.jsx("input",{className:"field",type:"password",autoComplete:"current-password",value:o,onChange:f=>i(f.target.value),required:!0})]}),a.jsx("button",{className:"btn",disabled:u,children:u?"Signing in…":"Sign in"}),l&&a.jsx("p",{role:"alert",children:l})]})})}function oz(){const[e,t]=g.useState([]),[n,s]=g.useState(""),[r,o]=g.useState(""),[i,l]=g.useState(""),c=async()=>t((await ee("/devices")).devices),u=async d=>{l("");try{await d()}catch(p){l(p.message)}};return g.useEffect(()=>{u(c)},[]),a.jsxs("section",{children:[a.jsx("h2",{children:"Devices"}),a.jsx("p",{children:"Every linked browser has its own credential. Revoking a device immediately ends its API and stream access."}),i&&a.jsx("p",{role:"alert",children:i}),a.jsx("button",{className:"btn",onClick:()=>void u(async()=>{const d=await ee("/devices/link",{}),p=new TextEncoder().encode(JSON.stringify(d)),f=btoa(String.fromCharCode(...p)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","");s(f),o(await tf.toDataURL(f))}),children:"Link a device"}),n&&a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"Private connection code expires in five minutes and works once."}),a.jsx("img",{src:r,alt:"Scan to link a device"}),a.jsx("textarea",{readOnly:!0,value:n}),a.jsx("button",{onClick:()=>void navigator.clipboard.writeText(n),children:"Copy code"}),a.jsx("button",{onClick:()=>{s(""),o("")},children:"Dismiss"})]}),e.map(d=>a.jsxs("div",{children:[a.jsx("strong",{children:d.label}),a.jsxs("p",{children:["Last used ",new Date(d.lastUsedAt).toLocaleString()," · ",d.revokedAt?"revoked":`expires ${new Date(d.expiresAt).toLocaleDateString()}`]}),!d.revokedAt&&a.jsx("button",{onClick:()=>void u(async()=>{await ee("/devices/"+encodeURIComponent(d.id),{},"DELETE"),await c()}),children:"Revoke"})]},d.id))]})}function iz({editor:e,go:t}){const[,n]=e.split("/"),[s,r]=g.useState(null),[o,i]=g.useState(""),[l,c]=g.useState(""),[u,d]=g.useState(),p=async()=>{try{const v=await Xt.catalog();r(v.layouts),d(v.defaultLayout),i("")}catch(v){i(v.message)}},f=Tc(!0,s);g.useEffect(()=>{p()},[e]);const h=()=>t({kind:"settings",editor:"layouts"});if(!s)return a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:"Room layouts",onBack:()=>t({kind:"settings"})}),a.jsx("p",{role:o?"alert":"status",children:o||"Loading room layouts…"})]});if(n){const v=decodeURIComponent(n),b=n==="new"?void 0:s.find(k=>k.name===v);return n!=="new"&&!b?a.jsx("main",{className:"fleet-form-page",children:a.jsx(We,{title:"Layout not found",onBack:h})}):a.jsx(az,{entry:b,origin:b?f?.layout[b.name]:void 0,taken:s.map(k=>k.name),done:async()=>{await p(),h()},cancel:h},e)}const m=s.filter(v=>v.name.toLowerCase().includes(l.toLowerCase()));return a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:"Room layouts",subtitle:"Every task runs one of these: its rooms, their goals and who works in each",onBack:()=>t({kind:"settings"}),actions:a.jsx(J,{primary:!0,onClick:()=>t({kind:"settings",editor:"layouts/new"}),children:"New layout"})}),o&&a.jsx("p",{role:"alert",children:o}),a.jsx(xr,{value:l,onChange:c,placeholder:"Search room layouts"}),a.jsxs("div",{className:"fleet-config-list",children:[m.map(v=>a.jsx(Te,{icon:ff,title:v.name,badge:zc(f?.layout[v.name]),description:v.error!==void 0?`Cannot be read · ${v.error}`:`${Xl(Object.keys(v.definition.rooms).length,"room")} · ${Xl(Object.keys(v.definition.participants).length,"participant")}${v.name===u?" · default for new tasks":""}${v.issues.length?" · needs attention":""}`,onClick:()=>t({kind:"settings",editor:"layouts/"+encodeURIComponent(v.name)})},v.name)),!m.length&&a.jsx("p",{className:"muted",children:s.length?"No layouts match.":"No room layouts yet. A layout describes the rooms of a task and who works in each."})]})]})}const Xl=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function az({entry:e,origin:t,taken:n,done:s,cancel:r}){const o=Yn(),i=Object.keys(o.data.template),[l,c]=g.useState(e?.name??""),[u,d]=g.useState(()=>structuredClone(e?.definition??Kf())),[p,f]=g.useState(e?.revision??Xi),[h,m]=g.useState(!1),[v,b]=g.useState(""),[k,z]=g.useState(!1),[R,A]=g.useState(!1),D=g.useMemo(()=>wc(u),[u]),O=g.useMemo(()=>[...e?[]:si(l.trim())?n.includes(l.trim())?["A layout with this name already exists."]:[]:["Name the layout: start with a letter; use letters, numbers, - or _."],...Jf(u,i)],[u,l,i.join(",")]),I=T=>{d(T),b("")},F=(T,B)=>I({...u,rooms:{...u.rooms,[T]:{...u.rooms[T],...B}}}),L=Object.keys(u.participants),j=g.useRef(new Map),x=(T,B)=>{const Y=`${T}:${B}`;return j.current.has(Y)||j.current.set(Y,crypto.randomUUID()),j.current.get(Y)},C=(T,B,Y)=>{j.current.set(`${T}:${Y}`,x(T,B)),j.current.delete(`${T}:${B}`)},M=async()=>{if(z(!0),!O.length){m(!0),b("");try{const T=await Xt.save(l.trim(),p,u);f(T.revision),await s()}catch(T){b(T.status===409?"This layout changed on the host since you opened it. Reload the list to see the latest version.":T.message)}finally{m(!1)}}},E=async()=>{m(!0),b("");try{await Xt.remove(e.name,p),await s()}catch(T){b(T.message),A(!1)}finally{m(!1)}};return e&&e.error!==void 0?a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:e.name,subtitle:e.file,onBack:r}),a.jsxs("p",{role:"alert",children:["This layout file cannot be read: ",e.error]}),a.jsx("p",{className:"muted",children:"Fix the file on the host, or delete it and create the layout again here."}),e.revision!==Xi&&a.jsx(ec,{busy:h,confirm:R,setConfirm:A,remove:E}),v&&a.jsx("p",{role:"alert",children:v})]}):a.jsxs("main",{className:"fleet-form-page fleet-layout-editor",children:[a.jsx(We,{title:e?e.name:"New room layout",subtitle:"Tasks snapshot a layout when they start; editing it never changes running tasks.",onBack:r}),a.jsx(Oc,{entry:t,noun:"room layout"}),a.jsxs("form",{className:"fleet-config-form",onSubmit:T=>{T.preventDefault(),M()},children:[a.jsx(xe,{label:"Layout name",children:a.jsx("input",{value:l,readOnly:!!e,onChange:T=>c(T.target.value),placeholder:"delivery"})}),a.jsx(xe,{label:"Description",children:a.jsx("textarea",{rows:2,value:u.description??"",onChange:T=>I({...u,description:T.target.value}),placeholder:"What this layout is for"})}),a.jsxs("section",{className:"fleet-layout-section","aria-labelledby":"layout-participants",children:[a.jsxs("header",{children:[a.jsx("h2",{id:"layout-participants",children:"Participants"}),a.jsxs(J,{onClick:()=>{const T=ea(L,"agent");I({...u,participants:{...u.participants,[T]:{agent_template:i[0]??""}}})},children:[a.jsx(wo,{size:16,"aria-hidden":!0}),"Add participant"]})]}),a.jsx("p",{className:"muted",children:"Each participant is one agent session. Put a participant in several rooms to share that session and its context between them. For a fresh session, add a new participant, even with the same template."}),a.jsx(dn.ul,{layout:!0,className:"fleet-layout-participants",children:a.jsx(er,{initial:!1,children:L.map(T=>a.jsxs(dn.li,{layout:!0,transition:ws,initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},children:[a.jsx(Ql,{label:"Participant key",value:T,taken:L,rename:B=>{C("p",T,B),I(Yf(u,T,B))}}),a.jsx(xe,{label:`Agent template for ${T}`,children:a.jsxs("select",{value:u.participants[T].agent_template??"",onChange:B=>I({...u,participants:{...u.participants,[T]:{agent_template:B.target.value}}}),children:[a.jsx("option",{value:"",children:"Choose…"}),i.map(B=>a.jsx("option",{children:B},B))]})}),a.jsx(lz,{template:u.participants[T].agent_template}),a.jsx(cz,{definition:u,participant:T,toggle:B=>I(Qi(u,T,B))}),a.jsx(J,{"aria-label":`Remove participant ${T}`,disabled:L.length===1,onClick:()=>I(Xf(u,T)),children:a.jsx(tr,{size:16,"aria-hidden":!0})})]},x("p",T)))})})]}),a.jsxs("section",{className:"fleet-layout-section","aria-labelledby":"layout-rooms",children:[a.jsxs("header",{children:[a.jsx("h2",{id:"layout-rooms",children:"Rooms"}),a.jsxs(J,{onClick:()=>{const T=ea(Object.keys(u.rooms),"room");I({...u,rooms:{...u.rooms,[T]:{goal:"",members:L.slice(0,1)}}})},children:[a.jsx(wo,{size:16,"aria-hidden":!0}),"Add room"]})]}),a.jsx("p",{className:"muted",children:"Rooms open one at a time from the task, in any order."}),a.jsx(dn.div,{layout:!0,className:"fleet-layout-rooms",children:a.jsx(er,{initial:!1,children:Object.entries(u.rooms).map(([T,B])=>a.jsxs(dn.fieldset,{layout:!0,className:"fleet-layout-room",transition:ws,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},children:[a.jsx("legend",{children:T}),a.jsx(Ql,{label:"Room key",value:T,taken:Object.keys(u.rooms),rename:Y=>{C("r",T,Y),I(Qf(u,T,Y))}}),a.jsx(xe,{label:`Goal of ${T}`,children:a.jsx("input",{value:B.goal,onChange:Y=>F(T,{goal:Y.target.value}),placeholder:"What this room decides or delivers"})}),a.jsxs("div",{className:"fleet-layout-members",role:"group","aria-label":`Members of ${T}`,children:[L.map(Y=>{const re=B.members.includes(Y);return a.jsx("button",{type:"button","aria-pressed":re,className:"fleet-layout-chip"+(re?" on":"")+(D.has(Y)?" shared":""),title:re?`Remove ${Y} from ${T}`:`Reuse ${Y} (and its session) in ${T}`,onClick:()=>I(Qi(u,Y,T)),children:Y},Y)}),a.jsxs("select",{className:"fleet-layout-fresh","aria-label":`Add a new participant to ${T}`,value:"",onChange:Y=>{if(!Y.target.value)return;const re=th(u,T,Y.target.value);I(re.definition)},children:[a.jsx("option",{value:"",children:"+ New participant (fresh session)…"}),i.map(Y=>a.jsx("option",{value:Y,children:Y},Y))]})]}),a.jsx("p",{className:"muted fleet-layout-hint",children:"Selected participants reuse their session here. A new participant starts a fresh session."}),a.jsxs("details",{className:"fleet-layout-more",children:[a.jsx("summary",{children:"Roles, contract and privacy"}),B.members.map(Y=>a.jsx(xe,{label:`Room role for ${Y}`,children:a.jsx("input",{value:B.roles?.[Y]??"",placeholder:Y,onChange:re=>F(T,{roles:{...B.roles,[Y]:re.target.value}})})},Y)),a.jsx(xe,{label:`Contract for ${T}`,children:a.jsx("textarea",{rows:3,value:B.contract??"",onChange:Y=>F(T,{contract:Y.target.value}),placeholder:"Working agreement shown to the room"})}),a.jsxs("label",{className:"fleet-check",children:[a.jsx("input",{type:"checkbox",checked:B.quiet_membership??!0,onChange:Y=>F(T,{quiet_membership:Y.target.checked})}),"Quiet membership"]}),a.jsxs("label",{className:"fleet-check",children:[a.jsx("input",{type:"checkbox",checked:!!B.anonymous,onChange:Y=>F(T,{anonymous:Y.target.checked})}),"Anonymous room"]})]}),a.jsxs(J,{"aria-label":`Remove room ${T}`,disabled:Object.keys(u.rooms).length===1,onClick:()=>{const{[T]:Y,...re}=u.rooms;I({...u,rooms:re})},children:[a.jsx(tr,{size:16,"aria-hidden":!0}),"Remove room"]})]},x("r",T)))})})]}),a.jsx(uz,{definition:u,shared:D}),k&&O.length>0&&a.jsx("ul",{className:"fleet-layout-issues",role:"alert",children:O.map(T=>a.jsx("li",{children:T},T))}),v&&a.jsx("p",{role:"alert",children:v}),a.jsxs("div",{className:"fleet-actions",children:[a.jsx(J,{onClick:r,children:"Cancel"}),a.jsx(J,{primary:!0,type:"submit",disabled:h,children:h?"Saving…":"Save layout"})]}),e&&a.jsx(ec,{busy:h,confirm:R,setConfirm:A,remove:E})]})]})}function lz({template:e}){const{data:t}=Yn(),n=e?t.template[e]:void 0;if(!n)return null;const s=n.brain?.ref?t.brain[n.brain.ref]:void 0,r=(o,i)=>i?a.jsx("a",{className:"fleet-link",href:`/fleet/settings/${o}/${encodeURIComponent(i)}`,target:"_blank",rel:"noopener",title:`Open ${o} ${i} in a new tab`,children:i}):a.jsx(a.Fragment,{children:"none"});return a.jsxs("p",{className:"muted fleet-layout-runs",children:["Role: ",r("role",n.role?.ref)," · Brain: ",r("brain",n.brain?.ref),s?` — ${$c(s)}`:""]})}function cz({definition:e,participant:t,toggle:n}){const s=Object.keys(e.rooms),r=eh(e,t);return a.jsxs("div",{className:"fleet-layout-participant-rooms",children:[a.jsx("div",{className:"fleet-layout-members",role:"group","aria-label":`Rooms of ${t}`,children:s.map(o=>{const i=r.includes(o);return a.jsx("button",{type:"button","aria-pressed":i,className:"fleet-layout-chip"+(i?" on":"")+(i&&r.length>1?" shared":""),onClick:()=>n(o),children:o},o)})}),a.jsxs("span",{className:r.length>1?"fleet-layout-shared":"muted",role:"status",children:[r.length>1?a.jsxs(a.Fragment,{children:[a.jsx(Vp,{size:14,"aria-hidden":!0}),"Shared session across ",r.length," rooms"]}):r.length===1?"Used in 1 room":"Not in any room yet",s.length===1&&" · add a second room to share this participant"]})]})}function Ql({label:e,value:t,taken:n,rename:s}){const[r,o]=g.useState(t);g.useEffect(()=>o(t),[t]);const i=r!==t&&(!si(r)||n.includes(r)),l=()=>{!i&&r!==t?s(r):o(t)};return a.jsx(xe,{label:e,children:a.jsx("input",{value:r,"aria-invalid":i||void 0,onChange:c=>o(c.target.value),onBlur:l,onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),l()),c.key==="Escape"&&o(t)}})})}function uz({definition:e,shared:t}){const n=Object.entries(e.rooms);return a.jsxs("section",{className:"fleet-layout-map","aria-label":"Layout preview",children:[a.jsxs("h2",{children:[a.jsx(Sr,{size:16,"aria-hidden":!0}),"Preview"]}),a.jsx("ol",{children:n.map(([s,r])=>a.jsxs("li",{children:[a.jsx("strong",{children:s}),a.jsx("span",{className:"muted",children:r.goal||"No goal yet"}),a.jsx("span",{className:"fleet-layout-map-members",children:r.members.map(o=>a.jsx("span",{className:t.has(o)?"shared":"",children:r.roles?.[o]?.trim()||o},o))})]},s))}),t.size>0&&a.jsxs("p",{className:"muted",children:[a.jsx("span",{className:"fleet-layout-legend","aria-hidden":!0}),"Highlighted participants keep one session across rooms."]})]})}function ec({busy:e,confirm:t,setConfirm:n,remove:s}){return a.jsx("div",{className:"fleet-layout-delete",children:t?a.jsxs(a.Fragment,{children:[a.jsx("p",{children:"Delete this layout? Tasks that already use it keep their own copy."}),a.jsx(J,{onClick:()=>n(!1),children:"Keep layout"}),a.jsx(J,{className:"danger",disabled:e,onClick:()=>void s(),children:"Delete layout"})]}):a.jsxs(J,{onClick:()=>n(!0),children:[a.jsx(tr,{size:16,"aria-hidden":!0}),"Delete layout…"]})})}function dz({back:e,editor:t,go:n}){const[s,r]=g.useState(""),[o,i]=g.useState(""),[l,c]=g.useState(""),[u,d]=g.useState(""),[p,f]=g.useState(!1),h=async()=>{const b=await ee("/configuration");r(JSON.stringify(b.model,null,2)),i(b.revision)};g.useEffect(()=>{h().catch(b=>c(b.message))},[]);const m=async b=>{f(!0),c("");try{const k=await ee(`/configuration/${b?"save":"preview"}`,{revision:o,model:JSON.parse(s)});d(JSON.stringify(k,null,2)),b&&await h()}catch(k){c(k.message)}finally{f(!1)}},v=async()=>{let b="";try{await jo()}catch(k){b=k.message}try{await ee("/auth/logout",{}),b&&sessionStorage.setItem("ours-notifications-cleanup-warning",b),location.reload()}catch(k){c([b,k.message].filter(Boolean).join(" "))}};return t&&["role","brain","template","tasks"].includes(t.split("/")[0])?a.jsx(yh,{editor:t,go:n},t):t?.split("/")[0]==="layouts"?a.jsx(iz,{editor:t,go:n}):t==="onboarding"?a.jsx(xc,{force:!0,back:e}):t==="devices"?a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:"Workspace Devices",onBack:e}),a.jsx(oz,{})]}):t==="notifications"?a.jsx(Bf,{back:e}):t==="subscriptions"?a.jsx(bc,{back:e}):t?a.jsxs("main",{className:"fleet-page",children:[a.jsx(We,{title:"Fleet configuration",onBack:e}),a.jsx("p",{children:"Edit the configuration on this host. Preview validates changes; save uses the loaded revision to prevent overwriting another edit."}),a.jsx("textarea",{className:"field fleet-config-json","aria-label":"Fleet configuration JSON",value:s,onChange:b=>{r(b.target.value),d("")}}),a.jsxs("div",{className:"fleet-actions",children:[a.jsx(J,{disabled:p||!o,onClick:()=>void m(!1),children:"Preview changes"}),a.jsx(J,{disabled:p||!u,onClick:()=>void m(!0),children:"Save changes"}),a.jsx(J,{onClick:()=>void v(),children:"Sign out"})]}),l&&a.jsx("p",{role:"alert",children:l}),u&&a.jsx("pre",{className:"fleet-output",children:u})]}):a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:"Configuration",onBack:e}),a.jsx(Te,{title:"Fleet setup wizard",icon:Hs,onClick:()=>n({kind:"settings",editor:"onboarding"})}),a.jsx(Te,{title:"Devices / Link a device",icon:Ki,onClick:()=>n({kind:"settings",editor:"devices"})}),a.jsx(Te,{title:"Notifications",icon:Hs,onClick:()=>n({kind:"settings",editor:"notifications"})}),a.jsx(Te,{title:"Subscriptions",icon:Ki,onClick:()=>n({kind:"settings",editor:"subscriptions"})}),[["template","Agent Templates"],["role","Roles"],["brain","Brains"],["layouts","Room layouts"],["advanced","Fleet manifest and agents"]].map(([b,k])=>a.jsx(Te,{title:k,icon:Hs,onClick:()=>n({kind:"settings",editor:b})},b)),a.jsx(J,{onClick:()=>void v(),children:"Sign out"}),a.jsx(GR,{}),a.jsx(J,{onClick:()=>{n({kind:"home"}),window.dispatchEvent(new Event("ours-header-rendering-compare"))},children:"Compare header rendering"}),l&&a.jsx("p",{role:"alert",children:l})]})}function pz({id:e,agents:t,go:n,modal:s,tasks:r}){const[o,i]=g.useState(),[l,c]=g.useState("");g.useEffect(()=>{(e==="human"?it.identity():t.some(m=>m.id===e)?ee(`/roles/${encodeURIComponent(e)}`):it.contacts()).then(i).catch(m=>c(m.message))},[e]);const u=o,d=t.find(m=>m.id===e),p=r.find(m=>m.agents.includes(e)),f=u?.contacts?.find(m=>m.container_id===e),h=u?.humanProfile?`${u.humanProfile.name} ${u.humanProfile.surname}`:d?.name??f?.display_name??f?.name??u?.name??"Identity";return a.jsx("main",{className:"fleet-page",children:a.jsxs("section",{className:"fleet-profile",children:[a.jsx("h1",{children:h}),l?a.jsx("p",{role:"alert",children:l}):u?a.jsxs(a.Fragment,{children:[a.jsx("p",{children:d?`${d.lifetime} agent · ${d.state}`:u.cid?"Local Messenger identity":"Contact"}),a.jsx("p",{children:u.bio??d?.role}),(u.cid||f?.container_id)&&a.jsx("small",{className:"muted",children:u.cid??f.container_id}),d&&a.jsxs(a.Fragment,{children:[a.jsx(Te,{title:"Contacts & conversations",icon:Sr,onClick:()=>n({kind:"contacts",id:e})}),a.jsx(Te,{title:"Generate invite",icon:nr,onClick:()=>s({kind:"agent-generate",id:e})}),a.jsx(Te,{title:"Accept invite",icon:gc,onClick:()=>s({kind:"agent-accept",id:e})}),p?a.jsxs("p",{className:"muted",children:["This agent belongs to ",p.name,". Finish its task to close the agent."]}):a.jsx(Te,{title:d.lifetime==="Temporary"?"Finish chat":"Stop agent",icon:d.lifetime==="Temporary"?Qo:yc,danger:!0,onClick:()=>s({kind:d.lifetime==="Temporary"?"finish-chat":"stop-agent",id:e})}),d.lifetime==="Persistent"&&a.jsxs(a.Fragment,{children:[a.jsx(Te,{title:"Restart",icon:js,onClick:()=>s({kind:"restart-agent",id:e})}),a.jsx(Te,{title:"Force restart",icon:js,danger:!0,onClick:()=>s({kind:"force-restart-agent",id:e})})]}),a.jsx(Fn,{title:"Identity",subtitle:u.role?.config?.identity??d.name}),a.jsx(Fn,{title:"Working folder",subtitle:d.folder}),a.jsx(Fn,{title:"Runtime",subtitle:u.role?.config?.harness??u.role?.harness}),d.lifetime==="Temporary"&&a.jsx(Fn,{title:"Auto-close",subtitle:u.chatIdle?`After ${u.chatIdle.timeoutMs/36e5} hours without activity`:"Not enabled for this session"})]})]}):a.jsx("p",{children:"Loading…"})]})})}function fz({value:e,change:t}){return a.jsx(qp,{label:"Agent lifetime",value:e,onChange:t,options:["Persistent","Temporary"].map(n=>({id:n,label:n}))})}const hz=e=>e.replace(/\s+/g," ").trim().slice(0,300),mz=()=>({text:"No messages yet",at:""});function gz(e,t){const n=e.messages.at(-1);if(!n)return mz();const s=n.dir==="in"?rc(t,n.text):null,r=hz(e.preview??(s?Hp(s):n.text)),o=n.message_kind==="file"?"File attachment":"Message";return{text:`${n.dir==="out"?"You: ":""}${r||o}`,at:n.date}}const yz=3e4,vz=4;function bz(e){const t=i=>i?.kind==="agent_text"&&typeof i.text=="string";let n=e.length-1;for(;n>=0&&!t(e[n]);)n--;if(n<0)return{text:"No recent agent output",at:""};const s=e[n],r=[];for(let i=n;i>=0;i--){const l=e[i];if(s.messageId!==void 0){t(l)&&l.messageId===s.messageId&&r.unshift(l.text);continue}if(!t(l)||l.messageId!==void 0)break;r.unshift(l.text)}return{text:r.join("").replace(/\s+/g," ").trim().slice(0,300)||"No recent agent output",at:s.at??""}}async function xz(e){if(e.kind==="agent"){const t=await ee(`/roles/${encodeURIComponent(e.id)}/output?limit=200`);return bz(t.events??[])}return gz(await it.conversation(e.cid),e.name)}const wp=g.createContext({previews:{},want:()=>{}});function kz({children:e,live:t=!1}){const[n,s]=g.useState({}),r=g.useRef([]),o=g.useRef(new Map),i=g.useRef(new Set),l=g.useCallback(()=>{if(!t||document.visibilityState==="hidden")return;const u=Date.now();for(const d of r.current){if(i.current.size>=vz)break;i.current.has(d.id)||u-(o.current.get(d.id)??0)<yz||(i.current.add(d.id),xz(d).then(p=>s(f=>({...f,[d.id]:p}))).catch(()=>s(p=>({...p,[d.id]:{...p[d.id]??{text:"Preview unavailable",at:""},unavailable:!0}}))).finally(()=>{o.current.set(d.id,Date.now()),i.current.delete(d.id),l()}))}},[t]);g.useEffect(()=>{if(!t)return;const u=setInterval(l,5e3);return document.addEventListener("visibilitychange",l),()=>{clearInterval(u),document.removeEventListener("visibilitychange",l)}},[t,l]);const c=g.useCallback(u=>{r.current=u,l()},[l]);return a.jsx(wp.Provider,{value:{previews:n,want:c},children:e})}function wz(e){const[t,n]=g.useState(()=>new Set);return g.useEffect(()=>{const s=e.current;if(!s)return;const r=new Map;let o=0;const i=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{const d=new Set([...r].filter(([p,f])=>f&&p.isConnected).map(([p])=>p.dataset.previewId));n(p=>p.size===d.size&&[...d].every(f=>p.has(f))?p:d)})},l=new IntersectionObserver(d=>{for(const p of d)r.set(p.target,p.isIntersecting);i()}),c=()=>{for(const d of s.querySelectorAll("[data-preview-id]"))r.has(d)||(r.set(d,!1),l.observe(d));for(const d of r.keys())d.isConnected||(r.delete(d),l.unobserve(d));i()},u=new MutationObserver(c);return u.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-preview-id"]}),c(),()=>{l.disconnect(),u.disconnect(),cancelAnimationFrame(o)}},[e]),t}function jz(e,t){const{previews:n,want:s}=g.useContext(wp),r=wz(t),o=e.filter(l=>r.has(l.id)),i=o.map(l=>l.kind+":"+l.id+":"+("cid"in l?l.cid:"")).join("|");return g.useEffect(()=>{s(o)},[i,s]),n}function Sz(e,t){const n=Ct(t),s=n&&e.find(r=>r.id===n.taskId);return s?n.key?!!s.layoutRooms?.find(r=>r.key===n.key)?.identity_cid:!!s.roomCid:!1}function _z({label:e,choices:t,value:n,change:s,nodes:r={},unread:o={}}){return a.jsx("div",{className:"fleet-chat-filters",role:"tablist","aria-label":e,children:t.map((i,l)=>a.jsxs("button",{role:"tab","aria-selected":n===i,tabIndex:n===i?0:-1,className:n===i?"active":"",onClick:()=>s(i),onKeyDown:c=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(c.key))return;c.preventDefault();const u=c.key==="Home"?0:c.key==="End"?t.length-1:(l+(c.key==="ArrowRight"?1:-1)+t.length)%t.length;s(t[u]),c.currentTarget.parentElement?.children[u]?.focus()},children:[i,!!o[i]&&a.jsx("span",{className:"contact-unread","aria-label":`${o[i]} unread`,children:o[i]})]},i))})}function Cz(e){const t=g.useRef(null),n=g.useRef(new Map),s=e.task?.id??`${e.scope}:${e.workspaceView}:${e.lifetime}`;g.useLayoutEffect(()=>{const x=t.current;x&&(x.scrollTop=n.current.get(s)??0)},[s]);const r=x=>x.toLowerCase().includes(e.search.toLowerCase()),o=e.scope!=="External",i=e.scope==="Workspace"&&e.workspaceView==="Agents",l=e.agents.filter(x=>(i||!x.taskId)&&(!i||x.lifetime===e.lifetime)&&r(x.name)),c=e.tasks.filter(x=>["Active","Review"].includes(x.status)&&r(x.name)),u=new Set(e.tasks.flatMap(x=>[x.roomCid,...(x.layoutRooms??[]).map(C=>C.identity_cid)]).filter(Boolean)),d=o&&(e.scope==="All"||e.workspaceView!=="Tasks"),p=o&&(e.scope==="All"||e.workspaceView!=="Agents"),f=e.scope!=="Workspace",h=x=>x.layout?Gt(x.id,x.layoutRooms?.find(C=>C.state==="active")?.key??x.layoutRooms?.[0]?.key):Gt(x.id),m=[],v=x=>e.contacts.find(C=>C.id===x)?.announcedName??"",b=(x,C)=>{C&&m.push({id:x,kind:"contact",cid:C,name:v(C)})},k=x=>{const C=Ct(x),M=C&&e.tasks.find(E=>E.id===C.taskId);return M?C.key?M.layoutRooms?.find(E=>E.key===C.key)?.identity_cid:M.roomCid:void 0};if(e.task){if(e.task.layout)for(const x of e.task.layoutRooms??[])x.identity_cid&&r(x.key)&&b(Gt(e.task.id,x.key),x.identity_cid);else b(Gt(e.task.id),e.task.roomCid);for(const x of e.task.agents)m.push({id:x,kind:"agent"})}else{if(d)for(const x of l)m.push({id:x.id,kind:"agent"});if(p)for(const x of c){const C=h(x);b(C,k(C))}if(f)for(const x of e.contacts)!u.has(x.id)&&x.status!=="pending"&&!x.id.startsWith("messenger-")&&(e.scope==="External"||r(x.name))&&m.push({id:x.id,kind:"contact",cid:x.id,name:x.announcedName??""})}const z=g.useRef(null),R=jz(m,z),A=x=>{const C=R[x];return!C&&Ct(x)&&!Sz(e.tasks,x)?{last:"No room messages yet",when:"",activityAt:""}:{last:C?`${C.text}${C.unavailable?" · Unable to refresh":""}`:"Loading…",when:C?.at?Jp(C.at):"",activityAt:C?.at??""}},D=(x,C="work")=>{const M=k(x);return e.notificationChats?.filter(E=>E.source===(M?"messenger":C)&&E.chat===(M??x)).reduce((E,T)=>E+T.count,0)??0},O=(x,C,M,E,T=0,B=x)=>a.jsx(qi,{hideAvatar:!0,category:M,previewId:B,c:{...pn(x,C),...A(B),unread:T+D(B)},active:e.selected===x,onClick:E},x),I=e.contacts.filter(x=>!u.has(x.id)).map(x=>({...x,...x.status==="pending"?{last:"Awaiting approval",when:"",activityAt:""}:A(x.id)})),F=I.filter(x=>!x.id.startsWith("messenger-")&&r(x.name)),L=x=>x.agents.reduce((C,M)=>C+D(M),0)+(x.layout?(x.layoutRooms??[]).reduce((C,M)=>C+D(Gt(x.id,M.key)),0):D(Gt(x.id))),j=(d?l.length:0)+(p?c.length:0)+(f?F.length:0);return a.jsx(jf,{id:"fleet-sessions",children:a.jsxs("div",{className:"listcol",ref:z,children:[a.jsx("div",{className:"listcol-head fleet-session-head",children:e.task?a.jsxs("div",{className:"fleet-session-context",children:[a.jsxs("div",{className:"fleet-task-toolbar",children:[a.jsx(wr,{onClick:e.leaveTask,label:"Back to chats"}),a.jsx(J,{onClick:()=>e.taskMenu(e.task.id),children:"Task ⋯"})]}),a.jsxs("div",{className:"fleet-task-summary",children:[a.jsx("h2",{children:e.task.name}),a.jsxs("p",{className:"muted",children:[e.task.status," · ",e.task.layout?(x=>`${x} ${x===1?"room":"rooms"} open`)((e.task.layoutRooms??[]).filter(x=>x.state==="active").length):`${e.task.agents.length} agents`]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(_z,{label:"Chat source",choices:["All","Agents","Tasks","External"],value:e.scope==="Workspace"?e.workspaceView==="Tasks"?"Tasks":"Agents":e.scope,unread:{All:(e.notificationChats??[]).reduce((x,C)=>x+C.count,0),Agents:(e.notificationChats??[]).filter(x=>x.source==="work").reduce((x,C)=>x+C.count,0),Tasks:e.tasks.reduce((x,C)=>x+L(C),0),External:(e.notificationChats??[]).filter(x=>x.source==="messenger"&&!u.has(x.chat)).reduce((x,C)=>x+C.count,0)},nodes:{All:"root",Agents:"agents",Tasks:"tasks",External:"messenger"},change:x=>{e.setScope(x==="Agents"||x==="Tasks"?"Workspace":x),e.setWorkspaceView(x==="Tasks"?"Tasks":x==="Agents"?"Agents":"All work")}}),i&&a.jsx(fz,{value:e.lifetime,change:e.setLifetime})]})}),a.jsx("div",{className:"fleet-external-list",hidden:e.scope!=="External"||!!e.task,children:a.jsx(Wp,{hideAvatars:!0,category:"External",contacts:I.map(x=>({...x,id:x.status==="pending"?`pending:${x.id}`:x.id,unread:D(x.id,"messenger")})),roots:{},selected:e.selected,onSelect:e.openExternal,onInvite:e.invite,onSettings:e.settings,onApprovePending:e.approve,onRejectPending:e.reject})}),a.jsx("div",{ref:t,onScroll:x=>n.current.set(s,x.currentTarget.scrollTop),className:"listcol-scroll",hidden:e.scope==="External"&&!e.task,"aria-label":e.task?`${e.task.name} conversations`:"Chats",children:e.task?a.jsxs("div",{className:"conversation-group",children:[e.task.layout?a.jsxs(a.Fragment,{children:[(e.task.layoutRooms??[]).filter(x=>x.identity_cid&&r(x.key)).map(x=>O(Gt(e.task.id,x.key),x.key,x.state==="closed"?"Closed room":"Room",()=>e.openRoom(e.task.id,!0,x.key))),e.manageRooms&&(()=>{const x=(e.task.layoutRooms??[]).filter(C=>!C.identity_cid).length;return a.jsx("button",{className:"fleet-rooms-manage",onClick:()=>e.manageRooms(e.task.id),children:x?`${x} ${x===1?"room":"rooms"} not opened · Manage rooms`:"Manage rooms"})})()]}):r("Room")&&O(Gt(e.task.id),"Room","",()=>e.openRoom(e.task.id)),e.task.agents.map(x=>e.agents.find(C=>C.id===x)).filter(x=>!!x&&r(x.name)).map(x=>O(x.id,x.name,"Agent",()=>e.openChat(x.id)))]}):a.jsxs("div",{className:"conversation-group",children:[d&&l.map(x=>O(x.id,x.name,"Agent",()=>e.openChat(x.id))),p&&c.map(x=>O(x.id,x.name,x.layout?(C=>`Task · ${C} ${C===1?"room":"rooms"} open`)((x.layoutRooms??[]).filter(C=>C.state==="active").length):"Task",()=>e.openRoom(x.id,!1),L(x)-D(h(x)),h(x))),f&&F.map(x=>a.jsx(qi,{hideAvatar:!0,category:"External",c:{...x,unread:D(x.id,"messenger")},active:e.selected===x.id,onClick:()=>e.openExternal(x.id),onApprove:()=>e.approve(x.id),onReject:()=>e.reject(x.id)},x.id)),!j&&a.jsx("p",{className:"fleet-session-context muted",children:"No chats match these filters."})]})}),a.jsx("div",{className:"list-bottom-chrome",hidden:e.scope==="External"&&!e.task,children:a.jsx(Kp,{value:e.search,onChange:e.setSearch,label:e.task?"Search this task":"Search chats",placeholder:e.task?"Search this task":"Search chats"})})]})})}function Iz(){return a.jsx("svg",{className:"fleet-launcher-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:Array.from({length:9},(e,t)=>a.jsx("rect",{x:3+t%3*7,y:3+Math.floor(t/3)*7,width:"4",height:"4",rx:".6"},t))})}function zz(){return a.jsx(rz,{children:a.jsx(gh,{live:!0,children:a.jsx(xc,{children:a.jsx(kz,{live:!0,children:a.jsx(Nz,{})})})})})}function Nz(){const{summary:e,refresh:t,viewed:n,captureRevision:s}=Uf(),r=e.unread;g.useEffect(()=>{const N=Vf();t();const W=()=>{document.visibilityState==="visible"&&t()},q=()=>{ni().catch(()=>{}),W()},te=Ie=>{Ie.data?.type?.startsWith("ours-push")&&q()},le=setInterval(W,5e3);return addEventListener("ours-notifications-changed",W),addEventListener("focus",q),document.addEventListener("visibilitychange",W),navigator.serviceWorker?.addEventListener("message",te),()=>{N(),removeEventListener("ours-notifications-changed",W),clearInterval(le),removeEventListener("focus",q),document.removeEventListener("visibilitychange",W),navigator.serviceWorker?.removeEventListener("message",te)}},[]);const[o,i]=g.useState([]),[l,c]=g.useState(null);g.useRef(new Set);const[u,d]=g.useState([]),[p,f]=g.useState([]),h=g.useRef(),[m,v]=g.useState({}),[b,k]=g.useState([]),[z,R]=g.useState("work"),[A,D]=g.useState({kind:"home"}),[O,I]=g.useState(null),F=g.useRef(null),L=N=>{N&&!O&&document.activeElement instanceof HTMLElement&&(F.current=document.activeElement),I(N)},[j,x]=g.useState("Persistent"),[C,M]=g.useState("All"),[E,T]=g.useState("All work"),B=g.useRef("work"),Y=g.useRef(""),[re,oe]=g.useState(null),[w,U]=g.useState(null),[ne,_]=g.useState(null),[ue,Se]=g.useState(!1),[H,he]=g.useState(""),[Ee,Re]=g.useState(""),[Le,nt]=g.useState("All lists"),[lt,kn]=g.useState(()=>localStorage.getItem("ours-fleet-dark")!=="0"),[tn,nn]=g.useState(""),[ss,rs]=g.useState(!1),[sn,wt]=g.useState([]),st=g.useRef(),rn=g.useRef(!1),On=g.useRef(!0),yt=g.useRef(null),Rt=g.useRef(A);Rt.current=A;const ct=g.useRef([]),Z=g.useRef({kind:"home"}),X=g.useRef(null),ie=g.useRef(0),we=N=>N.kind==="profile"||N.kind==="contacts",ye=we(A)?Z.current:A,ke=z==="messenger"?ne:w,Xe=g.useRef(null);Xe.current=ke&&A.kind==="home"&&z!=="tasks"&&(!matchMedia("(max-width: 700px)").matches||ue)?{source:z==="messenger"?"messenger":"work",id:ke}:null;const ut=(N,W,q)=>{Xe.current?.source===N&&Xe.current.id===W&&n(N,W,q)},jt=u.find(N=>N.id===re),de=ye.kind==="task"?u.find(N=>N.id===ye.id):void 0,qe=N=>{nn(N),clearTimeout(st.current),st.current=setTimeout(()=>nn(""),4e3)};g.useEffect(()=>()=>clearTimeout(st.current),[]),g.useEffect(()=>(document.documentElement.classList.toggle("theme-dark",lt),localStorage.setItem("ours-fleet-dark",lt?"1":"0"),()=>document.documentElement.classList.remove("theme-dark")),[lt]);const ze=N=>{we(N)&&!we(Rt.current)&&(Z.current=Rt.current,ie.current=ct.current.length,X.current=O?F.current:document.activeElement instanceof HTMLElement?document.activeElement:null);const W=Rt.current;if(W.kind==="settings"&&N.kind==="settings"&&W.editor&&(!N.editor||W.editor.startsWith(N.editor+"/"))){let te=-1;for(let le=ct.current.length-1;le>=0;le--){const Ie=ct.current[le];if(Ie.kind==="settings"&&Ie.editor===N.editor){te=le;break}}te>=0&&(ct.current.length=te)}else ct.current.push(W);D(N),L(null)},dt=()=>{D(Z.current),L(null),ct.current.length=ie.current,requestAnimationFrame(()=>{X.current?.isConnected&&X.current.focus({preventScroll:!0})})},An=()=>{D(ct.current.pop()??(Rt.current.kind==="settings"&&Rt.current.editor?{kind:"settings"}:{kind:"home"})),L(null)},Ht=N=>{R(N==="work"?B.current:N),N==="messenger"&&(M("External"),oe(null),B.current=N),ze({kind:"home"}),Se(!1)};g.useEffect(()=>{const N=()=>{const W=location.pathname.replace(/^\/fleet\/?/,"").split("/").filter(Boolean).map(decodeURIComponent);if(W[0]==="chats"){const q=new URLSearchParams(location.search),te=q.get("source")==="messenger"?"messenger":"work";R(te),B.current=te,D({kind:"home"}),M(["All","Workspace","External"].includes(q.get("scope")??"")?q.get("scope"):"All"),T(["All work","Agents","Tasks"].includes(q.get("view")??"")?q.get("view"):"All work"),x(q.get("lifetime")==="Temporary"?"Temporary":"Persistent"),oe(q.get("task")),he(q.get("search")??""),Y.current=q.get("parentSearch")??"";const le=q.get("chat");yt.current=le&&location.hash?{id:le,source:te,hash:location.hash}:null,Se(q.get("detail")==="1"),te==="messenger"?_(le):U(le),le&&wt(Ie=>[...new Set([...Ie,le])])}else if(W[0]==="tasks")R("tasks"),D(W[1]?{kind:"task",id:W[1]}:{kind:"home"});else if(W[0]==="profile")D(W[2]==="contacts"?{kind:"contacts",id:W[1]??"human",peer:W[3]}:{kind:"profile",id:W[1]??"human"});else if(W[0]==="notifications")D({kind:"notifications"});else if(W[0]==="settings")D({kind:"settings",editor:W.slice(1).join("/")||void 0});else if(W[0]==="account")D({kind:"account",step:W[1]??"login"});else if(W[0]==="empty")D({kind:"empty"});else if(W[0]==="messenger"){if(M("External"),oe(null),B.current="messenger",R("messenger"),D({kind:"home"}),W[1]){_(W[1]);const q=o.find(te=>`messenger-${te.id}`===W[1]);q&&f(te=>te.some(le=>le.id===W[1])?te:[...te,pn(W[1],q.name)]),Se(!0),wt(te=>[...new Set([...te,W[1]])])}}else if(oe(null),Se(!1),B.current="work",R("work"),D({kind:"home"}),W[1]){U(W[1]),Se(!0),wt(te=>[...new Set([...te,W[1]])]);const q=o.find(te=>te.id===W[1]);q?(x(q.lifetime),oe(q.taskId??null)):Ct(W[1])&&(x("Temporary"),oe(Ct(W[1]).taskId))}L(null)};return N(),rn.current=!0,addEventListener("popstate",N),()=>removeEventListener("popstate",N)},[]),g.useEffect(()=>{if(!rn.current)return;if(On.current){On.current=!1;return}let N="/fleet";if(A.kind==="home")if(z==="tasks")N+="/tasks";else{const W=new URLSearchParams;C!=="All"&&W.set("scope",C),E!=="All work"&&W.set("view",E),j!=="Persistent"&&W.set("lifetime",j),re&&(W.set("task",re),Y.current&&W.set("parentSearch",Y.current)),H&&W.set("search",H),z==="messenger"&&W.set("source",z),ke&&W.set("chat",ke),ue&&W.set("detail","1"),N+="/chats"+(W.size?"?"+W.toString():"")}else A.kind==="task"?N+=`/tasks/${A.id}`:A.kind==="profile"||A.kind==="contacts"?N+=`/profile/${A.id}${A.kind==="contacts"?"/contacts"+(A.peer?"/"+encodeURIComponent(A.peer):""):""}`:A.kind==="notifications"?N+="/notifications":A.kind==="settings"?N+=`/settings${A.editor?"/"+A.editor:""}`:A.kind==="account"?N+=`/account/${A.step}`:N+="/empty";A.kind==="home"&&ke===yt.current?.id&&(z==="messenger"?"messenger":"work")===yt.current?.source&&(N+=yt.current.hash),N=Hi(N),location.pathname+location.search+location.hash!==N&&window.history.pushState({},"",N)},[z,A,ue,w,ne,C,E,j,re,H]);const zt=g.useRef(o);g.useEffect(()=>{if(zt.current===o)return;zt.current=o;const N=o.find(W=>W.id===w);N&&(N.taskId||oe(null),!N.taskId&&C==="Workspace"&&E==="Agents"&&x(N.lifetime))},[w,o]);const vt=(N,W="work")=>{if(yt.current=null,wt(q=>[...new Set([...q,N])]),B.current=W,W==="messenger"&&C==="Workspace"&&M("External"),W==="work"&&C==="External"&&M("Workspace"),W==="messenger"){oe(null),_(N);const q=o.find(te=>`messenger-${te.id}`===N);q&&f(te=>te.some(le=>le.id===N)?te:[...te,pn(N,q.name)])}else{U(N);const q=o.find(te=>te.id===N);q&&!(C==="Workspace"&&E==="Agents"&&!re)&&(q.taskId&&!re&&(Y.current=H,he("")),oe(q.taskId??null))}R(W),D({kind:"home"}),Se(!0),L(null)},[os,Wt]=g.useState(""),[wn,G]=g.useState(!1),fe=g.useRef([]),Oe=async()=>{const[N,W,q]=await Promise.all([ee("/roles?includeTemporary=true"),ee("/tasks"),ee("/task-lists")]);i(N.roles.map(te=>({...Cf(te),taskId:W.tasks.find(le=>le.member_roles.some(Ie=>Ie.name===te.role.id))?.task_id}))),d(W.tasks.map(ti)),fe.current=W.tasks,k(q.lists.map(te=>te.name));try{f(await If()),Wt("")}catch(te){Wt("Messenger: "+te.message)}G(!0)};g.useEffect(()=>{let N=!0,W;const q=async()=>{try{await Oe()}catch(te){N&&Wt(te.message)}finally{N&&(W=setTimeout(q,1e4))}};return q(),()=>{N=!1,clearTimeout(W)}},[]);const Fe=async N=>{const W=s(),q=$s(fe.current,N);if(Ct(N)&&!q)throw new Error("This room is not open yet.");const te=p.some(on=>on.id===N)||!!q,le=Xe.current?.id===N&&location.hash.startsWith("#chat-message-")?location.hash:"";let Ie;try{Ie=le?decodeURIComponent(le.slice(14)):void 0}catch{}const _t=JSON.stringify([q??N,le]),Me=le&&h.current?.key===_t?h.current.messages:void 0;let Tt=te?await Nf(q??N,Me?void 0:Ie):await Ef(N);if(te&&le){const on=new Map((Me??[]).map(Ot=>[Ot.wireId??Ot.date+Ot.text,Ot]));for(const Ot of Tt)on.set(Ot.wireId??Ot.date+Ot.text,Ot);Tt=[...on.values()].sort((Ot,jp)=>Date.parse(Ot.date)-Date.parse(jp.date)),h.current={key:_t,messages:Tt}}v(on=>({...on,[N]:Tt}));const $n=!le||!!Ie&&Tt.some(on=>on.wireId===Ie);le&&Xe.current?.id===N&&Wt($n?"":"The notified message is unavailable or beyond the history search limit. Its notification remains unread."),requestAnimationFrame(()=>{Xe.current?.id!==N||te&&location.hash!==le||le&&(location.hash!==le||!$n||!document.getElementById(le.slice(1)))||(n(te?"messenger":"work",q??N,W),te&&document.visibilityState==="visible"&&it.markRead(q??N).catch(()=>{}))})};g.useEffect(()=>{if(!ke||ke.startsWith("draft-")||!wn||o.some(Ie=>Ie.id===ke)||z==="work"&&!Ct(ke)&&!o.some(Ie=>`messenger-${Ie.id}`===ke))return;let N=!0,W;const q=async()=>{try{await Fe(ke)}catch(Ie){N&&Wt(Ie.message)}finally{N&&(W=setTimeout(q,3e3))}};q();const te=Gp("/messenger/api/events",()=>{Fe(ke).catch(()=>{})}),le=()=>{Fe(ke).catch(()=>{})};return addEventListener("ours-notifications-changed",le),()=>{N=!1,clearTimeout(W),removeEventListener("ours-notifications-changed",le),te()}},[ke,wn,p.map(N=>N.id).join(","),o.map(N=>N.id).join(","),A.kind,z,ue]);const be=()=>{const N="draft-"+crypto.randomUUID();c({id:N,name:"",role:"",brain:"",permissions:"Ask before changes",folder:""}),oe(null),vt(N)},_e=(N,W=!0,q)=>{const te=u.find(Ie=>Ie.id===N),le=q??(te?.layout?te.layoutRooms?.find(Ie=>Ie.state==="active")?.key:void 0);if(W&&te?.layout&&!le){ze({kind:"task",id:N});return}re||(Y.current=H),he(""),oe(N),W?vt(Gt(N,le)):(U(null),R("work"),D({kind:"home"})),Se(W)},rt=(N,W)=>{const q=W.status==="Provisioning"?"start":W.status==="Review"?"review":"";if(!q){qe("This change is not available.");return}ee(`/tasks/${N}/${q}`,{}).then(async te=>{await Oe(),(te.provisioning?.blocker||te.provisioning?.next_action)&&qe(te.provisioning.blocker??te.provisioning.next_action)}).catch(te=>qe(te.message))},St=async(N,W,q)=>{const te=Ct(N);if(te?.key&&u.find(_t=>_t.id===te.taskId)?.layoutRooms?.find(_t=>_t.key===te.key)?.state==="closed")throw new Error("This room is closed. Messages can no longer be sent.");const le=$s(fe.current,N);if(Ct(N)&&!le)throw new Error("This room is not open yet.");if(p.some(_t=>_t.id===N)||le){const _t=await it.send(le??N,W,q);return await Fe(N),_t.wire_id??""}const Ie=await ee(`/roles/${encodeURIComponent(N)}/input`,{text:W,commandId:crypto.randomUUID()});return await Fe(N),Ie.promptId??Ie.commandId};de?.id??jt?.id;const Dt=O?a.jsx(tz,{modal:O,close:()=>L(null),setModal:L,section:z,agents:o,tasks:u,lists:b,go:ze,switchSection:Ht,openChat:vt,refresh:Oe,notify:qe,newChat:be,closedChat:N=>{wt(W=>W.filter(q=>q!==N)),U(null),Se(!1),D({kind:"home"})}},`${O.kind}:${O.id??""}`):null;return a.jsxs("div",{className:"fleet-app"+(ue&&ye.kind==="home"&&z!=="tasks"?" fleet-in-chat":"")+(ye.kind==="account"?" fleet-account-mode":""),children:[a.jsxs("header",{className:"fleet-nav",hidden:ye.kind==="account",children:[a.jsxs("button",{className:"fleet-brand",onClick:()=>Ht("work"),children:["ours",a.jsx("span",{className:"fleet-preview",children:"Local"})]}),Qs()&&a.jsx(nc,{context:Qs(),select:N=>un("select",N),add:()=>un("add"),settings:()=>un("settings"),logout:()=>un("logout")}),a.jsxs(Yp,{className:"fleet-section-trigger","aria-label":`Change section: ${z==="tasks"?"Tasks":"Chats"}`,"aria-haspopup":"dialog","aria-expanded":O?.kind==="navigation",onClick:()=>L({kind:"navigation"}),children:[a.jsx("span",{children:z==="tasks"?"Tasks":"Chats"}),a.jsx(ic,{size:12,"aria-hidden":!0})]}),a.jsxs(Ft,{className:" fleet-nav-trigger","aria-label":"Navigate",onClick:()=>L({kind:"navigation"}),children:[a.jsx(Iz,{}),r>0&&a.jsx("span",{className:"fleet-unread-dot","aria-label":"Unread chats"})]}),a.jsx("span",{className:"fleet-host",children:wn?"Connected to Fleet":"Connecting…"}),a.jsxs("div",{className:"fleet-actions",children:[a.jsxs(Ft,{className:"","aria-label":`Notifications${r?`, ${r} unread`:""}`,onClick:()=>ze({kind:"notifications"}),children:[a.jsx(ei,{size:18}),r>0&&a.jsx("small",{children:r})]}),a.jsx(J,{primary:!0,"aria-label":"Add or connect",onClick:()=>L({kind:"add"}),children:a.jsx(wo,{size:18})}),a.jsx(Ft,{className:"","aria-label":lt?"Use light theme":"Use dark theme",onClick:()=>kn(N=>!N),children:lt?a.jsx(Xp,{size:18}):a.jsx(Qp,{size:18})}),a.jsx(Ft,{className:" fleet-desktop-control","aria-label":"Settings",onClick:()=>ze({kind:"settings"}),children:a.jsx(pc,{size:18})}),a.jsx(Ft,{className:" fleet-desktop-control","aria-label":"My profile",onClick:()=>ze({kind:"profile",id:"human"}),children:a.jsx(yf,{size:18})})]})]}),a.jsx(JR,{}),a.jsxs("div",{className:"fleet-body",children:[a.jsx(YR,{}),a.jsxs("div",{className:"fleet-body-main",children:[os&&a.jsxs("div",{className:"fleet-live-error",role:"alert",children:[os,a.jsx(J,{onClick:()=>void Oe().catch(N=>Wt(N.message)),children:"Retry"})]}),a.jsxs("div",{className:"fleet-workspace"+(ue?" fleet-show-detail":""),hidden:ye.kind!=="home"||z==="tasks",children:[a.jsx("aside",{className:"fleet-list fleet-messenger-list signal-stage","aria-label":"Chats",children:a.jsx(Cz,{invite:()=>L({kind:"add"}),settings:()=>ze({kind:"settings"}),agents:o,tasks:u,contacts:p,notificationChats:e.chats,task:jt,selected:ke,scope:C,workspaceView:E,lifetime:j,search:H,setSearch:he,setScope:N=>{M(N),oe(null)},setWorkspaceView:T,setLifetime:x,leaveTask:()=>{oe(null),he(Y.current),Se(!1),U(null)},openChat:vt,openExternal:N=>vt(N,"messenger"),openRoom:_e,manageRooms:N=>ze({kind:"task",id:N}),taskMenu:N=>L({kind:"task-menu",id:N}),approve:async N=>(await it.respondToIntroduction(N,"approve"),await Oe(),!0),reject:async N=>(await it.respondToIntroduction(N,"reject"),await Oe(),!0)})}),a.jsxs("section",{className:"fleet-conversation","aria-label":z==="messenger"?"Messenger":"My Agent chat",children:[!ke&&a.jsxs("div",{className:"fleet-no-conversation",children:[a.jsx("h2",{children:"Choose a conversation"}),a.jsx("p",{children:"Your agents and their chats are in the list. Open one whenever you’re ready."})]}),sn.map(N=>{if(N.startsWith("draft-"))return l?.id===N?a.jsx("div",{className:"fleet-chat-slot",hidden:ke!==N,children:a.jsx(Sh,{active:ke===N&&A.kind==="home"&&z!=="tasks"&&(!matchMedia("(max-width: 700px)").matches||ue),dark:lt,back:()=>Se(!1),ready:async Me=>{await Oe(),wt(Tt=>Tt.filter($n=>$n!==N)),c(null),vt(Me)}})},N):null;const W=o.find(Me=>Me.id===N||`messenger-${Me.id}`===N),q=Ct(N),te=q?u.find(Me=>Me.id===q.taskId):void 0,le=q?$s(fe.current,N):N,Ie=!!q?.key&&te?.layoutRooms?.find(Me=>Me.key===q.key)?.state==="closed";if(z==="work"&&!W&&!q)return a.jsx("div",{className:"fleet-chat-slot",hidden:ke!==N,children:a.jsx(KR,{loaded:wn,dark:lt,back:()=>Se(!1)})},N);if(W&&W.id===N)return a.jsx("div",{className:"fleet-chat-slot",hidden:ke!==N,children:a.jsx(WR,{id:N,name:W.name,active:ke===N&&A.kind==="home"&&z!=="tasks"&&(!matchMedia("(max-width: 700px)").matches||ue),dark:lt,back:()=>Se(!1),captureNotificationRevision:s,viewed:Me=>ut("work",N,Me),actions:()=>ze({kind:"profile",id:N})})},N);const _t=p.find(Me=>Me.id===le)??pn(le??N,q?q.key?`${te?.name??"Task"} · ${q.key}`:"Room":W?.name??(l?.id===N?"New chat":"Agent"));return a.jsx("div",{className:"fleet-chat-slot signal-stage show-detail",hidden:ke!==N,children:a.jsx(ef,{hideContactAvatar:!0,headerActions:a.jsxs("div",{className:"fleet-header-actions",children:[z==="work"&&(W||q)&&a.jsx(Ft,{className:"","aria-label":q?"Room actions":"Agent actions",onClick:()=>q?L({kind:"members",id:N}):ze({kind:"profile",id:W?.id??N}),children:a.jsx(ko,{size:20})}),a.jsx(Ft,{className:" fleet-desktop-control","aria-label":"Close conversation",onClick:()=>{z==="messenger"?_(null):U(null),Se(!1)},children:a.jsx(oc,{size:18})})]}),readOnlyNotice:Ie?a.jsxs(a.Fragment,{children:[a.jsx(Qo,{size:14,"aria-hidden":!0})," This room is closed. Its history stays available; messages can no longer be sent."]}):void 0,headerAccessory:q?.key&&te?.layoutRooms&&te.layoutRooms.length>1?a.jsx(rh,{taskId:q.taskId,rooms:te.layoutRooms,current:q.key,select:Me=>_e(q.taskId,!0,Me)}):void 0,contact:_t,messages:m[N]??[],onBack:()=>Se(!1),onOpenContact:l?.id===N&&!W?void 0:()=>q?L({kind:"members",id:N}):ze({kind:"profile",id:N}),onSend:(Me,Tt)=>St(N,Me,Tt),onSendFile:!Ie&&(p.some(Me=>Me.id===N)||q&&le)?async(Me,Tt)=>{const $n=q?$s(fe.current,N):N;await it.sendFile($n,new Blob([new Uint8Array(Me.bytes)]),Me.filename,Me.mime,Tt),await Fe(N)}:void 0})},N)})]})]}),ye.kind==="home"&&z==="tasks"&&a.jsxs("main",{className:"fleet-page fleet-board-page",children:[a.jsx(We,{title:"Tasks",actions:a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"field","aria-label":"Filter task list",value:Le,onChange:N=>nt(N.target.value),children:["All lists",...b].map(N=>a.jsx("option",{children:N},N))}),a.jsx(J,{onClick:()=>L({kind:"lists"}),children:"Manage lists"})]})}),a.jsx(xr,{value:Ee,onChange:Re,placeholder:"Search tasks"}),a.jsx("div",{className:"fleet-board",children:XR.map(N=>{const W=u.filter(q=>q.status===N&&(Le==="All lists"||q.list===Le)&&q.name.toLowerCase().includes(Ee.toLowerCase()));return a.jsxs("section",{className:"fleet-column",children:[a.jsxs("h2",{children:[N," ",a.jsx("span",{children:W.length})]}),W.map(q=>a.jsxs("button",{className:"fleet-task-card",onClick:()=>ze({kind:"task",id:q.id}),children:[a.jsx("strong",{children:q.name}),a.jsx("span",{children:q.list}),a.jsx("small",{className:q.blocked?"fleet-warning":"",children:q.blocked?`Blocked · ${q.blocked}`:q.status==="Provisioning"?"Provisioning":q.status==="Backlog"?"Not started":q.status==="Failed"?"Launch failed":q.status==="Done"?"Completed":q.layout?`${(q.layoutRooms??[]).filter(te=>te.state==="active").length} of ${(q.layoutRooms??[]).length} rooms open`:`${q.agents.length} agents`})]},q.id))]},N)})})]}),ye.kind==="task"&&(de?a.jsxs("main",{className:"fleet-page fleet-task-page",children:[a.jsx(We,{title:de.name,onBack:An,actions:a.jsx(Ft,{"aria-label":"Task actions",onClick:()=>L({kind:"task-menu",id:de.id}),children:a.jsx(ko,{size:20})})}),a.jsxs("div",{className:"fleet-task-toolbar",children:[a.jsx("span",{className:"fleet-task-status",children:de.status}),["Backlog","Active"].includes(de.status)&&a.jsx(J,{primary:!0,disabled:!!de.pending||de.status==="Backlog"&&!de.layout,title:de.status==="Backlog"&&!de.layout?"Choose a room layout first":void 0,onClick:()=>rt(de.id,{status:de.status==="Backlog"?"Provisioning":"Review"}),children:de.status==="Backlog"?"Start task":"Send to review"}),de.status==="Review"&&a.jsx(J,{primary:!0,disabled:!!de.pending,onClick:()=>L({kind:"task-menu",id:de.id}),children:"Review task"}),de.roomCid&&a.jsx(J,{onClick:()=>_e(de.id),children:"Open room"})]}),de.pending&&a.jsx("p",{role:"status",children:de.pending}),de.blocked&&a.jsxs("p",{className:"fleet-warning",children:["Blocked · ",de.blocked]}),a.jsxs("div",{className:"fleet-task-content",children:[a.jsxs("div",{className:"fleet-task-main",children:[a.jsx(qf,{task:de,onSaved:N=>d(W=>W.map(q=>q.id===N.id?{...q,...N,layout:q.layout,layoutRooms:q.layoutRooms}:q))},de.id),de.layout&&a.jsx(sh,{task:de,openRoom:N=>_e(de.id,!0,N),changed:()=>void Oe().catch(()=>{})},`${de.id}:${de.layout}:${de.layoutHash??""}`)]}),a.jsxs("aside",{"aria-label":"Task properties",children:[a.jsxs("dl",{className:"fleet-task-properties",children:[a.jsx("dt",{children:"List"}),a.jsx("dd",{children:a.jsx("button",{onClick:()=>L({kind:"move-task",id:de.id}),children:de.list})}),a.jsx("dt",{children:"Task ID"}),a.jsx("dd",{className:"muted",children:de.id})]}),a.jsx(oh,{task:de,manage:()=>ze({kind:"settings",editor:"layouts"}),saved:N=>{d(W=>W.map(q=>q.id===N.id?N:q)),Oe().catch(()=>{})}},de.id),de.layout?null:a.jsxs(a.Fragment,{children:[a.jsxs("h2",{children:["Participants ",a.jsx("span",{className:"muted",children:de.agents.length||""})]}),de.agents.length?de.agents.map(N=>{const W=o.find(q=>q.id===N);return a.jsxs("button",{className:"fleet-task-participant",onClick:()=>vt(N),children:[a.jsx("span",{children:W?.name??N}),W&&a.jsx("small",{className:"muted",children:W.state})]},N)}):a.jsx("p",{className:"muted",children:de.status==="Backlog"?"Assigned when the task starts.":"No participants."})]})]})]})]}):a.jsx("main",{className:"fleet-page",children:a.jsx(We,{title:"Task no longer available",onBack:()=>Ht("tasks")})})),(A.kind==="profile"||A.kind==="contacts")&&a.jsxs(Es,{title:"Profile",wide:!0,onClose:dt,className:"fleet-modal fleet-profile-modal",children:[!O&&(A.kind==="contacts"&&o.find(N=>N.id===A.id)?a.jsx(ih,{agent:o.find(N=>N.id===A.id),peer:A.peer,go:ze},A.id):a.jsx(pz,{id:A.id,agents:o,go:ze,modal:L,tasks:u})),Dt]}),ye.kind==="notifications"&&a.jsx(Zf,{back:An,changed:()=>void t(),open:N=>{!N.startsWith("/fleet/")||N.startsWith("//")||(window.history.pushState({},"",Hi(N)),dispatchEvent(new PopStateEvent("popstate")))}}),ye.kind==="settings"&&a.jsx(dz,{back:An,editor:ye.editor,go:ze}),ye.kind==="account"&&a.jsxs("main",{className:"fleet-page",children:[a.jsx(We,{title:"Local instance",onBack:An}),a.jsx("p",{children:"Central accounts are not enabled."})]}),ye.kind==="empty"&&a.jsxs("main",{className:"fleet-form-page",children:[a.jsx(We,{title:"Your first agent session",subtitle:"Start a focused conversation with an agent on Workstation.",onBack:()=>ze({kind:"home"})}),a.jsx(Te,{icon:kr,title:"One agent",description:"Choose a template and host folder",onClick:be}),a.jsx(Te,{icon:hc,title:"A task with several agents",description:"Create a task session with a shared room",onClick:()=>L({kind:"new-task"})}),a.jsx(Te,{icon:Sr,title:"Persistent agents",description:"Configured agents appear here when available",onClick:()=>Ht("work")}),a.jsx(Te,{icon:jr,title:"Looking for someone?",description:"Open external chats",onClick:()=>Ht("messenger")})]})]})]}),!we(A)&&Dt,tn&&a.jsxs("div",{className:"fleet-toast",role:"status",children:[tn,a.jsx("button",{"aria-label":"Dismiss notification",onClick:()=>nn(""),children:"×"})]})]})}export{zz as default};
|
|
302
|
+
//# sourceMappingURL=FleetApp-Gjz3h8uS.js.map
|