yc-agent-ui 1.2.3 → 1.2.5

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 (156) hide show
  1. package/es/components/descriptions/index.d.ts +3 -3
  2. package/es/components/descriptions/src/index.vue.d.ts +1 -1
  3. package/es/components/dialog/index.d.ts +6 -6
  4. package/es/components/dialog/src/index.vue.d.ts +2 -2
  5. package/es/components/dialog-form/index.d.ts +4 -4
  6. package/es/components/dialog-form/src/index.vue.d.ts +4 -4
  7. package/es/components/display-item/index.d.ts +15 -15
  8. package/es/components/display-item/src/index.vue.d.ts +13 -13
  9. package/es/components/drawer-form/index.d.ts +22 -22
  10. package/es/components/drawer-form/src/index.vue.d.ts +10 -10
  11. package/es/components/form/index.d.ts +43 -43
  12. package/es/components/form/src/form-content.vue.d.ts +15 -15
  13. package/es/components/form/src/index.vue.d.ts +21 -21
  14. package/es/components/form-item/index.d.ts +61 -61
  15. package/es/components/form-item/src/index.vue.d.ts +24 -24
  16. package/es/components/index.d.ts +1 -0
  17. package/es/components/page/index.d.ts +936 -936
  18. package/es/components/page/src/index.vue.d.ts +316 -316
  19. package/es/components/popover/index.d.ts +9 -9
  20. package/es/components/popover/src/index.vue.d.ts +3 -3
  21. package/es/components/search/index.d.ts +282 -282
  22. package/es/components/search/src/index.vue.d.ts +98 -98
  23. package/es/components/table/index.d.ts +9 -9
  24. package/es/components/table/src/index.vue.d.ts +1 -1
  25. package/es/components/table/src/table-column.vue.d.ts +34 -34
  26. package/es/components/utils/index.d.ts +1 -1
  27. package/es/components/yc-ai-chat/index.d.ts +2 -1
  28. package/es/components/yc-ai-chat/src/question-card.vue.d.ts +17 -0
  29. package/es/components/yc-ai-chat/src/question-validation.d.ts +5 -0
  30. package/es/components/yc-ai-chat/src/type.d.ts +51 -0
  31. package/es/components/yc-date-picker/src/date-picker.vue.d.ts +1 -1
  32. package/es/components/yc-display-cards/capability.d.ts +4 -0
  33. package/es/components/yc-display-cards/index.d.ts +24 -0
  34. package/es/components/yc-display-cards/src/detail-card.vue.d.ts +10 -0
  35. package/es/components/yc-display-cards/src/metrics-card.vue.d.ts +8 -0
  36. package/es/components/yc-display-cards/src/table-card.vue.d.ts +12 -0
  37. package/es/components/yc-display-cards/src/types.d.ts +47 -0
  38. package/es/components/yc-input/src/input.vue.d.ts +1 -1
  39. package/es/components/yc-input/src/money-input.vue.d.ts +1 -1
  40. package/es/components/yc-plus-page/src/index.vue.d.ts +946 -946
  41. package/es/components/yc-plus-tree/src/index.vue.d.ts +1 -1
  42. package/es/components/yc-questionnaire/src/index.vue.d.ts +1 -1
  43. package/es/components/yc-status-dialog/src/index.vue.d.ts +1 -1
  44. package/es/hooks/usePlusFormReset.d.ts +132 -132
  45. package/es/index.css +11 -8
  46. package/es/index.mjs +2 -0
  47. package/es/packages/components/index.mjs +2 -0
  48. package/es/packages/components/yc-ai-chat/index.mjs +1 -0
  49. package/es/packages/components/yc-ai-chat/src/question-card.vue.mjs +5 -0
  50. package/es/packages/components/yc-ai-chat/src/question-card2.vue.mjs +613 -0
  51. package/es/packages/components/yc-ai-chat/src/question-validation.mjs +77 -0
  52. package/es/packages/components/yc-display-cards/capability.mjs +75 -0
  53. package/es/packages/components/yc-display-cards/index.mjs +10 -0
  54. package/es/packages/components/yc-display-cards/src/detail-card.vue.mjs +6 -0
  55. package/es/packages/components/yc-display-cards/src/detail-card2.vue.mjs +118 -0
  56. package/es/packages/components/yc-display-cards/src/metrics-card.vue.mjs +6 -0
  57. package/es/packages/components/yc-display-cards/src/metrics-card2.vue.mjs +132 -0
  58. package/es/packages/components/yc-display-cards/src/table-card.vue.mjs +6 -0
  59. package/es/packages/components/yc-display-cards/src/table-card2.vue.mjs +199 -0
  60. package/es/packages/components/yc-display-cards/src/types.mjs +1 -0
  61. package/es/packages/registry/load.mjs +9 -8
  62. package/es/version.d.ts +1 -1
  63. package/es/version.mjs +1 -1
  64. package/index.css +4 -1
  65. package/index.js +2546 -1335
  66. package/index.min.css +3 -0
  67. package/index.min.js +23 -23
  68. package/index.min.mjs +23 -23
  69. package/index.mjs +2535 -1328
  70. package/lib/components/descriptions/index.d.ts +3 -3
  71. package/lib/components/descriptions/src/index.vue.d.ts +1 -1
  72. package/lib/components/dialog/index.d.ts +6 -6
  73. package/lib/components/dialog/src/index.vue.d.ts +2 -2
  74. package/lib/components/dialog-form/index.d.ts +4 -4
  75. package/lib/components/dialog-form/src/index.vue.d.ts +4 -4
  76. package/lib/components/display-item/index.d.ts +15 -15
  77. package/lib/components/display-item/src/index.vue.d.ts +13 -13
  78. package/lib/components/drawer-form/index.d.ts +22 -22
  79. package/lib/components/drawer-form/src/index.vue.d.ts +10 -10
  80. package/lib/components/form/index.d.ts +43 -43
  81. package/lib/components/form/src/form-content.vue.d.ts +15 -15
  82. package/lib/components/form/src/index.vue.d.ts +21 -21
  83. package/lib/components/form-item/index.d.ts +61 -61
  84. package/lib/components/form-item/src/index.vue.d.ts +24 -24
  85. package/lib/components/index.d.ts +1 -0
  86. package/lib/components/page/index.d.ts +936 -936
  87. package/lib/components/page/src/index.vue.d.ts +316 -316
  88. package/lib/components/popover/index.d.ts +9 -9
  89. package/lib/components/popover/src/index.vue.d.ts +3 -3
  90. package/lib/components/search/index.d.ts +282 -282
  91. package/lib/components/search/src/index.vue.d.ts +98 -98
  92. package/lib/components/table/index.d.ts +9 -9
  93. package/lib/components/table/src/index.vue.d.ts +1 -1
  94. package/lib/components/table/src/table-column.vue.d.ts +34 -34
  95. package/lib/components/utils/index.d.ts +1 -1
  96. package/lib/components/yc-ai-chat/index.d.ts +2 -1
  97. package/lib/components/yc-ai-chat/src/question-card.vue.d.ts +17 -0
  98. package/lib/components/yc-ai-chat/src/question-validation.d.ts +5 -0
  99. package/lib/components/yc-ai-chat/src/type.d.ts +51 -0
  100. package/lib/components/yc-date-picker/src/date-picker.vue.d.ts +1 -1
  101. package/lib/components/yc-display-cards/capability.d.ts +4 -0
  102. package/lib/components/yc-display-cards/index.d.ts +24 -0
  103. package/lib/components/yc-display-cards/src/detail-card.vue.d.ts +10 -0
  104. package/lib/components/yc-display-cards/src/metrics-card.vue.d.ts +8 -0
  105. package/lib/components/yc-display-cards/src/table-card.vue.d.ts +12 -0
  106. package/lib/components/yc-display-cards/src/types.d.ts +47 -0
  107. package/lib/components/yc-input/src/input.vue.d.ts +1 -1
  108. package/lib/components/yc-input/src/money-input.vue.d.ts +1 -1
  109. package/lib/components/yc-plus-page/src/index.vue.d.ts +946 -946
  110. package/lib/components/yc-plus-tree/src/index.vue.d.ts +1 -1
  111. package/lib/components/yc-questionnaire/src/index.vue.d.ts +1 -1
  112. package/lib/components/yc-status-dialog/src/index.vue.d.ts +1 -1
  113. package/lib/hooks/usePlusFormReset.d.ts +132 -132
  114. package/lib/index.css +11 -8
  115. package/lib/index.js +12 -6
  116. package/lib/packages/components/index.js +12 -6
  117. package/lib/packages/components/yc-ai-chat/index.js +2 -0
  118. package/lib/packages/components/yc-ai-chat/src/question-card.vue.js +9 -0
  119. package/lib/packages/components/yc-ai-chat/src/question-card2.vue.js +617 -0
  120. package/lib/packages/components/yc-ai-chat/src/question-validation.js +81 -0
  121. package/lib/packages/components/yc-display-cards/capability.js +79 -0
  122. package/lib/packages/components/yc-display-cards/index.js +14 -0
  123. package/lib/packages/components/yc-display-cards/src/detail-card.vue.js +10 -0
  124. package/lib/packages/components/yc-display-cards/src/detail-card2.vue.js +122 -0
  125. package/lib/packages/components/yc-display-cards/src/metrics-card.vue.js +10 -0
  126. package/lib/packages/components/yc-display-cards/src/metrics-card2.vue.js +136 -0
  127. package/lib/packages/components/yc-display-cards/src/table-card.vue.js +10 -0
  128. package/lib/packages/components/yc-display-cards/src/table-card2.vue.js +203 -0
  129. package/lib/packages/components/yc-display-cards/src/types.js +2 -0
  130. package/lib/packages/registry/load.js +9 -8
  131. package/lib/version.d.ts +1 -1
  132. package/lib/version.js +1 -1
  133. package/locale/en.js +1 -1
  134. package/locale/en.min.js +1 -1
  135. package/locale/en.min.mjs +1 -1
  136. package/locale/en.mjs +1 -1
  137. package/locale/ja.js +1 -1
  138. package/locale/ja.min.js +1 -1
  139. package/locale/ja.min.mjs +1 -1
  140. package/locale/ja.mjs +1 -1
  141. package/locale/ko.js +1 -1
  142. package/locale/ko.min.js +1 -1
  143. package/locale/ko.min.mjs +1 -1
  144. package/locale/ko.mjs +1 -1
  145. package/locale/zh-cn.js +1 -1
  146. package/locale/zh-cn.min.js +1 -1
  147. package/locale/zh-cn.min.mjs +1 -1
  148. package/locale/zh-cn.mjs +1 -1
  149. package/locale/zh-tw.js +1 -1
  150. package/locale/zh-tw.min.js +1 -1
  151. package/locale/zh-tw.min.mjs +1 -1
  152. package/locale/zh-tw.mjs +1 -1
  153. package/package.json +1 -1
  154. package/theme-chalk/index.css +4 -1
  155. package/theme-chalk/plus-yc-ai-chat.css +1 -1
  156. package/theme-chalk/src/yc-ai-chat.scss +498 -0
@@ -0,0 +1,613 @@
1
+ import { defineComponent, reactive, ref, watch, computed, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, Fragment, renderList, withDirectives, vModelText } from 'vue';
2
+ import { validChatQuestionRequest, validChatOtherText, validChatAnswersForRequest } from './question-validation.mjs';
3
+
4
+ const _hoisted_1 = ["data-state", "data-testid"];
5
+ const _hoisted_2 = { class: "yc-chat-question-card__header question-card__header" };
6
+ const _hoisted_3 = { class: "yc-chat-question-card__title-wrap" };
7
+ const _hoisted_4 = {
8
+ key: 0,
9
+ viewBox: "0 0 18 18",
10
+ fill: "none"
11
+ };
12
+ const _hoisted_5 = {
13
+ key: 1,
14
+ viewBox: "0 0 18 18",
15
+ fill: "none"
16
+ };
17
+ const _hoisted_6 = { class: "yc-chat-question-card__title" };
18
+ const _hoisted_7 = { class: "yc-chat-question-card__header-meta" };
19
+ const _hoisted_8 = {
20
+ key: 0,
21
+ class: "yc-chat-question-card__summary",
22
+ "data-testid": "question-card-summary"
23
+ };
24
+ const _hoisted_9 = { class: "yc-chat-question-card__summary-question" };
25
+ const _hoisted_10 = {
26
+ key: 0,
27
+ class: "yc-chat-question-card__answer-chips"
28
+ };
29
+ const _hoisted_11 = {
30
+ key: 0,
31
+ class: "yc-chat-question-card__answer-chip is-other"
32
+ };
33
+ const _hoisted_12 = {
34
+ key: 1,
35
+ class: "yc-chat-question-card__summary-empty"
36
+ };
37
+ const _hoisted_13 = {
38
+ key: 1,
39
+ class: "yc-chat-question-card__questions"
40
+ };
41
+ const _hoisted_14 = ["disabled"];
42
+ const _hoisted_15 = { class: "yc-chat-question-card__legend" };
43
+ const _hoisted_16 = {
44
+ key: 0,
45
+ class: "yc-chat-question-card__mode-tag"
46
+ };
47
+ const _hoisted_17 = { class: "yc-chat-question-card__options" };
48
+ const _hoisted_18 = ["data-testid", "type", "name", "checked", "onChange"];
49
+ const _hoisted_19 = {
50
+ key: 0,
51
+ viewBox: "0 0 12 12",
52
+ fill: "none"
53
+ };
54
+ const _hoisted_20 = { class: "yc-chat-question-card__option-body" };
55
+ const _hoisted_21 = { class: "yc-chat-question-card__option-label" };
56
+ const _hoisted_22 = {
57
+ key: 0,
58
+ class: "yc-chat-question-card__option-desc"
59
+ };
60
+ const _hoisted_23 = {
61
+ key: 1,
62
+ class: "yc-chat-question-card__event question-card__event"
63
+ };
64
+ const _hoisted_24 = ["data-testid", "type", "name", "checked", "onChange"];
65
+ const _hoisted_25 = {
66
+ key: 0,
67
+ viewBox: "0 0 12 12",
68
+ fill: "none"
69
+ };
70
+ const _hoisted_26 = { class: "yc-chat-question-card__option-body" };
71
+ const _hoisted_27 = { class: "yc-chat-question-card__option-label" };
72
+ const _hoisted_28 = {
73
+ key: 0,
74
+ class: "yc-chat-question-card__textarea-box"
75
+ };
76
+ const _hoisted_29 = ["onUpdate:modelValue", "data-testid"];
77
+ const _hoisted_30 = {
78
+ key: 2,
79
+ class: "yc-chat-question-card__notice question-card__notice"
80
+ };
81
+ const _hoisted_31 = {
82
+ key: 3,
83
+ class: "yc-chat-question-card__notice question-card__notice"
84
+ };
85
+ const _hoisted_32 = {
86
+ key: 4,
87
+ class: "yc-chat-question-card__notice question-card__notice",
88
+ "data-testid": "client-event-not-executed"
89
+ };
90
+ const _hoisted_33 = {
91
+ key: 5,
92
+ class: "yc-chat-question-card__actions question-card__actions"
93
+ };
94
+ const _hoisted_34 = ["disabled"];
95
+ const _hoisted_35 = ["disabled"];
96
+ var _sfc_main = /* @__PURE__ */ defineComponent({
97
+ ...{
98
+ name: "YcChatQuestionCard"
99
+ },
100
+ __name: "question-card",
101
+ props: {
102
+ interaction: {},
103
+ submitting: { type: Boolean, default: false },
104
+ answerEnabled: { type: Boolean, default: true },
105
+ unavailableReason: { default: "" },
106
+ title: { default: "\u9700\u8981\u4F60\u7684\u56DE\u7B54" },
107
+ compact: { type: Boolean, default: false }
108
+ },
109
+ emits: ["answer", "cancel"],
110
+ setup(__props, { emit: __emit }) {
111
+ const props = __props;
112
+ const emit = __emit;
113
+ const selected = reactive({});
114
+ const otherActive = reactive({});
115
+ const otherText = reactive({});
116
+ const showDetails = ref(false);
117
+ const statusLabels = {
118
+ preparing: "\u51C6\u5907\u4E2D",
119
+ pending: "\u5F85\u56DE\u7B54",
120
+ answered: "\u5DF2\u56DE\u7B54",
121
+ invalidated: "\u5DF2\u5931\u6548",
122
+ expired: "\u5DF2\u8FC7\u671F",
123
+ cancelled: "\u5DF2\u53D6\u6D88",
124
+ superseded: "\u5DF2\u88AB\u65B0\u6D88\u606F\u66FF\u4EE3"
125
+ };
126
+ watch(
127
+ () => [props.interaction.request.request_id, props.interaction.state],
128
+ () => {
129
+ showDetails.value = false;
130
+ }
131
+ );
132
+ watch(
133
+ () => [props.interaction.request.request_id, props.interaction.answers],
134
+ () => {
135
+ var _a, _b;
136
+ for (const question of props.interaction.request.questions) {
137
+ const answer = props.interaction.answers.find(
138
+ (item) => item.question_id === question.id
139
+ );
140
+ selected[question.id] = [...(_a = answer == null ? void 0 : answer.selected_option_ids) != null ? _a : []];
141
+ otherActive[question.id] = (answer == null ? void 0 : answer.other_text) != null;
142
+ otherText[question.id] = (_b = answer == null ? void 0 : answer.other_text) != null ? _b : "";
143
+ }
144
+ },
145
+ { immediate: true, deep: true }
146
+ );
147
+ const requestIsValid = computed(
148
+ () => validChatQuestionRequest(props.interaction.request)
149
+ );
150
+ const isPending = computed(() => props.interaction.state === "pending");
151
+ const showForm = computed(() => isPending.value || showDetails.value);
152
+ const answerSummaries = computed(
153
+ () => props.interaction.request.questions.map((question) => {
154
+ var _a, _b, _c, _d;
155
+ const answer = props.interaction.answers.find(
156
+ (item) => item.question_id === question.id
157
+ );
158
+ const optionIds = (_b = (_a = answer == null ? void 0 : answer.selected_option_ids) != null ? _a : selected[question.id]) != null ? _b : [];
159
+ const labels = optionIds.map(
160
+ (id) => {
161
+ var _a2, _b2;
162
+ return (_b2 = (_a2 = question.options.find((option) => option.id === id)) == null ? void 0 : _a2.label) != null ? _b2 : id;
163
+ }
164
+ );
165
+ const customText = ((_d = (_c = answer == null ? void 0 : answer.other_text) != null ? _c : otherActive[question.id] ? otherText[question.id] : "") != null ? _d : "").trim();
166
+ return {
167
+ id: question.id,
168
+ title: question.title,
169
+ labels,
170
+ customText
171
+ };
172
+ })
173
+ );
174
+ const canAnswer = computed(
175
+ () => props.answerEnabled && props.interaction.state === "pending" && requestIsValid.value
176
+ );
177
+ const complete = computed(
178
+ () => props.interaction.request.questions.every((question) => {
179
+ var _a, _b, _c;
180
+ if (otherActive[question.id]) {
181
+ return validChatOtherText((_a = otherText[question.id]) != null ? _a : "");
182
+ }
183
+ return ((_c = (_b = selected[question.id]) == null ? void 0 : _b.length) != null ? _c : 0) > 0;
184
+ })
185
+ );
186
+ function optionChecked(question, optionId) {
187
+ var _a, _b;
188
+ return (_b = (_a = selected[question.id]) == null ? void 0 : _a.includes(optionId)) != null ? _b : false;
189
+ }
190
+ function selectOption(question, optionId) {
191
+ var _a;
192
+ if (!canAnswer.value) return;
193
+ otherActive[question.id] = false;
194
+ otherText[question.id] = "";
195
+ if (question.selection_mode === "single") {
196
+ selected[question.id] = [optionId];
197
+ return;
198
+ }
199
+ const current = (_a = selected[question.id]) != null ? _a : [];
200
+ selected[question.id] = current.includes(optionId) ? current.filter((id) => id !== optionId) : [...current, optionId];
201
+ }
202
+ function selectOther(question, enabled) {
203
+ if (!canAnswer.value) return;
204
+ otherActive[question.id] = enabled;
205
+ if (enabled) selected[question.id] = [];
206
+ }
207
+ function eventSummary(option) {
208
+ if (!option.event) return "";
209
+ const text = JSON.stringify(option.event.payload);
210
+ return text.length > 160 ? `${text.slice(0, 157)}...` : text;
211
+ }
212
+ function submit() {
213
+ if (!canAnswer.value || !complete.value || props.submitting) return;
214
+ const answers = props.interaction.request.questions.map((question) => {
215
+ var _a, _b;
216
+ return {
217
+ question_id: question.id,
218
+ selected_option_ids: otherActive[question.id] ? [] : [...(_a = selected[question.id]) != null ? _a : []].sort(),
219
+ other_text: otherActive[question.id] ? ((_b = otherText[question.id]) == null ? void 0 : _b.trim()) || null : null
220
+ };
221
+ });
222
+ if (validChatAnswersForRequest(props.interaction.request, answers)) {
223
+ emit("answer", answers);
224
+ }
225
+ }
226
+ return (_ctx, _cache) => {
227
+ var _a;
228
+ return openBlock(), createElementBlock("section", {
229
+ class: normalizeClass(["yc-chat-question-card question-card", {
230
+ "is-compact": __props.compact,
231
+ "is-readonly": !canAnswer.value,
232
+ "is-summary": !showForm.value
233
+ }]),
234
+ "data-state": __props.interaction.state,
235
+ "data-testid": `question-card-${__props.interaction.request.request_id}`
236
+ }, [
237
+ createElementVNode("header", _hoisted_2, [
238
+ createElementVNode("div", _hoisted_3, [
239
+ createElementVNode(
240
+ "span",
241
+ {
242
+ class: normalizeClass(["yc-chat-question-card__badge-icon", { "is-answered": __props.interaction.state === "answered" }]),
243
+ "aria-hidden": "true"
244
+ },
245
+ [
246
+ __props.interaction.state === "answered" ? (openBlock(), createElementBlock("svg", _hoisted_4, [..._cache[2] || (_cache[2] = [
247
+ createElementVNode(
248
+ "path",
249
+ {
250
+ d: "M4.2 9.4L7.4 12.6L13.8 5.8",
251
+ stroke: "currentColor",
252
+ "stroke-width": "2",
253
+ "stroke-linecap": "round",
254
+ "stroke-linejoin": "round"
255
+ },
256
+ null,
257
+ -1
258
+ /* CACHED */
259
+ )
260
+ ])])) : (openBlock(), createElementBlock("svg", _hoisted_5, [..._cache[3] || (_cache[3] = [
261
+ createElementVNode(
262
+ "path",
263
+ {
264
+ d: "M9 2.25C9.42 5.45 10.75 6.78 13.95 7.2C10.75 7.62 9.42 8.95 9 12.15C8.58 8.95 7.25 7.62 4.05 7.2C7.25 6.78 8.58 5.45 9 2.25Z",
265
+ fill: "currentColor"
266
+ },
267
+ null,
268
+ -1
269
+ /* CACHED */
270
+ ),
271
+ createElementVNode(
272
+ "circle",
273
+ {
274
+ cx: "14.2",
275
+ cy: "13.2",
276
+ r: "1.35",
277
+ fill: "currentColor",
278
+ opacity: "0.7"
279
+ },
280
+ null,
281
+ -1
282
+ /* CACHED */
283
+ )
284
+ ])]))
285
+ ],
286
+ 2
287
+ /* CLASS */
288
+ ),
289
+ createElementVNode(
290
+ "strong",
291
+ _hoisted_6,
292
+ toDisplayString(__props.title),
293
+ 1
294
+ /* TEXT */
295
+ )
296
+ ]),
297
+ createElementVNode("div", _hoisted_7, [
298
+ !isPending.value ? (openBlock(), createElementBlock(
299
+ "button",
300
+ {
301
+ key: 0,
302
+ type: "button",
303
+ class: "yc-chat-question-card__toggle-btn",
304
+ "data-testid": "toggle-question-details",
305
+ onClick: _cache[0] || (_cache[0] = ($event) => showDetails.value = !showDetails.value)
306
+ },
307
+ toDisplayString(showDetails.value ? "\u6536\u8D77\u9009\u9879" : "\u67E5\u770B\u9009\u9879"),
308
+ 1
309
+ /* TEXT */
310
+ )) : createCommentVNode("v-if", true),
311
+ createElementVNode(
312
+ "span",
313
+ {
314
+ class: normalizeClass(["yc-chat-question-card__status question-card__status", `is-${__props.interaction.state}`])
315
+ },
316
+ toDisplayString(statusLabels[__props.interaction.state]),
317
+ 3
318
+ /* TEXT, CLASS */
319
+ )
320
+ ])
321
+ ]),
322
+ !showForm.value ? (openBlock(), createElementBlock("div", _hoisted_8, [
323
+ (openBlock(true), createElementBlock(
324
+ Fragment,
325
+ null,
326
+ renderList(answerSummaries.value, (item) => {
327
+ return openBlock(), createElementBlock("div", {
328
+ key: item.id,
329
+ class: "yc-chat-question-card__summary-item"
330
+ }, [
331
+ createElementVNode(
332
+ "p",
333
+ _hoisted_9,
334
+ toDisplayString(item.title),
335
+ 1
336
+ /* TEXT */
337
+ ),
338
+ __props.interaction.state === "answered" ? (openBlock(), createElementBlock("div", _hoisted_10, [
339
+ (openBlock(true), createElementBlock(
340
+ Fragment,
341
+ null,
342
+ renderList(item.labels, (label, idx) => {
343
+ return openBlock(), createElementBlock(
344
+ "span",
345
+ {
346
+ key: `${item.id}-opt-${idx}`,
347
+ class: "yc-chat-question-card__answer-chip"
348
+ },
349
+ toDisplayString(label),
350
+ 1
351
+ /* TEXT */
352
+ );
353
+ }),
354
+ 128
355
+ /* KEYED_FRAGMENT */
356
+ )),
357
+ item.customText ? (openBlock(), createElementBlock(
358
+ "span",
359
+ _hoisted_11,
360
+ toDisplayString(item.customText),
361
+ 1
362
+ /* TEXT */
363
+ )) : createCommentVNode("v-if", true),
364
+ item.labels.length === 0 && !item.customText ? (openBlock(), createElementBlock("span", _hoisted_12, " \u5DF2\u63D0\u4EA4\u56DE\u7B54 ")) : createCommentVNode("v-if", true)
365
+ ])) : createCommentVNode("v-if", true)
366
+ ]);
367
+ }),
368
+ 128
369
+ /* KEYED_FRAGMENT */
370
+ ))
371
+ ])) : (openBlock(), createElementBlock("div", _hoisted_13, [
372
+ (openBlock(true), createElementBlock(
373
+ Fragment,
374
+ null,
375
+ renderList(__props.interaction.request.questions, (question) => {
376
+ return openBlock(), createElementBlock("fieldset", {
377
+ key: question.id,
378
+ class: "yc-chat-question-card__question question-card__question",
379
+ disabled: !canAnswer.value
380
+ }, [
381
+ createElementVNode("legend", _hoisted_15, [
382
+ createElementVNode(
383
+ "span",
384
+ null,
385
+ toDisplayString(question.title),
386
+ 1
387
+ /* TEXT */
388
+ ),
389
+ question.selection_mode === "multiple" ? (openBlock(), createElementBlock("span", _hoisted_16, " \u53EF\u591A\u9009 ")) : createCommentVNode("v-if", true)
390
+ ]),
391
+ createElementVNode("div", _hoisted_17, [
392
+ (openBlock(true), createElementBlock(
393
+ Fragment,
394
+ null,
395
+ renderList(question.options, (option) => {
396
+ return openBlock(), createElementBlock(
397
+ "label",
398
+ {
399
+ key: option.id,
400
+ class: normalizeClass(["yc-chat-question-card__option question-card__option", {
401
+ "is-selected": optionChecked(question, option.id),
402
+ "is-disabled": !canAnswer.value
403
+ }])
404
+ },
405
+ [
406
+ createElementVNode("input", {
407
+ class: "yc-chat-question-card__native-input",
408
+ "data-testid": `option-${question.id}-${option.id}`,
409
+ type: question.selection_mode === "single" ? "radio" : "checkbox",
410
+ name: `question-${__props.interaction.request.request_id}-${question.id}`,
411
+ checked: optionChecked(question, option.id),
412
+ onChange: ($event) => selectOption(question, option.id)
413
+ }, null, 40, _hoisted_18),
414
+ createElementVNode(
415
+ "span",
416
+ {
417
+ class: normalizeClass(["yc-chat-question-card__control", [
418
+ `is-${question.selection_mode}`,
419
+ { "is-checked": optionChecked(question, option.id) }
420
+ ]]),
421
+ "aria-hidden": "true"
422
+ },
423
+ [
424
+ question.selection_mode === "multiple" && optionChecked(question, option.id) ? (openBlock(), createElementBlock("svg", _hoisted_19, [..._cache[4] || (_cache[4] = [
425
+ createElementVNode(
426
+ "path",
427
+ {
428
+ d: "M2.5 6.2L4.9 8.6L9.5 3.6",
429
+ stroke: "currentColor",
430
+ "stroke-width": "1.7",
431
+ "stroke-linecap": "round",
432
+ "stroke-linejoin": "round"
433
+ },
434
+ null,
435
+ -1
436
+ /* CACHED */
437
+ )
438
+ ])])) : createCommentVNode("v-if", true)
439
+ ],
440
+ 2
441
+ /* CLASS */
442
+ ),
443
+ createElementVNode("span", _hoisted_20, [
444
+ createElementVNode(
445
+ "strong",
446
+ _hoisted_21,
447
+ toDisplayString(option.label),
448
+ 1
449
+ /* TEXT */
450
+ ),
451
+ option.description ? (openBlock(), createElementBlock(
452
+ "small",
453
+ _hoisted_22,
454
+ toDisplayString(option.description),
455
+ 1
456
+ /* TEXT */
457
+ )) : createCommentVNode("v-if", true),
458
+ option.event ? (openBlock(), createElementBlock("span", _hoisted_23, [
459
+ createElementVNode(
460
+ "span",
461
+ null,
462
+ toDisplayString(option.event.type) + " \xB7 v" + toDisplayString(option.event.version) + " \xB7 \u53C2\u6570",
463
+ 1
464
+ /* TEXT */
465
+ ),
466
+ createElementVNode(
467
+ "code",
468
+ null,
469
+ toDisplayString(eventSummary(option)),
470
+ 1
471
+ /* TEXT */
472
+ ),
473
+ _cache[5] || (_cache[5] = createElementVNode(
474
+ "em",
475
+ null,
476
+ "Admin \u4E0D\u652F\u6301\u6267\u884C\u5BA2\u6237\u7AEF\u4E8B\u4EF6",
477
+ -1
478
+ /* CACHED */
479
+ ))
480
+ ])) : createCommentVNode("v-if", true)
481
+ ])
482
+ ],
483
+ 2
484
+ /* CLASS */
485
+ );
486
+ }),
487
+ 128
488
+ /* KEYED_FRAGMENT */
489
+ )),
490
+ createElementVNode(
491
+ "div",
492
+ {
493
+ class: normalizeClass(["yc-chat-question-card__other-wrap", { "is-selected": otherActive[question.id] }])
494
+ },
495
+ [
496
+ createElementVNode(
497
+ "label",
498
+ {
499
+ class: normalizeClass(["yc-chat-question-card__option yc-chat-question-card__other question-card__option question-card__other", {
500
+ "is-selected": otherActive[question.id],
501
+ "is-disabled": !canAnswer.value
502
+ }])
503
+ },
504
+ [
505
+ createElementVNode("input", {
506
+ class: "yc-chat-question-card__native-input",
507
+ "data-testid": `other-${question.id}`,
508
+ type: question.selection_mode === "single" ? "radio" : "checkbox",
509
+ name: `question-${__props.interaction.request.request_id}-${question.id}`,
510
+ checked: otherActive[question.id],
511
+ onChange: ($event) => selectOther(question, $event.target.checked)
512
+ }, null, 40, _hoisted_24),
513
+ createElementVNode(
514
+ "span",
515
+ {
516
+ class: normalizeClass(["yc-chat-question-card__control", [
517
+ `is-${question.selection_mode}`,
518
+ { "is-checked": otherActive[question.id] }
519
+ ]]),
520
+ "aria-hidden": "true"
521
+ },
522
+ [
523
+ question.selection_mode === "multiple" && otherActive[question.id] ? (openBlock(), createElementBlock("svg", _hoisted_25, [..._cache[6] || (_cache[6] = [
524
+ createElementVNode(
525
+ "path",
526
+ {
527
+ d: "M2.5 6.2L4.9 8.6L9.5 3.6",
528
+ stroke: "currentColor",
529
+ "stroke-width": "1.7",
530
+ "stroke-linecap": "round",
531
+ "stroke-linejoin": "round"
532
+ },
533
+ null,
534
+ -1
535
+ /* CACHED */
536
+ )
537
+ ])])) : createCommentVNode("v-if", true)
538
+ ],
539
+ 2
540
+ /* CLASS */
541
+ ),
542
+ createElementVNode("span", _hoisted_26, [
543
+ createElementVNode(
544
+ "strong",
545
+ _hoisted_27,
546
+ toDisplayString(question.other.label),
547
+ 1
548
+ /* TEXT */
549
+ )
550
+ ])
551
+ ],
552
+ 2
553
+ /* CLASS */
554
+ ),
555
+ otherActive[question.id] ? (openBlock(), createElementBlock("div", _hoisted_28, [
556
+ withDirectives(createElementVNode("textarea", {
557
+ "onUpdate:modelValue": ($event) => otherText[question.id] = $event,
558
+ class: "yc-chat-question-card__textarea",
559
+ "data-testid": `other-text-${question.id}`,
560
+ rows: "2",
561
+ placeholder: "\u8BF7\u8F93\u5165\u4F60\u7684\u8865\u5145\u8BF4\u660E\u6216\u81EA\u5B9A\u4E49\u7B54\u6848\u2026"
562
+ }, null, 8, _hoisted_29), [
563
+ [vModelText, otherText[question.id]]
564
+ ])
565
+ ])) : createCommentVNode("v-if", true)
566
+ ],
567
+ 2
568
+ /* CLASS */
569
+ )
570
+ ])
571
+ ], 8, _hoisted_14);
572
+ }),
573
+ 128
574
+ /* KEYED_FRAGMENT */
575
+ ))
576
+ ])),
577
+ !requestIsValid.value ? (openBlock(), createElementBlock("p", _hoisted_30, " \u4EA4\u4E92\u8BF7\u6C42\u4E0D\u7B26\u5408\u5BA2\u6237\u7AEF\u4E8B\u4EF6\u7EA6\u675F\uFF0C\u65E0\u6CD5\u63D0\u4EA4\u56DE\u7B54\u3002 ")) : createCommentVNode("v-if", true),
578
+ !__props.answerEnabled && __props.interaction.state === "pending" ? (openBlock(), createElementBlock(
579
+ "p",
580
+ _hoisted_31,
581
+ toDisplayString(__props.unavailableReason || "\u5F53\u524D\u754C\u9762\u6682\u4E0D\u652F\u6301\u63D0\u4EA4\u56DE\u7B54"),
582
+ 1
583
+ /* TEXT */
584
+ )) : createCommentVNode("v-if", true),
585
+ ((_a = __props.interaction.receipt) == null ? void 0 : _a.clientEvent) ? (openBlock(), createElementBlock(
586
+ "p",
587
+ _hoisted_32,
588
+ " \u5BA2\u6237\u7AEF\u4E8B\u4EF6 " + toDisplayString(__props.interaction.receipt.clientEvent.type) + " \u672A\u5728 Admin \u6267\u884C\u3002 ",
589
+ 1
590
+ /* TEXT */
591
+ )) : createCommentVNode("v-if", true),
592
+ __props.interaction.state === "pending" ? (openBlock(), createElementBlock("div", _hoisted_33, [
593
+ createElementVNode("button", {
594
+ type: "button",
595
+ class: "yc-chat-question-card__btn yc-chat-question-card__btn--cancel question-card__cancel",
596
+ "data-testid": "cancel-interaction",
597
+ disabled: !__props.answerEnabled || __props.submitting,
598
+ onClick: _cache[1] || (_cache[1] = ($event) => emit("cancel"))
599
+ }, " \u53D6\u6D88 ", 8, _hoisted_34),
600
+ createElementVNode("button", {
601
+ type: "button",
602
+ class: "yc-chat-question-card__btn yc-chat-question-card__btn--submit",
603
+ "data-testid": "submit-answers",
604
+ disabled: !canAnswer.value || !complete.value || __props.submitting,
605
+ onClick: submit
606
+ }, toDisplayString(__props.submitting ? "\u63D0\u4EA4\u4E2D\u2026" : "\u63D0\u4EA4\u56DE\u7B54"), 9, _hoisted_35)
607
+ ])) : createCommentVNode("v-if", true)
608
+ ], 10, _hoisted_1);
609
+ };
610
+ }
611
+ });
612
+
613
+ export { _sfc_main as default };
@@ -0,0 +1,77 @@
1
+ const ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
2
+ const EVENT_TYPE_PATTERN = /^[A-Za-z0-9._-]{1,100}$/;
3
+ function codePointLength(value) {
4
+ return Array.from(value).length;
5
+ }
6
+ function hasForbiddenControl(value, allowLineBreaks) {
7
+ var _a;
8
+ for (const character of value) {
9
+ const point = (_a = character.codePointAt(0)) != null ? _a : 0;
10
+ if ((point >= 0 && point <= 31 || point >= 127 && point <= 159) && (!allowLineBreaks || point !== 9 && point !== 10 && point !== 13)) {
11
+ return true;
12
+ }
13
+ }
14
+ return false;
15
+ }
16
+ function validText(value, minimum, maximum, allowLineBreaks = false) {
17
+ const length = codePointLength(value);
18
+ return length >= minimum && length <= maximum && value.trim().length > 0 && !hasForbiddenControl(value, allowLineBreaks);
19
+ }
20
+ function validChatOtherText(value) {
21
+ return validText(value, 1, 2e3, true);
22
+ }
23
+ function validChatQuestionRequest(request) {
24
+ var _a, _b, _c;
25
+ if (request.schema !== "interaction.question.v1" || !validText(request.request_id, 1, 256) || !validText(request.tool_call_id, 1, 256) || request.questions.length < 1 || request.questions.length > 5) {
26
+ return false;
27
+ }
28
+ const questionIds = /* @__PURE__ */ new Set();
29
+ let hasEvent = false;
30
+ for (const question of request.questions) {
31
+ if (!ID_PATTERN.test(question.id) || questionIds.has(question.id) || !validText(question.title, 1, 500) || !["single", "multiple"].includes(question.selection_mode) || question.options.length < 1 || question.options.length > 10 || ((_a = question.other) == null ? void 0 : _a.enabled) !== true || ((_b = question.other) == null ? void 0 : _b.label) !== "\u5176\u4ED6") {
32
+ return false;
33
+ }
34
+ questionIds.add(question.id);
35
+ const optionIds = /* @__PURE__ */ new Set();
36
+ const optionLabels = /* @__PURE__ */ new Set();
37
+ for (const option of question.options) {
38
+ const normalizedLabel = option.label.trim();
39
+ if (!ID_PATTERN.test(option.id) || optionIds.has(option.id) || !validText(option.label, 1, 100) || normalizedLabel === "\u5176\u4ED6" || optionLabels.has(normalizedLabel) || option.description !== void 0 && option.description !== "" && !validText(option.description, 1, 300)) {
40
+ return false;
41
+ }
42
+ optionIds.add(option.id);
43
+ optionLabels.add(normalizedLabel);
44
+ if (option.event) {
45
+ hasEvent = true;
46
+ if (!EVENT_TYPE_PATTERN.test(option.event.type) || !Number.isInteger(option.event.version) || option.event.version < 1 || option.event.payload === null || typeof option.event.payload !== "object" || Array.isArray(option.event.payload)) {
47
+ return false;
48
+ }
49
+ }
50
+ }
51
+ }
52
+ if (hasEvent && (request.questions.length !== 1 || ((_c = request.questions[0]) == null ? void 0 : _c.selection_mode) !== "single")) {
53
+ return false;
54
+ }
55
+ return true;
56
+ }
57
+ function validChatAnswersForRequest(request, answers) {
58
+ if (!validChatQuestionRequest(request)) return false;
59
+ if (answers.length !== request.questions.length) return false;
60
+ return request.questions.every((question, index) => {
61
+ const answer = answers[index];
62
+ if (!answer || answer.question_id !== question.id) return false;
63
+ const allowed = new Set(question.options.map((option) => option.id));
64
+ if (new Set(answer.selected_option_ids).size !== answer.selected_option_ids.length || answer.selected_option_ids.some((id) => !allowed.has(id))) {
65
+ return false;
66
+ }
67
+ if (answer.other_text !== null) {
68
+ return answer.selected_option_ids.length === 0 && validChatOtherText(answer.other_text);
69
+ }
70
+ if (question.selection_mode === "single") {
71
+ return answer.selected_option_ids.length === 1;
72
+ }
73
+ return answer.selected_option_ids.length >= 1;
74
+ });
75
+ }
76
+
77
+ export { validChatAnswersForRequest, validChatOtherText, validChatQuestionRequest };