@blade-hq/agent-react 2612.0.0-beta.8 → 2612.0.0-beta.81

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.
Files changed (177) hide show
  1. package/README.md +47 -0
  2. package/dist/SessionPluginConfigForm-7LJ5SUNY.js +9 -0
  3. package/dist/SessionPluginConfigForm-7LJ5SUNY.js.map +1 -0
  4. package/dist/chat/AgentLoopBlock.d.ts +0 -2
  5. package/dist/chat/AskUserQuestionBlock.d.ts +3 -20
  6. package/dist/chat/AssistantTurnBlock.d.ts +1 -9
  7. package/dist/chat/AttachmentPreviewDialog.d.ts +0 -1
  8. package/dist/chat/ChatLoadingIndicator.d.ts +7 -0
  9. package/dist/chat/ContextAttachmentPills.d.ts +4 -0
  10. package/dist/chat/CurrentPlanPanel.d.ts +0 -3
  11. package/dist/chat/FileDeliveryCards.d.ts +0 -4
  12. package/dist/chat/FinalArtifactCards.d.ts +0 -1
  13. package/dist/chat/ImageLightbox.d.ts +1 -1
  14. package/dist/chat/LiteMessageList.d.ts +5 -3
  15. package/dist/chat/MessageFileAttachmentList.d.ts +0 -5
  16. package/dist/chat/QuestionnaireQuestionBlock.d.ts +11 -0
  17. package/dist/chat/SessionReplayBar.d.ts +0 -1
  18. package/dist/chat/TextAttachmentPills.d.ts +0 -3
  19. package/dist/chat/TurnNavRail.d.ts +1 -7
  20. package/dist/chat/WorkflowRunBlock.d.ts +21 -4
  21. package/dist/chat/ai-elements/shimmer.d.ts +0 -4
  22. package/dist/chat/customization.d.ts +1 -1
  23. package/dist/chat/index.d.ts +3 -2
  24. package/dist/chat/markdown/ExternalAnchor.d.ts +2 -2
  25. package/dist/chat/markdown/MarkdownContent.d.ts +3 -0
  26. package/dist/chat/message-list-blocks.d.ts +0 -1
  27. package/dist/chat/runtime/actions.d.ts +2 -2
  28. package/dist/chat/runtime/background-task-dismissals.d.ts +0 -1
  29. package/dist/chat/runtime/composer-channels.d.ts +0 -3
  30. package/dist/chat/runtime/input-cache-reset.d.ts +0 -5
  31. package/dist/chat/runtime/input-services.d.ts +10 -0
  32. package/dist/chat/runtime/session-source.d.ts +0 -5
  33. package/dist/chat/runtime/use-chat-actions.d.ts +0 -4
  34. package/dist/chat/turn-locate-channel.d.ts +53 -0
  35. package/dist/{chat-OCLOVB3H.css → chat-IHPRU35X.css} +5 -18
  36. package/dist/chat.css +5 -18
  37. package/dist/chunk-66JXSDLB.js +13770 -0
  38. package/dist/chunk-66JXSDLB.js.map +1 -0
  39. package/dist/chunk-C3LBNHVM.js +9482 -0
  40. package/dist/chunk-C3LBNHVM.js.map +1 -0
  41. package/dist/chunk-F4MWGSKX.js +1308 -0
  42. package/dist/chunk-F4MWGSKX.js.map +1 -0
  43. package/dist/chunk-FBGCDXRK.js +607 -0
  44. package/dist/chunk-FBGCDXRK.js.map +1 -0
  45. package/dist/{chunk-67GHJQK5.js → chunk-FDB3J5QF.js} +3889 -26106
  46. package/dist/chunk-FDB3J5QF.js.map +1 -0
  47. package/dist/chunk-FH5HA3GW.js +2416 -0
  48. package/dist/chunk-FH5HA3GW.js.map +1 -0
  49. package/dist/chunk-KHJEIHMJ.js +973 -0
  50. package/dist/chunk-KHJEIHMJ.js.map +1 -0
  51. package/dist/chunk-MWILWSPG.js +9629 -0
  52. package/dist/chunk-MWILWSPG.js.map +1 -0
  53. package/dist/chunk-NRYLAO3X.js +3978 -0
  54. package/dist/chunk-NRYLAO3X.js.map +1 -0
  55. package/dist/{chunk-MERN5XEM.js → chunk-SK43YNRX.js} +4181 -16594
  56. package/dist/chunk-SK43YNRX.js.map +1 -0
  57. package/dist/components/AccountConnectorRules.d.ts +7 -0
  58. package/dist/components/AccountConnectors.d.ts +13 -0
  59. package/dist/components/BrowserConnectionDialog.d.ts +8 -0
  60. package/dist/components/ChatInput.d.ts +1 -15
  61. package/dist/components/ConfigConnection.d.ts +16 -0
  62. package/dist/components/ConnectorAuthorizationProgress.d.ts +6 -0
  63. package/dist/components/ConnectorConnection.d.ts +4 -0
  64. package/dist/components/ConnectorDetail.d.ts +46 -0
  65. package/dist/components/ConnectorPanel.d.ts +3 -1
  66. package/dist/components/ConnectorRulesPanel.d.ts +10 -0
  67. package/dist/components/ConnectorRuntimeDiagnostics.d.ts +5 -0
  68. package/dist/components/DeviceConnection.d.ts +17 -0
  69. package/dist/components/FeishuCapabilitySelection.d.ts +14 -0
  70. package/dist/components/FeishuPermissionStatus.d.ts +7 -0
  71. package/dist/components/LlmAdvancedSettings.d.ts +0 -1
  72. package/dist/components/ManagedConnection.d.ts +12 -0
  73. package/dist/components/McpAppFrame.d.ts +17 -0
  74. package/dist/components/PackEventNotice.d.ts +3 -0
  75. package/dist/components/PlanUpdateBlock.d.ts +0 -1
  76. package/dist/components/SessionPluginConfigForm.d.ts +4 -1
  77. package/dist/components/SessionPluginIcon.d.ts +1 -0
  78. package/dist/components/plugin-connector.d.ts +1 -0
  79. package/dist/connectors.d.ts +6 -0
  80. package/dist/connectors.js +19 -0
  81. package/dist/connectors.js.map +1 -0
  82. package/dist/embed/blade-chat-element.d.ts +0 -8
  83. package/dist/embed/entry.d.ts +13 -19
  84. package/dist/hooks/use-message-pin.d.ts +1 -1
  85. package/dist/hooks/use-turn-navigation.d.ts +19 -0
  86. package/dist/index.d.ts +6 -0
  87. package/dist/index.js +23 -3
  88. package/dist/internal.d.ts +7 -3
  89. package/dist/internal.js +59 -71
  90. package/dist/internal.js.map +1 -1
  91. package/dist/lib/message-shortcuts.d.ts +5 -0
  92. package/dist/questions.d.ts +7 -0
  93. package/dist/questions.js +910 -0
  94. package/dist/questions.js.map +1 -0
  95. package/dist/rich-input/ConnectButton.d.ts +7 -5
  96. package/dist/rich-input/FileCompletionMenu.d.ts +1 -2
  97. package/dist/rich-input/InputActionSubmenu.d.ts +10 -0
  98. package/dist/rich-input/SkillActionMenu.d.ts +10 -0
  99. package/dist/rich-input/SkillStatusBar.d.ts +0 -6
  100. package/dist/rich-input/extensions/skill-mention.d.ts +3 -20
  101. package/dist/rich-input/index.d.ts +3 -2
  102. package/dist/rich-input/lib/composer-content.d.ts +5 -1
  103. package/dist/rich-input/lib/plugin-suggestions.d.ts +5 -5
  104. package/dist/rich-input/lib/reference-candidates.d.ts +0 -1
  105. package/dist/rich-input/lib/skill-suggestions.d.ts +1 -1
  106. package/dist/rich-input/lib/user-home.d.ts +0 -17
  107. package/dist/rich-input/services.d.ts +1 -1
  108. package/dist/rich-input/voice/VoiceWaveform.d.ts +0 -3
  109. package/dist/rich-input.js +793 -1068
  110. package/dist/rich-input.js.map +1 -1
  111. package/dist/style.css +16 -55
  112. package/dist/style.full.css +23 -77
  113. package/dist/tool-details.d.ts +8 -0
  114. package/dist/tool-details.js +25 -0
  115. package/dist/tool-details.js.map +1 -0
  116. package/node_modules/@modelcontextprotocol/ext-apps/LICENSE +216 -0
  117. package/node_modules/@modelcontextprotocol/ext-apps/README.md +284 -0
  118. package/node_modules/@modelcontextprotocol/ext-apps/dist/docs/patterns.d.ts +9 -0
  119. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.d.ts +1348 -0
  120. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.examples.d.ts +9 -0
  121. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.js +39 -0
  122. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.test.d.ts +1 -0
  123. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-with-deps.js +82 -0
  124. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.d.ts +1214 -0
  125. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.examples.d.ts +9 -0
  126. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.js +39 -0
  127. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.test.d.ts +1 -0
  128. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/constants.d.ts +65 -0
  129. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/events.d.ts +47 -0
  130. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/events.test.d.ts +1 -0
  131. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.d.ts +1047 -0
  132. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.json +6170 -0
  133. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.test.d.ts +41 -0
  134. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/interop-v1.test.d.ts +1 -0
  135. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/legacy-handlers.d.ts +66 -0
  136. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/legacy-handlers.test.d.ts +1 -0
  137. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.d.ts +126 -0
  138. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.examples.d.ts +9 -0
  139. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.test.d.ts +1 -0
  140. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.d.ts +37 -0
  141. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.examples.d.ts +6 -0
  142. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.js +39 -0
  143. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/react-with-deps.js +82 -0
  144. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useApp.d.ts +115 -0
  145. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useApp.examples.d.ts +6 -0
  146. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useAutoResize.d.ts +54 -0
  147. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useAutoResize.examples.d.ts +6 -0
  148. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useDocumentTheme.d.ts +44 -0
  149. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useDocumentTheme.examples.d.ts +6 -0
  150. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useHostStyles.d.ts +113 -0
  151. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useHostStyles.examples.d.ts +6 -0
  152. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.d.ts +381 -0
  153. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.examples.d.ts +9 -0
  154. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.js +1 -0
  155. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.test.d.ts +1 -0
  156. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/spec.types.d.ts +698 -0
  157. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/standard-schema.d.ts +23 -0
  158. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/styles.d.ts +184 -0
  159. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/styles.examples.d.ts +9 -0
  160. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/types.d.ts +33 -0
  161. package/node_modules/@modelcontextprotocol/ext-apps/dist/src/wire-compat.test.d.ts +1 -0
  162. package/node_modules/@modelcontextprotocol/ext-apps/package.json +144 -0
  163. package/node_modules/@standard-schema/spec/LICENSE +21 -0
  164. package/node_modules/@standard-schema/spec/README.md +198 -0
  165. package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
  166. package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
  167. package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
  168. package/node_modules/@standard-schema/spec/dist/index.js +0 -0
  169. package/node_modules/@standard-schema/spec/package.json +52 -0
  170. package/package.json +19 -3
  171. package/public-api.md +60 -4
  172. package/dist/chunk-67GHJQK5.js.map +0 -1
  173. package/dist/chunk-DPDXGYGM.js +0 -258
  174. package/dist/chunk-DPDXGYGM.js.map +0 -1
  175. package/dist/chunk-MERN5XEM.js.map +0 -1
  176. package/dist/lib/agent-computer-command.d.ts +0 -32
  177. package/dist/rich-input/extensions/workflow-mention.d.ts +0 -10
@@ -0,0 +1,2416 @@
1
+ import {
2
+ AlertDialog,
3
+ AlertDialogAction,
4
+ AlertDialogCancel,
5
+ AlertDialogContent,
6
+ AlertDialogDescription,
7
+ AlertDialogFooter,
8
+ AlertDialogHeader,
9
+ AlertDialogTitle,
10
+ AlertDialogTrigger,
11
+ Button,
12
+ ConnectorDetail,
13
+ Dialog,
14
+ DialogContent,
15
+ DialogTitle,
16
+ cn,
17
+ cva,
18
+ dist_exports,
19
+ dist_exports3 as dist_exports2,
20
+ dist_exports5 as dist_exports3,
21
+ dist_exports6 as dist_exports4
22
+ } from "./chunk-MWILWSPG.js";
23
+ import {
24
+ LoaderCircle
25
+ } from "./chunk-KHJEIHMJ.js";
26
+
27
+ // src/components/DeviceConnection.tsx
28
+ import { useEffect, useRef, useState } from "react";
29
+
30
+ // ../ui/src/composites/switch.tsx
31
+ import { jsx } from "react/jsx-runtime";
32
+ function Switch({
33
+ className,
34
+ thumbClassName,
35
+ ...props
36
+ }) {
37
+ return /* @__PURE__ */ jsx(
38
+ dist_exports4.Root,
39
+ {
40
+ "data-slot": "switch",
41
+ className: cn("outline-none focus-visible:ring-3 focus-visible:ring-ring/50", className),
42
+ ...props,
43
+ children: /* @__PURE__ */ jsx(dist_exports4.Thumb, { "data-slot": "switch-thumb", className: thumbClassName })
44
+ }
45
+ );
46
+ }
47
+
48
+ // ../../node_modules/.pnpm/qrcode.react@4.2.0_react@19.2.4/node_modules/qrcode.react/lib/esm/index.js
49
+ import React from "react";
50
+ var __defProp = Object.defineProperty;
51
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
52
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
53
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
54
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
55
+ var __spreadValues = (a, b) => {
56
+ for (var prop in b || (b = {}))
57
+ if (__hasOwnProp.call(b, prop))
58
+ __defNormalProp(a, prop, b[prop]);
59
+ if (__getOwnPropSymbols)
60
+ for (var prop of __getOwnPropSymbols(b)) {
61
+ if (__propIsEnum.call(b, prop))
62
+ __defNormalProp(a, prop, b[prop]);
63
+ }
64
+ return a;
65
+ };
66
+ var __objRest = (source, exclude) => {
67
+ var target = {};
68
+ for (var prop in source)
69
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
70
+ target[prop] = source[prop];
71
+ if (source != null && __getOwnPropSymbols)
72
+ for (var prop of __getOwnPropSymbols(source)) {
73
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
74
+ target[prop] = source[prop];
75
+ }
76
+ return target;
77
+ };
78
+ var qrcodegen;
79
+ ((qrcodegen2) => {
80
+ const _QrCode = class _QrCode2 {
81
+ /*-- Constructor (low level) and fields --*/
82
+ // Creates a new QR Code with the given version number,
83
+ // error correction level, data codeword bytes, and mask number.
84
+ // This is a low-level API that most users should not use directly.
85
+ // A mid-level API is the encodeSegments() function.
86
+ constructor(version, errorCorrectionLevel, dataCodewords, msk) {
87
+ this.version = version;
88
+ this.errorCorrectionLevel = errorCorrectionLevel;
89
+ this.modules = [];
90
+ this.isFunction = [];
91
+ if (version < _QrCode2.MIN_VERSION || version > _QrCode2.MAX_VERSION)
92
+ throw new RangeError("Version value out of range");
93
+ if (msk < -1 || msk > 7)
94
+ throw new RangeError("Mask value out of range");
95
+ this.size = version * 4 + 17;
96
+ let row = [];
97
+ for (let i = 0; i < this.size; i++)
98
+ row.push(false);
99
+ for (let i = 0; i < this.size; i++) {
100
+ this.modules.push(row.slice());
101
+ this.isFunction.push(row.slice());
102
+ }
103
+ this.drawFunctionPatterns();
104
+ const allCodewords = this.addEccAndInterleave(dataCodewords);
105
+ this.drawCodewords(allCodewords);
106
+ if (msk == -1) {
107
+ let minPenalty = 1e9;
108
+ for (let i = 0; i < 8; i++) {
109
+ this.applyMask(i);
110
+ this.drawFormatBits(i);
111
+ const penalty = this.getPenaltyScore();
112
+ if (penalty < minPenalty) {
113
+ msk = i;
114
+ minPenalty = penalty;
115
+ }
116
+ this.applyMask(i);
117
+ }
118
+ }
119
+ assert(0 <= msk && msk <= 7);
120
+ this.mask = msk;
121
+ this.applyMask(msk);
122
+ this.drawFormatBits(msk);
123
+ this.isFunction = [];
124
+ }
125
+ /*-- Static factory functions (high level) --*/
126
+ // Returns a QR Code representing the given Unicode text string at the given error correction level.
127
+ // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
128
+ // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
129
+ // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
130
+ // ecl argument if it can be done without increasing the version.
131
+ static encodeText(text, ecl) {
132
+ const segs = qrcodegen2.QrSegment.makeSegments(text);
133
+ return _QrCode2.encodeSegments(segs, ecl);
134
+ }
135
+ // Returns a QR Code representing the given binary data at the given error correction level.
136
+ // This function always encodes using the binary segment mode, not any text mode. The maximum number of
137
+ // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
138
+ // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
139
+ static encodeBinary(data, ecl) {
140
+ const seg = qrcodegen2.QrSegment.makeBytes(data);
141
+ return _QrCode2.encodeSegments([seg], ecl);
142
+ }
143
+ /*-- Static factory functions (mid level) --*/
144
+ // Returns a QR Code representing the given segments with the given encoding parameters.
145
+ // The smallest possible QR Code version within the given range is automatically
146
+ // chosen for the output. Iff boostEcl is true, then the ECC level of the result
147
+ // may be higher than the ecl argument if it can be done without increasing the
148
+ // version. The mask number is either between 0 to 7 (inclusive) to force that
149
+ // mask, or -1 to automatically choose an appropriate mask (which may be slow).
150
+ // This function allows the user to create a custom sequence of segments that switches
151
+ // between modes (such as alphanumeric and byte) to encode text in less space.
152
+ // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
153
+ static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
154
+ if (!(_QrCode2.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode2.MAX_VERSION) || mask < -1 || mask > 7)
155
+ throw new RangeError("Invalid value");
156
+ let version;
157
+ let dataUsedBits;
158
+ for (version = minVersion; ; version++) {
159
+ const dataCapacityBits2 = _QrCode2.getNumDataCodewords(version, ecl) * 8;
160
+ const usedBits = QrSegment.getTotalBits(segs, version);
161
+ if (usedBits <= dataCapacityBits2) {
162
+ dataUsedBits = usedBits;
163
+ break;
164
+ }
165
+ if (version >= maxVersion)
166
+ throw new RangeError("Data too long");
167
+ }
168
+ for (const newEcl of [_QrCode2.Ecc.MEDIUM, _QrCode2.Ecc.QUARTILE, _QrCode2.Ecc.HIGH]) {
169
+ if (boostEcl && dataUsedBits <= _QrCode2.getNumDataCodewords(version, newEcl) * 8)
170
+ ecl = newEcl;
171
+ }
172
+ let bb = [];
173
+ for (const seg of segs) {
174
+ appendBits(seg.mode.modeBits, 4, bb);
175
+ appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);
176
+ for (const b of seg.getData())
177
+ bb.push(b);
178
+ }
179
+ assert(bb.length == dataUsedBits);
180
+ const dataCapacityBits = _QrCode2.getNumDataCodewords(version, ecl) * 8;
181
+ assert(bb.length <= dataCapacityBits);
182
+ appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
183
+ appendBits(0, (8 - bb.length % 8) % 8, bb);
184
+ assert(bb.length % 8 == 0);
185
+ for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)
186
+ appendBits(padByte, 8, bb);
187
+ let dataCodewords = [];
188
+ while (dataCodewords.length * 8 < bb.length)
189
+ dataCodewords.push(0);
190
+ bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));
191
+ return new _QrCode2(version, ecl, dataCodewords, mask);
192
+ }
193
+ /*-- Accessor methods --*/
194
+ // Returns the color of the module (pixel) at the given coordinates, which is false
195
+ // for light or true for dark. The top left corner has the coordinates (x=0, y=0).
196
+ // If the given coordinates are out of bounds, then false (light) is returned.
197
+ getModule(x, y) {
198
+ return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];
199
+ }
200
+ // Modified to expose modules for easy access
201
+ getModules() {
202
+ return this.modules;
203
+ }
204
+ /*-- Private helper methods for constructor: Drawing function modules --*/
205
+ // Reads this object's version field, and draws and marks all function modules.
206
+ drawFunctionPatterns() {
207
+ for (let i = 0; i < this.size; i++) {
208
+ this.setFunctionModule(6, i, i % 2 == 0);
209
+ this.setFunctionModule(i, 6, i % 2 == 0);
210
+ }
211
+ this.drawFinderPattern(3, 3);
212
+ this.drawFinderPattern(this.size - 4, 3);
213
+ this.drawFinderPattern(3, this.size - 4);
214
+ const alignPatPos = this.getAlignmentPatternPositions();
215
+ const numAlign = alignPatPos.length;
216
+ for (let i = 0; i < numAlign; i++) {
217
+ for (let j = 0; j < numAlign; j++) {
218
+ if (!(i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0))
219
+ this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
220
+ }
221
+ }
222
+ this.drawFormatBits(0);
223
+ this.drawVersion();
224
+ }
225
+ // Draws two copies of the format bits (with its own error correction code)
226
+ // based on the given mask and this object's error correction level field.
227
+ drawFormatBits(mask) {
228
+ const data = this.errorCorrectionLevel.formatBits << 3 | mask;
229
+ let rem = data;
230
+ for (let i = 0; i < 10; i++)
231
+ rem = rem << 1 ^ (rem >>> 9) * 1335;
232
+ const bits = (data << 10 | rem) ^ 21522;
233
+ assert(bits >>> 15 == 0);
234
+ for (let i = 0; i <= 5; i++)
235
+ this.setFunctionModule(8, i, getBit(bits, i));
236
+ this.setFunctionModule(8, 7, getBit(bits, 6));
237
+ this.setFunctionModule(8, 8, getBit(bits, 7));
238
+ this.setFunctionModule(7, 8, getBit(bits, 8));
239
+ for (let i = 9; i < 15; i++)
240
+ this.setFunctionModule(14 - i, 8, getBit(bits, i));
241
+ for (let i = 0; i < 8; i++)
242
+ this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));
243
+ for (let i = 8; i < 15; i++)
244
+ this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
245
+ this.setFunctionModule(8, this.size - 8, true);
246
+ }
247
+ // Draws two copies of the version bits (with its own error correction code),
248
+ // based on this object's version field, iff 7 <= version <= 40.
249
+ drawVersion() {
250
+ if (this.version < 7)
251
+ return;
252
+ let rem = this.version;
253
+ for (let i = 0; i < 12; i++)
254
+ rem = rem << 1 ^ (rem >>> 11) * 7973;
255
+ const bits = this.version << 12 | rem;
256
+ assert(bits >>> 18 == 0);
257
+ for (let i = 0; i < 18; i++) {
258
+ const color = getBit(bits, i);
259
+ const a = this.size - 11 + i % 3;
260
+ const b = Math.floor(i / 3);
261
+ this.setFunctionModule(a, b, color);
262
+ this.setFunctionModule(b, a, color);
263
+ }
264
+ }
265
+ // Draws a 9*9 finder pattern including the border separator,
266
+ // with the center module at (x, y). Modules can be out of bounds.
267
+ drawFinderPattern(x, y) {
268
+ for (let dy = -4; dy <= 4; dy++) {
269
+ for (let dx = -4; dx <= 4; dx++) {
270
+ const dist = Math.max(Math.abs(dx), Math.abs(dy));
271
+ const xx = x + dx;
272
+ const yy = y + dy;
273
+ if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)
274
+ this.setFunctionModule(xx, yy, dist != 2 && dist != 4);
275
+ }
276
+ }
277
+ }
278
+ // Draws a 5*5 alignment pattern, with the center module
279
+ // at (x, y). All modules must be in bounds.
280
+ drawAlignmentPattern(x, y) {
281
+ for (let dy = -2; dy <= 2; dy++) {
282
+ for (let dx = -2; dx <= 2; dx++)
283
+ this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
284
+ }
285
+ }
286
+ // Sets the color of a module and marks it as a function module.
287
+ // Only used by the constructor. Coordinates must be in bounds.
288
+ setFunctionModule(x, y, isDark) {
289
+ this.modules[y][x] = isDark;
290
+ this.isFunction[y][x] = true;
291
+ }
292
+ /*-- Private helper methods for constructor: Codewords and masking --*/
293
+ // Returns a new byte string representing the given data with the appropriate error correction
294
+ // codewords appended to it, based on this object's version and error correction level.
295
+ addEccAndInterleave(data) {
296
+ const ver = this.version;
297
+ const ecl = this.errorCorrectionLevel;
298
+ if (data.length != _QrCode2.getNumDataCodewords(ver, ecl))
299
+ throw new RangeError("Invalid argument");
300
+ const numBlocks = _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
301
+ const blockEccLen = _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
302
+ const rawCodewords = Math.floor(_QrCode2.getNumRawDataModules(ver) / 8);
303
+ const numShortBlocks = numBlocks - rawCodewords % numBlocks;
304
+ const shortBlockLen = Math.floor(rawCodewords / numBlocks);
305
+ let blocks = [];
306
+ const rsDiv = _QrCode2.reedSolomonComputeDivisor(blockEccLen);
307
+ for (let i = 0, k = 0; i < numBlocks; i++) {
308
+ let dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
309
+ k += dat.length;
310
+ const ecc = _QrCode2.reedSolomonComputeRemainder(dat, rsDiv);
311
+ if (i < numShortBlocks)
312
+ dat.push(0);
313
+ blocks.push(dat.concat(ecc));
314
+ }
315
+ let result = [];
316
+ for (let i = 0; i < blocks[0].length; i++) {
317
+ blocks.forEach((block, j) => {
318
+ if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)
319
+ result.push(block[i]);
320
+ });
321
+ }
322
+ assert(result.length == rawCodewords);
323
+ return result;
324
+ }
325
+ // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
326
+ // data area of this QR Code. Function modules need to be marked off before this is called.
327
+ drawCodewords(data) {
328
+ if (data.length != Math.floor(_QrCode2.getNumRawDataModules(this.version) / 8))
329
+ throw new RangeError("Invalid argument");
330
+ let i = 0;
331
+ for (let right = this.size - 1; right >= 1; right -= 2) {
332
+ if (right == 6)
333
+ right = 5;
334
+ for (let vert = 0; vert < this.size; vert++) {
335
+ for (let j = 0; j < 2; j++) {
336
+ const x = right - j;
337
+ const upward = (right + 1 & 2) == 0;
338
+ const y = upward ? this.size - 1 - vert : vert;
339
+ if (!this.isFunction[y][x] && i < data.length * 8) {
340
+ this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
341
+ i++;
342
+ }
343
+ }
344
+ }
345
+ }
346
+ assert(i == data.length * 8);
347
+ }
348
+ // XORs the codeword modules in this QR Code with the given mask pattern.
349
+ // The function modules must be marked and the codeword bits must be drawn
350
+ // before masking. Due to the arithmetic of XOR, calling applyMask() with
351
+ // the same mask value a second time will undo the mask. A final well-formed
352
+ // QR Code needs exactly one (not zero, two, etc.) mask applied.
353
+ applyMask(mask) {
354
+ if (mask < 0 || mask > 7)
355
+ throw new RangeError("Mask value out of range");
356
+ for (let y = 0; y < this.size; y++) {
357
+ for (let x = 0; x < this.size; x++) {
358
+ let invert;
359
+ switch (mask) {
360
+ case 0:
361
+ invert = (x + y) % 2 == 0;
362
+ break;
363
+ case 1:
364
+ invert = y % 2 == 0;
365
+ break;
366
+ case 2:
367
+ invert = x % 3 == 0;
368
+ break;
369
+ case 3:
370
+ invert = (x + y) % 3 == 0;
371
+ break;
372
+ case 4:
373
+ invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0;
374
+ break;
375
+ case 5:
376
+ invert = x * y % 2 + x * y % 3 == 0;
377
+ break;
378
+ case 6:
379
+ invert = (x * y % 2 + x * y % 3) % 2 == 0;
380
+ break;
381
+ case 7:
382
+ invert = ((x + y) % 2 + x * y % 3) % 2 == 0;
383
+ break;
384
+ default:
385
+ throw new Error("Unreachable");
386
+ }
387
+ if (!this.isFunction[y][x] && invert)
388
+ this.modules[y][x] = !this.modules[y][x];
389
+ }
390
+ }
391
+ }
392
+ // Calculates and returns the penalty score based on state of this QR Code's current modules.
393
+ // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
394
+ getPenaltyScore() {
395
+ let result = 0;
396
+ for (let y = 0; y < this.size; y++) {
397
+ let runColor = false;
398
+ let runX = 0;
399
+ let runHistory = [0, 0, 0, 0, 0, 0, 0];
400
+ for (let x = 0; x < this.size; x++) {
401
+ if (this.modules[y][x] == runColor) {
402
+ runX++;
403
+ if (runX == 5)
404
+ result += _QrCode2.PENALTY_N1;
405
+ else if (runX > 5)
406
+ result++;
407
+ } else {
408
+ this.finderPenaltyAddHistory(runX, runHistory);
409
+ if (!runColor)
410
+ result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3;
411
+ runColor = this.modules[y][x];
412
+ runX = 1;
413
+ }
414
+ }
415
+ result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode2.PENALTY_N3;
416
+ }
417
+ for (let x = 0; x < this.size; x++) {
418
+ let runColor = false;
419
+ let runY = 0;
420
+ let runHistory = [0, 0, 0, 0, 0, 0, 0];
421
+ for (let y = 0; y < this.size; y++) {
422
+ if (this.modules[y][x] == runColor) {
423
+ runY++;
424
+ if (runY == 5)
425
+ result += _QrCode2.PENALTY_N1;
426
+ else if (runY > 5)
427
+ result++;
428
+ } else {
429
+ this.finderPenaltyAddHistory(runY, runHistory);
430
+ if (!runColor)
431
+ result += this.finderPenaltyCountPatterns(runHistory) * _QrCode2.PENALTY_N3;
432
+ runColor = this.modules[y][x];
433
+ runY = 1;
434
+ }
435
+ }
436
+ result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode2.PENALTY_N3;
437
+ }
438
+ for (let y = 0; y < this.size - 1; y++) {
439
+ for (let x = 0; x < this.size - 1; x++) {
440
+ const color = this.modules[y][x];
441
+ if (color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1])
442
+ result += _QrCode2.PENALTY_N2;
443
+ }
444
+ }
445
+ let dark = 0;
446
+ for (const row of this.modules)
447
+ dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);
448
+ const total = this.size * this.size;
449
+ const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
450
+ assert(0 <= k && k <= 9);
451
+ result += k * _QrCode2.PENALTY_N4;
452
+ assert(0 <= result && result <= 2568888);
453
+ return result;
454
+ }
455
+ /*-- Private helper functions --*/
456
+ // Returns an ascending list of positions of alignment patterns for this version number.
457
+ // Each position is in the range [0,177), and are used on both the x and y axes.
458
+ // This could be implemented as lookup table of 40 variable-length lists of integers.
459
+ getAlignmentPatternPositions() {
460
+ if (this.version == 1)
461
+ return [];
462
+ else {
463
+ const numAlign = Math.floor(this.version / 7) + 2;
464
+ const step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
465
+ let result = [6];
466
+ for (let pos = this.size - 7; result.length < numAlign; pos -= step)
467
+ result.splice(1, 0, pos);
468
+ return result;
469
+ }
470
+ }
471
+ // Returns the number of data bits that can be stored in a QR Code of the given version number, after
472
+ // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
473
+ // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
474
+ static getNumRawDataModules(ver) {
475
+ if (ver < _QrCode2.MIN_VERSION || ver > _QrCode2.MAX_VERSION)
476
+ throw new RangeError("Version number out of range");
477
+ let result = (16 * ver + 128) * ver + 64;
478
+ if (ver >= 2) {
479
+ const numAlign = Math.floor(ver / 7) + 2;
480
+ result -= (25 * numAlign - 10) * numAlign - 55;
481
+ if (ver >= 7)
482
+ result -= 36;
483
+ }
484
+ assert(208 <= result && result <= 29648);
485
+ return result;
486
+ }
487
+ // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
488
+ // QR Code of the given version number and error correction level, with remainder bits discarded.
489
+ // This stateless pure function could be implemented as a (40*4)-cell lookup table.
490
+ static getNumDataCodewords(ver, ecl) {
491
+ return Math.floor(_QrCode2.getNumRawDataModules(ver) / 8) - _QrCode2.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode2.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
492
+ }
493
+ // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
494
+ // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
495
+ static reedSolomonComputeDivisor(degree) {
496
+ if (degree < 1 || degree > 255)
497
+ throw new RangeError("Degree out of range");
498
+ let result = [];
499
+ for (let i = 0; i < degree - 1; i++)
500
+ result.push(0);
501
+ result.push(1);
502
+ let root = 1;
503
+ for (let i = 0; i < degree; i++) {
504
+ for (let j = 0; j < result.length; j++) {
505
+ result[j] = _QrCode2.reedSolomonMultiply(result[j], root);
506
+ if (j + 1 < result.length)
507
+ result[j] ^= result[j + 1];
508
+ }
509
+ root = _QrCode2.reedSolomonMultiply(root, 2);
510
+ }
511
+ return result;
512
+ }
513
+ // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
514
+ static reedSolomonComputeRemainder(data, divisor) {
515
+ let result = divisor.map((_) => 0);
516
+ for (const b of data) {
517
+ const factor = b ^ result.shift();
518
+ result.push(0);
519
+ divisor.forEach((coef, i) => result[i] ^= _QrCode2.reedSolomonMultiply(coef, factor));
520
+ }
521
+ return result;
522
+ }
523
+ // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
524
+ // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
525
+ static reedSolomonMultiply(x, y) {
526
+ if (x >>> 8 != 0 || y >>> 8 != 0)
527
+ throw new RangeError("Byte out of range");
528
+ let z = 0;
529
+ for (let i = 7; i >= 0; i--) {
530
+ z = z << 1 ^ (z >>> 7) * 285;
531
+ z ^= (y >>> i & 1) * x;
532
+ }
533
+ assert(z >>> 8 == 0);
534
+ return z;
535
+ }
536
+ // Can only be called immediately after a light run is added, and
537
+ // returns either 0, 1, or 2. A helper function for getPenaltyScore().
538
+ finderPenaltyCountPatterns(runHistory) {
539
+ const n = runHistory[1];
540
+ assert(n <= this.size * 3);
541
+ const core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;
542
+ return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
543
+ }
544
+ // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
545
+ finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
546
+ if (currentRunColor) {
547
+ this.finderPenaltyAddHistory(currentRunLength, runHistory);
548
+ currentRunLength = 0;
549
+ }
550
+ currentRunLength += this.size;
551
+ this.finderPenaltyAddHistory(currentRunLength, runHistory);
552
+ return this.finderPenaltyCountPatterns(runHistory);
553
+ }
554
+ // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
555
+ finderPenaltyAddHistory(currentRunLength, runHistory) {
556
+ if (runHistory[0] == 0)
557
+ currentRunLength += this.size;
558
+ runHistory.pop();
559
+ runHistory.unshift(currentRunLength);
560
+ }
561
+ };
562
+ _QrCode.MIN_VERSION = 1;
563
+ _QrCode.MAX_VERSION = 40;
564
+ _QrCode.PENALTY_N1 = 3;
565
+ _QrCode.PENALTY_N2 = 3;
566
+ _QrCode.PENALTY_N3 = 40;
567
+ _QrCode.PENALTY_N4 = 10;
568
+ _QrCode.ECC_CODEWORDS_PER_BLOCK = [
569
+ // Version: (note that index 0 is for padding, and is set to an illegal value)
570
+ //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
571
+ [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
572
+ // Low
573
+ [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
574
+ // Medium
575
+ [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
576
+ // Quartile
577
+ [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
578
+ // High
579
+ ];
580
+ _QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
581
+ // Version: (note that index 0 is for padding, and is set to an illegal value)
582
+ //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
583
+ [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
584
+ // Low
585
+ [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
586
+ // Medium
587
+ [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
588
+ // Quartile
589
+ [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
590
+ // High
591
+ ];
592
+ let QrCode = _QrCode;
593
+ qrcodegen2.QrCode = _QrCode;
594
+ function appendBits(val, len, bb) {
595
+ if (len < 0 || len > 31 || val >>> len != 0)
596
+ throw new RangeError("Value out of range");
597
+ for (let i = len - 1; i >= 0; i--)
598
+ bb.push(val >>> i & 1);
599
+ }
600
+ function getBit(x, i) {
601
+ return (x >>> i & 1) != 0;
602
+ }
603
+ function assert(cond) {
604
+ if (!cond)
605
+ throw new Error("Assertion error");
606
+ }
607
+ const _QrSegment = class _QrSegment2 {
608
+ /*-- Constructor (low level) and fields --*/
609
+ // Creates a new QR Code segment with the given attributes and data.
610
+ // The character count (numChars) must agree with the mode and the bit buffer length,
611
+ // but the constraint isn't checked. The given bit buffer is cloned and stored.
612
+ constructor(mode, numChars, bitData) {
613
+ this.mode = mode;
614
+ this.numChars = numChars;
615
+ this.bitData = bitData;
616
+ if (numChars < 0)
617
+ throw new RangeError("Invalid argument");
618
+ this.bitData = bitData.slice();
619
+ }
620
+ /*-- Static factory functions (mid level) --*/
621
+ // Returns a segment representing the given binary data encoded in
622
+ // byte mode. All input byte arrays are acceptable. Any text string
623
+ // can be converted to UTF-8 bytes and encoded as a byte mode segment.
624
+ static makeBytes(data) {
625
+ let bb = [];
626
+ for (const b of data)
627
+ appendBits(b, 8, bb);
628
+ return new _QrSegment2(_QrSegment2.Mode.BYTE, data.length, bb);
629
+ }
630
+ // Returns a segment representing the given string of decimal digits encoded in numeric mode.
631
+ static makeNumeric(digits) {
632
+ if (!_QrSegment2.isNumeric(digits))
633
+ throw new RangeError("String contains non-numeric characters");
634
+ let bb = [];
635
+ for (let i = 0; i < digits.length; ) {
636
+ const n = Math.min(digits.length - i, 3);
637
+ appendBits(parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);
638
+ i += n;
639
+ }
640
+ return new _QrSegment2(_QrSegment2.Mode.NUMERIC, digits.length, bb);
641
+ }
642
+ // Returns a segment representing the given text string encoded in alphanumeric mode.
643
+ // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
644
+ // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
645
+ static makeAlphanumeric(text) {
646
+ if (!_QrSegment2.isAlphanumeric(text))
647
+ throw new RangeError("String contains unencodable characters in alphanumeric mode");
648
+ let bb = [];
649
+ let i;
650
+ for (i = 0; i + 2 <= text.length; i += 2) {
651
+ let temp = _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
652
+ temp += _QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
653
+ appendBits(temp, 11, bb);
654
+ }
655
+ if (i < text.length)
656
+ appendBits(_QrSegment2.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
657
+ return new _QrSegment2(_QrSegment2.Mode.ALPHANUMERIC, text.length, bb);
658
+ }
659
+ // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
660
+ // The result may use various segment modes and switch modes to optimize the length of the bit stream.
661
+ static makeSegments(text) {
662
+ if (text == "")
663
+ return [];
664
+ else if (_QrSegment2.isNumeric(text))
665
+ return [_QrSegment2.makeNumeric(text)];
666
+ else if (_QrSegment2.isAlphanumeric(text))
667
+ return [_QrSegment2.makeAlphanumeric(text)];
668
+ else
669
+ return [_QrSegment2.makeBytes(_QrSegment2.toUtf8ByteArray(text))];
670
+ }
671
+ // Returns a segment representing an Extended Channel Interpretation
672
+ // (ECI) designator with the given assignment value.
673
+ static makeEci(assignVal) {
674
+ let bb = [];
675
+ if (assignVal < 0)
676
+ throw new RangeError("ECI assignment value out of range");
677
+ else if (assignVal < 1 << 7)
678
+ appendBits(assignVal, 8, bb);
679
+ else if (assignVal < 1 << 14) {
680
+ appendBits(2, 2, bb);
681
+ appendBits(assignVal, 14, bb);
682
+ } else if (assignVal < 1e6) {
683
+ appendBits(6, 3, bb);
684
+ appendBits(assignVal, 21, bb);
685
+ } else
686
+ throw new RangeError("ECI assignment value out of range");
687
+ return new _QrSegment2(_QrSegment2.Mode.ECI, 0, bb);
688
+ }
689
+ // Tests whether the given string can be encoded as a segment in numeric mode.
690
+ // A string is encodable iff each character is in the range 0 to 9.
691
+ static isNumeric(text) {
692
+ return _QrSegment2.NUMERIC_REGEX.test(text);
693
+ }
694
+ // Tests whether the given string can be encoded as a segment in alphanumeric mode.
695
+ // A string is encodable iff each character is in the following set: 0 to 9, A to Z
696
+ // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
697
+ static isAlphanumeric(text) {
698
+ return _QrSegment2.ALPHANUMERIC_REGEX.test(text);
699
+ }
700
+ /*-- Methods --*/
701
+ // Returns a new copy of the data bits of this segment.
702
+ getData() {
703
+ return this.bitData.slice();
704
+ }
705
+ // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
706
+ // the given version. The result is infinity if a segment has too many characters to fit its length field.
707
+ static getTotalBits(segs, version) {
708
+ let result = 0;
709
+ for (const seg of segs) {
710
+ const ccbits = seg.mode.numCharCountBits(version);
711
+ if (seg.numChars >= 1 << ccbits)
712
+ return Infinity;
713
+ result += 4 + ccbits + seg.bitData.length;
714
+ }
715
+ return result;
716
+ }
717
+ // Returns a new array of bytes representing the given string encoded in UTF-8.
718
+ static toUtf8ByteArray(str) {
719
+ str = encodeURI(str);
720
+ let result = [];
721
+ for (let i = 0; i < str.length; i++) {
722
+ if (str.charAt(i) != "%")
723
+ result.push(str.charCodeAt(i));
724
+ else {
725
+ result.push(parseInt(str.substring(i + 1, i + 3), 16));
726
+ i += 2;
727
+ }
728
+ }
729
+ return result;
730
+ }
731
+ };
732
+ _QrSegment.NUMERIC_REGEX = /^[0-9]*$/;
733
+ _QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/;
734
+ _QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
735
+ let QrSegment = _QrSegment;
736
+ qrcodegen2.QrSegment = _QrSegment;
737
+ })(qrcodegen || (qrcodegen = {}));
738
+ ((qrcodegen2) => {
739
+ let QrCode;
740
+ ((QrCode2) => {
741
+ const _Ecc = class _Ecc {
742
+ // The QR Code can tolerate about 30% erroneous codewords
743
+ /*-- Constructor and fields --*/
744
+ constructor(ordinal, formatBits) {
745
+ this.ordinal = ordinal;
746
+ this.formatBits = formatBits;
747
+ }
748
+ };
749
+ _Ecc.LOW = new _Ecc(0, 1);
750
+ _Ecc.MEDIUM = new _Ecc(1, 0);
751
+ _Ecc.QUARTILE = new _Ecc(2, 3);
752
+ _Ecc.HIGH = new _Ecc(3, 2);
753
+ let Ecc = _Ecc;
754
+ QrCode2.Ecc = _Ecc;
755
+ })(QrCode = qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));
756
+ })(qrcodegen || (qrcodegen = {}));
757
+ ((qrcodegen2) => {
758
+ let QrSegment;
759
+ ((QrSegment2) => {
760
+ const _Mode = class _Mode {
761
+ /*-- Constructor and fields --*/
762
+ constructor(modeBits, numBitsCharCount) {
763
+ this.modeBits = modeBits;
764
+ this.numBitsCharCount = numBitsCharCount;
765
+ }
766
+ /*-- Method --*/
767
+ // (Package-private) Returns the bit width of the character count field for a segment in
768
+ // this mode in a QR Code at the given version number. The result is in the range [0, 16].
769
+ numCharCountBits(ver) {
770
+ return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
771
+ }
772
+ };
773
+ _Mode.NUMERIC = new _Mode(1, [10, 12, 14]);
774
+ _Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]);
775
+ _Mode.BYTE = new _Mode(4, [8, 16, 16]);
776
+ _Mode.KANJI = new _Mode(8, [8, 10, 12]);
777
+ _Mode.ECI = new _Mode(7, [0, 0, 0]);
778
+ let Mode = _Mode;
779
+ QrSegment2.Mode = _Mode;
780
+ })(QrSegment = qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));
781
+ })(qrcodegen || (qrcodegen = {}));
782
+ var qrcodegen_default = qrcodegen;
783
+ var ERROR_LEVEL_MAP = {
784
+ L: qrcodegen_default.QrCode.Ecc.LOW,
785
+ M: qrcodegen_default.QrCode.Ecc.MEDIUM,
786
+ Q: qrcodegen_default.QrCode.Ecc.QUARTILE,
787
+ H: qrcodegen_default.QrCode.Ecc.HIGH
788
+ };
789
+ var DEFAULT_SIZE = 128;
790
+ var DEFAULT_LEVEL = "L";
791
+ var DEFAULT_BGCOLOR = "#FFFFFF";
792
+ var DEFAULT_FGCOLOR = "#000000";
793
+ var DEFAULT_INCLUDEMARGIN = false;
794
+ var DEFAULT_MINVERSION = 1;
795
+ var SPEC_MARGIN_SIZE = 4;
796
+ var DEFAULT_MARGIN_SIZE = 0;
797
+ var DEFAULT_IMG_SCALE = 0.1;
798
+ function generatePath(modules, margin = 0) {
799
+ const ops = [];
800
+ modules.forEach(function(row, y) {
801
+ let start = null;
802
+ row.forEach(function(cell, x) {
803
+ if (!cell && start !== null) {
804
+ ops.push(
805
+ `M${start + margin} ${y + margin}h${x - start}v1H${start + margin}z`
806
+ );
807
+ start = null;
808
+ return;
809
+ }
810
+ if (x === row.length - 1) {
811
+ if (!cell) {
812
+ return;
813
+ }
814
+ if (start === null) {
815
+ ops.push(`M${x + margin},${y + margin} h1v1H${x + margin}z`);
816
+ } else {
817
+ ops.push(
818
+ `M${start + margin},${y + margin} h${x + 1 - start}v1H${start + margin}z`
819
+ );
820
+ }
821
+ return;
822
+ }
823
+ if (cell && start === null) {
824
+ start = x;
825
+ }
826
+ });
827
+ });
828
+ return ops.join("");
829
+ }
830
+ function excavateModules(modules, excavation) {
831
+ return modules.slice().map((row, y) => {
832
+ if (y < excavation.y || y >= excavation.y + excavation.h) {
833
+ return row;
834
+ }
835
+ return row.map((cell, x) => {
836
+ if (x < excavation.x || x >= excavation.x + excavation.w) {
837
+ return cell;
838
+ }
839
+ return false;
840
+ });
841
+ });
842
+ }
843
+ function getImageSettings(cells, size, margin, imageSettings) {
844
+ if (imageSettings == null) {
845
+ return null;
846
+ }
847
+ const numCells = cells.length + margin * 2;
848
+ const defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);
849
+ const scale = numCells / size;
850
+ const w = (imageSettings.width || defaultSize) * scale;
851
+ const h = (imageSettings.height || defaultSize) * scale;
852
+ const x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;
853
+ const y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;
854
+ const opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;
855
+ let excavation = null;
856
+ if (imageSettings.excavate) {
857
+ let floorX = Math.floor(x);
858
+ let floorY = Math.floor(y);
859
+ let ceilW = Math.ceil(w + x - floorX);
860
+ let ceilH = Math.ceil(h + y - floorY);
861
+ excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
862
+ }
863
+ const crossOrigin = imageSettings.crossOrigin;
864
+ return { x, y, h, w, excavation, opacity, crossOrigin };
865
+ }
866
+ function getMarginSize(includeMargin, marginSize) {
867
+ if (marginSize != null) {
868
+ return Math.max(Math.floor(marginSize), 0);
869
+ }
870
+ return includeMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;
871
+ }
872
+ function useQRCode({
873
+ value,
874
+ level,
875
+ minVersion,
876
+ includeMargin,
877
+ marginSize,
878
+ imageSettings,
879
+ size,
880
+ boostLevel
881
+ }) {
882
+ let qrcode = React.useMemo(() => {
883
+ const values = Array.isArray(value) ? value : [value];
884
+ const segments = values.reduce((accum, v) => {
885
+ accum.push(...qrcodegen_default.QrSegment.makeSegments(v));
886
+ return accum;
887
+ }, []);
888
+ return qrcodegen_default.QrCode.encodeSegments(
889
+ segments,
890
+ ERROR_LEVEL_MAP[level],
891
+ minVersion,
892
+ void 0,
893
+ void 0,
894
+ boostLevel
895
+ );
896
+ }, [value, level, minVersion, boostLevel]);
897
+ const { cells, margin, numCells, calculatedImageSettings } = React.useMemo(() => {
898
+ let cells2 = qrcode.getModules();
899
+ const margin2 = getMarginSize(includeMargin, marginSize);
900
+ const numCells2 = cells2.length + margin2 * 2;
901
+ const calculatedImageSettings2 = getImageSettings(
902
+ cells2,
903
+ size,
904
+ margin2,
905
+ imageSettings
906
+ );
907
+ return {
908
+ cells: cells2,
909
+ margin: margin2,
910
+ numCells: numCells2,
911
+ calculatedImageSettings: calculatedImageSettings2
912
+ };
913
+ }, [qrcode, size, imageSettings, includeMargin, marginSize]);
914
+ return {
915
+ qrcode,
916
+ margin,
917
+ cells,
918
+ numCells,
919
+ calculatedImageSettings
920
+ };
921
+ }
922
+ var SUPPORTS_PATH2D = (function() {
923
+ try {
924
+ new Path2D().addPath(new Path2D());
925
+ } catch (e) {
926
+ return false;
927
+ }
928
+ return true;
929
+ })();
930
+ var QRCodeCanvas = React.forwardRef(
931
+ function QRCodeCanvas2(props, forwardedRef) {
932
+ const _a = props, {
933
+ value,
934
+ size = DEFAULT_SIZE,
935
+ level = DEFAULT_LEVEL,
936
+ bgColor = DEFAULT_BGCOLOR,
937
+ fgColor = DEFAULT_FGCOLOR,
938
+ includeMargin = DEFAULT_INCLUDEMARGIN,
939
+ minVersion = DEFAULT_MINVERSION,
940
+ boostLevel,
941
+ marginSize,
942
+ imageSettings
943
+ } = _a, extraProps = __objRest(_a, [
944
+ "value",
945
+ "size",
946
+ "level",
947
+ "bgColor",
948
+ "fgColor",
949
+ "includeMargin",
950
+ "minVersion",
951
+ "boostLevel",
952
+ "marginSize",
953
+ "imageSettings"
954
+ ]);
955
+ const _b = extraProps, { style } = _b, otherProps = __objRest(_b, ["style"]);
956
+ const imgSrc = imageSettings == null ? void 0 : imageSettings.src;
957
+ const _canvas = React.useRef(null);
958
+ const _image = React.useRef(null);
959
+ const setCanvasRef = React.useCallback(
960
+ (node) => {
961
+ _canvas.current = node;
962
+ if (typeof forwardedRef === "function") {
963
+ forwardedRef(node);
964
+ } else if (forwardedRef) {
965
+ forwardedRef.current = node;
966
+ }
967
+ },
968
+ [forwardedRef]
969
+ );
970
+ const [isImgLoaded, setIsImageLoaded] = React.useState(false);
971
+ const { margin, cells, numCells, calculatedImageSettings } = useQRCode({
972
+ value,
973
+ level,
974
+ minVersion,
975
+ boostLevel,
976
+ includeMargin,
977
+ marginSize,
978
+ imageSettings,
979
+ size
980
+ });
981
+ React.useEffect(() => {
982
+ if (_canvas.current != null) {
983
+ const canvas = _canvas.current;
984
+ const ctx = canvas.getContext("2d");
985
+ if (!ctx) {
986
+ return;
987
+ }
988
+ let cellsToDraw = cells;
989
+ const image = _image.current;
990
+ const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
991
+ if (haveImageToRender) {
992
+ if (calculatedImageSettings.excavation != null) {
993
+ cellsToDraw = excavateModules(
994
+ cells,
995
+ calculatedImageSettings.excavation
996
+ );
997
+ }
998
+ }
999
+ const pixelRatio = window.devicePixelRatio || 1;
1000
+ canvas.height = canvas.width = size * pixelRatio;
1001
+ const scale = size / numCells * pixelRatio;
1002
+ ctx.scale(scale, scale);
1003
+ ctx.fillStyle = bgColor;
1004
+ ctx.fillRect(0, 0, numCells, numCells);
1005
+ ctx.fillStyle = fgColor;
1006
+ if (SUPPORTS_PATH2D) {
1007
+ ctx.fill(new Path2D(generatePath(cellsToDraw, margin)));
1008
+ } else {
1009
+ cells.forEach(function(row, rdx) {
1010
+ row.forEach(function(cell, cdx) {
1011
+ if (cell) {
1012
+ ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
1013
+ }
1014
+ });
1015
+ });
1016
+ }
1017
+ if (calculatedImageSettings) {
1018
+ ctx.globalAlpha = calculatedImageSettings.opacity;
1019
+ }
1020
+ if (haveImageToRender) {
1021
+ ctx.drawImage(
1022
+ image,
1023
+ calculatedImageSettings.x + margin,
1024
+ calculatedImageSettings.y + margin,
1025
+ calculatedImageSettings.w,
1026
+ calculatedImageSettings.h
1027
+ );
1028
+ }
1029
+ }
1030
+ });
1031
+ React.useEffect(() => {
1032
+ setIsImageLoaded(false);
1033
+ }, [imgSrc]);
1034
+ const canvasStyle = __spreadValues({ height: size, width: size }, style);
1035
+ let img = null;
1036
+ if (imgSrc != null) {
1037
+ img = /* @__PURE__ */ React.createElement(
1038
+ "img",
1039
+ {
1040
+ src: imgSrc,
1041
+ key: imgSrc,
1042
+ style: { display: "none" },
1043
+ onLoad: () => {
1044
+ setIsImageLoaded(true);
1045
+ },
1046
+ ref: _image,
1047
+ crossOrigin: calculatedImageSettings == null ? void 0 : calculatedImageSettings.crossOrigin
1048
+ }
1049
+ );
1050
+ }
1051
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
1052
+ "canvas",
1053
+ __spreadValues({
1054
+ style: canvasStyle,
1055
+ height: size,
1056
+ width: size,
1057
+ ref: setCanvasRef,
1058
+ role: "img"
1059
+ }, otherProps)
1060
+ ), img);
1061
+ }
1062
+ );
1063
+ QRCodeCanvas.displayName = "QRCodeCanvas";
1064
+ var QRCodeSVG = React.forwardRef(
1065
+ function QRCodeSVG2(props, forwardedRef) {
1066
+ const _a = props, {
1067
+ value,
1068
+ size = DEFAULT_SIZE,
1069
+ level = DEFAULT_LEVEL,
1070
+ bgColor = DEFAULT_BGCOLOR,
1071
+ fgColor = DEFAULT_FGCOLOR,
1072
+ includeMargin = DEFAULT_INCLUDEMARGIN,
1073
+ minVersion = DEFAULT_MINVERSION,
1074
+ boostLevel,
1075
+ title,
1076
+ marginSize,
1077
+ imageSettings
1078
+ } = _a, otherProps = __objRest(_a, [
1079
+ "value",
1080
+ "size",
1081
+ "level",
1082
+ "bgColor",
1083
+ "fgColor",
1084
+ "includeMargin",
1085
+ "minVersion",
1086
+ "boostLevel",
1087
+ "title",
1088
+ "marginSize",
1089
+ "imageSettings"
1090
+ ]);
1091
+ const { margin, cells, numCells, calculatedImageSettings } = useQRCode({
1092
+ value,
1093
+ level,
1094
+ minVersion,
1095
+ boostLevel,
1096
+ includeMargin,
1097
+ marginSize,
1098
+ imageSettings,
1099
+ size
1100
+ });
1101
+ let cellsToDraw = cells;
1102
+ let image = null;
1103
+ if (imageSettings != null && calculatedImageSettings != null) {
1104
+ if (calculatedImageSettings.excavation != null) {
1105
+ cellsToDraw = excavateModules(
1106
+ cells,
1107
+ calculatedImageSettings.excavation
1108
+ );
1109
+ }
1110
+ image = /* @__PURE__ */ React.createElement(
1111
+ "image",
1112
+ {
1113
+ href: imageSettings.src,
1114
+ height: calculatedImageSettings.h,
1115
+ width: calculatedImageSettings.w,
1116
+ x: calculatedImageSettings.x + margin,
1117
+ y: calculatedImageSettings.y + margin,
1118
+ preserveAspectRatio: "none",
1119
+ opacity: calculatedImageSettings.opacity,
1120
+ crossOrigin: calculatedImageSettings.crossOrigin
1121
+ }
1122
+ );
1123
+ }
1124
+ const fgPath = generatePath(cellsToDraw, margin);
1125
+ return /* @__PURE__ */ React.createElement(
1126
+ "svg",
1127
+ __spreadValues({
1128
+ height: size,
1129
+ width: size,
1130
+ viewBox: `0 0 ${numCells} ${numCells}`,
1131
+ ref: forwardedRef,
1132
+ role: "img"
1133
+ }, otherProps),
1134
+ !!title && /* @__PURE__ */ React.createElement("title", null, title),
1135
+ /* @__PURE__ */ React.createElement(
1136
+ "path",
1137
+ {
1138
+ fill: bgColor,
1139
+ d: `M0,0 h${numCells}v${numCells}H0z`,
1140
+ shapeRendering: "crispEdges"
1141
+ }
1142
+ ),
1143
+ /* @__PURE__ */ React.createElement("path", { fill: fgColor, d: fgPath, shapeRendering: "crispEdges" }),
1144
+ image
1145
+ );
1146
+ }
1147
+ );
1148
+ QRCodeSVG.displayName = "QRCodeSVG";
1149
+
1150
+ // src/components/FeishuCapabilitySelection.tsx
1151
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
1152
+ var capabilityStatus = {
1153
+ available: "\u53EF\u4F7F\u7528",
1154
+ not_selected: "\u5C1A\u672A\u5F00\u901A",
1155
+ permission_required: "\u5F85\u5E94\u7528\u5F00\u901A",
1156
+ user_auth_required: "\u5F85\u672C\u4EBA\u6388\u6743",
1157
+ app_required: "\u5F85\u5173\u8054\u5E94\u7528",
1158
+ unsupported: "\u6682\u672A\u652F\u6301",
1159
+ unknown: "\u5F85\u6838\u9A8C",
1160
+ temporarily_unavailable: "\u6682\u65F6\u4E0D\u53EF\u7528"
1161
+ };
1162
+ function selectableCapabilities(capabilities) {
1163
+ return capabilities.filter((item) => item.status !== "unsupported" && item.executable === true && item.id !== "user_send" && !item.scopes.includes("im:message.send_as_user"));
1164
+ }
1165
+ function defaultCapabilities(capabilities) {
1166
+ return selectableCapabilities(capabilities).map((item) => item.id);
1167
+ }
1168
+ function FeishuCapabilitySelection({ capabilities, permissions = [], domains = [] }) {
1169
+ const groups = /* @__PURE__ */ new Map();
1170
+ for (const item of selectableCapabilities(capabilities)) {
1171
+ const key = item.category || "other";
1172
+ groups.set(key, [...groups.get(key) ?? [], item]);
1173
+ }
1174
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
1175
+ /* @__PURE__ */ jsx2("p", { className: "text-sm", children: "\u521D\u6B21\u8FDE\u63A5\u91C7\u7528\u98DE\u4E66\u5E73\u53F0\u9ED8\u8BA4\u6A21\u677F\u53CA\u5B98\u65B9\u63A8\u8350\u6743\u9650\u3002\u5728\u98DE\u4E66\u9875\u9762\u786E\u8BA4\uFF0C\u514D\u5BA1\u548C\u5BA1\u6838\u8981\u6C42\u4EE5\u6240\u5728\u4F01\u4E1A\u89C4\u5219\u4E3A\u51C6\u3002" }),
1176
+ /* @__PURE__ */ jsx2("p", { className: "text-xs opacity-70", children: "\u9996\u6B21\u53EF\u80FD\u9700\u8981\u4E24\u6B21\u626B\u7801\uFF1A\u5148\u5173\u8054\u5E94\u7528\uFF0C\u518D\u786E\u8BA4\u672C\u4EBA\u6388\u6743\u3002\u90E8\u5206\u6743\u9650\u672A\u5F00\u901A\u65F6\uFF0C\u5DF2\u5F00\u901A\u6743\u9650\u4ECD\u53EF\u4F7F\u7528\u3002" }),
1177
+ /* @__PURE__ */ jsxs("details", { className: "rounded-xl border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-4 text-sm", children: [
1178
+ /* @__PURE__ */ jsx2("summary", { className: "cursor-pointer", children: "\u67E5\u770B\u5F53\u524D\u53EF\u7528\u7684\u5DE5\u4F5C\u80FD\u529B" }),
1179
+ /* @__PURE__ */ jsx2("div", { className: "mt-3 grid gap-3 sm:grid-cols-2", children: [...groups].map(([id, items]) => /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
1180
+ /* @__PURE__ */ jsx2("h4", { className: "font-medium", children: domains.find((domain) => domain.id === id)?.name || items[0]?.category_name || "\u5176\u4ED6\u5DE5\u4F5C\u80FD\u529B" }),
1181
+ items.map((item) => /* @__PURE__ */ jsxs("details", { className: "text-xs", children: [
1182
+ /* @__PURE__ */ jsxs("summary", { className: "cursor-pointer", children: [
1183
+ item.name,
1184
+ " \xB7 ",
1185
+ capabilityStatus[item.status] || "\u5F85\u6838\u9A8C"
1186
+ ] }),
1187
+ /* @__PURE__ */ jsx2("p", { className: "mt-1", children: item.description }),
1188
+ item.reason && /* @__PURE__ */ jsx2("p", { children: item.reason }),
1189
+ item.next_action && /* @__PURE__ */ jsx2("p", { children: item.next_action }),
1190
+ /* @__PURE__ */ jsx2("p", { children: item.identity === "bot" ? "\u673A\u5668\u4EBA\u8EAB\u4EFD" : "\u672C\u4EBA\u8EAB\u4EFD" }),
1191
+ item.scopes.map((scope) => /* @__PURE__ */ jsx2("p", { className: "break-all", children: permissions.find((p) => p.scope === scope && p.identity === item.identity)?.name || scope }, scope)),
1192
+ /* @__PURE__ */ jsx2("p", { children: "\u5BA1\u6838\u8981\u6C42\u4EE5\u98DE\u4E66\u5B98\u65B9\u9875\u9762\u548C\u4F01\u4E1A\u89C4\u5219\u4E3A\u51C6\u3002" })
1193
+ ] }, item.id))
1194
+ ] }, id)) })
1195
+ ] })
1196
+ ] });
1197
+ }
1198
+
1199
+ // src/components/ConnectorAuthorizationProgress.tsx
1200
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1201
+ function ConnectorAuthorizationProgress({ result, onCheck, busy }) {
1202
+ if (!result || result.status === "complete" || result.status === "waiting") return null;
1203
+ let manualURL;
1204
+ try {
1205
+ const url = new URL(result.manual_url || "");
1206
+ if (url.protocol === "https:" && url.hostname === "open.feishu.cn" && !url.username && !url.password && !url.port && /^\/app(?:\/[^/]+\/auth)?$/.test(url.pathname)) manualURL = url.href;
1207
+ } catch {
1208
+ }
1209
+ return /* @__PURE__ */ jsxs2("output", { className: "block space-y-2 rounded-lg border p-4 text-sm", children: [
1210
+ /* @__PURE__ */ jsx3("span", { className: "block", children: result.status === "partial" ? "\u90E8\u5206\u6743\u9650\u5DF2\u751F\u6548\uFF0C\u672C\u6B21\u64CD\u4F5C\u6240\u9700\u6743\u9650\u5C1A\u672A\u8865\u9F50" : "\u672C\u6B21\u64CD\u4F5C\u6240\u9700\u6743\u9650\u5C1A\u672A\u751F\u6548" }),
1211
+ /* @__PURE__ */ jsx3("span", { className: "block", children: result.next_action }),
1212
+ result.missing_permissions.map((item) => /* @__PURE__ */ jsxs2("span", { className: "block break-all text-xs", children: [
1213
+ item.identity === "bot" ? "\u5E94\u7528\u8EAB\u4EFD" : "\u672C\u4EBA\u8EAB\u4EFD",
1214
+ " \xB7 ",
1215
+ item.scope
1216
+ ] }, `${item.identity}:${item.scope}`)),
1217
+ result.mode === "manual" && manualURL && /* @__PURE__ */ jsx3("a", { className: "block underline", href: manualURL, target: "_blank", rel: "noopener noreferrer", children: "\u6253\u5F00\u98DE\u4E66\u6743\u9650\u7BA1\u7406" }),
1218
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "underline disabled:opacity-50", disabled: busy, onClick: onCheck, children: "\u6211\u5DF2\u5904\u7406\uFF0C\u91CD\u65B0\u6838\u9A8C" })
1219
+ ] });
1220
+ }
1221
+
1222
+ // src/components/FeishuPermissionStatus.tsx
1223
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1224
+ function FeishuPermissionStatus({ permissions, template, expanded = false, hideScopes = false }) {
1225
+ if (!template && !permissions.some((item) => item.app_status)) return null;
1226
+ const listed = template ? permissions.filter((item) => item.template) : permissions;
1227
+ const missingApp = listed.filter((item) => item.app_status === "missing");
1228
+ const missingUser = listed.filter((item) => item.identity === "user" && item.app_status === "granted" && item.user_status === "not_granted");
1229
+ const unknown = listed.filter((item) => !item.app_status || item.app_status === "unknown");
1230
+ return /* @__PURE__ */ jsxs3("details", { open: expanded || void 0, className: "rounded-xl border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-4 text-sm", children: [
1231
+ /* @__PURE__ */ jsxs3("summary", { className: "cursor-pointer", children: [
1232
+ template ? "\u98DE\u4E66\u5B98\u65B9\u63A8\u8350\u6743\u9650" : "\u98DE\u4E66\u6743\u9650\u72B6\u6001",
1233
+ " \xB7 ",
1234
+ missingApp.length,
1235
+ " \u9879\u5E94\u7528\u672A\u5F00\u901A \xB7 ",
1236
+ missingUser.length,
1237
+ " \u9879\u5F85\u672C\u4EBA\u6388\u6743",
1238
+ unknown.length ? ` \xB7 ${unknown.length} \u9879\u5F85\u6838\u9A8C` : ""
1239
+ ] }),
1240
+ /* @__PURE__ */ jsx4("p", { className: "mt-3 text-xs opacity-70", children: "\u4F01\u4E1A\u51B3\u5B9A\u54EA\u4E9B\u6743\u9650\u514D\u5BA1\u3001\u54EA\u4E9B\u9700\u8981\u5BA1\u6279\u3002\u5E94\u7528\u5DF2\u5F00\u901A\u548C\u672C\u4EBA\u5DF2\u6388\u6743\u5206\u522B\u6838\u9A8C\uFF1B\u5F85\u6838\u9A8C\u4E0D\u4EE3\u8868\u4F01\u4E1A\u62D2\u7EDD\u3002\u672A\u5F00\u901A\u9879\u76EE\u4E0D\u5F71\u54CD\u5176\u4ED6\u5DF2\u83B7\u6388\u6743\u7684\u64CD\u4F5C\u3002" }),
1241
+ /* @__PURE__ */ jsx4("div", { className: "mt-3 max-h-72 space-y-3 overflow-y-auto", children: listed.map((item) => /* @__PURE__ */ jsxs3("div", { className: "text-xs", children: [
1242
+ /* @__PURE__ */ jsxs3("p", { children: [
1243
+ item.category_name ? `${item.category_name} \xB7 ` : "",
1244
+ item.name
1245
+ ] }),
1246
+ !hideScopes && item.name !== item.scope && /* @__PURE__ */ jsx4("p", { className: "break-all opacity-70", children: item.scope }),
1247
+ /* @__PURE__ */ jsxs3("p", { children: [
1248
+ item.app_status === "granted" ? "\u5E94\u7528\u5DF2\u5F00\u901A" : item.app_status === "missing" ? "\u5E94\u7528\u672A\u5F00\u901A\uFF0C\u8BF7\u5728\u98DE\u4E66\u786E\u8BA4\u4F01\u4E1A\u5BA1\u6279\u6216\u53D1\u5E03\u8981\u6C42" : "\u5E94\u7528\u5F00\u901A\u60C5\u51B5\u5F85\u6838\u9A8C",
1249
+ item.identity === "user" ? item.user_status === "granted" ? "\uFF1B\u672C\u4EBA\u5DF2\u6388\u6743" : "\uFF1B\u672C\u4EBA\u5C1A\u672A\u6388\u6743" : ""
1250
+ ] })
1251
+ ] }, `${item.identity}:${item.scope}`)) })
1252
+ ] });
1253
+ }
1254
+
1255
+ // src/components/ConnectorRuntimeDiagnostics.tsx
1256
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1257
+ var channelLabels = {
1258
+ "channel.connecting": "\u5F00\u59CB\u8FDE\u63A5\u98DE\u4E66",
1259
+ "channel.connected": "\u98DE\u4E66\u8FDE\u63A5\u5DF2\u5EFA\u7ACB",
1260
+ "channel.reconnecting": "\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5\u98DE\u4E66",
1261
+ "channel.disconnected": "\u98DE\u4E66\u8FDE\u63A5\u5DF2\u65AD\u5F00",
1262
+ "channel.receiver_error": "\u6D88\u606F\u63A5\u6536\u53D1\u751F\u9519\u8BEF",
1263
+ "channel.warning": "\u63A5\u6536\u901A\u9053\u4EA7\u751F\u8B66\u544A",
1264
+ "channel.error": "\u63A5\u6536\u901A\u9053\u53D1\u751F\u9519\u8BEF",
1265
+ "message.received": "\u5DF2\u8BB0\u5F55\u6536\u5230\u98DE\u4E66\u6D88\u606F"
1266
+ };
1267
+ var deliveryLabels = {
1268
+ ready: "\u7B49\u5F85\u6295\u9012",
1269
+ delivering: "\u6B63\u5728\u6295\u9012",
1270
+ retry_wait: "\u7B49\u5F85\u91CD\u8BD5",
1271
+ accepted: "\u63A5\u6536\u7AEF\u5DF2\u786E\u8BA4",
1272
+ dead_letter: "\u5DF2\u505C\u6B62\u91CD\u8BD5\uFF0C\u9700\u8981\u5904\u7406",
1273
+ cancelled: "\u5DF2\u53D6\u6D88",
1274
+ waiting_condition: "\u7B49\u5F85\u6295\u9012\u6761\u4EF6",
1275
+ expired_unknown: "\u5DF2\u8FC7\u671F\uFF0C\u7ED3\u679C\u672A\u77E5",
1276
+ leased: "\u6B63\u5728\u5904\u7406"
1277
+ };
1278
+ var time = (value) => value > 0 ? new Date(value).toLocaleString() : "\u6682\u65E0\u8BB0\u5F55";
1279
+ var channelLabel = (value) => channelLabels[value] ?? (value ? "\u5C1A\u672A\u8BC6\u522B\u7684\u901A\u9053\u8BB0\u5F55" : "\u5C1A\u65E0\u901A\u9053\u8BB0\u5F55");
1280
+ var deliveryLabel = (value) => deliveryLabels[value] ?? "\u5C1A\u672A\u8BC6\u522B\u7684\u6295\u9012\u72B6\u6001";
1281
+ function ConnectorRuntimeDiagnostics({ runtime }) {
1282
+ if ("last_sync_at_ms" in runtime) return /* @__PURE__ */ jsxs4("section", { "aria-label": "\u90AE\u7BB1\u540C\u6B65\u8BB0\u5F55", className: "space-y-3 rounded-lg border p-3 text-xs", children: [
1283
+ /* @__PURE__ */ jsx5("p", { className: "font-medium", children: "\u90AE\u7BB1\u540C\u6B65\u8BB0\u5F55" }),
1284
+ /* @__PURE__ */ jsxs4("p", { children: [
1285
+ "\u6700\u8FD1\u540C\u6B65\u65F6\u95F4\uFF1A",
1286
+ time(runtime.last_sync_at_ms)
1287
+ ] }),
1288
+ /* @__PURE__ */ jsxs4("p", { children: [
1289
+ "\u8FDE\u7EED\u540C\u6B65\u5931\u8D25\u6B21\u6570\uFF1A",
1290
+ runtime.consecutive_failures
1291
+ ] }),
1292
+ runtime.next_retry_at_ms > 0 && /* @__PURE__ */ jsxs4("p", { children: [
1293
+ "\u4E0B\u6B21\u91CD\u8BD5\u65F6\u95F4\uFF1A",
1294
+ time(runtime.next_retry_at_ms)
1295
+ ] }),
1296
+ /* @__PURE__ */ jsx5("p", { children: "\u4EE5\u4E0A\u662F SuperWork \u4FDD\u5B58\u7684\u90AE\u7BB1\u540C\u6B65\u8BB0\u5F55\uFF0C\u4E0D\u80FD\u636E\u6B64\u786E\u8BA4\u6D88\u606F\u5DF2\u9001\u8FBE\u52A9\u624B\u3002" })
1297
+ ] });
1298
+ return /* @__PURE__ */ jsxs4("section", { "aria-label": "\u6D88\u606F\u63A5\u6536\u4E0E\u6295\u9012\u8BB0\u5F55", className: "space-y-3 rounded-lg border p-3 text-xs", children: [
1299
+ /* @__PURE__ */ jsx5("p", { className: "font-medium", children: "\u6D88\u606F\u63A5\u6536\u4E0E\u6295\u9012\u8BB0\u5F55" }),
1300
+ /* @__PURE__ */ jsxs4("p", { children: [
1301
+ "\u901A\u9053\u6700\u8FD1\u8BB0\u5F55\uFF1A",
1302
+ channelLabel(runtime.channel_state)
1303
+ ] }),
1304
+ /* @__PURE__ */ jsxs4("p", { children: [
1305
+ "\u6700\u8FD1\u6536\u5230\u4E8B\u4EF6\uFF1A",
1306
+ time(runtime.last_event_at_ms)
1307
+ ] }),
1308
+ /* @__PURE__ */ jsx5("p", { children: "\u4EE5\u4E0B\u662F SuperWork \u4FDD\u5B58\u7684\u8BB0\u5F55\uFF1B\u6CA1\u6709\u6295\u9012\u8BB0\u5F55\u65F6\uFF0C\u5C1A\u4E0D\u80FD\u786E\u8BA4\u6D88\u606F\u5DF2\u9001\u8FBE\u52A9\u624B\u3002" }),
1309
+ /* @__PURE__ */ jsxs4("details", { children: [
1310
+ /* @__PURE__ */ jsxs4("summary", { className: "cursor-pointer", children: [
1311
+ "\u63A5\u6536\u901A\u9053\u8BB0\u5F55\uFF08",
1312
+ runtime.channel_events.length,
1313
+ "\uFF09"
1314
+ ] }),
1315
+ runtime.channel_events.length ? /* @__PURE__ */ jsx5("ol", { className: "space-y-2 pt-2", children: runtime.channel_events.map((event) => /* @__PURE__ */ jsxs4("li", { className: "space-y-1", children: [
1316
+ /* @__PURE__ */ jsxs4("p", { children: [
1317
+ channelLabel(event.type),
1318
+ " \xB7 ",
1319
+ time(event.at_ms)
1320
+ ] }),
1321
+ /* @__PURE__ */ jsxs4("p", { className: "break-all", children: [
1322
+ "\u6392\u67E5\u7F16\u53F7\uFF1A",
1323
+ event.trace_id
1324
+ ] })
1325
+ ] }, event.trace_id)) }) : /* @__PURE__ */ jsx5("p", { children: "\u6682\u65E0\u63A5\u6536\u901A\u9053\u8BB0\u5F55\u3002" })
1326
+ ] }),
1327
+ /* @__PURE__ */ jsxs4("details", { children: [
1328
+ /* @__PURE__ */ jsxs4("summary", { className: "cursor-pointer", children: [
1329
+ "\u6D88\u606F\u6295\u9012\u8BB0\u5F55\uFF08",
1330
+ runtime.deliveries.length,
1331
+ "\uFF09"
1332
+ ] }),
1333
+ runtime.deliveries.length ? /* @__PURE__ */ jsx5("ol", { className: "space-y-2 pt-2", children: runtime.deliveries.map((delivery) => /* @__PURE__ */ jsxs4("li", { className: "space-y-1", children: [
1334
+ /* @__PURE__ */ jsxs4("p", { children: [
1335
+ deliveryLabel(delivery.status),
1336
+ " \xB7 \u5DF2\u5C1D\u8BD5 ",
1337
+ delivery.attempt,
1338
+ " \u6B21"
1339
+ ] }),
1340
+ /* @__PURE__ */ jsxs4("p", { className: "break-all", children: [
1341
+ "\u6295\u9012\u7F16\u53F7\uFF1A",
1342
+ delivery.delivery_id
1343
+ ] }),
1344
+ /* @__PURE__ */ jsxs4("p", { children: [
1345
+ "\u521B\u5EFA\u65F6\u95F4\uFF1A",
1346
+ time(delivery.created_at_ms)
1347
+ ] }),
1348
+ ["ready", "retry_wait", "waiting_condition"].includes(delivery.status) && delivery.next_at_ms > 0 && /* @__PURE__ */ jsxs4("p", { children: [
1349
+ "\u4E0B\u6B21\u5904\u7406\u65F6\u95F4\uFF1A",
1350
+ time(delivery.next_at_ms)
1351
+ ] })
1352
+ ] }, delivery.delivery_id)) }) : /* @__PURE__ */ jsx5("p", { children: "\u6682\u65E0\u6D88\u606F\u6295\u9012\u8BB0\u5F55\u3002" })
1353
+ ] }),
1354
+ /* @__PURE__ */ jsxs4("details", { children: [
1355
+ /* @__PURE__ */ jsxs4("summary", { className: "cursor-pointer", children: [
1356
+ "\u9010\u6B21\u6295\u9012\u5C1D\u8BD5\uFF08",
1357
+ runtime.delivery_attempts.length,
1358
+ "\uFF09"
1359
+ ] }),
1360
+ runtime.delivery_attempts.length ? /* @__PURE__ */ jsx5("ol", { className: "space-y-2 pt-2", children: runtime.delivery_attempts.map((attempt) => /* @__PURE__ */ jsxs4("li", { className: "space-y-1", children: [
1361
+ /* @__PURE__ */ jsxs4("p", { children: [
1362
+ "\u7B2C ",
1363
+ attempt.attempt,
1364
+ " \u6B21 \xB7 ",
1365
+ deliveryLabel(attempt.status)
1366
+ ] }),
1367
+ /* @__PURE__ */ jsxs4("p", { className: "break-all", children: [
1368
+ "\u6295\u9012\u7F16\u53F7\uFF1A",
1369
+ attempt.delivery_id
1370
+ ] }),
1371
+ /* @__PURE__ */ jsxs4("p", { children: [
1372
+ "\u5F00\u59CB\uFF1A",
1373
+ time(attempt.started_at_ms),
1374
+ "\uFF1B\u7ED3\u675F\uFF1A",
1375
+ time(attempt.finished_at_ms)
1376
+ ] })
1377
+ ] }, attempt.id)) }) : /* @__PURE__ */ jsx5("p", { children: "\u6682\u65E0\u6295\u9012\u5C1D\u8BD5\u8BB0\u5F55\u3002" })
1378
+ ] })
1379
+ ] });
1380
+ }
1381
+
1382
+ // src/components/DeviceConnection.tsx
1383
+ import { Fragment, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1384
+ var statusLabels = {
1385
+ available: "\u53EF\u7528",
1386
+ not_selected: "\u672A\u9009\u62E9",
1387
+ permission_required: "\u5E94\u7528\u6743\u9650\u672A\u751F\u6548",
1388
+ user_auth_required: "\u9700\u8981\u672C\u4EBA\u6388\u6743",
1389
+ app_required: "\u9700\u8981\u8FDE\u63A5\u5E94\u7528",
1390
+ unsupported: "\u6682\u4E0D\u652F\u6301",
1391
+ unknown: "\u5F85\u6838\u9A8C",
1392
+ temporarily_unavailable: "\u6682\u65F6\u4E0D\u53EF\u7528"
1393
+ };
1394
+ var stateLabels = {
1395
+ running: "\u8FDB\u884C\u4E2D",
1396
+ waiting: "\u7B49\u5F85\u5904\u7406",
1397
+ succeeded: "\u5DF2\u5B8C\u6210",
1398
+ failed: "\u672A\u5B8C\u6210",
1399
+ cancelled: "\u5DF2\u53D6\u6D88",
1400
+ completed: "\u5DF2\u5B8C\u6210",
1401
+ partial: "\u90E8\u5206\u5B8C\u6210",
1402
+ expired: "\u5DF2\u8FC7\u671F"
1403
+ };
1404
+ var auditLabels = {
1405
+ "connection.created": "\u521B\u5EFA\u8FDE\u63A5",
1406
+ "authorization.step": "\u6267\u884C\u6388\u6743\u6B65\u9AA4",
1407
+ "authorization.failed": "\u5F53\u524D\u6388\u6743\u6B65\u9AA4\u672A\u5B8C\u6210",
1408
+ "authorization.granted": "\u672C\u4EBA\u6388\u6743\u5DF2\u4FDD\u5B58",
1409
+ "permissions.check_unknown": "\u5E94\u7528\u6743\u9650\u5C1A\u65E0\u6CD5\u6838\u5B9E",
1410
+ "credential.refreshed": "\u672C\u4EBA\u6388\u6743\u5DF2\u7EED\u671F",
1411
+ "subscription.bound": "\u52A9\u624B\u6D88\u606F\u8BA2\u9605\u5DF2\u63A5\u5165",
1412
+ "subscription.updated": "\u52A9\u624B\u6D88\u606F\u8BA2\u9605\u5DF2\u66F4\u65B0",
1413
+ "connection.disconnected": "SuperWork \u8FDE\u63A5\u5DF2\u65AD\u5F00",
1414
+ "tool.started": "\u5F00\u59CB\u5904\u7406\u98DE\u4E66\u64CD\u4F5C",
1415
+ "tool.failed": "\u98DE\u4E66\u64CD\u4F5C\u672A\u5B8C\u6210",
1416
+ "tool.completed": "\u98DE\u4E66\u64CD\u4F5C\u5DF2\u5B8C\u6210",
1417
+ "send.unknown": "\u53D1\u9001\u7ED3\u679C\u5F85\u786E\u8BA4"
1418
+ };
1419
+ var button = "rounded-lg border border-[color-mix(in_srgb,currentColor_18%,transparent)] px-3 py-2 text-sm disabled:opacity-50";
1420
+ function authorizationURL(value) {
1421
+ if (!value) return null;
1422
+ try {
1423
+ const url = new URL(value);
1424
+ const official = ["feishu.cn", "larksuite.com", "larkoffice.com"].some((domain) => url.hostname === domain || url.hostname.endsWith(`.${domain}`));
1425
+ return official && url.protocol === "https:" && !url.username && !url.password && !url.port ? url.href : null;
1426
+ } catch {
1427
+ return null;
1428
+ }
1429
+ }
1430
+ function permissionNoticeKey(name, connection, permissions) {
1431
+ const scopes = JSON.stringify([...new Set(permissions.map((item) => JSON.stringify([item.identity, item.scope])))].sort());
1432
+ let hash = 2166136261;
1433
+ for (let index = 0; index < scopes.length; index++) hash = Math.imul(hash ^ scopes.charCodeAt(index), 16777619);
1434
+ return `blade-connector-notice:${name}:${JSON.stringify([connection.connection_id ?? "", connection.app_id ?? ""])}:${(hash >>> 0).toString(16)}`;
1435
+ }
1436
+ function DeviceConnection({ read, act, diagnostics, onChanged, bindDelivery = false, onDisable, initialPage = "connection", authorizationCapabilities, autoAuthorize = false, detail }) {
1437
+ const [view, setView] = useState(null);
1438
+ const [selected, setSelected] = useState([]);
1439
+ const [page, setPage] = useState(initialPage);
1440
+ const [diagnosticView, setDiagnosticView] = useState(null);
1441
+ const [error, setError] = useState("");
1442
+ const [notice, setNotice] = useState("");
1443
+ const [busy, setBusy] = useState(false);
1444
+ const [removingConnectionID, setRemovingConnectionID] = useState(null);
1445
+ const callbacks = useRef({ read, act, diagnostics, onChanged, onDisable });
1446
+ callbacks.current = { read, act, diagnostics, onChanged, onDisable };
1447
+ const live = useRef(false);
1448
+ const inFlight = useRef(false);
1449
+ const initialized = useRef(false);
1450
+ const flow = useRef(null);
1451
+ const linking = useRef(false);
1452
+ const newConnection = useRef(false);
1453
+ function accept(value) {
1454
+ if (value.permissions && !value.permissions.some((item) => item.app_status === "missing")) {
1455
+ try {
1456
+ const prefix = `blade-connector-notice:${detail?.name ?? "connector.builtin.feishu"}:`;
1457
+ for (const key of Object.keys(localStorage)) if (key.startsWith(prefix)) localStorage.removeItem(key);
1458
+ } catch {
1459
+ }
1460
+ }
1461
+ setView(value);
1462
+ const activationKnown = typeof value.activation_pending === "boolean";
1463
+ if (activationKnown) {
1464
+ newConnection.current = value.activation_pending === true;
1465
+ if (flow.current) flow.current.enable = newConnection.current || value.enabled !== false;
1466
+ }
1467
+ if (flow.current && newConnection.current && value.selected_capabilities !== void 0) {
1468
+ flow.current.capabilities = value.selected_capabilities;
1469
+ }
1470
+ if (!initialized.current) {
1471
+ initialized.current = true;
1472
+ setSelected(value.app_id ? value.selected_capabilities ?? [] : defaultCapabilities(value.capabilities ?? []));
1473
+ if (!activationKnown) newConnection.current = !value.app_id;
1474
+ linking.current = value.phase === "app";
1475
+ if (["app", "user", "permissions"].includes(value.phase) && value.authorization_url || value.current_step?.state === "verifying" && value.current_step.action === "poll") flow.current = { enable: newConnection.current || value.enabled !== false, capabilities: value.selected_capabilities ?? [], focus: value.selected_capabilities ?? [] };
1476
+ if (!flow.current && matchesRequestedAuthorization(value) && value.app_id && value.authorization_result && value.authorization_result.status !== "complete" && value.authorization_result.capabilities.length) {
1477
+ const focus = value.authorization_result.capabilities;
1478
+ flow.current = { enable: newConnection.current || value.enabled !== false, capabilities: [.../* @__PURE__ */ new Set([...value.selected_capabilities ?? [], ...focus])], focus };
1479
+ }
1480
+ if (!value.app_id) setPage("select");
1481
+ }
1482
+ }
1483
+ useEffect(() => {
1484
+ live.current = true;
1485
+ void callbacks.current.read().then((value) => {
1486
+ if (live.current) accept(value);
1487
+ }).catch(() => {
1488
+ if (live.current) setError("\u8BFB\u53D6\u8FDE\u63A5\u72B6\u6001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002");
1489
+ });
1490
+ return () => {
1491
+ live.current = false;
1492
+ };
1493
+ }, []);
1494
+ const matchesRequestedAuthorization = (value) => !authorizationCapabilities?.length || !!value.authorization_result && [...value.authorization_result.capabilities].sort().join(" ") === [...authorizationCapabilities].sort().join(" ");
1495
+ const canCompleteInitial = (value) => value.activation_pending === true && !authorizationCapabilities?.length && !!value.app_id && !value.error && (value.capabilities ?? []).some((item) => (value.selected_capabilities ?? []).includes(item.id) && item.status === "available");
1496
+ const canReceive = (value) => (value.capabilities ?? []).some((item) => (value.selected_capabilities ?? selected).includes(item.id) && item.id.startsWith("bot_receive_") && (item.status === "available" || item.status === "unknown" && item.evidence === "platform_scope_query"));
1497
+ const isWaiting = (value) => matchesRequestedAuthorization(value) && (["app", "user", "permissions"].includes(value.phase) && Boolean(value.authorization_url) || value.current_step?.state === "verifying" && value.current_step.action === "poll");
1498
+ async function changed() {
1499
+ try {
1500
+ await callbacks.current.onChanged();
1501
+ } catch {
1502
+ if (live.current) setNotice("\u8FDE\u63A5\u72B6\u6001\u5DF2\u4FDD\u5B58\uFF0C\u5217\u8868\u5237\u65B0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u5237\u65B0\u3002");
1503
+ }
1504
+ }
1505
+ async function run(action, options = {}) {
1506
+ if (inFlight.current) return;
1507
+ inFlight.current = true;
1508
+ setBusy(true);
1509
+ setError("");
1510
+ setNotice("");
1511
+ try {
1512
+ if (action === "cancel") {
1513
+ flow.current = null;
1514
+ linking.current = false;
1515
+ }
1516
+ let value = await callbacks.current.act(action, options);
1517
+ if (!live.current) return;
1518
+ if (action === "finish" && !value.error) newConnection.current = false;
1519
+ accept(value);
1520
+ if (!value.error && action === "poll" && !isWaiting(value) && value.app_id && linking.current) {
1521
+ linking.current = false;
1522
+ setSelected(defaultCapabilities(value.capabilities ?? []));
1523
+ setPage("select");
1524
+ }
1525
+ if (!value.error && ((action === "authorize" || action === "poll" || action === "check" && (value.authorization_result?.status === "complete" || canCompleteInitial(value))) && !isWaiting(value) || action === "finish") && value.app_id && flow.current) {
1526
+ const target = flow.current;
1527
+ if (!matchesRequestedAuthorization(value)) {
1528
+ setError("\u65E0\u6CD5\u6838\u5B9E\u5F53\u524D\u6388\u6743\u5BF9\u5E94\u7684\u6743\u9650\uFF0C\u6682\u4E0D\u5C55\u793A\u4E8C\u7EF4\u7801\u3002\u8BF7\u91CD\u65B0\u68C0\u67E5\u672C\u6B21\u64CD\u4F5C\u3002");
1529
+ await changed();
1530
+ return;
1531
+ }
1532
+ if (action !== "finish" && value.authorization_result && value.authorization_result.status !== "complete" && !canCompleteInitial(value)) {
1533
+ setPage("connection");
1534
+ await changed();
1535
+ return;
1536
+ }
1537
+ if (action !== "finish") value = await callbacks.current.act("finish", { capabilities: target.capabilities, enable: target.enable });
1538
+ if (!live.current) return;
1539
+ accept(value);
1540
+ if (value.error) {
1541
+ await changed();
1542
+ return;
1543
+ }
1544
+ newConnection.current = false;
1545
+ flow.current = null;
1546
+ if (bindDelivery && canReceive(value) && value.subscription_state !== "paused") {
1547
+ try {
1548
+ value = await callbacks.current.act("bind");
1549
+ if (!live.current) return;
1550
+ accept(value);
1551
+ } catch {
1552
+ setNotice("\u98DE\u4E66\u80FD\u529B\u5DF2\u4FDD\u5B58\uFF0C\u63A5\u5165\u52A9\u624B\u6D88\u606F\u672A\u5B8C\u6210\u3002\u53EF\u5728\u7BA1\u7406\u8FDE\u63A5\u4E2D\u91CD\u8BD5\uFF0C\u4E0D\u9700\u8981\u91CD\u65B0\u626B\u7801\u3002");
1553
+ }
1554
+ }
1555
+ setPage("connection");
1556
+ }
1557
+ if (action === "cancel") {
1558
+ setNotice("\u5DF2\u53D6\u6D88\u672C\u6B21\u6388\u6743\uFF0C\u5DF2\u7ECF\u5F00\u901A\u7684\u80FD\u529B\u7EE7\u7EED\u4FDD\u7559\u3002");
1559
+ setPage("connection");
1560
+ }
1561
+ await changed();
1562
+ } catch {
1563
+ if (live.current) setError("\u672C\u6B21\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u5DF2\u6709\u6388\u6743\u7EE7\u7EED\u4FDD\u7559\u3002\u8BF7\u91CD\u8BD5\u5F53\u524D\u9879\u76EE\uFF0C\u6216\u67E5\u770B\u8FDE\u63A5\u5E2E\u52A9\u3002");
1564
+ try {
1565
+ const current = await callbacks.current.read();
1566
+ if (live.current) accept(current);
1567
+ } catch {
1568
+ }
1569
+ } finally {
1570
+ inFlight.current = false;
1571
+ if (live.current) setBusy(false);
1572
+ }
1573
+ }
1574
+ const start = (retryIDs) => {
1575
+ let focus = retryIDs ?? defaultCapabilities((view?.capabilities ?? []).filter((item) => view?.app_id || item.identity === "bot"));
1576
+ if (!view?.app_id && !focus.length) {
1577
+ focus = capabilities.filter((item) => item.identity === "bot" && item.default && item.status !== "unsupported").map((item) => item.id);
1578
+ if (!focus.length && view?.catalog_unavailable) focus = (view.selected_capabilities ?? []).filter((id) => ["bot_send", "bot_receive_p2p", "bot_receive_at", "bot_receive_group"].includes(id));
1579
+ }
1580
+ const target = [.../* @__PURE__ */ new Set([...view?.app_id ? view.selected_capabilities ?? [] : [], ...focus])];
1581
+ if (!view?.app_id) {
1582
+ linking.current = false;
1583
+ flow.current = { enable: true, capabilities: target, focus };
1584
+ void run("authorize", { capabilities: focus });
1585
+ return;
1586
+ }
1587
+ flow.current = { enable: newConnection.current || view.enabled !== false, capabilities: target, focus: [...focus] };
1588
+ void run("authorize", { capabilities: focus });
1589
+ };
1590
+ const retryCurrent = () => {
1591
+ if (flow.current) {
1592
+ flow.current.enable = newConnection.current || view?.enabled !== false;
1593
+ void run("authorize", { capabilities: flow.current.focus });
1594
+ } else start(failedUser.length ? failedUser.map((item) => item.id) : selected);
1595
+ };
1596
+ const automaticStarted = useRef(false);
1597
+ useEffect(() => {
1598
+ if (!authorizationCapabilities?.length && !autoAuthorize || !view || automaticStarted.current) return;
1599
+ automaticStarted.current = true;
1600
+ if (!isWaiting(view) && !(matchesRequestedAuthorization(view) && view.authorization_result?.mode === "manual")) start(authorizationCapabilities);
1601
+ }, [view, authorizationCapabilities, autoAuthorize]);
1602
+ const initialCompletionStarted = useRef(false);
1603
+ useEffect(() => {
1604
+ if (!view || !view.authorization_result || isWaiting(view) || busy || error || initialCompletionStarted.current || !canCompleteInitial(view)) return;
1605
+ initialCompletionStarted.current = true;
1606
+ automaticStarted.current = true;
1607
+ const capabilities2 = view.selected_capabilities ?? [];
1608
+ flow.current = { enable: true, capabilities: capabilities2, focus: capabilities2 };
1609
+ void run("finish", { capabilities: capabilities2, enable: true });
1610
+ }, [view, busy, error, authorizationCapabilities]);
1611
+ async function addCapabilities() {
1612
+ start();
1613
+ }
1614
+ async function refresh() {
1615
+ if (inFlight.current) return;
1616
+ inFlight.current = true;
1617
+ setBusy(true);
1618
+ setError("");
1619
+ try {
1620
+ const value = await callbacks.current.read();
1621
+ if (live.current) {
1622
+ if (view?.catalog_unavailable && !value.app_id) initialized.current = false;
1623
+ accept(value);
1624
+ }
1625
+ } catch {
1626
+ if (live.current) setError("\u8BFB\u53D6\u8FDE\u63A5\u72B6\u6001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002");
1627
+ } finally {
1628
+ inFlight.current = false;
1629
+ if (live.current) setBusy(false);
1630
+ }
1631
+ }
1632
+ async function removeConnection(connectionID) {
1633
+ if (inFlight.current) return;
1634
+ inFlight.current = true;
1635
+ setBusy(true);
1636
+ setError("");
1637
+ setNotice("");
1638
+ try {
1639
+ const value = await callbacks.current.act("remove", { expected_connection_id: connectionID });
1640
+ if (!live.current) return;
1641
+ if (value.error) {
1642
+ setError(value.error.message);
1643
+ return;
1644
+ }
1645
+ flow.current = null;
1646
+ linking.current = false;
1647
+ newConnection.current = true;
1648
+ initialized.current = false;
1649
+ setSelected([]);
1650
+ setDiagnosticView(null);
1651
+ setRemovingConnectionID(null);
1652
+ accept(value);
1653
+ setPage("select");
1654
+ setNotice(value.catalog_unavailable ? "\u65E7\u8FDE\u63A5\u5DF2\u79FB\u9664\uFF0C\u80FD\u529B\u76EE\u5F55\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002\u53EF\u4EE5\u91CD\u65B0\u8BFB\u53D6\u5DE5\u4F5C\u80FD\u529B\uFF0C\u6216\u70B9\u51FB\u8FDE\u63A5\u98DE\u4E66\u7EE7\u7EED\u3002" : "\u65E7\u8FDE\u63A5\u5DF2\u79FB\u9664\uFF0C\u5386\u53F2\u6D88\u606F\u548C\u6392\u67E5\u65E5\u5FD7\u4FDD\u7559\u3002\u70B9\u51FB\u8FDE\u63A5\u98DE\u4E66\uFF0C\u91CD\u65B0\u9009\u62E9\u6216\u521B\u5EFA\u5E94\u7528\u3002");
1655
+ await changed();
1656
+ } catch {
1657
+ if (live.current) setError("\u79FB\u9664\u8FDE\u63A5\u672A\u5B8C\u6210\uFF0C\u5F53\u524D\u8FDE\u63A5\u4FE1\u606F\u5DF2\u4FDD\u7559\u3002\u8BF7\u91CD\u8BD5\uFF1B\u5982\u4ECD\u5931\u8D25\uFF0C\u53EF\u5728\u8FDE\u63A5\u5E2E\u52A9\u4E2D\u67E5\u770B\u8BB0\u5F55\u3002");
1658
+ } finally {
1659
+ inFlight.current = false;
1660
+ if (live.current) setBusy(false);
1661
+ }
1662
+ }
1663
+ async function inspect() {
1664
+ if (inFlight.current || !callbacks.current.diagnostics) return;
1665
+ inFlight.current = true;
1666
+ setBusy(true);
1667
+ setError("");
1668
+ try {
1669
+ const value = await callbacks.current.diagnostics();
1670
+ if (live.current) {
1671
+ setDiagnosticView(value);
1672
+ accept(value.connection);
1673
+ }
1674
+ } catch {
1675
+ if (live.current) setError("\u6392\u67E5\u8BB0\u5F55\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002");
1676
+ } finally {
1677
+ inFlight.current = false;
1678
+ if (live.current) setBusy(false);
1679
+ }
1680
+ }
1681
+ const waiting = view ? isWaiting(view) : false;
1682
+ const verifying = view?.current_step?.state === "verifying" && view.current_step.action === "poll";
1683
+ useEffect(() => {
1684
+ if (!waiting || busy || error || view?.error) return;
1685
+ const timer = setTimeout(() => {
1686
+ void run("poll", view?.attempt_id ? { attempt_id: view.attempt_id } : {});
1687
+ }, 5e3);
1688
+ return () => clearTimeout(timer);
1689
+ }, [view, busy, error, waiting]);
1690
+ const capabilities = view?.capabilities ?? [];
1691
+ const active = capabilities.filter((item) => item.status === "available");
1692
+ const pending = capabilities.filter((item) => (view?.selected_capabilities ?? []).includes(item.id) && item.status !== "available" && item.status !== "unsupported");
1693
+ const pendingPermissions = pending.filter((item) => item.status === "permission_required" || item.status === "unknown" && item.evidence !== "platform_scope_query");
1694
+ const failedUser = pending.filter((item) => item.identity === "user" && item.status === "user_auth_required");
1695
+ const categories = [...new Set(active.map((item) => item.category_name || item.category || "\u5176\u4ED6\u5DE5\u4F5C\u80FD\u529B"))];
1696
+ const subscription = view?.subscription_state ?? (view?.delivery_bound ? "enabled" : "not_bound");
1697
+ const url = waiting && !(view?.expires_at && view.expires_at <= Date.now() / 1e3) ? authorizationURL(view?.authorization_url) : null;
1698
+ const receptionNeedsTest = capabilities.some((item) => item.id.startsWith("bot_receive_") && item.status === "unknown" && item.evidence === "platform_scope_query");
1699
+ const finishExisting = () => {
1700
+ const target = flow.current ?? { enable: view?.enabled === true, capabilities: view?.selected_capabilities ?? selected, focus: view?.selected_capabilities ?? selected };
1701
+ target.enable = newConnection.current || view?.enabled !== false;
1702
+ flow.current = target;
1703
+ void run("finish", { capabilities: target.capabilities, enable: target.enable });
1704
+ };
1705
+ const preserveDisabled = Boolean(view?.app_id && view.enabled === false && !newConnection.current);
1706
+ const back = /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline opacity-70", disabled: busy, onClick: () => setPage(view?.app_id ? "connection" : "select"), children: "\u8FD4\u56DE\u98DE\u4E66" });
1707
+ const authorizationContent = /* @__PURE__ */ jsx6(Fragment, { children: (autoAuthorize || authorizationCapabilities?.length) && busy && !waiting && !error && !view?.error ? /* @__PURE__ */ jsx6("output", { className: "block text-sm", children: "\u6B63\u5728\u5904\u7406\u98DE\u4E66\u6388\u6743\u2026" }) : waiting ? /* @__PURE__ */ jsxs5("div", { className: "space-y-4 rounded-xl border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-5 text-center", children: [
1708
+ /* @__PURE__ */ jsx6("h4", { className: "font-medium", children: view?.phase === "app" ? "\u5728\u98DE\u4E66\u9009\u62E9\u6216\u521B\u5EFA\u5E94\u7528" : view?.phase === "permissions" ? "\u5728\u98DE\u4E66\u786E\u8BA4\u5E76\u5F00\u901A\u6743\u9650" : "\u8BF7\u5728\u98DE\u4E66\u786E\u8BA4\u672C\u6B21\u6388\u6743" }),
1709
+ /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: view?.current_step?.message || "\u5B8C\u6210\u5F53\u524D\u6B65\u9AA4\u540E\u81EA\u52A8\u7EE7\u7EED\uFF0C\u5DF2\u6709\u80FD\u529B\u59CB\u7EC8\u4FDD\u7559\u3002" }),
1710
+ url ? /* @__PURE__ */ jsxs5(Fragment, { children: [
1711
+ new TextEncoder().encode(url).length <= 2200 ? /* @__PURE__ */ jsx6(QRCodeSVG, { value: url, size: 180, marginSize: 4, title: "\u98DE\u4E66\u6388\u6743\u4E8C\u7EF4\u7801", className: "mx-auto rounded-lg bg-white" }) : /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: "\u6388\u6743\u9879\u76EE\u8F83\u591A\uFF0C\u8BF7\u6253\u5F00\u98DE\u4E66\u6388\u6743\u9875\u9762\u7EE7\u7EED\u3002" }),
1712
+ /* @__PURE__ */ jsx6("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "block text-sm underline", children: "\u6253\u5F00\u98DE\u4E66\u6388\u6743\u9875\u9762" })
1713
+ ] }) : verifying ? /* @__PURE__ */ jsx6("output", { className: "block text-sm", children: view?.error ? "\u6838\u9A8C\u6682\u672A\u5B8C\u6210\uFF0C\u8BF7\u70B9\u51FB\u201C\u6211\u5DF2\u5B8C\u6210\u6388\u6743\u201D\u91CD\u8BD5\u3002" : "\u6B63\u5728\u6838\u9A8C\u6388\u6743\u7ED3\u679C\uFF0C\u8BF7\u7A0D\u5019\u3002" }) : /* @__PURE__ */ jsx6("p", { role: "alert", className: "text-sm", children: "\u5F53\u524D\u4E8C\u7EF4\u7801\u5DF2\u8FC7\u671F\u6216\u65E0\u6CD5\u9A8C\u8BC1\uFF0C\u8BF7\u91CD\u8BD5\u672C\u6B21\u6388\u6743\u3002" }),
1714
+ view?.expires_at && /* @__PURE__ */ jsxs5("p", { className: "text-xs opacity-70", children: [
1715
+ "\u6709\u6548\u81F3 ",
1716
+ new Date(view.expires_at * 1e3).toLocaleTimeString()
1717
+ ] }),
1718
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap justify-center gap-3", children: [
1719
+ /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run("poll", view?.attempt_id ? { attempt_id: view.attempt_id } : {}), children: busy ? "\u6B63\u5728\u786E\u8BA4\u2026" : "\u6211\u5DF2\u5B8C\u6210\u6388\u6743" }),
1720
+ /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run("cancel", view?.attempt_id ? { attempt_id: view.attempt_id } : {}), children: "\u6682\u65F6\u53D6\u6D88" }),
1721
+ !url && !verifying && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: retryCurrent, children: "\u91CD\u8BD5\u672C\u6B21\u6388\u6743" })
1722
+ ] }),
1723
+ view?.phase === "permissions" && /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: finishExisting, children: "\u5148\u4F7F\u7528\u5DF2\u5F00\u901A\u80FD\u529B\uFF0C\u5176\u4ED6\u7A0D\u540E\u5904\u7406" })
1724
+ ] }) : view && page === "select" ? /* @__PURE__ */ jsxs5(Fragment, { children: [
1725
+ view.app_id ? back : /* @__PURE__ */ jsx6("p", { className: "text-sm", children: "\u9996\u6B21\u8FDE\u63A5\u9700\u8981\u626B\u7801\u4E24\u6B21\uFF1A\u5148\u5173\u8054\u98DE\u4E66\u5E94\u7528\uFF0C\u518D\u786E\u8BA4\u672C\u4EBA\u6388\u6743\u3002\u9009\u5DF2\u6709\u5E94\u7528\u65F6\u7B2C\u4E8C\u6B21\u4E5F\u4E0D\u80FD\u7701\uFF0C\u98DE\u4E66\u8981\u6C42\u4F60\u672C\u4EBA\u540C\u610F\uFF0C\u52A9\u624B\u624D\u80FD\u8BFB\u53D6\u4F60\u7684\u6D88\u606F\u3002" }),
1726
+ /* @__PURE__ */ jsx6(FeishuCapabilitySelection, { capabilities, permissions: view.permissions, operations: view.operations, domains: view.domains, selected, onChange: setSelected, disabled: busy }),
1727
+ view.catalog_unavailable && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void refresh(), children: "\u91CD\u65B0\u8BFB\u53D6\u5DE5\u4F5C\u80FD\u529B" }),
1728
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-3 border-t border-[color-mix(in_srgb,currentColor_18%,transparent)] pt-4", children: [
1729
+ /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: "\u6743\u9650\u7531\u98DE\u4E66\u5B98\u65B9\u9875\u9762\u7EDF\u4E00\u9009\u62E9\uFF0C\u5DF2\u6709\u6388\u6743\u7EE7\u7EED\u4FDD\u7559\u3002" }),
1730
+ /* @__PURE__ */ jsx6("button", { type: "button", className: `${button} border-blue-600 bg-blue-600 text-white`, disabled: busy || Boolean(view.app_id) && !selected.length, onClick: () => start(), children: busy ? "\u6B63\u5728\u51C6\u5907\u6388\u6743\u2026" : view.app_id ? preserveDisabled ? "\u8865\u5145\u6388\u6743\u5E76\u4FDD\u5B58" : "\u524D\u5F80\u98DE\u4E66\u6388\u6743" : "\u8FDE\u63A5\u98DE\u4E66" })
1731
+ ] }),
1732
+ preserveDisabled && /* @__PURE__ */ jsx6("p", { className: "text-xs", children: "\u6B64\u52A9\u624B\u5F53\u524D\u505C\u7528\uFF0C\u65B0\u589E\u6388\u6743\u4E0D\u4F1A\u81EA\u52A8\u542F\u7528\u3002\u9700\u8981\u65F6\u53EF\u5728\u7BA1\u7406\u8FDE\u63A5\u4E2D\u91CD\u65B0\u542F\u7528\u3002" })
1733
+ ] }) : null });
1734
+ const diagnosticContent = view && /* @__PURE__ */ jsxs5(Fragment, { children: [
1735
+ " ",
1736
+ /* @__PURE__ */ jsx6("p", { className: "text-sm", children: "\u53EA\u5904\u7406\u672A\u5B8C\u6210\u7684\u9879\u76EE\uFF0C\u5DF2\u7ECF\u5F00\u901A\u7684\u80FD\u529B\u4E0D\u9700\u8981\u91CD\u65B0\u7533\u8BF7\u3002" }),
1737
+ pending.map((item) => /* @__PURE__ */ jsxs5("div", { className: "rounded-lg border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-3 text-sm", children: [
1738
+ /* @__PURE__ */ jsx6("p", { children: item.name }),
1739
+ /* @__PURE__ */ jsxs5("p", { className: "text-xs", children: [
1740
+ item.reason || item.next_action || statusLabels[item.status],
1741
+ item.actor ? ` \xB7 \u7531${item.actor}\u5904\u7406` : ""
1742
+ ] })
1743
+ ] }, item.id)),
1744
+ /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run("check"), children: "\u91CD\u65B0\u68C0\u67E5\u8FDE\u63A5" }),
1745
+ view.app_id && /* @__PURE__ */ jsx6("a", { className: "block text-xs underline", href: `https://open.feishu.cn/app/${encodeURIComponent(view.app_id)}/auth`, target: "_blank", rel: "noopener noreferrer", children: "\u5728\u98DE\u4E66\u67E5\u770B\u6743\u9650\u3001\u53D1\u5E03\u4E0E\u53EF\u7528\u8303\u56F4" }),
1746
+ /* @__PURE__ */ jsxs5("details", { className: "rounded-lg border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-3 text-xs", children: [
1747
+ /* @__PURE__ */ jsx6("summary", { className: "cursor-pointer", children: "\u9AD8\u7EA7\u6392\u67E5\u4FE1\u606F" }),
1748
+ /* @__PURE__ */ jsxs5("div", { className: "space-y-3 pt-3", children: [
1749
+ /* @__PURE__ */ jsxs5("p", { children: [
1750
+ "\u8FDE\u63A5\u7F16\u53F7\uFF1A",
1751
+ view.connection_id || "\u5C1A\u672A\u521B\u5EFA"
1752
+ ] }),
1753
+ /* @__PURE__ */ jsxs5("p", { children: [
1754
+ "\u6392\u67E5\u7F16\u53F7\uFF1A",
1755
+ view.error?.trace_id || view.trace_id || "\u6682\u65E0\u8BB0\u5F55"
1756
+ ] }),
1757
+ /* @__PURE__ */ jsx6("p", { children: "\u8BB0\u5F55\u4E0D\u5305\u542B\u51ED\u636E\u4E0E\u6D88\u606F\u6B63\u6587\u3002" }),
1758
+ view.steps?.length ? /* @__PURE__ */ jsx6("ol", { className: "space-y-2", children: view.steps.map((step, index) => /* @__PURE__ */ jsxs5("li", { children: [
1759
+ stateLabels[step.state] ?? step.state,
1760
+ "\uFF1A",
1761
+ step.message
1762
+ ] }, `${step.id}:${index}`)) }) : null,
1763
+ diagnostics && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void inspect(), children: "\u8BFB\u53D6\u6392\u67E5\u8BB0\u5F55" }),
1764
+ diagnosticView?.runtime && /* @__PURE__ */ jsx6(ConnectorRuntimeDiagnostics, { runtime: diagnosticView.runtime }),
1765
+ diagnosticView && /* @__PURE__ */ jsx6("ol", { className: "space-y-3", children: diagnosticView.audit_events.map((event, index) => /* @__PURE__ */ jsxs5("li", { children: [
1766
+ event.message ?? auditLabels[event.type ?? ""] ?? "\u8FDE\u63A5\u72B6\u6001\u8BB0\u5F55",
1767
+ event.code && /* @__PURE__ */ jsxs5("p", { children: [
1768
+ "\u539F\u56E0\u7F16\u53F7\uFF1A",
1769
+ event.code
1770
+ ] }),
1771
+ event.platform_code && /* @__PURE__ */ jsxs5("p", { children: [
1772
+ "\u98DE\u4E66\u9519\u8BEF\u7801\uFF1A",
1773
+ event.platform_code
1774
+ ] }),
1775
+ event.platform_request_id && /* @__PURE__ */ jsxs5("p", { children: [
1776
+ "\u98DE\u4E66\u8BF7\u6C42\u7F16\u53F7\uFF1A",
1777
+ event.platform_request_id
1778
+ ] }),
1779
+ event.trace_id && /* @__PURE__ */ jsxs5("p", { children: [
1780
+ "\u6392\u67E5\u7F16\u53F7\uFF1A",
1781
+ event.trace_id
1782
+ ] })
1783
+ ] }, event.id ?? index)) })
1784
+ ] })
1785
+ ] })
1786
+ ] });
1787
+ if (detail) {
1788
+ const hasConnection = Boolean(view?.app_id);
1789
+ const needsAttention = hasConnection && Boolean(view?.permissions?.some((item) => item.app_status === "missing") || view?.error || pendingPermissions.length || failedUser.length || view?.activation_pending || view?.enabled === false);
1790
+ const disable = async () => {
1791
+ if (inFlight.current) return;
1792
+ inFlight.current = true;
1793
+ setBusy(true);
1794
+ try {
1795
+ await callbacks.current.onDisable?.();
1796
+ const value = await callbacks.current.read();
1797
+ if (live.current) accept(value);
1798
+ await changed();
1799
+ } finally {
1800
+ inFlight.current = false;
1801
+ if (live.current) setBusy(false);
1802
+ }
1803
+ };
1804
+ const missingApp = (view?.permissions ?? []).filter((item) => item.app_status === "missing");
1805
+ const permissionActions = /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-3", children: [
1806
+ view?.app_id && /* @__PURE__ */ jsx6("a", { className: `${button} inline-flex items-center`, href: `https://open.feishu.cn/app/${encodeURIComponent(view.app_id)}/auth`, target: "_blank", rel: "noopener noreferrer", children: "\u6253\u5F00\u98DE\u4E66\u6743\u9650\u7BA1\u7406" }),
1807
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "min-h-10 text-xs underline disabled:opacity-50", disabled: busy, onClick: () => void run("check"), children: "\u6211\u5DF2\u5904\u7406\uFF0C\u91CD\u65B0\u6838\u9A8C" })
1808
+ ] });
1809
+ const actions = [
1810
+ { id: "check", description: "\u68C0\u67E5\u6700\u65B0\u6743\u9650\u5F00\u901A\u60C5\u51B5", label: "\u91CD\u65B0\u6838\u9A8C\u6743\u9650", run: () => run("check") },
1811
+ { id: "permissions", description: "\u67E5\u770B\u5168\u90E8\u6743\u9650\u53CA\u5F00\u901A\u60C5\u51B5", label: "\u98DE\u4E66\u5B98\u65B9\u63A8\u8350\u6743\u9650", page: /* @__PURE__ */ jsxs5("div", { className: "space-y-4", children: [
1812
+ /* @__PURE__ */ jsx6(FeishuPermissionStatus, { permissions: view?.permissions ?? [], template: view?.permission_template, expanded: true, hideScopes: true }),
1813
+ permissionActions,
1814
+ /* @__PURE__ */ jsx6(ConnectorAuthorizationProgress, { result: view?.authorization_result, onCheck: () => void run("check"), busy }),
1815
+ pendingPermissions.length > 0 && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => start(pendingPermissions.map((item) => item.id)), children: "\u7EE7\u7EED\u5F00\u901A\u672A\u5B8C\u6210\u7684\u6743\u9650" }),
1816
+ failedUser.length > 0 && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => start(failedUser.map((item) => item.id)), children: "\u4EC5\u8865\u5145\u672A\u5B8C\u6210\u7684\u672C\u4EBA\u6388\u6743" }),
1817
+ view?.activation_pending && active.length > 0 && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: finishExisting, children: "\u5148\u4F7F\u7528\u5DF2\u5F00\u901A\u80FD\u529B\uFF0C\u5176\u4ED6\u7A0D\u540E\u5904\u7406" }),
1818
+ /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => {
1819
+ setPage("select");
1820
+ start();
1821
+ }, children: "\u8865\u5145\u6388\u6743" })
1822
+ ] }) },
1823
+ ...hasConnection ? [{ id: "disable", description: "\u53EA\u5F71\u54CD\u6B64\u52A9\u624B\uFF0CSW \u4E2D\u7684\u6388\u6743\u548C\u6536\u6D88\u606F\u4FDD\u7559", label: view?.enabled === false ? "\u91CD\u65B0\u542F\u7528" : "\u5728\u6B64\u52A9\u624B\u4E2D\u505C\u7528", run: view?.enabled === false ? () => run("finish", { capabilities: view.selected_capabilities ?? selected, enable: true }) : disable, disabled: !onDisable && view?.enabled !== false, confirmation: { title: view?.enabled === false ? "\u91CD\u65B0\u542F\u7528\u98DE\u4E66\uFF1F" : "\u5728\u6B64\u52A9\u624B\u4E2D\u505C\u7528\u98DE\u4E66\uFF1F", description: "\u53EA\u5F71\u54CD\u6B64\u52A9\u624B\u4F7F\u7528\u98DE\u4E66\uFF0CSuperWork \u4E2D\u7684\u6388\u6743\u548C\u6D88\u606F\u63A5\u6536\u4FDD\u7559\u3002" } }] : [],
1824
+ { id: "diagnostics", description: "\u8BCA\u65AD\u4FE1\u606F\u3001\u6700\u8FD1\u4E8B\u4EF6\u548C\u65E5\u5FD7", label: "\u9047\u5230\u95EE\u9898\uFF1F", run: inspect, page: /* @__PURE__ */ jsxs5("div", { className: "space-y-4", children: [
1825
+ diagnosticContent,
1826
+ bindDelivery && view && canReceive(view) && subscription !== "paused" && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run("bind"), children: "\u66F4\u65B0\u52A9\u624B\u63A5\u6536\u5730\u5740" })
1827
+ ] }) },
1828
+ { id: "help", description: "\u67E5\u770B\u8FDE\u63A5\u548C\u4F7F\u7528\u8BF4\u660E", label: "\u4F7F\u7528\u5E2E\u52A9", page: /* @__PURE__ */ jsxs5("div", { className: "space-y-3", children: [
1829
+ /* @__PURE__ */ jsx6("p", { children: "\u53EF\u4EE5\u8BA9\u52A9\u624B\u6536\u53D1\u6D88\u606F\u3001\u67E5\u770B\u65E5\u7A0B\u548C\u6587\u6863\u3002\u672A\u5F00\u901A\u7684\u6743\u9650\u4F1A\u5728\u7528\u5230\u65F6\u63D0\u793A\u4F60\u5904\u7406\u3002" }),
1830
+ /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => {
1831
+ setPage("select");
1832
+ start();
1833
+ }, children: "\u8865\u5145\u6388\u6743" })
1834
+ ] }) },
1835
+ ...view?.connection_id ? [{ id: "remove", description: "\u6E05\u9664 SW \u4E2D\u7684\u51ED\u636E\u5E76\u505C\u6B62\u6536\u6D88\u606F", label: "\u79FB\u9664\u8FDE\u63A5\u5E76\u91CD\u65B0\u8FDE\u63A5", danger: true, confirmation: { title: "\u786E\u8BA4\u79FB\u9664\u5F53\u524D\u98DE\u4E66\u8FDE\u63A5\uFF1F", description: "SuperWork \u4E2D\u6B64\u8FDE\u63A5\u7684\u51ED\u636E\u5C06\u88AB\u79FB\u9664\uFF0C\u6D88\u606F\u63A5\u6536\u548C\u8F6C\u53D1\u5C06\u505C\u6B62\uFF0C\u5176\u4ED6\u4F9D\u8D56\u6B64\u8FDE\u63A5\u7684\u52A9\u624B\u4E5F\u4F1A\u53D7\u5F71\u54CD\u3002\u5386\u53F2\u6D88\u606F\u4E0E\u6392\u67E5\u65E5\u5FD7\u4F1A\u4FDD\u7559\uFF0C\u98DE\u4E66\u540E\u53F0\u5E94\u7528\u4E0D\u4F1A\u5220\u9664\u3002" }, run: () => removeConnection(view.connection_id) }] : [],
1836
+ ...detail.actions ?? []
1837
+ ];
1838
+ return /* @__PURE__ */ jsxs5(
1839
+ ConnectorDetail,
1840
+ {
1841
+ title: detail.title,
1842
+ icon: detail.icon,
1843
+ account: view?.label || "\u8FDE\u63A5\u540E\uFF0C\u52A9\u624B\u53EF\u4EE5\u5E2E\u4F60\u5904\u7406\u6D88\u606F\u3001\u65E5\u7A0B\u548C\u6587\u6863\u3002",
1844
+ connected: hasConnection && !waiting && page !== "select" && !view?.activation_pending,
1845
+ status: needsAttention ? "attention" : hasConnection ? "connected" : "disconnected",
1846
+ statusLabel: view?.enabled === false && hasConnection ? "\u5DF2\u505C\u7528" : void 0,
1847
+ busy,
1848
+ actions,
1849
+ noticeStorageKey: view && missingApp.length ? permissionNoticeKey(detail.name ?? "connector.builtin.feishu", view, missingApp) : void 0,
1850
+ noticeTitle: view?.enabled === false ? "\u5DF2\u5728\u6B64\u52A9\u624B\u4E2D\u505C\u7528" : missingApp.length ? `\u6709 ${missingApp.length} \u9879\u6743\u9650\u9700\u8981\u7BA1\u7406\u5458\u5728\u98DE\u4E66\u5F00\u901A` : "\u6709\u6388\u6743\u4E8B\u9879\u9700\u8981\u5904\u7406",
1851
+ noticeCollapsedTitle: view?.enabled === false ? "\u5DF2\u5728\u6B64\u52A9\u624B\u4E2D\u505C\u7528" : missingApp.length ? `${missingApp.length} \u9879\u6743\u9650\u5F85\u7BA1\u7406\u5458\u5F00\u901A` : "\u6709\u6388\u6743\u4E8B\u9879\u9700\u8981\u5904\u7406",
1852
+ notice: hasConnection && needsAttention && !waiting ? /* @__PURE__ */ jsxs5(Fragment, { children: [
1853
+ /* @__PURE__ */ jsx6("p", { children: view?.error?.message || "\u4E0D\u5F71\u54CD\u5DF2\u5F00\u901A\u7684\u529F\u80FD\uFF0C\u7528\u5230\u76F8\u5173\u64CD\u4F5C\u65F6\u52A9\u624B\u4F1A\u63D0\u793A\u4F60\u5904\u7406\u3002" }),
1854
+ view?.error?.next_action && /* @__PURE__ */ jsx6("p", { children: view.error.next_action }),
1855
+ permissionActions,
1856
+ missingApp.length > 0 && /* @__PURE__ */ jsxs5("details", { className: "text-xs opacity-70", children: [
1857
+ /* @__PURE__ */ jsx6("summary", { className: "cursor-pointer", children: "\u67E5\u770B\u662F\u54EA\u4E9B\u6743\u9650" }),
1858
+ /* @__PURE__ */ jsx6("ul", { className: "mt-2 space-y-1", children: missingApp.map((item) => /* @__PURE__ */ jsx6("li", { className: "break-all", children: item.name || item.scope }, `${item.identity}:${item.scope}`)) })
1859
+ ] })
1860
+ ] }) : void 0,
1861
+ connection: /* @__PURE__ */ jsxs5(Fragment, { children: [
1862
+ !view && /* @__PURE__ */ jsxs5(Fragment, { children: [
1863
+ /* @__PURE__ */ jsx6("output", { children: error || "\u6B63\u5728\u8BFB\u53D6\u98DE\u4E66\u8FDE\u63A5\u2026" }),
1864
+ error && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void refresh(), children: "\u91CD\u65B0\u8BFB\u53D6\u8FDE\u63A5" })
1865
+ ] }),
1866
+ page === "select" && !waiting ? /* @__PURE__ */ jsxs5("div", { className: "space-y-4 rounded-[20px] border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-5", children: [
1867
+ /* @__PURE__ */ jsx6("h3", { className: "text-base font-medium", children: "\u8FDE\u63A5\u98DE\u4E66" }),
1868
+ authorizationContent
1869
+ ] }) : authorizationContent
1870
+ ] }),
1871
+ tabs: [{ id: "rules", label: "\u4F7F\u7528\u89C4\u5219", content: detail.rules }, ...bindDelivery ? [{ id: "push", label: "\u6D88\u606F\u63A8\u9001", content: /* @__PURE__ */ jsxs5("div", { className: "settings-surface space-y-4 rounded-[22px] p-5", style: { background: "var(--settings-surface, hsl(var(--muted)))" }, children: [
1872
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-4", children: [
1873
+ /* @__PURE__ */ jsxs5("div", { className: "min-w-0", children: [
1874
+ /* @__PURE__ */ jsx6("p", { className: "font-medium", children: "\u5411\u52A9\u624B\u63A8\u9001\u98DE\u4E66\u6D88\u606F" }),
1875
+ /* @__PURE__ */ jsx6("p", { className: "mt-1 text-xs opacity-70", children: "\u6682\u505C\u540E SW \u4ECD\u63A5\u6536\u5E76\u4FDD\u5B58\u6D88\u606F\uFF0C\u53EA\u662F\u4E0D\u8F6C\u7ED9\u52A9\u624B\u3002" })
1876
+ ] }),
1877
+ /* @__PURE__ */ jsx6(Switch, { "aria-label": "\u5411\u52A9\u624B\u63A8\u9001", checked: subscription === "enabled", disabled: busy, onCheckedChange: (checked) => void run(checked ? subscription === "paused" ? "resume" : "bind" : "pause"), className: "relative inline-flex h-6 w-11 shrink-0 items-center rounded-full bg-[color-mix(in_srgb,currentColor_20%,transparent)] transition-colors after:absolute after:-inset-y-2 after:-inset-x-1 data-[state=checked]:bg-[var(--color-accent,hsl(var(--primary)))] disabled:opacity-50", thumbClassName: "pointer-events-none block size-5 translate-x-0.5 rounded-full bg-white shadow-sm transition-transform data-[state=checked]:translate-x-[22px]" })
1878
+ ] }),
1879
+ detail.pushFrequency,
1880
+ detail.onOpenPush && /* @__PURE__ */ jsx6("button", { type: "button", className: "block min-h-10 text-xs underline", onClick: detail.onOpenPush, children: "\u524D\u5F80\u63A8\u9001\u63A5\u53E3" })
1881
+ ] }) }] : [], ...detail.preferences ? [{ id: "preferences", label: "\u52A9\u624B\u504F\u597D", content: detail.preferences }] : []],
1882
+ children: [
1883
+ notice && /* @__PURE__ */ jsx6("output", { className: "block text-xs", children: notice }),
1884
+ error && /* @__PURE__ */ jsx6("p", { role: "alert", children: error })
1885
+ ]
1886
+ },
1887
+ waiting ? "waiting" : page === "select" ? "select" : "details"
1888
+ );
1889
+ }
1890
+ return /* @__PURE__ */ jsxs5("section", { "aria-label": "\u98DE\u4E66\u6388\u6743", "aria-busy": busy, className: "space-y-5 py-3 text-left", children: [
1891
+ /* @__PURE__ */ jsxs5("div", { children: [
1892
+ /* @__PURE__ */ jsx6("h3", { className: "text-lg font-medium", children: page === "manage" ? "\u7BA1\u7406\u98DE\u4E66\u8FDE\u63A5" : page === "help" ? "\u8FDE\u63A5\u5E2E\u52A9" : page === "select" ? "\u8FDE\u63A5\u98DE\u4E66" : "\u98DE\u4E66" }),
1893
+ /* @__PURE__ */ jsx6("p", { className: "mt-1 text-xs opacity-70", children: "\u6309\u98DE\u4E66\u5B98\u65B9\u63A8\u8350\u6743\u9650\u8FDE\u63A5\uFF0C\u5177\u4F53\u5F00\u901A\u7ED3\u679C\u7531\u4F01\u4E1A\u89C4\u5219\u548C\u672C\u4EBA\u6388\u6743\u51B3\u5B9A\u3002" })
1894
+ ] }),
1895
+ notice && /* @__PURE__ */ jsx6("output", { className: "block rounded-lg border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-3 text-sm", children: notice }),
1896
+ error && /* @__PURE__ */ jsx6("p", { role: "alert", className: "rounded-lg border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-3 text-sm", children: error }),
1897
+ view?.error && /* @__PURE__ */ jsxs5("div", { role: "alert", className: "space-y-1 rounded-lg border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-3 text-sm", children: [
1898
+ /* @__PURE__ */ jsx6("p", { children: view.error.message }),
1899
+ view.error.next_action && /* @__PURE__ */ jsx6("p", { children: view.error.next_action }),
1900
+ !waiting && view.app_id && /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap gap-3", children: [
1901
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: retryCurrent, children: "\u91CD\u8BD5\u5F53\u524D\u6388\u6743" }),
1902
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: finishExisting, children: "\u5148\u4F7F\u7528\u5DF2\u5F00\u901A\u80FD\u529B\uFF0C\u5176\u4ED6\u7A0D\u540E\u5904\u7406" })
1903
+ ] })
1904
+ ] }),
1905
+ view && !waiting && matchesRequestedAuthorization(view) && /* @__PURE__ */ jsx6(ConnectorAuthorizationProgress, { result: view.authorization_result, onCheck: () => void run("check"), busy }),
1906
+ view && !waiting && page !== "help" && /* @__PURE__ */ jsx6(FeishuPermissionStatus, { permissions: view.permissions ?? [], template: view.permission_template }),
1907
+ !view && !error && /* @__PURE__ */ jsx6("output", { className: "block text-sm", children: "\u6B63\u5728\u8BFB\u53D6\u98DE\u4E66\u8FDE\u63A5\u2026" }),
1908
+ !view && error && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void refresh(), children: "\u91CD\u65B0\u8BFB\u53D6\u8FDE\u63A5" }),
1909
+ authorizationContent,
1910
+ view && !waiting && page === "connection" ? /* @__PURE__ */ jsxs5(Fragment, { children: [
1911
+ /* @__PURE__ */ jsxs5("div", { className: "rounded-xl border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-4", children: [
1912
+ /* @__PURE__ */ jsxs5("p", { className: "font-medium", children: [
1913
+ view.activation_pending === true ? "\u8FDE\u63A5\u5C1A\u672A\u5B8C\u6210" : view.enabled === false && view.app_id ? "\u5DF2\u5728\u6B64\u52A9\u624B\u4E2D\u505C\u7528" : active.length ? "\u98DE\u4E66\u5DF2\u53EF\u4EE5\u4F7F\u7528" : "\u8FD8\u6709\u9879\u76EE\u9700\u8981\u5904\u7406",
1914
+ view.label ? ` \xB7 ${view.label}` : ""
1915
+ ] }),
1916
+ /* @__PURE__ */ jsx6("p", { className: "mt-1 text-xs opacity-70", children: view.activation_pending === true ? "\u5B8C\u6210\u6388\u6743\u540E\u5373\u53EF\u5F00\u59CB\u4F7F\u7528" : view.enabled === false ? "\u5DF2\u6709\u6388\u6743\u4E0E SuperWork \u63A5\u6536\u8BBE\u7F6E\u4FDD\u7559\u3002" : "\u53EF\u4EE5\u8BA9\u52A9\u624B\u5904\u7406\u5DF2\u5F00\u901A\u7684\u98DE\u4E66\u5DE5\u4F5C\u3002" })
1917
+ ] }),
1918
+ view.activation_pending === true && active.length > 0 && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: finishExisting, children: "\u5148\u4F7F\u7528\u5DF2\u5F00\u901A\u80FD\u529B\uFF0C\u5176\u4ED6\u7A0D\u540E\u5904\u7406" }),
1919
+ pending.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "space-y-2 rounded-xl border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-4 text-sm", children: [
1920
+ /* @__PURE__ */ jsxs5("p", { children: [
1921
+ pending.length,
1922
+ " \u9879\u5C1A\u672A\u5B8C\u6210\uFF0C\u5176\u4ED6\u5DF2\u5F00\u901A\u80FD\u529B\u7EE7\u7EED\u4FDD\u7559\u3002"
1923
+ ] }),
1924
+ /* @__PURE__ */ jsxs5("details", { className: "text-xs", children: [
1925
+ /* @__PURE__ */ jsx6("summary", { className: "cursor-pointer", children: "\u67E5\u770B\u672A\u5B8C\u6210\u9879\u76EE" }),
1926
+ /* @__PURE__ */ jsx6("div", { className: "mt-2 max-h-60 space-y-2 overflow-y-auto", children: pending.map((item) => /* @__PURE__ */ jsxs5("p", { children: [
1927
+ item.name,
1928
+ "\uFF1A",
1929
+ item.reason || item.next_action || statusLabels[item.status]
1930
+ ] }, item.id)) })
1931
+ ] }),
1932
+ receptionNeedsTest && /* @__PURE__ */ jsx6("p", { className: "text-xs", children: "\u63A5\u6536\u6743\u9650\u5DF2\u7ECF\u751F\u6548\uFF0C\u4ECD\u9700\u5411\u673A\u5668\u4EBA\u53D1\u9001\u6D4B\u8BD5\u6D88\u606F\u4EE5\u786E\u8BA4\u5B9E\u9645\u63A5\u6536\u3002" }),
1933
+ pendingPermissions.length > 0 && /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: () => start(pendingPermissions.map((item) => item.id)), children: "\u7EE7\u7EED\u5F00\u901A\u672A\u5B8C\u6210\u7684\u6743\u9650" }),
1934
+ failedUser.length > 0 && /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline", disabled: busy, onClick: () => start(failedUser.map((item) => item.id)), children: "\u4EC5\u8865\u5145\u672A\u5B8C\u6210\u7684\u672C\u4EBA\u6388\u6743" })
1935
+ ] }),
1936
+ /* @__PURE__ */ jsxs5("dl", { className: "divide-y divide-[color-mix(in_srgb,currentColor_18%,transparent)] rounded-xl border border-[color-mix(in_srgb,currentColor_18%,transparent)] px-4 text-sm", children: [
1937
+ /* @__PURE__ */ jsxs5("div", { className: "flex justify-between gap-3 py-4", children: [
1938
+ /* @__PURE__ */ jsx6("dt", { children: "\u53D1\u9001\u6D88\u606F" }),
1939
+ /* @__PURE__ */ jsx6("dd", { children: "\u673A\u5668\u4EBA\u8EAB\u4EFD" })
1940
+ ] }),
1941
+ /* @__PURE__ */ jsxs5("div", { className: "flex justify-between gap-3 py-4", children: [
1942
+ /* @__PURE__ */ jsx6("dt", { children: "\u63A5\u6536\u98DE\u4E66\u6D88\u606F" }),
1943
+ /* @__PURE__ */ jsx6("dd", { children: subscription === "enabled" ? "\u5DF2\u63A5\u5165\u52A9\u624B" : subscription === "paused" ? "\u5411\u52A9\u624B\u63A8\u9001\u5DF2\u6682\u505C" : "\u5C1A\u672A\u63A5\u5165\u52A9\u624B" })
1944
+ ] }),
1945
+ /* @__PURE__ */ jsxs5("div", { className: "flex justify-between gap-3 py-4", children: [
1946
+ /* @__PURE__ */ jsx6("dt", { children: "\u5DF2\u5F00\u901A\u7684\u5DE5\u4F5C\u80FD\u529B" }),
1947
+ /* @__PURE__ */ jsxs5("dd", { children: [
1948
+ categories.length,
1949
+ " \u7C7B \xB7 ",
1950
+ active.length,
1951
+ " \u9879\u64CD\u4F5C"
1952
+ ] })
1953
+ ] })
1954
+ ] }),
1955
+ /* @__PURE__ */ jsx6("div", { className: "flex flex-wrap gap-2", children: categories.map((name) => /* @__PURE__ */ jsx6("span", { className: "rounded-md border border-[color-mix(in_srgb,currentColor_18%,transparent)] px-2 py-1 text-xs", children: name }, name)) }),
1956
+ /* @__PURE__ */ jsxs5("details", { className: "text-sm", children: [
1957
+ /* @__PURE__ */ jsx6("summary", { className: "cursor-pointer", children: "\u67E5\u770B\u6743\u9650\u4E0E\u80FD\u529B\u72B6\u6001" }),
1958
+ /* @__PURE__ */ jsx6(FeishuCapabilitySelection, { capabilities, permissions: view.permissions, operations: view.operations, domains: view.domains, selected, onChange: setSelected, disabled: busy })
1959
+ ] }),
1960
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap gap-3 border-t border-[color-mix(in_srgb,currentColor_18%,transparent)] pt-4", children: [
1961
+ /* @__PURE__ */ jsx6("button", { type: "button", className: `${button} bg-blue-600 text-white`, disabled: busy, onClick: () => void addCapabilities(), children: busy ? "\u6B63\u5728\u68C0\u67E5\u2026" : "\u8865\u5145\u6388\u6743" }),
1962
+ /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => setPage("manage"), children: "\u7BA1\u7406\u8FDE\u63A5" })
1963
+ ] })
1964
+ ] }) : view && page === "manage" ? /* @__PURE__ */ jsxs5(Fragment, { children: [
1965
+ back,
1966
+ /* @__PURE__ */ jsxs5("div", { className: "space-y-5 divide-y divide-[color-mix(in_srgb,currentColor_18%,transparent)] rounded-xl border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-4 text-sm", children: [
1967
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-4", children: [
1968
+ /* @__PURE__ */ jsxs5("div", { children: [
1969
+ /* @__PURE__ */ jsx6("p", { children: "\u5728\u6B64\u52A9\u624B\u4E2D\u4F7F\u7528\u98DE\u4E66" }),
1970
+ /* @__PURE__ */ jsx6("p", { className: "mt-1 text-xs opacity-70", children: "\u505C\u7528\u53EA\u5F71\u54CD\u6B64\u52A9\u624B\uFF0CSuperWork \u6388\u6743\u548C\u6D88\u606F\u63A5\u6536\u4FDD\u7559\u3002" })
1971
+ ] }),
1972
+ view.enabled === false ? /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run("finish", { capabilities: view.selected_capabilities ?? selected, enable: true }), children: "\u91CD\u65B0\u542F\u7528" }) : onDisable ? /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: async () => {
1973
+ if (inFlight.current) return;
1974
+ inFlight.current = true;
1975
+ setBusy(true);
1976
+ try {
1977
+ await callbacks.current.onDisable?.();
1978
+ const value = await callbacks.current.read();
1979
+ if (live.current) accept(value);
1980
+ await changed();
1981
+ } catch {
1982
+ if (live.current) setError("\u505C\u7528\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002");
1983
+ } finally {
1984
+ inFlight.current = false;
1985
+ if (live.current) setBusy(false);
1986
+ }
1987
+ }, children: "\u505C\u7528\u6B64\u52A9\u624B\u8FDE\u63A5" }) : /* @__PURE__ */ jsx6("span", { className: "text-xs", children: "\u5DF2\u542F\u7528" })
1988
+ ] }),
1989
+ /* @__PURE__ */ jsxs5("div", { className: "space-y-2 pt-4", children: [
1990
+ /* @__PURE__ */ jsx6("p", { children: "\u5411\u52A9\u624B\u63A8\u9001\u98DE\u4E66\u6D88\u606F" }),
1991
+ /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: "\u4E0E\u6B64\u52A9\u624B\u4F7F\u7528\u6743\u9650\u5206\u522B\u7BA1\u7406\uFF1B\u6682\u505C\u63A8\u9001\u4ECD\u4FDD\u7559 SuperWork \u4E2D\u7684\u6388\u6743\u548C\u6D88\u606F\u63A5\u6536\u3002" }),
1992
+ ["enabled", "paused"].includes(subscription) && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run(subscription === "paused" ? "resume" : "pause"), children: subscription === "paused" ? "\u6062\u590D\u5411\u52A9\u624B\u63A8\u9001" : "\u6682\u505C\u5411\u52A9\u624B\u63A8\u9001" }),
1993
+ bindDelivery && canReceive(view) && subscription !== "paused" && /* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: busy, onClick: () => void run("bind"), children: subscription === "enabled" ? "\u66F4\u65B0\u52A9\u624B\u63A5\u6536\u5730\u5740" : "\u91CD\u65B0\u63A5\u5165\u52A9\u624B\u6D88\u606F" }),
1994
+ receptionNeedsTest && /* @__PURE__ */ jsx6("p", { className: "text-xs", children: "\u63A5\u6536\u6743\u9650\u5DF2\u6838\u9A8C\uFF0C\u4E8B\u4EF6\u8BA2\u9605\u5C1A\u5F85\u6D4B\u8BD5\u3002\u8BF7\u5411\u673A\u5668\u4EBA\u53D1\u9001\u6D4B\u8BD5\u6D88\u606F\u540E\u5728\u8FDE\u63A5\u5E2E\u52A9\u4E2D\u67E5\u770B\u8BB0\u5F55\u3002" })
1995
+ ] }),
1996
+ /* @__PURE__ */ jsxs5("div", { className: "pt-4", children: [
1997
+ /* @__PURE__ */ jsx6("p", { children: view.label || "\u98DE\u4E66\u8D26\u53F7" }),
1998
+ /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: "\u5DF2\u5F00\u901A\u80FD\u529B\u4E0E\u65B0\u589E\u6388\u6743\u5747\u53D7\u98DE\u4E66\u5E94\u7528\u53EF\u7528\u8303\u56F4\u548C\u6570\u636E\u6743\u9650\u9650\u5236\u3002" }),
1999
+ /* @__PURE__ */ jsx6("button", { type: "button", className: "mt-2 text-xs underline", disabled: busy, onClick: () => void addCapabilities(), children: "\u67E5\u770B\u4E0E\u6DFB\u52A0\u5DE5\u4F5C\u80FD\u529B" })
2000
+ ] })
2001
+ ] }),
2002
+ view.connection_id && /* @__PURE__ */ jsxs5("div", { className: "space-y-3 rounded-xl border border-red-600/30 p-4 text-sm", children: [
2003
+ /* @__PURE__ */ jsx6("p", { className: "font-medium", children: "\u79FB\u9664\u65E7\u8FDE\u63A5\uFF0C\u91CD\u65B0\u5F00\u59CB" }),
2004
+ /* @__PURE__ */ jsx6("p", { className: "text-xs opacity-70", children: "\u8FD9\u4F1A\u79FB\u9664 SuperWork \u4E2D\u6B64\u8FDE\u63A5\u7684\u51ED\u636E\u5E76\u505C\u6B62\u63A5\u6536\u548C\u8F6C\u53D1\u6D88\u606F\uFF0C\u5176\u4ED6\u4F9D\u8D56\u6B64\u8FDE\u63A5\u7684\u52A9\u624B\u4E5F\u4F1A\u53D7\u5230\u5F71\u54CD\u3002\u5386\u53F2\u6D88\u606F\u4E0E\u6392\u67E5\u65E5\u5FD7\u4FDD\u7559\uFF0C\u98DE\u4E66\u540E\u53F0\u5E94\u7528\u4E0D\u4F1A\u5220\u9664\u3002" }),
2005
+ /* @__PURE__ */ jsxs5(AlertDialog, { open: removingConnectionID !== null, onOpenChange: (open) => {
2006
+ if (!open) setRemovingConnectionID(null);
2007
+ }, children: [
2008
+ /* @__PURE__ */ jsx6(AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx6("button", { type: "button", className: `${button} border-red-600/40 text-red-600`, disabled: busy, onClick: () => setRemovingConnectionID(view.connection_id ?? null), children: "\u79FB\u9664\u8FDE\u63A5\u5E76\u91CD\u65B0\u8FDE\u63A5" }) }),
2009
+ /* @__PURE__ */ jsxs5(AlertDialogContent, { className: "z-[60] w-[calc(100%_-_32px)] max-w-md p-5 sm:max-w-md", overlayClassName: "z-[60] bg-black/40", style: { backgroundColor: "var(--color-canvas, hsl(var(--popover, 0 0% 100%)))", color: "var(--color-copy, hsl(var(--foreground, 0 0% 10%)))" }, children: [
2010
+ /* @__PURE__ */ jsx6(AlertDialogTitle, { children: "\u786E\u8BA4\u79FB\u9664\u5F53\u524D\u98DE\u4E66\u8FDE\u63A5\uFF1F" }),
2011
+ /* @__PURE__ */ jsx6(AlertDialogDescription, { children: "SuperWork \u4E2D\u6B64\u8FDE\u63A5\u7684\u51ED\u636E\u5C06\u88AB\u79FB\u9664\uFF0C\u6D88\u606F\u63A5\u6536\u548C\u8F6C\u53D1\u5C06\u505C\u6B62\uFF0C\u5176\u4ED6\u4F9D\u8D56\u6B64\u8FDE\u63A5\u7684\u52A9\u624B\u4E5F\u4F1A\u53D7\u5F71\u54CD\u3002\u5386\u53F2\u6D88\u606F\u4E0E\u6392\u67E5\u65E5\u5FD7\u4F1A\u4FDD\u7559\uFF0C\u98DE\u4E66\u540E\u53F0\u5E94\u7528\u4E0D\u4F1A\u5220\u9664\u3002\u79FB\u9664\u540E\uFF0C\u7531\u4F60\u518D\u6B21\u70B9\u51FB\u201C\u8FDE\u63A5\u98DE\u4E66\u201D\u83B7\u53D6\u65B0\u4E8C\u7EF4\u7801\u3002" }),
2012
+ /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap justify-end gap-3", children: [
2013
+ /* @__PURE__ */ jsx6(AlertDialogCancel, { asChild: true, children: /* @__PURE__ */ jsx6("button", { type: "button", className: button, children: "\u53D6\u6D88" }) }),
2014
+ /* @__PURE__ */ jsx6(AlertDialogAction, { asChild: true, children: /* @__PURE__ */ jsx6("button", { type: "button", className: `${button} border-red-600 bg-red-600 text-white`, onClick: () => {
2015
+ if (removingConnectionID) void removeConnection(removingConnectionID);
2016
+ }, children: "\u786E\u8BA4\u79FB\u9664\u8FDE\u63A5" }) })
2017
+ ] })
2018
+ ] })
2019
+ ] })
2020
+ ] })
2021
+ ] }) : view && page === "help" ? /* @__PURE__ */ jsxs5(Fragment, { children: [
2022
+ back,
2023
+ diagnosticContent
2024
+ ] }) : null,
2025
+ !waiting && page !== "help" && /* @__PURE__ */ jsx6("button", { type: "button", className: "text-xs underline opacity-70", disabled: busy, onClick: () => setPage("help"), children: "\u9047\u5230\u95EE\u9898\uFF1F" })
2026
+ ] });
2027
+ }
2028
+
2029
+ // src/components/ManagedConnection.tsx
2030
+ import { useEffect as useEffect2, useId, useRef as useRef2, useState as useState2 } from "react";
2031
+
2032
+ // ../ui/src/components/badge.tsx
2033
+ import { jsx as jsx7 } from "react/jsx-runtime";
2034
+ var badgeVariants = cva(
2035
+ "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
2036
+ {
2037
+ variants: {
2038
+ variant: {
2039
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
2040
+ secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
2041
+ destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
2042
+ outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
2043
+ ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
2044
+ link: "text-primary underline-offset-4 hover:underline"
2045
+ }
2046
+ },
2047
+ defaultVariants: {
2048
+ variant: "default"
2049
+ }
2050
+ }
2051
+ );
2052
+ function Badge({
2053
+ className,
2054
+ variant = "default",
2055
+ asChild = false,
2056
+ ...props
2057
+ }) {
2058
+ const Comp = asChild ? dist_exports.Root : "span";
2059
+ return /* @__PURE__ */ jsx7(
2060
+ Comp,
2061
+ {
2062
+ "data-slot": "badge",
2063
+ "data-variant": variant,
2064
+ className: cn(badgeVariants({ variant }), className),
2065
+ ...props
2066
+ }
2067
+ );
2068
+ }
2069
+
2070
+ // ../ui/src/components/input.tsx
2071
+ import { jsx as jsx8 } from "react/jsx-runtime";
2072
+ function Input({ className, type, ...props }) {
2073
+ return /* @__PURE__ */ jsx8(
2074
+ "input",
2075
+ {
2076
+ type,
2077
+ "data-slot": "input",
2078
+ className: cn(
2079
+ "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
2080
+ className
2081
+ ),
2082
+ ...props
2083
+ }
2084
+ );
2085
+ }
2086
+
2087
+ // ../ui/src/components/label.tsx
2088
+ import { jsx as jsx9 } from "react/jsx-runtime";
2089
+ function Label({
2090
+ className,
2091
+ ...props
2092
+ }) {
2093
+ return /* @__PURE__ */ jsx9(
2094
+ dist_exports2.Root,
2095
+ {
2096
+ "data-slot": "label",
2097
+ className: cn(
2098
+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
2099
+ className
2100
+ ),
2101
+ ...props
2102
+ }
2103
+ );
2104
+ }
2105
+
2106
+ // ../ui/src/components/separator.tsx
2107
+ import { jsx as jsx10 } from "react/jsx-runtime";
2108
+ function Separator({
2109
+ className,
2110
+ orientation = "horizontal",
2111
+ decorative = true,
2112
+ ...props
2113
+ }) {
2114
+ return /* @__PURE__ */ jsx10(
2115
+ dist_exports3.Root,
2116
+ {
2117
+ "data-slot": "separator",
2118
+ decorative,
2119
+ orientation,
2120
+ className: cn(
2121
+ "shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
2122
+ className
2123
+ ),
2124
+ ...props
2125
+ }
2126
+ );
2127
+ }
2128
+
2129
+ // src/components/ManagedConnection.tsx
2130
+ import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
2131
+ var field = "h-10 focus-visible:ring-1 focus-visible:ring-foreground/30 focus-visible:border-foreground/70";
2132
+ var deliveryFailure = (reason) => `\u90AE\u7BB1\u5DF2\u8FDE\u63A5\uFF0C\u63A5\u5165\u52A9\u624B\u6D88\u606F\u672A\u5B8C\u6210${reason ? `\uFF1A${reason}` : "\uFF0C\u53EF\u70B9\u51FB\u91CD\u8BD5\u3002"}`;
2133
+ function ManagedConnection({ read, act, onChanged, bindDelivery, onDisable, detail, diagnostics }) {
2134
+ const [view, setView] = useState2(null);
2135
+ const [busy, setBusy] = useState2(true);
2136
+ const [failure, setFailure] = useState2("");
2137
+ const [email, setEmail] = useState2("");
2138
+ const [code, setCode] = useState2("");
2139
+ const [diagnosticView, setDiagnosticView] = useState2(null);
2140
+ const [editing, setEditing] = useState2(false);
2141
+ const formId = useId();
2142
+ const callbacks = useRef2({ read, act, onChanged, onDisable });
2143
+ callbacks.current = { read, act, onChanged, onDisable };
2144
+ const alive = useRef2(false);
2145
+ useEffect2(() => {
2146
+ alive.current = true;
2147
+ let cancelled = false;
2148
+ callbacks.current.read().then((value) => {
2149
+ if (!cancelled) {
2150
+ setView(value);
2151
+ setFailure(value.error?.message || "");
2152
+ }
2153
+ }).catch(() => {
2154
+ if (!cancelled) setFailure("\u8FDE\u63A5\u72B6\u6001\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u8BD5");
2155
+ }).finally(() => {
2156
+ if (!cancelled) setBusy(false);
2157
+ });
2158
+ return () => {
2159
+ cancelled = true;
2160
+ alive.current = false;
2161
+ };
2162
+ }, []);
2163
+ const perform = async (action) => {
2164
+ if (busy) return;
2165
+ setBusy(true);
2166
+ setFailure("");
2167
+ try {
2168
+ let next;
2169
+ if (action === "disable") {
2170
+ await callbacks.current.onDisable?.();
2171
+ next = await callbacks.current.read();
2172
+ } else if (action === "refresh") next = await callbacks.current.read();
2173
+ else next = await callbacks.current.act(action, {
2174
+ ...view?.connection_id ? { expected_connection_id: view.connection_id } : {},
2175
+ ...action === "finish" ? { enable: true } : {},
2176
+ ...action === "credentials" ? { email: email.trim(), authorization_code: code } : {}
2177
+ });
2178
+ if (!alive.current) return;
2179
+ if (action === "bind" && next.error) {
2180
+ setFailure(deliveryFailure(next.error.message));
2181
+ return;
2182
+ }
2183
+ if (next.connection_id !== view?.connection_id) setDiagnosticView(null);
2184
+ setView(next);
2185
+ if (next.error) setFailure(next.error.message);
2186
+ else if (action === "credentials" && next.connected) {
2187
+ setEmail("");
2188
+ setCode("");
2189
+ setEditing(false);
2190
+ if (bindDelivery && next.subscription_state !== "paused" && !next.delivery_bound) {
2191
+ try {
2192
+ const bound = await callbacks.current.act("bind", { expected_connection_id: next.connection_id });
2193
+ if (!alive.current) return;
2194
+ if (bound.error) {
2195
+ setFailure(deliveryFailure(bound.error.message));
2196
+ return;
2197
+ }
2198
+ setView(bound);
2199
+ } catch (error) {
2200
+ if (!alive.current) return;
2201
+ setFailure(deliveryFailure(error instanceof Error ? error.message : void 0));
2202
+ return;
2203
+ }
2204
+ }
2205
+ }
2206
+ await callbacks.current.onChanged();
2207
+ } catch (error) {
2208
+ if (alive.current) setFailure(action === "bind" ? deliveryFailure(error instanceof Error ? error.message : void 0) : error instanceof Error ? error.message : "\u64CD\u4F5C\u5C1A\u672A\u5B8C\u6210\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5");
2209
+ } finally {
2210
+ if (alive.current) setBusy(false);
2211
+ }
2212
+ };
2213
+ const showForm = view && (!view.connected || editing);
2214
+ const brand = view?.provider === "netease-mail" ? "\u7F51\u6613\u90AE\u7BB1" : "QQ \u90AE\u7BB1";
2215
+ const paused = view?.subscription_state === "paused";
2216
+ const connectionForm = showForm && /* @__PURE__ */ jsxs6("form", { className: "space-y-4", "aria-label": `\u8FDE\u63A5${brand}`, onSubmit: (event) => {
2217
+ event.preventDefault();
2218
+ void perform("credentials");
2219
+ }, children: [
2220
+ /* @__PURE__ */ jsxs6("div", { className: "space-y-2", children: [
2221
+ /* @__PURE__ */ jsx11(Label, { htmlFor: `${formId}-email`, children: "\u90AE\u7BB1\u5730\u5740" }),
2222
+ /* @__PURE__ */ jsx11(Input, { className: field, id: `${formId}-email`, type: "email", autoComplete: "username", placeholder: view.provider === "netease-mail" ? "\u4F8B\u5982 name@163.com" : "\u4F8B\u5982 name@qq.com", maxLength: 254, required: true, disabled: busy, value: email, onChange: (event) => setEmail(event.target.value) })
2223
+ ] }),
2224
+ /* @__PURE__ */ jsxs6("div", { className: "space-y-2", children: [
2225
+ /* @__PURE__ */ jsx11(Label, { htmlFor: `${formId}-code`, children: "\u6388\u6743\u7801" }),
2226
+ /* @__PURE__ */ jsx11(Input, { className: field, id: `${formId}-code`, type: "password", autoComplete: "off", placeholder: "\u586B\u5199\u90AE\u7BB1\u63D0\u4F9B\u7684\u6388\u6743\u7801", "aria-describedby": `${formId}-help`, maxLength: 256, required: true, disabled: busy, value: code, onChange: (event) => setCode(event.target.value) }),
2227
+ /* @__PURE__ */ jsxs6("details", { id: `${formId}-help`, className: "rounded-lg bg-[hsl(var(--muted)/0.5)] px-3 py-2.5 text-xs leading-relaxed text-muted-foreground", children: [
2228
+ /* @__PURE__ */ jsx11("summary", { className: "min-h-8 cursor-pointer font-medium text-foreground", children: "\u5982\u4F55\u83B7\u53D6\u6388\u6743\u7801" }),
2229
+ /* @__PURE__ */ jsxs6("ol", { className: "list-decimal space-y-1 pl-4", children: [
2230
+ /* @__PURE__ */ jsxs6("li", { children: [
2231
+ "\u5728\u7F51\u9875\u7248",
2232
+ brand,
2233
+ "\u4E2D\u6253\u5F00\u201C\u8BBE\u7F6E\u201D\u3002"
2234
+ ] }),
2235
+ /* @__PURE__ */ jsx11("li", { children: view.provider === "netease-mail" ? "\u8FDB\u5165\u201CPOP3/SMTP/IMAP\u201D\uFF0C\u5F00\u542F IMAP/SMTP \u670D\u52A1\u3002" : "\u8FDB\u5165\u201C\u8D26\u53F7\u201D\uFF0C\u5F00\u542F IMAP/SMTP \u670D\u52A1\u3002" }),
2236
+ /* @__PURE__ */ jsx11("li", { children: "\u6309\u90AE\u7BB1\u63D0\u793A\u751F\u6210\u6388\u6743\u7801\uFF0C\u590D\u5236\u5230\u4E0A\u65B9\u3002" })
2237
+ ] })
2238
+ ] })
2239
+ ] }),
2240
+ /* @__PURE__ */ jsxs6("div", { className: "space-y-2", children: [
2241
+ /* @__PURE__ */ jsx11(Button, { className: "w-full", type: "submit", disabled: busy || !email.trim() || !code.trim(), children: busy ? /* @__PURE__ */ jsxs6(Fragment2, { children: [
2242
+ /* @__PURE__ */ jsx11(LoaderCircle, { className: "animate-spin" }),
2243
+ "\u6B63\u5728\u8FDE\u63A5\u2026"
2244
+ ] }) : "\u8FDE\u63A5\u90AE\u7BB1" }),
2245
+ editing && /* @__PURE__ */ jsx11(Button, { className: "w-full", variant: "ghost", type: "button", disabled: busy, onClick: () => {
2246
+ setCode("");
2247
+ setEditing(false);
2248
+ setFailure("");
2249
+ }, children: "\u53D6\u6D88" })
2250
+ ] })
2251
+ ] });
2252
+ if (detail) {
2253
+ const actions = [
2254
+ ...view?.connected ? [{ id: "edit", description: "\u91CD\u65B0\u586B\u5199\u90AE\u7BB1\u5730\u5740\u548C\u6388\u6743\u7801", label: "\u66F4\u6362\u8D26\u53F7", confirmation: { title: "\u66F4\u6362\u8D26\u53F7\uFF1F", description: "\u5C06\u6253\u5F00\u8FDE\u63A5\u8868\u5355\u3002\u4FDD\u5B58\u65B0\u8D26\u53F7\u524D\uFF0C\u5F53\u524D\u8FDE\u63A5\u4FDD\u6301\u4E0D\u53D8\uFF1B\u66F4\u6362\u540E\u4F7F\u7528\u89C4\u5219\u4FDD\u7559\u3002" }, run: () => {
2255
+ setEmail(view.label || "");
2256
+ setFailure("");
2257
+ setEditing(true);
2258
+ } }] : [],
2259
+ { id: "check", description: "\u68C0\u67E5\u5F53\u524D\u8D26\u53F7\u7684\u8FDE\u63A5\u72B6\u6001", label: "\u91CD\u65B0\u6838\u9A8C", run: () => perform("check") },
2260
+ ...view?.connected && onDisable ? [{ id: "disable", description: "\u53EA\u5F71\u54CD\u6B64\u52A9\u624B\uFF0CSW \u4E2D\u7684\u6388\u6743\u548C\u6536\u6D88\u606F\u4FDD\u7559", label: view.enabled ? "\u5728\u6B64\u52A9\u624B\u4E2D\u505C\u7528" : "\u91CD\u65B0\u542F\u7528", confirmation: { title: view.enabled ? "\u5728\u6B64\u52A9\u624B\u4E2D\u505C\u7528\u90AE\u7BB1\uFF1F" : "\u91CD\u65B0\u542F\u7528\u90AE\u7BB1\uFF1F", description: "\u6B64\u64CD\u4F5C\u53EA\u5F71\u54CD\u52A9\u624B\u4F7F\u7528\u90AE\u7BB1\uFF0CSuperWork \u4E2D\u7684\u6388\u6743\u548C\u6D88\u606F\u63A5\u6536\u4FDD\u7559\u3002" }, run: () => perform(view.enabled ? "disable" : "finish") }] : [],
2261
+ { id: "diagnostics", description: "\u8BCA\u65AD\u4FE1\u606F\u548C\u6700\u8FD1\u9519\u8BEF", label: "\u9047\u5230\u95EE\u9898\uFF1F", run: async () => {
2262
+ if (view?.connection_id && diagnostics) {
2263
+ const next = await diagnostics();
2264
+ if (alive.current) setDiagnosticView(next);
2265
+ }
2266
+ }, page: /* @__PURE__ */ jsxs6("div", { className: "space-y-3", children: [
2267
+ /* @__PURE__ */ jsxs6("p", { children: [
2268
+ "\u8D26\u53F7\uFF1A",
2269
+ view?.label || "\u5C1A\u672A\u8FDE\u63A5"
2270
+ ] }),
2271
+ /* @__PURE__ */ jsxs6("p", { children: [
2272
+ "\u6392\u67E5\u7F16\u53F7\uFF1A",
2273
+ view?.error?.trace_id || view?.trace_id || "\u6682\u65E0\u8BB0\u5F55"
2274
+ ] }),
2275
+ view?.error && /* @__PURE__ */ jsx11("p", { children: view.error.message }),
2276
+ diagnosticView?.runtime && /* @__PURE__ */ jsx11(ConnectorRuntimeDiagnostics, { runtime: diagnosticView.runtime }),
2277
+ diagnosticView?.audit_events.map((event, index) => /* @__PURE__ */ jsx11("p", { children: event.message || "\u8FDE\u63A5\u72B6\u6001\u8BB0\u5F55" }, event.id ?? index)),
2278
+ bindDelivery && view?.connected && !paused && /* @__PURE__ */ jsx11(Button, { disabled: busy, onClick: () => void perform("bind"), children: "\u66F4\u65B0\u52A9\u624B\u63A5\u6536\u5730\u5740" })
2279
+ ] }) },
2280
+ { id: "help", description: "\u67E5\u770B\u8FDE\u63A5\u548C\u4F7F\u7528\u8BF4\u660E", label: "\u4F7F\u7528\u5E2E\u52A9", page: /* @__PURE__ */ jsx11("p", { children: "\u53EF\u4EE5\u8BA9\u52A9\u624B\u641C\u7D22\u3001\u9605\u8BFB\u548C\u6574\u7406\u90AE\u4EF6\u3002\u53D1\u9001\u90AE\u4EF6\u65F6\u4F1A\u9075\u5B88\u4F60\u8BBE\u7F6E\u7684\u4F7F\u7528\u89C4\u5219\u3002" }) },
2281
+ ...view?.connection_id ? [{ id: "remove", description: "\u6E05\u9664 SW \u4E2D\u7684\u51ED\u636E\u5E76\u505C\u6B62\u6536\u6D88\u606F", label: "\u79FB\u9664\u90AE\u7BB1\u8FDE\u63A5", danger: true, confirmation: { title: "\u79FB\u9664\u90AE\u7BB1\u8FDE\u63A5\uFF1F", description: "\u79FB\u9664\u540E\u5C06\u505C\u6B62\u63A5\u6536\u548C\u63A8\u9001\uFF0C\u5E76\u6E05\u9664\u5DF2\u4FDD\u5B58\u7684\u90AE\u7BB1\u5730\u5740\u548C\u6388\u6743\u7801\u3002\u5DF2\u6709\u6D88\u606F\u548C\u6587\u4EF6\u4FDD\u7559\u3002\u5176\u4ED6\u4F9D\u8D56\u6B64\u8FDE\u63A5\u7684\u52A9\u624B\u4E5F\u4F1A\u53D7\u5F71\u54CD\u3002" }, run: () => perform("remove") }] : [],
2282
+ ...detail.actions ?? []
2283
+ ];
2284
+ return /* @__PURE__ */ jsxs6("div", { className: "managed-mail-connection", children: [
2285
+ /* @__PURE__ */ jsx11(
2286
+ ConnectorDetail,
2287
+ {
2288
+ title: detail.title,
2289
+ icon: detail.icon,
2290
+ account: view?.label || "\u8FDE\u63A5\u540E\uFF0C\u52A9\u624B\u53EF\u4EE5\u5E2E\u4F60\u5904\u7406\u90AE\u4EF6\u3002",
2291
+ connected: Boolean(view?.connected),
2292
+ status: failure || view?.connected && !view.enabled ? "attention" : view?.connected ? "connected" : "disconnected",
2293
+ statusLabel: view?.connected && !view.enabled ? "\u5DF2\u505C\u7528" : void 0,
2294
+ busy,
2295
+ actions,
2296
+ connection: !view ? /* @__PURE__ */ jsx11("output", { children: busy ? "\u6B63\u5728\u8BFB\u53D6\u90AE\u7BB1\u72B6\u6001\u2026" : "\u8FDE\u63A5\u72B6\u6001\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u65B0\u6838\u9A8C\u3002" }) : !view.connected ? /* @__PURE__ */ jsxs6("div", { className: "rounded-[20px] border border-[color-mix(in_srgb,currentColor_18%,transparent)] p-5", children: [
2297
+ /* @__PURE__ */ jsxs6("h3", { className: "mb-4 text-base font-medium", children: [
2298
+ "\u8FDE\u63A5",
2299
+ brand
2300
+ ] }),
2301
+ connectionForm
2302
+ ] }) : void 0,
2303
+ noticeTitle: "\u90AE\u7BB1\u9700\u8981\u5904\u7406",
2304
+ notice: failure || (view?.connected && !view.enabled ? "\u5DF2\u5728\u6B64\u52A9\u624B\u4E2D\u505C\u7528\uFF0C\u6388\u6743\u548C\u6D88\u606F\u63A5\u6536\u4ECD\u7136\u4FDD\u7559\u3002" : void 0),
2305
+ tabs: [{ id: "rules", label: "\u4F7F\u7528\u89C4\u5219", content: detail.rules }, ...bindDelivery ? [{ id: "push", label: "\u65B0\u90AE\u4EF6\u63A8\u9001", content: /* @__PURE__ */ jsxs6("div", { className: "space-y-4 rounded-xl bg-[hsl(var(--muted)/0.3)] p-4", children: [
2306
+ /* @__PURE__ */ jsx11("p", { children: "\u65B0\u90AE\u4EF6\u4F1A\u63A8\u9001\u7ED9\u52A9\u624B\uFF0C\u7531\u52A9\u624B\u5224\u65AD\u662F\u5426\u9700\u8981\u63D0\u9192\u4F60\u3002" }),
2307
+ /* @__PURE__ */ jsx11(Button, { disabled: busy, onClick: () => void perform(paused ? "resume" : view?.delivery_bound ? "pause" : "bind"), children: paused ? "\u6062\u590D\u63A8\u9001" : view?.delivery_bound ? "\u6682\u505C\u63A8\u9001" : "\u63A5\u5165\u52A9\u624B\u6D88\u606F" }),
2308
+ detail.pushFrequency,
2309
+ detail.onOpenPush && /* @__PURE__ */ jsx11("button", { type: "button", className: "block min-h-10 text-xs underline", onClick: detail.onOpenPush, children: "\u524D\u5F80\u63A8\u9001\u63A5\u53E3" })
2310
+ ] }) }] : []]
2311
+ }
2312
+ ),
2313
+ /* @__PURE__ */ jsx11(Dialog, { open: Boolean(editing && view?.connected), onOpenChange: (open) => {
2314
+ if (!open && !busy) {
2315
+ setCode("");
2316
+ setEditing(false);
2317
+ }
2318
+ }, children: /* @__PURE__ */ jsxs6(DialogContent, { "aria-describedby": void 0, className: "managed-mail-connection max-h-[85dvh] overflow-y-auto", onEscapeKeyDown: (event) => {
2319
+ if (busy) event.preventDefault();
2320
+ }, onInteractOutside: (event) => {
2321
+ if (busy) event.preventDefault();
2322
+ }, children: [
2323
+ /* @__PURE__ */ jsx11(DialogTitle, { children: "\u66F4\u6362\u90AE\u7BB1\u8D26\u53F7" }),
2324
+ /* @__PURE__ */ jsx11("p", { className: "text-sm", children: "\u4FDD\u5B58\u540E\u65E7\u8D26\u53F7\u7684\u8FDE\u63A5\u4F1A\u88AB\u66FF\u6362\uFF0C\u4F7F\u7528\u89C4\u5219\u4FDD\u7559\u3002" }),
2325
+ failure && /* @__PURE__ */ jsx11("p", { role: "alert", children: failure }),
2326
+ connectionForm
2327
+ ] }) })
2328
+ ] });
2329
+ }
2330
+ return /* @__PURE__ */ jsxs6("section", { "aria-label": "\u8FDE\u63A5\u90AE\u7BB1", "aria-busy": busy, className: "managed-mail-connection min-w-0 space-y-5 text-left text-sm text-foreground", children: [
2331
+ view ? /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-3", children: [
2332
+ /* @__PURE__ */ jsx11("p", { className: "min-w-0 break-all text-xs text-muted-foreground", children: view.connected ? view.label : "\u8FDE\u63A5\u540E\uFF0C\u52A9\u624B\u53EF\u4EE5\u5E2E\u4F60\u5904\u7406\u90AE\u4EF6\u3002" }),
2333
+ /* @__PURE__ */ jsx11(Badge, { className: "shrink-0", variant: view.connected ? "secondary" : "outline", children: paused ? "\u63A8\u9001\u5DF2\u6682\u505C" : view.connected ? "\u5DF2\u8FDE\u63A5" : "\u672A\u8FDE\u63A5" })
2334
+ ] }) : busy && /* @__PURE__ */ jsx11("output", { className: "text-muted-foreground", children: "\u6B63\u5728\u8BFB\u53D6\u90AE\u7BB1\u72B6\u6001\u2026" }),
2335
+ failure && /* @__PURE__ */ jsx11("p", { role: "alert", className: "break-words rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2.5 text-sm text-destructive", children: failure }),
2336
+ connectionForm,
2337
+ view?.connected && !editing && /* @__PURE__ */ jsxs6(Fragment2, { children: [
2338
+ !view.enabled && /* @__PURE__ */ jsxs6("div", { className: "space-y-2 rounded-lg border border-border p-3", children: [
2339
+ /* @__PURE__ */ jsx11("p", { className: "text-xs text-muted-foreground", children: "\u90AE\u7BB1\u5DF2\u8FDE\u63A5\uFF0C\u542F\u7528\u540E\u53EF\u5728\u5BF9\u8BDD\u4E2D\u4F7F\u7528\u3002" }),
2340
+ /* @__PURE__ */ jsx11(Button, { type: "button", disabled: busy, onClick: () => {
2341
+ void perform("finish");
2342
+ }, children: "\u542F\u7528\u90AE\u7BB1" })
2343
+ ] }),
2344
+ bindDelivery && /* @__PURE__ */ jsxs6("div", { className: "space-y-3 rounded-xl border border-border bg-[hsl(var(--muted)/0.3)] p-4", "aria-label": "\u52A9\u624B\u6D88\u606F", children: [
2345
+ /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-2", children: [
2346
+ /* @__PURE__ */ jsx11("h4", { className: "font-medium", children: "\u52A9\u624B\u6D88\u606F" }),
2347
+ /* @__PURE__ */ jsx11("span", { className: "text-xs text-muted-foreground", children: paused ? "\u5411\u52A9\u624B\u63A8\u9001\u5DF2\u6682\u505C" : view.delivery_bound ? "\u5DF2\u63A5\u5165\u52A9\u624B\u6D88\u606F" : "\u5C1A\u672A\u63A5\u5165" })
2348
+ ] }),
2349
+ /* @__PURE__ */ jsx11("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "\u65B0\u90AE\u4EF6\u4F1A\u63A8\u9001\u7ED9\u52A9\u624B\uFF0C\u7531\u52A9\u624B\u5224\u65AD\u662F\u5426\u9700\u8981\u63D0\u9192\u4F60" }),
2350
+ /* @__PURE__ */ jsxs6(Button, { className: "w-full", variant: view.delivery_bound && !paused ? "outline" : "default", type: "button", disabled: busy, onClick: () => {
2351
+ void perform(paused ? "resume" : view.delivery_bound ? "pause" : "bind");
2352
+ }, children: [
2353
+ busy && /* @__PURE__ */ jsx11(LoaderCircle, { className: "animate-spin" }),
2354
+ paused ? "\u6062\u590D\u63A8\u9001" : view.delivery_bound ? "\u6682\u505C\u63A8\u9001" : "\u63A5\u5165\u52A9\u624B\u6D88\u606F"
2355
+ ] })
2356
+ ] })
2357
+ ] }),
2358
+ !editing && /* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center justify-between gap-1 text-muted-foreground", children: [
2359
+ view?.connected && /* @__PURE__ */ jsx11(Button, { type: "button", variant: "ghost", size: "xs", disabled: busy, onClick: () => {
2360
+ setEmail(view.label || "");
2361
+ setFailure("");
2362
+ setEditing(true);
2363
+ }, children: "\u91CD\u65B0\u8FDE\u63A5\u90AE\u7BB1" }),
2364
+ /* @__PURE__ */ jsx11(Button, { type: "button", variant: "ghost", size: "xs", disabled: busy, onClick: () => {
2365
+ void perform("refresh");
2366
+ }, children: "\u5237\u65B0\u72B6\u6001" }),
2367
+ onDisable && view?.enabled && /* @__PURE__ */ jsx11(Button, { type: "button", variant: "ghost", size: "xs", disabled: busy, onClick: () => {
2368
+ void perform("disable");
2369
+ }, children: "\u505C\u7528\u6B64\u8FDE\u63A5" })
2370
+ ] }),
2371
+ view?.connection_id && !editing && /* @__PURE__ */ jsxs6("div", { className: "space-y-3", children: [
2372
+ /* @__PURE__ */ jsx11(Separator, {}),
2373
+ /* @__PURE__ */ jsxs6(AlertDialog, { children: [
2374
+ /* @__PURE__ */ jsx11(AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx11(Button, { type: "button", variant: "destructive", size: "sm", disabled: busy, children: "\u79FB\u9664\u90AE\u7BB1\u8FDE\u63A5" }) }),
2375
+ /* @__PURE__ */ jsxs6(AlertDialogContent, { className: "managed-mail-connection", children: [
2376
+ /* @__PURE__ */ jsxs6(AlertDialogHeader, { children: [
2377
+ /* @__PURE__ */ jsx11(AlertDialogTitle, { children: "\u79FB\u9664\u90AE\u7BB1\u8FDE\u63A5\uFF1F" }),
2378
+ /* @__PURE__ */ jsx11(AlertDialogDescription, { children: "\u79FB\u9664\u540E\u5C06\u505C\u6B62\u63A5\u6536\u548C\u63A8\u9001\uFF0C\u5E76\u6E05\u9664\u5DF2\u4FDD\u5B58\u7684\u90AE\u7BB1\u5730\u5740\u548C\u6388\u6743\u7801\u3002\u5DF2\u6709\u6D88\u606F\u548C\u6587\u4EF6\u4FDD\u7559\u3002" })
2379
+ ] }),
2380
+ /* @__PURE__ */ jsxs6(AlertDialogFooter, { children: [
2381
+ /* @__PURE__ */ jsx11(AlertDialogCancel, { type: "button", children: "\u53D6\u6D88" }),
2382
+ /* @__PURE__ */ jsx11(AlertDialogAction, { type: "button", variant: "destructive", onClick: () => {
2383
+ void perform("remove");
2384
+ }, children: "\u786E\u8BA4\u79FB\u9664" })
2385
+ ] })
2386
+ ] })
2387
+ ] })
2388
+ ] })
2389
+ ] });
2390
+ }
2391
+
2392
+ // src/components/ConnectorConnection.tsx
2393
+ import { jsx as jsx12 } from "react/jsx-runtime";
2394
+ function ConnectorConnection({ type, ...props }) {
2395
+ return type === "managed" ? /* @__PURE__ */ jsx12(ManagedConnection, { ...props }) : /* @__PURE__ */ jsx12(DeviceConnection, { ...props });
2396
+ }
2397
+
2398
+ export {
2399
+ DeviceConnection,
2400
+ ConnectorConnection
2401
+ };
2402
+ /*! Bundled license information:
2403
+
2404
+ qrcode.react/lib/esm/index.js:
2405
+ (**
2406
+ * @license QR Code generator library (TypeScript)
2407
+ * Copyright (c) Project Nayuki.
2408
+ * SPDX-License-Identifier: MIT
2409
+ *)
2410
+ (**
2411
+ * @license qrcode.react
2412
+ * Copyright (c) Paul O'Shannessy
2413
+ * SPDX-License-Identifier: ISC
2414
+ *)
2415
+ */
2416
+ //# sourceMappingURL=chunk-FH5HA3GW.js.map