band-design 0.0.0 → 0.0.1

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.
@@ -0,0 +1,3481 @@
1
+ import {
2
+ durationText,
3
+ failureReason,
4
+ idsUnder,
5
+ orgCheck,
6
+ planOrgAdd,
7
+ precheckOrgAdd,
8
+ scrollIntoPanel,
9
+ shortTime,
10
+ stallNoteOf,
11
+ stoppedTurnText,
12
+ usualDurationText
13
+ } from "./chunk-B2ECXTXC.js";
14
+
15
+ import { jsx } from "react/jsx-runtime";
16
+ function Icon({ icon: Svg, size = 16, strokeWidth = 2.1, label, ...props }) {
17
+ const name = label?.trim() || void 0;
18
+ return /* @__PURE__ */ jsx(
19
+ Svg,
20
+ {
21
+ ...props,
22
+ size,
23
+ width: size,
24
+ height: size,
25
+ strokeWidth,
26
+ focusable: "false",
27
+ role: name ? "img" : void 0,
28
+ "aria-label": name,
29
+ "aria-hidden": name ? void 0 : true
30
+ }
31
+ );
32
+ }
33
+
34
+ import {
35
+ WORKSHOP_GENRES,
36
+ agentDisplayName
37
+ } from "@kanyun-ai-infra/band-contracts/display";
38
+
39
+ var classical_compact_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u53E4\u5178 Classical"><style>.i,.a{fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="rotate(-28 24 25) translate(24 25) scale(1.12) translate(-24 -25)"><path class="i" d="M24 19.5C18.6 19.5 17.4 22.6 18.8 25.6C19.9 27.9 19.6 29 17.8 30.8C14.6 34 15.9 41.5 24 41.5C32.1 41.5 33.4 34 30.2 30.8C28.4 29 28.1 27.9 29.2 25.6C30.6 22.6 29.4 19.5 24 19.5Z"/><path class="i" d="M24 19.5V8.2"/><circle class="i" cx="24" cy="6.4" r="1.8"/><path class="i" d="M21.4 35.6H26.6"/><path class="i" d="M21.6 28.6v4.2M26.4 28.6v4.2"/></g><path class="a" d="M8.5 37.5L39.5 13.5"/><path class="a" d="M8.2 35.2l2.3 3.1"/></svg>%0A';
40
+
41
+ var classical_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u53E4\u5178 Classical"><style>.i,.a{fill:none;stroke-width:2.26;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1.29}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="translate(6.24 1.46) scale(0.774)"><g transform="rotate(-28 24 25) translate(24 25) scale(1.12) translate(-24 -25)"><path class="i" d="M24 19.5C18.6 19.5 17.4 22.6 18.8 25.6C19.9 27.9 19.6 29 17.8 30.8C14.6 34 15.9 41.5 24 41.5C32.1 41.5 33.4 34 30.2 30.8C28.4 29 28.1 27.9 29.2 25.6C30.6 22.6 29.4 19.5 24 19.5Z"/><path class="i" d="M24 19.5V8.2"/><circle class="i" cx="24" cy="6.4" r="1.8"/><path class="i" d="M21.4 35.6H26.6"/><path class="i" d="M21.6 28.6v4.2M26.4 28.6v4.2"/></g><path class="a" d="M8.5 37.5L39.5 13.5"/><path class="a" d="M8.2 35.2l2.3 3.1"/></g><path class="l" d="M5.63 44.57C6.81 44.57 7.6 43.79 7.74 42.84H6.84C6.72 43.43 6.24 43.77 5.64 43.77C4.83 43.77 4.24 43.15 4.24 42.01C4.24 40.87 4.83 40.24 5.65 40.24C6.24 40.24 6.72 40.58 6.84 41.17H7.74C7.58 40.07 6.73 39.44 5.63 39.44C4.33 39.44 3.35 40.39 3.35 42.01C3.35 43.61 4.32 44.57 5.63 44.57ZM8.97 44.5H12.07V43.75H9.87V39.5H8.97ZM12.93 44.5H13.91L14.32 43.26H16.19L16.61 44.5H17.6L15.81 39.5H14.68ZM14.56 42.54 14.77 41.91C14.91 41.46 15.06 40.9 15.24 40.2C15.42 40.89 15.58 41.45 15.73 41.91L15.94 42.54ZM20.43 44.58C21.62 44.58 22.32 43.98 22.32 43.1C22.32 42.23 21.59 41.84 20.85 41.66L20.38 41.54C19.98 41.44 19.53 41.27 19.53 40.86C19.53 40.48 19.88 40.2 20.44 40.2C20.98 40.2 21.34 40.45 21.38 40.87H22.25C22.23 40.04 21.52 39.44 20.45 39.44C19.41 39.44 18.63 40.03 18.63 40.91C18.63 41.61 19.12 42.04 19.96 42.25L20.52 42.4C21.06 42.54 21.42 42.7 21.42 43.09C21.42 43.52 21.01 43.81 20.42 43.81C19.86 43.81 19.41 43.56 19.37 43.03H18.49C18.53 44.02 19.27 44.58 20.43 44.58ZM25.31 44.58C26.5 44.58 27.2 43.98 27.2 43.1C27.2 42.23 26.47 41.84 25.73 41.66L25.26 41.54C24.86 41.44 24.41 41.27 24.41 40.86C24.41 40.48 24.75 40.2 25.32 40.2C25.86 40.2 26.22 40.45 26.26 40.87H27.13C27.11 40.04 26.4 39.44 25.33 39.44C24.28 39.44 23.51 40.03 23.51 40.91C23.51 41.61 24 42.04 24.83 42.25L25.4 42.4C25.94 42.54 26.3 42.7 26.3 43.09C26.3 43.52 25.89 43.81 25.3 43.81C24.74 43.81 24.29 43.56 24.25 43.03H23.37C23.41 44.02 24.14 44.58 25.31 44.58ZM29.33 39.5H28.43V44.5H29.33ZM32.87 44.57C34.05 44.57 34.84 43.79 34.98 42.84H34.08C33.96 43.43 33.48 43.77 32.88 43.77C32.07 43.77 31.48 43.15 31.48 42.01C31.48 40.87 32.07 40.24 32.88 40.24C33.48 40.24 33.96 40.58 34.08 41.17H34.98C34.82 40.07 33.97 39.44 32.87 39.44C31.57 39.44 30.59 40.39 30.59 42.01C30.59 43.61 31.56 44.57 32.87 44.57ZM35.88 44.5H36.86L37.27 43.26H39.13L39.56 44.5H40.54L38.76 39.5H37.62ZM37.5 42.54 37.72 41.91C37.85 41.46 38 40.9 38.18 40.2C38.37 40.89 38.52 41.45 38.67 41.91L38.89 42.54ZM41.62 44.5H44.72V43.75H42.52V39.5H41.62Z"/></svg>%0A';
42
+
43
+ var electronic_compact_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u7535\u5B50 Electronic"><style>.i,.a{fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><rect class="i" x="6" y="26" width="36" height="15" rx="2.5"/><path class="i" d="M12 26v15M18 26v15M24 26v15M30 26v15M36 26v15"/><path class="f" d="M10.4 26h3.2v8h-3.2zM16.4 26h3.2v8h-3.2zM28.4 26h3.2v8h-3.2zM34.4 26h3.2v8h-3.2z"/><path class="a" d="M6 15c3 0 3-7 6-7s3 14 6 14 3-14 6-14 3 14 6 14 3-7 6-7 3 7 6 7"/></svg>%0A';
44
+
45
+ var electronic_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u7535\u5B50 Electronic"><style>.i,.a{fill:none;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1.29}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="translate(5.33 -2.72) scale(0.778)"><rect class="i" x="6" y="26" width="36" height="15" rx="2.5"/><path class="i" d="M12 26v15M18 26v15M24 26v15M30 26v15M36 26v15"/><path class="f" d="M10.4 26h3.2v8h-3.2zM16.4 26h3.2v8h-3.2zM28.4 26h3.2v8h-3.2zM34.4 26h3.2v8h-3.2z"/><path class="a" d="M6 15c3 0 3-7 6-7s3 14 6 14 3-14 6-14 3 14 6 14 3-7 6-7 3 7 6 7"/></g><path class="l" d="M3.45 44.5H6.33V43.83H4.24V42.6H6.17V41.94H4.24V40.74H6.32V40.08H3.45ZM7.49 44.5H10.24V43.83H8.28V40.08H7.49ZM11.29 44.5H14.18V43.83H12.09V42.6H14.01V41.94H12.09V40.74H14.17V40.08H11.29ZM17.23 44.56C18.27 44.56 18.97 43.87 19.09 43.03H18.29C18.19 43.55 17.76 43.85 17.24 43.85C16.52 43.85 16 43.31 16 42.29C16 41.29 16.51 40.73 17.24 40.73C17.77 40.73 18.19 41.03 18.29 41.55H19.09C18.95 40.58 18.2 40.02 17.23 40.02C16.07 40.02 15.2 40.86 15.2 42.29C15.2 43.72 16.06 44.56 17.23 44.56ZM19.99 40.74H21.35V44.5H22.15V40.74H23.51V40.08H19.99ZM24.57 44.5H25.36V42.88H26.18L27.05 44.5H27.94L26.98 42.74C27.5 42.53 27.78 42.09 27.78 41.49C27.78 40.65 27.24 40.08 26.22 40.08H24.57ZM25.36 42.22V40.74H26.1C26.7 40.74 26.97 41.02 26.97 41.49C26.97 41.96 26.7 42.22 26.1 42.22ZM30.79 44.56C31.95 44.56 32.82 43.72 32.82 42.29C32.82 40.86 31.95 40.02 30.79 40.02C29.63 40.02 28.76 40.86 28.76 42.29C28.76 43.72 29.63 44.56 30.79 44.56ZM30.79 43.85C30.07 43.85 29.55 43.3 29.55 42.29C29.55 41.28 30.07 40.73 30.79 40.73C31.51 40.73 32.02 41.28 32.02 42.29C32.02 43.3 31.51 43.85 30.79 43.85ZM33.94 44.5H34.74V42.3C34.74 42.06 34.72 41.59 34.69 41.04C34.98 41.62 35.15 41.93 35.38 42.31L36.76 44.5H37.66V40.08H36.86V42.4C36.86 42.67 36.87 43.12 36.9 43.54C36.71 43.1 36.52 42.77 36.36 42.51L34.83 40.08H33.94ZM39.71 40.08H38.92V44.5H39.71ZM42.85 44.56C43.9 44.56 44.6 43.87 44.72 43.03H43.92C43.82 43.55 43.39 43.85 42.86 43.85C42.14 43.85 41.62 43.31 41.62 42.29C41.62 41.29 42.14 40.73 42.86 40.73C43.39 40.73 43.82 41.03 43.92 41.55H44.71C44.58 40.58 43.82 40.02 42.85 40.02C41.7 40.02 40.83 40.86 40.83 42.29C40.83 43.72 41.69 44.56 42.85 44.56Z"/></svg>%0A';
46
+
47
+ var folk_compact_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u6C11\u8C23 Folk"><style>.i,.a{fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="rotate(32 24 25)"><path class="i" d="M24 18.5C19.4 18.5 18.2 21.9 19.6 25C20.4 26.8 20.1 27.8 18.6 29.3C15.2 32.8 16.2 42 24 42C31.8 42 32.8 32.8 29.4 29.3C27.9 27.8 27.6 26.8 28.4 25C29.8 21.9 28.6 18.5 24 18.5Z"/><circle class="a" cx="24" cy="29.5" r="2.9"/><path class="i" d="M22.8 18.5V7M25.2 18.5V7"/><path class="i" d="M21.8 7l.3-4h3.8l.3 4Z"/><path class="i" d="M21 37h6"/></g></svg>%0A';
48
+
49
+ var folk_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u6C11\u8C23 Folk"><style>.i,.a{fill:none;stroke-width:1.93;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1.1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="translate(-4.00 1.23) scale(0.909)"><g transform="rotate(32 24 25)"><path class="i" d="M24 18.5C19.4 18.5 18.2 21.9 19.6 25C20.4 26.8 20.1 27.8 18.6 29.3C15.2 32.8 16.2 42 24 42C31.8 42 32.8 32.8 29.4 29.3C27.9 27.8 27.6 26.8 28.4 25C29.8 21.9 28.6 18.5 24 18.5Z"/><circle class="a" cx="24" cy="29.5" r="2.9"/><path class="i" d="M22.8 18.5V7M25.2 18.5V7"/><path class="i" d="M21.8 7l.3-4h3.8l.3 4Z"/><path class="i" d="M21 37h6"/></g></g><path class="l" d="M26.5 43.5H27.38V41.53H29.43V40.79H27.38V39.32H29.65V38.57H26.5ZM32.99 43.57C34.28 43.57 35.25 42.63 35.25 41.04C35.25 39.45 34.28 38.51 32.99 38.51C31.7 38.51 30.73 39.45 30.73 41.04C30.73 42.63 31.7 43.57 32.99 43.57ZM32.99 42.78C32.19 42.78 31.62 42.16 31.62 41.04C31.62 39.91 32.19 39.3 32.99 39.3C33.8 39.3 34.36 39.91 34.36 41.04C34.36 42.16 33.8 42.78 32.99 42.78ZM36.5 43.5H39.56V42.76H37.38V38.57H36.5ZM40.73 43.5H41.62V42.02L42.29 41.29L43.78 43.5H44.82L42.9 40.71L44.79 38.57H43.69L42.4 40.05C42.08 40.42 41.83 40.73 41.6 41.09L41.62 40.03V38.57H40.73Z"/></svg>%0A';
50
+
51
+ var guoyue_compact_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u56FD\u4E50 Guoyue"><style>.i,.a{fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="rotate(-22 24 25) translate(24 25) scale(1.1) translate(-24 -25)"><path class="i" d="M24 18.5C17.6 18.5 14.3 27.2 15.3 33.6C16.1 38.8 19.5 42 24 42C28.5 42 31.9 38.8 32.7 33.6C33.7 27.2 30.4 18.5 24 18.5Z"/><path class="i" d="M24 18.5V8.5"/><path class="i" d="M24 8.5l-2.4-5"/><path class="i" d="M21.2 6.3h-2.4M22.4 9h-2.4M26.4 6.6h2.2M26.4 9.4h2.2"/><path class="i" d="M22.2 12h3.6M22.2 14.6h3.6M22.2 17h3.6"/><path class="af" d="M19.8 35.4h8.4v2.2h-8.4z"/><path class="i" d="M22.6 18.5v16.9M25.4 18.5v16.9"/></g></svg>%0A';
52
+
53
+ var guoyue_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u56FD\u4E50 Guoyue"><style>.i,.a{fill:none;stroke-width:2.59;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1.48}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="translate(8.37 1.91) scale(0.676)"><g transform="rotate(-22 24 25) translate(24 25) scale(1.1) translate(-24 -25)"><path class="i" d="M24 18.5C17.6 18.5 14.3 27.2 15.3 33.6C16.1 38.8 19.5 42 24 42C28.5 42 31.9 38.8 32.7 33.6C33.7 27.2 30.4 18.5 24 18.5Z"/><path class="i" d="M24 18.5V8.5"/><path class="i" d="M24 8.5l-2.4-5"/><path class="i" d="M21.2 6.3h-2.4M22.4 9h-2.4M26.4 6.6h2.2M26.4 9.4h2.2"/><path class="i" d="M22.2 12h3.6M22.2 14.6h3.6M22.2 17h3.6"/><path class="af" d="M19.8 35.4h8.4v2.2h-8.4z"/><path class="i" d="M22.6 18.5v16.9M25.4 18.5v16.9"/></g></g><path class="l" d="M9.77 44.57C11.11 44.57 12.06 43.71 12.06 42.33V41.68H9.88V42.44H11.12C11.11 43.21 10.59 43.71 9.78 43.71C8.87 43.71 8.24 43.02 8.24 41.8C8.24 40.58 8.88 39.89 9.75 39.89C10.41 39.89 10.85 40.25 11.03 40.83H12.02C11.85 39.76 10.93 39.03 9.74 39.03C8.33 39.03 7.27 40.07 7.27 41.81C7.27 43.51 8.28 44.57 9.77 44.57ZM15.64 44.58C16.95 44.58 17.83 43.78 17.83 42.63V39.1H16.86V42.55C16.86 43.22 16.38 43.71 15.64 43.71C14.89 43.71 14.41 43.22 14.41 42.55V39.1H13.45V42.63C13.45 43.78 14.31 44.58 15.64 44.58ZM21.67 44.57C23.08 44.57 24.14 43.55 24.14 41.8C24.14 40.06 23.08 39.03 21.67 39.03C20.25 39.03 19.18 40.06 19.18 41.8C19.18 43.54 20.25 44.57 21.67 44.57ZM21.67 43.71C20.78 43.71 20.15 43.03 20.15 41.8C20.15 40.57 20.78 39.89 21.67 39.89C22.54 39.89 23.17 40.56 23.17 41.8C23.17 43.04 22.54 43.71 21.67 43.71ZM27.13 44.5H28.1V42.41L30.07 39.1H28.95L28 40.8C27.86 41.06 27.74 41.29 27.62 41.6C27.5 41.3 27.38 41.07 27.24 40.8L26.27 39.1H25.14L27.13 42.41ZM33.43 44.58C34.75 44.58 35.62 43.78 35.62 42.63V39.1H34.65V42.55C34.65 43.22 34.18 43.71 33.43 43.71C32.69 43.71 32.21 43.22 32.21 42.55V39.1H31.24V42.63C31.24 43.78 32.11 44.58 33.43 44.58ZM37.15 44.5H40.67V43.68H38.12V42.18H40.47V41.37H38.12V39.92H40.66V39.1H37.15Z"/></svg>%0A';
54
+
55
+ var hiphop_compact_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u563B\u54C8 Hip-hop"><style>.i,.a{fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><rect class="i" x="5" y="7" width="38" height="34" rx="4"/><circle class="i" cx="21" cy="24" r="12"/><circle class="t" cx="21" cy="24" r="8.2"/><circle class="af" cx="21" cy="24" r="3.6"/><path class="i" d="M37 11.5v15l-6.2 5.8"/><circle class="i" cx="37" cy="11.5" r="1.8"/><path class="i" d="M29.4 30.8l2.6 2.4"/></svg>%0A';
56
+
57
+ var hiphop_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u563B\u54C8 Hip-hop"><style>.i,.a{fill:none;stroke-width:2.46;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1.41}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="translate(6.95 -1.97) scale(0.711)"><rect class="i" x="5" y="7" width="38" height="34" rx="4"/><circle class="i" cx="21" cy="24" r="12"/><circle class="t" cx="21" cy="24" r="8.2"/><circle class="af" cx="21" cy="24" r="3.6"/><path class="i" d="M37 11.5v15l-6.2 5.8"/><circle class="i" cx="37" cy="11.5" r="1.8"/><path class="i" d="M29.4 30.8l2.6 2.4"/></g><path class="l" d="M6.66 44.5H7.66V42.06H10.27V44.5H11.27V38.9H10.27V41.22H7.66V38.9H6.66ZM13.86 38.9H12.86V44.5H13.86ZM15.45 44.5H16.46V42.61H17.53C18.83 42.61 19.52 41.83 19.52 40.75C19.52 39.69 18.84 38.9 17.55 38.9H15.45ZM16.46 41.78V39.74H17.39C18.16 39.74 18.49 40.16 18.49 40.75C18.49 41.35 18.16 41.78 17.4 41.78ZM23.36 41.76H20.85V42.57H23.36ZM24.92 44.5H25.93V42.06H28.53V44.5H29.54V38.9H28.53V41.22H25.93V38.9H24.92ZM33.52 44.58C34.99 44.58 36.09 43.51 36.09 41.7C36.09 39.89 34.99 38.82 33.52 38.82C32.05 38.82 30.95 39.89 30.95 41.7C30.95 43.51 32.05 44.58 33.52 44.58ZM33.52 43.68C32.61 43.68 31.96 42.98 31.96 41.7C31.96 40.42 32.61 39.72 33.52 39.72C34.43 39.72 35.08 40.42 35.08 41.7C35.08 42.98 34.43 43.68 33.52 43.68ZM37.5 44.5H38.51V42.61H39.58C40.87 42.61 41.57 41.83 41.57 40.75C41.57 39.69 40.89 38.9 39.6 38.9H37.5ZM38.51 41.78V39.74H39.44C40.21 39.74 40.54 40.16 40.54 40.75C40.54 41.35 40.21 41.78 39.45 41.78Z"/></svg>%0A';
58
+
59
+ var jazz_compact_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u7235\u58EB Jazz"><style>.i,.a{fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><path class="i" d="M19.5 11v20c0 7 4.3 11 10 11s9.5-4 9.5-9.5V27"/><path class="i" d="M24.5 11v19.5c0 4 2 6.5 5 6.5s4.5-2 4.5-4.5V27"/><path class="i" d="M31.5 27h10"/><path class="i" d="M19.5 11c0-4.6-3.8-6.3-7.5-4.6M24.5 11c0-6.3-6-8.6-11-6.2"/><path class="i" d="M12 6.4l-1.6-2.8 2.6-1.3"/><circle class="af" cx="22" cy="16" r="1.7"/><circle class="af" cx="22" cy="21.5" r="1.7"/><circle class="af" cx="22" cy="27" r="1.7"/></svg>%0A';
60
+
61
+ var jazz_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u7235\u58EB Jazz"><style>.i,.a{fill:none;stroke-width:1.81;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1.04}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="translate(-7.03 1.78) scale(0.965)"><path class="i" d="M19.5 11v20c0 7 4.3 11 10 11s9.5-4 9.5-9.5V27"/><path class="i" d="M24.5 11v19.5c0 4 2 6.5 5 6.5s4.5-2 4.5-4.5V27"/><path class="i" d="M31.5 27h10"/><path class="i" d="M19.5 11c0-4.6-3.8-6.3-7.5-4.6M24.5 11c0-6.3-6-8.6-11-6.2"/><path class="i" d="M12 6.4l-1.6-2.8 2.6-1.3"/><circle class="af" cx="22" cy="16" r="1.7"/><circle class="af" cx="22" cy="21.5" r="1.7"/><circle class="af" cx="22" cy="27" r="1.7"/></g><path class="l" d="M27.86 14.07C28.83 14.07 29.45 13.52 29.45 12.53V9.05H28.57V12.54C28.57 13.07 28.29 13.34 27.86 13.34C27.43 13.34 27.15 13.07 27.15 12.54V12.26H26.26V12.54C26.26 13.52 26.88 14.07 27.86 14.07ZM30.52 14H31.49L31.89 12.77H33.75L34.17 14H35.14L33.37 9.05H32.25ZM32.13 12.06 32.34 11.43C32.48 10.99 32.63 10.43 32.8 9.74C32.98 10.42 33.14 10.97 33.29 11.43L33.5 12.06ZM36.11 14H39.77V13.25H38.14C37.81 13.25 37.48 13.25 37.15 13.27C37.35 13.03 37.54 12.79 37.71 12.54L39.75 9.61V9.05H36.1V9.8H37.75C38.08 9.8 38.4 9.8 38.72 9.78C38.53 10.01 38.35 10.23 38.19 10.46L36.11 13.45ZM40.96 14H44.62V13.25H42.99C42.66 13.25 42.33 13.25 42 13.27C42.2 13.03 42.39 12.79 42.56 12.54L44.6 9.61V9.05H40.95V9.8H42.6C42.92 9.8 43.25 9.8 43.56 9.78C43.38 10.01 43.2 10.23 43.04 10.46L40.96 13.45Z"/></svg>%0A';
62
+
63
+ var pop_compact_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u6D41\u884C Pop"><style>.i,.a{fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><circle class="i" cx="29.5" cy="17.5" r="8"/><clipPath id="pg"><circle cx="29.5" cy="17.5" r="6.6"/></clipPath><g clip-path="url(%23pg)"><path class="a" d="M20 14l17 12M20 9.5l17 12M23 6l17 12M17 18.5l17 12"/></g><path class="i" d="M23.6 23L12.6 38.7c-.9 1.3.6 2.8 1.9 1.9L30.2 29.4"/><path class="i" d="M39.5 6.5v4M37.5 8.5h4"/></svg>%0A';
64
+
65
+ var pop_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u6D41\u884C Pop"><style>.i,.a{fill:none;stroke-width:1.82;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1.04}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="translate(-7.79 -1.75) scale(0.959)"><circle class="i" cx="29.5" cy="17.5" r="8"/><clipPath id="pg"><circle cx="29.5" cy="17.5" r="6.6"/></clipPath><g clip-path="url(%23pg)"><path class="a" d="M20 14l17 12M20 9.5l17 12M23 6l17 12M17 18.5l17 12"/></g><path class="i" d="M23.6 23L12.6 38.7c-.9 1.3.6 2.8 1.9 1.9L30.2 29.4"/><path class="i" d="M39.5 6.5v4M37.5 8.5h4"/></g><path class="l" d="M25.21 43.5H26.46V41.13H27.81C29.43 41.13 30.3 40.15 30.3 38.81C30.3 37.47 29.44 36.49 27.83 36.49H25.21ZM26.46 40.09V37.54H27.63C28.59 37.54 29.01 38.06 29.01 38.81C29.01 39.56 28.59 40.09 27.64 40.09ZM35 43.59C36.84 43.59 38.22 42.26 38.22 40C38.22 37.73 36.84 36.39 35 36.39C33.16 36.39 31.78 37.73 31.78 40C31.78 42.26 33.16 43.59 35 43.59ZM35 42.47C33.86 42.47 33.04 41.59 33.04 40C33.04 38.39 33.86 37.52 35 37.52C36.14 37.52 36.95 38.39 36.95 40C36.95 41.6 36.14 42.47 35 42.47ZM39.99 43.5H41.25V41.13H42.59C44.21 41.13 45.08 40.15 45.08 38.81C45.08 37.47 44.22 36.49 42.61 36.49H39.99ZM41.25 40.09V37.54H42.42C43.38 37.54 43.8 38.06 43.8 38.81C43.8 39.56 43.38 40.09 42.43 40.09Z"/></svg>%0A';
66
+
67
+ var rock_compact_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u6447\u6EDA Rock"><style>.i,.a{fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="rotate(38 24 24)"><path class="i" d="M22 30c-.4-3.2-2-5.6-4-4.9-1.7.6-1.1 3.2-1.6 4.9-3.3.2-5.2 3.1-4.4 6.6.8 3.6 4.4 6 9.7 5.6 1.2-.1 2-.1 3.2.1 5.6.6 9.4-1.6 10-5.3.4-2.6-1-4.6-3.5-4.9-.4-2.6.4-5.3-1.4-6.2-2-1-3.6 1.6-4 4.1Z"/><path class="i" d="M23 30V6.5M25.5 30V6.5"/><path class="i" d="M22 6.5l.6-3.5h3.6l.4 3.5Z"/><path class="af" d="M21.2 33.4h5.6v1.8h-5.6zM21.2 37h5.6v1.8h-5.6z"/></g></svg>%0A';
68
+
69
+ var rock_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" role="img" aria-label="\u6447\u6EDA Rock"><style>.i,.a{fill:none;stroke-width:2.12;stroke-linecap:round;stroke-linejoin:round}.i{stroke:%231c1e23}.a{stroke:%233462e6}.af{fill:%233462e6}.f{fill:%231c1e23}.bg{fill:%23fff}.t{fill:none;stroke:%231c1e23;stroke-opacity:.32;stroke-width:1.21}.l{fill:%231c1e23}@media (prefers-color-scheme:dark){.i,.t{stroke:%23e9ebef}.f,.l{fill:%23e9ebef}.a{stroke:%2382a4ff}.af{fill:%2382a4ff}.bg{fill:%2316191f}}</style><g transform="translate(8.45 7.00) scale(0.824)"><g transform="rotate(38 24 24)"><path class="i" d="M22 30c-.4-3.2-2-5.6-4-4.9-1.7.6-1.1 3.2-1.6 4.9-3.3.2-5.2 3.1-4.4 6.6.8 3.6 4.4 6 9.7 5.6 1.2-.1 2-.1 3.2.1 5.6.6 9.4-1.6 10-5.3.4-2.6-1-4.6-3.5-4.9-.4-2.6.4-5.3-1.4-6.2-2-1-3.6 1.6-4 4.1Z"/><path class="i" d="M23 30V6.5M25.5 30V6.5"/><path class="i" d="M22 6.5l.6-3.5h3.6l.4 3.5Z"/><path class="af" d="M21.2 33.4h5.6v1.8h-5.6zM21.2 37h5.6v1.8h-5.6z"/></g></g><path class="l" d="M4.01 12.5H4.91V10.66H5.84L6.83 12.5H7.84L6.75 10.5C7.34 10.27 7.65 9.77 7.65 9.08C7.65 8.13 7.04 7.48 5.88 7.48H4.01ZM4.91 9.91V8.23H5.75C6.43 8.23 6.73 8.55 6.73 9.08C6.73 9.62 6.43 9.91 5.75 9.91ZM11.08 12.57C12.39 12.57 13.38 11.61 13.38 9.99C13.38 8.37 12.39 7.41 11.08 7.41C9.76 7.41 8.77 8.37 8.77 9.99C8.77 11.61 9.76 12.57 11.08 12.57ZM11.08 11.76C10.25 11.76 9.67 11.13 9.67 9.99C9.67 8.84 10.25 8.21 11.08 8.21C11.89 8.21 12.47 8.84 12.47 9.99C12.47 11.14 11.89 11.76 11.08 11.76ZM16.79 12.57C17.98 12.57 18.77 11.79 18.91 10.83H18C17.88 11.42 17.4 11.76 16.8 11.76C15.98 11.76 15.39 11.14 15.39 9.99C15.39 8.85 15.98 8.21 16.8 8.21C17.4 8.21 17.89 8.55 18 9.15H18.91C18.75 8.05 17.89 7.41 16.79 7.41C15.48 7.41 14.49 8.37 14.49 9.99C14.49 11.61 15.47 12.57 16.79 12.57ZM20.15 12.5H21.05V10.99L21.73 10.25L23.26 12.5H24.32L22.36 9.65L24.29 7.48H23.17L21.85 8.98C21.52 9.36 21.27 9.68 21.04 10.04L21.05 8.97V7.48H20.15Z"/></svg>%0A';
70
+
71
+ var drum_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M2.5 7.6c0-1 2.5-1.8 5.5-1.8s5.5.8 5.5 1.8v4.6c0 1.1-2.5 1.9-5.5 1.9s-5.5-.8-5.5-1.9Z"/><path d="M2.8 2 6.8 6.2M13.2 2 9.2 6.2" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>%0A';
72
+
73
+ var guitar_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><g transform="rotate(40 8 8)"><path d="M8 7.2c-1.5 0-2.4.9-2.2 2.1-1.2.4-1.8 1.4-1.6 2.6.3 1.6 1.8 2.6 3.8 2.6s3.5-1 3.8-2.6c.2-1.2-.4-2.2-1.6-2.6.2-1.2-.7-2.1-2.2-2.1Z"/><rect x="7.3" y="2.4" width="1.4" height="6" rx=".4"/><path d="M6.8.8h2.4l-.3 2.2H7.1Z"/></g></svg>%0A';
74
+
75
+ var keys_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M2.5 4h11A1.5 1.5 0 0 1 15 5.5v5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 10.5v-5A1.5 1.5 0 0 1 2.5 4Zm-.3 1.2v5.6h2.6V5.2Zm3 0v5.6h2.6V5.2Zm3 0v5.6h2.6V5.2Zm3 0v5.6h2.6V5.2Z"/><path d="M4.2 5.2h1.6v3.2H4.2zM7.2 5.2h1.6v3.2H7.2zM10.2 5.2h1.6v3.2h-1.6z"/></svg>%0A';
76
+
77
+ var sax_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M6.6 2.4v7.8c0 2.6 1.6 4.2 3.7 4.2 1.9 0 3.2-1.4 3.2-3.4V9.6" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round"/><path d="M11.2 8.6h4l-.6 1.7h-2.8Z"/><path d="M6.6 2.4c0-1-1.3-1.4-2.7-.8" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>%0A';
78
+
79
+ var trumpet_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M1.4 8.8h8.6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M9.4 7.4 14.6 4.4v8.8l-5.2-3Z"/><path d="M3.8 9.2v2.2c0 .6.4 1 1 1h3.2c.6 0 1-.4 1-1V9.2" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M4.6 5.4v2.6M6.6 5.4v2.6M8.6 5.4v2.6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>%0A';
80
+
81
+ var violin_default = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><g transform="rotate(-28 8 8)"><path d="M8 5.2c-2.3 0-2.9 1.4-2.3 2.6.4.8.3 1.2-.4 1.9-1.3 1.3-.8 4.6 2.7 4.6s4-3.3 2.7-4.6c-.7-.7-.8-1.1-.4-1.9.6-1.2 0-2.6-2.3-2.6Z"/><rect x="7.3" y="1.8" width="1.4" height="4" rx=".5"/><circle cx="8" cy="1.7" r="1.1"/><path d="M12.2 3.6v8.8" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></g></svg>%0A';
82
+
83
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
84
+ function ErrorNote({ children, retry }) {
85
+ if (!children) return null;
86
+ const note = /* @__PURE__ */ jsx2("div", { className: "band-plugin-react-error", children });
87
+ if (!retry) return note;
88
+ return /* @__PURE__ */ jsxs("div", { className: "band-plugin-react-retry", role: "alert", children: [
89
+ note,
90
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "btn sm", onClick: retry, children: "\u91CD\u8BD5" })
91
+ ] });
92
+ }
93
+ function InfoNote({ children }) {
94
+ if (!children) return null;
95
+ return /* @__PURE__ */ jsx2("div", { className: "band-plugin-react-info", children });
96
+ }
97
+ function PaneHeader({ title, children }) {
98
+ return /* @__PURE__ */ jsxs("div", { className: "band-plugin-react-pane-head", children: [
99
+ /* @__PURE__ */ jsx2("h2", { className: "band-plugin-react-pane-title", children: title }),
100
+ children
101
+ ] });
102
+ }
103
+ function avatarTone(id, order) {
104
+ const i = order?.indexOf(id) ?? -1;
105
+ if (i >= 0) return i % 5 + 1;
106
+ let h = 2166136261;
107
+ for (const c of id) {
108
+ h ^= c.codePointAt(0) ?? 0;
109
+ h = Math.imul(h, 16777619);
110
+ }
111
+ h ^= h >>> 16;
112
+ h = Math.imul(h, 2246822507);
113
+ h ^= h >>> 13;
114
+ return (h >>> 0) % 5 + 1;
115
+ }
116
+ function memberOrder(members) {
117
+ return members.filter((m) => m.actor.kind === "human").map((m) => m.actor.id);
118
+ }
119
+ function avatarInitial(name) {
120
+ const first = Array.from(name.trim())[0];
121
+ if (!first) return "?";
122
+ const up = first.toUpperCase();
123
+ return Array.from(up).length === 1 ? up : first;
124
+ }
125
+ function Avatar({
126
+ id,
127
+ name,
128
+ agent = false,
129
+ instrument,
130
+ size = "sm",
131
+ decorative = false,
132
+ order
133
+ }) {
134
+ const cls = `av${size === "md" ? "" : ` ${size}`}${agent ? " bot" : ""}`;
135
+ const a11y = decorative ? { "aria-hidden": true } : { role: "img", "aria-label": name };
136
+ return /* @__PURE__ */ jsx2(
137
+ "span",
138
+ {
139
+ className: cls,
140
+ title: name,
141
+ style: agent ? void 0 : { background: `var(--av${avatarTone(id, order)})` },
142
+ ...a11y,
143
+ children: agent && instrument ? /* @__PURE__ */ jsx2(
144
+ "span",
145
+ {
146
+ className: "band-plugin-react-instrument",
147
+ "aria-hidden": "true",
148
+ style: { ["--band-instrument"]: cssUrl(INSTRUMENT_SRC[instrument]) }
149
+ }
150
+ ) : agent ? /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("ellipse", { cx: "8", cy: "8.4", rx: "5.6", ry: "3.7", transform: "rotate(-20 8 8.4)" }) }) : avatarInitial(name)
151
+ }
152
+ );
153
+ }
154
+ function Glyph({
155
+ kind,
156
+ bg = false
157
+ }) {
158
+ return /* @__PURE__ */ jsx2("span", { className: `glyph ${kind}${bg ? " bgwork" : ""}`.trim(), "aria-hidden": "true" });
159
+ }
160
+ function agentInstrument(id, members) {
161
+ const peers = members.filter((m) => m.actor.kind === "agent").map((m) => m.actor.id);
162
+ return instrumentOf(id, peers);
163
+ }
164
+ function AgentAvatar({
165
+ id,
166
+ members,
167
+ size = "xs",
168
+ decorative = false
169
+ }) {
170
+ const list = members ?? [];
171
+ const name = list.find((m) => m.actor.id === id)?.displayName ?? agentDisplayName(id);
172
+ const instrument = agentInstrument(id, list);
173
+ return /* @__PURE__ */ jsx2(
174
+ Avatar,
175
+ {
176
+ id,
177
+ name,
178
+ agent: true,
179
+ size,
180
+ decorative,
181
+ ...instrument ? { instrument } : {}
182
+ }
183
+ );
184
+ }
185
+ var INSTRUMENTS = ["sax", "keys", "guitar", "drum", "trumpet", "violin"];
186
+ var INSTRUMENT_SRC = {
187
+ sax: sax_default,
188
+ keys: keys_default,
189
+ guitar: guitar_default,
190
+ drum: drum_default,
191
+ trumpet: trumpet_default,
192
+ violin: violin_default
193
+ };
194
+ function cssUrl(src) {
195
+ return `url("${src.replace(/"/g, "'")}")`;
196
+ }
197
+ function fnv1a(s) {
198
+ let h = 2166136261;
199
+ for (const c of s) {
200
+ h ^= c.codePointAt(0) ?? 0;
201
+ h = Math.imul(h, 16777619);
202
+ }
203
+ return h >>> 0;
204
+ }
205
+ function instrumentOf(name, peers) {
206
+ const isRondo = (n) => n.toLowerCase() === "rondo";
207
+ if (isRondo(name)) return void 0;
208
+ const all = [...new Set([...peers, name].filter((n) => !isRondo(n)))].sort();
209
+ const taken = /* @__PURE__ */ new Set();
210
+ for (const n of all) {
211
+ const start = fnv1a(n) % INSTRUMENTS.length;
212
+ let pick = INSTRUMENTS[start];
213
+ for (let k = 0; k < INSTRUMENTS.length; k++) {
214
+ const cand = INSTRUMENTS[(start + k) % INSTRUMENTS.length];
215
+ if (!taken.has(cand)) {
216
+ pick = cand;
217
+ break;
218
+ }
219
+ }
220
+ if (taken.size < INSTRUMENTS.length) taken.add(pick);
221
+ if (n === name) return pick;
222
+ }
223
+ return void 0;
224
+ }
225
+ var GENRE_FULL_SRC = {
226
+ classical: classical_default,
227
+ jazz: jazz_default,
228
+ pop: pop_default,
229
+ rock: rock_default,
230
+ electronic: electronic_default,
231
+ folk: folk_default,
232
+ hiphop: hiphop_default,
233
+ guoyue: guoyue_default
234
+ };
235
+ var GENRE_COMPACT_SRC = {
236
+ classical: classical_compact_default,
237
+ jazz: jazz_compact_default,
238
+ pop: pop_compact_default,
239
+ rock: rock_compact_default,
240
+ electronic: electronic_compact_default,
241
+ folk: folk_compact_default,
242
+ hiphop: hiphop_compact_default,
243
+ guoyue: guoyue_compact_default
244
+ };
245
+ function WorkshopIcon({
246
+ icon,
247
+ size = 20,
248
+ tile = false
249
+ }) {
250
+ return drawWorkshopIcon(GENRE_COMPACT_SRC, icon, size, tile);
251
+ }
252
+ function WorkshopEmblem({
253
+ icon,
254
+ size = 48
255
+ }) {
256
+ return drawWorkshopIcon(size >= 48 ? GENRE_FULL_SRC : GENRE_COMPACT_SRC, icon, size, true);
257
+ }
258
+ function drawWorkshopIcon(srcs, icon, size, tile) {
259
+ const genre = icon?.startsWith("genre:") ? icon.slice("genre:".length) : void 0;
260
+ const known = genre && WORKSHOP_GENRES.includes(genre);
261
+ const src = known ? srcs[genre] : void 0;
262
+ const inner = src ? /* @__PURE__ */ jsx2("img", { className: "band-plugin-react-wsicon", src, width: size, height: size, alt: "" }) : /* @__PURE__ */ jsx2(BandMark, { className: "band-plugin-react-wsicon", size });
263
+ if (!tile) return inner;
264
+ return /* @__PURE__ */ jsx2(
265
+ "span",
266
+ {
267
+ className: `band-plugin-react-wstile${size >= 28 ? " is-large" : ""}`,
268
+ style: { ["--band-wstile"]: `${size}px` },
269
+ "aria-hidden": "true",
270
+ children: inner
271
+ }
272
+ );
273
+ }
274
+ function BandMark({
275
+ size = 20,
276
+ className
277
+ }) {
278
+ return /* @__PURE__ */ jsxs(
279
+ "svg",
280
+ {
281
+ className,
282
+ viewBox: "0 0 24 24",
283
+ width: size,
284
+ height: size,
285
+ "aria-hidden": "true",
286
+ focusable: "false",
287
+ children: [
288
+ /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.75", children: [
289
+ /* @__PURE__ */ jsx2("path", { d: "M7.67 18.81V6.95" }),
290
+ /* @__PURE__ */ jsx2("path", { d: "M14.67 15.71V4.65" }),
291
+ /* @__PURE__ */ jsx2("path", { d: "M21.67 12.61V2.35" })
292
+ ] }),
293
+ /* @__PURE__ */ jsx2("path", { fill: "currentColor", d: "M6.8 5.69L22.55 0.51V3.61L6.8 8.79Z" }),
294
+ /* @__PURE__ */ jsx2(
295
+ "ellipse",
296
+ {
297
+ fill: "currentColor",
298
+ cx: "5.4",
299
+ cy: "19.4",
300
+ rx: "3.25",
301
+ ry: "2.2",
302
+ transform: "rotate(-20 5.4 19.4)"
303
+ }
304
+ ),
305
+ /* @__PURE__ */ jsx2(
306
+ "ellipse",
307
+ {
308
+ fill: "var(--accent)",
309
+ cx: "12.4",
310
+ cy: "16.3",
311
+ rx: "3.25",
312
+ ry: "2.2",
313
+ transform: "rotate(-20 12.4 16.3)"
314
+ }
315
+ ),
316
+ /* @__PURE__ */ jsx2(
317
+ "ellipse",
318
+ {
319
+ fill: "currentColor",
320
+ cx: "19.4",
321
+ cy: "13.2",
322
+ rx: "3.25",
323
+ ry: "2.2",
324
+ transform: "rotate(-20 19.4 13.2)"
325
+ }
326
+ )
327
+ ]
328
+ }
329
+ );
330
+ }
331
+ function LogoLockup() {
332
+ return /* @__PURE__ */ jsxs("svg", { className: "logo lockup", viewBox: "0 0 111 28", role: "img", "aria-label": "Band", children: [
333
+ /* @__PURE__ */ jsx2("g", { className: "staff", children: [5, 9.5, 14, 18.5, 23].map((y) => /* @__PURE__ */ jsx2("line", { x1: "1", y1: y, x2: "39", y2: y }, y)) }),
334
+ /* @__PURE__ */ jsx2("path", { className: "st", d: "M12.36 20.12V7.65" }),
335
+ /* @__PURE__ */ jsx2("path", { className: "st", d: "M21.86 15.62V5.35" }),
336
+ /* @__PURE__ */ jsx2("path", { className: "st", d: "M31.36 11.12V3.05" }),
337
+ /* @__PURE__ */ jsx2("path", { d: "M11.54 6.4L32.19 1.4V4.3L11.54 9.3Z" }),
338
+ /* @__PURE__ */ jsx2("ellipse", { cx: "10", cy: "20.75", rx: "3.3", ry: "2.15", transform: "rotate(-20 10 20.75)" }),
339
+ /* @__PURE__ */ jsx2(
340
+ "ellipse",
341
+ {
342
+ className: "ag",
343
+ cx: "19.5",
344
+ cy: "16.25",
345
+ rx: "3.3",
346
+ ry: "2.15",
347
+ transform: "rotate(-20 19.5 16.25)"
348
+ }
349
+ ),
350
+ /* @__PURE__ */ jsx2("ellipse", { cx: "29", cy: "11.75", rx: "3.3", ry: "2.15", transform: "rotate(-20 29 11.75)" }),
351
+ /* @__PURE__ */ jsx2("text", { className: "wm", x: "46", y: "23", children: "Band" })
352
+ ] });
353
+ }
354
+
355
+ import {
356
+ useEffect,
357
+ useId,
358
+ useRef
359
+ } from "react";
360
+ import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
361
+ function settingsLinkHandler(go, target) {
362
+ return (e) => {
363
+ if (!go) return;
364
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
365
+ e.preventDefault();
366
+ go(target);
367
+ };
368
+ }
369
+ function SettingsLayout({
370
+ navLabel,
371
+ title,
372
+ obj,
373
+ crumb,
374
+ groups,
375
+ current,
376
+ view = "page",
377
+ back,
378
+ backMobile,
379
+ onNavigate,
380
+ mainRef,
381
+ children
382
+ }) {
383
+ return /* @__PURE__ */ jsxs2("div", { className: "band-sf", "data-view": view, children: [
384
+ /* @__PURE__ */ jsxs2("nav", { className: "band-sf-nav", "aria-label": navLabel, children: [
385
+ /* @__PURE__ */ jsxs2("div", { className: "band-sf-head", children: [
386
+ crumb ? /* @__PURE__ */ jsx3("div", { className: "band-sf-crumb", children: crumb }) : null,
387
+ /* @__PURE__ */ jsx3("span", { className: "band-sf-title", children: title }),
388
+ !crumb && obj ? /* @__PURE__ */ jsx3("span", { className: "band-sf-obj", children: obj }) : null
389
+ ] }),
390
+ groups.map((g) => /* @__PURE__ */ jsxs2("div", { className: "band-sf-grp", children: [
391
+ /* @__PURE__ */ jsx3("span", { children: g.group }),
392
+ g.sections.map((s) => /* @__PURE__ */ jsxs2(
393
+ "a",
394
+ {
395
+ href: s.href,
396
+ "aria-current": s.slug === current ? "page" : void 0,
397
+ onClick: settingsLinkHandler(onNavigate, s),
398
+ children: [
399
+ s.title,
400
+ s.glyph ?? null,
401
+ /* @__PURE__ */ jsx3("span", { className: "band-sf-chev", "aria-hidden": "true", children: "\u203A" })
402
+ ]
403
+ },
404
+ s.slug
405
+ ))
406
+ ] }, g.group))
407
+ ] }),
408
+ /* @__PURE__ */ jsx3("div", { className: "band-sf-scroll", children: /* @__PURE__ */ jsxs2("main", { className: "band-sf-main", "data-view": view, ref: mainRef, children: [
409
+ view === "page" && back ? /* @__PURE__ */ jsx3(SettingsBack, { target: back, onNavigate }) : null,
410
+ view === "page" && backMobile ? /* @__PURE__ */ jsx3(SettingsBack, { target: backMobile, onNavigate, mobileOnly: true }) : null,
411
+ children
412
+ ] }) })
413
+ ] });
414
+ }
415
+ function SettingsBack({
416
+ target,
417
+ onNavigate,
418
+ mobileOnly = false
419
+ }) {
420
+ return /* @__PURE__ */ jsxs2(
421
+ "a",
422
+ {
423
+ className: mobileOnly ? "band-sf-back band-sf-back-m" : "band-sf-back",
424
+ href: target.href,
425
+ onClick: settingsLinkHandler(onNavigate, target),
426
+ children: [
427
+ /* @__PURE__ */ jsx3("span", { "aria-hidden": "true", children: "\u2039" }),
428
+ " ",
429
+ target.label
430
+ ]
431
+ }
432
+ );
433
+ }
434
+ function SettingsHead({
435
+ title,
436
+ desc,
437
+ action
438
+ }) {
439
+ return /* @__PURE__ */ jsxs2("div", { className: "band-sf-h", children: [
440
+ /* @__PURE__ */ jsxs2("div", { children: [
441
+ /* @__PURE__ */ jsx3("h1", { children: title }),
442
+ desc ? /* @__PURE__ */ jsx3("p", { children: desc }) : null
443
+ ] }),
444
+ action ? /* @__PURE__ */ jsx3("div", { className: "band-sf-h-a", children: action }) : null
445
+ ] });
446
+ }
447
+ function SettingsRows({ label, children }) {
448
+ return /* @__PURE__ */ jsx3("ul", { className: "band-sf-rows", "aria-label": label, children });
449
+ }
450
+ var warnedExtra = false;
451
+ function warnExtraWithOpen() {
452
+ const env = globalThis.process?.env?.NODE_ENV;
453
+ if (warnedExtra || env === void 0 || env === "production") return;
454
+ warnedExtra = true;
455
+ console.warn("SettingsRow\uFF1Aextra \u4E0E onOpen \u4E0D\u8981\u540C\u65F6\u7ED9\uFF0C\u6574\u884C\u94FE\u63A5\u4F1A\u76D6\u4F4F\u5C55\u5F00\u7684\u90A3\u4E00\u5757");
456
+ }
457
+ function SettingsRow({
458
+ title,
459
+ tags,
460
+ meta,
461
+ actions,
462
+ leading,
463
+ href,
464
+ onOpen,
465
+ mono = false,
466
+ isNew = false,
467
+ extra
468
+ }) {
469
+ if (extra && onOpen) warnExtraWithOpen();
470
+ const name = /* @__PURE__ */ jsx3("b", { className: mono ? "band-sf-mono" : void 0, children: title });
471
+ const cls = ["band-sf-row", leading ? "has-lead" : "", isNew ? "is-new" : ""].filter(Boolean).join(" ");
472
+ return /* @__PURE__ */ jsxs2("li", { className: cls, children: [
473
+ leading ? /* @__PURE__ */ jsx3("div", { className: "band-sf-row-l", children: leading }) : null,
474
+ /* @__PURE__ */ jsxs2("div", { className: "band-sf-row-t", children: [
475
+ onOpen ? /* @__PURE__ */ jsx3(
476
+ "a",
477
+ {
478
+ className: "band-sf-row-link",
479
+ href: href ?? "#",
480
+ onClick: (e) => {
481
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
482
+ e.preventDefault();
483
+ onOpen();
484
+ },
485
+ children: name
486
+ }
487
+ ) : name,
488
+ tags
489
+ ] }),
490
+ /* @__PURE__ */ jsxs2("div", { className: "band-sf-row-a", children: [
491
+ actions,
492
+ onOpen ? /* @__PURE__ */ jsx3("span", { className: "band-sf-chev", "aria-hidden": "true", children: "\u203A" }) : null
493
+ ] }),
494
+ meta && meta.length > 0 ? /* @__PURE__ */ jsx3("div", { className: "band-sf-row-m", children: meta.map((m, i) => (
495
+ /* @__PURE__ */ jsx3("span", { children: m }, i)
496
+ )) }) : null,
497
+ extra ? /* @__PURE__ */ jsx3("div", { className: "band-sf-row-x", children: extra }) : null
498
+ ] });
499
+ }
500
+ function SettingsFacts({ items }) {
501
+ return /* @__PURE__ */ jsx3("dl", { className: "band-sf-facts", children: items.map((f) => /* @__PURE__ */ jsxs2("div", { className: "band-sf-fact", children: [
502
+ /* @__PURE__ */ jsx3("dt", { children: f.key }),
503
+ /* @__PURE__ */ jsx3("dd", { children: f.value })
504
+ ] }, f.key)) });
505
+ }
506
+ function SettingsSection({
507
+ title,
508
+ desc,
509
+ children
510
+ }) {
511
+ return /* @__PURE__ */ jsxs2("section", { className: "band-sf-sec", "aria-label": title, children: [
512
+ /* @__PURE__ */ jsx3("h2", { children: title }),
513
+ desc ? /* @__PURE__ */ jsx3("p", { children: desc }) : null,
514
+ children
515
+ ] });
516
+ }
517
+ function SettingsSingle({ label, children }) {
518
+ return /* @__PURE__ */ jsx3("section", { className: "band-sf-one", "aria-label": label, children });
519
+ }
520
+ function SettingsChoices({ children }) {
521
+ return /* @__PURE__ */ jsx3("div", { className: "band-sf-choices", children });
522
+ }
523
+ function SettingsPicks({
524
+ label,
525
+ value,
526
+ onChange,
527
+ options,
528
+ disabled = false
529
+ }) {
530
+ const id = useId();
531
+ return /* @__PURE__ */ jsxs2("div", { className: "band-sf-fld", children: [
532
+ /* @__PURE__ */ jsx3("span", { className: "band-sf-blks-l", id: `${id}-l`, children: label }),
533
+ /* @__PURE__ */ jsx3(
534
+ "div",
535
+ {
536
+ className: `band-sf-blks band-sf-blks-${options.length === 2 ? 2 : 3}`,
537
+ role: "radiogroup",
538
+ "aria-labelledby": `${id}-l`,
539
+ children: options.map((o) => /* @__PURE__ */ jsxs2("label", { className: o.value === value ? "band-sf-blk is-on" : "band-sf-blk", children: [
540
+ /* @__PURE__ */ jsx3(
541
+ "input",
542
+ {
543
+ type: "radio",
544
+ className: "sr-only",
545
+ name: id,
546
+ value: o.value,
547
+ checked: o.value === value,
548
+ disabled,
549
+ onChange: () => onChange(o.value)
550
+ }
551
+ ),
552
+ /* @__PURE__ */ jsx3("b", { children: o.label }),
553
+ o.line ? /* @__PURE__ */ jsx3("small", { children: o.line }) : null
554
+ ] }, o.value))
555
+ }
556
+ )
557
+ ] });
558
+ }
559
+ function SettingsDanger({ children }) {
560
+ return /* @__PURE__ */ jsxs2("section", { className: "band-sf-dz", "aria-label": "\u5371\u9669\u64CD\u4F5C", children: [
561
+ /* @__PURE__ */ jsx3("h2", { children: "\u5371\u9669\u64CD\u4F5C" }),
562
+ children
563
+ ] });
564
+ }
565
+ function SettingsDangerRow({
566
+ title,
567
+ note,
568
+ action
569
+ }) {
570
+ return /* @__PURE__ */ jsxs2("div", { className: "band-sf-dz-r", children: [
571
+ /* @__PURE__ */ jsxs2("div", { children: [
572
+ /* @__PURE__ */ jsx3("b", { children: title }),
573
+ /* @__PURE__ */ jsx3("span", { children: note })
574
+ ] }),
575
+ action
576
+ ] });
577
+ }
578
+ function SettingsLoading({ text }) {
579
+ return /* @__PURE__ */ jsx3("output", { className: "band-sf-load", children: /* @__PURE__ */ jsxs2("span", { className: "tuning", children: [
580
+ /* @__PURE__ */ jsxs2("svg", { viewBox: "0 0 80 55", "aria-hidden": "true", children: [
581
+ /* @__PURE__ */ jsx3("line", { x1: "0", y1: "12", x2: "80", y2: "12" }),
582
+ /* @__PURE__ */ jsx3("line", { x1: "0", y1: "22", x2: "80", y2: "22" }),
583
+ /* @__PURE__ */ jsx3("line", { x1: "0", y1: "32", x2: "80", y2: "32" }),
584
+ /* @__PURE__ */ jsx3("line", { x1: "0", y1: "42", x2: "80", y2: "42" }),
585
+ /* @__PURE__ */ jsx3("line", { x1: "0", y1: "52", x2: "80", y2: "52" }),
586
+ /* @__PURE__ */ jsx3("circle", { cx: "20", cy: "37", r: "4.6", fill: "var(--ink)" }),
587
+ /* @__PURE__ */ jsx3("circle", { cx: "40", cy: "27", r: "4.6", fill: "var(--accent)" }),
588
+ /* @__PURE__ */ jsx3("circle", { cx: "60", cy: "17", r: "4.6", fill: "var(--ink)" })
589
+ ] }),
590
+ /* @__PURE__ */ jsx3("span", { children: text })
591
+ ] }) });
592
+ }
593
+ function SettingsEmpty({ children, action }) {
594
+ return /* @__PURE__ */ jsxs2("div", { className: "band-sf-empty rest", children: [
595
+ /* @__PURE__ */ jsx3("i", {}),
596
+ /* @__PURE__ */ jsx3("p", { children }),
597
+ action ?? null
598
+ ] });
599
+ }
600
+ function SettingsReadError({ children, retry }) {
601
+ return /* @__PURE__ */ jsx3("div", { className: "band-sf-error", children: /* @__PURE__ */ jsx3(ErrorNote, { retry, children }) });
602
+ }
603
+ function SettingsNoAccess({
604
+ title,
605
+ children,
606
+ action
607
+ }) {
608
+ const id = useId();
609
+ return /* @__PURE__ */ jsxs2("section", { className: "band-settings-no-access", "aria-labelledby": id, children: [
610
+ /* @__PURE__ */ jsx3("h2", { id, children: title }),
611
+ /* @__PURE__ */ jsx3("p", { children }),
612
+ action ? /* @__PURE__ */ jsx3("button", { type: "button", className: "btn", onClick: action.onClick, children: action.label }) : null
613
+ ] });
614
+ }
615
+ function SettingsNotice({ text }) {
616
+ return /* @__PURE__ */ jsx3("output", { className: "sr-only", "aria-live": "polite", children: text });
617
+ }
618
+ function SettingsSaved({
619
+ text = "\u5DF2\u4FDD\u5B58"
620
+ }) {
621
+ return /* @__PURE__ */ jsx3("output", { className: "band-sf-ok", children: text });
622
+ }
623
+ function SettingsDialog({
624
+ title,
625
+ children,
626
+ actions,
627
+ onClose
628
+ }) {
629
+ const ref = useRef(null);
630
+ const titleId = useId();
631
+ useEffect(() => {
632
+ const el = ref.current;
633
+ const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
634
+ if (el && !el.open) {
635
+ if (typeof el.showModal === "function") el.showModal();
636
+ else el.setAttribute("open", "");
637
+ }
638
+ return () => {
639
+ if (opener?.isConnected) opener.focus();
640
+ };
641
+ }, []);
642
+ return /* @__PURE__ */ jsxs2(
643
+ "dialog",
644
+ {
645
+ ref,
646
+ className: "band-sf-dialog",
647
+ "aria-labelledby": titleId,
648
+ onCancel: (e) => {
649
+ e.preventDefault();
650
+ onClose();
651
+ },
652
+ children: [
653
+ /* @__PURE__ */ jsx3("h2", { id: titleId, children: title }),
654
+ children,
655
+ /* @__PURE__ */ jsx3("div", { className: "band-sf-acts band-sf-acts-end", children: actions })
656
+ ]
657
+ }
658
+ );
659
+ }
660
+ function SettingsForm({
661
+ label,
662
+ onSubmit,
663
+ children
664
+ }) {
665
+ return /* @__PURE__ */ jsx3(
666
+ "form",
667
+ {
668
+ className: "band-sf-form",
669
+ "aria-label": label,
670
+ onSubmit: (e) => {
671
+ e.preventDefault();
672
+ onSubmit?.();
673
+ },
674
+ children
675
+ }
676
+ );
677
+ }
678
+ function SettingsField({
679
+ label,
680
+ required = false,
681
+ optional = false,
682
+ hint,
683
+ error,
684
+ count,
685
+ over = false,
686
+ children
687
+ }) {
688
+ const id = useId();
689
+ const noteId = `${id}-note`;
690
+ const note = error ?? hint;
691
+ const props = { id };
692
+ if (note) props["aria-describedby"] = `${noteId}-t`;
693
+ if (error) props["aria-invalid"] = true;
694
+ return /* @__PURE__ */ jsxs2("div", { className: "band-sf-fld", children: [
695
+ /* @__PURE__ */ jsxs2("label", { htmlFor: id, children: [
696
+ label,
697
+ required ? /* @__PURE__ */ jsxs2(Fragment, { children: [
698
+ " ",
699
+ /* @__PURE__ */ jsx3("span", { className: "band-sf-req", children: "\u5FC5\u586B" })
700
+ ] }) : optional ? /* @__PURE__ */ jsxs2(Fragment, { children: [
701
+ " ",
702
+ /* @__PURE__ */ jsx3("span", { className: "band-sf-optional", children: "\u9009\u586B" })
703
+ ] }) : null
704
+ ] }),
705
+ children(props),
706
+ note || count ? (
707
+ /* @__PURE__ */ jsxs2(
708
+ "p",
709
+ {
710
+ className: error ? "field-note err" : "field-note",
711
+ id: noteId,
712
+ role: error ? "alert" : void 0,
713
+ children: [
714
+ note ? /* @__PURE__ */ jsx3("span", { id: `${noteId}-t`, children: note }) : null,
715
+ count ? /* @__PURE__ */ jsx3("span", { className: over ? "field-count over" : "field-count", children: count }) : null
716
+ ]
717
+ }
718
+ )
719
+ ) : null
720
+ ] });
721
+ }
722
+ function SettingsActions({
723
+ children,
724
+ end = false
725
+ }) {
726
+ return /* @__PURE__ */ jsx3("div", { className: end ? "band-sf-acts band-sf-acts-end" : "band-sf-acts", children });
727
+ }
728
+ function SettingsSaveState({
729
+ saving,
730
+ saved,
731
+ failed,
732
+ missing
733
+ }) {
734
+ if (failed)
735
+ return /* @__PURE__ */ jsx3("p", { className: "band-sf-err", role: "alert", children: failed });
736
+ if (saved) return /* @__PURE__ */ jsx3(SettingsSaved, { text: saved === true ? "\u5DF2\u4FDD\u5B58" : saved });
737
+ const text = saving ?? missing;
738
+ if (!text) return /* @__PURE__ */ jsx3("span", { className: "band-sf-state", "aria-live": "polite" });
739
+ return /* @__PURE__ */ jsx3("span", { className: "band-sf-state", "aria-live": "polite", children: text });
740
+ }
741
+
742
+ import { isLdap, isUsableId } from "@kanyun-ai-infra/band-contracts/display";
743
+ import { withImeGuard } from "@kanyun-ai-infra/band-plugin-sdk/keys";
744
+ import { useCallback, useEffect as useEffect2, useId as useId2, useLayoutEffect, useMemo, useRef as useRef2, useState } from "react";
745
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
746
+ var SPLIT = /[\s,,、;;]+/;
747
+ var MEMBERS_MAX = 500;
748
+ function errorText(e) {
749
+ if (e instanceof Error && e.message) return e.message;
750
+ return "\u51FA\u9519\u4E86";
751
+ }
752
+ function useLoad(key, fn, delay = 0) {
753
+ const [load, setLoad] = useState({ state: "idle" });
754
+ const [nonce, setNonce] = useState(0);
755
+ const fnRef = useRef2(fn);
756
+ fnRef.current = fn;
757
+ useEffect2(() => {
758
+ if (key === null) {
759
+ setLoad({ state: "idle" });
760
+ return;
761
+ }
762
+ const ac = new AbortController();
763
+ setLoad({ state: "loading" });
764
+ const t = setTimeout(() => {
765
+ fnRef.current(ac.signal).then(
766
+ (data) => !ac.signal.aborted && setLoad({ state: "ok", data }),
767
+ (e) => !ac.signal.aborted && setLoad({ state: "error", message: errorText(e) })
768
+ );
769
+ }, delay);
770
+ return () => {
771
+ clearTimeout(t);
772
+ ac.abort();
773
+ };
774
+ }, [key, nonce, delay]);
775
+ return { load, reload: () => setNonce((n) => n + 1) };
776
+ }
777
+ function rowKey(r) {
778
+ switch (r.kind) {
779
+ case "up":
780
+ return `up:${r.depth}`;
781
+ case "here":
782
+ return `here:${r.org.id}`;
783
+ case "org":
784
+ return `org:${r.org.id}`;
785
+ case "person":
786
+ return `p:${r.person.id}`;
787
+ case "raw":
788
+ return `raw:${r.id}`;
789
+ case "more":
790
+ return "more-orgs";
791
+ }
792
+ }
793
+ function Tuning({ label }) {
794
+ return /* @__PURE__ */ jsxs3("output", { className: "band-plugin-react-pp-state", children: [
795
+ /* @__PURE__ */ jsx4("span", { className: "tuning band-plugin-react-pp-tuning", "aria-hidden": "true", children: /* @__PURE__ */ jsxs3("svg", { viewBox: "0 0 80 55", "aria-hidden": "true", children: [
796
+ /* @__PURE__ */ jsx4("line", { x1: "0", y1: "11", x2: "80", y2: "11" }),
797
+ /* @__PURE__ */ jsx4("line", { x1: "0", y1: "22", x2: "80", y2: "22" }),
798
+ /* @__PURE__ */ jsx4("line", { x1: "0", y1: "33", x2: "80", y2: "33" }),
799
+ /* @__PURE__ */ jsx4("line", { x1: "0", y1: "44", x2: "80", y2: "44" }),
800
+ /* @__PURE__ */ jsx4("circle", { cx: "20", cy: "33", r: "4.5" }),
801
+ /* @__PURE__ */ jsx4("circle", { cx: "40", cy: "22", r: "4.5" }),
802
+ /* @__PURE__ */ jsx4("circle", { cx: "60", cy: "11", r: "4.5" })
803
+ ] }) }),
804
+ /* @__PURE__ */ jsx4("span", { children: label })
805
+ ] });
806
+ }
807
+ function TriBox({
808
+ state,
809
+ disabled,
810
+ onToggle,
811
+ label
812
+ }) {
813
+ const ref = useRef2(null);
814
+ useLayoutEffect(() => {
815
+ if (ref.current) ref.current.indeterminate = state === "mixed";
816
+ }, [state]);
817
+ return /* @__PURE__ */ jsx4(
818
+ "input",
819
+ {
820
+ ref,
821
+ type: "checkbox",
822
+ className: "checkbox",
823
+ checked: state === "on",
824
+ disabled,
825
+ tabIndex: -1,
826
+ "aria-label": label,
827
+ "data-state": state,
828
+ onMouseDown: (e) => e.preventDefault(),
829
+ onClick: (e) => {
830
+ e.stopPropagation();
831
+ e.preventDefault();
832
+ onToggle();
833
+ },
834
+ onChange: () => {
835
+ }
836
+ }
837
+ );
838
+ }
839
+ function PersonSearch({
840
+ label,
841
+ inputId,
842
+ describedBy,
843
+ directory,
844
+ picked,
845
+ onPick,
846
+ onUnpick,
847
+ multiple = false,
848
+ room,
849
+ disabled = [],
850
+ allowUnknown = false,
851
+ query: controlledQuery,
852
+ onQueryChange,
853
+ unknownIdKind = "ldap",
854
+ placeholder,
855
+ busy = false,
856
+ rootLabel = "\u5168\u90E8\u95E8",
857
+ onLearn,
858
+ defaultOpen = false,
859
+ defaultQuery = "",
860
+ defaultTrail = []
861
+ }) {
862
+ const id = useId2();
863
+ const listId = `${id}-list`;
864
+ const [open, setOpen] = useState(defaultOpen);
865
+ const [ownQuery, setOwnQuery] = useState(defaultQuery);
866
+ const query = controlledQuery ?? ownQuery;
867
+ const setQuery = (next) => {
868
+ setOwnQuery(next);
869
+ onQueryChange?.(next);
870
+ };
871
+ const [trail, setTrail] = useState(defaultTrail);
872
+ const org = trail[trail.length - 1]?.id ?? null;
873
+ const [active, setActive] = useState({
874
+ page: null,
875
+ i: 0
876
+ });
877
+ const [notice, setNotice] = useState(null);
878
+ const [batch, setBatch] = useState(null);
879
+ const input = useRef2(null);
880
+ const list = useRef2(null);
881
+ const host = useRef2(null);
882
+ const inflight = useRef2(null);
883
+ const begin = () => {
884
+ inflight.current?.abort();
885
+ setBatch(null);
886
+ const ac = new AbortController();
887
+ inflight.current = ac;
888
+ return ac;
889
+ };
890
+ const cancel = () => {
891
+ inflight.current?.abort();
892
+ inflight.current = null;
893
+ setBatch(null);
894
+ };
895
+ useEffect2(() => () => inflight.current?.abort(), []);
896
+ useEffect2(() => {
897
+ if (!open) cancel();
898
+ }, [open]);
899
+ const q = query.trim();
900
+ const browsing = q === "" && directory.browse !== void 0;
901
+ const pickedIds = useMemo(() => new Set(picked.map((p) => p.id)), [picked]);
902
+ const blockedById = useMemo(() => new Map(disabled.map((b) => [b.id, b.reason])), [disabled]);
903
+ const full = room !== void 0 && room <= 0;
904
+ const acceptsId = unknownIdKind === "account" ? isUsableId : isLdap;
905
+ const idWord = unknownIdKind === "account" ? "\u8D26\u53F7" : "ldap";
906
+ const canTree = multiple && directory.members !== void 0;
907
+ const searchLoad = useLoad(
908
+ open && q !== "" ? `s:${q}` : null,
909
+ (signal) => directory.search(q, { signal }),
910
+ 200
911
+ );
912
+ const browseLoad = useLoad(
913
+ open && browsing ? `b:${org ?? ""}` : null,
914
+ (signal) => {
915
+ if (!directory.browse) throw new Error("\u4E0D\u652F\u6301\u6309\u90E8\u95E8\u6D4F\u89C8");
916
+ const chain = trail[trail.length - 1]?.chain;
917
+ return directory.browse(org, { signal, ...chain ? { chain } : {} });
918
+ }
919
+ );
920
+ const current = browsing ? browseLoad : searchLoad;
921
+ const page = current.load.state === "ok" ? current.load.data : null;
922
+ const [expandedOrgs, setExpandedOrgs] = useState(null);
923
+ const rows = useMemo(() => {
924
+ if (!page) return [];
925
+ const out = [];
926
+ if (browsing && trail.length > 0) {
927
+ const parent = trail.length >= 2 ? trail[trail.length - 2] : void 0;
928
+ out.push({ kind: "up", depth: trail.length - 1, label: parent?.name ?? rootLabel });
929
+ const here = trail[trail.length - 1];
930
+ if (canTree && here) out.push({ kind: "here", org: here });
931
+ }
932
+ if (!browsing) for (const p of page.people) out.push({ kind: "person", person: p });
933
+ const orgs = !browsing && expandedOrgs !== page ? page.orgs.slice(0, 3) : page.orgs;
934
+ for (const o of orgs) out.push({ kind: "org", org: o });
935
+ if (browsing) for (const p of page.people) out.push({ kind: "person", person: p });
936
+ if (orgs.length < page.orgs.length)
937
+ out.push({ kind: "more", count: page.orgs.length - orgs.length });
938
+ if (!browsing && allowUnknown && unknownIdKind !== "account" && acceptsId(q) && !page.people.some((p) => p.id === q) && !pickedIds.has(q) &&
939
+ !blockedById.has(q))
940
+ out.push({ kind: "raw", id: q });
941
+ return out;
942
+ }, [
943
+ page,
944
+ browsing,
945
+ trail,
946
+ canTree,
947
+ allowUnknown,
948
+ q,
949
+ pickedIds,
950
+ blockedById,
951
+ rootLabel,
952
+ expandedOrgs,
953
+ acceptsId,
954
+ unknownIdKind
955
+ ]);
956
+ const activeIndex = rows.length === 0 ? -1 : Math.min(active.page === page ? active.i : 0, rows.length - 1);
957
+ useEffect2(() => {
958
+ if (activeIndex < 0 || !list.current) return;
959
+ const el = list.current.querySelector(`[data-row="${activeIndex}"]`);
960
+ if (el) scrollIntoPanel(el);
961
+ }, [activeIndex]);
962
+ useEffect2(() => {
963
+ if (!open) return;
964
+ const onDown = (e) => {
965
+ if (host.current && !host.current.contains(e.target)) setOpen(false);
966
+ };
967
+ document.addEventListener("pointerdown", onDown);
968
+ return () => document.removeEventListener("pointerdown", onDown);
969
+ }, [open]);
970
+ const reasonOf = useCallback(
971
+ (p) => {
972
+ const r = blockedById.get(p.id);
973
+ if (r) return r;
974
+ if (!multiple || pickedIds.has(p.id)) return null;
975
+ if (full) return "\u540D\u5355\u5DF2\u6EE1";
976
+ return null;
977
+ },
978
+ [blockedById, multiple, pickedIds, full]
979
+ );
980
+ const checkOf = useCallback(
981
+ (o) => canTree ? orgCheck(o, picked, disabled) : null,
982
+ [canTree, picked, disabled]
983
+ );
984
+ const rawPerson = (id2) => ({
985
+ id: id2,
986
+ name: id2,
987
+ ...unknownIdKind === "ldap" ? { inBand: false } : {}
988
+ });
989
+ function choose(p) {
990
+ if (reasonOf(p)) return;
991
+ if (pickedIds.has(p.id)) {
992
+ if (multiple) onUnpick?.([p.id]);
993
+ return;
994
+ }
995
+ onPick([p]);
996
+ setNotice(null);
997
+ if (!multiple) {
998
+ setOpen(false);
999
+ setQuery("");
1000
+ }
1001
+ }
1002
+ async function toggleOrg(o) {
1003
+ const check = checkOf(o);
1004
+ if (!check || !directory.members || batch) return;
1005
+ if (check.state === "on") {
1006
+ const ids = idsUnder(o, picked);
1007
+ if (ids.length > 0) onUnpick?.(ids);
1008
+ setNotice(`\u53D6\u6D88\u4E86${o.name}\u7684 ${ids.length} \u4EBA`);
1009
+ return;
1010
+ }
1011
+ const pre = precheckOrgAdd(o, check, room);
1012
+ if (pre) {
1013
+ setNotice(pre);
1014
+ return;
1015
+ }
1016
+ if (o.count !== void 0 && o.count > MEMBERS_MAX) {
1017
+ setNotice(`${o.name}\u6709 ${o.count} \u4EBA\uFF0C\u8D85\u8FC7\u4E00\u6B21\u80FD\u52A0\u7684 ${MEMBERS_MAX} \u4EBA\uFF0C\u6CA1\u6709\u52A0`);
1018
+ return;
1019
+ }
1020
+ const ac = begin();
1021
+ const signal = ac.signal;
1022
+ setBatch(o.id);
1023
+ try {
1024
+ const limit = Math.min(o.count ?? MEMBERS_MAX, MEMBERS_MAX);
1025
+ const { people, total } = await directory.members(o.id, {
1026
+ signal,
1027
+ limit,
1028
+ ...o.chain ? { chain: o.chain } : {}
1029
+ });
1030
+ if (signal.aborted) return;
1031
+ if (total > people.length) {
1032
+ setNotice(`${o.name}\u6709 ${total} \u4EBA\uFF0C\u8D85\u8FC7\u4E00\u6B21\u80FD\u52A0\u7684\u4EBA\u6570\uFF0C\u6CA1\u6709\u52A0`);
1033
+ return;
1034
+ }
1035
+ const plan = planOrgAdd(o, people, picked, disabled, room);
1036
+ if ("refuse" in plan) {
1037
+ onLearn?.(people.filter((p) => p.chain));
1038
+ setNotice(plan.refuse);
1039
+ return;
1040
+ }
1041
+ if (plan.add.length > 0) onPick(plan.add);
1042
+ onLearn?.(people.filter((p) => p.chain));
1043
+ setNotice(
1044
+ plan.add.length === 0 ? `${o.name}\u7684\u4EBA\u90FD\u5DF2\u7ECF\u9009\u4E86` : `\u52A0\u4E86${o.name}\u7684 ${plan.add.length} \u4EBA${plan.skipped > 0 ? `\uFF0C${plan.skipped} \u4EBA\u5DF2\u9009\u6216\u4E0D\u80FD\u9009` : ""}`
1045
+ );
1046
+ } catch (e) {
1047
+ if (!signal.aborted) setNotice(`${o.name}\u7684\u4EBA\u6CA1\u53D6\u5230\uFF1A${errorText(e)}`);
1048
+ } finally {
1049
+ if (inflight.current === ac) {
1050
+ inflight.current = null;
1051
+ setBatch(null);
1052
+ }
1053
+ }
1054
+ }
1055
+ function activate(r) {
1056
+ switch (r.kind) {
1057
+ case "up":
1058
+ setTrail(trail.slice(0, r.depth));
1059
+ break;
1060
+ case "org":
1061
+ setTrail(browsing ? [...trail, r.org] : [r.org]);
1062
+ setQuery("");
1063
+ break;
1064
+ case "here":
1065
+ void toggleOrg(r.org);
1066
+ break;
1067
+ case "person":
1068
+ choose(r.person);
1069
+ break;
1070
+ case "raw":
1071
+ choose(rawPerson(r.id));
1072
+ if (multiple) setQuery("");
1073
+ break;
1074
+ case "more":
1075
+ setExpandedOrgs(page);
1076
+ break;
1077
+ }
1078
+ input.current?.focus();
1079
+ }
1080
+ async function onPaste(e) {
1081
+ const text = e.clipboardData.getData("text");
1082
+ const parts = [...new Set(text.split(SPLIT).filter(Boolean))];
1083
+ if (!multiple || parts.length < 2) return;
1084
+ e.preventDefault();
1085
+ const bad = parts.filter((x) => !acceptsId(x));
1086
+ const ids = parts.filter((x) => acceptsId(x) && !pickedIds.has(x));
1087
+ if (ids.length === 0) {
1088
+ setNotice(
1089
+ bad.length > 0 ? `\u8FD9\u4E9B\u4E0D\u662F ${idWord}\uFF0C\u6CA1\u6709\u52A0\uFF1A${bad.join("\u3001")}` : "\u7C98\u8D34\u7684\u4EBA\u90FD\u5DF2\u7ECF\u9009\u4E86"
1090
+ );
1091
+ return;
1092
+ }
1093
+ if (room !== void 0 && ids.length > room) {
1094
+ setNotice(`\u7C98\u8D34\u4E86 ${ids.length} \u4E2A ${idWord}\uFF0C\u540D\u5355\u6700\u591A\u8FD8\u80FD\u52A0 ${room} \u4EBA\uFF0C\u6CA1\u6709\u52A0`);
1095
+ return;
1096
+ }
1097
+ let found = [];
1098
+ let missing = ids;
1099
+ let why;
1100
+ if (directory.resolve) {
1101
+ const signal = begin().signal;
1102
+ try {
1103
+ const r = await directory.resolve(ids, { signal });
1104
+ if (signal.aborted) return;
1105
+ found = r.people;
1106
+ missing = r.missing;
1107
+ why = r.fallback;
1108
+ } catch (err) {
1109
+ if (!signal.aborted) setNotice(`\u7C98\u8D34\u7684 ${idWord} \u6CA1\u67E5\u6210\uFF1A${errorText(err)}`);
1110
+ return;
1111
+ }
1112
+ }
1113
+ const extra = allowUnknown ? missing.map(rawPerson) : [];
1114
+ const seen = /* @__PURE__ */ new Set();
1115
+ const add = [...found, ...extra].filter(
1116
+ (p) => !blockedById.has(p.id) && !seen.has(p.id) && seen.add(p.id)
1117
+ );
1118
+ if (add.length > 0) onPick(add);
1119
+ const tail = [
1120
+ !allowUnknown && missing.length > 0 ? `${missing.length} \u4E2A\u6CA1\u627E\u5230\uFF1A${missing.join("\u3001")}${why ? `\uFF08${why}\uFF09` : ""}` : "",
1121
+ bad.length > 0 ? `\u8FD9\u4E9B\u4E0D\u662F ${idWord}\uFF1A${bad.join("\u3001")}` : ""
1122
+ ].filter(Boolean);
1123
+ setNotice(`\u52A0\u4E86 ${add.length} \u4EBA${tail.length > 0 ? `\uFF1B${tail.join("\uFF1B")}` : ""}`);
1124
+ }
1125
+ const onKeyDown = withImeGuard((e) => {
1126
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1127
+ e.preventDefault();
1128
+ if (!open) return setOpen(true);
1129
+ if (rows.length === 0) return;
1130
+ const d = e.key === "ArrowDown" ? 1 : -1;
1131
+ setActive({ page, i: (activeIndex + d + rows.length) % rows.length });
1132
+ return;
1133
+ }
1134
+ if (e.key === "Enter") {
1135
+ if (!open) return;
1136
+ e.preventDefault();
1137
+ const r = rows[activeIndex];
1138
+ if (r) activate(r);
1139
+ return;
1140
+ }
1141
+ if (e.key === " " && open && query === "") {
1142
+ const r = rows[activeIndex];
1143
+ if (r?.kind === "org" || r?.kind === "here") {
1144
+ e.preventDefault();
1145
+ void toggleOrg(r.org);
1146
+ } else if (r?.kind === "person" && multiple) {
1147
+ e.preventDefault();
1148
+ choose(r.person);
1149
+ }
1150
+ return;
1151
+ }
1152
+ if (e.key === "ArrowRight" && open && query === "") {
1153
+ const r = rows[activeIndex];
1154
+ if (r?.kind === "org") {
1155
+ e.preventDefault();
1156
+ activate(r);
1157
+ }
1158
+ return;
1159
+ }
1160
+ if ((e.key === "ArrowLeft" || e.key === "Backspace") && open && query === "" && browsing && trail.length > 0) {
1161
+ e.preventDefault();
1162
+ setTrail(trail.slice(0, -1));
1163
+ return;
1164
+ }
1165
+ if (e.key === "Escape" && open) {
1166
+ e.preventDefault();
1167
+ e.stopPropagation();
1168
+ setOpen(false);
1169
+ }
1170
+ });
1171
+ const activeId = activeIndex >= 0 ? `${id}-r${activeIndex}` : void 0;
1172
+ const ph = !multiple && picked.length > 0 ? "\u6362\u4E00\u4E2A\u4EBA" : full ? "\u540D\u5355\u5DF2\u6EE1" : placeholder ?? (directory.browse ? "\u641C\u59D3\u540D\u3001ldap \u6216\u90E8\u95E8" : "\u641C\u59D3\u540D\u6216 ldap");
1173
+ let body;
1174
+ if (!browsing && q === "" || browsing && page?.fallback && page.orgs.length === 0 && page.people.length === 0) {
1175
+ body = /* @__PURE__ */ jsx4("div", { className: "band-plugin-react-pp-state", children: "\u8F93\u5165\u59D3\u540D\u6216 ldap \u67E5\u627E" });
1176
+ } else if (current.load.state === "loading" || current.load.state === "idle") {
1177
+ body = /* @__PURE__ */ jsx4(Tuning, { label: browsing ? "\u6B63\u5728\u8BFB\u7EC4\u7EC7\u67B6\u6784" : "\u6B63\u5728\u67E5" });
1178
+ } else if (current.load.state === "error") {
1179
+ body = /* @__PURE__ */ jsxs3("div", { className: "band-plugin-react-pp-state band-plugin-react-retry", role: "alert", children: [
1180
+ /* @__PURE__ */ jsxs3("div", { className: "band-plugin-react-error", children: [
1181
+ browsing ? "\u7EC4\u7EC7\u67B6\u6784\u6CA1\u8BFB\u51FA\u6765" : "\u6CA1\u67E5\u6210",
1182
+ "\uFF1A",
1183
+ current.load.message
1184
+ ] }),
1185
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "btn sm", onClick: current.reload, children: "\u91CD\u8BD5" })
1186
+ ] });
1187
+ } else if (rows.length === 0) {
1188
+ body = /* @__PURE__ */ jsx4("div", { className: "band-plugin-react-pp-state", children: browsing ? "\u8FD9\u4E2A\u90E8\u95E8\u6CA1\u6709\u4EBA" : `\u6CA1\u6709\u627E\u5230\u300C${q}\u300D` });
1189
+ } else {
1190
+ body =
1191
+ /* @__PURE__ */ jsx4(
1192
+ "div",
1193
+ {
1194
+ className: "band-plugin-react-pp-list",
1195
+ role: "listbox",
1196
+ id: listId,
1197
+ ref: list,
1198
+ "aria-label": `${label}\u7684\u5019\u9009`,
1199
+ "aria-multiselectable": multiple || void 0,
1200
+ children: rows.map((r, i) => /* @__PURE__ */ jsx4(
1201
+ RowView,
1202
+ {
1203
+ row: r,
1204
+ index: i,
1205
+ optionId: `${id}-r${i}`,
1206
+ active: i === activeIndex,
1207
+ multiple,
1208
+ picked: r.kind === "person" && pickedIds.has(r.person.id),
1209
+ reason: r.kind === "person" ? reasonOf(r.person) : null,
1210
+ check: r.kind === "org" || r.kind === "here" ? checkOf(r.org) : null,
1211
+ batching: (r.kind === "org" || r.kind === "here") && batch === r.org.id,
1212
+ query: browsing ? "" : q,
1213
+ onHover: () => setActive({ page, i }),
1214
+ onActivate: () => activate(r),
1215
+ onToggleOrg: (o) => {
1216
+ void toggleOrg(o);
1217
+ input.current?.focus();
1218
+ }
1219
+ },
1220
+ rowKey(r)
1221
+ ))
1222
+ }
1223
+ );
1224
+ }
1225
+ const manualAccount = unknownIdKind === "account" && allowUnknown && acceptsId(q) && !pickedIds.has(q) && !blockedById.has(q) ? q : null;
1226
+ const reason = page?.fallback ?? directory.unavailable;
1227
+ const chosen = !multiple ? picked[0] : void 0;
1228
+ return /* @__PURE__ */ jsxs3("div", { className: "band-plugin-react-pp", ref: host, children: [
1229
+ /* @__PURE__ */ jsxs3("div", { className: "band-plugin-react-pp-field field-host", children: [
1230
+ /* @__PURE__ */ jsxs3("svg", { className: "band-plugin-react-pp-icon", viewBox: "0 0 16 16", "aria-hidden": "true", children: [
1231
+ /* @__PURE__ */ jsx4("circle", { cx: "7", cy: "7", r: "4.5" }),
1232
+ /* @__PURE__ */ jsx4("path", { d: "M10.5 10.5 14 14" })
1233
+ ] }),
1234
+ chosen && /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-chosen", children: [
1235
+ /* @__PURE__ */ jsx4(Avatar, { id: chosen.id, name: chosen.name, size: "xs", decorative: true }),
1236
+ chosen.name,
1237
+ chosen.name !== chosen.id && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-id", children: chosen.id }),
1238
+ /* @__PURE__ */ jsx4(
1239
+ "button",
1240
+ {
1241
+ type: "button",
1242
+ "aria-label": `\u6362\u6389${chosen.name}`,
1243
+ onClick: () => {
1244
+ onUnpick?.([chosen.id]);
1245
+ input.current?.focus();
1246
+ },
1247
+ children: "\xD7"
1248
+ }
1249
+ )
1250
+ ] }),
1251
+ /* @__PURE__ */ jsx4(
1252
+ "input",
1253
+ {
1254
+ ref: input,
1255
+ className: "field bare",
1256
+ id: inputId,
1257
+ role: "combobox",
1258
+ "aria-label": label,
1259
+ "aria-describedby": describedBy,
1260
+ "aria-expanded": open,
1261
+ "aria-controls": listId,
1262
+ "aria-autocomplete": "list",
1263
+ "aria-activedescendant": open ? activeId : void 0,
1264
+ value: query,
1265
+ placeholder: ph,
1266
+ disabled: busy,
1267
+ autoComplete: "off",
1268
+ onFocus: () => setOpen(true),
1269
+ onClick: () => setOpen(true),
1270
+ onChange: (e) => {
1271
+ setQuery(e.target.value);
1272
+ setOpen(true);
1273
+ setNotice(null);
1274
+ },
1275
+ onKeyDown,
1276
+ onPaste: (e) => void onPaste(e)
1277
+ }
1278
+ )
1279
+ ] }),
1280
+ notice && /* @__PURE__ */ jsx4("output", { className: "band-plugin-react-pp-notice", children: notice }),
1281
+ open && !busy && /* @__PURE__ */ jsxs3("div", { className: "band-plugin-react-pp-pop", children: [
1282
+ reason && /* @__PURE__ */ jsx4("div", { className: "band-plugin-react-pp-fallback", children: reason }),
1283
+ browsing && /* @__PURE__ */ jsxs3("nav", { className: "band-plugin-react-pp-trail", "aria-label": "\u90E8\u95E8\u8DEF\u5F84", children: [
1284
+ /* @__PURE__ */ jsx4(
1285
+ "button",
1286
+ {
1287
+ type: "button",
1288
+ tabIndex: -1,
1289
+ onClick: () => setTrail([]),
1290
+ "aria-current": trail.length === 0 ? "location" : void 0,
1291
+ children: rootLabel
1292
+ }
1293
+ ),
1294
+ trail.map((t, i) => /* @__PURE__ */ jsxs3("span", { children: [
1295
+ /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: "/" }),
1296
+ /* @__PURE__ */ jsx4(
1297
+ "button",
1298
+ {
1299
+ type: "button",
1300
+ tabIndex: -1,
1301
+ onClick: () => setTrail(trail.slice(0, i + 1)),
1302
+ "aria-current": i === trail.length - 1 ? "location" : void 0,
1303
+ children: t.name
1304
+ }
1305
+ )
1306
+ ] }, t.id))
1307
+ ] }),
1308
+ body,
1309
+ manualAccount && /* @__PURE__ */ jsxs3(
1310
+ "button",
1311
+ {
1312
+ type: "button",
1313
+ className: "btn ghost sm band-plugin-react-pp-manual",
1314
+ disabled: full,
1315
+ onClick: () => {
1316
+ const person = page?.people.find((p) => p.id === manualAccount);
1317
+ activate(person ? { kind: "person", person } : { kind: "raw", id: manualAccount });
1318
+ if (person && multiple) setQuery("");
1319
+ if (!multiple) setOpen(false);
1320
+ },
1321
+ onKeyDown: withImeGuard((e) => {
1322
+ if (e.key !== "Escape") return;
1323
+ e.preventDefault();
1324
+ e.stopPropagation();
1325
+ input.current?.focus();
1326
+ setOpen(false);
1327
+ }),
1328
+ children: [
1329
+ "\u6309\u8D26\u53F7\u52A0\u300C",
1330
+ manualAccount,
1331
+ "\u300D"
1332
+ ]
1333
+ }
1334
+ ),
1335
+ page?.truncated && !browsing && /* @__PURE__ */ jsxs3("div", { className: "band-plugin-react-pp-sub band-plugin-react-pp-foot", children: [
1336
+ "\u53EA\u663E\u793A\u4E86\u524D ",
1337
+ page.people.length,
1338
+ " \u4EBA\uFF0C\u6362\u4E2A\u66F4\u51C6\u7684\u8BCD"
1339
+ ] })
1340
+ ] })
1341
+ ] });
1342
+ }
1343
+ function mark(text, q) {
1344
+ if (q === "") return text;
1345
+ const i = text.toLowerCase().indexOf(q.toLowerCase());
1346
+ if (i < 0) return text;
1347
+ return /* @__PURE__ */ jsxs3(Fragment2, { children: [
1348
+ text.slice(0, i),
1349
+ /* @__PURE__ */ jsx4("mark", { children: text.slice(i, i + q.length) }),
1350
+ text.slice(i + q.length)
1351
+ ] });
1352
+ }
1353
+ function checkLabel(o, check) {
1354
+ if (check.state === "on") return `\u53D6\u6D88${o.name}\u5168\u90E8 ${check.selectable} \u4EBA`;
1355
+ return `\u9009${o.name}\u5168\u90E8 ${check.selectable} \u4EBA${check.selected > 0 ? `\uFF08\u5DF2\u9009 ${check.selected} \u4EBA\uFF09` : ""}`;
1356
+ }
1357
+ function RowView({
1358
+ row,
1359
+ index,
1360
+ optionId,
1361
+ active,
1362
+ multiple,
1363
+ picked,
1364
+ reason,
1365
+ check,
1366
+ batching,
1367
+ query,
1368
+ onHover,
1369
+ onActivate,
1370
+ onToggleOrg
1371
+ }) {
1372
+ const cls = `band-plugin-react-pp-row${active ? " is-active" : ""}${reason ? " is-off" : ""}`;
1373
+ const common = {
1374
+ id: optionId,
1375
+ role: "option",
1376
+ "data-row": index,
1377
+ "aria-selected": active,
1378
+ className: cls,
1379
+ onMouseMove: onHover,
1380
+ onMouseDown: (e) => e.preventDefault(),
1381
+ onClick: () => onActivate()
1382
+ };
1383
+ switch (row.kind) {
1384
+ case "up":
1385
+ return /* @__PURE__ */ jsxs3("div", { ...common, children: [
1386
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-chev", "aria-hidden": "true", children: "\u2039" }),
1387
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-name", children: [
1388
+ "\u8FD4\u56DE ",
1389
+ row.label
1390
+ ] })
1391
+ ] });
1392
+ case "here":
1393
+ return /* @__PURE__ */ jsxs3("div", { ...common, "aria-checked": check ? check.state === "on" : void 0, children: [
1394
+ check && /* @__PURE__ */ jsx4(
1395
+ TriBox,
1396
+ {
1397
+ state: check.state,
1398
+ disabled: check.selectable === 0 || batching,
1399
+ label: checkLabel(row.org, check),
1400
+ onToggle: () => onToggleOrg(row.org)
1401
+ }
1402
+ ),
1403
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-main", children: /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-name", children: batching ? "\u6B63\u5728\u53D6\u90E8\u95E8\u7684\u4EBA\u2026" : `\u6574\u4E2A${row.org.name}` }) }),
1404
+ check && /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-meta", children: [
1405
+ check.selected > 0 ? `\u5DF2\u9009 ${check.selected} / ` : "",
1406
+ check.selectable,
1407
+ " \u4EBA"
1408
+ ] })
1409
+ ] });
1410
+ case "org":
1411
+ return /* @__PURE__ */ jsxs3(
1412
+ "div",
1413
+ {
1414
+ ...common,
1415
+ "aria-checked": check ? check.state === "mixed" ? "mixed" : check.state === "on" : void 0,
1416
+ children: [
1417
+ check ? /* @__PURE__ */ jsx4(
1418
+ TriBox,
1419
+ {
1420
+ state: check.state,
1421
+ disabled: check.selectable === 0 || batching,
1422
+ label: checkLabel(row.org, check),
1423
+ onToggle: () => onToggleOrg(row.org)
1424
+ }
1425
+ ) : /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-dept", "aria-hidden": "true", children: /* @__PURE__ */ jsxs3("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: [
1426
+ /* @__PURE__ */ jsx4("rect", { x: "2", y: "3", width: "12", height: "10", rx: "2" }),
1427
+ /* @__PURE__ */ jsx4("path", { d: "M2 6.5h12" })
1428
+ ] }) }),
1429
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-main", children: [
1430
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-name", children: batching ? "\u6B63\u5728\u53D6\u90E8\u95E8\u7684\u4EBA\u2026" : mark(row.org.name, query) }),
1431
+ query !== "" && row.org.path && /* @__PURE__ */ jsx4(
1432
+ "span",
1433
+ {
1434
+ className: "band-plugin-react-pp-sub band-plugin-react-pp-path",
1435
+ title: row.org.path,
1436
+ children: row.org.path
1437
+ }
1438
+ )
1439
+ ] }),
1440
+ row.org.count !== void 0 && /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-meta", children: [
1441
+ check && check.selected > 0 ? `\u5DF2\u9009 ${check.selected} / ` : "",
1442
+ row.org.count,
1443
+ " \u4EBA"
1444
+ ] }),
1445
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-chev", "aria-hidden": "true", children: "\u203A" })
1446
+ ]
1447
+ }
1448
+ );
1449
+ case "person": {
1450
+ const p = row.person;
1451
+ return /* @__PURE__ */ jsxs3(
1452
+ "div",
1453
+ {
1454
+ ...common,
1455
+ "aria-disabled": reason ? true : void 0,
1456
+ "aria-checked": multiple ? picked : void 0,
1457
+ children: [
1458
+ multiple && /* @__PURE__ */ jsx4(
1459
+ "input",
1460
+ {
1461
+ type: "checkbox",
1462
+ className: "checkbox",
1463
+ checked: picked,
1464
+ readOnly: true,
1465
+ tabIndex: -1,
1466
+ "aria-hidden": "true",
1467
+ disabled: !!reason
1468
+ }
1469
+ ),
1470
+ /* @__PURE__ */ jsx4(Avatar, { id: p.id, name: p.name, size: "sm", decorative: true }),
1471
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-main", children: [
1472
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-name", children: [
1473
+ mark(p.name, query),
1474
+ " ",
1475
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-id", children: mark(p.id, query) })
1476
+ ] }),
1477
+ (reason || p.path) && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-sub band-plugin-react-pp-path", title: p.path, children: reason ?? p.path })
1478
+ ] }),
1479
+ !multiple && picked && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-meta", children: "\u5DF2\u9009" })
1480
+ ]
1481
+ }
1482
+ );
1483
+ }
1484
+ case "raw":
1485
+ return /* @__PURE__ */ jsxs3("div", { ...common, children: [
1486
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-all", "aria-hidden": "true", children: "\uFF0B" }),
1487
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-main", children: [
1488
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-name", children: [
1489
+ "\u6309 ldap \u52A0\u300C",
1490
+ row.id,
1491
+ "\u300D"
1492
+ ] }),
1493
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-sub", children: "\u7EC4\u7EC7\u67B6\u6784\u91CC\u6CA1\u6709\u8FD9\u4E2A\u4EBA\uFF0C\u540D\u5B57\u5148\u663E\u793A ldap" })
1494
+ ] })
1495
+ ] });
1496
+ case "more":
1497
+ return /* @__PURE__ */ jsxs3("div", { ...common, children: [
1498
+ "\u8FD8\u6709 ",
1499
+ row.count,
1500
+ " \u4E2A\u90E8\u95E8"
1501
+ ] });
1502
+ }
1503
+ }
1504
+ function PersonPicker({
1505
+ value,
1506
+ onChange,
1507
+ max,
1508
+ readOnly = false,
1509
+ confirmRemove = false,
1510
+ emptyText = "\u8FD8\u6CA1\u6709\u4EBA",
1511
+ locked = {},
1512
+ addSlot,
1513
+ label,
1514
+ ...search
1515
+ }) {
1516
+ const [confirming, setConfirming] = useState(null);
1517
+ const room = max === void 0 ? void 0 : Math.max(0, max - value.length);
1518
+ const lockOf = (id) => Object.hasOwn(locked, id) ? locked[id] : void 0;
1519
+ const remove = (id) => {
1520
+ onChange(value.filter((p) => p.id !== id));
1521
+ setConfirming(null);
1522
+ };
1523
+ return /* @__PURE__ */ jsxs3("div", { className: "band-plugin-react-pp-picker", children: [
1524
+ value.length === 0 ? /* @__PURE__ */ jsx4("div", { className: "band-plugin-react-pp-empty", children: emptyText }) : /* @__PURE__ */ jsx4(
1525
+ "ul",
1526
+ {
1527
+ className: "band-plugin-react-pp-people",
1528
+ "aria-label": `${label}\uFF1A\u5DF2\u9009 ${value.length} \u4EBA`,
1529
+ children: value.map((p) => /* @__PURE__ */ jsxs3("li", { className: "band-plugin-react-pp-person", children: [
1530
+ /* @__PURE__ */ jsx4(Avatar, { id: p.id, name: p.name, size: "md", decorative: true }),
1531
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-main", children: [
1532
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-pp-name", children: [
1533
+ p.name,
1534
+ " ",
1535
+ p.name !== p.id && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-id", children: p.id })
1536
+ ] }),
1537
+ (p.path || p.inBand === false) && /* @__PURE__ */ jsx4(
1538
+ "span",
1539
+ {
1540
+ className: "band-plugin-react-pp-sub band-plugin-react-pp-path",
1541
+ title: p.path,
1542
+ children: [p.path, p.inBand === false ? "\u6CA1\u767B\u5F55\u8FC7 Band" : ""].filter(Boolean).join(" \xB7 ")
1543
+ }
1544
+ )
1545
+ ] }),
1546
+ readOnly ? null : lockOf(p.id) ? /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-meta", children: lockOf(p.id) }) : confirming === p.id ? /* @__PURE__ */ jsxs3(
1547
+ "span",
1548
+ {
1549
+ className: "band-plugin-react-pp-confirm",
1550
+ role: "group",
1551
+ "aria-label": `\u786E\u8BA4\u79FB\u51FA${p.name}`,
1552
+ children: [
1553
+ /* @__PURE__ */ jsxs3("span", { children: [
1554
+ "\u79FB\u51FA",
1555
+ p.name,
1556
+ "\uFF1F"
1557
+ ] }),
1558
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "btn sm danger", onClick: () => remove(p.id), children: "\u79FB\u51FA" }),
1559
+ /* @__PURE__ */ jsx4(
1560
+ "button",
1561
+ {
1562
+ type: "button",
1563
+ className: "btn sm ghost",
1564
+ onClick: () => setConfirming(null),
1565
+ children: "\u53D6\u6D88"
1566
+ }
1567
+ )
1568
+ ]
1569
+ }
1570
+ ) : /* @__PURE__ */ jsx4(
1571
+ "button",
1572
+ {
1573
+ type: "button",
1574
+ className: "btn ghost sm",
1575
+ "aria-label": `\u79FB\u51FA${p.name}`,
1576
+ disabled: search.busy,
1577
+ onClick: () => confirmRemove ? setConfirming(p.id) : remove(p.id),
1578
+ children: "\u79FB\u51FA"
1579
+ }
1580
+ )
1581
+ ] }, p.id))
1582
+ }
1583
+ ),
1584
+ !readOnly && addSlot,
1585
+ !readOnly && !addSlot && /* @__PURE__ */ jsxs3(Fragment2, { children: [
1586
+ /* @__PURE__ */ jsx4(
1587
+ PersonSearch,
1588
+ {
1589
+ ...search,
1590
+ label,
1591
+ multiple: true,
1592
+ picked: value,
1593
+ room,
1594
+ onPick: (people) => {
1595
+ const have = new Set(value.map((p) => p.id));
1596
+ const fresh = [];
1597
+ for (const p of people)
1598
+ if (!have.has(p.id)) {
1599
+ have.add(p.id);
1600
+ fresh.push(p);
1601
+ }
1602
+ onChange([...value, ...fresh]);
1603
+ },
1604
+ onUnpick: (ids) => {
1605
+ const drop = new Set(ids.filter((i) => !lockOf(i)));
1606
+ onChange(value.filter((p) => !drop.has(p.id)));
1607
+ }
1608
+ }
1609
+ ),
1610
+ max !== void 0 && /* @__PURE__ */ jsxs3("div", { className: "band-plugin-react-pp-count", children: [
1611
+ value.length,
1612
+ " / ",
1613
+ max,
1614
+ " \u4EBA"
1615
+ ] })
1616
+ ] })
1617
+ ] });
1618
+ }
1619
+ function directoryFor(people, searchUsers) {
1620
+ if (people) return peopleDirectory(people);
1621
+ if (!searchUsers)
1622
+ return {
1623
+ unavailable: "\u8FD9\u91CC\u6CA1\u6709\u63A5\u7EC4\u7EC7\u67B6\u6784\uFF0C\u641C\u4E0D\u4E86\u4EBA\uFF1A\u8F93\u5165 ldap \u6309 ldap \u52A0\uFF0C\u4E5F\u53EF\u4EE5\u7C98\u8D34\u591A\u4E2A ldap",
1624
+ search: async () => ({ orgs: [], people: [] })
1625
+ };
1626
+ return {
1627
+ unavailable: "\u7EC4\u7EC7\u67B6\u6784\u6CA1\u6709\u63A5\u4E0A\uFF1A\u53EA\u80FD\u641C\u767B\u5F55\u8FC7 Band \u7684\u4EBA\uFF0C\u4E5F\u53EF\u4EE5\u6309 ldap \u52A0",
1628
+ async search(q) {
1629
+ const users = await searchUsers(q);
1630
+ return {
1631
+ orgs: [],
1632
+ people: users.map((u) => ({ id: u.id, name: u.displayName, inBand: true }))
1633
+ };
1634
+ }
1635
+ };
1636
+ }
1637
+ function peopleDirectory(api) {
1638
+ return {
1639
+ search: (q) => api.search(q),
1640
+ browse: (id, o) => api.org(id, o.chain ? { chain: o.chain } : {}),
1641
+ members: (id, o) => api.members(id, { limit: o.limit, ...o.chain ? { chain: o.chain } : {} }),
1642
+ resolve: (ids) => api.resolve(ids)
1643
+ };
1644
+ }
1645
+
1646
+ import { useRef as useRef3, useState as useState2 } from "react";
1647
+ var MISSING = "missing";
1648
+ function usePersonList(directory) {
1649
+ const cache = useRef3(/* @__PURE__ */ new Map());
1650
+ const noOrg = useRef3(false);
1651
+ const [filled, setFilled] = useState2(false);
1652
+ const filling = useRef3(0);
1653
+ const [list, setRaw] = useState2([]);
1654
+ const fromCache = (people) => people.map((p) => {
1655
+ const cached = cache.current.get(p.id);
1656
+ const chain = p.chain ?? (cached && cached !== MISSING ? cached : void 0);
1657
+ return chain ? { ...p, chain } : { ...p };
1658
+ });
1659
+ const put = (next) => setRaw((cur) => fromCache(typeof next === "function" ? next(cur) : next));
1660
+ const remember = (people) => {
1661
+ for (const p of people) if (p.chain) cache.current.set(p.id, p.chain);
1662
+ };
1663
+ async function fill(people) {
1664
+ const seq2 = ++filling.current;
1665
+ remember(people);
1666
+ const need = people.filter((p) => !cache.current.has(p.id)).map((p) => p.id);
1667
+ if (need.length > 0 && directory.resolve) {
1668
+ try {
1669
+ const r = await directory.resolve(need, { signal: new AbortController().signal });
1670
+ if (r.fallback !== void 0) noOrg.current = true;
1671
+ remember(r.people);
1672
+ for (const id of need) if (!cache.current.has(id)) cache.current.set(id, MISSING);
1673
+ } catch {
1674
+ }
1675
+ }
1676
+ if (seq2 !== filling.current) return;
1677
+ put((cur) => cur);
1678
+ setFilled(true);
1679
+ }
1680
+ const hasTree = directory.browse !== void 0 && directory.members !== void 0 && directory.resolve !== void 0;
1681
+ return {
1682
+ list,
1683
+ load(people) {
1684
+ put(people);
1685
+ void fill(people);
1686
+ },
1687
+ onChange(next) {
1688
+ remember(next);
1689
+ put(next);
1690
+ },
1691
+ onLearn(people) {
1692
+ remember(people);
1693
+ put((cur) => cur);
1694
+ },
1695
+ noChain: filled && hasTree && !noOrg.current ? list.filter((p) => !p.chain).length : 0
1696
+ };
1697
+ }
1698
+
1699
+ import { useId as useId3, useState as useState3 } from "react";
1700
+
1701
+ var LOG_TAIL = 6;
1702
+ function trailOf(turn, opts) {
1703
+ if (turn.current) return runningTrail(turn.current, opts);
1704
+ if (!turn.last) return void 0;
1705
+ return endedTrail(turn.last, opts);
1706
+ }
1707
+ function runningTrail(t, opts) {
1708
+ const stopping = t.stopping ? `${opts.name(t.stopping.by)} \u70B9\u4E86\u505C\u6B62\uFF0C\u6B63\u5728\u505C\u4E0B\u2026` : void 0;
1709
+ const what = activityText(t);
1710
+ const elapsed = opts.elapsed === null ? void 0 : `\u5DF2\u7528 ${durationText(opts.elapsed)}`;
1711
+ const slow = slowText(t, opts.elapsed);
1712
+ const title = `\u56DE\u5408 #${t.number} \xB7 ${opts.name(t.agent)}`;
1713
+ const alive = stopping !== void 0 || what !== void 0 || t.log.length > 0;
1714
+ if (t.steps.length > 0) {
1715
+ const items = t.steps.map((step, i) => {
1716
+ const mark2 = i < t.step ? "done" : i === t.step ? "now" : "next";
1717
+ if (mark2 !== "now") {
1718
+ return {
1719
+ key: `step-${i}`,
1720
+ mark: mark2,
1721
+ state: mark2 === "done" ? "\u5DF2\u5B8C\u6210" : "\u8FD8\u6CA1\u5F00\u59CB",
1722
+ title: step
1723
+ };
1724
+ }
1725
+ const subs = opts.subsOpen ? logTail(t.log, opts.allLog ? t.log.length : LOG_TAIL) : void 0;
1726
+ const live = t.log.length > 0 ? t.activity?.note : what;
1727
+ return nowRow({
1728
+ key: `step-${i}`,
1729
+ alive,
1730
+ title: step,
1731
+ detail: [stopping ?? live ?? t.summary, slow].filter(Boolean).join(" \xB7 ") || void 0,
1732
+ ...t.log.length > 0 ? { canExpand: true } : {},
1733
+ ...subs && subs.length > 0 ? { subs } : {},
1734
+ ...elapsed ? { side: elapsed } : {}
1735
+ });
1736
+ });
1737
+ if (t.step >= t.steps.length) {
1738
+ items.push(
1739
+ nowRow({
1740
+ key: "wrap-up",
1741
+ alive,
1742
+ title: stopping ?? what ?? t.summary,
1743
+ ...slow ? { detail: slow } : {},
1744
+ ...elapsed ? { side: elapsed } : {}
1745
+ })
1746
+ );
1747
+ }
1748
+ const done = Math.min(t.step, t.steps.length);
1749
+ return {
1750
+ title,
1751
+ side: `${done}/${t.steps.length}`,
1752
+ items,
1753
+ ...opts.subsOpen && t.step < t.steps.length && t.log.length > LOG_TAIL ? { log: { count: t.log.length, open: opts.allLog } } : {}
1754
+ };
1755
+ }
1756
+ if (t.log.length > 0) {
1757
+ const shown = opts.allLog ? t.log : t.log.slice(-LOG_TAIL);
1758
+ const items = shown.map((line, i) => {
1759
+ const last = i === shown.length - 1;
1760
+ const detail = [stopping ?? t.activity?.note, slow].filter(Boolean).join(" \xB7 ");
1761
+ return {
1762
+ key: `log-${opts.allLog ? i : t.log.length - shown.length + i}`,
1763
+ mark: last ? "now" : "done",
1764
+ state: last ? "\u6B63\u5728\u505A" : "\u5DF2\u5B8C\u6210",
1765
+ title: line,
1766
+ ...last && detail ? { detail } : {}
1767
+ };
1768
+ });
1769
+ return {
1770
+ title,
1771
+ ...elapsed ? { side: elapsed } : {},
1772
+ items,
1773
+ ...t.log.length > LOG_TAIL ? { log: { count: t.log.length, open: opts.allLog } } : {}
1774
+ };
1775
+ }
1776
+ return {
1777
+ title,
1778
+ ...elapsed ? { side: elapsed } : {},
1779
+ items: [
1780
+ nowRow({
1781
+ key: "now",
1782
+ alive,
1783
+ state: what ? "\u6B63\u5728\u505A" : "\u5728\u8DD1",
1784
+ title: stopping ?? what ?? t.summary,
1785
+ ...slow ? { detail: slow } : {}
1786
+ })
1787
+ ]
1788
+ };
1789
+ }
1790
+ function endedTrail(last, opts) {
1791
+ const title = "\u4E0A\u4E00\u56DE\u5408";
1792
+ if (last.outcome === "failed") {
1793
+ const who = last.stoppedBy ? opts.name(last.stoppedBy) : void 0;
1794
+ const stopped = who !== void 0;
1795
+ const reason = failureReason(last);
1796
+ const item = {
1797
+ key: "failed",
1798
+ mark: stopped ? "stopped" : "failed",
1799
+ state: stopped ? "\u5DF2\u505C\u4E0B" : "\u6CA1\u505A\u5B8C",
1800
+ title: stopped ? stoppedTurnText(last.number, who) : `\u56DE\u5408 #${last.number} \u6CA1\u505A\u5B8C`,
1801
+ ...reason ? { detail: reason, detailTone: "bad" } : {},
1802
+ ...last.totalMs !== void 0 ? { meta: `\u7528\u65F6 ${durationText(last.totalMs)}` } : {},
1803
+ side: shortTime(last.at)
1804
+ };
1805
+ return { title, items: [item], ...bannerOf(last, opts) };
1806
+ }
1807
+ const items = [
1808
+ {
1809
+ key: "delivered",
1810
+ mark: "done",
1811
+ state: "\u5DF2\u4EA4\u4ED8",
1812
+ title: `\u56DE\u5408 #${last.number} \u5DF2\u4EA4\u4ED8`,
1813
+ ...last.summary ? { detail: last.summary } : {},
1814
+ ...last.totalMs !== void 0 ? { meta: `\u7528\u65F6 ${durationText(last.totalMs)}` } : {},
1815
+ side: shortTime(last.at)
1816
+ }
1817
+ ];
1818
+ if (opts.gate) {
1819
+ items.push({
1820
+ key: "gate",
1821
+ mark: "wait",
1822
+ state: "\u7B49\u6279\u51C6",
1823
+ title: `\u7B49\u300C${opts.stageName(opts.gate)}\u300D\u6279\u51C6`,
1824
+ detail: "\u6279\u51C6\u524D\u4E0D\u8FDB\u4E0B\u4E00\u9636\u6BB5",
1825
+ badge: "\u95E8\u7981"
1826
+ });
1827
+ }
1828
+ return { title, items };
1829
+ }
1830
+ function bannerOf(last, opts) {
1831
+ if (last.retryStage) {
1832
+ const stage = opts.stageName(last.retryStage);
1833
+ return {
1834
+ banner: {
1835
+ lead: last.autoStalled ? "\u81EA\u52A8\u91CD\u8BD5\u505C\u4E0B\u4E86" : "\u53EF\u4EE5\u91CD\u8BD5",
1836
+ text: `\u5728\u56DE\u5408\u680F\u70B9\u300C\u91CD\u8BD5\u300D\uFF0C\u91CD\u8DD1\u300C${stage}\u300D\u8FD9\u4E00\u6B65\u3002`
1837
+ }
1838
+ };
1839
+ }
1840
+ if (last.handBack) {
1841
+ return {
1842
+ banner: { lead: "\u7B49\u4F60\u5904\u7406", text: "\u610F\u89C1\u56DE\u5230\u4E86\u5F85\u5904\u7406\uFF0C\u53EF\u4EE5\u5728\u8FD9\u6761\u610F\u89C1\u4E0A\u518D\u4EA4\u7ED9 Agent\u3002" }
1843
+ };
1844
+ }
1845
+ return {};
1846
+ }
1847
+ function nowRow(o) {
1848
+ return {
1849
+ key: o.key,
1850
+ mark: "now",
1851
+ state: o.state ?? "\u6B63\u5728\u505A",
1852
+ title: o.title,
1853
+ ...o.detail ? { detail: o.detail } : {},
1854
+ ...o.subs && o.subs.length > 0 ? { subs: o.subs } : {},
1855
+ ...o.canExpand ? { canExpand: true } : {},
1856
+ ...o.side ? { side: o.side } : {},
1857
+ ...o.alive ? {} : { quiet: true }
1858
+ };
1859
+ }
1860
+ function activityText(t) {
1861
+ const parts = [t.activity?.note, t.activity?.action].filter(
1862
+ (x) => typeof x === "string" && x.length > 0
1863
+ );
1864
+ return parts.length > 0 ? parts.join(" \xB7 ") : void 0;
1865
+ }
1866
+ function slowText(t, elapsed) {
1867
+ if (t.usualMs === void 0 || elapsed === null || elapsed <= 2 * t.usualMs) return void 0;
1868
+ const usual = t.usualMs < 6e4 ? "\u4E0D\u5230 1 \u5206\u949F" : `\u7EA6 ${usualDurationText(t.usualMs)}`;
1869
+ return `\u6BD4\u5E73\u65F6\u4E45\uFF08\u901A\u5E38${usual}\uFF09`;
1870
+ }
1871
+ function logTail(log, count = LOG_TAIL) {
1872
+ return log.slice(-count).map((text, i, all) => ({
1873
+ text,
1874
+ ...i === all.length - 1 ? { now: true } : {}
1875
+ }));
1876
+ }
1877
+
1878
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1879
+ function AgentTrace({ turn, elapsed, name, stageName, gate, empty }) {
1880
+ const [subsOpen, setSubsOpen] = useState3(true);
1881
+ const [allLog, setAllLog] = useState3(false);
1882
+ const uid = useId3();
1883
+ const trail = trailOf(turn, {
1884
+ elapsed,
1885
+ subsOpen,
1886
+ allLog,
1887
+ name,
1888
+ stageName,
1889
+ ...gate ? { gate } : {}
1890
+ });
1891
+ if (!trail) return /* @__PURE__ */ jsx5(Fragment3, { children: empty });
1892
+ return /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-trace", children: [
1893
+ /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-trace-head", children: [
1894
+ /* @__PURE__ */ jsx5("span", { className: "band-plugin-react-trace-head-title", children: trail.title }),
1895
+ trail.side && /* @__PURE__ */ jsx5("span", { className: "band-plugin-react-trace-count", children: trail.side })
1896
+ ] }),
1897
+ /* @__PURE__ */ jsx5("ol", { className: "band-plugin-react-trace-list", children: trail.items.map((item) => /* @__PURE__ */ jsx5(
1898
+ Row,
1899
+ {
1900
+ item,
1901
+ subsId: `${uid}-subs`,
1902
+ onToggle: () => setSubsOpen(!subsOpen)
1903
+ },
1904
+ item.key
1905
+ )) }),
1906
+ trail.banner && /* @__PURE__ */ jsxs4("p", { className: "band-plugin-react-trace-banner", children: [
1907
+ /* @__PURE__ */ jsx5("b", { children: trail.banner.lead }),
1908
+ /* @__PURE__ */ jsx5("span", { children: trail.banner.text })
1909
+ ] }),
1910
+ trail.log && /* @__PURE__ */ jsx5(
1911
+ "button",
1912
+ {
1913
+ type: "button",
1914
+ className: "btn ghost sm band-plugin-react-trace-more",
1915
+ "aria-expanded": trail.log.open,
1916
+ onClick: () => setAllLog(!allLog),
1917
+ children: trail.log.open ? "\u53EA\u770B\u6700\u8FD1\u51E0\u884C" : `\u770B\u5168\u90E8 ${trail.log.count} \u884C`
1918
+ }
1919
+ )
1920
+ ] });
1921
+ }
1922
+ var markText = (item) => item.mark === "failed" ? "!" : "";
1923
+ var isPending = (item) => item.mark === "next" || item.mark === "stopped";
1924
+ function Row({
1925
+ item,
1926
+ subsId,
1927
+ onToggle
1928
+ }) {
1929
+ return /* @__PURE__ */ jsxs4("li", { className: "band-plugin-react-trace-step", "data-state": item.mark, children: [
1930
+ /* @__PURE__ */ jsx5(
1931
+ "span",
1932
+ {
1933
+ className: "band-plugin-react-trace-mark",
1934
+ "data-mark": item.mark,
1935
+ "data-quiet": item.quiet ? "" : void 0,
1936
+ "aria-hidden": "true",
1937
+ children: markText(item)
1938
+ }
1939
+ ),
1940
+ /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-trace-main", children: [
1941
+ item.canExpand ? (
1942
+ /* @__PURE__ */ jsxs4(
1943
+ "button",
1944
+ {
1945
+ type: "button",
1946
+ className: "band-plugin-react-trace-toggle",
1947
+ "aria-expanded": item.subs !== void 0,
1948
+ ...item.subs !== void 0 ? { "aria-controls": subsId } : {},
1949
+ onClick: onToggle,
1950
+ children: [
1951
+ /* @__PURE__ */ jsx5("span", { className: "band-plugin-react-trace-step-title", children: item.title }),
1952
+ /* @__PURE__ */ jsx5("span", { className: "band-plugin-react-trace-caret", "aria-hidden": "true", children: item.subs !== void 0 ? "\u25BE" : "\u25B8" })
1953
+ ]
1954
+ }
1955
+ )
1956
+ ) : /* @__PURE__ */ jsxs4(
1957
+ "span",
1958
+ {
1959
+ className: "band-plugin-react-trace-step-title",
1960
+ "data-pending": isPending(item) || void 0,
1961
+ children: [
1962
+ item.title,
1963
+ item.badge && /* @__PURE__ */ jsx5("span", { className: "chip plain band-plugin-react-trace-badge", children: item.badge })
1964
+ ]
1965
+ }
1966
+ ),
1967
+ /* @__PURE__ */ jsx5("span", { className: "sr-only", children: item.state }),
1968
+ item.detail && /* @__PURE__ */ jsx5(
1969
+ "span",
1970
+ {
1971
+ className: `band-plugin-react-trace-detail${item.detailTone === "bad" ? " bad" : ""}`,
1972
+ children: item.detail
1973
+ }
1974
+ ),
1975
+ item.meta && /* @__PURE__ */ jsx5("span", { className: "band-plugin-react-trace-detail", children: item.meta }),
1976
+ item.subs && /* @__PURE__ */ jsx5("span", { className: "band-plugin-react-trace-subs", id: subsId, children: item.subs.map((sub, i) => /* @__PURE__ */ jsxs4(
1977
+ "span",
1978
+ {
1979
+ className: "band-plugin-react-trace-sub",
1980
+ "data-now": sub.now ? "" : void 0,
1981
+ children: [
1982
+ /* @__PURE__ */ jsx5(
1983
+ "span",
1984
+ {
1985
+ className: "band-plugin-react-trace-dot",
1986
+ "data-now": sub.now ? "" : void 0,
1987
+ "aria-hidden": "true"
1988
+ }
1989
+ ),
1990
+ /* @__PURE__ */ jsx5("span", { children: sub.text })
1991
+ ]
1992
+ },
1993
+ i
1994
+ )) })
1995
+ ] }),
1996
+ item.side &&
1997
+ /* @__PURE__ */ jsx5("span", { className: "band-plugin-react-trace-side", "aria-hidden": "true", children: item.side })
1998
+ ] });
1999
+ }
2000
+
2001
+ import { useSyncExternalStore } from "react";
2002
+ var clock = (() => {
2003
+ let now = Date.now();
2004
+ let timer = null;
2005
+ const subs = /* @__PURE__ */ new Set();
2006
+ return {
2007
+ get: () => now,
2008
+ subscribe(fn) {
2009
+ subs.add(fn);
2010
+ if (timer === null) {
2011
+ now = Date.now();
2012
+ timer = setInterval(() => {
2013
+ now = Date.now();
2014
+ for (const f of [...subs]) f();
2015
+ }, 1e3);
2016
+ }
2017
+ return () => {
2018
+ subs.delete(fn);
2019
+ if (subs.size === 0 && timer !== null) {
2020
+ clearInterval(timer);
2021
+ timer = null;
2022
+ }
2023
+ };
2024
+ }
2025
+ };
2026
+ })();
2027
+ var idle = () => () => {
2028
+ };
2029
+ function useElapsed(startedAt) {
2030
+ const start = startedAt ? Date.parse(startedAt) : Number.NaN;
2031
+ const running = Number.isFinite(start);
2032
+ const now = useSyncExternalStore(running ? clock.subscribe : idle, clock.get, clock.get);
2033
+ return running ? Math.max(0, now - start) : null;
2034
+ }
2035
+ function useNow(active = true) {
2036
+ return useSyncExternalStore(active ? clock.subscribe : idle, clock.get, clock.get);
2037
+ }
2038
+
2039
+ import { agentDisplayName as agentDisplayName2 } from "@kanyun-ai-infra/band-contracts/display";
2040
+ function memberDisplayName(members, id) {
2041
+ return members?.find((m) => m.actor.id === id)?.displayName ?? agentDisplayName2(id);
2042
+ }
2043
+
2044
+ import { useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore2 } from "react";
2045
+ var TURN_STATUS_ATTR = "data-band-turn-status";
2046
+ var read = (id) => typeof document !== "undefined" && [...document.querySelectorAll(`[${TURN_STATUS_ATTR}]`)].some(
2047
+ (el) => el.getAttribute(TURN_STATUS_ATTR) === id && !el.closest("[hidden], [inert]") &&
2048
+ (typeof el.checkVisibility !== "function" || el.checkVisibility())
2049
+ );
2050
+ function useTurnStatusOnPage(changeRequestId) {
2051
+ const subscribe = useCallback2(
2052
+ (fn) => {
2053
+ if (typeof MutationObserver === "undefined") return () => {
2054
+ };
2055
+ let last = read(changeRequestId);
2056
+ const recheck = () => {
2057
+ const next = read(changeRequestId);
2058
+ if (next === last) return;
2059
+ last = next;
2060
+ fn();
2061
+ };
2062
+ const observer = new MutationObserver(recheck);
2063
+ observer.observe(document.body, {
2064
+ childList: true,
2065
+ subtree: true,
2066
+ attributes: true,
2067
+ attributeFilter: ["hidden", "inert", "class", "style", "data-mpane", TURN_STATUS_ATTR]
2068
+ });
2069
+ window.addEventListener("resize", recheck);
2070
+ return () => {
2071
+ window.removeEventListener("resize", recheck);
2072
+ observer.disconnect();
2073
+ };
2074
+ },
2075
+ [changeRequestId]
2076
+ );
2077
+ return useSyncExternalStore2(
2078
+ subscribe,
2079
+ () => read(changeRequestId),
2080
+ () => false
2081
+ );
2082
+ }
2083
+
2084
+ import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
2085
+ var P = "band-plugin-react-status";
2086
+ function AgentRun({ turn, members, context, stop, stopOnPage }) {
2087
+ const who = memberDisplayName(members, turn.agent);
2088
+ const elapsed = useElapsed(turn.startedAt);
2089
+ const stallNote = stallNoteOf(turn, useNow(turn.stall !== void 0));
2090
+ const note = turn.stopping ? `${memberDisplayName(members, turn.stopping.by)} \u70B9\u4E86\u505C\u6B62\uFF0C\u6B63\u5728\u505C\u4E0B\u2026` : turn.activity?.note ?? (turn.activity ? void 0 : turn.summary);
2091
+ const action = turn.activity?.action;
2092
+ const hasStop = stop !== void 0 && stop !== null && stop !== false && stop !== "";
2093
+ const marked = stopOnPage ?? hasStop;
2094
+ const status = /* @__PURE__ */ jsxs5(
2095
+ "output",
2096
+ {
2097
+ className: P,
2098
+ "aria-label": `${who}\u6B63\u5728\u5904\u7406`,
2099
+ ...marked ? { [TURN_STATUS_ATTR]: turn.changeRequestId } : {},
2100
+ children: [
2101
+ /* @__PURE__ */ jsxs5("span", { className: `${P}-head`, children: [
2102
+ /* @__PURE__ */ jsx6(AgentAvatar, { id: turn.agent, members, decorative: true }),
2103
+ /* @__PURE__ */ jsx6("span", { className: `${P}-who`, children: who }),
2104
+ context && /* @__PURE__ */ jsx6("span", { className: `${P}-context`, children: context }),
2105
+ /* @__PURE__ */ jsx6("span", { className: `glyph working ${P}-glyph`, "aria-hidden": "true" }),
2106
+ /* @__PURE__ */ jsx6("span", { className: `${P}-spacer` }),
2107
+ elapsed !== null &&
2108
+ /* @__PURE__ */ jsxs5("span", { className: `${P}-elapsed`, "aria-hidden": "true", children: [
2109
+ "\u5DF2\u7528 ",
2110
+ durationText(elapsed)
2111
+ ] })
2112
+ ] }),
2113
+ note && /* @__PURE__ */ jsx6("span", { className: `${P}-note`, children: note }),
2114
+ action && /* @__PURE__ */ jsx6("span", { className: `${P}-action`, children: action }),
2115
+ stallNote && !turn.stopping && /* @__PURE__ */ jsx6("span", { className: `${P}-stall`, children: stallNote }),
2116
+ turn.steps.length > 0 && /* @__PURE__ */ jsx6("ol", { className: `${P}-steps`, children: turn.steps.map((step, i) => /* @__PURE__ */ jsx6(
2117
+ "li",
2118
+ {
2119
+ ...i === turn.step ? { "aria-current": "step" } : {},
2120
+ "data-state": i < turn.step ? "done" : i === turn.step ? "now" : "next",
2121
+ children: step
2122
+ },
2123
+ i
2124
+ )) })
2125
+ ]
2126
+ }
2127
+ );
2128
+ if (!hasStop || turn.stopping) return status;
2129
+ return /* @__PURE__ */ jsxs5(Fragment4, { children: [
2130
+ status,
2131
+ /* @__PURE__ */ jsx6("div", { className: `${P}-stop`, children: stop })
2132
+ ] });
2133
+ }
2134
+
2135
+ import { withImeGuard as withImeGuard2 } from "@kanyun-ai-infra/band-plugin-sdk/keys";
2136
+ import {
2137
+ useCallback as useCallback3,
2138
+ useLayoutEffect as useLayoutEffect2,
2139
+ useRef as useRef4
2140
+ } from "react";
2141
+ var messagesOf = (root) => [...root.querySelectorAll("[data-band-message]")].filter(
2142
+ (el) => el.closest("[data-band-messages]") === root
2143
+ );
2144
+ function useMessageList() {
2145
+ const ref = useRef4(null);
2146
+ const active = useRef4(null);
2147
+ useLayoutEffect2(() => {
2148
+ const root = ref.current;
2149
+ if (!root) return;
2150
+ const all = messagesOf(root);
2151
+ const current = active.current && all.includes(active.current) ? active.current : all.at(-1);
2152
+ for (const el of all) el.tabIndex = el === current ? 0 : -1;
2153
+ });
2154
+ const onFocus = useCallback3((e) => {
2155
+ const el = e.target;
2156
+ if (!el.hasAttribute("data-band-message") || !ref.current) return;
2157
+ active.current = el;
2158
+ for (const m of messagesOf(ref.current)) m.tabIndex = m === el ? 0 : -1;
2159
+ }, []);
2160
+ const onKeyDown = useCallback3(
2161
+ withImeGuard2((e) => {
2162
+ const el = e.target;
2163
+ const root = ref.current;
2164
+ if (!root || !el.hasAttribute("data-band-message")) return;
2165
+ const all = messagesOf(root);
2166
+ const i = all.indexOf(el);
2167
+ const to = e.key === "ArrowDown" ? all[i + 1] : e.key === "ArrowUp" ? all[i - 1] : e.key === "Home" ? all[0] : e.key === "End" ? all.at(-1) : void 0;
2168
+ if (!to) return;
2169
+ e.preventDefault();
2170
+ to.focus();
2171
+ }),
2172
+ []
2173
+ );
2174
+ return { ref, onKeyDown, onFocus };
2175
+ }
2176
+
2177
+ import {
2178
+ Tooltip as UiTooltip,
2179
+ TooltipContent as UiTooltipContent,
2180
+ TooltipTrigger as UiTooltipTrigger
2181
+ } from "@ui-sdk/react/tooltip";
2182
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
2183
+ function Tooltip(props) {
2184
+ const { label, children, side = "top", shortcut, ...forwarded } = props;
2185
+ return /* @__PURE__ */ jsxs6(UiTooltip, { children: [
2186
+ /* @__PURE__ */ jsx7(UiTooltipTrigger, { render: children, ...forwarded }),
2187
+ /* @__PURE__ */ jsxs6(UiTooltipContent, { side, className: "band-plugin-react-tooltip", children: [
2188
+ /* @__PURE__ */ jsx7("span", { children: label }),
2189
+ shortcut ? /* @__PURE__ */ jsx7("kbd", { className: "band-plugin-react-tooltip-keys", children: shortcut }) : null
2190
+ ] })
2191
+ ] });
2192
+ }
2193
+
2194
+ import {
2195
+ Menu as UiMenu,
2196
+ MenuCheckboxItem as UiMenuCheckboxItem,
2197
+ MenuContent as UiMenuContent,
2198
+ MenuGroup as UiMenuGroup,
2199
+ MenuGroupLabel as UiMenuGroupLabel,
2200
+ MenuItem as UiMenuItem,
2201
+ MenuItemIndicator as UiMenuItemIndicator,
2202
+ MenuSeparator as UiMenuSeparator,
2203
+ MenuTrigger as UiMenuTrigger
2204
+ } from "@ui-sdk/react/menu";
2205
+ import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
2206
+ function hasCheck(entries2) {
2207
+ return entries2.some((e) => e.kind === "check" || e.kind === "group" && hasCheck(e.items));
2208
+ }
2209
+ function Entries({ entries: entries2, indent }) {
2210
+ return /* @__PURE__ */ jsx8(Fragment5, { children: entries2.map((entry, i) => {
2211
+ if (entry.kind === "separator")
2212
+ return /* @__PURE__ */ jsx8(UiMenuSeparator, { className: "band-plugin-react-menu-sep" }, `sep-${i}`);
2213
+ if (entry.kind === "group")
2214
+ return (
2215
+ /* @__PURE__ */ jsxs7(UiMenuGroup, { className: "band-plugin-react-menu-group", children: [
2216
+ /* @__PURE__ */ jsx8(UiMenuGroupLabel, { className: "band-plugin-react-menu-group-label", children: entry.label }),
2217
+ /* @__PURE__ */ jsx8(Entries, { entries: entry.items, indent })
2218
+ ] }, `group-${i}`)
2219
+ );
2220
+ const cls = `band-plugin-react-menu-item${indent ? " band-plugin-react-menu-has-check" : ""}`;
2221
+ if (entry.kind === "check")
2222
+ return /* @__PURE__ */ jsxs7(
2223
+ UiMenuCheckboxItem,
2224
+ {
2225
+ value: entry.id,
2226
+ label: entry.label,
2227
+ className: cls,
2228
+ checked: entry.checked,
2229
+ disabled: entry.disabled,
2230
+ onCheckedChange: (next) => entry.onCheckedChange(next),
2231
+ children: [
2232
+ /* @__PURE__ */ jsx8(UiMenuItemIndicator, { keepMounted: true, className: "band-plugin-react-menu-check", children: /* @__PURE__ */ jsx8("svg", { viewBox: "0 0 16 16", width: "12", height: "12", "aria-hidden": "true", children: /* @__PURE__ */ jsx8(
2233
+ "path",
2234
+ {
2235
+ d: "M3 8.5l3.2 3L13 4.5",
2236
+ fill: "none",
2237
+ stroke: "currentColor",
2238
+ strokeWidth: "1.8",
2239
+ strokeLinecap: "round",
2240
+ strokeLinejoin: "round"
2241
+ }
2242
+ ) }) }),
2243
+ /* @__PURE__ */ jsx8("span", { className: "band-plugin-react-menu-label", children: entry.label })
2244
+ ]
2245
+ },
2246
+ entry.id
2247
+ );
2248
+ return /* @__PURE__ */ jsxs7(
2249
+ UiMenuItem,
2250
+ {
2251
+ value: entry.id,
2252
+ label: entry.label,
2253
+ className: cls,
2254
+ disabled: entry.disabled,
2255
+ destructive: entry.danger,
2256
+ onSelect: () => {
2257
+ entry.onSelect();
2258
+ },
2259
+ children: [
2260
+ indent ? /* @__PURE__ */ jsx8("span", { className: "band-plugin-react-menu-check" }) : null,
2261
+ /* @__PURE__ */ jsx8("span", { className: "band-plugin-react-menu-label", children: entry.label }),
2262
+ entry.shortcut ? /* @__PURE__ */ jsx8("kbd", { className: "band-plugin-react-menu-keys", children: entry.shortcut }) : null,
2263
+ entry.hint ? /* @__PURE__ */ jsx8("span", { className: "band-plugin-react-menu-hint", children: entry.hint }) : null
2264
+ ]
2265
+ },
2266
+ entry.id
2267
+ );
2268
+ }) });
2269
+ }
2270
+ var CLEAR_LABELLEDBY = { "aria-labelledby": "" };
2271
+ function Menu({ label, trigger, items, side = "bottom", align = "start" }) {
2272
+ return /* @__PURE__ */ jsxs7(UiMenu, { children: [
2273
+ /* @__PURE__ */ jsx8(UiMenuTrigger, { render: trigger }),
2274
+ /* @__PURE__ */ jsx8(
2275
+ UiMenuContent,
2276
+ {
2277
+ "aria-label": label,
2278
+ ...CLEAR_LABELLEDBY,
2279
+ side,
2280
+ align,
2281
+ sideOffset: 4,
2282
+ className: "band-plugin-react-menu",
2283
+ children: /* @__PURE__ */ jsx8(Entries, { entries: items, indent: hasCheck(items) })
2284
+ }
2285
+ )
2286
+ ] });
2287
+ }
2288
+
2289
+ import {
2290
+ AlertDialog as UiAlertDialog,
2291
+ AlertDialogContent as UiAlertDialogContent,
2292
+ AlertDialogDescription as UiAlertDialogDescription,
2293
+ AlertDialogTitle as UiAlertDialogTitle
2294
+ } from "@ui-sdk/react/alert-dialog";
2295
+ import {
2296
+ Dialog as UiDialog,
2297
+ DialogContent as UiDialogContent,
2298
+ DialogDescription as UiDialogDescription,
2299
+ DialogTitle as UiDialogTitle
2300
+ } from "@ui-sdk/react/dialog";
2301
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
2302
+ function Dialog({
2303
+ open,
2304
+ onOpenChange,
2305
+ title,
2306
+ description,
2307
+ children,
2308
+ actions,
2309
+ closeLabel,
2310
+ size = "md",
2311
+ dismissible = true
2312
+ }) {
2313
+ const label = closeLabel ?? (actions ? "\u53D6\u6D88" : "\u5173\u95ED");
2314
+ return /* @__PURE__ */ jsx9(UiDialog, { open, onOpenChange: (next) => onOpenChange(next), dismissible, children: /* @__PURE__ */ jsxs8(
2315
+ UiDialogContent,
2316
+ {
2317
+ className: "band-plugin-react-dialog",
2318
+ "data-band-modal": open ? "" : void 0,
2319
+ "data-size": size,
2320
+ children: [
2321
+ /* @__PURE__ */ jsx9(UiDialogTitle, { className: "band-plugin-react-dialog-title", children: title }),
2322
+ description ? (
2323
+ /* @__PURE__ */ jsx9(UiDialogDescription, { render: /* @__PURE__ */ jsx9("div", {}), className: "band-plugin-react-dialog-desc", children: description })
2324
+ ) : null,
2325
+ children ? /* @__PURE__ */ jsx9("div", { className: "band-plugin-react-dialog-body", children }) : null,
2326
+ /* @__PURE__ */ jsxs8("div", { className: "band-plugin-react-dialog-actions", children: [
2327
+ /* @__PURE__ */ jsx9(
2328
+ "button",
2329
+ {
2330
+ type: "button",
2331
+ className: "btn",
2332
+ "aria-disabled": dismissible ? void 0 : true,
2333
+ onClick: () => {
2334
+ if (dismissible) onOpenChange(false);
2335
+ },
2336
+ children: label
2337
+ }
2338
+ ),
2339
+ actions
2340
+ ] })
2341
+ ]
2342
+ }
2343
+ ) });
2344
+ }
2345
+ function ConfirmDialog({
2346
+ open,
2347
+ onOpenChange,
2348
+ title,
2349
+ consequence,
2350
+ confirmLabel,
2351
+ cancelLabel = "\u53D6\u6D88",
2352
+ danger = false,
2353
+ busy = false,
2354
+ onConfirm
2355
+ }) {
2356
+ return /* @__PURE__ */ jsx9(UiAlertDialog, { open, onOpenChange: (next) => onOpenChange(next), dismissible: !busy, children: /* @__PURE__ */ jsxs8(
2357
+ UiAlertDialogContent,
2358
+ {
2359
+ className: "band-plugin-react-dialog",
2360
+ "data-band-modal": open ? "" : void 0,
2361
+ "data-size": "sm",
2362
+ children: [
2363
+ /* @__PURE__ */ jsx9(UiAlertDialogTitle, { className: "band-plugin-react-dialog-title", children: title }),
2364
+ /* @__PURE__ */ jsx9(UiAlertDialogDescription, { render: /* @__PURE__ */ jsx9("div", {}), className: "band-plugin-react-dialog-desc", children: consequence }),
2365
+ /* @__PURE__ */ jsxs8("div", { className: "band-plugin-react-dialog-actions", children: [
2366
+ /* @__PURE__ */ jsx9(
2367
+ "button",
2368
+ {
2369
+ type: "button",
2370
+ className: "btn",
2371
+ "data-autofocus": "",
2372
+ "aria-disabled": busy || void 0,
2373
+ onClick: () => {
2374
+ if (!busy) onOpenChange(false);
2375
+ },
2376
+ children: cancelLabel
2377
+ }
2378
+ ),
2379
+ /* @__PURE__ */ jsx9(
2380
+ "button",
2381
+ {
2382
+ type: "button",
2383
+ className: `btn primary${danger ? " band-plugin-react-dialog-danger" : ""}${busy ? " band-plugin-react-dialog-busy" : ""}`,
2384
+ "aria-disabled": busy || void 0,
2385
+ "aria-busy": busy || void 0,
2386
+ onClick: () => {
2387
+ if (!busy) onConfirm();
2388
+ },
2389
+ children: confirmLabel
2390
+ }
2391
+ )
2392
+ ] })
2393
+ ]
2394
+ }
2395
+ ) });
2396
+ }
2397
+
2398
+ import { imeOwns, withImeGuard as withImeGuard3 } from "@kanyun-ai-infra/band-plugin-sdk/keys";
2399
+ import {
2400
+ Autocomplete,
2401
+ AutocompleteContent,
2402
+ AutocompleteInput,
2403
+ AutocompleteItem,
2404
+ AutocompleteItemText,
2405
+ AutocompleteList
2406
+ } from "@ui-sdk/react/autocomplete";
2407
+ import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "@ui-sdk/react/collapsible";
2408
+ import {
2409
+ ComboboxCreate,
2410
+ ComboboxGroup,
2411
+ ComboboxGroupLabel,
2412
+ ComboboxInput,
2413
+ ComboboxItemText,
2414
+ Combobox as UiCombobox,
2415
+ ComboboxContent as UiComboboxContent,
2416
+ ComboboxItem as UiComboboxItem,
2417
+ createComboboxController
2418
+ } from "@ui-sdk/react/combobox";
2419
+ import { useEffect as useEffect3, useId as useId4, useMemo as useMemo2, useRef as useRef5, useState as useState4 } from "react";
2420
+ import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
2421
+ function sectionsOf(items) {
2422
+ const byTitle = /* @__PURE__ */ new Map();
2423
+ for (const item of items) {
2424
+ const title = item.group ?? null;
2425
+ const bucket = byTitle.get(title);
2426
+ if (bucket) bucket.push(item);
2427
+ else byTitle.set(title, [item]);
2428
+ }
2429
+ return [...byTitle].map(([title, list]) => ({ title, items: list }));
2430
+ }
2431
+ function filterCandidates(pool, text) {
2432
+ const t = text.trim().toLowerCase();
2433
+ return sectionsOf(pool).flatMap((sec) => sec.items).filter(
2434
+ (it) => t === "" || [it.label, it.meta ?? "", it.keywords ?? ""].some((x) => x.toLowerCase().includes(t))
2435
+ );
2436
+ }
2437
+ var COMBO_LOADING_TEXT = "\u52A0\u8F7D\u4E2D\u2026";
2438
+ function ChoiceCombobox({
2439
+ label,
2440
+ items,
2441
+ value,
2442
+ onChange,
2443
+ multiple = false,
2444
+ placeholder,
2445
+ emptyText,
2446
+ onCreate,
2447
+ createLabel,
2448
+ disabled = false,
2449
+ loading = false,
2450
+ error
2451
+ }) {
2452
+ const [query, setQueryState] = useState4("");
2453
+ const [open, setOpenState] = useState4(false);
2454
+ const openRef = useRef5(false);
2455
+ const queryRef = useRef5("");
2456
+ const setOpen = (next) => {
2457
+ openRef.current = next;
2458
+ if (!next) highlighted.current = void 0;
2459
+ setOpenState(next);
2460
+ };
2461
+ const setQuery = (next) => {
2462
+ queryRef.current = next;
2463
+ setQueryState(next);
2464
+ };
2465
+ const ctl = useMemo2(() => createComboboxController(), []);
2466
+ const [field, setField] = useState4(null);
2467
+ const highlighted = useRef5(void 0);
2468
+ const q = query.trim();
2469
+ const pool = useMemo2(() => items.filter((it) => !value.includes(it.value)), [items, value]);
2470
+ const candidates = (text) => filterCandidates(pool, text);
2471
+ const shown = useMemo2(() => sectionsOf(filterCandidates(pool, q)), [pool, q]);
2472
+ const exact = q !== "" && items.some((it) => it.label === q);
2473
+ const canCreate = onCreate !== void 0 && q !== "" && !exact;
2474
+ function pick(v) {
2475
+ if (multiple) {
2476
+ if (!value.includes(v)) onChange([...value, v]);
2477
+ } else {
2478
+ onChange([v]);
2479
+ setOpen(false);
2480
+ }
2481
+ setQuery("");
2482
+ }
2483
+ function remove(v) {
2484
+ onChange(value.filter((x) => x !== v));
2485
+ field?.querySelector("input")?.focus();
2486
+ }
2487
+ const onComboKeyCapture = withImeGuard3((e) => {
2488
+ if (e.key === "Enter") {
2489
+ if (!openRef.current) return;
2490
+ e.preventDefault();
2491
+ e.stopPropagation();
2492
+ const text = queryRef.current.trim();
2493
+ const list = candidates(text);
2494
+ const hl = highlighted.current;
2495
+ const onCreateRow = hl === null && canCreate;
2496
+ const target = onCreateRow ? void 0 : typeof hl === "string" && list.some((c) => c.value === hl) ? hl : list[0]?.value;
2497
+ if (target !== void 0) pick(target);
2498
+ else if (onCreate !== void 0 && text !== "" && !items.some((it) => it.label === text)) {
2499
+ onCreate(text);
2500
+ setQuery("");
2501
+ if (!multiple) setOpen(false);
2502
+ }
2503
+ return;
2504
+ }
2505
+ if (e.key === " " && multiple && openRef.current && queryRef.current === "") {
2506
+ const list = candidates("");
2507
+ const hl = highlighted.current;
2508
+ const v = typeof hl === "string" && list.some((c) => c.value === hl) ? hl : list[0]?.value;
2509
+ if (v === void 0) return;
2510
+ e.preventDefault();
2511
+ e.stopPropagation();
2512
+ pick(v);
2513
+ }
2514
+ });
2515
+ const onComboKey = withImeGuard3((e) => {
2516
+ if (e.key === "Escape" && openRef.current) {
2517
+ e.stopPropagation();
2518
+ setOpen(false);
2519
+ return;
2520
+ }
2521
+ if (e.key === "Backspace" && !multiple && query === "" && value.length > 0) {
2522
+ const last = value[value.length - 1];
2523
+ if (last !== void 0) {
2524
+ e.preventDefault();
2525
+ remove(last);
2526
+ }
2527
+ }
2528
+ });
2529
+ const selected = value.map((v) => ({
2530
+ value: v,
2531
+ label: items.find((it) => it.value === v)?.label ?? v
2532
+ }));
2533
+ const state = error ? error : loading ? COMBO_LOADING_TEXT : "";
2534
+ const common = {
2535
+ open,
2536
+ onOpenChange: (next) => setOpen(next),
2537
+ query,
2538
+ onQueryChange: (next, details) => {
2539
+ if (details.reason === "input-change") {
2540
+ setQuery(next);
2541
+ highlighted.current = void 0;
2542
+ } else if (details.reason === "item-press" || details.reason === "clear-press") setQuery("");
2543
+ },
2544
+ itemToLabel: (v) => items.find((it) => it.value === v)?.label ?? v,
2545
+ controller: ctl,
2546
+ autoHighlight: "always",
2547
+ disabled,
2548
+ onHighlight: (v) => {
2549
+ highlighted.current = v;
2550
+ }
2551
+ };
2552
+ const parts = /* @__PURE__ */ jsxs9(Fragment6, { children: [
2553
+ /* @__PURE__ */ jsx10("div", { className: "band-plugin-react-combo-field field-host", ref: setField, children: /* @__PURE__ */ jsx10(
2554
+ ComboboxInput,
2555
+ {
2556
+ className: "field bare",
2557
+ "aria-label": label,
2558
+ autoComplete: "off",
2559
+ placeholder: placeholder ?? label,
2560
+ onFocus: () => ctl.setOpen(true, { reason: "trigger-press" }),
2561
+ onClick: () => ctl.setOpen(true, { reason: "trigger-press" }),
2562
+ onBlur: () => setOpen(false),
2563
+ onKeyDownCapture: onComboKeyCapture,
2564
+ onKeyDown: onComboKey
2565
+ }
2566
+ ) }),
2567
+ open && /* @__PURE__ */ jsxs9(
2568
+ UiComboboxContent,
2569
+ {
2570
+ anchor: field,
2571
+ sideOffset: 6,
2572
+ "aria-label": label,
2573
+ "aria-busy": loading && !error ? true : void 0,
2574
+ className: "band-plugin-react-combo-pop",
2575
+ children: [
2576
+ shown.map((section) => {
2577
+ const rows = section.items.map((it) => /* @__PURE__ */ jsxs9(
2578
+ UiComboboxItem,
2579
+ {
2580
+ value: it.value,
2581
+ label: it.label,
2582
+ keywords: [it.meta ?? "", it.keywords ?? ""].filter((k) => k !== ""),
2583
+ className: "band-plugin-react-combo-opt",
2584
+ children: [
2585
+ /* @__PURE__ */ jsx10(ComboboxItemText, { className: "band-plugin-react-combo-label" }),
2586
+ it.meta !== void 0 && /* @__PURE__ */ jsx10("span", { className: "band-plugin-react-combo-meta", children: it.meta })
2587
+ ]
2588
+ },
2589
+ it.value
2590
+ ));
2591
+ return section.title === null ? /* @__PURE__ */ jsx10("div", { className: "band-plugin-react-combo-section", children: rows }, "\\u0000") : /* @__PURE__ */ jsxs9(ComboboxGroup, { className: "band-plugin-react-combo-section", children: [
2592
+ /* @__PURE__ */ jsx10(ComboboxGroupLabel, { className: "band-plugin-react-combo-group", children: section.title }),
2593
+ rows
2594
+ ] }, section.title);
2595
+ }),
2596
+ q !== "" && shown.length === 0 && !loading && !error &&
2597
+ /* @__PURE__ */ jsx10("div", { className: "band-plugin-react-combo-empty", children: emptyText ?? `\u6CA1\u6709\u5339\u914D\u7684${label}` }),
2598
+ state !== "" && /* @__PURE__ */ jsx10(
2599
+ "div",
2600
+ {
2601
+ className: "band-plugin-react-combo-state",
2602
+ role: "presentation",
2603
+ ...error ? { "data-err": "" } : {},
2604
+ children: state
2605
+ }
2606
+ ),
2607
+ canCreate && /* @__PURE__ */ jsxs9(
2608
+ ComboboxCreate,
2609
+ {
2610
+ className: "band-plugin-react-combo-opt",
2611
+ onCreate: (name) => {
2612
+ onCreate?.(name);
2613
+ },
2614
+ children: [
2615
+ /* @__PURE__ */ jsx10("span", { className: "band-plugin-react-combo-plus", "aria-hidden": "true", children: "+" }),
2616
+ /* @__PURE__ */ jsx10("span", { className: "band-plugin-react-combo-label", children: createLabel ? createLabel(q) : `\u65B0\u5EFA\u300C${q}\u300D` })
2617
+ ]
2618
+ }
2619
+ )
2620
+ ]
2621
+ }
2622
+ )
2623
+ ] });
2624
+ return /* @__PURE__ */ jsxs9("div", { className: "band-plugin-react-combo", children: [
2625
+ /* @__PURE__ */ jsx10("span", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true", children: open ? state : "" }),
2626
+ selected.length > 0 && /* @__PURE__ */ jsx10("ul", { className: "band-plugin-react-combo-picked", "aria-label": `\u5DF2\u9009${label}`, children: selected.map((it) => /* @__PURE__ */ jsxs9("li", { className: "band-plugin-react-combo-chip", children: [
2627
+ it.label,
2628
+ /* @__PURE__ */ jsx10(
2629
+ "button",
2630
+ {
2631
+ type: "button",
2632
+ "aria-label": `\u79FB\u9664 ${it.label}`,
2633
+ disabled,
2634
+ onClick: () => remove(it.value),
2635
+ children: "\xD7"
2636
+ }
2637
+ )
2638
+ ] }, it.value)) }),
2639
+ multiple ? /* @__PURE__ */ jsx10(
2640
+ UiCombobox,
2641
+ {
2642
+ ...common,
2643
+ multiple: true,
2644
+ value: [...value],
2645
+ onValueChange: (next) => {
2646
+ onChange(next);
2647
+ },
2648
+ children: parts
2649
+ }
2650
+ ) : /* @__PURE__ */ jsx10(
2651
+ UiCombobox,
2652
+ {
2653
+ ...common,
2654
+ value: value[0] ?? null,
2655
+ onValueChange: (next) => {
2656
+ if (next !== null) onChange([next]);
2657
+ setOpen(false);
2658
+ },
2659
+ children: parts
2660
+ }
2661
+ )
2662
+ ] });
2663
+ }
2664
+ function FreeTextCombobox({
2665
+ label,
2666
+ items,
2667
+ value,
2668
+ onChange,
2669
+ placeholder,
2670
+ disabled = false,
2671
+ loading = false,
2672
+ error,
2673
+ inputProps,
2674
+ autoOpen = false
2675
+ }) {
2676
+ const text = value[0] ?? "";
2677
+ const [open, setOpen] = useState4(false);
2678
+ const [anchor, setAnchor] = useState4(text);
2679
+ const [field, setField] = useState4(null);
2680
+ const enterOwned = useRef5(false);
2681
+ const itemsKey = items.map((it) => it.value).join("\0");
2682
+ useEffect3(() => {
2683
+ if (field?.querySelector("input") === document.activeElement) return;
2684
+ setAnchor(text);
2685
+ setOpen(autoOpen && items.length > 0);
2686
+ }, [itemsKey, autoOpen]);
2687
+ useEffect3(() => {
2688
+ if (!open) return;
2689
+ const onFocus = (e) => {
2690
+ if (e.target !== field?.querySelector("input")) setOpen(false);
2691
+ };
2692
+ document.addEventListener("focusin", onFocus);
2693
+ return () => document.removeEventListener("focusin", onFocus);
2694
+ }, [open, field]);
2695
+ const q = text.trim().toLowerCase();
2696
+ const shown = text === anchor || q === "" || items.some((it) => it.value === text) ? items : items.filter(
2697
+ (it) => [it.label, it.value, it.meta ?? "", it.keywords ?? ""].some(
2698
+ (x) => x.toLowerCase().includes(q)
2699
+ )
2700
+ );
2701
+ const state = error ? error : loading ? COMBO_LOADING_TEXT : "";
2702
+ const expanded = open && (shown.length > 0 || state !== "") && !disabled;
2703
+ return /* @__PURE__ */ jsxs9("div", { className: "band-plugin-react-combo", children: [
2704
+ /* @__PURE__ */ jsx10("span", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true", children: expanded ? state : "" }),
2705
+ /* @__PURE__ */ jsxs9(
2706
+ Autocomplete,
2707
+ {
2708
+ value: text,
2709
+ onValueChange: (next) => {
2710
+ onChange(next === "" ? [] : [next]);
2711
+ },
2712
+ open: expanded,
2713
+ onOpenChange: (next) => setOpen(next),
2714
+ openOnFocus: true,
2715
+ filter: false,
2716
+ disabled,
2717
+ children: [
2718
+ /* @__PURE__ */ jsx10(
2719
+ "div",
2720
+ {
2721
+ className: "band-plugin-react-combo-field field-host",
2722
+ ref: setField,
2723
+ onKeyDown: withImeGuard3((e) => {
2724
+ if (e.key === "Enter" && enterOwned.current) e.preventDefault();
2725
+ }),
2726
+ children: /* @__PURE__ */ jsx10(
2727
+ AutocompleteInput,
2728
+ {
2729
+ className: "field bare",
2730
+ "aria-label": label,
2731
+ autoComplete: "off",
2732
+ spellCheck: false,
2733
+ placeholder,
2734
+ onFocus: () => setAnchor(text),
2735
+ onKeyDownCapture: (e) => {
2736
+ if (imeOwns(e)) e.stopPropagation();
2737
+ else if (e.key === "Enter") enterOwned.current = expanded;
2738
+ },
2739
+ id: inputProps?.id,
2740
+ maxLength: inputProps?.maxLength,
2741
+ "aria-invalid": inputProps?.["aria-invalid"],
2742
+ "aria-describedby": inputProps?.["aria-describedby"]
2743
+ }
2744
+ )
2745
+ }
2746
+ ),
2747
+ /* @__PURE__ */ jsxs9(
2748
+ AutocompleteContent,
2749
+ {
2750
+ anchor: field,
2751
+ sideOffset: 6,
2752
+ "aria-label": label,
2753
+ "aria-busy": loading && !error ? true : void 0,
2754
+ className: "band-plugin-react-combo-pop band-plugin-react-combo-pop-free",
2755
+ children: [
2756
+ /* @__PURE__ */ jsx10(AutocompleteList, { "aria-label": label, "aria-labelledby": "", children: shown.map((it) => /* @__PURE__ */ jsxs9(
2757
+ AutocompleteItem,
2758
+ {
2759
+ value: it.value,
2760
+ label: it.value,
2761
+ keywords: [it.label, it.meta ?? "", it.keywords ?? ""].filter((k) => k !== ""),
2762
+ className: "band-plugin-react-combo-opt",
2763
+ children: [
2764
+ /* @__PURE__ */ jsx10(AutocompleteItemText, { className: "band-plugin-react-combo-label", children: it.label }),
2765
+ it.meta !== void 0 && /* @__PURE__ */ jsx10("span", { className: "band-plugin-react-combo-meta", children: it.meta })
2766
+ ]
2767
+ },
2768
+ it.value
2769
+ )) }),
2770
+ state !== "" && /* @__PURE__ */ jsx10(
2771
+ "div",
2772
+ {
2773
+ className: "band-plugin-react-combo-state",
2774
+ role: "presentation",
2775
+ ...error ? { "data-err": "" } : {},
2776
+ children: state
2777
+ }
2778
+ )
2779
+ ]
2780
+ }
2781
+ )
2782
+ ]
2783
+ }
2784
+ )
2785
+ ] });
2786
+ }
2787
+ function Combobox(props) {
2788
+ return props.allowCustom && !props.multiple ? /* @__PURE__ */ jsx10(FreeTextCombobox, { ...props }) : /* @__PURE__ */ jsx10(ChoiceCombobox, { ...props });
2789
+ }
2790
+ var TAG_SPLIT = /[,,\n\t]/;
2791
+ function splitTags(text) {
2792
+ return text.split(TAG_SPLIT).map((s) => s.trim()).filter((s) => s !== "");
2793
+ }
2794
+ function TagInput({
2795
+ label,
2796
+ value,
2797
+ onChange,
2798
+ placeholder,
2799
+ hint,
2800
+ disabled = false,
2801
+ id
2802
+ }) {
2803
+ const auto = useId4();
2804
+ const inputId = id ?? auto;
2805
+ const hintId = `${inputId}-hint`;
2806
+ const [draft, setDraft] = useState4("");
2807
+ const [dup, setDup] = useState4(null);
2808
+ const [dupChip, setDupChip] = useState4(null);
2809
+ const timer = useRef5(null);
2810
+ const input = useRef5(null);
2811
+ const removers = useRef5(/* @__PURE__ */ new Map());
2812
+ useEffect3(
2813
+ () => () => {
2814
+ if (timer.current !== null) clearTimeout(timer.current);
2815
+ },
2816
+ []
2817
+ );
2818
+ function flash(name) {
2819
+ setDup(name);
2820
+ setDupChip(name);
2821
+ if (timer.current !== null) clearTimeout(timer.current);
2822
+ timer.current = setTimeout(() => {
2823
+ setDup(null);
2824
+ setDupChip(null);
2825
+ timer.current = null;
2826
+ }, 1800);
2827
+ }
2828
+ function clearDup() {
2829
+ if (timer.current !== null) {
2830
+ clearTimeout(timer.current);
2831
+ timer.current = null;
2832
+ }
2833
+ setDup(null);
2834
+ setDupChip(null);
2835
+ }
2836
+ function add(raw) {
2837
+ const parts = splitTags(raw);
2838
+ if (parts.length === 0) return;
2839
+ const seen = new Set(value);
2840
+ const added = [];
2841
+ let repeated = null;
2842
+ for (const part of parts) {
2843
+ if (seen.has(part)) {
2844
+ repeated = repeated ?? part;
2845
+ continue;
2846
+ }
2847
+ seen.add(part);
2848
+ added.push(part);
2849
+ }
2850
+ if (repeated !== null) flash(repeated);
2851
+ else clearDup();
2852
+ if (added.length > 0) onChange([...value, ...added]);
2853
+ }
2854
+ function removeAt(i) {
2855
+ const gone = value[i];
2856
+ const next = value[i + 1] ?? value[i - 1];
2857
+ const target = next !== void 0 ? removers.current.get(next) : void 0;
2858
+ (target ?? input.current)?.focus();
2859
+ onChange(value.filter((_, k) => k !== i));
2860
+ if (gone !== void 0 && gone === dupChip) clearDup();
2861
+ }
2862
+ const onTagsKey = withImeGuard3((e) => {
2863
+ if (e.key === "Enter") {
2864
+ e.preventDefault();
2865
+ if (draft.trim() === "") return;
2866
+ add(draft);
2867
+ setDraft("");
2868
+ return;
2869
+ }
2870
+ if (e.key === "," || e.key === "\uFF0C") {
2871
+ if (draft.trim() === "") return;
2872
+ e.preventDefault();
2873
+ add(draft);
2874
+ setDraft("");
2875
+ return;
2876
+ }
2877
+ if (e.key === "Backspace" && draft === "" && value.length > 0) {
2878
+ e.preventDefault();
2879
+ const last = value[value.length - 1];
2880
+ if (last !== void 0) {
2881
+ onChange(value.slice(0, -1));
2882
+ if (dupChip === last) clearDup();
2883
+ }
2884
+ }
2885
+ });
2886
+ return /* @__PURE__ */ jsxs9(Fragment6, { children: [
2887
+ /* @__PURE__ */ jsxs9("div", { className: "band-plugin-react-tags field-host", children: [
2888
+ value.map((tag, i) => /* @__PURE__ */ jsxs9(
2889
+ "span",
2890
+ {
2891
+ className: "band-plugin-react-tag",
2892
+ ...dupChip === tag ? { "data-dup": "" } : {},
2893
+ children: [
2894
+ tag,
2895
+ /* @__PURE__ */ jsx10(
2896
+ "button",
2897
+ {
2898
+ type: "button",
2899
+ "aria-label": `\u79FB\u9664 ${tag}`,
2900
+ disabled,
2901
+ ref: (el) => {
2902
+ if (el) removers.current.set(tag, el);
2903
+ else removers.current.delete(tag);
2904
+ },
2905
+ onClick: () => removeAt(i),
2906
+ children: "\xD7"
2907
+ }
2908
+ )
2909
+ ]
2910
+ },
2911
+ tag
2912
+ )),
2913
+ /* @__PURE__ */ jsx10(
2914
+ "input",
2915
+ {
2916
+ ref: input,
2917
+ id: inputId,
2918
+ className: "field bare",
2919
+ type: "text",
2920
+ "aria-label": label,
2921
+ "aria-describedby": hintId,
2922
+ autoComplete: "off",
2923
+ disabled,
2924
+ placeholder: value.length === 0 ? placeholder ?? "\u7C98\u8D34\u6216\u8F93\u5165\uFF0C\u56DE\u8F66\u786E\u8BA4" : "",
2925
+ value: draft,
2926
+ onChange: (e) => setDraft(e.target.value),
2927
+ onKeyDown: onTagsKey,
2928
+ onPaste: (e) => {
2929
+ const text = e.clipboardData.getData("text");
2930
+ if (!TAG_SPLIT.test(text)) return;
2931
+ e.preventDefault();
2932
+ const el = e.currentTarget;
2933
+ const at = el.selectionStart ?? draft.length;
2934
+ const end = el.selectionEnd ?? at;
2935
+ add(draft.slice(0, at) + text + draft.slice(end));
2936
+ setDraft("");
2937
+ }
2938
+ }
2939
+ )
2940
+ ] }),
2941
+ /* @__PURE__ */ jsx10(
2942
+ "p",
2943
+ {
2944
+ className: "band-plugin-react-tag-hint",
2945
+ id: hintId,
2946
+ "aria-live": "polite",
2947
+ ...dup !== null ? { "data-err": "" } : {},
2948
+ children: dup !== null ? `\u300C${dup}\u300D\u91CD\u590D\u4E86\uFF0C\u5DF2\u8DF3\u8FC7` : hint
2949
+ }
2950
+ )
2951
+ ] });
2952
+ }
2953
+ function facetedCount(rows, groups, selection, groupKey, value) {
2954
+ let n = 0;
2955
+ for (const row of rows) {
2956
+ if (row[groupKey] !== value) continue;
2957
+ let ok = true;
2958
+ for (const g of groups) {
2959
+ if (g.key === groupKey) continue;
2960
+ const picked = selection[g.key] ?? [];
2961
+ if (picked.length === 0) continue;
2962
+ const v = row[g.key];
2963
+ if (v === void 0 || !picked.includes(v)) {
2964
+ ok = false;
2965
+ break;
2966
+ }
2967
+ }
2968
+ if (ok) n++;
2969
+ }
2970
+ return n;
2971
+ }
2972
+ function filterRows(rows, groups, selection) {
2973
+ return rows.filter(
2974
+ (row) => groups.every((g) => {
2975
+ const picked = selection[g.key] ?? [];
2976
+ if (picked.length === 0) return true;
2977
+ const v = row[g.key];
2978
+ return v !== void 0 && picked.includes(v);
2979
+ })
2980
+ );
2981
+ }
2982
+ function FilterMenu({
2983
+ groups,
2984
+ rows,
2985
+ value,
2986
+ onChange,
2987
+ emptyText
2988
+ }) {
2989
+ const firstHead = useRef5(null);
2990
+ const root = useRef5(null);
2991
+ const refocus = () => (firstHead.current ?? root.current)?.focus();
2992
+ function toggle(groupKey, option) {
2993
+ const picked = value[groupKey] ?? [];
2994
+ const next = picked.includes(option) ? picked.filter((x) => x !== option) : [...picked, option];
2995
+ const merged = { ...value, [groupKey]: next };
2996
+ if (next.length === 0) delete merged[groupKey];
2997
+ onChange(merged);
2998
+ }
2999
+ function clear() {
3000
+ refocus();
3001
+ onChange({});
3002
+ }
3003
+ function removeChip(groupKey, option) {
3004
+ refocus();
3005
+ toggle(groupKey, option);
3006
+ }
3007
+ const chips = Object.entries(value).flatMap(([key, values]) => {
3008
+ const group = groups.find((g) => g.key === key);
3009
+ return values.map((v) => ({
3010
+ key,
3011
+ value: v,
3012
+ label: group?.options.find((o) => o.value === v)?.label ?? v
3013
+ }));
3014
+ });
3015
+ return /* @__PURE__ */ jsxs9("div", { className: "band-plugin-react-filter", ref: root, tabIndex: -1, children: [
3016
+ /* @__PURE__ */ jsxs9("div", { className: "band-plugin-react-filter-chips", children: [
3017
+ chips.map((chip) => /* @__PURE__ */ jsxs9("span", { className: "band-plugin-react-filter-chip", children: [
3018
+ chip.label,
3019
+ /* @__PURE__ */ jsx10(
3020
+ "button",
3021
+ {
3022
+ type: "button",
3023
+ "aria-label": `\u79FB\u9664 ${chip.label} \u7B5B\u9009`,
3024
+ onClick: () => removeChip(chip.key, chip.value),
3025
+ children: "\xD7"
3026
+ }
3027
+ )
3028
+ ] }, `${chip.key}\0${chip.value}`)),
3029
+ chips.length > 0 && /* @__PURE__ */ jsx10("button", { type: "button", className: "band-plugin-react-filter-clear", onClick: clear, children: "\u6E05\u7A7A" })
3030
+ ] }),
3031
+ groups.map((g, gi) => {
3032
+ const picked = value[g.key] ?? [];
3033
+ return (
3034
+ /* @__PURE__ */ jsxs9(Collapsible, { defaultOpen: true, className: "band-plugin-react-filter-group-box", children: [
3035
+ /* @__PURE__ */ jsxs9(
3036
+ CollapsibleTrigger,
3037
+ {
3038
+ ref: gi === 0 ? firstHead : void 0,
3039
+ className: "band-plugin-react-filter-group",
3040
+ children: [
3041
+ g.label,
3042
+ /* @__PURE__ */ jsx10("span", { className: "band-plugin-react-filter-group-count", children: picked.length })
3043
+ ]
3044
+ }
3045
+ ),
3046
+ /* @__PURE__ */ jsxs9(CollapsiblePanel, { keepMounted: true, children: [
3047
+ g.options.length === 0 && /* @__PURE__ */ jsx10("p", { className: "band-plugin-react-filter-empty", children: emptyText ?? "\u6CA1\u6709\u53EF\u7B5B\u7684" }),
3048
+ g.options.map((o) => /* @__PURE__ */ jsxs9("label", { className: "band-plugin-react-filter-opt choice", children: [
3049
+ /* @__PURE__ */ jsx10(
3050
+ "input",
3051
+ {
3052
+ type: "checkbox",
3053
+ className: "checkbox",
3054
+ checked: picked.includes(o.value),
3055
+ onChange: () => toggle(g.key, o.value)
3056
+ }
3057
+ ),
3058
+ o.label,
3059
+ /* @__PURE__ */ jsx10("span", { className: "band-plugin-react-filter-count", children: facetedCount(rows, groups, value, g.key, o.value) })
3060
+ ] }, o.value))
3061
+ ] })
3062
+ ] }, g.key)
3063
+ );
3064
+ })
3065
+ ] });
3066
+ }
3067
+
3068
+ import { withImeGuard as withImeGuard4 } from "@kanyun-ai-infra/band-plugin-sdk/keys";
3069
+ import { useEffect as useEffect4, useRef as useRef6, useSyncExternalStore as useSyncExternalStore3 } from "react";
3070
+ import { createPortal } from "react-dom";
3071
+
3072
+ var MAX_TOASTS = 3;
3073
+ var OK_MS = 4e3;
3074
+ var LEAVE_MS = 2e3;
3075
+ var TOAST_CLOSE_LABEL = "\u5173\u95ED";
3076
+ var EMPTY = [];
3077
+ var entries = [];
3078
+ var listeners = /* @__PURE__ */ new Set();
3079
+ var snapshot = EMPTY;
3080
+ var seq = 0;
3081
+ var pageHidden = false;
3082
+ function subscribeToasts(listener) {
3083
+ listeners.add(listener);
3084
+ return () => {
3085
+ listeners.delete(listener);
3086
+ };
3087
+ }
3088
+ function toastsSnapshot() {
3089
+ return snapshot;
3090
+ }
3091
+ function emptyToasts() {
3092
+ return EMPTY;
3093
+ }
3094
+ function publish() {
3095
+ snapshot = entries.length === 0 ? EMPTY : entries.map((e) => ({
3096
+ id: e.id,
3097
+ kind: e.kind,
3098
+ text: e.text,
3099
+ detail: e.detail,
3100
+ action: e.action
3101
+ }));
3102
+ for (const listener of listeners) listener();
3103
+ }
3104
+ function clearTimer(entry) {
3105
+ if (entry.timer !== void 0) {
3106
+ clearTimeout(entry.timer);
3107
+ entry.timer = void 0;
3108
+ }
3109
+ }
3110
+ function arm(id, ms) {
3111
+ const entry = entries.find((e) => e.id === id);
3112
+ if (!entry) return;
3113
+ clearTimer(entry);
3114
+ entry.left = ms;
3115
+ if (entry.pausedBy.size > 0) return;
3116
+ entry.deadline = Date.now() + ms;
3117
+ entry.timer = setTimeout(() => dismissToast(id), ms);
3118
+ }
3119
+ function toast(opts) {
3120
+ const kind = opts.kind ?? "ok";
3121
+ const id = opts.id ?? `toast-${++seq}`;
3122
+ const existing = entries.find((e) => e.id === id);
3123
+ if (existing) {
3124
+ clearTimer(existing);
3125
+ existing.kind = kind;
3126
+ existing.text = opts.text;
3127
+ existing.detail = opts.detail;
3128
+ existing.action = opts.action;
3129
+ } else {
3130
+ if (entries.length >= MAX_TOASTS) {
3131
+ const i = entries.findIndex((e) => e.kind !== "busy");
3132
+ const [dropped] = entries.splice(i === -1 ? 0 : i, 1);
3133
+ if (dropped) clearTimer(dropped);
3134
+ }
3135
+ entries.push({
3136
+ id,
3137
+ kind,
3138
+ text: opts.text,
3139
+ detail: opts.detail,
3140
+ action: opts.action,
3141
+ pausedBy: new Set(pageHidden ? ["hidden"] : [])
3142
+ });
3143
+ }
3144
+ if (kind === "ok") arm(id, OK_MS);
3145
+ publish();
3146
+ return id;
3147
+ }
3148
+ function pauseToast(id, by = "pointer") {
3149
+ const entry = entries.find((e) => e.id === id);
3150
+ if (!entry) return;
3151
+ entry.pausedBy.add(by);
3152
+ clearTimer(entry);
3153
+ }
3154
+ function resumeToast(id, by = "pointer") {
3155
+ const entry = entries.find((e) => e.id === id);
3156
+ if (!entry) return;
3157
+ entry.pausedBy.delete(by);
3158
+ if (entry.kind !== "ok") return;
3159
+ if (entry.pausedBy.size === 0) arm(id, LEAVE_MS);
3160
+ else entry.left = LEAVE_MS;
3161
+ }
3162
+ function setToastPageHidden(hidden) {
3163
+ if (pageHidden === hidden) return;
3164
+ pageHidden = hidden;
3165
+ for (const entry of entries) {
3166
+ if (hidden) {
3167
+ if (entry.timer !== void 0 && entry.deadline !== void 0) {
3168
+ entry.left = Math.max(entry.deadline - Date.now(), 0);
3169
+ }
3170
+ entry.pausedBy.add("hidden");
3171
+ clearTimer(entry);
3172
+ } else {
3173
+ entry.pausedBy.delete("hidden");
3174
+ if (entry.kind === "ok" && entry.pausedBy.size === 0) {
3175
+ arm(entry.id, entry.left && entry.left > 0 ? entry.left : LEAVE_MS);
3176
+ }
3177
+ }
3178
+ }
3179
+ }
3180
+ function syncToastPause(id, paused) {
3181
+ const entry = entries.find((e) => e.id === id);
3182
+ if (!entry) return;
3183
+ const wasPaused = entry.pausedBy.size > 0;
3184
+ entry.pausedBy.delete("pointer");
3185
+ entry.pausedBy.delete("focus");
3186
+ if (paused.pointer) entry.pausedBy.add("pointer");
3187
+ if (paused.focus) entry.pausedBy.add("focus");
3188
+ if (entry.pausedBy.size > 0) {
3189
+ if (entry.timer !== void 0 && entry.deadline !== void 0 && pageHidden) {
3190
+ entry.left = Math.max(entry.deadline - Date.now(), 0);
3191
+ }
3192
+ clearTimer(entry);
3193
+ } else if (wasPaused && entry.kind === "ok") arm(id, LEAVE_MS);
3194
+ }
3195
+ function dismissToast(id) {
3196
+ const i = entries.findIndex((e) => e.id === id);
3197
+ if (i < 0) return;
3198
+ const [entry] = entries.splice(i, 1);
3199
+ if (entry) clearTimer(entry);
3200
+ publish();
3201
+ }
3202
+ function dismissAllToasts() {
3203
+ for (const entry of entries) clearTimer(entry);
3204
+ entries = [];
3205
+ publish();
3206
+ }
3207
+
3208
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
3209
+ var MODAL_SELECTOR = "dialog:modal, dialog[open][data-band-layer], [data-band-modal]";
3210
+ var MODAL_FALLBACK = "dialog[open][data-band-layer], [data-band-modal]";
3211
+ var modalOrder = /* @__PURE__ */ new Map();
3212
+ var modalSeq = 0;
3213
+ function openModals() {
3214
+ try {
3215
+ return [...document.querySelectorAll(MODAL_SELECTOR)];
3216
+ } catch {
3217
+ return [...document.querySelectorAll(MODAL_FALLBACK)];
3218
+ }
3219
+ }
3220
+ function modalTarget() {
3221
+ if (typeof document === "undefined") return null;
3222
+ const modals = openModals();
3223
+ const live = new Set(modals);
3224
+ for (const el of [...modalOrder.keys()]) if (!live.has(el)) modalOrder.delete(el);
3225
+ for (const el of modals) if (!modalOrder.has(el)) modalOrder.set(el, ++modalSeq);
3226
+ let top = null;
3227
+ let seq2 = -1;
3228
+ for (const el of modals) {
3229
+ const n = modalOrder.get(el) ?? 0;
3230
+ if (n > seq2) {
3231
+ seq2 = n;
3232
+ top = el;
3233
+ }
3234
+ }
3235
+ return top ?? null;
3236
+ }
3237
+ var modalListeners = /* @__PURE__ */ new Set();
3238
+ var modalObserver = null;
3239
+ var modalSnapshot = null;
3240
+ function topChanged() {
3241
+ const next = modalTarget();
3242
+ if (next === modalSnapshot) return;
3243
+ modalSnapshot = next;
3244
+ for (const fn of [...modalListeners]) fn();
3245
+ }
3246
+ if (typeof document !== "undefined") {
3247
+ document.addEventListener(
3248
+ "toggle",
3249
+ (e) => {
3250
+ const el = e.target;
3251
+ if (!el || typeof el.tagName !== "string") return;
3252
+ let opened;
3253
+ if (el.tagName === "DIALOG") opened = el.open;
3254
+ else if (el.hasAttribute("data-band-modal"))
3255
+ opened = e.newState !== "closed";
3256
+ else return;
3257
+ if (opened) {
3258
+ if (!modalOrder.has(el)) modalOrder.set(el, ++modalSeq);
3259
+ } else {
3260
+ modalOrder.delete(el);
3261
+ }
3262
+ if (modalListeners.size > 0) topChanged();
3263
+ },
3264
+ true
3265
+ );
3266
+ }
3267
+ function subscribeModals(listener) {
3268
+ modalListeners.add(listener);
3269
+ if (!modalObserver && typeof MutationObserver !== "undefined") {
3270
+ modalSnapshot = modalTarget();
3271
+ modalObserver = new MutationObserver(topChanged);
3272
+ modalObserver.observe(document.documentElement, {
3273
+ childList: true,
3274
+ subtree: true,
3275
+ attributes: true,
3276
+ attributeFilter: ["open", "data-band-modal"]
3277
+ });
3278
+ }
3279
+ return () => {
3280
+ modalListeners.delete(listener);
3281
+ if (modalListeners.size === 0) {
3282
+ modalObserver?.disconnect();
3283
+ modalObserver = null;
3284
+ }
3285
+ };
3286
+ }
3287
+ function modalSnapshotNow() {
3288
+ return modalObserver ? modalSnapshot : modalTarget();
3289
+ }
3290
+ var entered = /* @__PURE__ */ new Set();
3291
+ function ToastRow({ item }) {
3292
+ const label = item.action?.label ?? (item.kind === "bad" ? TOAST_CLOSE_LABEL : void 0);
3293
+ const row = useRef6(null);
3294
+ const first = useRef6(!entered.has(item.id));
3295
+ useEffect4(() => {
3296
+ entered.add(item.id);
3297
+ const el = row.current;
3298
+ if (!el) return;
3299
+ syncToastPause(item.id, {
3300
+ pointer: el.matches(":hover"),
3301
+ focus: el.contains(document.activeElement)
3302
+ });
3303
+ }, [item.id]);
3304
+ const run = () => {
3305
+ dismissToast(item.id);
3306
+ item.action?.onClick();
3307
+ };
3308
+ return /* @__PURE__ */ jsxs10(
3309
+ "div",
3310
+ {
3311
+ ref: row,
3312
+ className: first.current ? "band-plugin-react-toast" : "band-plugin-react-toast band-plugin-react-toast-again",
3313
+ role: item.kind === "bad" ? "alert" : void 0,
3314
+ tabIndex: -1,
3315
+ onPointerEnter: () => pauseToast(item.id, "pointer"),
3316
+ onPointerLeave: () => resumeToast(item.id, "pointer"),
3317
+ onFocus: () => pauseToast(item.id, "focus"),
3318
+ onBlur: () => resumeToast(item.id, "focus"),
3319
+ onKeyDown: withImeGuard4((e) => {
3320
+ if (e.key !== "Escape") return;
3321
+ e.preventDefault();
3322
+ e.stopPropagation();
3323
+ dismissToast(item.id);
3324
+ }),
3325
+ children: [
3326
+ /* @__PURE__ */ jsx11("span", { className: `band-plugin-react-toast-icon ${item.kind}`, "aria-hidden": "true", children: item.kind === "ok" ? "\u2713" : item.kind === "bad" ? "!" : "" }),
3327
+ /* @__PURE__ */ jsxs10("span", { className: "band-plugin-react-toast-text", children: [
3328
+ item.text,
3329
+ item.detail ? /* @__PURE__ */ jsx11("small", { className: "band-plugin-react-toast-detail", children: item.detail }) : null
3330
+ ] }),
3331
+ label ? /* @__PURE__ */ jsx11("button", { type: "button", className: "band-plugin-react-toast-act", onClick: run, children: label }) : /* @__PURE__ */ jsx11("span", {})
3332
+ ]
3333
+ }
3334
+ );
3335
+ }
3336
+ function ToastHost() {
3337
+ const items = useSyncExternalStore3(subscribeToasts, toastsSnapshot, emptyToasts);
3338
+ const watching = items.length > 0;
3339
+ const stackRef = useRef6(null);
3340
+ const returnTo = useRef6(null);
3341
+ useEffect4(() => {
3342
+ const sync = () => setToastPageHidden(document.visibilityState === "hidden");
3343
+ sync();
3344
+ document.addEventListener("visibilitychange", sync);
3345
+ return () => {
3346
+ document.removeEventListener("visibilitychange", sync);
3347
+ setToastPageHidden(false);
3348
+ };
3349
+ }, []);
3350
+ useEffect4(() => {
3351
+ if (!watching) {
3352
+ returnTo.current = null;
3353
+ return;
3354
+ }
3355
+ const onKey = withImeGuard4((e) => {
3356
+ if (e.key !== "F6" || e.defaultPrevented) return;
3357
+ if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
3358
+ const stack2 = stackRef.current;
3359
+ const latest = stack2?.lastElementChild;
3360
+ if (!stack2 || !(latest instanceof HTMLElement)) return;
3361
+ e.preventDefault();
3362
+ const active = document.activeElement;
3363
+ if (active instanceof HTMLElement && stack2.contains(active)) {
3364
+ const back = returnTo.current;
3365
+ returnTo.current = null;
3366
+ if (back?.isConnected) back.focus();
3367
+ return;
3368
+ }
3369
+ returnTo.current = active instanceof HTMLElement && active !== document.body ? active : null;
3370
+ latest.focus();
3371
+ });
3372
+ document.addEventListener("keydown", onKey);
3373
+ return () => document.removeEventListener("keydown", onKey);
3374
+ }, [watching]);
3375
+ const target = useSyncExternalStore3(
3376
+ watching ? subscribeModals : noSubscribe,
3377
+ watching ? modalSnapshotNow : noTarget,
3378
+ noTarget
3379
+ );
3380
+ useEffect4(() => {
3381
+ if (items.length === 0) {
3382
+ entered.clear();
3383
+ return;
3384
+ }
3385
+ const live = new Set(items.map((item) => item.id));
3386
+ for (const id of entered) if (!live.has(id)) entered.delete(id);
3387
+ }, [items]);
3388
+ const stack = /* @__PURE__ */ jsx11(
3389
+ "div",
3390
+ {
3391
+ ref: stackRef,
3392
+ className: "band-plugin-react-toast-stack",
3393
+ "aria-label": "\u901A\u77E5",
3394
+ "aria-live": "polite",
3395
+ "aria-relevant": "additions text",
3396
+ "aria-atomic": "false",
3397
+ children: items.map((item) => /* @__PURE__ */ jsx11(ToastRow, { item }, item.id))
3398
+ }
3399
+ );
3400
+ return target ? createPortal(stack, target) : stack;
3401
+ }
3402
+ function noSubscribe() {
3403
+ return () => {
3404
+ };
3405
+ }
3406
+ function noTarget() {
3407
+ return null;
3408
+ }
3409
+
3410
+ export {
3411
+ Icon,
3412
+ ErrorNote,
3413
+ InfoNote,
3414
+ PaneHeader,
3415
+ avatarTone,
3416
+ memberOrder,
3417
+ avatarInitial,
3418
+ Avatar,
3419
+ Glyph,
3420
+ agentInstrument,
3421
+ AgentAvatar,
3422
+ INSTRUMENTS,
3423
+ instrumentOf,
3424
+ WorkshopIcon,
3425
+ WorkshopEmblem,
3426
+ BandMark,
3427
+ LogoLockup,
3428
+ settingsLinkHandler,
3429
+ SettingsLayout,
3430
+ SettingsBack,
3431
+ SettingsHead,
3432
+ SettingsRows,
3433
+ SettingsRow,
3434
+ SettingsFacts,
3435
+ SettingsSection,
3436
+ SettingsSingle,
3437
+ SettingsChoices,
3438
+ SettingsPicks,
3439
+ SettingsDanger,
3440
+ SettingsDangerRow,
3441
+ SettingsLoading,
3442
+ SettingsEmpty,
3443
+ SettingsReadError,
3444
+ SettingsNoAccess,
3445
+ SettingsNotice,
3446
+ SettingsSaved,
3447
+ SettingsDialog,
3448
+ SettingsForm,
3449
+ SettingsField,
3450
+ SettingsActions,
3451
+ SettingsSaveState,
3452
+ PersonSearch,
3453
+ PersonPicker,
3454
+ directoryFor,
3455
+ peopleDirectory,
3456
+ usePersonList,
3457
+ LOG_TAIL,
3458
+ trailOf,
3459
+ AgentTrace,
3460
+ useElapsed,
3461
+ useNow,
3462
+ memberDisplayName,
3463
+ TURN_STATUS_ATTR,
3464
+ useTurnStatusOnPage,
3465
+ AgentRun,
3466
+ useMessageList,
3467
+ Tooltip,
3468
+ Menu,
3469
+ Dialog,
3470
+ ConfirmDialog,
3471
+ Combobox,
3472
+ splitTags,
3473
+ TagInput,
3474
+ facetedCount,
3475
+ filterRows,
3476
+ FilterMenu,
3477
+ toast,
3478
+ dismissToast,
3479
+ dismissAllToasts,
3480
+ ToastHost
3481
+ };