@kanyun-ai-infra/band-plugin-react 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2425 @@
1
+ import {
2
+ scrollIntoPanel
3
+ } from "./chunk-VKASR4EL.js";
4
+
5
+ // src/ui.tsx
6
+ import {
7
+ WORKSHOP_GENRES,
8
+ agentDisplayName
9
+ } from "@kanyun-ai-infra/band-contracts/display";
10
+
11
+ // ../tokens/assets/genres/classical-compact.svg
12
+ 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';
13
+
14
+ // ../tokens/assets/genres/classical.svg
15
+ 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';
16
+
17
+ // ../tokens/assets/genres/electronic-compact.svg
18
+ 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';
19
+
20
+ // ../tokens/assets/genres/electronic.svg
21
+ 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';
22
+
23
+ // ../tokens/assets/genres/folk-compact.svg
24
+ 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';
25
+
26
+ // ../tokens/assets/genres/folk.svg
27
+ 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';
28
+
29
+ // ../tokens/assets/genres/guoyue-compact.svg
30
+ 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';
31
+
32
+ // ../tokens/assets/genres/guoyue.svg
33
+ 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';
34
+
35
+ // ../tokens/assets/genres/hiphop-compact.svg
36
+ 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';
37
+
38
+ // ../tokens/assets/genres/hiphop.svg
39
+ 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';
40
+
41
+ // ../tokens/assets/genres/jazz-compact.svg
42
+ 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';
43
+
44
+ // ../tokens/assets/genres/jazz.svg
45
+ 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';
46
+
47
+ // ../tokens/assets/genres/pop-compact.svg
48
+ 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';
49
+
50
+ // ../tokens/assets/genres/pop.svg
51
+ 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';
52
+
53
+ // ../tokens/assets/genres/rock-compact.svg
54
+ 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';
55
+
56
+ // ../tokens/assets/genres/rock.svg
57
+ 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';
58
+
59
+ // ../tokens/assets/instruments/drum.svg
60
+ 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';
61
+
62
+ // ../tokens/assets/instruments/guitar.svg
63
+ 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';
64
+
65
+ // ../tokens/assets/instruments/keys.svg
66
+ 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';
67
+
68
+ // ../tokens/assets/instruments/sax.svg
69
+ 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';
70
+
71
+ // ../tokens/assets/instruments/trumpet.svg
72
+ 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';
73
+
74
+ // ../tokens/assets/instruments/violin.svg
75
+ 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';
76
+
77
+ // src/ui.tsx
78
+ import { jsx, jsxs } from "react/jsx-runtime";
79
+ function ErrorNote({ children, retry }) {
80
+ if (!children) return null;
81
+ const note = /* @__PURE__ */ jsx("div", { className: "band-plugin-react-error", children });
82
+ if (!retry) return note;
83
+ return /* @__PURE__ */ jsxs("div", { className: "band-plugin-react-retry", role: "alert", children: [
84
+ note,
85
+ /* @__PURE__ */ jsx("button", { type: "button", className: "btn sm", onClick: retry, children: "\u91CD\u8BD5" })
86
+ ] });
87
+ }
88
+ function InfoNote({ children }) {
89
+ if (!children) return null;
90
+ return /* @__PURE__ */ jsx("div", { className: "band-plugin-react-info", children });
91
+ }
92
+ function PaneHeader({ title, children }) {
93
+ return /* @__PURE__ */ jsxs("div", { className: "band-plugin-react-pane-head", children: [
94
+ /* @__PURE__ */ jsx("h2", { className: "band-plugin-react-pane-title", children: title }),
95
+ children
96
+ ] });
97
+ }
98
+ function avatarTone(id, order) {
99
+ const i = order?.indexOf(id) ?? -1;
100
+ if (i >= 0) return i % 5 + 1;
101
+ let h = 2166136261;
102
+ for (const c of id) {
103
+ h ^= c.codePointAt(0) ?? 0;
104
+ h = Math.imul(h, 16777619);
105
+ }
106
+ h ^= h >>> 16;
107
+ h = Math.imul(h, 2246822507);
108
+ h ^= h >>> 13;
109
+ return (h >>> 0) % 5 + 1;
110
+ }
111
+ function memberOrder(members) {
112
+ return members.filter((m) => m.actor.kind === "human").map((m) => m.actor.id);
113
+ }
114
+ function avatarInitial(name) {
115
+ const first = Array.from(name.trim())[0];
116
+ if (!first) return "?";
117
+ const up = first.toUpperCase();
118
+ return Array.from(up).length === 1 ? up : first;
119
+ }
120
+ function Avatar({
121
+ id,
122
+ name,
123
+ agent = false,
124
+ instrument,
125
+ size = "sm",
126
+ decorative = false,
127
+ order
128
+ }) {
129
+ const cls = `av${size === "md" ? "" : ` ${size}`}${agent ? " bot" : ""}`;
130
+ const a11y = decorative ? { "aria-hidden": true } : { role: "img", "aria-label": name };
131
+ return /* @__PURE__ */ jsx(
132
+ "span",
133
+ {
134
+ className: cls,
135
+ title: name,
136
+ style: agent ? void 0 : { background: `var(--av${avatarTone(id, order)})` },
137
+ ...a11y,
138
+ children: agent && instrument ? /* @__PURE__ */ jsx(
139
+ "span",
140
+ {
141
+ className: "band-plugin-react-instrument",
142
+ "aria-hidden": "true",
143
+ style: { ["--band-instrument"]: cssUrl(INSTRUMENT_SRC[instrument]) }
144
+ }
145
+ ) : agent ? /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx("ellipse", { cx: "8", cy: "8.4", rx: "5.6", ry: "3.7", transform: "rotate(-20 8 8.4)" }) }) : avatarInitial(name)
146
+ }
147
+ );
148
+ }
149
+ function Glyph({ kind, bg = false }) {
150
+ return /* @__PURE__ */ jsx("span", { className: `glyph ${kind}${bg ? " bgwork" : ""}`.trim(), "aria-hidden": "true" });
151
+ }
152
+ function agentInstrument(id, members) {
153
+ const peers = members.filter((m) => m.actor.kind === "agent").map((m) => m.actor.id);
154
+ return instrumentOf(id, peers);
155
+ }
156
+ function AgentAvatar({
157
+ id,
158
+ members,
159
+ size = "xs",
160
+ decorative = false
161
+ }) {
162
+ const list = members ?? [];
163
+ const name = list.find((m) => m.actor.id === id)?.displayName ?? agentDisplayName(id);
164
+ const instrument = agentInstrument(id, list);
165
+ return /* @__PURE__ */ jsx(
166
+ Avatar,
167
+ {
168
+ id,
169
+ name,
170
+ agent: true,
171
+ size,
172
+ decorative,
173
+ ...instrument ? { instrument } : {}
174
+ }
175
+ );
176
+ }
177
+ var INSTRUMENTS = ["sax", "keys", "guitar", "drum", "trumpet", "violin"];
178
+ var INSTRUMENT_SRC = {
179
+ sax: sax_default,
180
+ keys: keys_default,
181
+ guitar: guitar_default,
182
+ drum: drum_default,
183
+ trumpet: trumpet_default,
184
+ violin: violin_default
185
+ };
186
+ function cssUrl(src) {
187
+ return `url("${src.replace(/"/g, "'")}")`;
188
+ }
189
+ function fnv1a(s) {
190
+ let h = 2166136261;
191
+ for (const c of s) {
192
+ h ^= c.codePointAt(0) ?? 0;
193
+ h = Math.imul(h, 16777619);
194
+ }
195
+ return h >>> 0;
196
+ }
197
+ function instrumentOf(name, peers) {
198
+ const isRondo = (n) => n.toLowerCase() === "rondo";
199
+ if (isRondo(name)) return void 0;
200
+ const all = [...new Set([...peers, name].filter((n) => !isRondo(n)))].sort();
201
+ const taken = /* @__PURE__ */ new Set();
202
+ for (const n of all) {
203
+ const start = fnv1a(n) % INSTRUMENTS.length;
204
+ let pick = INSTRUMENTS[start];
205
+ for (let k = 0; k < INSTRUMENTS.length; k++) {
206
+ const cand = INSTRUMENTS[(start + k) % INSTRUMENTS.length];
207
+ if (!taken.has(cand)) {
208
+ pick = cand;
209
+ break;
210
+ }
211
+ }
212
+ if (taken.size < INSTRUMENTS.length) taken.add(pick);
213
+ if (n === name) return pick;
214
+ }
215
+ return void 0;
216
+ }
217
+ var GENRE_FULL_SRC = {
218
+ classical: classical_default,
219
+ jazz: jazz_default,
220
+ pop: pop_default,
221
+ rock: rock_default,
222
+ electronic: electronic_default,
223
+ folk: folk_default,
224
+ hiphop: hiphop_default,
225
+ guoyue: guoyue_default
226
+ };
227
+ var GENRE_COMPACT_SRC = {
228
+ classical: classical_compact_default,
229
+ jazz: jazz_compact_default,
230
+ pop: pop_compact_default,
231
+ rock: rock_compact_default,
232
+ electronic: electronic_compact_default,
233
+ folk: folk_compact_default,
234
+ hiphop: hiphop_compact_default,
235
+ guoyue: guoyue_compact_default
236
+ };
237
+ function WorkshopIcon({
238
+ icon,
239
+ size = 20,
240
+ tile = false
241
+ }) {
242
+ return drawWorkshopIcon(GENRE_COMPACT_SRC, icon, size, tile);
243
+ }
244
+ function WorkshopEmblem({ icon, size = 48 }) {
245
+ return drawWorkshopIcon(size >= 48 ? GENRE_FULL_SRC : GENRE_COMPACT_SRC, icon, size, true);
246
+ }
247
+ function drawWorkshopIcon(srcs, icon, size, tile) {
248
+ const genre = icon?.startsWith("genre:") ? icon.slice("genre:".length) : void 0;
249
+ const known = genre && WORKSHOP_GENRES.includes(genre);
250
+ const src = known ? srcs[genre] : void 0;
251
+ const inner = src ? /* @__PURE__ */ jsx("img", { className: "band-plugin-react-wsicon", src, width: size, height: size, alt: "" }) : /* @__PURE__ */ jsx(BandMark, { className: "band-plugin-react-wsicon", size });
252
+ if (!tile) return inner;
253
+ return /* @__PURE__ */ jsx(
254
+ "span",
255
+ {
256
+ className: `band-plugin-react-wstile${size >= 28 ? " is-large" : ""}`,
257
+ style: { ["--band-wstile"]: `${size}px` },
258
+ "aria-hidden": "true",
259
+ children: inner
260
+ }
261
+ );
262
+ }
263
+ function BandMark({ size = 20, className }) {
264
+ return /* @__PURE__ */ jsxs(
265
+ "svg",
266
+ {
267
+ className,
268
+ viewBox: "0 0 24 24",
269
+ width: size,
270
+ height: size,
271
+ "aria-hidden": "true",
272
+ focusable: "false",
273
+ children: [
274
+ /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.75", children: [
275
+ /* @__PURE__ */ jsx("path", { d: "M7.67 18.81V6.95" }),
276
+ /* @__PURE__ */ jsx("path", { d: "M14.67 15.71V4.65" }),
277
+ /* @__PURE__ */ jsx("path", { d: "M21.67 12.61V2.35" })
278
+ ] }),
279
+ /* @__PURE__ */ jsx("path", { fill: "currentColor", d: "M6.8 5.69L22.55 0.51V3.61L6.8 8.79Z" }),
280
+ /* @__PURE__ */ jsx(
281
+ "ellipse",
282
+ {
283
+ fill: "currentColor",
284
+ cx: "5.4",
285
+ cy: "19.4",
286
+ rx: "3.25",
287
+ ry: "2.2",
288
+ transform: "rotate(-20 5.4 19.4)"
289
+ }
290
+ ),
291
+ /* @__PURE__ */ jsx(
292
+ "ellipse",
293
+ {
294
+ fill: "var(--accent)",
295
+ cx: "12.4",
296
+ cy: "16.3",
297
+ rx: "3.25",
298
+ ry: "2.2",
299
+ transform: "rotate(-20 12.4 16.3)"
300
+ }
301
+ ),
302
+ /* @__PURE__ */ jsx(
303
+ "ellipse",
304
+ {
305
+ fill: "currentColor",
306
+ cx: "19.4",
307
+ cy: "13.2",
308
+ rx: "3.25",
309
+ ry: "2.2",
310
+ transform: "rotate(-20 19.4 13.2)"
311
+ }
312
+ )
313
+ ]
314
+ }
315
+ );
316
+ }
317
+ function LogoLockup() {
318
+ return /* @__PURE__ */ jsxs("svg", { className: "logo lockup", viewBox: "0 0 111 28", role: "img", "aria-label": "Band", children: [
319
+ /* @__PURE__ */ jsx("g", { className: "staff", children: [5, 9.5, 14, 18.5, 23].map((y) => /* @__PURE__ */ jsx("line", { x1: "1", y1: y, x2: "39", y2: y }, y)) }),
320
+ /* @__PURE__ */ jsx("path", { className: "st", d: "M12.36 20.12V7.65" }),
321
+ /* @__PURE__ */ jsx("path", { className: "st", d: "M21.86 15.62V5.35" }),
322
+ /* @__PURE__ */ jsx("path", { className: "st", d: "M31.36 11.12V3.05" }),
323
+ /* @__PURE__ */ jsx("path", { d: "M11.54 6.4L32.19 1.4V4.3L11.54 9.3Z" }),
324
+ /* @__PURE__ */ jsx("ellipse", { cx: "10", cy: "20.75", rx: "3.3", ry: "2.15", transform: "rotate(-20 10 20.75)" }),
325
+ /* @__PURE__ */ jsx(
326
+ "ellipse",
327
+ {
328
+ className: "ag",
329
+ cx: "19.5",
330
+ cy: "16.25",
331
+ rx: "3.3",
332
+ ry: "2.15",
333
+ transform: "rotate(-20 19.5 16.25)"
334
+ }
335
+ ),
336
+ /* @__PURE__ */ jsx("ellipse", { cx: "29", cy: "11.75", rx: "3.3", ry: "2.15", transform: "rotate(-20 29 11.75)" }),
337
+ /* @__PURE__ */ jsx("text", { className: "wm", x: "46", y: "23", children: "Band" })
338
+ ] });
339
+ }
340
+
341
+ // src/controls.tsx
342
+ import { withImeGuard } from "@kanyun-ai-infra/band-plugin-sdk/keys";
343
+ import { useEffect, useId, useMemo, useRef, useState } from "react";
344
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
345
+ function sectionsOf(items) {
346
+ const byTitle = /* @__PURE__ */ new Map();
347
+ for (const item of items) {
348
+ const title = item.group ?? null;
349
+ const bucket = byTitle.get(title);
350
+ if (bucket) bucket.push(item);
351
+ else byTitle.set(title, [item]);
352
+ }
353
+ return [...byTitle].map(([title, list]) => ({ title, items: list }));
354
+ }
355
+ function highlight(text, query) {
356
+ const q = query.trim();
357
+ if (q === "") return text;
358
+ const escaped = q.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
359
+ const parts = text.split(new RegExp(`(${escaped})`, "gi"));
360
+ return parts.map(
361
+ (part, i) => (
362
+ // 奇数下标就是命中的那几段;split 带捕获组时长度与命中的段数相关,按内容再判一次更稳
363
+ i % 2 === 1 && part.toLowerCase() === q.toLowerCase() ? (
364
+ // biome-ignore lint/suspicious/noArrayIndexKey: 拆分结果没有稳定的键,重排只发生在查询变化时
365
+ /* @__PURE__ */ jsx2("mark", { children: part }, i)
366
+ ) : (
367
+ // biome-ignore lint/suspicious/noArrayIndexKey: 同上
368
+ /* @__PURE__ */ jsx2("span", { children: part }, i)
369
+ )
370
+ )
371
+ );
372
+ }
373
+ function Combobox({
374
+ label,
375
+ items,
376
+ value,
377
+ onChange,
378
+ multiple = false,
379
+ placeholder,
380
+ emptyText,
381
+ onCreate,
382
+ createLabel,
383
+ disabled = false
384
+ }) {
385
+ const id = useId();
386
+ const listId = `${id}-list`;
387
+ const [query, setQuery] = useState("");
388
+ const [open, setOpen] = useState(false);
389
+ const [active, setActive] = useState(0);
390
+ const input = useRef(null);
391
+ const list = useRef(null);
392
+ const q = query.trim();
393
+ const matched = useMemo(() => {
394
+ const base = q === "" ? items : items.filter(
395
+ (it) => [it.label, it.meta ?? "", it.keywords ?? ""].some(
396
+ (t) => t.toLowerCase().includes(q.toLowerCase())
397
+ )
398
+ );
399
+ return base.filter((it) => !value.includes(it.value));
400
+ }, [items, value, q]);
401
+ const sections = useMemo(() => sectionsOf(matched), [matched]);
402
+ const flat = useMemo(() => sections.flatMap((s) => s.items), [sections]);
403
+ const exact = q !== "" && items.some((it) => it.label === q);
404
+ const canCreate = onCreate !== void 0 && q !== "" && !exact;
405
+ const total = flat.length + (canCreate ? 1 : 0);
406
+ const activeIndex = total === 0 ? -1 : Math.min(active, total - 1);
407
+ function pick(item) {
408
+ if (multiple) {
409
+ if (!value.includes(item.value)) onChange([...value, item.value]);
410
+ } else {
411
+ onChange([item.value]);
412
+ }
413
+ setQuery("");
414
+ if (!multiple) setOpen(false);
415
+ setActive(0);
416
+ input.current?.focus();
417
+ }
418
+ function create() {
419
+ if (!onCreate || q === "") return;
420
+ onCreate(q);
421
+ setQuery("");
422
+ if (!multiple) setOpen(false);
423
+ setActive(0);
424
+ input.current?.focus();
425
+ }
426
+ function remove(v) {
427
+ onChange(value.filter((x) => x !== v));
428
+ input.current?.focus();
429
+ }
430
+ function move(step) {
431
+ if (total === 0) return;
432
+ setOpen(true);
433
+ const next = (activeIndex + step + total) % total;
434
+ setActive(next);
435
+ const el = list.current?.querySelector(`[data-index="${next}"]`);
436
+ if (el) scrollIntoPanel(el, { block: "nearest" });
437
+ }
438
+ const onComboKey = withImeGuard((e) => {
439
+ if (e.key === "Escape") {
440
+ if (open) {
441
+ setOpen(false);
442
+ e.stopPropagation();
443
+ }
444
+ return;
445
+ }
446
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
447
+ e.preventDefault();
448
+ move(e.key === "ArrowDown" ? 1 : -1);
449
+ return;
450
+ }
451
+ if (e.key === "Enter") {
452
+ if (!open) return;
453
+ e.preventDefault();
454
+ if (activeIndex < 0) return;
455
+ const item = flat[activeIndex];
456
+ if (item) pick(item);
457
+ else create();
458
+ return;
459
+ }
460
+ if (e.key === " " && multiple && open && query === "" && activeIndex >= 0) {
461
+ const item = flat[activeIndex];
462
+ if (!item) return;
463
+ e.preventDefault();
464
+ pick(item);
465
+ return;
466
+ }
467
+ if (e.key === "Backspace" && query === "" && value.length > 0) {
468
+ const last = value[value.length - 1];
469
+ if (last !== void 0) {
470
+ e.preventDefault();
471
+ remove(last);
472
+ }
473
+ }
474
+ });
475
+ const selected = value.map((v) => ({
476
+ value: v,
477
+ label: items.find((it) => it.value === v)?.label ?? v
478
+ }));
479
+ return /* @__PURE__ */ jsxs2("div", { className: "band-plugin-react-combo", children: [
480
+ selected.length > 0 && /* @__PURE__ */ jsx2("ul", { className: "band-plugin-react-combo-picked", "aria-label": `\u5DF2\u9009${label}`, children: selected.map((it) => /* @__PURE__ */ jsxs2("li", { className: "band-plugin-react-combo-chip", children: [
481
+ it.label,
482
+ /* @__PURE__ */ jsx2(
483
+ "button",
484
+ {
485
+ type: "button",
486
+ "aria-label": `\u79FB\u9664 ${it.label}`,
487
+ disabled,
488
+ onClick: () => remove(it.value),
489
+ children: "\xD7"
490
+ }
491
+ )
492
+ ] }, it.value)) }),
493
+ /* @__PURE__ */ jsxs2("div", { className: "band-plugin-react-combo-field field-host", children: [
494
+ /* @__PURE__ */ jsx2(
495
+ "input",
496
+ {
497
+ ref: input,
498
+ className: "field bare",
499
+ type: "text",
500
+ role: "combobox",
501
+ "aria-label": label,
502
+ "aria-expanded": open,
503
+ "aria-controls": open ? listId : void 0,
504
+ "aria-autocomplete": "list",
505
+ "aria-activedescendant": open && activeIndex >= 0 ? `${listId}-${activeIndex}` : void 0,
506
+ autoComplete: "off",
507
+ disabled,
508
+ placeholder: placeholder ?? label,
509
+ value: query,
510
+ onChange: (e) => {
511
+ setQuery(e.target.value);
512
+ setOpen(true);
513
+ setActive(0);
514
+ },
515
+ onFocus: () => setOpen(true),
516
+ onClick: () => setOpen(true),
517
+ onBlur: () => setOpen(false),
518
+ onKeyDown: onComboKey
519
+ }
520
+ ),
521
+ open && // biome-ignore lint/a11y/useFocusableInteractive: 焦点留在输入框(combobox + aria-activedescendant),列表自己不取焦点
522
+ /* @__PURE__ */ jsxs2(
523
+ "div",
524
+ {
525
+ ref: list,
526
+ className: "band-plugin-react-combo-pop",
527
+ id: listId,
528
+ role: "listbox",
529
+ "aria-label": label,
530
+ onMouseDown: (e) => {
531
+ e.preventDefault();
532
+ const row = e.target.closest("[data-index]");
533
+ if (!row) return;
534
+ const i = Number(row.dataset.index);
535
+ const item = flat[i];
536
+ if (item) pick(item);
537
+ else if (i === flat.length) create();
538
+ },
539
+ children: [
540
+ sections.map((section) => /* @__PURE__ */ jsxs2("div", { className: "band-plugin-react-combo-section", children: [
541
+ section.title !== null && /* @__PURE__ */ jsx2("div", { className: "band-plugin-react-combo-group", role: "presentation", children: section.title }),
542
+ section.items.map((it) => {
543
+ const i = flat.indexOf(it);
544
+ return (
545
+ // biome-ignore lint/a11y/useFocusableInteractive: 见上,选项经 aria-activedescendant 标出,不自己取焦点
546
+ /* @__PURE__ */ jsxs2(
547
+ "div",
548
+ {
549
+ id: `${listId}-${i}`,
550
+ role: "option",
551
+ "aria-selected": value.includes(it.value),
552
+ "data-index": i,
553
+ className: `band-plugin-react-combo-opt${i === activeIndex ? " is-active" : ""}`,
554
+ onMouseEnter: () => setActive(i),
555
+ children: [
556
+ /* @__PURE__ */ jsx2("span", { className: "band-plugin-react-combo-label", children: highlight(it.label, q) }),
557
+ it.meta !== void 0 && /* @__PURE__ */ jsx2("span", { className: "band-plugin-react-combo-meta", children: it.meta })
558
+ ]
559
+ },
560
+ it.value
561
+ )
562
+ );
563
+ })
564
+ ] }, section.title ?? "\0")),
565
+ flat.length === 0 && q !== "" && /* @__PURE__ */ jsx2("div", { className: "band-plugin-react-combo-empty", children: emptyText ?? `\u6CA1\u6709\u5339\u914D\u7684${label}` }),
566
+ canCreate && // biome-ignore lint/a11y/useFocusableInteractive: 同候选行
567
+ /* @__PURE__ */ jsxs2(
568
+ "div",
569
+ {
570
+ id: `${listId}-${flat.length}`,
571
+ role: "option",
572
+ "aria-selected": false,
573
+ "data-index": flat.length,
574
+ className: `band-plugin-react-combo-opt${flat.length === activeIndex ? " is-active" : ""}`,
575
+ onMouseEnter: () => setActive(flat.length),
576
+ children: [
577
+ /* @__PURE__ */ jsx2("span", { className: "band-plugin-react-combo-plus", "aria-hidden": "true", children: "+" }),
578
+ /* @__PURE__ */ jsx2("span", { className: "band-plugin-react-combo-label", children: createLabel ? createLabel(q) : `\u65B0\u5EFA\u300C${q}\u300D` })
579
+ ]
580
+ }
581
+ )
582
+ ]
583
+ }
584
+ )
585
+ ] })
586
+ ] });
587
+ }
588
+ var TAG_SPLIT = /[,,\n\t]/;
589
+ function splitTags(text) {
590
+ return text.split(TAG_SPLIT).map((s) => s.trim()).filter((s) => s !== "");
591
+ }
592
+ function TagInput({
593
+ label,
594
+ value,
595
+ onChange,
596
+ placeholder,
597
+ hint,
598
+ disabled = false,
599
+ id
600
+ }) {
601
+ const auto = useId();
602
+ const inputId = id ?? auto;
603
+ const hintId = `${inputId}-hint`;
604
+ const [draft, setDraft] = useState("");
605
+ const [dup, setDup] = useState(null);
606
+ const [dupChip, setDupChip] = useState(null);
607
+ const timer = useRef(null);
608
+ useEffect(
609
+ () => () => {
610
+ if (timer.current !== null) clearTimeout(timer.current);
611
+ },
612
+ []
613
+ );
614
+ function flash(name) {
615
+ setDup(name);
616
+ setDupChip(name);
617
+ if (timer.current !== null) clearTimeout(timer.current);
618
+ timer.current = setTimeout(() => {
619
+ setDup(null);
620
+ setDupChip(null);
621
+ timer.current = null;
622
+ }, 1800);
623
+ }
624
+ function clearDup() {
625
+ if (timer.current !== null) {
626
+ clearTimeout(timer.current);
627
+ timer.current = null;
628
+ }
629
+ setDup(null);
630
+ setDupChip(null);
631
+ }
632
+ function add(raw) {
633
+ const parts = splitTags(raw);
634
+ if (parts.length === 0) return;
635
+ const seen = new Set(value);
636
+ const added = [];
637
+ let repeated = null;
638
+ for (const part of parts) {
639
+ if (seen.has(part)) {
640
+ repeated = repeated ?? part;
641
+ continue;
642
+ }
643
+ seen.add(part);
644
+ added.push(part);
645
+ }
646
+ if (repeated !== null) flash(repeated);
647
+ else clearDup();
648
+ if (added.length > 0) onChange([...value, ...added]);
649
+ }
650
+ function removeAt(i) {
651
+ const gone = value[i];
652
+ onChange(value.filter((_, k) => k !== i));
653
+ if (gone !== void 0 && gone === dupChip) clearDup();
654
+ }
655
+ const onTagsKey = withImeGuard((e) => {
656
+ if (e.key === "Enter") {
657
+ e.preventDefault();
658
+ if (draft.trim() === "") return;
659
+ add(draft);
660
+ setDraft("");
661
+ return;
662
+ }
663
+ if (e.key === "," || e.key === "\uFF0C") {
664
+ if (draft.trim() === "") return;
665
+ e.preventDefault();
666
+ add(draft);
667
+ setDraft("");
668
+ return;
669
+ }
670
+ if (e.key === "Backspace" && draft === "" && value.length > 0) {
671
+ e.preventDefault();
672
+ const last = value[value.length - 1];
673
+ if (last !== void 0) {
674
+ onChange(value.slice(0, -1));
675
+ if (dupChip === last) clearDup();
676
+ }
677
+ }
678
+ });
679
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
680
+ /* @__PURE__ */ jsxs2("div", { className: "band-plugin-react-tags field-host", children: [
681
+ value.map((tag, i) => /* @__PURE__ */ jsxs2(
682
+ "span",
683
+ {
684
+ className: "band-plugin-react-tag",
685
+ ...dupChip === tag ? { "data-dup": "" } : {},
686
+ children: [
687
+ tag,
688
+ /* @__PURE__ */ jsx2(
689
+ "button",
690
+ {
691
+ type: "button",
692
+ "aria-label": `\u79FB\u9664 ${tag}`,
693
+ disabled,
694
+ onClick: () => removeAt(i),
695
+ children: "\xD7"
696
+ }
697
+ )
698
+ ]
699
+ },
700
+ tag
701
+ )),
702
+ /* @__PURE__ */ jsx2(
703
+ "input",
704
+ {
705
+ id: inputId,
706
+ className: "field bare",
707
+ type: "text",
708
+ "aria-label": label,
709
+ "aria-describedby": hintId,
710
+ autoComplete: "off",
711
+ disabled,
712
+ placeholder: value.length === 0 ? placeholder ?? "\u7C98\u8D34\u6216\u8F93\u5165\uFF0C\u56DE\u8F66\u786E\u8BA4" : "",
713
+ value: draft,
714
+ onChange: (e) => setDraft(e.target.value),
715
+ onKeyDown: onTagsKey,
716
+ onPaste: (e) => {
717
+ const text = e.clipboardData.getData("text");
718
+ if (!TAG_SPLIT.test(text)) return;
719
+ e.preventDefault();
720
+ const el = e.currentTarget;
721
+ const at = el.selectionStart ?? draft.length;
722
+ const end = el.selectionEnd ?? at;
723
+ add(draft.slice(0, at) + text + draft.slice(end));
724
+ setDraft("");
725
+ }
726
+ }
727
+ )
728
+ ] }),
729
+ /* @__PURE__ */ jsx2(
730
+ "p",
731
+ {
732
+ className: "band-plugin-react-tag-hint",
733
+ id: hintId,
734
+ ...dup !== null ? { "data-err": "" } : {},
735
+ children: dup !== null ? `\u300C${dup}\u300D\u91CD\u590D\u4E86\uFF0C\u5DF2\u8DF3\u8FC7` : hint
736
+ }
737
+ )
738
+ ] });
739
+ }
740
+ function facetedCount(rows, groups, selection, groupKey, value) {
741
+ let n = 0;
742
+ for (const row of rows) {
743
+ if (row[groupKey] !== value) continue;
744
+ let ok = true;
745
+ for (const g of groups) {
746
+ if (g.key === groupKey) continue;
747
+ const picked = selection[g.key] ?? [];
748
+ if (picked.length === 0) continue;
749
+ const v = row[g.key];
750
+ if (v === void 0 || !picked.includes(v)) {
751
+ ok = false;
752
+ break;
753
+ }
754
+ }
755
+ if (ok) n++;
756
+ }
757
+ return n;
758
+ }
759
+ function filterRows(rows, groups, selection) {
760
+ return rows.filter(
761
+ (row) => groups.every((g) => {
762
+ const picked = selection[g.key] ?? [];
763
+ if (picked.length === 0) return true;
764
+ const v = row[g.key];
765
+ return v !== void 0 && picked.includes(v);
766
+ })
767
+ );
768
+ }
769
+ function FilterMenu({
770
+ groups,
771
+ rows,
772
+ value,
773
+ onChange,
774
+ emptyText
775
+ }) {
776
+ const id = useId();
777
+ const [collapsed, setCollapsed] = useState(() => /* @__PURE__ */ new Set());
778
+ function toggle(groupKey, option) {
779
+ const picked = value[groupKey] ?? [];
780
+ const next = picked.includes(option) ? picked.filter((x) => x !== option) : [...picked, option];
781
+ const merged = { ...value, [groupKey]: next };
782
+ if (next.length === 0) delete merged[groupKey];
783
+ onChange(merged);
784
+ }
785
+ function clear() {
786
+ onChange({});
787
+ }
788
+ function toggleGroup(key) {
789
+ setCollapsed((prev) => {
790
+ const next = new Set(prev);
791
+ if (next.has(key)) next.delete(key);
792
+ else next.add(key);
793
+ return next;
794
+ });
795
+ }
796
+ const chips = Object.entries(value).flatMap(([key, values]) => {
797
+ const group = groups.find((g) => g.key === key);
798
+ return values.map((v) => ({
799
+ key,
800
+ value: v,
801
+ label: group?.options.find((o) => o.value === v)?.label ?? v
802
+ }));
803
+ });
804
+ return /* @__PURE__ */ jsxs2("div", { className: "band-plugin-react-filter", children: [
805
+ /* @__PURE__ */ jsxs2("div", { className: "band-plugin-react-filter-chips", children: [
806
+ chips.map((chip) => /* @__PURE__ */ jsxs2("span", { className: "band-plugin-react-filter-chip", children: [
807
+ chip.label,
808
+ /* @__PURE__ */ jsx2(
809
+ "button",
810
+ {
811
+ type: "button",
812
+ "aria-label": `\u79FB\u9664 ${chip.label} \u7B5B\u9009`,
813
+ onClick: () => toggle(chip.key, chip.value),
814
+ children: "\xD7"
815
+ }
816
+ )
817
+ ] }, `${chip.key}\0${chip.value}`)),
818
+ chips.length > 0 && /* @__PURE__ */ jsx2("button", { type: "button", className: "band-plugin-react-filter-clear", onClick: clear, children: "\u6E05\u7A7A" })
819
+ ] }),
820
+ groups.map((g) => {
821
+ const picked = value[g.key] ?? [];
822
+ const isCollapsed = collapsed.has(g.key);
823
+ const panel = `${id}-${g.key}`;
824
+ return /* @__PURE__ */ jsxs2("div", { className: "band-plugin-react-filter-group-box", children: [
825
+ /* @__PURE__ */ jsxs2(
826
+ "button",
827
+ {
828
+ type: "button",
829
+ className: "band-plugin-react-filter-group",
830
+ "aria-expanded": !isCollapsed,
831
+ "aria-controls": panel,
832
+ onClick: () => toggleGroup(g.key),
833
+ children: [
834
+ g.label,
835
+ /* @__PURE__ */ jsx2("span", { className: "band-plugin-react-filter-group-count", children: picked.length })
836
+ ]
837
+ }
838
+ ),
839
+ /* @__PURE__ */ jsxs2("div", { id: panel, hidden: isCollapsed, children: [
840
+ g.options.length === 0 && /* @__PURE__ */ jsx2("p", { className: "band-plugin-react-filter-empty", children: emptyText ?? "\u6CA1\u6709\u53EF\u7B5B\u7684" }),
841
+ g.options.map((o) => /* @__PURE__ */ jsxs2("label", { className: "band-plugin-react-filter-opt choice", children: [
842
+ /* @__PURE__ */ jsx2(
843
+ "input",
844
+ {
845
+ type: "checkbox",
846
+ className: "checkbox",
847
+ checked: picked.includes(o.value),
848
+ onChange: () => toggle(g.key, o.value)
849
+ }
850
+ ),
851
+ o.label,
852
+ /* @__PURE__ */ jsx2("span", { className: "band-plugin-react-filter-count", children: facetedCount(rows, groups, value, g.key, o.value) })
853
+ ] }, o.value))
854
+ ] })
855
+ ] }, g.key);
856
+ })
857
+ ] });
858
+ }
859
+
860
+ // src/toast/store.ts
861
+ var MAX_TOASTS = 3;
862
+ var OK_MS = 4e3;
863
+ var LEAVE_MS = 2e3;
864
+ var TOAST_CLOSE_LABEL = "\u5173\u95ED";
865
+ var EMPTY = [];
866
+ var entries = [];
867
+ var listeners = /* @__PURE__ */ new Set();
868
+ var snapshot = EMPTY;
869
+ var seq = 0;
870
+ function subscribeToasts(listener) {
871
+ listeners.add(listener);
872
+ return () => {
873
+ listeners.delete(listener);
874
+ };
875
+ }
876
+ function toastsSnapshot() {
877
+ return snapshot;
878
+ }
879
+ function emptyToasts() {
880
+ return EMPTY;
881
+ }
882
+ function publish() {
883
+ snapshot = entries.length === 0 ? EMPTY : entries.map((e) => ({
884
+ id: e.id,
885
+ kind: e.kind,
886
+ text: e.text,
887
+ detail: e.detail,
888
+ action: e.action
889
+ }));
890
+ for (const listener of listeners) listener();
891
+ }
892
+ function clearTimer(entry) {
893
+ if (entry.timer !== void 0) {
894
+ clearTimeout(entry.timer);
895
+ entry.timer = void 0;
896
+ }
897
+ }
898
+ function arm(id, ms) {
899
+ const entry = entries.find((e) => e.id === id);
900
+ if (!entry) return;
901
+ clearTimer(entry);
902
+ if (entry.pausedBy.size > 0) return;
903
+ entry.timer = setTimeout(() => dismissToast(id), ms);
904
+ }
905
+ function toast(opts) {
906
+ const kind = opts.kind ?? "ok";
907
+ const id = opts.id ?? `toast-${++seq}`;
908
+ const existing = entries.find((e) => e.id === id);
909
+ if (existing) {
910
+ clearTimer(existing);
911
+ existing.kind = kind;
912
+ existing.text = opts.text;
913
+ existing.detail = opts.detail;
914
+ existing.action = opts.action;
915
+ } else {
916
+ if (entries.length >= MAX_TOASTS) {
917
+ const i = entries.findIndex((e) => e.kind !== "busy");
918
+ const [dropped] = entries.splice(i === -1 ? 0 : i, 1);
919
+ if (dropped) clearTimer(dropped);
920
+ }
921
+ entries.push({
922
+ id,
923
+ kind,
924
+ text: opts.text,
925
+ detail: opts.detail,
926
+ action: opts.action,
927
+ pausedBy: /* @__PURE__ */ new Set()
928
+ });
929
+ }
930
+ if (kind === "ok") arm(id, OK_MS);
931
+ publish();
932
+ return id;
933
+ }
934
+ function pauseToast(id, by = "pointer") {
935
+ const entry = entries.find((e) => e.id === id);
936
+ if (!entry) return;
937
+ entry.pausedBy.add(by);
938
+ clearTimer(entry);
939
+ }
940
+ function resumeToast(id, by = "pointer") {
941
+ const entry = entries.find((e) => e.id === id);
942
+ if (!entry) return;
943
+ entry.pausedBy.delete(by);
944
+ if (entry.kind === "ok" && entry.pausedBy.size === 0) arm(id, LEAVE_MS);
945
+ }
946
+ function syncToastPause(id, paused) {
947
+ const entry = entries.find((e) => e.id === id);
948
+ if (!entry) return;
949
+ const wasPaused = entry.pausedBy.size > 0;
950
+ entry.pausedBy.clear();
951
+ if (paused.pointer) entry.pausedBy.add("pointer");
952
+ if (paused.focus) entry.pausedBy.add("focus");
953
+ if (entry.pausedBy.size > 0) clearTimer(entry);
954
+ else if (wasPaused && entry.kind === "ok") arm(id, LEAVE_MS);
955
+ }
956
+ function dismissToast(id) {
957
+ const i = entries.findIndex((e) => e.id === id);
958
+ if (i < 0) return;
959
+ const [entry] = entries.splice(i, 1);
960
+ if (entry) clearTimer(entry);
961
+ publish();
962
+ }
963
+ function dismissAllToasts() {
964
+ for (const entry of entries) clearTimer(entry);
965
+ entries = [];
966
+ publish();
967
+ }
968
+
969
+ // src/toast/ToastHost.tsx
970
+ import { withImeGuard as withImeGuard2 } from "@kanyun-ai-infra/band-plugin-sdk/keys";
971
+ import { useEffect as useEffect2, useRef as useRef2, useSyncExternalStore } from "react";
972
+ import { createPortal } from "react-dom";
973
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
974
+ var MODAL_SELECTOR = "dialog:modal, dialog[open][data-band-layer]";
975
+ var MODAL_FALLBACK = "dialog[open][data-band-layer]";
976
+ var modalOrder = /* @__PURE__ */ new Map();
977
+ var modalSeq = 0;
978
+ function openModals() {
979
+ try {
980
+ return [...document.querySelectorAll(MODAL_SELECTOR)];
981
+ } catch {
982
+ return [...document.querySelectorAll(MODAL_FALLBACK)];
983
+ }
984
+ }
985
+ function modalTarget() {
986
+ if (typeof document === "undefined") return null;
987
+ const modals = openModals();
988
+ const live = new Set(modals);
989
+ for (const el of [...modalOrder.keys()]) if (!live.has(el)) modalOrder.delete(el);
990
+ for (const el of modals) if (!modalOrder.has(el)) modalOrder.set(el, ++modalSeq);
991
+ let top = null;
992
+ let seq2 = -1;
993
+ for (const el of modals) {
994
+ const n = modalOrder.get(el) ?? 0;
995
+ if (n > seq2) {
996
+ seq2 = n;
997
+ top = el;
998
+ }
999
+ }
1000
+ return top ?? null;
1001
+ }
1002
+ var modalListeners = /* @__PURE__ */ new Set();
1003
+ var modalObserver = null;
1004
+ var modalSnapshot = null;
1005
+ function topChanged() {
1006
+ const next = modalTarget();
1007
+ if (next === modalSnapshot) return;
1008
+ modalSnapshot = next;
1009
+ for (const fn of [...modalListeners]) fn();
1010
+ }
1011
+ if (typeof document !== "undefined") {
1012
+ document.addEventListener(
1013
+ "toggle",
1014
+ (e) => {
1015
+ const el = e.target;
1016
+ if (!el || typeof el.tagName !== "string" || el.tagName !== "DIALOG") return;
1017
+ if (el.open) {
1018
+ if (!modalOrder.has(el)) modalOrder.set(el, ++modalSeq);
1019
+ } else {
1020
+ modalOrder.delete(el);
1021
+ }
1022
+ if (modalListeners.size > 0) topChanged();
1023
+ },
1024
+ true
1025
+ );
1026
+ }
1027
+ function subscribeModals(listener) {
1028
+ modalListeners.add(listener);
1029
+ if (!modalObserver && typeof MutationObserver !== "undefined") {
1030
+ modalSnapshot = modalTarget();
1031
+ modalObserver = new MutationObserver(topChanged);
1032
+ modalObserver.observe(document.documentElement, {
1033
+ childList: true,
1034
+ subtree: true,
1035
+ attributes: true,
1036
+ attributeFilter: ["open"]
1037
+ });
1038
+ }
1039
+ return () => {
1040
+ modalListeners.delete(listener);
1041
+ if (modalListeners.size === 0) {
1042
+ modalObserver?.disconnect();
1043
+ modalObserver = null;
1044
+ }
1045
+ };
1046
+ }
1047
+ function modalSnapshotNow() {
1048
+ return modalObserver ? modalSnapshot : modalTarget();
1049
+ }
1050
+ var entered = /* @__PURE__ */ new Set();
1051
+ function ToastRow({ item }) {
1052
+ const label = item.action?.label ?? (item.kind === "bad" ? TOAST_CLOSE_LABEL : void 0);
1053
+ const row = useRef2(null);
1054
+ const first = useRef2(!entered.has(item.id));
1055
+ useEffect2(() => {
1056
+ entered.add(item.id);
1057
+ const el = row.current;
1058
+ if (!el) return;
1059
+ syncToastPause(item.id, {
1060
+ pointer: el.matches(":hover"),
1061
+ focus: el.contains(document.activeElement)
1062
+ });
1063
+ }, [item.id]);
1064
+ const run = () => {
1065
+ dismissToast(item.id);
1066
+ item.action?.onClick();
1067
+ };
1068
+ return /* @__PURE__ */ jsxs3(
1069
+ "div",
1070
+ {
1071
+ ref: row,
1072
+ className: first.current ? "band-plugin-react-toast" : "band-plugin-react-toast band-plugin-react-toast-again",
1073
+ role: item.kind === "bad" ? "alert" : void 0,
1074
+ onPointerEnter: () => pauseToast(item.id, "pointer"),
1075
+ onPointerLeave: () => resumeToast(item.id, "pointer"),
1076
+ onFocus: () => pauseToast(item.id, "focus"),
1077
+ onBlur: () => resumeToast(item.id, "focus"),
1078
+ onKeyDown: withImeGuard2((e) => {
1079
+ if (e.key !== "Escape") return;
1080
+ e.preventDefault();
1081
+ e.stopPropagation();
1082
+ dismissToast(item.id);
1083
+ }),
1084
+ children: [
1085
+ /* @__PURE__ */ jsx3("span", { className: `band-plugin-react-toast-icon ${item.kind}`, "aria-hidden": "true", children: item.kind === "ok" ? "\u2713" : item.kind === "bad" ? "!" : "" }),
1086
+ /* @__PURE__ */ jsxs3("span", { className: "band-plugin-react-toast-text", children: [
1087
+ item.text,
1088
+ item.detail ? /* @__PURE__ */ jsx3("small", { className: "band-plugin-react-toast-detail", children: item.detail }) : null
1089
+ ] }),
1090
+ label ? /* @__PURE__ */ jsx3("button", { type: "button", className: "band-plugin-react-toast-act", onClick: run, children: label }) : /* @__PURE__ */ jsx3("span", {})
1091
+ ]
1092
+ }
1093
+ );
1094
+ }
1095
+ function ToastHost() {
1096
+ const items = useSyncExternalStore(subscribeToasts, toastsSnapshot, emptyToasts);
1097
+ const watching = items.length > 0;
1098
+ const target = useSyncExternalStore(
1099
+ watching ? subscribeModals : noSubscribe,
1100
+ watching ? modalSnapshotNow : noTarget,
1101
+ noTarget
1102
+ );
1103
+ useEffect2(() => {
1104
+ if (items.length === 0) {
1105
+ entered.clear();
1106
+ return;
1107
+ }
1108
+ const live = new Set(items.map((item) => item.id));
1109
+ for (const id of entered) if (!live.has(id)) entered.delete(id);
1110
+ }, [items]);
1111
+ const stack = /* @__PURE__ */ jsx3(
1112
+ "div",
1113
+ {
1114
+ className: "band-plugin-react-toast-stack",
1115
+ "aria-label": "\u901A\u77E5",
1116
+ "aria-live": "polite",
1117
+ "aria-relevant": "additions text",
1118
+ "aria-atomic": "false",
1119
+ children: items.map((item) => /* @__PURE__ */ jsx3(ToastRow, { item }, item.id))
1120
+ }
1121
+ );
1122
+ return target ? createPortal(stack, target) : stack;
1123
+ }
1124
+ function noSubscribe() {
1125
+ return () => {
1126
+ };
1127
+ }
1128
+ function noTarget() {
1129
+ return null;
1130
+ }
1131
+
1132
+ // src/person-picker.tsx
1133
+ import { withImeGuard as withImeGuard3 } from "@kanyun-ai-infra/band-plugin-sdk/keys";
1134
+ import { useCallback, useEffect as useEffect3, useId as useId2, useLayoutEffect, useMemo as useMemo2, useRef as useRef3, useState as useState2 } from "react";
1135
+
1136
+ // src/person-picker-model.ts
1137
+ function normChain(chain) {
1138
+ const parts = chain.split("/").filter(Boolean);
1139
+ return parts.length === 0 ? "/" : `/${parts.join("/")}/`;
1140
+ }
1141
+ function chainUnder(person, org) {
1142
+ return normChain(person).startsWith(normChain(org));
1143
+ }
1144
+ function orgCheck(org, picked, blocked) {
1145
+ if (org.chain === void 0 || org.count === void 0) return null;
1146
+ const chain = org.chain;
1147
+ const blockedIds = new Set(
1148
+ blocked.filter((b) => b.chain !== void 0 && chainUnder(b.chain, chain)).map((b) => b.id)
1149
+ );
1150
+ const selectedIds = new Set(
1151
+ picked.filter((p) => p.chain !== void 0 && chainUnder(p.chain, chain) && !blockedIds.has(p.id)).map((p) => p.id)
1152
+ );
1153
+ const selectable = Math.max(0, org.count - blockedIds.size);
1154
+ const selected = selectedIds.size;
1155
+ const state = selected === 0 ? "off" : selectable > 0 && selected >= selectable ? "on" : "mixed";
1156
+ return { state, selectable, selected };
1157
+ }
1158
+ function precheckOrgAdd(org, check, room) {
1159
+ if (check.selectable === 0) return `${org.name}\u91CC\u7684\u4EBA\u90FD\u4E0D\u80FD\u9009`;
1160
+ const need = check.selectable - check.selected;
1161
+ if (room !== void 0 && need > room)
1162
+ return `${org.name}\u8FD8\u6709 ${need} \u4EBA\u6CA1\u9009\uFF0C\u540D\u5355\u6700\u591A\u8FD8\u80FD\u52A0 ${room} \u4EBA\uFF0C\u6CA1\u6709\u52A0`;
1163
+ return null;
1164
+ }
1165
+ function planOrgAdd(org, members, picked, blocked, room) {
1166
+ const have = new Set(picked.map((p) => p.id));
1167
+ const no = new Set(blocked.map((b) => b.id));
1168
+ const seen = /* @__PURE__ */ new Set();
1169
+ const add = [];
1170
+ let skipped = 0;
1171
+ for (const m of members) {
1172
+ if (seen.has(m.id)) continue;
1173
+ seen.add(m.id);
1174
+ if (have.has(m.id) || no.has(m.id)) {
1175
+ skipped++;
1176
+ continue;
1177
+ }
1178
+ add.push(m);
1179
+ }
1180
+ if (room !== void 0 && add.length > room)
1181
+ return { refuse: `${org.name}\u8FD8\u6709 ${add.length} \u4EBA\u6CA1\u9009\uFF0C\u540D\u5355\u6700\u591A\u8FD8\u80FD\u52A0 ${room} \u4EBA\uFF0C\u6CA1\u6709\u52A0` };
1182
+ return { add, skipped };
1183
+ }
1184
+ function idsUnder(org, picked) {
1185
+ const chain = org.chain;
1186
+ if (chain === void 0) return [];
1187
+ return picked.filter((p) => p.chain !== void 0 && chainUnder(p.chain, chain)).map((p) => p.id);
1188
+ }
1189
+
1190
+ // src/person-picker.tsx
1191
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1192
+ var LDAP = /^[a-z][a-z0-9._-]{1,63}$/i;
1193
+ var SPLIT = /[\s,,、;;]+/;
1194
+ var MEMBERS_MAX = 500;
1195
+ function errorText(e) {
1196
+ if (e instanceof Error && e.message) return e.message;
1197
+ return "\u51FA\u9519\u4E86";
1198
+ }
1199
+ function useLoad(key, fn, delay = 0) {
1200
+ const [load, setLoad] = useState2({ state: "idle" });
1201
+ const [nonce, setNonce] = useState2(0);
1202
+ const fnRef = useRef3(fn);
1203
+ fnRef.current = fn;
1204
+ useEffect3(() => {
1205
+ if (key === null) {
1206
+ setLoad({ state: "idle" });
1207
+ return;
1208
+ }
1209
+ const ac = new AbortController();
1210
+ setLoad({ state: "loading" });
1211
+ const t = setTimeout(() => {
1212
+ fnRef.current(ac.signal).then(
1213
+ (data) => !ac.signal.aborted && setLoad({ state: "ok", data }),
1214
+ (e) => !ac.signal.aborted && setLoad({ state: "error", message: errorText(e) })
1215
+ );
1216
+ }, delay);
1217
+ return () => {
1218
+ clearTimeout(t);
1219
+ ac.abort();
1220
+ };
1221
+ }, [key, nonce, delay]);
1222
+ return { load, reload: () => setNonce((n) => n + 1) };
1223
+ }
1224
+ function rowKey(r) {
1225
+ switch (r.kind) {
1226
+ case "up":
1227
+ return `up:${r.depth}`;
1228
+ case "here":
1229
+ return `here:${r.org.id}`;
1230
+ case "org":
1231
+ return `org:${r.org.id}`;
1232
+ case "person":
1233
+ return `p:${r.person.id}`;
1234
+ case "raw":
1235
+ return `raw:${r.id}`;
1236
+ }
1237
+ }
1238
+ function Tuning({ label }) {
1239
+ return /* @__PURE__ */ jsxs4("output", { className: "band-plugin-react-pp-state", children: [
1240
+ /* @__PURE__ */ jsx4("span", { className: "tuning band-plugin-react-pp-tuning", "aria-hidden": "true", children: /* @__PURE__ */ jsxs4("svg", { viewBox: "0 0 80 55", "aria-hidden": "true", children: [
1241
+ /* @__PURE__ */ jsx4("line", { x1: "0", y1: "11", x2: "80", y2: "11" }),
1242
+ /* @__PURE__ */ jsx4("line", { x1: "0", y1: "22", x2: "80", y2: "22" }),
1243
+ /* @__PURE__ */ jsx4("line", { x1: "0", y1: "33", x2: "80", y2: "33" }),
1244
+ /* @__PURE__ */ jsx4("line", { x1: "0", y1: "44", x2: "80", y2: "44" }),
1245
+ /* @__PURE__ */ jsx4("circle", { cx: "20", cy: "33", r: "4.5" }),
1246
+ /* @__PURE__ */ jsx4("circle", { cx: "40", cy: "22", r: "4.5" }),
1247
+ /* @__PURE__ */ jsx4("circle", { cx: "60", cy: "11", r: "4.5" })
1248
+ ] }) }),
1249
+ /* @__PURE__ */ jsx4("span", { children: label })
1250
+ ] });
1251
+ }
1252
+ function TriBox({
1253
+ state,
1254
+ disabled,
1255
+ onToggle,
1256
+ label
1257
+ }) {
1258
+ const ref = useRef3(null);
1259
+ useLayoutEffect(() => {
1260
+ if (ref.current) ref.current.indeterminate = state === "mixed";
1261
+ }, [state]);
1262
+ return /* @__PURE__ */ jsx4(
1263
+ "input",
1264
+ {
1265
+ ref,
1266
+ type: "checkbox",
1267
+ className: "checkbox",
1268
+ checked: state === "on",
1269
+ disabled,
1270
+ tabIndex: -1,
1271
+ "aria-label": label,
1272
+ "data-state": state,
1273
+ onMouseDown: (e) => e.preventDefault(),
1274
+ onClick: (e) => {
1275
+ e.stopPropagation();
1276
+ e.preventDefault();
1277
+ onToggle();
1278
+ },
1279
+ onChange: () => {
1280
+ }
1281
+ }
1282
+ );
1283
+ }
1284
+ function PersonSearch({
1285
+ label,
1286
+ directory,
1287
+ picked,
1288
+ onPick,
1289
+ onUnpick,
1290
+ multiple = false,
1291
+ room,
1292
+ disabled = [],
1293
+ allowUnknown = false,
1294
+ placeholder,
1295
+ busy = false,
1296
+ rootLabel = "\u5168\u90E8\u95E8",
1297
+ onLearn,
1298
+ defaultOpen = false,
1299
+ defaultQuery = "",
1300
+ defaultTrail = []
1301
+ }) {
1302
+ const id = useId2();
1303
+ const listId = `${id}-list`;
1304
+ const [open, setOpen] = useState2(defaultOpen);
1305
+ const [query, setQuery] = useState2(defaultQuery);
1306
+ const [trail, setTrail] = useState2(defaultTrail);
1307
+ const org = trail[trail.length - 1]?.id ?? null;
1308
+ const [active, setActive] = useState2({
1309
+ page: null,
1310
+ i: 0
1311
+ });
1312
+ const [notice, setNotice] = useState2(null);
1313
+ const [batch, setBatch] = useState2(null);
1314
+ const input = useRef3(null);
1315
+ const list = useRef3(null);
1316
+ const host = useRef3(null);
1317
+ const inflight = useRef3(null);
1318
+ const begin = () => {
1319
+ inflight.current?.abort();
1320
+ setBatch(null);
1321
+ const ac = new AbortController();
1322
+ inflight.current = ac;
1323
+ return ac;
1324
+ };
1325
+ const cancel = () => {
1326
+ inflight.current?.abort();
1327
+ inflight.current = null;
1328
+ setBatch(null);
1329
+ };
1330
+ useEffect3(() => () => inflight.current?.abort(), []);
1331
+ useEffect3(() => {
1332
+ if (!open) cancel();
1333
+ }, [open]);
1334
+ const q = query.trim();
1335
+ const browsing = q === "" && directory.browse !== void 0;
1336
+ const pickedIds = useMemo2(() => new Set(picked.map((p) => p.id)), [picked]);
1337
+ const blockedById = useMemo2(() => new Map(disabled.map((b) => [b.id, b.reason])), [disabled]);
1338
+ const full = room !== void 0 && room <= 0;
1339
+ const canTree = multiple && directory.members !== void 0;
1340
+ const searchLoad = useLoad(
1341
+ open && q !== "" ? `s:${q}` : null,
1342
+ (signal) => directory.search(q, { signal }),
1343
+ 200
1344
+ );
1345
+ const browseLoad = useLoad(
1346
+ open && browsing ? `b:${org ?? ""}` : null,
1347
+ (signal) => {
1348
+ if (!directory.browse) throw new Error("\u4E0D\u652F\u6301\u6309\u90E8\u95E8\u6D4F\u89C8");
1349
+ const chain = trail[trail.length - 1]?.chain;
1350
+ return directory.browse(org, { signal, ...chain ? { chain } : {} });
1351
+ }
1352
+ );
1353
+ const current = browsing ? browseLoad : searchLoad;
1354
+ const page = current.load.state === "ok" ? current.load.data : null;
1355
+ const rows = useMemo2(() => {
1356
+ if (!page) return [];
1357
+ const out = [];
1358
+ if (browsing && trail.length > 0) {
1359
+ const parent = trail.length >= 2 ? trail[trail.length - 2] : void 0;
1360
+ out.push({ kind: "up", depth: trail.length - 1, label: parent?.name ?? rootLabel });
1361
+ const here = trail[trail.length - 1];
1362
+ if (canTree && here) out.push({ kind: "here", org: here });
1363
+ }
1364
+ for (const o of page.orgs) out.push({ kind: "org", org: o });
1365
+ for (const p of page.people) out.push({ kind: "person", person: p });
1366
+ if (!browsing && allowUnknown && LDAP.test(q) && !page.people.some((p) => p.id === q) && !pickedIds.has(q) && // 不能选的人(已经是管理员这类)不给「按 ldap 加」的后门
1367
+ !blockedById.has(q))
1368
+ out.push({ kind: "raw", id: q });
1369
+ return out;
1370
+ }, [page, browsing, trail, canTree, allowUnknown, q, pickedIds, blockedById, rootLabel]);
1371
+ const activeIndex = rows.length === 0 ? -1 : Math.min(active.page === page ? active.i : 0, rows.length - 1);
1372
+ useEffect3(() => {
1373
+ if (activeIndex < 0 || !list.current) return;
1374
+ const el = list.current.querySelector(`[data-row="${activeIndex}"]`);
1375
+ if (el) scrollIntoPanel(el);
1376
+ }, [activeIndex]);
1377
+ useEffect3(() => {
1378
+ if (!open) return;
1379
+ const onDown = (e) => {
1380
+ if (host.current && !host.current.contains(e.target)) setOpen(false);
1381
+ };
1382
+ document.addEventListener("pointerdown", onDown);
1383
+ return () => document.removeEventListener("pointerdown", onDown);
1384
+ }, [open]);
1385
+ const reasonOf = useCallback(
1386
+ (p) => {
1387
+ const r = blockedById.get(p.id);
1388
+ if (r) return r;
1389
+ if (!multiple || pickedIds.has(p.id)) return null;
1390
+ if (full) return "\u540D\u5355\u5DF2\u6EE1";
1391
+ return null;
1392
+ },
1393
+ [blockedById, multiple, pickedIds, full]
1394
+ );
1395
+ const checkOf = useCallback(
1396
+ (o) => canTree ? orgCheck(o, picked, disabled) : null,
1397
+ [canTree, picked, disabled]
1398
+ );
1399
+ function choose(p) {
1400
+ if (reasonOf(p)) return;
1401
+ if (pickedIds.has(p.id)) {
1402
+ if (multiple) onUnpick?.([p.id]);
1403
+ return;
1404
+ }
1405
+ onPick([p]);
1406
+ setNotice(null);
1407
+ if (!multiple) {
1408
+ setOpen(false);
1409
+ setQuery("");
1410
+ }
1411
+ }
1412
+ async function toggleOrg(o) {
1413
+ const check = checkOf(o);
1414
+ if (!check || !directory.members || batch) return;
1415
+ if (check.state === "on") {
1416
+ const ids = idsUnder(o, picked);
1417
+ if (ids.length > 0) onUnpick?.(ids);
1418
+ setNotice(`\u53D6\u6D88\u4E86${o.name}\u7684 ${ids.length} \u4EBA`);
1419
+ return;
1420
+ }
1421
+ const pre = precheckOrgAdd(o, check, room);
1422
+ if (pre) {
1423
+ setNotice(pre);
1424
+ return;
1425
+ }
1426
+ if (o.count !== void 0 && o.count > MEMBERS_MAX) {
1427
+ setNotice(`${o.name}\u6709 ${o.count} \u4EBA\uFF0C\u8D85\u8FC7\u4E00\u6B21\u80FD\u52A0\u7684 ${MEMBERS_MAX} \u4EBA\uFF0C\u6CA1\u6709\u52A0`);
1428
+ return;
1429
+ }
1430
+ const ac = begin();
1431
+ const signal = ac.signal;
1432
+ setBatch(o.id);
1433
+ try {
1434
+ const limit = Math.min(o.count ?? MEMBERS_MAX, MEMBERS_MAX);
1435
+ const { people, total } = await directory.members(o.id, {
1436
+ signal,
1437
+ limit,
1438
+ ...o.chain ? { chain: o.chain } : {}
1439
+ });
1440
+ if (signal.aborted) return;
1441
+ if (total > people.length) {
1442
+ setNotice(`${o.name}\u6709 ${total} \u4EBA\uFF0C\u8D85\u8FC7\u4E00\u6B21\u80FD\u52A0\u7684\u4EBA\u6570\uFF0C\u6CA1\u6709\u52A0`);
1443
+ return;
1444
+ }
1445
+ const plan = planOrgAdd(o, people, picked, disabled, room);
1446
+ if ("refuse" in plan) {
1447
+ onLearn?.(people.filter((p) => p.chain));
1448
+ setNotice(plan.refuse);
1449
+ return;
1450
+ }
1451
+ if (plan.add.length > 0) onPick(plan.add);
1452
+ onLearn?.(people.filter((p) => p.chain));
1453
+ setNotice(
1454
+ 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` : ""}`
1455
+ );
1456
+ } catch (e) {
1457
+ if (!signal.aborted) setNotice(`${o.name}\u7684\u4EBA\u6CA1\u53D6\u5230\uFF1A${errorText(e)}`);
1458
+ } finally {
1459
+ if (inflight.current === ac) {
1460
+ inflight.current = null;
1461
+ setBatch(null);
1462
+ }
1463
+ }
1464
+ }
1465
+ function activate(r) {
1466
+ switch (r.kind) {
1467
+ case "up":
1468
+ setTrail(trail.slice(0, r.depth));
1469
+ break;
1470
+ case "org":
1471
+ setTrail(browsing ? [...trail, r.org] : [r.org]);
1472
+ setQuery("");
1473
+ break;
1474
+ case "here":
1475
+ void toggleOrg(r.org);
1476
+ break;
1477
+ case "person":
1478
+ choose(r.person);
1479
+ break;
1480
+ case "raw":
1481
+ choose({ id: r.id, name: r.id, inBand: false });
1482
+ if (multiple) setQuery("");
1483
+ break;
1484
+ }
1485
+ input.current?.focus();
1486
+ }
1487
+ async function onPaste(e) {
1488
+ const text = e.clipboardData.getData("text");
1489
+ const parts = [...new Set(text.split(SPLIT).filter(Boolean))];
1490
+ if (!multiple || parts.length < 2) return;
1491
+ e.preventDefault();
1492
+ const bad = parts.filter((x) => !LDAP.test(x));
1493
+ const ids = parts.filter((x) => LDAP.test(x) && !pickedIds.has(x));
1494
+ if (ids.length === 0) {
1495
+ setNotice(bad.length > 0 ? `\u8FD9\u4E9B\u4E0D\u662F ldap\uFF0C\u6CA1\u6709\u52A0\uFF1A${bad.join("\u3001")}` : "\u7C98\u8D34\u7684\u4EBA\u90FD\u5DF2\u7ECF\u9009\u4E86");
1496
+ return;
1497
+ }
1498
+ if (room !== void 0 && ids.length > room) {
1499
+ setNotice(`\u7C98\u8D34\u4E86 ${ids.length} \u4E2A ldap\uFF0C\u540D\u5355\u6700\u591A\u8FD8\u80FD\u52A0 ${room} \u4EBA\uFF0C\u6CA1\u6709\u52A0`);
1500
+ return;
1501
+ }
1502
+ let found = [];
1503
+ let missing = ids;
1504
+ let why;
1505
+ if (directory.resolve) {
1506
+ const signal = begin().signal;
1507
+ try {
1508
+ const r = await directory.resolve(ids, { signal });
1509
+ if (signal.aborted) return;
1510
+ found = r.people;
1511
+ missing = r.missing;
1512
+ why = r.fallback;
1513
+ } catch (err) {
1514
+ if (!signal.aborted) setNotice(`\u7C98\u8D34\u7684 ldap \u6CA1\u67E5\u6210\uFF1A${errorText(err)}`);
1515
+ return;
1516
+ }
1517
+ }
1518
+ const extra = allowUnknown ? missing.map((m) => ({ id: m, name: m, inBand: false })) : [];
1519
+ const seen = /* @__PURE__ */ new Set();
1520
+ const add = [...found, ...extra].filter(
1521
+ (p) => !blockedById.has(p.id) && !seen.has(p.id) && seen.add(p.id)
1522
+ );
1523
+ if (add.length > 0) onPick(add);
1524
+ const tail = [
1525
+ !allowUnknown && missing.length > 0 ? `${missing.length} \u4E2A\u6CA1\u627E\u5230\uFF1A${missing.join("\u3001")}${why ? `\uFF08${why}\uFF09` : ""}` : "",
1526
+ bad.length > 0 ? `\u8FD9\u4E9B\u4E0D\u662F ldap\uFF1A${bad.join("\u3001")}` : ""
1527
+ ].filter(Boolean);
1528
+ setNotice(`\u52A0\u4E86 ${add.length} \u4EBA${tail.length > 0 ? `\uFF1B${tail.join("\uFF1B")}` : ""}`);
1529
+ }
1530
+ const onKeyDown = withImeGuard3((e) => {
1531
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1532
+ e.preventDefault();
1533
+ if (!open) return setOpen(true);
1534
+ if (rows.length === 0) return;
1535
+ const d = e.key === "ArrowDown" ? 1 : -1;
1536
+ setActive({ page, i: (activeIndex + d + rows.length) % rows.length });
1537
+ return;
1538
+ }
1539
+ if (e.key === "Enter") {
1540
+ if (!open) return;
1541
+ e.preventDefault();
1542
+ const r = rows[activeIndex];
1543
+ if (r) activate(r);
1544
+ return;
1545
+ }
1546
+ if (e.key === " " && open && query === "") {
1547
+ const r = rows[activeIndex];
1548
+ if (r?.kind === "org" || r?.kind === "here") {
1549
+ e.preventDefault();
1550
+ void toggleOrg(r.org);
1551
+ } else if (r?.kind === "person" && multiple) {
1552
+ e.preventDefault();
1553
+ choose(r.person);
1554
+ }
1555
+ return;
1556
+ }
1557
+ if (e.key === "ArrowRight" && open && query === "") {
1558
+ const r = rows[activeIndex];
1559
+ if (r?.kind === "org") {
1560
+ e.preventDefault();
1561
+ activate(r);
1562
+ }
1563
+ return;
1564
+ }
1565
+ if ((e.key === "ArrowLeft" || e.key === "Backspace") && open && query === "" && browsing && trail.length > 0) {
1566
+ e.preventDefault();
1567
+ setTrail(trail.slice(0, -1));
1568
+ return;
1569
+ }
1570
+ if (e.key === "Escape" && open) {
1571
+ e.preventDefault();
1572
+ e.stopPropagation();
1573
+ setOpen(false);
1574
+ }
1575
+ });
1576
+ const activeId = activeIndex >= 0 ? `${id}-r${activeIndex}` : void 0;
1577
+ 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");
1578
+ let body;
1579
+ if (!browsing && q === "" || browsing && page?.fallback && page.orgs.length === 0 && page.people.length === 0) {
1580
+ body = /* @__PURE__ */ jsx4("div", { className: "band-plugin-react-pp-state", children: "\u8F93\u5165\u59D3\u540D\u6216 ldap \u67E5\u627E" });
1581
+ } else if (current.load.state === "loading" || current.load.state === "idle") {
1582
+ body = /* @__PURE__ */ jsx4(Tuning, { label: browsing ? "\u6B63\u5728\u8BFB\u7EC4\u7EC7\u67B6\u6784" : "\u6B63\u5728\u67E5" });
1583
+ } else if (current.load.state === "error") {
1584
+ body = /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-pp-state band-plugin-react-retry", role: "alert", children: [
1585
+ /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-error", children: [
1586
+ browsing ? "\u7EC4\u7EC7\u67B6\u6784\u6CA1\u8BFB\u51FA\u6765" : "\u6CA1\u67E5\u6210",
1587
+ "\uFF1A",
1588
+ current.load.message
1589
+ ] }),
1590
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "btn sm", onClick: current.reload, children: "\u91CD\u8BD5" })
1591
+ ] });
1592
+ } else if (rows.length === 0) {
1593
+ 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` });
1594
+ } else {
1595
+ body = // biome-ignore lint/a11y/useFocusableInteractive: 焦点留在输入框,列表靠 aria-activedescendant
1596
+ /* @__PURE__ */ jsx4(
1597
+ "div",
1598
+ {
1599
+ className: "band-plugin-react-pp-list",
1600
+ role: "listbox",
1601
+ id: listId,
1602
+ ref: list,
1603
+ "aria-label": `${label}\u7684\u5019\u9009`,
1604
+ "aria-multiselectable": multiple || void 0,
1605
+ children: rows.map((r, i) => /* @__PURE__ */ jsx4(
1606
+ RowView,
1607
+ {
1608
+ row: r,
1609
+ index: i,
1610
+ optionId: `${id}-r${i}`,
1611
+ active: i === activeIndex,
1612
+ multiple,
1613
+ picked: r.kind === "person" && pickedIds.has(r.person.id),
1614
+ reason: r.kind === "person" ? reasonOf(r.person) : null,
1615
+ check: r.kind === "org" || r.kind === "here" ? checkOf(r.org) : null,
1616
+ batching: (r.kind === "org" || r.kind === "here") && batch === r.org.id,
1617
+ query: browsing ? "" : q,
1618
+ onHover: () => setActive({ page, i }),
1619
+ onActivate: () => activate(r),
1620
+ onToggleOrg: (o) => {
1621
+ void toggleOrg(o);
1622
+ input.current?.focus();
1623
+ }
1624
+ },
1625
+ rowKey(r)
1626
+ ))
1627
+ }
1628
+ );
1629
+ }
1630
+ const reason = page?.fallback ?? directory.unavailable;
1631
+ const chosen = !multiple ? picked[0] : void 0;
1632
+ return /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-pp", ref: host, children: [
1633
+ /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-pp-field field-host", children: [
1634
+ /* @__PURE__ */ jsxs4("svg", { className: "band-plugin-react-pp-icon", viewBox: "0 0 16 16", "aria-hidden": "true", children: [
1635
+ /* @__PURE__ */ jsx4("circle", { cx: "7", cy: "7", r: "4.5" }),
1636
+ /* @__PURE__ */ jsx4("path", { d: "M10.5 10.5 14 14" })
1637
+ ] }),
1638
+ chosen && /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-chosen", children: [
1639
+ /* @__PURE__ */ jsx4(Avatar, { id: chosen.id, name: chosen.name, size: "xs", decorative: true }),
1640
+ chosen.name,
1641
+ chosen.name !== chosen.id && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-id", children: chosen.id }),
1642
+ /* @__PURE__ */ jsx4(
1643
+ "button",
1644
+ {
1645
+ type: "button",
1646
+ "aria-label": `\u6362\u6389${chosen.name}`,
1647
+ onClick: () => {
1648
+ onUnpick?.([chosen.id]);
1649
+ input.current?.focus();
1650
+ },
1651
+ children: "\xD7"
1652
+ }
1653
+ )
1654
+ ] }),
1655
+ /* @__PURE__ */ jsx4(
1656
+ "input",
1657
+ {
1658
+ ref: input,
1659
+ className: "field bare",
1660
+ role: "combobox",
1661
+ "aria-label": label,
1662
+ "aria-expanded": open,
1663
+ "aria-controls": listId,
1664
+ "aria-autocomplete": "list",
1665
+ "aria-activedescendant": open ? activeId : void 0,
1666
+ value: query,
1667
+ placeholder: ph,
1668
+ disabled: busy,
1669
+ autoComplete: "off",
1670
+ onFocus: () => setOpen(true),
1671
+ onClick: () => setOpen(true),
1672
+ onChange: (e) => {
1673
+ setQuery(e.target.value);
1674
+ setOpen(true);
1675
+ setNotice(null);
1676
+ },
1677
+ onKeyDown,
1678
+ onPaste: (e) => void onPaste(e)
1679
+ }
1680
+ )
1681
+ ] }),
1682
+ notice && /* @__PURE__ */ jsx4("output", { className: "band-plugin-react-pp-notice", children: notice }),
1683
+ open && !busy && /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-pp-pop", children: [
1684
+ reason && /* @__PURE__ */ jsx4("div", { className: "band-plugin-react-pp-fallback", children: reason }),
1685
+ browsing && /* @__PURE__ */ jsxs4("nav", { className: "band-plugin-react-pp-trail", "aria-label": "\u90E8\u95E8\u8DEF\u5F84", children: [
1686
+ /* @__PURE__ */ jsx4(
1687
+ "button",
1688
+ {
1689
+ type: "button",
1690
+ tabIndex: -1,
1691
+ onClick: () => setTrail([]),
1692
+ "aria-current": trail.length === 0 ? "location" : void 0,
1693
+ children: rootLabel
1694
+ }
1695
+ ),
1696
+ trail.map((t, i) => /* @__PURE__ */ jsxs4("span", { children: [
1697
+ /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: "/" }),
1698
+ /* @__PURE__ */ jsx4(
1699
+ "button",
1700
+ {
1701
+ type: "button",
1702
+ tabIndex: -1,
1703
+ onClick: () => setTrail(trail.slice(0, i + 1)),
1704
+ "aria-current": i === trail.length - 1 ? "location" : void 0,
1705
+ children: t.name
1706
+ }
1707
+ )
1708
+ ] }, t.id))
1709
+ ] }),
1710
+ body,
1711
+ page?.truncated && !browsing && /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-pp-sub band-plugin-react-pp-foot", children: [
1712
+ "\u53EA\u663E\u793A\u4E86\u524D ",
1713
+ page.people.length,
1714
+ " \u4EBA\uFF0C\u6362\u4E2A\u66F4\u51C6\u7684\u8BCD"
1715
+ ] })
1716
+ ] })
1717
+ ] });
1718
+ }
1719
+ function mark(text, q) {
1720
+ if (q === "") return text;
1721
+ const i = text.toLowerCase().indexOf(q.toLowerCase());
1722
+ if (i < 0) return text;
1723
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
1724
+ text.slice(0, i),
1725
+ /* @__PURE__ */ jsx4("mark", { children: text.slice(i, i + q.length) }),
1726
+ text.slice(i + q.length)
1727
+ ] });
1728
+ }
1729
+ function checkLabel(o, check) {
1730
+ if (check.state === "on") return `\u53D6\u6D88${o.name}\u5168\u90E8 ${check.selectable} \u4EBA`;
1731
+ return `\u9009${o.name}\u5168\u90E8 ${check.selectable} \u4EBA${check.selected > 0 ? `\uFF08\u5DF2\u9009 ${check.selected} \u4EBA\uFF09` : ""}`;
1732
+ }
1733
+ function RowView({
1734
+ row,
1735
+ index,
1736
+ optionId,
1737
+ active,
1738
+ multiple,
1739
+ picked,
1740
+ reason,
1741
+ check,
1742
+ batching,
1743
+ query,
1744
+ onHover,
1745
+ onActivate,
1746
+ onToggleOrg
1747
+ }) {
1748
+ const cls = `band-plugin-react-pp-row${active ? " is-active" : ""}${reason ? " is-off" : ""}`;
1749
+ const common = {
1750
+ id: optionId,
1751
+ role: "option",
1752
+ "data-row": index,
1753
+ "aria-selected": active,
1754
+ className: cls,
1755
+ onMouseMove: onHover,
1756
+ onMouseDown: (e) => e.preventDefault(),
1757
+ onClick: () => onActivate()
1758
+ };
1759
+ switch (row.kind) {
1760
+ case "up":
1761
+ return /* @__PURE__ */ jsxs4("div", { ...common, children: [
1762
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-chev", "aria-hidden": "true", children: "\u2039" }),
1763
+ /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-name", children: [
1764
+ "\u8FD4\u56DE ",
1765
+ row.label
1766
+ ] })
1767
+ ] });
1768
+ case "here":
1769
+ return /* @__PURE__ */ jsxs4("div", { ...common, "aria-checked": check ? check.state === "on" : void 0, children: [
1770
+ check && /* @__PURE__ */ jsx4(
1771
+ TriBox,
1772
+ {
1773
+ state: check.state,
1774
+ disabled: check.selectable === 0 || batching,
1775
+ label: checkLabel(row.org, check),
1776
+ onToggle: () => onToggleOrg(row.org)
1777
+ }
1778
+ ),
1779
+ /* @__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}` }) }),
1780
+ check && /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-meta", children: [
1781
+ check.selected > 0 ? `\u5DF2\u9009 ${check.selected} / ` : "",
1782
+ check.selectable,
1783
+ " \u4EBA"
1784
+ ] })
1785
+ ] });
1786
+ case "org":
1787
+ return /* @__PURE__ */ jsxs4(
1788
+ "div",
1789
+ {
1790
+ ...common,
1791
+ "aria-checked": check ? check.state === "mixed" ? "mixed" : check.state === "on" : void 0,
1792
+ children: [
1793
+ check ? /* @__PURE__ */ jsx4(
1794
+ TriBox,
1795
+ {
1796
+ state: check.state,
1797
+ disabled: check.selectable === 0 || batching,
1798
+ label: checkLabel(row.org, check),
1799
+ onToggle: () => onToggleOrg(row.org)
1800
+ }
1801
+ ) : /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-dept", "aria-hidden": "true", children: /* @__PURE__ */ jsxs4("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: [
1802
+ /* @__PURE__ */ jsx4("rect", { x: "2", y: "3", width: "12", height: "10", rx: "2" }),
1803
+ /* @__PURE__ */ jsx4("path", { d: "M2 6.5h12" })
1804
+ ] }) }),
1805
+ /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-main", children: [
1806
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-name", children: batching ? "\u6B63\u5728\u53D6\u90E8\u95E8\u7684\u4EBA\u2026" : mark(row.org.name, query) }),
1807
+ query !== "" && row.org.path && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-sub", children: row.org.path })
1808
+ ] }),
1809
+ row.org.count !== void 0 && /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-meta", children: [
1810
+ check && check.selected > 0 ? `\u5DF2\u9009 ${check.selected} / ` : "",
1811
+ row.org.count,
1812
+ " \u4EBA"
1813
+ ] }),
1814
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-chev", "aria-hidden": "true", children: "\u203A" })
1815
+ ]
1816
+ }
1817
+ );
1818
+ case "person": {
1819
+ const p = row.person;
1820
+ return /* @__PURE__ */ jsxs4(
1821
+ "div",
1822
+ {
1823
+ ...common,
1824
+ "aria-disabled": reason ? true : void 0,
1825
+ "aria-checked": multiple ? picked : void 0,
1826
+ children: [
1827
+ multiple && /* @__PURE__ */ jsx4(
1828
+ "input",
1829
+ {
1830
+ type: "checkbox",
1831
+ className: "checkbox",
1832
+ checked: picked,
1833
+ readOnly: true,
1834
+ tabIndex: -1,
1835
+ "aria-hidden": "true",
1836
+ disabled: !!reason
1837
+ }
1838
+ ),
1839
+ /* @__PURE__ */ jsx4(Avatar, { id: p.id, name: p.name, size: "sm", decorative: true }),
1840
+ /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-main", children: [
1841
+ /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-name", children: [
1842
+ mark(p.name, query),
1843
+ " ",
1844
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-id", children: mark(p.id, query) })
1845
+ ] }),
1846
+ (reason || p.path) && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-sub", children: reason ?? p.path })
1847
+ ] }),
1848
+ !multiple && picked && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-meta", children: "\u5DF2\u9009" })
1849
+ ]
1850
+ }
1851
+ );
1852
+ }
1853
+ case "raw":
1854
+ return /* @__PURE__ */ jsxs4("div", { ...common, children: [
1855
+ /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-all", "aria-hidden": "true", children: "\uFF0B" }),
1856
+ /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-main", children: [
1857
+ /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-name", children: [
1858
+ "\u6309 ldap \u52A0\u300C",
1859
+ row.id,
1860
+ "\u300D"
1861
+ ] }),
1862
+ /* @__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" })
1863
+ ] })
1864
+ ] });
1865
+ }
1866
+ }
1867
+ function PersonPicker({
1868
+ value,
1869
+ onChange,
1870
+ max,
1871
+ readOnly = false,
1872
+ confirmRemove = false,
1873
+ emptyText = "\u8FD8\u6CA1\u6709\u4EBA",
1874
+ locked = {},
1875
+ addSlot,
1876
+ label,
1877
+ ...search
1878
+ }) {
1879
+ const [confirming, setConfirming] = useState2(null);
1880
+ const room = max === void 0 ? void 0 : Math.max(0, max - value.length);
1881
+ const remove = (id) => {
1882
+ onChange(value.filter((p) => p.id !== id));
1883
+ setConfirming(null);
1884
+ };
1885
+ return /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-pp-picker", children: [
1886
+ value.length === 0 ? /* @__PURE__ */ jsx4("div", { className: "band-plugin-react-pp-empty", children: emptyText }) : /* @__PURE__ */ jsx4(
1887
+ "ul",
1888
+ {
1889
+ className: "band-plugin-react-pp-people",
1890
+ "aria-label": `${label}\uFF1A\u5DF2\u9009 ${value.length} \u4EBA`,
1891
+ children: value.map((p) => /* @__PURE__ */ jsxs4("li", { className: "band-plugin-react-pp-person", children: [
1892
+ /* @__PURE__ */ jsx4(Avatar, { id: p.id, name: p.name, size: "md", decorative: true }),
1893
+ /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-main", children: [
1894
+ /* @__PURE__ */ jsxs4("span", { className: "band-plugin-react-pp-name", children: [
1895
+ p.name,
1896
+ " ",
1897
+ p.name !== p.id && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-id", children: p.id })
1898
+ ] }),
1899
+ (p.path || p.inBand === false) && /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-sub", children: [p.path, p.inBand === false ? "\u6CA1\u767B\u5F55\u8FC7 Band" : ""].filter(Boolean).join(" \xB7 ") })
1900
+ ] }),
1901
+ readOnly ? null : locked[p.id] ? /* @__PURE__ */ jsx4("span", { className: "band-plugin-react-pp-meta", children: locked[p.id] }) : confirming === p.id ? /* @__PURE__ */ jsxs4(
1902
+ "span",
1903
+ {
1904
+ className: "band-plugin-react-pp-confirm",
1905
+ role: "group",
1906
+ "aria-label": `\u786E\u8BA4\u79FB\u51FA${p.name}`,
1907
+ children: [
1908
+ /* @__PURE__ */ jsxs4("span", { children: [
1909
+ "\u79FB\u51FA",
1910
+ p.name,
1911
+ "\uFF1F"
1912
+ ] }),
1913
+ /* @__PURE__ */ jsx4("button", { type: "button", className: "btn sm danger", onClick: () => remove(p.id), children: "\u79FB\u51FA" }),
1914
+ /* @__PURE__ */ jsx4(
1915
+ "button",
1916
+ {
1917
+ type: "button",
1918
+ className: "btn sm ghost",
1919
+ onClick: () => setConfirming(null),
1920
+ children: "\u53D6\u6D88"
1921
+ }
1922
+ )
1923
+ ]
1924
+ }
1925
+ ) : /* @__PURE__ */ jsx4(
1926
+ "button",
1927
+ {
1928
+ type: "button",
1929
+ className: "btn ghost sm",
1930
+ "aria-label": `\u79FB\u51FA${p.name}`,
1931
+ disabled: search.busy,
1932
+ onClick: () => confirmRemove ? setConfirming(p.id) : remove(p.id),
1933
+ children: "\u79FB\u51FA"
1934
+ }
1935
+ )
1936
+ ] }, p.id))
1937
+ }
1938
+ ),
1939
+ !readOnly && addSlot,
1940
+ !readOnly && !addSlot && /* @__PURE__ */ jsxs4(Fragment2, { children: [
1941
+ /* @__PURE__ */ jsx4(
1942
+ PersonSearch,
1943
+ {
1944
+ ...search,
1945
+ label,
1946
+ multiple: true,
1947
+ picked: value,
1948
+ room,
1949
+ onPick: (people) => {
1950
+ const have = new Set(value.map((p) => p.id));
1951
+ const fresh = [];
1952
+ for (const p of people)
1953
+ if (!have.has(p.id)) {
1954
+ have.add(p.id);
1955
+ fresh.push(p);
1956
+ }
1957
+ onChange([...value, ...fresh]);
1958
+ },
1959
+ onUnpick: (ids) => {
1960
+ const drop = new Set(ids.filter((i) => !locked[i]));
1961
+ onChange(value.filter((p) => !drop.has(p.id)));
1962
+ }
1963
+ }
1964
+ ),
1965
+ max !== void 0 && /* @__PURE__ */ jsxs4("div", { className: "band-plugin-react-pp-count", children: [
1966
+ value.length,
1967
+ " / ",
1968
+ max,
1969
+ " \u4EBA"
1970
+ ] })
1971
+ ] })
1972
+ ] });
1973
+ }
1974
+ function peopleDirectory(api) {
1975
+ return {
1976
+ search: (q) => api.search(q),
1977
+ browse: (id, o) => api.org(id, o.chain ? { chain: o.chain } : {}),
1978
+ members: (id, o) => api.members(id, { limit: o.limit, ...o.chain ? { chain: o.chain } : {} }),
1979
+ resolve: (ids) => api.resolve(ids)
1980
+ };
1981
+ }
1982
+
1983
+ // src/settings/kit.tsx
1984
+ import {
1985
+ useEffect as useEffect4,
1986
+ useId as useId3,
1987
+ useRef as useRef4
1988
+ } from "react";
1989
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1990
+ function settingsLinkHandler(go, target) {
1991
+ return (e) => {
1992
+ if (!go) return;
1993
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
1994
+ e.preventDefault();
1995
+ go(target);
1996
+ };
1997
+ }
1998
+ function SettingsLayout({
1999
+ navLabel,
2000
+ title,
2001
+ obj,
2002
+ crumb,
2003
+ groups,
2004
+ current,
2005
+ view = "page",
2006
+ back,
2007
+ backMobile,
2008
+ onNavigate,
2009
+ mainRef,
2010
+ children
2011
+ }) {
2012
+ return /* @__PURE__ */ jsxs5("div", { className: "band-sf", "data-view": view, children: [
2013
+ /* @__PURE__ */ jsxs5("nav", { className: "band-sf-nav", "aria-label": navLabel, children: [
2014
+ /* @__PURE__ */ jsxs5("div", { className: "band-sf-head", children: [
2015
+ crumb ? /* @__PURE__ */ jsx5("div", { className: "band-sf-crumb", children: crumb }) : null,
2016
+ /* @__PURE__ */ jsx5("span", { className: "band-sf-title", children: title }),
2017
+ !crumb && obj ? /* @__PURE__ */ jsx5("span", { className: "band-sf-obj", children: obj }) : null
2018
+ ] }),
2019
+ groups.map((g) => /* @__PURE__ */ jsxs5("div", { className: "band-sf-grp", children: [
2020
+ /* @__PURE__ */ jsx5("span", { children: g.group }),
2021
+ g.sections.map((s) => /* @__PURE__ */ jsxs5(
2022
+ "a",
2023
+ {
2024
+ href: s.href,
2025
+ "aria-current": s.slug === current ? "page" : void 0,
2026
+ onClick: settingsLinkHandler(onNavigate, s),
2027
+ children: [
2028
+ s.title,
2029
+ s.glyph ?? null,
2030
+ /* @__PURE__ */ jsx5("span", { className: "band-sf-chev", "aria-hidden": "true", children: "\u203A" })
2031
+ ]
2032
+ },
2033
+ s.slug
2034
+ ))
2035
+ ] }, g.group))
2036
+ ] }),
2037
+ /* @__PURE__ */ jsx5("div", { className: "band-sf-scroll", children: /* @__PURE__ */ jsxs5("main", { className: "band-sf-main", "data-view": view, ref: mainRef, children: [
2038
+ view === "page" && back ? /* @__PURE__ */ jsx5(SettingsBack, { target: back, onNavigate }) : null,
2039
+ view === "page" && backMobile ? /* @__PURE__ */ jsx5(SettingsBack, { target: backMobile, onNavigate, mobileOnly: true }) : null,
2040
+ children
2041
+ ] }) })
2042
+ ] });
2043
+ }
2044
+ function SettingsBack({
2045
+ target,
2046
+ onNavigate,
2047
+ mobileOnly = false
2048
+ }) {
2049
+ return /* @__PURE__ */ jsxs5(
2050
+ "a",
2051
+ {
2052
+ className: mobileOnly ? "band-sf-back band-sf-back-m" : "band-sf-back",
2053
+ href: target.href,
2054
+ onClick: settingsLinkHandler(onNavigate, target),
2055
+ children: [
2056
+ /* @__PURE__ */ jsx5("span", { "aria-hidden": "true", children: "\u2039" }),
2057
+ " ",
2058
+ target.label
2059
+ ]
2060
+ }
2061
+ );
2062
+ }
2063
+ function SettingsHead({
2064
+ title,
2065
+ desc,
2066
+ action
2067
+ }) {
2068
+ return /* @__PURE__ */ jsxs5("div", { className: "band-sf-h", children: [
2069
+ /* @__PURE__ */ jsxs5("div", { children: [
2070
+ /* @__PURE__ */ jsx5("h1", { children: title }),
2071
+ desc ? /* @__PURE__ */ jsx5("p", { children: desc }) : null
2072
+ ] }),
2073
+ action ? /* @__PURE__ */ jsx5("div", { className: "band-sf-h-a", children: action }) : null
2074
+ ] });
2075
+ }
2076
+ function SettingsRows({ label, children }) {
2077
+ return /* @__PURE__ */ jsx5("ul", { className: "band-sf-rows", "aria-label": label, children });
2078
+ }
2079
+ var warnedExtra = false;
2080
+ function warnExtraWithOpen() {
2081
+ const env = globalThis.process?.env?.NODE_ENV;
2082
+ if (warnedExtra || env === void 0 || env === "production") return;
2083
+ warnedExtra = true;
2084
+ 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");
2085
+ }
2086
+ function SettingsRow({
2087
+ title,
2088
+ tags,
2089
+ meta,
2090
+ actions,
2091
+ leading,
2092
+ href,
2093
+ onOpen,
2094
+ mono = false,
2095
+ isNew = false,
2096
+ extra
2097
+ }) {
2098
+ if (extra && onOpen) warnExtraWithOpen();
2099
+ const name = /* @__PURE__ */ jsx5("b", { className: mono ? "band-sf-mono" : void 0, children: title });
2100
+ const cls = ["band-sf-row", leading ? "has-lead" : "", isNew ? "is-new" : ""].filter(Boolean).join(" ");
2101
+ return /* @__PURE__ */ jsxs5("li", { className: cls, children: [
2102
+ leading ? /* @__PURE__ */ jsx5("div", { className: "band-sf-row-l", children: leading }) : null,
2103
+ /* @__PURE__ */ jsxs5("div", { className: "band-sf-row-t", children: [
2104
+ onOpen ? /* @__PURE__ */ jsx5(
2105
+ "a",
2106
+ {
2107
+ className: "band-sf-row-link",
2108
+ href: href ?? "#",
2109
+ onClick: (e) => {
2110
+ if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
2111
+ e.preventDefault();
2112
+ onOpen();
2113
+ },
2114
+ children: name
2115
+ }
2116
+ ) : name,
2117
+ tags
2118
+ ] }),
2119
+ /* @__PURE__ */ jsxs5("div", { className: "band-sf-row-a", children: [
2120
+ actions,
2121
+ onOpen ? /* @__PURE__ */ jsx5("span", { className: "band-sf-chev", "aria-hidden": "true", children: "\u203A" }) : null
2122
+ ] }),
2123
+ meta && meta.length > 0 ? /* @__PURE__ */ jsx5("div", { className: "band-sf-row-m", children: meta.map((m, i) => (
2124
+ // biome-ignore lint/suspicious/noArrayIndexKey: 元信息是一串短句,没有稳定 id
2125
+ /* @__PURE__ */ jsx5("span", { children: m }, i)
2126
+ )) }) : null,
2127
+ extra ? /* @__PURE__ */ jsx5("div", { className: "band-sf-row-x", children: extra }) : null
2128
+ ] });
2129
+ }
2130
+ function SettingsFacts({ items }) {
2131
+ return /* @__PURE__ */ jsx5("dl", { className: "band-sf-facts", children: items.map((f) => /* @__PURE__ */ jsxs5("div", { className: "band-sf-fact", children: [
2132
+ /* @__PURE__ */ jsx5("dt", { children: f.key }),
2133
+ /* @__PURE__ */ jsx5("dd", { children: f.value })
2134
+ ] }, f.key)) });
2135
+ }
2136
+ function SettingsSection({
2137
+ title,
2138
+ desc,
2139
+ children
2140
+ }) {
2141
+ return /* @__PURE__ */ jsxs5("section", { className: "band-sf-sec", "aria-label": title, children: [
2142
+ /* @__PURE__ */ jsx5("h2", { children: title }),
2143
+ desc ? /* @__PURE__ */ jsx5("p", { children: desc }) : null,
2144
+ children
2145
+ ] });
2146
+ }
2147
+ function SettingsSingle({ label, children }) {
2148
+ return /* @__PURE__ */ jsx5("section", { className: "band-sf-one", "aria-label": label, children });
2149
+ }
2150
+ function SettingsChoices({ children }) {
2151
+ return /* @__PURE__ */ jsx5("div", { className: "band-sf-choices", children });
2152
+ }
2153
+ function SettingsPicks({
2154
+ label,
2155
+ value,
2156
+ onChange,
2157
+ options,
2158
+ disabled = false
2159
+ }) {
2160
+ const id = useId3();
2161
+ return /* @__PURE__ */ jsxs5("div", { className: "band-sf-fld", children: [
2162
+ /* @__PURE__ */ jsx5("span", { className: "band-sf-blks-l", id: `${id}-l`, children: label }),
2163
+ /* @__PURE__ */ jsx5(
2164
+ "div",
2165
+ {
2166
+ className: `band-sf-blks band-sf-blks-${options.length === 2 ? 2 : 3}`,
2167
+ role: "radiogroup",
2168
+ "aria-labelledby": `${id}-l`,
2169
+ children: options.map((o) => /* @__PURE__ */ jsxs5("label", { className: o.value === value ? "band-sf-blk is-on" : "band-sf-blk", children: [
2170
+ /* @__PURE__ */ jsx5(
2171
+ "input",
2172
+ {
2173
+ type: "radio",
2174
+ className: "sr-only",
2175
+ name: id,
2176
+ value: o.value,
2177
+ checked: o.value === value,
2178
+ disabled,
2179
+ onChange: () => onChange(o.value)
2180
+ }
2181
+ ),
2182
+ /* @__PURE__ */ jsx5("b", { children: o.label }),
2183
+ o.line ? /* @__PURE__ */ jsx5("small", { children: o.line }) : null
2184
+ ] }, o.value))
2185
+ }
2186
+ )
2187
+ ] });
2188
+ }
2189
+ function SettingsDanger({ children }) {
2190
+ return /* @__PURE__ */ jsxs5("section", { className: "band-sf-dz", "aria-label": "\u5371\u9669\u64CD\u4F5C", children: [
2191
+ /* @__PURE__ */ jsx5("h2", { children: "\u5371\u9669\u64CD\u4F5C" }),
2192
+ children
2193
+ ] });
2194
+ }
2195
+ function SettingsDangerRow({
2196
+ title,
2197
+ note,
2198
+ action
2199
+ }) {
2200
+ return /* @__PURE__ */ jsxs5("div", { className: "band-sf-dz-r", children: [
2201
+ /* @__PURE__ */ jsxs5("div", { children: [
2202
+ /* @__PURE__ */ jsx5("b", { children: title }),
2203
+ /* @__PURE__ */ jsx5("span", { children: note })
2204
+ ] }),
2205
+ action
2206
+ ] });
2207
+ }
2208
+ function SettingsLoading({ text }) {
2209
+ return /* @__PURE__ */ jsx5("output", { className: "band-sf-load", children: /* @__PURE__ */ jsxs5("span", { className: "tuning", children: [
2210
+ /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 80 55", "aria-hidden": "true", children: [
2211
+ /* @__PURE__ */ jsx5("line", { x1: "0", y1: "12", x2: "80", y2: "12" }),
2212
+ /* @__PURE__ */ jsx5("line", { x1: "0", y1: "22", x2: "80", y2: "22" }),
2213
+ /* @__PURE__ */ jsx5("line", { x1: "0", y1: "32", x2: "80", y2: "32" }),
2214
+ /* @__PURE__ */ jsx5("line", { x1: "0", y1: "42", x2: "80", y2: "42" }),
2215
+ /* @__PURE__ */ jsx5("line", { x1: "0", y1: "52", x2: "80", y2: "52" }),
2216
+ /* @__PURE__ */ jsx5("circle", { cx: "20", cy: "37", r: "4.6", fill: "var(--ink)" }),
2217
+ /* @__PURE__ */ jsx5("circle", { cx: "40", cy: "27", r: "4.6", fill: "var(--accent)" }),
2218
+ /* @__PURE__ */ jsx5("circle", { cx: "60", cy: "17", r: "4.6", fill: "var(--ink)" })
2219
+ ] }),
2220
+ /* @__PURE__ */ jsx5("span", { children: text })
2221
+ ] }) });
2222
+ }
2223
+ function SettingsEmpty({ children, action }) {
2224
+ return /* @__PURE__ */ jsxs5("div", { className: "band-sf-empty rest", children: [
2225
+ /* @__PURE__ */ jsx5("i", {}),
2226
+ /* @__PURE__ */ jsx5("p", { children }),
2227
+ action ?? null
2228
+ ] });
2229
+ }
2230
+ function SettingsReadError({ children, retry }) {
2231
+ return /* @__PURE__ */ jsx5("div", { className: "band-sf-error", children: /* @__PURE__ */ jsx5(ErrorNote, { retry, children }) });
2232
+ }
2233
+ function SettingsNoAccess({
2234
+ title,
2235
+ children,
2236
+ action
2237
+ }) {
2238
+ const id = useId3();
2239
+ return /* @__PURE__ */ jsxs5("section", { className: "band-settings-no-access", "aria-labelledby": id, children: [
2240
+ /* @__PURE__ */ jsx5("h2", { id, children: title }),
2241
+ /* @__PURE__ */ jsx5("p", { children }),
2242
+ action ? /* @__PURE__ */ jsx5("button", { type: "button", className: "btn", onClick: action.onClick, children: action.label }) : null
2243
+ ] });
2244
+ }
2245
+ function SettingsNotice({ text }) {
2246
+ return /* @__PURE__ */ jsx5("output", { className: "sr-only", "aria-live": "polite", children: text });
2247
+ }
2248
+ function SettingsSaved({ text = "\u5DF2\u4FDD\u5B58" }) {
2249
+ return /* @__PURE__ */ jsx5("output", { className: "band-sf-ok", children: text });
2250
+ }
2251
+ function SettingsDialog({
2252
+ title,
2253
+ children,
2254
+ actions,
2255
+ onClose
2256
+ }) {
2257
+ const ref = useRef4(null);
2258
+ const titleId = useId3();
2259
+ useEffect4(() => {
2260
+ const el = ref.current;
2261
+ const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
2262
+ if (el && !el.open) {
2263
+ if (typeof el.showModal === "function") el.showModal();
2264
+ else el.setAttribute("open", "");
2265
+ }
2266
+ return () => {
2267
+ if (opener?.isConnected) opener.focus();
2268
+ };
2269
+ }, []);
2270
+ return /* @__PURE__ */ jsxs5(
2271
+ "dialog",
2272
+ {
2273
+ ref,
2274
+ className: "band-sf-dialog",
2275
+ "aria-labelledby": titleId,
2276
+ onCancel: (e) => {
2277
+ e.preventDefault();
2278
+ onClose();
2279
+ },
2280
+ children: [
2281
+ /* @__PURE__ */ jsx5("h2", { id: titleId, children: title }),
2282
+ children,
2283
+ /* @__PURE__ */ jsx5("div", { className: "band-sf-acts band-sf-acts-end", children: actions })
2284
+ ]
2285
+ }
2286
+ );
2287
+ }
2288
+ function SettingsForm({
2289
+ label,
2290
+ onSubmit,
2291
+ children
2292
+ }) {
2293
+ return /* @__PURE__ */ jsx5(
2294
+ "form",
2295
+ {
2296
+ className: "band-sf-form",
2297
+ "aria-label": label,
2298
+ onSubmit: (e) => {
2299
+ e.preventDefault();
2300
+ onSubmit?.();
2301
+ },
2302
+ children
2303
+ }
2304
+ );
2305
+ }
2306
+ function SettingsField({
2307
+ label,
2308
+ required = false,
2309
+ optional = false,
2310
+ hint,
2311
+ error,
2312
+ count,
2313
+ over = false,
2314
+ children
2315
+ }) {
2316
+ const id = useId3();
2317
+ const noteId = `${id}-note`;
2318
+ const note = error ?? hint;
2319
+ const props = { id };
2320
+ if (note) props["aria-describedby"] = `${noteId}-t`;
2321
+ if (error) props["aria-invalid"] = true;
2322
+ return /* @__PURE__ */ jsxs5("div", { className: "band-sf-fld", children: [
2323
+ /* @__PURE__ */ jsxs5("label", { htmlFor: id, children: [
2324
+ label,
2325
+ required ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
2326
+ " ",
2327
+ /* @__PURE__ */ jsx5("span", { className: "band-sf-req", children: "\u5FC5\u586B" })
2328
+ ] }) : optional ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
2329
+ " ",
2330
+ /* @__PURE__ */ jsx5("span", { className: "band-sf-optional", children: "\u9009\u586B" })
2331
+ ] }) : null
2332
+ ] }),
2333
+ children(props),
2334
+ note || count ? (
2335
+ // 出错的话当场播报:校验被拦时焦点不动,读屏不会自己走到这一行
2336
+ /* @__PURE__ */ jsxs5(
2337
+ "p",
2338
+ {
2339
+ className: error ? "field-note err" : "field-note",
2340
+ id: noteId,
2341
+ role: error ? "alert" : void 0,
2342
+ children: [
2343
+ note ? /* @__PURE__ */ jsx5("span", { id: `${noteId}-t`, children: note }) : null,
2344
+ count ? /* @__PURE__ */ jsx5("span", { className: over ? "field-count over" : "field-count", children: count }) : null
2345
+ ]
2346
+ }
2347
+ )
2348
+ ) : null
2349
+ ] });
2350
+ }
2351
+ function SettingsActions({
2352
+ children,
2353
+ end = false
2354
+ }) {
2355
+ return /* @__PURE__ */ jsx5("div", { className: end ? "band-sf-acts band-sf-acts-end" : "band-sf-acts", children });
2356
+ }
2357
+ function SettingsSaveState({
2358
+ saving,
2359
+ saved,
2360
+ failed,
2361
+ missing
2362
+ }) {
2363
+ if (failed)
2364
+ return /* @__PURE__ */ jsx5("p", { className: "band-sf-err", role: "alert", children: failed });
2365
+ if (saved) return /* @__PURE__ */ jsx5(SettingsSaved, { text: saved === true ? "\u5DF2\u4FDD\u5B58" : saved });
2366
+ const text = saving ?? missing;
2367
+ if (!text) return /* @__PURE__ */ jsx5("span", { className: "band-sf-state", "aria-live": "polite" });
2368
+ return /* @__PURE__ */ jsx5("span", { className: "band-sf-state", "aria-live": "polite", children: text });
2369
+ }
2370
+
2371
+ export {
2372
+ ErrorNote,
2373
+ InfoNote,
2374
+ PaneHeader,
2375
+ avatarTone,
2376
+ memberOrder,
2377
+ avatarInitial,
2378
+ Avatar,
2379
+ Glyph,
2380
+ agentInstrument,
2381
+ AgentAvatar,
2382
+ INSTRUMENTS,
2383
+ instrumentOf,
2384
+ WorkshopIcon,
2385
+ WorkshopEmblem,
2386
+ BandMark,
2387
+ LogoLockup,
2388
+ Combobox,
2389
+ splitTags,
2390
+ TagInput,
2391
+ facetedCount,
2392
+ filterRows,
2393
+ FilterMenu,
2394
+ toast,
2395
+ dismissToast,
2396
+ dismissAllToasts,
2397
+ ToastHost,
2398
+ PersonSearch,
2399
+ PersonPicker,
2400
+ peopleDirectory,
2401
+ settingsLinkHandler,
2402
+ SettingsLayout,
2403
+ SettingsBack,
2404
+ SettingsHead,
2405
+ SettingsRows,
2406
+ SettingsRow,
2407
+ SettingsFacts,
2408
+ SettingsSection,
2409
+ SettingsSingle,
2410
+ SettingsChoices,
2411
+ SettingsPicks,
2412
+ SettingsDanger,
2413
+ SettingsDangerRow,
2414
+ SettingsLoading,
2415
+ SettingsEmpty,
2416
+ SettingsReadError,
2417
+ SettingsNoAccess,
2418
+ SettingsNotice,
2419
+ SettingsSaved,
2420
+ SettingsDialog,
2421
+ SettingsForm,
2422
+ SettingsField,
2423
+ SettingsActions,
2424
+ SettingsSaveState
2425
+ };