@luckylillia-dev/plugin-onebot11 0.0.0-placeholder → 1.0.3

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,1270 @@
1
+ // node_modules/lucide-react/dist/esm/createLucideIcon.js
2
+ import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
3
+
4
+ // node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.js
5
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
6
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
7
+ }).join(" ").trim();
8
+
9
+ // node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.js
10
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
11
+
12
+ // node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.js
13
+ var toCamelCase = (string) => string.replace(
14
+ /^([A-Z])|[\s-_]+(\w)/g,
15
+ (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
16
+ );
17
+
18
+ // node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.js
19
+ var toPascalCase = (string) => {
20
+ const camelCase = toCamelCase(string);
21
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
22
+ };
23
+
24
+ // node_modules/lucide-react/dist/esm/Icon.js
25
+ import { forwardRef, createElement } from "react";
26
+
27
+ // node_modules/lucide-react/dist/esm/defaultAttributes.js
28
+ var defaultAttributes = {
29
+ xmlns: "http://www.w3.org/2000/svg",
30
+ width: 24,
31
+ height: 24,
32
+ viewBox: "0 0 24 24",
33
+ fill: "none",
34
+ stroke: "currentColor",
35
+ strokeWidth: 2,
36
+ strokeLinecap: "round",
37
+ strokeLinejoin: "round"
38
+ };
39
+
40
+ // node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.js
41
+ var hasA11yProp = (props) => {
42
+ for (const prop in props) {
43
+ if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
44
+ return true;
45
+ }
46
+ }
47
+ return false;
48
+ };
49
+
50
+ // node_modules/lucide-react/dist/esm/Icon.js
51
+ var Icon = forwardRef(
52
+ ({
53
+ color = "currentColor",
54
+ size = 24,
55
+ strokeWidth = 2,
56
+ absoluteStrokeWidth,
57
+ className = "",
58
+ children,
59
+ iconNode,
60
+ ...rest
61
+ }, ref) => createElement(
62
+ "svg",
63
+ {
64
+ ref,
65
+ ...defaultAttributes,
66
+ width: size,
67
+ height: size,
68
+ stroke: color,
69
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
70
+ className: mergeClasses("lucide", className),
71
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
72
+ ...rest
73
+ },
74
+ [
75
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
76
+ ...Array.isArray(children) ? children : [children]
77
+ ]
78
+ )
79
+ );
80
+
81
+ // node_modules/lucide-react/dist/esm/createLucideIcon.js
82
+ var createLucideIcon = (iconName, iconNode) => {
83
+ const Component = forwardRef2(
84
+ ({ className, ...props }, ref) => createElement2(Icon, {
85
+ ref,
86
+ iconNode,
87
+ className: mergeClasses(
88
+ `lucide-${toKebabCase(toPascalCase(iconName))}`,
89
+ `lucide-${iconName}`,
90
+ className
91
+ ),
92
+ ...props
93
+ })
94
+ );
95
+ Component.displayName = toPascalCase(iconName);
96
+ return Component;
97
+ };
98
+
99
+ // node_modules/lucide-react/dist/esm/icons/chevron-down.js
100
+ var __iconNode = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
101
+ var ChevronDown = createLucideIcon("chevron-down", __iconNode);
102
+
103
+ // node_modules/lucide-react/dist/esm/icons/chevron-right.js
104
+ var __iconNode2 = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
105
+ var ChevronRight = createLucideIcon("chevron-right", __iconNode2);
106
+
107
+ // node_modules/lucide-react/dist/esm/icons/code.js
108
+ var __iconNode3 = [
109
+ ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
110
+ ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
111
+ ];
112
+ var Code = createLucideIcon("code", __iconNode3);
113
+
114
+ // node_modules/lucide-react/dist/esm/icons/external-link.js
115
+ var __iconNode4 = [
116
+ ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
117
+ ["path", { d: "M10 14 21 3", key: "gplh6r" }],
118
+ ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
119
+ ];
120
+ var ExternalLink = createLucideIcon("external-link", __iconNode4);
121
+
122
+ // node_modules/lucide-react/dist/esm/icons/eye-off.js
123
+ var __iconNode5 = [
124
+ [
125
+ "path",
126
+ {
127
+ d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
128
+ key: "ct8e1f"
129
+ }
130
+ ],
131
+ ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
132
+ [
133
+ "path",
134
+ {
135
+ d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
136
+ key: "13bj9a"
137
+ }
138
+ ],
139
+ ["path", { d: "m2 2 20 20", key: "1ooewy" }]
140
+ ];
141
+ var EyeOff = createLucideIcon("eye-off", __iconNode5);
142
+
143
+ // node_modules/lucide-react/dist/esm/icons/eye.js
144
+ var __iconNode6 = [
145
+ [
146
+ "path",
147
+ {
148
+ d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
149
+ key: "1nclc0"
150
+ }
151
+ ],
152
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
153
+ ];
154
+ var Eye = createLucideIcon("eye", __iconNode6);
155
+
156
+ // node_modules/lucide-react/dist/esm/icons/funnel.js
157
+ var __iconNode7 = [
158
+ [
159
+ "path",
160
+ {
161
+ d: "M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",
162
+ key: "sc7q7i"
163
+ }
164
+ ]
165
+ ];
166
+ var Funnel = createLucideIcon("funnel", __iconNode7);
167
+
168
+ // node_modules/lucide-react/dist/esm/icons/globe.js
169
+ var __iconNode8 = [
170
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
171
+ ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
172
+ ["path", { d: "M2 12h20", key: "9i4pu4" }]
173
+ ];
174
+ var Globe = createLucideIcon("globe", __iconNode8);
175
+
176
+ // node_modules/lucide-react/dist/esm/icons/layout-list.js
177
+ var __iconNode9 = [
178
+ ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
179
+ ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }],
180
+ ["path", { d: "M14 4h7", key: "3xa0d5" }],
181
+ ["path", { d: "M14 9h7", key: "1icrd9" }],
182
+ ["path", { d: "M14 15h7", key: "1mj8o2" }],
183
+ ["path", { d: "M14 20h7", key: "11slyb" }]
184
+ ];
185
+ var LayoutList = createLucideIcon("layout-list", __iconNode9);
186
+
187
+ // node_modules/lucide-react/dist/esm/icons/loader-circle.js
188
+ var __iconNode10 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
189
+ var LoaderCircle = createLucideIcon("loader-circle", __iconNode10);
190
+
191
+ // node_modules/lucide-react/dist/esm/icons/pen.js
192
+ var __iconNode11 = [
193
+ [
194
+ "path",
195
+ {
196
+ d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
197
+ key: "1a8usu"
198
+ }
199
+ ]
200
+ ];
201
+ var Pen = createLucideIcon("pen", __iconNode11);
202
+
203
+ // node_modules/lucide-react/dist/esm/icons/plus.js
204
+ var __iconNode12 = [
205
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
206
+ ["path", { d: "M12 5v14", key: "s699le" }]
207
+ ];
208
+ var Plus = createLucideIcon("plus", __iconNode12);
209
+
210
+ // node_modules/lucide-react/dist/esm/icons/radio.js
211
+ var __iconNode13 = [
212
+ ["path", { d: "M16.247 7.761a6 6 0 0 1 0 8.478", key: "1fwjs5" }],
213
+ ["path", { d: "M19.075 4.933a10 10 0 0 1 0 14.134", key: "ehdyv1" }],
214
+ ["path", { d: "M4.925 19.067a10 10 0 0 1 0-14.134", key: "1q22gi" }],
215
+ ["path", { d: "M7.753 16.239a6 6 0 0 1 0-8.478", key: "r2q7qm" }],
216
+ ["circle", { cx: "12", cy: "12", r: "2", key: "1c9p78" }]
217
+ ];
218
+ var Radio = createLucideIcon("radio", __iconNode13);
219
+
220
+ // node_modules/lucide-react/dist/esm/icons/send.js
221
+ var __iconNode14 = [
222
+ [
223
+ "path",
224
+ {
225
+ d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
226
+ key: "1ffxy3"
227
+ }
228
+ ],
229
+ ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
230
+ ];
231
+ var Send = createLucideIcon("send", __iconNode14);
232
+
233
+ // node_modules/lucide-react/dist/esm/icons/settings-2.js
234
+ var __iconNode15 = [
235
+ ["path", { d: "M14 17H5", key: "gfn3mx" }],
236
+ ["path", { d: "M19 7h-9", key: "6i9tg" }],
237
+ ["circle", { cx: "17", cy: "17", r: "3", key: "18b49y" }],
238
+ ["circle", { cx: "7", cy: "7", r: "3", key: "dfmy0x" }]
239
+ ];
240
+ var Settings2 = createLucideIcon("settings-2", __iconNode15);
241
+
242
+ // node_modules/lucide-react/dist/esm/icons/settings.js
243
+ var __iconNode16 = [
244
+ [
245
+ "path",
246
+ {
247
+ d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",
248
+ key: "1i5ecw"
249
+ }
250
+ ],
251
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
252
+ ];
253
+ var Settings = createLucideIcon("settings", __iconNode16);
254
+
255
+ // node_modules/lucide-react/dist/esm/icons/trash-2.js
256
+ var __iconNode17 = [
257
+ ["path", { d: "M10 11v6", key: "nco0om" }],
258
+ ["path", { d: "M14 11v6", key: "outv1u" }],
259
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
260
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
261
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
262
+ ];
263
+ var Trash2 = createLucideIcon("trash-2", __iconNode17);
264
+
265
+ // node_modules/lucide-react/dist/esm/icons/wifi.js
266
+ var __iconNode18 = [
267
+ ["path", { d: "M12 20h.01", key: "zekei9" }],
268
+ ["path", { d: "M2 8.82a15 15 0 0 1 20 0", key: "dnpr2z" }],
269
+ ["path", { d: "M5 12.859a10 10 0 0 1 14 0", key: "1x1e6c" }],
270
+ ["path", { d: "M8.5 16.429a5 5 0 0 1 7 0", key: "1bycff" }]
271
+ ];
272
+ var Wifi = createLucideIcon("wifi", __iconNode18);
273
+
274
+ // node_modules/lucide-react/dist/esm/icons/x.js
275
+ var __iconNode19 = [
276
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
277
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
278
+ ];
279
+ var X = createLucideIcon("x", __iconNode19);
280
+
281
+ // src/client/index.tsx
282
+ import { usePluginConfig } from "@luckylillia-dev/plugin-sdk/webui";
283
+
284
+ // src/client/Connections.tsx
285
+ import { useState as useState3 } from "react";
286
+ import { createPortal as createPortal2 } from "react-dom";
287
+ import { HostInput, usePluginContext as usePluginContext2 } from "@luckylillia-dev/plugin-sdk/webui";
288
+
289
+ // src/client/EventFilterEditor.tsx
290
+ import { useState, useEffect, useCallback } from "react";
291
+ import { SelectInput } from "@luckylillia-dev/plugin-sdk/webui";
292
+ import { jsx, jsxs } from "react/jsx-runtime";
293
+ var FIELD_OPTIONS = [
294
+ { value: "post_type", label: "\u4E8B\u4EF6\u7C7B\u578B", type: "select", options: [
295
+ { value: "message", label: "\u6D88\u606F" },
296
+ { value: "message_sent", label: "\u81EA\u5DF1\u53D1\u9001\u7684\u6D88\u606F" },
297
+ { value: "notice", label: "\u901A\u77E5" },
298
+ { value: "request", label: "\u8BF7\u6C42" },
299
+ { value: "meta_event", label: "\u5143\u4E8B\u4EF6" }
300
+ ] },
301
+ { value: "message_type", label: "\u6D88\u606F\u7C7B\u578B", type: "select", options: [
302
+ { value: "private", label: "\u79C1\u804A" },
303
+ { value: "group", label: "\u7FA4\u804A" }
304
+ ] },
305
+ { value: "notice_type", label: "\u901A\u77E5\u7C7B\u578B", type: "select", options: [
306
+ { value: "group_upload", label: "\u7FA4\u6587\u4EF6\u4E0A\u4F20" },
307
+ { value: "group_admin", label: "\u7FA4\u7BA1\u7406\u5458\u53D8\u52A8" },
308
+ { value: "group_decrease", label: "\u7FA4\u6210\u5458\u51CF\u5C11" },
309
+ { value: "group_increase", label: "\u7FA4\u6210\u5458\u589E\u52A0" },
310
+ { value: "group_ban", label: "\u7FA4\u7981\u8A00" },
311
+ { value: "group_recall", label: "\u7FA4\u6D88\u606F\u64A4\u56DE" },
312
+ { value: "friend_recall", label: "\u597D\u53CB\u6D88\u606F\u64A4\u56DE" },
313
+ { value: "notify", label: "\u7FA4\u5185\u63D0\u793A" },
314
+ { value: "group_card", label: "\u7FA4\u540D\u7247\u53D8\u66F4" },
315
+ { value: "essence", label: "\u7CBE\u534E\u6D88\u606F" }
316
+ ] },
317
+ { value: "request_type", label: "\u8BF7\u6C42\u7C7B\u578B", type: "select", options: [
318
+ { value: "friend", label: "\u597D\u53CB\u8BF7\u6C42" },
319
+ { value: "group", label: "\u7FA4\u8BF7\u6C42" }
320
+ ] },
321
+ { value: "group_id", label: "\u7FA4\u53F7", type: "number" },
322
+ { value: "user_id", label: "\u7528\u6237 QQ \u53F7", type: "number" },
323
+ { value: "sub_type", label: "\u5B50\u7C7B\u578B", type: "text" },
324
+ { value: "raw_message", label: "\u6D88\u606F\u5185\u5BB9", type: "text" }
325
+ ];
326
+ var OPERATOR_OPTIONS = [
327
+ { value: "$eq", label: "\u7B49\u4E8E" },
328
+ { value: "$ne", label: "\u4E0D\u7B49\u4E8E" },
329
+ { value: "$in", label: "\u5728\u5217\u8868\u4E2D" },
330
+ { value: "$nin", label: "\u4E0D\u5728\u5217\u8868\u4E2D" },
331
+ { value: "$regex", label: "\u6B63\u5219\u5339\u914D" },
332
+ { value: "$gt", label: "\u5927\u4E8E" },
333
+ { value: "$lt", label: "\u5C0F\u4E8E" }
334
+ ];
335
+ var nextRuleId = 1;
336
+ function parseFilterToRules(filter) {
337
+ const rules = [];
338
+ try {
339
+ for (const [field, condition] of Object.entries(filter)) {
340
+ if (field.startsWith("$")) return null;
341
+ if (condition === null || condition === void 0) continue;
342
+ if (typeof condition === "object" && !Array.isArray(condition)) {
343
+ const entries = Object.entries(condition);
344
+ if (entries.length !== 1) return null;
345
+ const [op, val] = entries[0];
346
+ if (!op.startsWith("$")) return null;
347
+ const valStr = Array.isArray(val) ? val.join(", ") : String(val ?? "");
348
+ rules.push({ id: nextRuleId++, field, operator: op, value: valStr });
349
+ } else {
350
+ const valStr = Array.isArray(condition) ? condition.join(", ") : String(condition);
351
+ rules.push({ id: nextRuleId++, field, operator: "$eq", value: valStr });
352
+ }
353
+ }
354
+ } catch {
355
+ return null;
356
+ }
357
+ return rules;
358
+ }
359
+ function rulesToFilter(rules) {
360
+ if (rules.length === 0) return void 0;
361
+ const filter = {};
362
+ for (const rule of rules) {
363
+ if (!rule.field) continue;
364
+ const fieldDef = FIELD_OPTIONS.find((f) => f.value === rule.field);
365
+ const isNumeric = fieldDef?.type === "number";
366
+ let parsedValue;
367
+ if (rule.operator === "$in" || rule.operator === "$nin") {
368
+ parsedValue = rule.value.split(/[,,]/).map((v) => {
369
+ const trimmed = v.trim();
370
+ if (!trimmed) return void 0;
371
+ return isNumeric ? Number(trimmed) : trimmed;
372
+ }).filter((v) => v !== void 0 && !(isNumeric && isNaN(v)));
373
+ } else if (rule.operator === "$regex") {
374
+ parsedValue = rule.value;
375
+ } else {
376
+ if (isNumeric) {
377
+ if (rule.value.trim() === "") continue;
378
+ parsedValue = Number(rule.value);
379
+ if (isNaN(parsedValue)) continue;
380
+ } else {
381
+ parsedValue = rule.value;
382
+ }
383
+ }
384
+ if (rule.operator === "$eq") {
385
+ filter[rule.field] = parsedValue;
386
+ } else {
387
+ filter[rule.field] = { [rule.operator]: parsedValue };
388
+ }
389
+ }
390
+ return Object.keys(filter).length > 0 ? filter : void 0;
391
+ }
392
+ var EventFilterEditor = ({ filter, onChange }) => {
393
+ const [expanded, setExpanded] = useState(false);
394
+ const [mode, setMode] = useState("visual");
395
+ const [rules, setRules] = useState([]);
396
+ const [jsonText, setJsonText] = useState("");
397
+ const [jsonError, setJsonError] = useState("");
398
+ const [visualUnsupported, setVisualUnsupported] = useState(false);
399
+ useEffect(() => {
400
+ if (filter && Object.keys(filter).length > 0) {
401
+ setJsonText(JSON.stringify(filter, null, 2));
402
+ const parsed = parseFilterToRules(filter);
403
+ if (parsed) {
404
+ setRules(parsed);
405
+ setVisualUnsupported(false);
406
+ } else {
407
+ setRules([]);
408
+ setVisualUnsupported(true);
409
+ setMode("json");
410
+ }
411
+ } else {
412
+ setRules([]);
413
+ setJsonText("");
414
+ setVisualUnsupported(false);
415
+ }
416
+ }, []);
417
+ const hasFilter = filter && Object.keys(filter).length > 0 || rules.length > 0;
418
+ const updateFromRules = useCallback((newRules) => {
419
+ setRules(newRules);
420
+ const newFilter = rulesToFilter(newRules);
421
+ onChange(newFilter);
422
+ setJsonText(newFilter ? JSON.stringify(newFilter, null, 2) : "");
423
+ setJsonError("");
424
+ }, [onChange]);
425
+ const handleJsonChange = useCallback((text) => {
426
+ setJsonText(text);
427
+ const trimmed = text.trim();
428
+ if (!trimmed || trimmed === "{}") {
429
+ setJsonError("");
430
+ onChange(void 0);
431
+ setRules([]);
432
+ setVisualUnsupported(false);
433
+ return;
434
+ }
435
+ try {
436
+ const parsed = JSON.parse(trimmed);
437
+ setJsonError("");
438
+ onChange(parsed);
439
+ const parsedRules = parseFilterToRules(parsed);
440
+ if (parsedRules) {
441
+ setRules(parsedRules);
442
+ setVisualUnsupported(false);
443
+ } else {
444
+ setVisualUnsupported(true);
445
+ }
446
+ } catch (err) {
447
+ setJsonError(err.message);
448
+ }
449
+ }, [onChange]);
450
+ const addRule = () => {
451
+ updateFromRules([...rules, { id: nextRuleId++, field: "post_type", operator: "$eq", value: "" }]);
452
+ };
453
+ const removeRule = (id) => {
454
+ updateFromRules(rules.filter((r) => r.id !== id));
455
+ };
456
+ const updateRule = (id, updates) => {
457
+ const newRules = rules.map((r) => {
458
+ if (r.id !== id) return r;
459
+ const updated = { ...r, ...updates };
460
+ if (updates.field && updates.field !== r.field) {
461
+ updated.value = "";
462
+ updated.operator = "$eq";
463
+ }
464
+ if (updates.operator && updates.operator !== r.operator) {
465
+ const wasListOp = r.operator === "$in" || r.operator === "$nin";
466
+ const isListOp = updates.operator === "$in" || updates.operator === "$nin";
467
+ if (!wasListOp && isListOp) {
468
+ } else if (wasListOp && !isListOp) {
469
+ const items = r.value.split(/[,,]/).map((v) => v.trim()).filter(Boolean);
470
+ updated.value = items[0] || "";
471
+ }
472
+ }
473
+ return updated;
474
+ });
475
+ updateFromRules(newRules);
476
+ };
477
+ const switchToMode = (newMode) => {
478
+ if (newMode === "visual" && visualUnsupported) return;
479
+ if (newMode === "json" && mode === "visual") {
480
+ const f = rulesToFilter(rules);
481
+ setJsonText(f ? JSON.stringify(f, null, 2) : "");
482
+ }
483
+ setMode(newMode);
484
+ };
485
+ return /* @__PURE__ */ jsxs("div", { className: "border-t border-theme-divider pt-6", children: [
486
+ /* @__PURE__ */ jsxs(
487
+ "button",
488
+ {
489
+ type: "button",
490
+ onClick: () => setExpanded(!expanded),
491
+ className: "flex items-center gap-2 w-full text-left",
492
+ children: [
493
+ expanded ? /* @__PURE__ */ jsx(ChevronDown, { size: 18, className: "text-theme-secondary" }) : /* @__PURE__ */ jsx(ChevronRight, { size: 18, className: "text-theme-secondary" }),
494
+ /* @__PURE__ */ jsx(Funnel, { size: 18, className: "text-theme-secondary" }),
495
+ /* @__PURE__ */ jsx("h4", { className: "text-md font-semibold text-theme", children: "\u4E8B\u4EF6\u8FC7\u6EE4\u5668" }),
496
+ hasFilter && /* @__PURE__ */ jsx("span", { className: "text-xs font-medium px-2 py-0.5 rounded-full bg-pink-100 dark:bg-pink-900/50 text-pink-700 dark:text-pink-400", children: rules.length > 0 ? `${rules.length} \u6761\u89C4\u5219` : "\u5DF2\u914D\u7F6E" })
497
+ ]
498
+ }
499
+ ),
500
+ expanded && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-4", children: [
501
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-1 p-1 bg-theme-item rounded-xl w-fit", children: [
502
+ /* @__PURE__ */ jsxs(
503
+ "button",
504
+ {
505
+ type: "button",
506
+ onClick: () => switchToMode("visual"),
507
+ disabled: visualUnsupported,
508
+ className: `flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${mode === "visual" ? "bg-white dark:bg-neutral-700 text-theme shadow-sm" : visualUnsupported ? "text-theme-hint cursor-not-allowed" : "text-theme-secondary hover:text-theme"}`,
509
+ children: [
510
+ /* @__PURE__ */ jsx(LayoutList, { size: 14 }),
511
+ "\u53EF\u89C6\u5316"
512
+ ]
513
+ }
514
+ ),
515
+ /* @__PURE__ */ jsxs(
516
+ "button",
517
+ {
518
+ type: "button",
519
+ onClick: () => switchToMode("json"),
520
+ className: `flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${mode === "json" ? "bg-white dark:bg-neutral-700 text-theme shadow-sm" : "text-theme-secondary hover:text-theme"}`,
521
+ children: [
522
+ /* @__PURE__ */ jsx(Code, { size: 14 }),
523
+ "JSON"
524
+ ]
525
+ }
526
+ )
527
+ ] }),
528
+ visualUnsupported && mode === "json" && /* @__PURE__ */ jsx("p", { className: "text-xs text-amber-600 dark:text-amber-400", children: "\u5F53\u524D\u8FC7\u6EE4\u5668\u5305\u542B\u590D\u6742\u67E5\u8BE2\uFF08$and/$or \u7B49\uFF09\uFF0C\u4EC5\u652F\u6301 JSON \u7F16\u8F91" }),
529
+ mode === "visual" && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
530
+ rules.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-theme-hint py-3 text-center", children: "\u672A\u914D\u7F6E\u8FC7\u6EE4\u89C4\u5219\uFF0C\u5C06\u63A5\u6536\u6240\u6709\u4E8B\u4EF6" }),
531
+ rules.length > 0 && /* @__PURE__ */ jsxs("div", { className: "text-xs text-theme-hint px-1 py-1 bg-blue-50 dark:bg-blue-900/20 rounded-lg", children: [
532
+ "\u53EA\u6709\u7B26\u5408\u4EE5\u4E0B\u89C4\u5219\u7684\u4E8B\u4EF6\u624D\u4F1A\u88AB\u4E0A\u62A5",
533
+ rules.length > 1 && /* @__PURE__ */ jsxs("span", { children: [
534
+ "\uFF0C\u89C4\u5219\u4E4B\u95F4\u4E3A ",
535
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-pink-500", children: "\u4E14 (AND)" }),
536
+ " \u7684\u5173\u7CFB"
537
+ ] })
538
+ ] }),
539
+ rules.map((rule, idx) => {
540
+ const fieldDef = FIELD_OPTIONS.find((f) => f.value === rule.field);
541
+ const isListOp = rule.operator === "$in" || rule.operator === "$nin";
542
+ const listValues = isListOp ? rule.value.split(/[,,]/).map((v) => v.trim()).filter(Boolean) : [];
543
+ return /* @__PURE__ */ jsxs("div", { className: "p-3 bg-theme-item rounded-xl space-y-2", children: [
544
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
545
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 grid grid-cols-[1fr_auto] gap-2 items-start", children: [
546
+ /* @__PURE__ */ jsx(
547
+ SelectInput,
548
+ {
549
+ value: rule.field,
550
+ options: FIELD_OPTIONS,
551
+ onChange: (field) => updateRule(rule.id, { field }),
552
+ className: "text-sm !py-2"
553
+ }
554
+ ),
555
+ /* @__PURE__ */ jsx(
556
+ SelectInput,
557
+ {
558
+ value: rule.operator,
559
+ options: OPERATOR_OPTIONS,
560
+ onChange: (operator) => updateRule(rule.id, { operator }),
561
+ className: "text-sm !py-2 !w-auto"
562
+ }
563
+ )
564
+ ] }),
565
+ /* @__PURE__ */ jsx(
566
+ "button",
567
+ {
568
+ type: "button",
569
+ onClick: () => removeRule(rule.id),
570
+ className: "p-2 text-theme-hint hover:text-red-500 transition-colors shrink-0",
571
+ children: /* @__PURE__ */ jsx(Trash2, { size: 16 })
572
+ }
573
+ )
574
+ ] }),
575
+ isListOp ? (
576
+ /* 标签式列表输入 */
577
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
578
+ listValues.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: listValues.map((val, vi) => /* @__PURE__ */ jsxs(
579
+ "span",
580
+ {
581
+ className: "inline-flex items-center gap-1 px-2.5 py-1 text-sm bg-pink-100 dark:bg-pink-900/40 text-pink-700 dark:text-pink-300 rounded-lg",
582
+ children: [
583
+ fieldDef && "options" in fieldDef ? fieldDef.options.find((o) => o.value === val)?.label ?? val : val,
584
+ /* @__PURE__ */ jsx(
585
+ "button",
586
+ {
587
+ type: "button",
588
+ onClick: () => {
589
+ const newList = listValues.filter((_, i) => i !== vi);
590
+ updateRule(rule.id, { value: newList.join(", ") });
591
+ },
592
+ className: "hover:text-pink-900 dark:hover:text-pink-100 transition-colors",
593
+ children: /* @__PURE__ */ jsx(X, { size: 14 })
594
+ }
595
+ )
596
+ ]
597
+ },
598
+ vi
599
+ )) }),
600
+ fieldDef && "options" in fieldDef ? /* @__PURE__ */ jsx(
601
+ SelectInput,
602
+ {
603
+ value: "",
604
+ placeholder: "\u70B9\u51FB\u6DFB\u52A0...",
605
+ options: fieldDef.options.filter((opt) => !listValues.includes(opt.value)),
606
+ disabled: listValues.length >= fieldDef.options.length,
607
+ onChange: (added) => updateRule(rule.id, { value: [...listValues, added].join(", ") }),
608
+ className: "text-sm !py-2"
609
+ }
610
+ ) : /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsx(
611
+ "input",
612
+ {
613
+ type: fieldDef?.type === "number" ? "number" : "text",
614
+ placeholder: fieldDef?.type === "number" ? "\u8F93\u5165\u6570\u5B57\u540E\u6309\u56DE\u8F66\u6DFB\u52A0" : "\u8F93\u5165\u503C\u540E\u6309\u56DE\u8F66\u6DFB\u52A0",
615
+ className: "input-field text-sm !py-2 flex-1",
616
+ onKeyDown: (e) => {
617
+ if (e.key !== "Enter") return;
618
+ e.preventDefault();
619
+ const input = e.currentTarget;
620
+ const val = input.value.trim();
621
+ if (!val) return;
622
+ if (listValues.includes(val)) {
623
+ input.value = "";
624
+ return;
625
+ }
626
+ const newList = [...listValues, val];
627
+ updateRule(rule.id, { value: newList.join(", ") });
628
+ input.value = "";
629
+ }
630
+ }
631
+ ) })
632
+ ] })
633
+ ) : fieldDef && "options" in fieldDef ? /* @__PURE__ */ jsx(
634
+ SelectInput,
635
+ {
636
+ value: rule.value,
637
+ options: fieldDef.options,
638
+ onChange: (value) => updateRule(rule.id, { value }),
639
+ className: "text-sm !py-2"
640
+ }
641
+ ) : /* @__PURE__ */ jsx(
642
+ "input",
643
+ {
644
+ type: fieldDef?.type === "number" ? "number" : "text",
645
+ value: rule.value,
646
+ onChange: (e) => updateRule(rule.id, { value: e.target.value }),
647
+ placeholder: rule.operator === "$regex" ? "\u6B63\u5219\u8868\u8FBE\u5F0F" : fieldDef?.type === "number" ? "\u8F93\u5165\u6570\u5B57" : "\u8F93\u5165\u503C",
648
+ className: "input-field text-sm !py-2"
649
+ }
650
+ )
651
+ ] }, rule.id);
652
+ }),
653
+ /* @__PURE__ */ jsxs(
654
+ "button",
655
+ {
656
+ type: "button",
657
+ onClick: addRule,
658
+ className: "flex items-center gap-1.5 px-3 py-2 text-sm text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-xl transition-colors",
659
+ children: [
660
+ /* @__PURE__ */ jsx(Plus, { size: 16 }),
661
+ "\u6DFB\u52A0\u89C4\u5219"
662
+ ]
663
+ }
664
+ )
665
+ ] }),
666
+ mode === "json" && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
667
+ /* @__PURE__ */ jsx(
668
+ "textarea",
669
+ {
670
+ value: jsonText,
671
+ onChange: (e) => handleJsonChange(e.target.value),
672
+ placeholder: '{ "post_type": "message", "message_type": "group" }',
673
+ rows: 6,
674
+ spellCheck: false,
675
+ className: `input-field font-mono text-sm resize-y ${jsonError ? "ring-2 ring-red-500 border-red-500" : ""}`
676
+ }
677
+ ),
678
+ jsonError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: jsonError }),
679
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-theme-hint leading-relaxed", children: "\u53EA\u6709\u7B26\u5408\u8FC7\u6EE4\u5668\u7684\u4E8B\u4EF6\u624D\u4F1A\u88AB\u4E0A\u62A5\uFF0C\u7559\u7A7A\u8868\u793A\u63A5\u6536\u6240\u6709\u4E8B\u4EF6\u3002 MongoDB \u67E5\u8BE2\u8BED\u6CD5\uFF0C\u652F\u6301\uFF1A$eq, $ne, $in, $nin, $gt, $lt, $regex, $and, $or, $not" })
680
+ ] })
681
+ ] })
682
+ ] });
683
+ };
684
+ var EventFilterEditor_default = EventFilterEditor;
685
+
686
+ // src/client/MusicCardSign.tsx
687
+ import { useCallback as useCallback2, useEffect as useEffect2, useId, useRef, useState as useState2 } from "react";
688
+ import { createPortal } from "react-dom";
689
+ import { usePluginContext } from "@luckylillia-dev/plugin-sdk/webui";
690
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
691
+ var DEFAULT_URL = "https://ss.xingzhige.com/music_card/card";
692
+ var MusicCardSign = () => {
693
+ const [open, setOpen] = useState2(false);
694
+ const button = useRef(null);
695
+ const close = useCallback2(() => {
696
+ setOpen(false);
697
+ button.current?.focus();
698
+ }, []);
699
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
700
+ /* @__PURE__ */ jsxs2(
701
+ "button",
702
+ {
703
+ ref: button,
704
+ type: "button",
705
+ onClick: () => setOpen(true),
706
+ className: "flex items-center gap-1.5 px-3 py-1.5 text-sm text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-lg transition-colors flex-shrink-0",
707
+ children: [
708
+ /* @__PURE__ */ jsx2(Settings2, { size: 16 }),
709
+ "\u9AD8\u7EA7\u8BBE\u7F6E"
710
+ ]
711
+ }
712
+ ),
713
+ open && createPortal(/* @__PURE__ */ jsx2(MusicCardSignDialog, { onClose: close }), document.body)
714
+ ] });
715
+ };
716
+ var MusicCardSignDialog = ({ onClose }) => {
717
+ const ctx = usePluginContext();
718
+ const id = useId();
719
+ const dialog = useRef(null);
720
+ const [saved, setSaved] = useState2(null);
721
+ const [url, setUrl] = useState2("");
722
+ const [saving, setSaving] = useState2(false);
723
+ useEffect2(() => {
724
+ let disposed = false;
725
+ dialog.current?.focus();
726
+ ctx.api("/api/config").then(
727
+ (data) => {
728
+ if (disposed) return;
729
+ setSaved(data.config.musicCardSignUrl ?? "");
730
+ setUrl(data.config.musicCardSignUrl ?? "");
731
+ },
732
+ (e) => {
733
+ if (disposed) return;
734
+ ctx.toast(e instanceof Error ? e.message : "\u8BFB\u53D6\u8BBE\u7F6E\u5931\u8D25", "error");
735
+ onClose();
736
+ }
737
+ );
738
+ return () => {
739
+ disposed = true;
740
+ };
741
+ }, [ctx, onClose]);
742
+ useEffect2(() => {
743
+ const onKey = (e) => {
744
+ if (e.key === "Escape") {
745
+ e.preventDefault();
746
+ if (!saving) onClose();
747
+ }
748
+ };
749
+ window.addEventListener("keydown", onKey);
750
+ return () => window.removeEventListener("keydown", onKey);
751
+ }, [onClose, saving]);
752
+ const save = async () => {
753
+ if (saving || saved === null || url.trim() === saved) return;
754
+ setSaving(true);
755
+ try {
756
+ await ctx.api("/api/config", { method: "POST", body: { config: { musicCardSignUrl: url.trim() } } });
757
+ ctx.toast("\u97F3\u4E50\u5361\u7247\u7B7E\u540D\u5730\u5740\u5DF2\u4FDD\u5B58");
758
+ onClose();
759
+ } catch (e) {
760
+ ctx.toast(e instanceof Error ? e.message : "\u4FDD\u5B58\u5931\u8D25", "error");
761
+ } finally {
762
+ setSaving(false);
763
+ }
764
+ };
765
+ return /* @__PURE__ */ jsx2("div", { className: "fixed inset-0 scrim flex items-center justify-center p-4", style: { zIndex: 9e3 }, children: /* @__PURE__ */ jsxs2(
766
+ "div",
767
+ {
768
+ ref: dialog,
769
+ role: "dialog",
770
+ "aria-modal": "true",
771
+ "aria-labelledby": `${id}-title`,
772
+ tabIndex: -1,
773
+ className: "glass glass-thick r-window glass-pop w-full max-w-lg max-h-[90vh] overflow-y-auto",
774
+ onKeyDown: (e) => {
775
+ if (e.key !== "Tab") return;
776
+ const controls = e.currentTarget.querySelectorAll("button:not(:disabled), input:not(:disabled)");
777
+ const first = controls[0];
778
+ const last = controls[controls.length - 1];
779
+ if (e.shiftKey && (document.activeElement === first || document.activeElement === dialog.current)) {
780
+ e.preventDefault();
781
+ last?.focus();
782
+ } else if (!e.shiftKey && document.activeElement === last) {
783
+ e.preventDefault();
784
+ first?.focus();
785
+ }
786
+ },
787
+ children: [
788
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between px-6 pt-5 pb-4 hairline-b", children: [
789
+ /* @__PURE__ */ jsx2("h3", { id: `${id}-title`, className: "text-lg font-semibold text-theme", children: "OneBot 11 \xB7 \u9AD8\u7EA7\u8BBE\u7F6E" }),
790
+ /* @__PURE__ */ jsx2("button", { type: "button", onClick: onClose, disabled: saving, "aria-label": "\u5173\u95ED\u9AD8\u7EA7\u8BBE\u7F6E", className: "p-2 text-theme-muted hover:text-theme hover:bg-theme-item rounded-lg transition-colors disabled:opacity-50", children: /* @__PURE__ */ jsx2(X, { size: 20 }) })
791
+ ] }),
792
+ /* @__PURE__ */ jsxs2("form", { onSubmit: (e) => {
793
+ e.preventDefault();
794
+ void save();
795
+ }, children: [
796
+ /* @__PURE__ */ jsx2("div", { className: "p-6", children: saved === null ? /* @__PURE__ */ jsx2("div", { className: "flex justify-center py-6", "aria-label": "\u6B63\u5728\u8BFB\u53D6\u8BBE\u7F6E", children: /* @__PURE__ */ jsx2(LoaderCircle, { size: 24, className: "animate-spin text-pink-500" }) }) : /* @__PURE__ */ jsxs2("div", { children: [
797
+ /* @__PURE__ */ jsx2("label", { htmlFor: `${id}-url`, className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u97F3\u4E50\u5361\u7247\u7B7E\u540D\u5730\u5740" }),
798
+ /* @__PURE__ */ jsx2(
799
+ "input",
800
+ {
801
+ id: `${id}-url`,
802
+ type: "text",
803
+ inputMode: "url",
804
+ autoFocus: true,
805
+ autoComplete: "off",
806
+ spellCheck: false,
807
+ value: url,
808
+ disabled: saving,
809
+ onChange: (e) => setUrl(e.target.value),
810
+ placeholder: DEFAULT_URL,
811
+ "aria-describedby": `${id}-description`,
812
+ className: "input-field w-full"
813
+ }
814
+ ),
815
+ /* @__PURE__ */ jsx2("p", { id: `${id}-description`, className: "text-xs text-theme-muted mt-2", children: "\u53D1\u9001\u97F3\u4E50\u5361\u7247\u65F6\uFF0C\u4F7F\u7528\u6B64\u670D\u52A1\u751F\u6210\u7B7E\u540D\u5361\u7247\u3002\u4FEE\u6539\u540E\u7ACB\u5373\u751F\u6548\u3002" })
816
+ ] }) }),
817
+ /* @__PURE__ */ jsxs2("div", { className: "flex justify-end gap-3 px-6 pb-6", children: [
818
+ /* @__PURE__ */ jsx2("button", { type: "button", onClick: onClose, disabled: saving, className: "px-5 py-2 text-theme-secondary hover:bg-theme-item rounded-xl font-medium transition-colors disabled:opacity-50", children: "\u53D6\u6D88" }),
819
+ /* @__PURE__ */ jsxs2("button", { type: "submit", disabled: saving || saved === null || url.trim() === saved, className: "btn-primary flex items-center gap-2 disabled:opacity-50", children: [
820
+ saving && /* @__PURE__ */ jsx2(LoaderCircle, { size: 18, className: "animate-spin" }),
821
+ "\u4FDD\u5B58"
822
+ ] })
823
+ ] })
824
+ ] })
825
+ ]
826
+ }
827
+ ) });
828
+ };
829
+ var MusicCardSign_default = MusicCardSign;
830
+
831
+ // src/client/Connections.tsx
832
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
833
+ var Portal = ({ children }) => createPortal2(children, document.body);
834
+ var Connections = ({ config, onChange, onSave }) => {
835
+ const { toast: showToast } = usePluginContext2();
836
+ const [selectedAdapter, setSelectedAdapter] = useState3(null);
837
+ const [selectedAdapterIndex, setSelectedAdapterIndex] = useState3(-1);
838
+ const [showDialog, setShowDialog] = useState3(false);
839
+ const [showAddDialog, setShowAddDialog] = useState3(false);
840
+ const [isNewAdapter, setIsNewAdapter] = useState3(false);
841
+ const [editingName, setEditingName] = useState3(false);
842
+ const [tempName, setTempName] = useState3("");
843
+ const [showToken, setShowToken] = useState3(false);
844
+ const adapterInfo = {
845
+ "ws": { icon: Radio, name: "WebSocket\u6B63\u5411", desc: "\u63D0\u4F9BWebSocket\u670D\u52A1\u5668" },
846
+ "ws-reverse": { icon: Wifi, name: "WebSocket\u53CD\u5411", desc: "\u4F5C\u4E3A\u5BA2\u6237\u7AEF\u8FDE\u63A5\u5230WebSocket\u670D\u52A1" },
847
+ "http": { icon: Globe, name: "HTTP\u670D\u52A1", desc: "\u63D0\u4F9BHTTP API\u670D\u52A1" },
848
+ "http-post": { icon: Send, name: "HTTP\u4E0A\u62A5", desc: "\u4E0A\u62A5\u4E8B\u4EF6\u5230HTTP\u670D\u52A1\u5668" }
849
+ };
850
+ const handleAdapterClick = (adapter, index) => {
851
+ setSelectedAdapter(adapter);
852
+ setSelectedAdapterIndex(index);
853
+ setIsNewAdapter(false);
854
+ setEditingName(false);
855
+ setTempName(adapter.name || "");
856
+ setShowToken(false);
857
+ setShowDialog(true);
858
+ };
859
+ const handleStartEditName = (e) => {
860
+ e.stopPropagation();
861
+ setEditingName(true);
862
+ };
863
+ const handleSaveName = () => {
864
+ if (!selectedAdapter) return;
865
+ const updatedAdapter = { ...selectedAdapter, name: tempName.trim() };
866
+ setSelectedAdapter(updatedAdapter);
867
+ setEditingName(false);
868
+ };
869
+ const handleCancelEditName = () => {
870
+ setTempName(selectedAdapter?.name || "");
871
+ setEditingName(false);
872
+ };
873
+ const handleSaveAdapter = () => {
874
+ if (!selectedAdapter) return;
875
+ const needsTokenValidation = selectedAdapter.enable && (selectedAdapter.type === "ws" || selectedAdapter.type === "http");
876
+ const adapterHost = selectedAdapter.host;
877
+ const isListenAll = !adapterHost || adapterHost === "0.0.0.0" || adapterHost === "::";
878
+ if (needsTokenValidation && isListenAll && !selectedAdapter.token?.trim()) {
879
+ showToast("\u76D1\u542C\u5168\u90E8\u5730\u5740\u65F6\u5FC5\u987B\u8BBE\u7F6E Token", "error");
880
+ return;
881
+ }
882
+ let newConnect;
883
+ if (isNewAdapter) {
884
+ newConnect = [...config.connect, selectedAdapter];
885
+ } else {
886
+ if (selectedAdapterIndex < 0) return;
887
+ newConnect = [...config.connect];
888
+ newConnect[selectedAdapterIndex] = selectedAdapter;
889
+ }
890
+ const newConfig = { ...config, connect: newConnect };
891
+ onChange(newConfig);
892
+ setShowDialog(false);
893
+ setIsNewAdapter(false);
894
+ onSave(newConfig);
895
+ };
896
+ const handleDeleteAdapter = () => {
897
+ if (isNewAdapter) {
898
+ setShowDialog(false);
899
+ setIsNewAdapter(false);
900
+ return;
901
+ }
902
+ if (selectedAdapterIndex < 0) return;
903
+ const newConnect = config.connect.filter((_, index) => index !== selectedAdapterIndex);
904
+ const newConfig = { ...config, connect: newConnect };
905
+ onChange(newConfig);
906
+ setShowDialog(false);
907
+ onSave(newConfig);
908
+ };
909
+ const handleAddAdapter = (type) => {
910
+ const baseConfig = {
911
+ enable: true,
912
+ token: "",
913
+ messageFormat: "array",
914
+ reportSelfMessage: false,
915
+ reportOfflineMessage: false,
916
+ debug: false
917
+ };
918
+ let newAdapter;
919
+ switch (type) {
920
+ case "ws":
921
+ newAdapter = { ...baseConfig, type: "ws", host: "", port: 3001, heartInterval: 6e4 };
922
+ break;
923
+ case "ws-reverse":
924
+ newAdapter = { ...baseConfig, type: "ws-reverse", url: "", heartInterval: 6e4 };
925
+ break;
926
+ case "http":
927
+ newAdapter = { ...baseConfig, type: "http", host: "", port: 3e3 };
928
+ break;
929
+ case "http-post":
930
+ newAdapter = { ...baseConfig, type: "http-post", url: "", enableHeart: false, heartInterval: 6e4 };
931
+ break;
932
+ }
933
+ setShowAddDialog(false);
934
+ setSelectedAdapter(newAdapter);
935
+ setSelectedAdapterIndex(-1);
936
+ setIsNewAdapter(true);
937
+ setShowToken(false);
938
+ setShowDialog(true);
939
+ };
940
+ const updateSelectedAdapter = (field, value) => {
941
+ if (!selectedAdapter) return;
942
+ setSelectedAdapter({ ...selectedAdapter, [field]: value });
943
+ };
944
+ return /* @__PURE__ */ jsxs3("div", { className: "space-y-6", children: [
945
+ /* @__PURE__ */ jsx3("div", { className: "card p-6", children: /* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center gap-3", children: [
946
+ /* @__PURE__ */ jsx3("div", { className: "w-12 h-12 rounded-xl gradient-primary-br flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx3(Radio, { size: 24, className: "text-white" }) }),
947
+ /* @__PURE__ */ jsxs3("div", { className: "flex-1 min-w-48", children: [
948
+ /* @__PURE__ */ jsx3("h3", { className: "text-lg font-semibold text-theme", children: "OneBot 11 \u534F\u8BAE" }),
949
+ /* @__PURE__ */ jsx3("p", { className: "text-sm text-theme-secondary", children: "\u4EC5\u652F\u6301 NTQQ \u534F\u8BAE\u7AEF\uFF1B\u542F\u7528\u5F00\u5173\u5728\u63D2\u4EF6\u9875\u7684\u5361\u7247\u4E0A" })
950
+ ] }),
951
+ /* @__PURE__ */ jsxs3("div", { className: "ml-auto flex items-center gap-1", children: [
952
+ /* @__PURE__ */ jsx3(MusicCardSign_default, {}),
953
+ /* @__PURE__ */ jsxs3(
954
+ "a",
955
+ {
956
+ href: "https://www.luckylillia.com/guide/develop#onebot11-%E5%8D%8F%E8%AE%AE",
957
+ target: "_blank",
958
+ rel: "noopener noreferrer",
959
+ className: "flex items-center gap-1.5 px-3 py-1.5 text-sm text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-lg transition-colors",
960
+ children: [
961
+ /* @__PURE__ */ jsx3(ExternalLink, { size: 16 }),
962
+ "\u6587\u6863"
963
+ ]
964
+ }
965
+ )
966
+ ] })
967
+ ] }) }),
968
+ config.connect && Array.isArray(config.connect) && /* @__PURE__ */ jsxs3(Fragment2, { children: [
969
+ /* @__PURE__ */ jsx3("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: config.connect.map((adapter, index) => {
970
+ const info = adapterInfo[adapter.type];
971
+ const Icon2 = info.icon;
972
+ return /* @__PURE__ */ jsxs3(
973
+ "div",
974
+ {
975
+ className: `card p-6 cursor-pointer hover:scale-105 transition-all ${adapter.enable ? "ring-2 ring-pink-500" : ""}`,
976
+ onClick: () => handleAdapterClick(adapter, index),
977
+ children: [
978
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-start justify-between mb-4", children: [
979
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
980
+ /* @__PURE__ */ jsx3("div", { className: `w-12 h-12 rounded-2xl flex items-center justify-center ${adapter.enable ? "gradient-primary-br text-white" : "bg-gray-200 dark:bg-neutral-600 text-theme-secondary"}`, children: /* @__PURE__ */ jsx3(Icon2, { size: 24 }) }),
981
+ /* @__PURE__ */ jsxs3("div", { className: "flex-1", children: [
982
+ /* @__PURE__ */ jsx3("h4", { className: "text-lg font-semibold text-theme", children: adapter.name || info.name }),
983
+ /* @__PURE__ */ jsx3("p", { className: "text-sm text-theme-secondary", children: info.desc })
984
+ ] })
985
+ ] }),
986
+ /* @__PURE__ */ jsx3(Settings, { size: 20, className: "text-theme-hint" })
987
+ ] }),
988
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between mt-4 pt-4 border-t border-theme-divider", children: [
989
+ /* @__PURE__ */ jsx3("span", { className: `text-xs font-medium px-3 py-1 rounded-full ${adapter.enable ? "bg-green-100 dark:bg-green-900/50 text-green-800 dark:text-green-400" : "bg-gray-100 dark:bg-neutral-700 text-gray-600 dark:text-neutral-400"}`, children: adapter.enable ? "\u5DF2\u542F\u7528" : "\u672A\u542F\u7528" }),
990
+ adapter.enable && /* @__PURE__ */ jsxs3(Fragment2, { children: [
991
+ (adapter.type === "ws" || adapter.type === "http") && /* @__PURE__ */ jsxs3("span", { className: "text-sm text-theme-secondary", children: [
992
+ "\u7AEF\u53E3: ",
993
+ adapter.port
994
+ ] }),
995
+ (adapter.type === "ws-reverse" || adapter.type === "http-post") && /* @__PURE__ */ jsxs3("span", { className: "text-sm text-theme-secondary truncate max-w-[180px]", title: adapter.url || "\u672A\u914D\u7F6E", children: [
996
+ "URL: ",
997
+ adapter.url || "\u672A\u914D\u7F6E"
998
+ ] })
999
+ ] })
1000
+ ] })
1001
+ ]
1002
+ },
1003
+ index
1004
+ );
1005
+ }) }),
1006
+ /* @__PURE__ */ jsx3("div", { className: "flex justify-center mt-6", children: /* @__PURE__ */ jsxs3(
1007
+ "button",
1008
+ {
1009
+ onClick: () => setShowAddDialog(true),
1010
+ className: "btn-primary flex items-center gap-2",
1011
+ children: [
1012
+ /* @__PURE__ */ jsx3(Plus, { size: 20 }),
1013
+ "\u6DFB\u52A0\u9002\u914D\u5668"
1014
+ ]
1015
+ }
1016
+ ) })
1017
+ ] }),
1018
+ showDialog && selectedAdapter && /* @__PURE__ */ jsx3(Portal, { children: /* @__PURE__ */ jsx3("div", { className: "fixed inset-0 scrim flex items-center justify-center p-4", style: { zIndex: 9e3 }, children: /* @__PURE__ */ jsxs3("div", { className: "glass glass-thick r-window glass-pop w-full max-w-2xl max-h-[80vh] flex flex-col", children: [
1019
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between p-6 hairline-b", children: [
1020
+ /* @__PURE__ */ jsx3("div", { className: "flex items-center gap-3 flex-1", children: editingName ? /* @__PURE__ */ jsxs3("div", { className: "flex flex-col sm:flex-row items-stretch sm:items-center gap-2 flex-1", children: [
1021
+ /* @__PURE__ */ jsx3(
1022
+ "input",
1023
+ {
1024
+ type: "text",
1025
+ value: tempName,
1026
+ onChange: (e) => setTempName(e.target.value),
1027
+ onKeyDown: (e) => {
1028
+ if (e.key === "Enter") handleSaveName();
1029
+ if (e.key === "Escape") handleCancelEditName();
1030
+ },
1031
+ placeholder: "\u8F93\u5165\u81EA\u5B9A\u4E49\u540D\u79F0",
1032
+ className: "flex-1 px-3 py-2 border border-theme-input rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-500 bg-theme-input text-theme",
1033
+ autoFocus: true
1034
+ }
1035
+ ),
1036
+ /* @__PURE__ */ jsxs3("div", { className: "flex gap-2 sm:flex-shrink-0", children: [
1037
+ /* @__PURE__ */ jsx3("button", { onClick: handleSaveName, className: "flex-1 sm:flex-none px-4 py-2 bg-pink-500 text-white rounded-xl hover:bg-pink-600 transition-colors whitespace-nowrap", children: "\u786E\u5B9A" }),
1038
+ /* @__PURE__ */ jsx3("button", { onClick: handleCancelEditName, className: "flex-1 sm:flex-none px-4 py-2 bg-theme-item text-theme-secondary rounded-xl hover:bg-theme-item-hover transition-colors whitespace-nowrap", children: "\u53D6\u6D88" })
1039
+ ] })
1040
+ ] }) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
1041
+ /* @__PURE__ */ jsxs3("h3", { className: "text-xl font-semibold text-theme", children: [
1042
+ isNewAdapter ? "\u65B0\u5EFA - " : "",
1043
+ selectedAdapter.name || adapterInfo[selectedAdapter.type].name
1044
+ ] }),
1045
+ /* @__PURE__ */ jsx3("button", { onClick: handleStartEditName, className: "p-2 text-theme-hint hover:text-pink-500 hover:bg-pink-50 dark:hover:bg-pink-900/30 rounded-lg transition-colors", title: "\u7F16\u8F91\u540D\u79F0", children: /* @__PURE__ */ jsx3(Pen, { size: 18 }) })
1046
+ ] }) }),
1047
+ /* @__PURE__ */ jsx3("button", { onClick: () => {
1048
+ setShowDialog(false);
1049
+ setIsNewAdapter(false);
1050
+ setEditingName(false);
1051
+ }, className: "text-theme-hint hover:text-theme", children: /* @__PURE__ */ jsx3(X, { size: 24 }) })
1052
+ ] }),
1053
+ /* @__PURE__ */ jsxs3("div", { className: "p-6 space-y-6 overflow-y-auto flex-1", children: [
1054
+ /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsxs3("label", { className: "flex items-center justify-between", children: [
1055
+ /* @__PURE__ */ jsx3("span", { className: "text-sm font-medium text-theme-secondary", children: "\u542F\u7528\u6B64\u9002\u914D\u5668" }),
1056
+ /* @__PURE__ */ jsx3("input", { type: "checkbox", checked: selectedAdapter.enable, onChange: (e) => updateSelectedAdapter("enable", e.target.checked), className: "switch-toggle" })
1057
+ ] }) }),
1058
+ selectedAdapter.type === "ws" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
1059
+ /* @__PURE__ */ jsxs3("div", { children: [
1060
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u76D1\u542C\u5730\u5740" }),
1061
+ /* @__PURE__ */ jsx3(HostInput, { value: selectedAdapter.host || "", onChange: (host) => updateSelectedAdapter("host", host) })
1062
+ ] }),
1063
+ /* @__PURE__ */ jsxs3("div", { children: [
1064
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u7AEF\u53E3" }),
1065
+ /* @__PURE__ */ jsx3("input", { type: "number", value: selectedAdapter.port, onChange: (e) => updateSelectedAdapter("port", parseInt(e.target.value)), className: "input-field" })
1066
+ ] }),
1067
+ /* @__PURE__ */ jsxs3("div", { children: [
1068
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u5FC3\u8DF3\u95F4\u9694 (ms)" }),
1069
+ /* @__PURE__ */ jsx3("input", { type: "number", value: selectedAdapter.heartInterval, onChange: (e) => updateSelectedAdapter("heartInterval", parseInt(e.target.value)), className: "input-field" })
1070
+ ] })
1071
+ ] }),
1072
+ selectedAdapter.type === "ws-reverse" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
1073
+ /* @__PURE__ */ jsxs3("div", { children: [
1074
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u8FDE\u63A5\u5730\u5740" }),
1075
+ /* @__PURE__ */ jsx3("input", { type: "text", value: selectedAdapter.url, onChange: (e) => updateSelectedAdapter("url", e.target.value), placeholder: "ws://example.com:8080", className: "input-field" })
1076
+ ] }),
1077
+ /* @__PURE__ */ jsxs3("div", { children: [
1078
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u5FC3\u8DF3\u95F4\u9694 (ms)" }),
1079
+ /* @__PURE__ */ jsx3("input", { type: "number", value: selectedAdapter.heartInterval, onChange: (e) => updateSelectedAdapter("heartInterval", parseInt(e.target.value)), className: "input-field" })
1080
+ ] })
1081
+ ] }),
1082
+ selectedAdapter.type === "http" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
1083
+ /* @__PURE__ */ jsxs3("div", { children: [
1084
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u76D1\u542C\u5730\u5740" }),
1085
+ /* @__PURE__ */ jsx3(HostInput, { value: selectedAdapter.host || "", onChange: (host) => updateSelectedAdapter("host", host) })
1086
+ ] }),
1087
+ /* @__PURE__ */ jsxs3("div", { children: [
1088
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u7AEF\u53E3" }),
1089
+ /* @__PURE__ */ jsx3("input", { type: "number", value: selectedAdapter.port, onChange: (e) => updateSelectedAdapter("port", parseInt(e.target.value)), className: "input-field" })
1090
+ ] })
1091
+ ] }),
1092
+ selectedAdapter.type === "http-post" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
1093
+ /* @__PURE__ */ jsxs3("div", { children: [
1094
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u4E0A\u62A5\u5730\u5740" }),
1095
+ /* @__PURE__ */ jsx3("input", { type: "text", value: selectedAdapter.url, onChange: (e) => updateSelectedAdapter("url", e.target.value), placeholder: "http://example.com:8080/webhook", className: "input-field" })
1096
+ ] }),
1097
+ /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsxs3("label", { className: "flex items-center justify-between mb-2", children: [
1098
+ /* @__PURE__ */ jsx3("span", { className: "text-sm font-medium text-theme-secondary", children: "\u542F\u7528\u5FC3\u8DF3" }),
1099
+ /* @__PURE__ */ jsx3("input", { type: "checkbox", checked: selectedAdapter.enableHeart, onChange: (e) => updateSelectedAdapter("enableHeart", e.target.checked), className: "switch-toggle" })
1100
+ ] }) }),
1101
+ /* @__PURE__ */ jsxs3("div", { children: [
1102
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u5FC3\u8DF3\u95F4\u9694 (ms)" }),
1103
+ /* @__PURE__ */ jsx3("input", { type: "number", value: selectedAdapter.heartInterval, onChange: (e) => updateSelectedAdapter("heartInterval", parseInt(e.target.value)), className: "input-field" })
1104
+ ] })
1105
+ ] }),
1106
+ /* @__PURE__ */ jsxs3("div", { className: "border-t border-theme-divider pt-6", children: [
1107
+ /* @__PURE__ */ jsx3("h4", { className: "text-md font-semibold text-theme mb-4", children: "\u901A\u7528\u914D\u7F6E" }),
1108
+ /* @__PURE__ */ jsxs3("div", { className: "space-y-4", children: [
1109
+ /* @__PURE__ */ jsxs3("div", { children: [
1110
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "Token" }),
1111
+ /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
1112
+ /* @__PURE__ */ jsx3("input", { type: showToken ? "text" : "password", value: selectedAdapter.token, onChange: (e) => updateSelectedAdapter("token", e.target.value), placeholder: "\u8BBF\u95EE\u4EE4\u724C", className: "input-field pr-12" }),
1113
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => setShowToken(!showToken), className: "absolute right-3 top-1/2 -translate-y-1/2 text-theme-hint hover:text-theme transition-colors p-1", children: showToken ? /* @__PURE__ */ jsx3(EyeOff, { size: 20 }) : /* @__PURE__ */ jsx3(Eye, { size: 20 }) })
1114
+ ] })
1115
+ ] }),
1116
+ /* @__PURE__ */ jsxs3("div", { children: [
1117
+ /* @__PURE__ */ jsx3("label", { className: "block text-sm font-medium text-theme-secondary mb-2", children: "\u6D88\u606F\u683C\u5F0F" }),
1118
+ /* @__PURE__ */ jsxs3("div", { className: "flex gap-4 text-theme-secondary", children: [
1119
+ /* @__PURE__ */ jsxs3("label", { className: "flex items-center", children: [
1120
+ /* @__PURE__ */ jsx3("input", { type: "radio", value: "array", checked: selectedAdapter.messageFormat === "array", onChange: (e) => updateSelectedAdapter("messageFormat", e.target.value), className: "mr-2" }),
1121
+ "\u6D88\u606F\u6BB5 (array)"
1122
+ ] }),
1123
+ /* @__PURE__ */ jsxs3("label", { className: "flex items-center", children: [
1124
+ /* @__PURE__ */ jsx3("input", { type: "radio", value: "string", checked: selectedAdapter.messageFormat === "string", onChange: (e) => updateSelectedAdapter("messageFormat", e.target.value), className: "mr-2" }),
1125
+ "CQ\u7801 (string)"
1126
+ ] })
1127
+ ] })
1128
+ ] }),
1129
+ /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsxs3("label", { className: "flex items-center justify-between", children: [
1130
+ /* @__PURE__ */ jsx3("span", { className: "text-sm font-medium text-theme-secondary", children: "\u4E0A\u62A5\u81EA\u5DF1\u53D1\u9001\u7684\u6D88\u606F" }),
1131
+ /* @__PURE__ */ jsx3("input", { type: "checkbox", checked: selectedAdapter.reportSelfMessage, onChange: (e) => updateSelectedAdapter("reportSelfMessage", e.target.checked), className: "switch-toggle" })
1132
+ ] }) }),
1133
+ /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsxs3("label", { className: "flex items-center justify-between", children: [
1134
+ /* @__PURE__ */ jsx3("span", { className: "text-sm font-medium text-theme-secondary", children: "\u4E0A\u62A5\u79BB\u7EBF\u6D88\u606F" }),
1135
+ /* @__PURE__ */ jsx3("input", { type: "checkbox", checked: selectedAdapter.reportOfflineMessage, onChange: (e) => updateSelectedAdapter("reportOfflineMessage", e.target.checked), className: "switch-toggle" })
1136
+ ] }) }),
1137
+ /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsxs3("label", { className: "flex items-center justify-between", children: [
1138
+ /* @__PURE__ */ jsx3("span", { className: "text-sm font-medium text-theme-secondary", children: "\u8C03\u8BD5\u6A21\u5F0F" }),
1139
+ /* @__PURE__ */ jsx3("input", { type: "checkbox", checked: selectedAdapter.debug, onChange: (e) => updateSelectedAdapter("debug", e.target.checked), className: "switch-toggle" })
1140
+ ] }) })
1141
+ ] })
1142
+ ] }),
1143
+ /* @__PURE__ */ jsx3(
1144
+ EventFilterEditor_default,
1145
+ {
1146
+ filter: selectedAdapter.filter,
1147
+ onChange: (f) => updateSelectedAdapter("filter", f)
1148
+ },
1149
+ selectedAdapterIndex
1150
+ )
1151
+ ] }),
1152
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between p-6 hairline-t", children: [
1153
+ !isNewAdapter && /* @__PURE__ */ jsxs3("button", { onClick: handleDeleteAdapter, className: "px-6 py-2.5 bg-red-500 hover:bg-red-600 text-white rounded-xl font-medium transition-colors flex items-center gap-2", children: [
1154
+ /* @__PURE__ */ jsx3(Trash2, { size: 18 }),
1155
+ "\u5220\u9664"
1156
+ ] }),
1157
+ isNewAdapter && /* @__PURE__ */ jsx3("div", {}),
1158
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
1159
+ /* @__PURE__ */ jsx3("button", { onClick: () => setShowDialog(false), className: "px-6 py-2.5 text-theme-secondary hover:bg-theme-item rounded-xl font-medium transition-colors", children: "\u53D6\u6D88" }),
1160
+ /* @__PURE__ */ jsx3("button", { onClick: handleSaveAdapter, className: "btn-primary", children: "\u4FDD\u5B58" })
1161
+ ] })
1162
+ ] })
1163
+ ] }) }) }),
1164
+ showAddDialog && /* @__PURE__ */ jsx3(Portal, { children: /* @__PURE__ */ jsx3("div", { className: "fixed inset-0 scrim flex items-center justify-center p-4", style: { zIndex: 9e3 }, children: /* @__PURE__ */ jsxs3("div", { className: "glass glass-thick r-window glass-pop w-full max-w-md", children: [
1165
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between p-6 hairline-b", children: [
1166
+ /* @__PURE__ */ jsx3("h3", { className: "text-xl font-semibold text-theme", children: "\u9009\u62E9\u9002\u914D\u5668\u7C7B\u578B" }),
1167
+ /* @__PURE__ */ jsx3("button", { onClick: () => setShowAddDialog(false), className: "text-theme-hint hover:text-theme", children: /* @__PURE__ */ jsx3(X, { size: 24 }) })
1168
+ ] }),
1169
+ /* @__PURE__ */ jsxs3("div", { className: "p-6 space-y-3", children: [
1170
+ /* @__PURE__ */ jsxs3("button", { onClick: () => handleAddAdapter("ws"), className: "w-full p-4 rounded-2xl bg-gradient-to-br from-pink-50 to-rose-50 dark:from-pink-900/30 dark:to-rose-900/30 hover:from-pink-100 hover:to-rose-100 dark:hover:from-pink-900/50 dark:hover:to-rose-900/50 transition-all flex items-center gap-4 group", children: [
1171
+ /* @__PURE__ */ jsx3("div", { className: "w-12 h-12 rounded-xl gradient-primary-br text-white flex items-center justify-center group-hover:scale-110 transition-transform", children: /* @__PURE__ */ jsx3(Radio, { size: 24 }) }),
1172
+ /* @__PURE__ */ jsxs3("div", { className: "text-left", children: [
1173
+ /* @__PURE__ */ jsx3("h4", { className: "text-lg font-semibold text-theme", children: "WebSocket\u6B63\u5411" }),
1174
+ /* @__PURE__ */ jsx3("p", { className: "text-sm text-theme-secondary", children: "\u4F5C\u4E3AWebSocket\u670D\u52A1\u5668" })
1175
+ ] })
1176
+ ] }),
1177
+ /* @__PURE__ */ jsxs3("button", { onClick: () => handleAddAdapter("ws-reverse"), className: "w-full p-4 rounded-2xl bg-gradient-to-br from-green-50 to-teal-50 dark:from-green-900/30 dark:to-teal-900/30 hover:from-green-100 hover:to-teal-100 dark:hover:from-green-900/50 dark:hover:to-teal-900/50 transition-all flex items-center gap-4 group", children: [
1178
+ /* @__PURE__ */ jsx3("div", { className: "w-12 h-12 rounded-xl bg-gradient-to-br from-green-500 to-teal-600 text-white flex items-center justify-center group-hover:scale-110 transition-transform", children: /* @__PURE__ */ jsx3(Wifi, { size: 24 }) }),
1179
+ /* @__PURE__ */ jsxs3("div", { className: "text-left", children: [
1180
+ /* @__PURE__ */ jsx3("h4", { className: "text-lg font-semibold text-theme", children: "WebSocket\u53CD\u5411" }),
1181
+ /* @__PURE__ */ jsx3("p", { className: "text-sm text-theme-secondary", children: "\u4F5C\u4E3A\u5BA2\u6237\u7AEF\u8FDE\u63A5\u5230WebSocket\u670D\u52A1\u7AEF" })
1182
+ ] })
1183
+ ] }),
1184
+ /* @__PURE__ */ jsxs3("button", { onClick: () => handleAddAdapter("http"), className: "w-full p-4 rounded-2xl bg-gradient-to-br from-orange-50 to-red-50 dark:from-orange-900/30 dark:to-red-900/30 hover:from-orange-100 hover:to-red-100 dark:hover:from-orange-900/50 dark:hover:to-red-900/50 transition-all flex items-center gap-4 group", children: [
1185
+ /* @__PURE__ */ jsx3("div", { className: "w-12 h-12 rounded-xl bg-gradient-to-br from-orange-500 to-red-600 text-white flex items-center justify-center group-hover:scale-110 transition-transform", children: /* @__PURE__ */ jsx3(Globe, { size: 24 }) }),
1186
+ /* @__PURE__ */ jsxs3("div", { className: "text-left", children: [
1187
+ /* @__PURE__ */ jsx3("h4", { className: "text-lg font-semibold text-theme", children: "HTTP\u670D\u52A1" }),
1188
+ /* @__PURE__ */ jsx3("p", { className: "text-sm text-theme-secondary", children: "\u63D0\u4F9BHTTP API\u670D\u52A1" })
1189
+ ] })
1190
+ ] }),
1191
+ /* @__PURE__ */ jsxs3("button", { onClick: () => handleAddAdapter("http-post"), className: "w-full p-4 rounded-2xl bg-gradient-to-br from-pink-50 to-rose-50 dark:from-pink-900/30 dark:to-rose-900/30 hover:from-pink-100 hover:to-rose-100 dark:hover:from-pink-900/50 dark:hover:to-rose-900/50 transition-all flex items-center gap-4 group", children: [
1192
+ /* @__PURE__ */ jsx3("div", { className: "w-12 h-12 rounded-xl bg-gradient-to-br from-pink-500 to-rose-600 text-white flex items-center justify-center group-hover:scale-110 transition-transform", children: /* @__PURE__ */ jsx3(Send, { size: 24 }) }),
1193
+ /* @__PURE__ */ jsxs3("div", { className: "text-left", children: [
1194
+ /* @__PURE__ */ jsx3("h4", { className: "text-lg font-semibold text-theme", children: "HTTP\u4E0A\u62A5" }),
1195
+ /* @__PURE__ */ jsx3("p", { className: "text-sm text-theme-secondary", children: "\u4E0A\u62A5\u4E8B\u4EF6\u5230HTTP\u670D\u52A1\u5668" })
1196
+ ] })
1197
+ ] })
1198
+ ] }),
1199
+ /* @__PURE__ */ jsx3("div", { className: "flex justify-end p-6 hairline-t", children: /* @__PURE__ */ jsx3("button", { onClick: () => setShowAddDialog(false), className: "px-6 py-2.5 text-theme-secondary hover:bg-theme-item rounded-xl font-medium transition-colors", children: "\u53D6\u6D88" }) })
1200
+ ] }) }) })
1201
+ ] });
1202
+ };
1203
+ var Connections_default = Connections;
1204
+
1205
+ // src/client/index.tsx
1206
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1207
+ var name = "@luckylillia-dev/plugin-onebot11";
1208
+ var OneBotSettings = () => {
1209
+ const { value, setValue, save, error } = usePluginConfig();
1210
+ if (error) return /* @__PURE__ */ jsxs4("p", { className: "card p-6 text-sm text-red-500", children: [
1211
+ "\u52A0\u8F7D OneBot 11 \u914D\u7F6E\u5931\u8D25\uFF1A",
1212
+ error
1213
+ ] });
1214
+ if (!value) return /* @__PURE__ */ jsx4("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsx4(LoaderCircle, { size: 40, className: "animate-spin text-pink-500" }) });
1215
+ return /* @__PURE__ */ jsx4("div", { className: "space-y-6", children: /* @__PURE__ */ jsx4(
1216
+ Connections_default,
1217
+ {
1218
+ config: value,
1219
+ onChange: setValue,
1220
+ onSave: (next) => {
1221
+ void save(next ?? value);
1222
+ }
1223
+ }
1224
+ ) });
1225
+ };
1226
+ var apply = (ctx) => {
1227
+ ctx.page({ id: "onebot", title: "OneBot 11", icon: "radio", component: OneBotSettings, order: 10, settings: true });
1228
+ };
1229
+ var index_default = apply;
1230
+ export {
1231
+ index_default as default,
1232
+ name
1233
+ };
1234
+ /*! Bundled license information:
1235
+
1236
+ lucide-react/dist/esm/shared/src/utils/mergeClasses.js:
1237
+ lucide-react/dist/esm/shared/src/utils/toKebabCase.js:
1238
+ lucide-react/dist/esm/shared/src/utils/toCamelCase.js:
1239
+ lucide-react/dist/esm/shared/src/utils/toPascalCase.js:
1240
+ lucide-react/dist/esm/defaultAttributes.js:
1241
+ lucide-react/dist/esm/shared/src/utils/hasA11yProp.js:
1242
+ lucide-react/dist/esm/Icon.js:
1243
+ lucide-react/dist/esm/createLucideIcon.js:
1244
+ lucide-react/dist/esm/icons/chevron-down.js:
1245
+ lucide-react/dist/esm/icons/chevron-right.js:
1246
+ lucide-react/dist/esm/icons/code.js:
1247
+ lucide-react/dist/esm/icons/external-link.js:
1248
+ lucide-react/dist/esm/icons/eye-off.js:
1249
+ lucide-react/dist/esm/icons/eye.js:
1250
+ lucide-react/dist/esm/icons/funnel.js:
1251
+ lucide-react/dist/esm/icons/globe.js:
1252
+ lucide-react/dist/esm/icons/layout-list.js:
1253
+ lucide-react/dist/esm/icons/loader-circle.js:
1254
+ lucide-react/dist/esm/icons/pen.js:
1255
+ lucide-react/dist/esm/icons/plus.js:
1256
+ lucide-react/dist/esm/icons/radio.js:
1257
+ lucide-react/dist/esm/icons/send.js:
1258
+ lucide-react/dist/esm/icons/settings-2.js:
1259
+ lucide-react/dist/esm/icons/settings.js:
1260
+ lucide-react/dist/esm/icons/trash-2.js:
1261
+ lucide-react/dist/esm/icons/wifi.js:
1262
+ lucide-react/dist/esm/icons/x.js:
1263
+ lucide-react/dist/esm/lucide-react.js:
1264
+ (**
1265
+ * @license lucide-react v0.575.0 - ISC
1266
+ *
1267
+ * This source code is licensed under the ISC license.
1268
+ * See the LICENSE file in the root directory of this source tree.
1269
+ *)
1270
+ */