wi-chat 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { provideOutputFileConfig as q, createAnswerContentMap as $, DeepThinkingSteps as x, AiAnswerBubble as P } from "wi-chat/renderers";
2
- import { AiAnswerBubble as ke, ClarificationCard as ve, DeepThinkingSteps as Ce, IframePage as Te, KnowledgeStreamResult as Ie, OutputFile as Se, createAnswerContentMap as Be, injectIframeResizerChild as Ee, provideIframePageConfig as Ve, provideOutputFileConfig as Ae, resolveIframePlaceholders as Fe, useIframePage as Oe } from "wi-chat/renderers";
3
- import { defineComponent as C, openBlock as i, createElementBlock as n, createVNode as f, unref as c, withKeys as U, withModifiers as K, withCtx as O, createTextVNode as N, toDisplayString as y, ref as z, computed as L, watch as V, createElementVNode as _, createCommentVNode as k, Fragment as v, renderList as A, Transition as R, pushScopeId as j, popScopeId as W, renderSlot as F } from "vue";
2
+ import { AgentActionStatus as ke, AiAnswerBubble as ve, ClarificationCard as Ce, DeepThinkingSteps as Te, IframePage as Ie, KnowledgeStreamResult as Se, OutputFile as Be, createAnswerContentMap as Ee, injectIframeResizerChild as Ae, provideIframePageConfig as Ve, provideOutputFileConfig as Fe, resolveIframePlaceholders as Oe, useIframePage as De } from "wi-chat/renderers";
3
+ import { defineComponent as C, openBlock as i, createElementBlock as n, createVNode as f, unref as c, withKeys as U, withModifiers as K, withCtx as O, createTextVNode as N, toDisplayString as y, ref as z, computed as L, watch as A, createElementVNode as _, createCommentVNode as k, Fragment as v, renderList as V, Transition as R, pushScopeId as j, popScopeId as W, renderSlot as F } from "vue";
4
4
  import { Field as G, Button as H } from "vant";
5
5
  import { useAutoScroll as J } from "wi-chat/tools";
6
6
  const Q = { class: "wi-mobile-inputbox" }, X = /* @__PURE__ */ C({
@@ -88,14 +88,14 @@ const Q = { class: "wi-mobile-inputbox" }, X = /* @__PURE__ */ C({
88
88
  const t = l, r = o;
89
89
  q(t.outputFileConfig ?? {});
90
90
  const g = z(), { showScrollToBottom: e, forceScrollToBottom: a, requestScrollToBottom: p, resetScrollState: w, onReachTop: D } = J(g), M = L(() => $(t.parsers));
91
- V(
91
+ A(
92
92
  () => t.messages.length === 0,
93
93
  (d) => {
94
94
  d && w();
95
95
  }
96
96
  );
97
97
  let I = ((B = t.messages[0]) == null ? void 0 : B.id) ?? "", S = ((E = t.messages[t.messages.length - 1]) == null ? void 0 : E.id) ?? "";
98
- return V(
98
+ return A(
99
99
  () => t.messages,
100
100
  () => {
101
101
  var b, m;
@@ -118,7 +118,7 @@ const Q = { class: "wi-mobile-inputbox" }, X = /* @__PURE__ */ C({
118
118
  _("div", oe, y(d.emptyTitle), 1),
119
119
  _("div", ae, y(d.emptyDescription), 1)
120
120
  ])) : k("", !0),
121
- (i(!0), n(v, null, A(d.messages, (s) => {
121
+ (i(!0), n(v, null, V(d.messages, (s) => {
122
122
  var b;
123
123
  return i(), n(v, {
124
124
  key: s.id
@@ -126,7 +126,7 @@ const Q = { class: "wi-mobile-inputbox" }, X = /* @__PURE__ */ C({
126
126
  s.role === "user" ? (i(), n("div", ie, [
127
127
  _("div", ne, [
128
128
  (b = s.attachments) != null && b.length ? (i(), n("div", le, [
129
- (i(!0), n(v, null, A(s.attachments, (m) => (i(), n("span", {
129
+ (i(!0), n(v, null, V(s.attachments, (m) => (i(), n("span", {
130
130
  key: m.name,
131
131
  class: "wi-mobile-chat-messages__attachment"
132
132
  }, y(m.name), 1))), 128))
@@ -213,20 +213,21 @@ const Q = { class: "wi-mobile-inputbox" }, X = /* @__PURE__ */ C({
213
213
  }
214
214
  }), ye = /* @__PURE__ */ T(ce, [["__scopeId", "data-v-9bd22d00"]]);
215
215
  export {
216
- ke as AiAnswerBubble,
216
+ ke as AgentActionStatus,
217
+ ve as AiAnswerBubble,
217
218
  ye as ChatContainer,
218
219
  ue as ChatMessagesView,
219
- ve as ClarificationCard,
220
- Ce as DeepThinkingSteps,
221
- Te as IframePage,
220
+ Ce as ClarificationCard,
221
+ Te as DeepThinkingSteps,
222
+ Ie as IframePage,
222
223
  Y as Inputbox,
223
- Ie as KnowledgeStreamResult,
224
- Se as OutputFile,
225
- Be as createAnswerContentMap,
226
- Ee as injectIframeResizerChild,
224
+ Se as KnowledgeStreamResult,
225
+ Be as OutputFile,
226
+ Ee as createAnswerContentMap,
227
+ Ae as injectIframeResizerChild,
227
228
  Ve as provideIframePageConfig,
228
- Ae as provideOutputFileConfig,
229
- Fe as resolveIframePlaceholders,
230
- Oe as useIframePage
229
+ Fe as provideOutputFileConfig,
230
+ Oe as resolveIframePlaceholders,
231
+ De as useIframePage
231
232
  };
232
233
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,4 @@
1
+ import { StreamChunk } from '../../sse';
1
2
  import { ActionExecuteCommand, ActionResult, ActionDefinition } from './types';
2
3
 
3
4
  /**
@@ -36,3 +37,29 @@ export declare const wrapActionFrame: (frame: unknown) => ActionResult;
36
37
  * @returns 仅含 name / arguments 的 Action
37
38
  */
38
39
  export declare const normalizeActionDefinition: (action: ActionDefinition) => ActionDefinition;
40
+ /**
41
+ * front_reply 帧内 action_execute 指令的读取结果(三态,供各 parser 精确分流):
42
+ * - `ignored`:不是本协议(mode 不是 front_reply / type 不是 action_execute)→ parser 应 `return false`;
43
+ * - `invalid`:是 action_execute 但字段非法 → 由负责该执行端的 parser 回失败帧;
44
+ * - `ok`:解析成功,parser 再按 executor / action.name 判断是否自己负责。
45
+ */
46
+ export type FrontReplyActionResult = {
47
+ kind: 'ignored';
48
+ } | {
49
+ kind: 'invalid';
50
+ error: Error;
51
+ replyId?: string | number;
52
+ } | {
53
+ kind: 'ok';
54
+ command: ActionExecuteCommand;
55
+ replyId?: string | number;
56
+ };
57
+ /**
58
+ * 读取 front_reply 帧里的 action_execute 指令(只做通用协议解析,不做业务筛选)。
59
+ *
60
+ * 严格按 `type === 'action_execute'` 认领:其它 front_reply 载荷(别的业务回包)
61
+ * 一律 `ignored`,确保 `front_reply` 通道还能被其它场景复用。
62
+ * @param chunk 流式数据块
63
+ * @returns 三态读取结果(见 FrontReplyActionResult)
64
+ */
65
+ export declare const readFrontReplyAction: (chunk: StreamChunk) => FrontReplyActionResult;
@@ -0,0 +1,25 @@
1
+ import { AiAnswerReport } from '../../answer';
2
+ import { AnswerParser, AnswerParseOptions } from '../../registry';
3
+ import { StreamChunk } from '../../sse';
4
+ import { AgentActionValue } from './types';
5
+
6
+ /** agent 指令执行过程的回答类型(也是历史 report 的分发键) */
7
+ export declare const AGENT_ACTION_ANSWER_TYPE = "agent_action";
8
+ /**
9
+ * 处理实时流中的 agent 指令
10
+ * @param chunk 流式数据块
11
+ * @param reports 回答 reports 数组(registry 预取的同一引用,push 即累积)
12
+ * @param answerValues 回答整体结构(本 parser 不使用)
13
+ * @param options 解析配置(actionExecute 提供宿主执行器与回包通道)
14
+ * @returns 是否消费了该 chunk(只在自己负责的组合上返回 true)
15
+ */
16
+ export declare const applyAgentActionChunk: (chunk: StreamChunk, reports: AiAnswerReport<any>[], _answerValues?: unknown, options?: AnswerParseOptions) => boolean;
17
+ /**
18
+ * 历史归一化:历史里的执行过程卡片已无法确认执行结果,running 统一标为未知。
19
+ * @param report 历史 reports 中的执行过程报告(就地修改)
20
+ */
21
+ export declare const normalizeAgentActionReport: (report: AiAnswerReport<AgentActionValue>) => void;
22
+ /**
23
+ * agent_action 答案类型的注册表条目(registry 内置)
24
+ */
25
+ export declare const agentActionParser: AnswerParser<AgentActionValue>;
@@ -0,0 +1,26 @@
1
+ import { AiAnswerReport } from '../../answer';
2
+ import { AnswerParser, AnswerParseOptions } from '../../registry';
3
+ import { StreamChunk } from '../../sse';
4
+ import { ClarificationViewModel } from './types';
5
+
6
+ /** 确认卡片的回答类型(也是历史 report 的分发键) */
7
+ export declare const COLLECT_CLARIFICATIONS_ANSWER_TYPE = "collect_clarifications";
8
+ /**
9
+ * 处理实时流中的确认项指令
10
+ * @param chunk 流式数据块
11
+ * @param reports 回答 reports 数组(registry 预取的同一引用,push 即累积)
12
+ * @param answerValues 回答整体结构(本 parser 不使用)
13
+ * @param options 解析配置(actionExecute 提供回包通道与错误回调)
14
+ * @returns 是否消费了该 chunk(只在自己负责的组合上返回 true)
15
+ */
16
+ export declare const applyCollectClarificationsChunk: (chunk: StreamChunk, reports: AiAnswerReport<any>[], _answerValues?: unknown, options?: AnswerParseOptions) => boolean;
17
+ /**
18
+ * 历史归一化:历史里的确认卡片没有在途请求,统一标为已失效(只读展示)。
19
+ * 实时链路产出的 pending 报告若仍有在途请求则保持原状。
20
+ * @param report 历史 reports 中的确认卡片报告(就地修改)
21
+ */
22
+ export declare const normalizeCollectClarificationsReport: (report: AiAnswerReport<ClarificationViewModel>) => void;
23
+ /**
24
+ * collect_clarifications 答案类型的注册表条目(registry 内置)
25
+ */
26
+ export declare const collectClarificationsParser: AnswerParser<ClarificationViewModel>;
@@ -0,0 +1,17 @@
1
+ import { ActionExecuteOptions } from './types';
2
+
3
+ /**
4
+ * 发送一条 wait_reply
5
+ * @param options action_execute 配置(提供 reply 回传通道)
6
+ * @param replyId 后端 front_reply 的 reply_id
7
+ * @param values 回包载荷
8
+ * @returns 是否回传成功(false = 无回传通道 / 连接已关闭 / 发送异常)
9
+ */
10
+ export declare const replyWait: (options: ActionExecuteOptions | undefined, replyId: string | number | undefined, values: unknown) => boolean;
11
+ /**
12
+ * 回一条失败帧(指令非法 / 不支持的操作 / 执行异常),避免后端一直等待 wait_reply
13
+ * @param options action_execute 配置
14
+ * @param replyId 后端 reply_id
15
+ * @param message 失败原因
16
+ */
17
+ export declare const replyFailure: (options: ActionExecuteOptions | undefined, replyId: string | number | undefined, message: string) => void;
@@ -45,13 +45,14 @@ export interface WaitReplyPayload {
45
45
  values: unknown;
46
46
  }
47
47
  /**
48
- * front_reply 处理配置(经 AnswerParseOptions.frontReply 注入;
49
- * useChat 会自动补上 reply = sendWsMessage,宿主通常只需提供 execute)。
48
+ * action_execute 指令处理配置(只作用于 `executor === 'agent'` 的指令:
49
+ * agent 下发命令、宿主执行)。`executor === 'host'` 的 `collect_clarifications`
50
+ * 走确认卡片,不需要宿主注入执行器。
50
51
  */
51
- export interface FrontReplyOptions {
52
+ export interface ActionExecuteOptions {
52
53
  /**
53
- * host 执行器:executor === 'host' 时由宿主执行该 Action。
54
- * 未提供时 host 指令一律回失败帧(避免后端一直等待 wait_reply)。
54
+ * 宿主执行器:`executor === 'agent'` 的 action 由宿主执行。
55
+ * 未提供时一律回失败帧(避免后端一直等待 wait_reply)。
55
56
  * @param action 待执行的 Action(name + arguments)
56
57
  * @returns 统一执行结果(同步或异步均可)
57
58
  */
@@ -68,6 +69,26 @@ export interface FrontReplyOptions {
68
69
  */
69
70
  onError?: (error: unknown) => void;
70
71
  }
72
+ /** agent 下发指令的执行状态:执行中 / 成功 / 失败 / 未知(历史回放,状态已无法确认) */
73
+ export type AgentActionStatus = 'running' | 'success' | 'error' | 'unknown';
74
+ /**
75
+ * agent 指令的执行过程卡片(`answer_type = 'agent_action'` 的 values)
76
+ * 对应 `front_reply + action_execute + executor='agent'`:agent 发出命令,宿主执行并回包。
77
+ */
78
+ export interface AgentActionValue {
79
+ /** 卡片 id(取后端 reply_id,缺省时本地生成) */
80
+ id: string;
81
+ /** Action 名称 */
82
+ name: string;
83
+ /** Action 参数 */
84
+ arguments: Record<string, unknown>;
85
+ /** 当前执行状态 */
86
+ status: AgentActionStatus;
87
+ /** 状态说明(执行中 / 成功结果 / 失败原因) */
88
+ message: string;
89
+ /** 业务数据(执行成功时原样回传的 data,供 UI 展示) */
90
+ data?: unknown;
91
+ }
71
92
  /** 确认项输入类型 */
72
93
  export type ClarificationInputType = 'single_select' | 'multi_select' | 'date' | 'text';
73
94
  /** 确认项回答方式:结构化选项 / 自然语言 */
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=()=>({answer_type:"knowledge_stream_result",values:[{answer:""}]}),q=e=>(e.answer_type="knowledge_stream_result",(!Array.isArray(e.values)||!e.values.length)&&(e.values=[{answer:""}]),e),X=(e="",t="")=>({id:e,question:t,answer:{reports:[]}}),je=["knowledge_stream_begin","knowledge_stream","knowledge_stream_result","knowledge_stream_end"],$=(e,t,n,r)=>{var l;if(!e.mode||!je.includes(e.mode))return!1;if(e.mode==="knowledge_stream_result"||e.mode==="knowledge_stream_end")return!0;const o=r==null?void 0:r.beforeKnowledgeRender,s=u=>o?o(u):u;if(e.mode==="knowledge_stream_begin"){const u=t.at(-1);return(u==null?void 0:u.answer_type)==="knowledge_stream_result"?(u.values=u.values??[],u.values.push({answer:""}),!0):u&&!u.answer_type?(q(u),!0):(t.push(W()),!0)}if(e.mode!=="knowledge_stream")return!1;let i=t.at(-1);i&&!i.answer_type?i=q(i):(!i||i.answer_type!=="knowledge_stream_result")&&(i=W(),t.push(i)),i.values=(l=i.values)!=null&&l.length?i.values:[{answer:""}];const a=i.values[i.values.length-1],c=`${a.raw??""}${e.value||""}`;return a.raw=c,a.answer=s(c),!0},K=(e,t)=>{if(Array.isArray(e.values)&&e.values.length)return e;const n=t==null?void 0:t.beforeKnowledgeRender,r=s=>n?n(s):s;let o=[];return Array.isArray(e.knowledge)&&(o=e.knowledge.map(s=>typeof s=="string"?s:s==null?void 0:s.answer).filter(s=>typeof s=="string"&&s!=="")),o.length===0&&typeof e.answer=="string"&&e.answer!==""&&(o=[e.answer]),o.length&&(e.values=o.map(s=>({answer:r(s),raw:s}))),e},Y={id:"knowledge_stream",answerType:"knowledge_stream_result",applyChunk:$,normalizeReport:K},V=["begin","begin_stream","send_stream","end_stream"],J=(e,t)=>{if(!V.includes(e.mode||""))return!1;let n=t.at(-1);return(!n||n.answer_type)&&(n={exec_process:[]},t.push(n)),n.exec_process=n.exec_process??[],n.exec_process.push({mode:e.mode,type:e.type,value:e.value}),!0},Z=e=>{const t=[];let n="",r=!1;for(const o of(e.exec_process??[]).filter(s=>V.includes(s.mode||""))){const s=typeof o.value=="string"?o.value:"";o.mode==="begin"?(r&&n.trim()&&t.push(n.trim()),r=!1,n="",s.trim()&&t.push(s.trim())):o.mode==="begin_stream"?(r&&n.trim()&&t.push(n.trim()),r=!0,n=s):o.mode==="send_stream"&&r?n+=s:o.mode==="end_stream"&&r&&(n+=s,n.trim()&&t.push(n.trim()),r=!1,n="")}return r&&n.trim()&&t.push(n.trim()),t},j=e=>{var t;return(((t=e.answer)==null?void 0:t.reports)??[]).flatMap(Z)},Q={id:"deep_thinking",applyChunk:J},F='/**\n * Skipped minification because the original files appears to be already minified.\n * Original file: /npm/@iframe-resizer/child@5.1.5/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n/*!\n * @preserve\n * \n * @module iframe-resizer/child 5.1.5 (umd) - 2024-07-09\n *\n * @license GPL-3.0 for non-commercial use only.\n * For commercial use, you must purchase a license from\n * https://iframe-resizer.com/pricing\n * \n * @desciption Keep same and cross domain iFrames sized to their content \n *\n * @author David J. Bradshaw <info@iframe-resizer.com>\n * \n * @see {@link https://iframe-resizer.com}\n * \n * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.\n */\n\n\n!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.5",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(de("Custom height calculation function not defined"),He.auto()),width:()=>(de("Custom width calculation function not defined"),Ue.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,C=!0,T=!1,k=1,I=f,x=!0,N="",R={},B=!0,q=!1,L=0,W=!1,D="",H="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{de("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e,re=new WeakSet,ae=e=>"object"==typeof e&&re.add(e);function le(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ce(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\\n"," ")}...`:e}const se=(...e)=>[`[iframe-resizer][${D}]`,...e].join(" "),ue=(...e)=>console?.info(se(...e)),de=(...e)=>console?.warn(se(...e)),me=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\\n").replaceAll("<rb>","\x1B[31;1m").replaceAll("</>","\x1B[m").replaceAll("<b>","\x1B[1m").replaceAll("<i>","\x1B[3m").replaceAll("<u>","\x1B[4m")):e(t.replaceAll("<br>","\\n").replaceAll(/<[/a-z]+>/gi,"")))(se)(...e)),fe=e=>me(e);function pe(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");D=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],I=void 0===t[8]?I:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),H=void 0===t[13]?H:t[13],K=void 0===t[14]?K:t[14],W=void 0===t[15]?W:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,I=e?.heightCalculationMethod||I,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),I=t(I,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);he("margin",function(e,t){t.includes("-")&&(de(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),he("background",S),he("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),ye(),L<0?fe(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&fe(a(3)),function(){if(!Y||""===Y||"false"===Y)return void me("<rb>Legacy version detected on parent page</>\\n\\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\\n\\nSee <u>https://iframe-resizer.com/setup/</> for more details.\\n");Y!==e&&me(`<rb>Version mismatch</>\\n\\nThe parent and child pages are running different versions of <i>iframe resizer</>.\\n\\nParent page: ${Y} - Child page: ${e}.\\n`)}(),ze(),Se(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&me("<rb>Deprecated Attributes</>\\n \\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===I&&(I="autoOverflow"),"auto"===K&&(K="autoOverflow")),be(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,$e()):!1===e&&!0===z&&(z=!1,ve("remove"),U?.disconnect(),E?.disconnect()),Xe(0,0,"autoResize",JSON.stringify(z)),z),close(){Xe(0,0,"close")},getId:()=>D,getPageInfo(e){if("function"==typeof e)return ne=e,Xe(0,0,"pageInfo"),void me("<rb>Deprecated Method</>\\n \\nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n");ne=null,Xe(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Xe(0,0,"parentInfo"),()=>{oe=null,Xe(0,0,"parentInfoStop")}},getParentProperties(e){me("<rb>Renamed Method</>\\n \\nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Qe()},scrollBy(e,t){Xe(t,e,"scrollBy")},scrollTo(e,t){Xe(t,e,"scrollTo")},scrollToOffset(e,t){Xe(t,e,"scrollToOffset")},sendMessage(e,t){Xe(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){I=e,ze()},setWidthCalculationMethod(e){K=e,Se()},setTargetOrigin(e){Z=e},resize(e,t){Ve("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){me("<rb>Deprecated Method</>\\n \\nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==W)return;function e(e){Xe(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),$e(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Xe(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Xe(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll(\'a[href^="#"]\').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?me("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),ae(document.documentElement),ae(document.body),Ve("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Xe(0,0,"title",document.title),te(),B=!1}function he(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function ye(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function ge(e){({add(t){function n(){Ve(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ve(e){ge({method:e,eventType:"After Print",eventName:"afterprint"}),ge({method:e,eventType:"Before Print",eventName:"beforeprint"}),ge({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function be(){const e=document.querySelectorAll(`[${n}]`);T=e.length>0,A=T?e:Re(document)()}function we(e,t,n,o){return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&me(`<rb>Deprecated ${o}CalculationMethod (${e})</>\\n\\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ze(){I=we(I,f,He,"height")}function Se(){K=we(K,v,Ue,"width")}function $e(){!0===z&&(ve("add"),E=function(){function e(e){e.forEach(Te),ye(),be()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(Ee),Ce(window.document))}let je;function Ee(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;je=()=>Ve("resizeObserver",`Resize Observed: ${le(t)}`),setTimeout((()=>{je&&je(),je=void 0}),0)}const Pe=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Oe=()=>[...Re(document)()].filter(Pe),Me=new WeakSet;function Ae(e){e&&(Me.has(e)||(U.observe(e),Me.add(e)))}function Ce(e){[...Oe(),...g.flatMap((t=>e.querySelector(t)))].forEach(Ae)}function Te(e){"childList"===e.type&&Ce(e.target)}let ke=4,Ie=4;function xe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o=0,i=A.length,r=document.documentElement,a=T?0:document.documentElement.getBoundingClientRect().bottom,c=performance.now();var s;A.forEach((t=>{T||!m||t.checkVisibility(l)?(o=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),o>a&&(a=o,r=t)):i-=1})),c=performance.now()-c,i>1&&(s=r,re.has(s)||(ae(s),ue(`\\nHeight calculated from: ${le(s)} (${ce(s)})`)));const u=`\\nParsed ${i} element${1===i?"":"s"} in ${c.toPrecision(3)}ms\\n${t} ${T?"tagged ":""}element found at: ${a}px\\nPosition calculated from HTML element: ${le(r)} (${ce(r,100)})`;return c<4||i<99||T||B||ke<c&&ke<Ie&&(ke=1.2*c,me(`<rb>Performance Warning</>\\n\\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\\n${u}`)),Ie=c,a}const Ne=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Re=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Be=!1;function qe({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Be)return Be=!0,n.taggedElement();const r=o?"bottom":"right";return me(`<rb>Detected content overflowing html element</>\\n \\nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \\n\\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \\n \\nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\\n\\nMore info: https://iframe-resizer.com/performance.\\n\\n(Page size: ${i} > document size: ${e})`),o?I="autoOverflow":K="autoOverflow",n.taggedElement()}const Le={height:0,width:0},We={height:0,width:0};function De(e,t){function n(){return We[i]=r,Le[i]=c,r}const o=e===He,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===We[i]&&0===Le[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===We[i]&&c===Le[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==We[i]&&c<=Le[i]:return n();case!o:return t?e.taggedElement():qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<We[i]:case c===l||c===a:case r>c:return n();case!t:return qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const He={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>De(He,!1),autoOverflow:()=>De(He,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>He.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ne(He)),min:()=>Math.min(...Ne(He)),grow:()=>He.max(),lowestElement:()=>xe("bottom"),taggedElement:()=>xe("bottom")},Ue={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>De(Ue,!1),autoOverflow:()=>De(Ue,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ne(Ue)),min:()=>Math.min(...Ne(Ue)),rightMostElement:()=>xe("right"),scroll:()=>Math.max(Ue.bodyScroll(),Ue.documentElementScroll()),taggedElement:()=>xe("right")};function Fe(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?He[I]():n,a=void 0===o?Ue[K]():o,O&&e(k,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&I in y||M&&K in y)&&Qe():(Je(),k=r,G=a,Xe(k,G,e,i))}function Ve(e,t,n,o,i){document.hidden||Fe(e,0,n,o,i)}function Je(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Ze(e){k=He[I](),G=Ue[K](),Xe(k,G,e)}function Qe(e){const t=I;I=f,Je(),Ze("reset"),I=t}function Xe(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${D}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ye(e){const t={init:function(){N=e.data,J=e.source,pe(),C=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Ze("resetPage")},resize(){Ve("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Xe(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Xe(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==C?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||de(`Unexpected message (${e.data})`)}())}function Ge(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ye({data:e,sameDomain:!0}),o(window,"message",Ye),o(window,"readystatechange",Ge),Ge())}));\n',Pe="iframe-resizer/child 5.1.5",Oe=F,C=`<script>${F}<\/script>`,xe=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),ee=e=>{if(!e||typeof e!="object")return{};const t=e.values,n=s=>{const i=t&&typeof t=="object"?t[s]:void 0;if(typeof i=="string"&&i)return i;const a=e[s];return typeof a=="string"&&a?a:void 0},r=n("url"),o=n("srcdoc");return{...r?{url:r}:{},...o?{srcdoc:o}:{}}},P=e=>e&&(e.includes("</head>")?e.replace("</head>",`${C}</head>`):e.includes("<body")?e.replace("<body",`${C}<body`):C+e),ke=e=>!e||typeof e!="object"||Array.isArray(e)||!e.url&&!e.srcdoc?!1:!e.srcdoc||e.srcdoc.includes(Pe),te=(e,t)=>{if(e.mode!=="result"||xe(e.value)!=="url")return!1;const n=ee(e.value);return!n.url&&!n.srcdoc||(n.srcdoc&&(n.srcdoc=P(n.srcdoc)),t.push({answer_type:"url",values:n})),!0},ne=e=>{if(ke(e.values))return e;const t=ee(e);return!t.url&&!t.srcdoc||(t.srcdoc&&(t.srcdoc=P(t.srcdoc)),e.values=t),e},re={id:"iframe_page",answerType:"url",applyChunk:te,normalizeReport:ne},E="recordset",Me=["cols","values","chart","title","max_cols","parent_link_col","agent_key"],Re=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),S=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&(Array.isArray(e.cols)||Array.isArray(e.values)),oe=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e.values;if(S(t))return t;if(S(e))return e},se=(e,t)=>{if(e.mode!=="result"||Re(e.value)!==E)return!1;const n=oe(e.value);return n&&t.push({answer_type:E,values:n}),!0},ie=e=>{if(S(e.values))return e;const t=e;if(!S(t))return e;const n={};for(const r of Me)n[r]=t[r];return e.values=n,e},ae={id:"recordset",answerType:E,applyChunk:se,normalizeReport:ie},w="output_file",Ne=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),_=(e,t)=>{if(!e||typeof e!="object")return;const n=e[t];return typeof n=="string"&&n?n:void 0},O=e=>{if(!e||typeof e!="object")return{};const t=e.values&&typeof e.values=="object"?e.values:void 0,n=_(t,"file_id")??_(e,"file_id"),r=_(t,"file_name")??_(e,"file_name");return{...n?{file_id:n}:{},...r?{file_name:r}:{}}},ce=(e,t)=>{if(e.mode!=="result"||Ne(e.value)!==w)return!1;const n=O(e.value);return!n.file_id&&!n.file_name||t.push({answer_type:w,values:n}),!0},le=e=>{const t=O(e);if(!t.file_id&&!t.file_name)return e;const n=e.values&&typeof e.values=="object"&&!Array.isArray(e.values)?e.values:{};return(!t.file_id||n.file_id)&&(!t.file_name||n.file_name)||(e.values={...n,...t}),e},ue={id:w,answerType:w,applyChunk:ce,normalizeReport:le},y=e=>({success:!1,message:e,data:null}),Le=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{throw new Error("执行指令不是合法的 JSON")}},de=e=>{const t=Le(e);if(!t||typeof t!="object")throw new Error("执行指令格式无效");const{type:n,executor:r,action:o}=t;if(n!=="action_execute")throw new Error(`不支持的指令类型:${String(n??"")}`);if(r!=="host"&&r!=="agent")throw new Error(`不支持的执行端:${String(r??"")}`);if(!o||typeof o!="object"||typeof o.name!="string"||!o.name.trim())throw new Error("执行指令缺少合法的 action.name");if(!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))throw new Error("执行指令的 action.arguments 必须是对象");return{type:n,executor:r,action:{name:o.name,arguments:o.arguments}}},fe=(e,t="执行端未返回有效的执行结果")=>{if(!e||typeof e!="object")return y(t);const n=e;return typeof n.success!="boolean"?y("执行端返回的 success 必须是布尔值"):{success:n.success,message:typeof n.message=="string"?n.message:n.success?"操作成功":"操作失败",data:Object.prototype.hasOwnProperty.call(n,"data")?n.data??null:null}},He=e=>{if(e&&typeof e=="object"){const t=e;if(typeof t.success=="boolean")return e;if(t.json_ok===!0)return{success:!0,message:"操作成功",data:e};if(t.json_ok===!1)return{success:!1,message:typeof t.error=="string"?t.error:"操作失败",data:e}}return y("系统操作返回了无法识别的报文帧")},De=e=>({name:e.name,arguments:e.arguments}),Ue=["single_select","multi_select","date","text"],h=new Map;let G=0;const b=e=>!!e&&typeof e=="object"&&!Array.isArray(e),g=e=>typeof e=="string"&&e.trim()?e:void 0,Be=(e,t)=>{if(!Array.isArray(e)||e.length===0)throw new Error(`确认项 ${t} 缺少可选项`);return e.map((n,r)=>{if(!b(n)||typeof n.label!="string"||!n.label.trim())throw new Error(`确认项 ${t} 的第 ${r+1} 个选项格式无效`);if(!Object.prototype.hasOwnProperty.call(n,"value"))throw new Error(`确认项 ${t} 的第 ${r+1} 个选项缺少 value`);return{label:n.label,value:n.value}})},We=e=>{if(e===void 0)return;if(!b(e))throw new Error("确认项的 binding 必须是对象");const t={};return typeof e.actionIndex=="number"&&(t.actionIndex=e.actionIndex),typeof e.actionName=="string"&&(t.actionName=e.actionName),typeof e.parameterPath=="string"&&(t.parameterPath=e.parameterPath),t},qe=(e,t)=>{if(!b(e)||!Ue.includes(e.type))throw new Error(`确认项 ${t} 的 input.type 无效`);const n=e.type,r={type:n,placeholder:g(e.placeholder)};if((n==="single_select"||n==="multi_select")&&(r.options=Be(e.options,t)),n==="date"){if(e.format!==void 0&&e.format!=="YYYY-MM-DD")throw new Error(`确认项 ${t} 暂不支持日期格式 ${String(e.format)}`);r.format="YYYY-MM-DD"}if(e.textInput!==void 0){if(!b(e.textInput))throw new Error(`确认项 ${t} 的 textInput 必须是对象`);r.textInput={placeholder:g(e.textInput.placeholder)}}return r},me=e=>{if(!Array.isArray(e.items)||e.items.length===0)throw new Error("collect_clarifications 至少需要一个确认项");const t=new Set,n=e.items.map((r,o)=>{if(!b(r))throw new Error(`第 ${o+1} 个确认项格式无效`);const s=typeof r.id=="string"?r.id.trim():"",i=typeof r.question=="string"?r.question.trim():"";if(!s)throw new Error(`第 ${o+1} 个确认项缺少 id`);if(t.has(s))throw new Error(`确认项 id 重复:${s}`);if(!i)throw new Error(`确认项 ${s} 缺少 question`);return t.add(s),{id:s,question:i,description:g(r.description),required:r.required!==!1,default:r.default,binding:We(r.binding),input:qe(r.input,s)}});return{title:g(e.title)??"需要你确认几项信息",description:g(e.description)??"请补充以下信息,我会据此继续完成操作。",items:n}},pe=e=>e!==void 0?String(e):(G+=1,`clarification-${Date.now()}-${G}`),he=e=>{h.set(e.reportId,e)},Ge=e=>h.has(e),x=(e,t)=>{const n=e.reports.findIndex(r=>{var o;return((o=r.values)==null?void 0:o.requestId)===e.reportId});n<0||e.reports.splice(n,1,{...e.reports[n],values:{...e.reports[n].values,...t}})},ye=(e,t)=>{var n;if(!e.reply)return!1;try{return e.reply({type:"wait_reply",reply_id:e.replyId,values:t})!==!1}catch(r){return(n=e.onError)==null||n.call(e,r),!1}},Xe=(e,t)=>{const n=h.get(e);if(!n)return!1;h.delete(e);const r=ye(n,{success:!0,message:"用户已提交补充信息",data:{answers:t}});return x(n,{status:"submitted",resultMessage:r?"补充信息已提交":"补充信息已提交,但结果回传失败(连接已关闭)",answers:t}),!0},Ke=e=>{const t=h.get(e);if(!t)return!1;h.delete(e);const n=ye(t,{success:!1,message:"用户取消了补充信息",data:null});return x(t,{status:"cancelled",resultMessage:n?"已取消补充信息":"已取消补充信息,但结果回传失败(连接已关闭)"}),!0},Ye=()=>{h.forEach(e=>{x(e,{status:"expired",resultMessage:"本次补充信息已失效(回答已结束)"})}),h.clear()},k="collect_clarifications",Ve=["collect_clarifications"],ge=(e,t,n)=>{var r;if(!(e!=null&&e.reply))return!1;try{const o={type:"wait_reply",reply_id:t,values:n};return e.reply(o)!==!1}catch(o){return(r=e.onError)==null||r.call(e,o),!1}},z=(e,t,n)=>{ge(e,t,y(n))},Je=async(e,t,n)=>{var o,s,i;let r;try{const a=await((o=n==null?void 0:n.execute)==null?void 0:o.call(n,e));r=fe(a,`宿主未返回 ${e.name} 的执行结果`)}catch(a){(s=n==null?void 0:n.onError)==null||s.call(n,a),r=y(a instanceof Error?a.message:`${e.name} 执行失败`)}ge(n,t,r)||(i=n==null?void 0:n.onError)==null||i.call(n,new Error(`${e.name} 已执行,但 wait_reply 回传失败(连接已关闭)`))},we=(e,t,n,r)=>{var a,c;if(e.mode!=="front_reply")return!1;const o=r==null?void 0:r.frontReply,s=typeof e.reply_id=="string"||typeof e.reply_id=="number"?e.reply_id:void 0;let i;try{i=de(e.values??e.value)}catch(l){return(a=o==null?void 0:o.onError)==null||a.call(o,l),z(o,s,l instanceof Error?l.message:"执行指令解析失败"),!0}if(i.executor==="agent"){if(!Ve.includes(i.action.name))return z(o,s,`暂不支持的 Agent 操作:${i.action.name}`),!0;let l;try{l=me(i.action.arguments)}catch(d){return(c=o==null?void 0:o.onError)==null||c.call(o,d),z(o,s,d instanceof Error?d.message:"确认项参数无效"),!0}const u=pe(s),p={requestId:u,...l,status:"pending",resultMessage:""};return he({reportId:u,replyId:s,reports:t,reply:o==null?void 0:o.reply,onError:o==null?void 0:o.onError}),t.push({answer_type:k,values:p}),!0}return o!=null&&o.execute?(Je(i.action,s,o),!0):(z(o,s,`宿主未注入执行器,无法执行:${i.action.name}`),!0)},be=e=>{const t=e.values;!t||typeof t!="object"||t.status==="pending"&&(t.status="expired",t.resultMessage="本次补充信息已失效(回答已结束)")},ve={id:"action_execute",answerType:k,applyChunk:we,normalizeReport:be},A=[Q,Y,re,ae,ue,ve],Ze=e=>{const t=(e==null?void 0:e.parsers)??[];return t.length?[...A,...t]:A},Qe=(e,t,n)=>{var i;const r=(i=e.answer)==null?void 0:i.reports;if(!r)return[];const o=new Set(((n==null?void 0:n.parsers)??[]).filter(a=>a.applyChunk&&a.answerType).map(a=>a.answerType)),s=[];for(const a of Ze(n))a.applyChunk&&(A.includes(a)&&a.answerType&&o.has(a.answerType)||a.applyChunk(t,r,e,n)&&s.push(a.id));return s},_e=(e,t)=>{var s;const n=e.answer_type;if(!n)return;const o=((t==null?void 0:t.parsers)??[]).find(i=>i.answerType===n&&!!i.normalizeReport)??A.find(i=>i.answerType===n&&!!i.normalizeReport);(s=o==null?void 0:o.normalizeReport)==null||s.call(o,e,t)},M=(e,t="",n="",r)=>{var i;const o=(e==null?void 0:e.values)??e;if((i=o==null?void 0:o.answer)!=null&&i.reports){const a=o;for(const c of a.answer.reports)_e(c,r);return a}const s=X(t,n);return typeof o=="string"&&$({mode:"knowledge_stream",value:o},s.answer.reports,s,r),s},Fe={User:"user",Assistant:"assistant"};let et=0;const R=(e="msg")=>`${e}-${++et}`,ze=e=>{const t=e.trim();if(!t||t==="[DONE]")return null;const n=t.replace(/^data:\s*/,"");try{return JSON.parse(n)}catch{try{return JSON.parse(decodeURIComponent(n))}catch{return null}}},Ee=()=>{let e="";return{push(t){const n=(e+t).split(`
2
- `);return e=n.pop()||"",n},flush(){const t=e;return e="",t?[t]:[]}}},Se=30,tt=/[A-Za-z]:[\\/][^\s"'`,。;;、,()()【】\[\]<>|?*]*/g,nt=/\\\\[^\s"'`,。;;、,()()【】\[\]<>|?*]+/g,rt=/(^|[\s"'`((【\[::,,、])((?:\/[^\s"'`,。;;、,()()【】\[\]<>|?*\/]+){2,})/g,ot=/^(?:请帮忙|请帮我|帮我看看|帮我把|帮我|帮忙|请把|麻烦你|麻烦|劳驾|请你|请问|帮(?!助))\s*[::,,、\-—]?\s*/,T=e=>{const t=e.split(/[\\/]+/).filter(Boolean);return t.length?t[t.length-1]:""},st=e=>e.replace(nt,t=>T(t)).replace(tt,t=>T(t)).replace(rt,(t,n,r)=>n+T(r)),it=e=>{let t=String(e??"").replace(/\r\n|\r|\n/g," ").replace(/\s+/g," ").trim();if(!t)return"";t=st(t).replace(/\s+/g," ").trim();let n="";for(;n!==t;)n=t,t=t.replace(ot,"").trim(),t=t.replace(/^[::,,、\-—\s]+/,"").trim();return t.slice(0,Se)},at=async(e,t)=>{const n=e.getReader(),r=new TextDecoder,o=Ee(),s=i=>{const a=ze(i);a&&t(a)};try{for(;;){const{done:i,value:a}=await n.read();if(i)break;o.push(r.decode(a,{stream:!0})).forEach(s)}o.flush().forEach(s)}catch(i){throw await n.cancel().catch(()=>{}),i}finally{n.releaseLock()}},v=new Set(["png","jpg","jpeg","gif","webp","svg","bmp"]),N=e=>!e||isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,ct=e=>{var r;if(e.type&&e.type!=="file")return!1;const t=e.attachContent||{};if(t.groupType==="image")return!0;const n=(t.suffix||((r=e.name)!=null&&r.includes(".")?e.name.split(".").pop():"")||"").toLowerCase();return!!(v.has(n)||t.raw&&typeof t.raw.type=="string"&&t.raw.type.startsWith("image/"))},Ae=(e,t,n)=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?e:`${(t||"").replace(/\/$/,"")}${n}?file_id=${e}`,Ce=(e,t="",n)=>e?n?n(e):Ae(e,t,"/file/download_file"):"",lt=(e,t="",n)=>{const r=e.attachContent||{};return r.url?r.url:typeof r.fileContent=="string"&&r.fileContent.startsWith("data:image/")?r.fileContent:r.fileId?Ce(r.fileId,t,n):""},I=e=>{var a;const t=(e==null?void 0:e.name)||"",n=t.includes(".")&&((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"",r=v.has(n)||(e==null?void 0:e.type)&&typeof e.type=="string"&&e.type.startsWith("image/");let o;if(r&&typeof window<"u"&&typeof URL<"u"&&e instanceof Blob)try{o=URL.createObjectURL(e)}catch{o=void 0}const s=N(e==null?void 0:e.size),i=[n.toUpperCase(),s].filter(Boolean).join(" · ");return{type:"file",name:t,description:i,attachContent:{file_name:t,size:e==null?void 0:e.size,suffix:n,raw:e,url:o,groupType:r?"image":"file"}}},L=e=>{var s;const t=(e==null?void 0:e.file_name)??(e==null?void 0:e.name)??(e==null?void 0:e.title)??"",n=t.includes(".")&&((s=t.split(".").pop())==null?void 0:s.toLowerCase())||"",r=v.has(n)||(e==null?void 0:e.groupType)==="image",o=n?n.toUpperCase():"";return{type:"file",name:t,description:o,attachContent:{file_name:(e==null?void 0:e.file_name)??t,fileId:(e==null?void 0:e.file_id)??(e==null?void 0:e.id),fileContent:e==null?void 0:e.file_content,suffix:n,groupType:r?"image":"file"}}},Te=e=>{var r,o,s,i;const t=(e==null?void 0:e.values)??e,n=((r=t==null?void 0:t.attach)==null?void 0:r.files)??((s=(o=t==null?void 0:t.answer)==null?void 0:o.attach)==null?void 0:s.files)??(t==null?void 0:t.attach_files)??((i=t==null?void 0:t.answer)==null?void 0:i.attach_files)??[];return!Array.isArray(n)||n.length===0?[]:n.map(a=>L(a))},ut=e=>{var r,o;if(!e)return{type:"file",name:"",description:"",attachContent:{}};if(typeof Blob<"u"&&e instanceof Blob)return I(e);if(typeof e=="object"&&e.attachContent){const s=e.type||"file",i=e.name||e.attachContent.file_name||e.attachContent.name||"";let a=e.description||"";const c={...e.attachContent};if(s==="file"&&(!c.suffix&&i.includes(".")&&(c.suffix=((r=i.split(".").pop())==null?void 0:r.toLowerCase())||""),(c.groupType==="image"||c.suffix&&v.has(c.suffix.toLowerCase())||c.raw&&typeof c.raw.type=="string"&&c.raw.type.startsWith("image/"))&&(c.groupType="image"),!a)){const u=typeof c.size=="number"?N(c.size):c.size||"";a=[c.suffix?c.suffix.toUpperCase():"",u].filter(Boolean).join(" · ")}return{...e,type:s,name:i,description:a,attachContent:c}}if(e.file_id||e.fileId)return L(e);if(e.raw&&typeof Blob<"u"&&e.raw instanceof Blob){const s=I(e.raw);return{...s,...e,attachContent:{...s.attachContent,...e.attachContent}}}const t=e.name||e.title||"",n=t.includes(".")&&((o=t.split(".").pop())==null?void 0:o.toLowerCase())||"";return{type:e.type||"file",name:t,description:e.description||(n?n.toUpperCase():""),attachContent:{file_name:t,suffix:n,...e}}},H=e=>Te(e),dt=async e=>[...(await e.getHistoryGroups()).groups??[]].sort((r,o)=>String(o.create_time??"").localeCompare(String(r.create_time??""))),ft=async(e,t)=>{const n=await e.createHistoryGroup(t),r=(n==null?void 0:n.group_id)??(n==null?void 0:n.history_group_id)??"";if(!r)throw new Error("创建对话分组失败");return r},mt=(e,t)=>e.deleteHistoryGroup(t),pt=(e,t,n)=>e.setHistoryGroupTitle(t,n),Ie=5,$e=async(e,t,n)=>{const r=new Array(e.length);let o=0;const s=Array.from({length:Math.min(t,e.length)},async()=>{for(;o<e.length;){const i=o++;r[i]=await n(e[i],i)}});return await Promise.all(s),r},ht=async(e,t,n=10,r=0,o)=>{if(!t)return[];const i=[...await e.getHistoryDetail(t,r,n)].sort((l,u)=>String(l.create_time||"").localeCompare(String(u.create_time||""))),a=await $e(i,Ie,async l=>{try{return await e.getHistoryAnswer(l.history_id||"")}catch{return null}}),c=[];return i.forEach((l,u)=>{const p=l.history_id||R("h"),d=a[u],f=d!=null?H(d):[];if(c.push({id:p,historyId:l.history_id,role:"user",content:l.question??"",attachments:f.length>0?f:void 0}),d!=null){const m=M(d,p,l.question??"",o);c.push({id:`${p}-answer`,historyId:l.history_id,role:"assistant",answer:m,error:!1,stopped:!1,thinking:{steps:j(m),expanded:!1}})}}),c},yt=async(e,t,n=10,r,o=0,s)=>{if(!t)return r==null||r({type:"users",users:[]}),[];const a=[...await e.getHistoryDetail(t,o,n)].sort((d,f)=>String(d.create_time||"").localeCompare(String(f.create_time||""))),c=a.map(d=>d.history_id||R("h")),l=a.map((d,f)=>({id:c[f],historyId:d.history_id,role:"user",content:d.question??""}));r==null||r({type:"users",users:l});const u=new Array(a.length).fill(null);await $e(a,Ie,async(d,f)=>{let m=null;try{m=await e.getHistoryAnswer(d.history_id||"")}catch{m=null}if(m==null)return;const D=H(m);D.length>0&&(l[f].attachments=D);const U=M(m,c[f],d.question??"",s),B={id:`${c[f]}-answer`,historyId:d.history_id,role:"assistant",answer:U,error:!1,stopped:!1,thinking:{steps:j(U),expanded:!1}};u[f]=B,r==null||r({type:"assistant",index:f,user:l[f],assistant:B})});const p=[];return a.forEach((d,f)=>{p.push(l[f]);const m=u[f];m&&p.push(m)}),p};exports.ACTION_EXECUTE_ANSWER_TYPE=k;exports.CHAT_TITLE_MAX_LENGTH=Se;exports.IFRAME_RESIZER_CHILD_SCRIPT=Oe;exports.IMAGE_EXTENSIONS=v;exports.OUTPUT_FILE_ANSWER_TYPE=w;exports.RECORDSET_ANSWER_TYPE=E;exports.RoleEnum=Fe;exports.actionExecuteParser=ve;exports.applyActionExecuteChunk=we;exports.applyAnswerChunk=Qe;exports.applyDeepThinkingChunk=J;exports.applyIframePageChunk=te;exports.applyKnowledgeStreamChunk=$;exports.applyOutputFileChunk=ce;exports.applyRecordsetChunk=se;exports.buildChatTitle=it;exports.cancelClarification=Ke;exports.clearPendingClarifications=Ye;exports.collectDeepThinkingSteps=Z;exports.collectThinkingSteps=j;exports.consumeStream=at;exports.createEmptyAnswerValues=X;exports.createFailureResult=y;exports.createHistoryGroup=ft;exports.createLineSplitter=Ee;exports.deepThinkingParser=Q;exports.deleteHistoryGroup=mt;exports.extractAttachmentsFromHistory=H;exports.extractHistoryAttachments=Te;exports.formatFileSize=N;exports.getHistoryGroups=dt;exports.hasPendingClarification=Ge;exports.iframePageParser=re;exports.injectIframeResizerScript=P;exports.isImageAttachment=ct;exports.knowledgeStreamParser=Y;exports.loadGroupMessages=ht;exports.loadGroupMessagesByStep=yt;exports.nextClarificationRequestId=pe;exports.nextLocalMessageId=R;exports.normalizeActionDefinition=De;exports.normalizeActionExecuteReport=be;exports.normalizeActionResult=fe;exports.normalizeAnswer=M;exports.normalizeAnswerReport=_e;exports.normalizeAttachment=ut;exports.normalizeIframePageReport=ne;exports.normalizeKnowledgeStreamReport=K;exports.normalizeOutputFileReport=le;exports.normalizeRecordsetReport=ie;exports.outputFileParser=ue;exports.parseActionExecuteCommand=de;exports.parseClarificationArguments=me;exports.parseHistoryAttachment=L;exports.parseRealtimeAttachment=I;exports.parseSseLine=ze;exports.readOutputFilePayload=O;exports.readRecordsetPayload=oe;exports.recordsetParser=ae;exports.registerClarification=he;exports.resolveAttachDownloadUrl=Ce;exports.resolveAttachPreviewUrl=lt;exports.resolveRemoteFileUrl=Ae;exports.setHistoryGroupTitle=pt;exports.submitClarification=Xe;exports.wrapActionFrame=He;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=()=>({answer_type:"knowledge_stream_result",values:[{answer:""}]}),G=e=>(e.answer_type="knowledge_stream_result",(!Array.isArray(e.values)||!e.values.length)&&(e.values=[{answer:""}]),e),K=(e="",t="")=>({id:e,question:t,answer:{reports:[]}}),Me=["knowledge_stream_begin","knowledge_stream","knowledge_stream_result","knowledge_stream_end"],I=(e,t,n,r)=>{var u;if(!e.mode||!Me.includes(e.mode))return!1;if(e.mode==="knowledge_stream_result"||e.mode==="knowledge_stream_end")return!0;const o=r==null?void 0:r.beforeKnowledgeRender,s=l=>o?o(l):l;if(e.mode==="knowledge_stream_begin"){const l=t.at(-1);return(l==null?void 0:l.answer_type)==="knowledge_stream_result"?(l.values=l.values??[],l.values.push({answer:""}),!0):l&&!l.answer_type?(G(l),!0):(t.push(q()),!0)}if(e.mode!=="knowledge_stream")return!1;let a=t.at(-1);a&&!a.answer_type?a=G(a):(!a||a.answer_type!=="knowledge_stream_result")&&(a=q(),t.push(a)),a.values=(u=a.values)!=null&&u.length?a.values:[{answer:""}];const i=a.values[a.values.length-1],c=`${i.raw??""}${e.value||""}`;return i.raw=c,i.answer=s(c),!0},V=(e,t)=>{if(Array.isArray(e.values)&&e.values.length)return e;const n=t==null?void 0:t.beforeKnowledgeRender,r=s=>n?n(s):s;let o=[];return Array.isArray(e.knowledge)&&(o=e.knowledge.map(s=>typeof s=="string"?s:s==null?void 0:s.answer).filter(s=>typeof s=="string"&&s!=="")),o.length===0&&typeof e.answer=="string"&&e.answer!==""&&(o=[e.answer]),o.length&&(e.values=o.map(s=>({answer:r(s),raw:s}))),e},J={id:"knowledge_stream",answerType:"knowledge_stream_result",applyChunk:I,normalizeReport:V},Z=["begin","begin_stream","send_stream","end_stream"],F=(e,t)=>{if(!Z.includes(e.mode||""))return!1;let n=t.at(-1);return(!n||n.answer_type)&&(n={exec_process:[]},t.push(n)),n.exec_process=n.exec_process??[],n.exec_process.push({mode:e.mode,type:e.type,value:e.value}),!0},Q=e=>{const t=[];let n="",r=!1;for(const o of(e.exec_process??[]).filter(s=>Z.includes(s.mode||""))){const s=typeof o.value=="string"?o.value:"";o.mode==="begin"?(r&&n.trim()&&t.push(n.trim()),r=!1,n="",s.trim()&&t.push(s.trim())):o.mode==="begin_stream"?(r&&n.trim()&&t.push(n.trim()),r=!0,n=s):o.mode==="send_stream"&&r?n+=s:o.mode==="end_stream"&&r&&(n+=s,n.trim()&&t.push(n.trim()),r=!1,n="")}return r&&n.trim()&&t.push(n.trim()),t},$=e=>{var t;return(((t=e.answer)==null?void 0:t.reports)??[]).flatMap(Q)},ee={id:"deep_thinking",applyChunk:F},te='/**\n * Skipped minification because the original files appears to be already minified.\n * Original file: /npm/@iframe-resizer/child@5.1.5/index.umd.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n/*!\n * @preserve\n * \n * @module iframe-resizer/child 5.1.5 (umd) - 2024-07-09\n *\n * @license GPL-3.0 for non-commercial use only.\n * For commercial use, you must purchase a license from\n * https://iframe-resizer.com/pricing\n * \n * @desciption Keep same and cross domain iFrames sized to their content \n *\n * @author David J. Bradshaw <info@iframe-resizer.com>\n * \n * @see {@link https://iframe-resizer.com}\n * \n * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.\n */\n\n\n!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.5",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(de("Custom height calculation function not defined"),He.auto()),width:()=>(de("Custom width calculation function not defined"),Ue.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,C=!0,T=!1,k=1,I=f,x=!0,N="",R={},B=!0,q=!1,L=0,W=!1,D="",H="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{de("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e,re=new WeakSet,ae=e=>"object"==typeof e&&re.add(e);function le(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ce(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\\n"," ")}...`:e}const se=(...e)=>[`[iframe-resizer][${D}]`,...e].join(" "),ue=(...e)=>console?.info(se(...e)),de=(...e)=>console?.warn(se(...e)),me=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\\n").replaceAll("<rb>","\x1B[31;1m").replaceAll("</>","\x1B[m").replaceAll("<b>","\x1B[1m").replaceAll("<i>","\x1B[3m").replaceAll("<u>","\x1B[4m")):e(t.replaceAll("<br>","\\n").replaceAll(/<[/a-z]+>/gi,"")))(se)(...e)),fe=e=>me(e);function pe(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");D=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],I=void 0===t[8]?I:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),H=void 0===t[13]?H:t[13],K=void 0===t[14]?K:t[14],W=void 0===t[15]?W:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,I=e?.heightCalculationMethod||I,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),I=t(I,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);he("margin",function(e,t){t.includes("-")&&(de(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),he("background",S),he("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),ye(),L<0?fe(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&fe(a(3)),function(){if(!Y||""===Y||"false"===Y)return void me("<rb>Legacy version detected on parent page</>\\n\\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\\n\\nSee <u>https://iframe-resizer.com/setup/</> for more details.\\n");Y!==e&&me(`<rb>Version mismatch</>\\n\\nThe parent and child pages are running different versions of <i>iframe resizer</>.\\n\\nParent page: ${Y} - Child page: ${e}.\\n`)}(),ze(),Se(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&me("<rb>Deprecated Attributes</>\\n \\nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===I&&(I="autoOverflow"),"auto"===K&&(K="autoOverflow")),be(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,$e()):!1===e&&!0===z&&(z=!1,ve("remove"),U?.disconnect(),E?.disconnect()),Xe(0,0,"autoResize",JSON.stringify(z)),z),close(){Xe(0,0,"close")},getId:()=>D,getPageInfo(e){if("function"==typeof e)return ne=e,Xe(0,0,"pageInfo"),void me("<rb>Deprecated Method</>\\n \\nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n");ne=null,Xe(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Xe(0,0,"parentInfo"),()=>{oe=null,Xe(0,0,"parentInfoStop")}},getParentProperties(e){me("<rb>Renamed Method</>\\n \\nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Qe()},scrollBy(e,t){Xe(t,e,"scrollBy")},scrollTo(e,t){Xe(t,e,"scrollTo")},scrollToOffset(e,t){Xe(t,e,"scrollToOffset")},sendMessage(e,t){Xe(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){I=e,ze()},setWidthCalculationMethod(e){K=e,Se()},setTargetOrigin(e){Z=e},resize(e,t){Ve("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){me("<rb>Deprecated Method</>\\n \\nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==W)return;function e(e){Xe(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),$e(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Xe(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Xe(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll(\'a[href^="#"]\').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?me("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),ae(document.documentElement),ae(document.body),Ve("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Xe(0,0,"title",document.title),te(),B=!1}function he(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function ye(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function ge(e){({add(t){function n(){Ve(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ve(e){ge({method:e,eventType:"After Print",eventName:"afterprint"}),ge({method:e,eventType:"Before Print",eventName:"beforeprint"}),ge({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function be(){const e=document.querySelectorAll(`[${n}]`);T=e.length>0,A=T?e:Re(document)()}function we(e,t,n,o){return t!==e&&(e in n||(de(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&me(`<rb>Deprecated ${o}CalculationMethod (${e})</>\\n\\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function ze(){I=we(I,f,He,"height")}function Se(){K=we(K,v,Ue,"width")}function $e(){!0===z&&(ve("add"),E=function(){function e(e){e.forEach(Te),ye(),be()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver(Ee),Ce(window.document))}let je;function Ee(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;je=()=>Ve("resizeObserver",`Resize Observed: ${le(t)}`),setTimeout((()=>{je&&je(),je=void 0}),0)}const Pe=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Oe=()=>[...Re(document)()].filter(Pe),Me=new WeakSet;function Ae(e){e&&(Me.has(e)||(U.observe(e),Me.add(e)))}function Ce(e){[...Oe(),...g.flatMap((t=>e.querySelector(t)))].forEach(Ae)}function Te(e){"childList"===e.type&&Ce(e.target)}let ke=4,Ie=4;function xe(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o=0,i=A.length,r=document.documentElement,a=T?0:document.documentElement.getBoundingClientRect().bottom,c=performance.now();var s;A.forEach((t=>{T||!m||t.checkVisibility(l)?(o=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),o>a&&(a=o,r=t)):i-=1})),c=performance.now()-c,i>1&&(s=r,re.has(s)||(ae(s),ue(`\\nHeight calculated from: ${le(s)} (${ce(s)})`)));const u=`\\nParsed ${i} element${1===i?"":"s"} in ${c.toPrecision(3)}ms\\n${t} ${T?"tagged ":""}element found at: ${a}px\\nPosition calculated from HTML element: ${le(r)} (${ce(r,100)})`;return c<4||i<99||T||B||ke<c&&ke<Ie&&(ke=1.2*c,me(`<rb>Performance Warning</>\\n\\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\\n${u}`)),Ie=c,a}const Ne=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],Re=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let Be=!1;function qe({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!Be)return Be=!0,n.taggedElement();const r=o?"bottom":"right";return me(`<rb>Detected content overflowing html element</>\\n \\nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \\n\\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \\n \\nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\\n\\nMore info: https://iframe-resizer.com/performance.\\n\\n(Page size: ${i} > document size: ${e})`),o?I="autoOverflow":K="autoOverflow",n.taggedElement()}const Le={height:0,width:0},We={height:0,width:0};function De(e,t){function n(){return We[i]=r,Le[i]=c,r}const o=e===He,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===We[i]&&0===Le[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===We[i]&&c===Le[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==We[i]&&c<=Le[i]:return n();case!o:return t?e.taggedElement():qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<We[i]:case c===l||c===a:case r>c:return n();case!t:return qe({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const He={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>De(He,!1),autoOverflow:()=>De(He,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>He.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ne(He)),min:()=>Math.min(...Ne(He)),grow:()=>He.max(),lowestElement:()=>xe("bottom"),taggedElement:()=>xe("bottom")},Ue={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>De(Ue,!1),autoOverflow:()=>De(Ue,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ne(Ue)),min:()=>Math.min(...Ne(Ue)),rightMostElement:()=>xe("right"),scroll:()=>Math.max(Ue.bodyScroll(),Ue.documentElementScroll()),taggedElement:()=>xe("right")};function Fe(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?He[I]():n,a=void 0===o?Ue[K]():o,O&&e(k,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&I in y||M&&K in y)&&Qe():(Je(),k=r,G=a,Xe(k,G,e,i))}function Ve(e,t,n,o,i){document.hidden||Fe(e,0,n,o,i)}function Je(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Ze(e){k=He[I](),G=Ue[K](),Xe(k,G,e)}function Qe(e){const t=I;I=f,Je(),Ze("reset"),I=t}function Xe(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${D}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ye(e){const t={init:function(){N=e.data,J=e.source,pe(),C=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Ze("resetPage")},resize(){Ve("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Xe(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Xe(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==C?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||de(`Unexpected message (${e.data})`)}())}function Ge(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ye({data:e,sameDomain:!0}),o(window,"message",Ye),o(window,"readystatechange",Ge),Ge())}));\n',Ne="iframe-resizer/child 5.1.5",Le=te,C=`<script>${te}<\/script>`,He=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),ne=e=>{if(!e||typeof e!="object")return{};const t=e.values,n=s=>{const a=t&&typeof t=="object"?t[s]:void 0;if(typeof a=="string"&&a)return a;const i=e[s];return typeof i=="string"&&i?i:void 0},r=n("url"),o=n("srcdoc");return{...r?{url:r}:{},...o?{srcdoc:o}:{}}},j=e=>e&&(e.includes("</head>")?e.replace("</head>",`${C}</head>`):e.includes("<body")?e.replace("<body",`${C}<body`):C+e),De=e=>!e||typeof e!="object"||Array.isArray(e)||!e.url&&!e.srcdoc?!1:!e.srcdoc||e.srcdoc.includes(Ne),re=(e,t)=>{if(e.mode!=="result"||He(e.value)!=="url")return!1;const n=ne(e.value);return!n.url&&!n.srcdoc||(n.srcdoc&&(n.srcdoc=j(n.srcdoc)),t.push({answer_type:"url",values:n})),!0},oe=e=>{if(De(e.values))return e;const t=ne(e);return!t.url&&!t.srcdoc||(t.srcdoc&&(t.srcdoc=j(t.srcdoc)),e.values=t),e},se={id:"iframe_page",answerType:"url",applyChunk:re,normalizeReport:oe},z="recordset",Be=["cols","values","chart","title","max_cols","parent_link_col","agent_key"],Ue=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),A=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&(Array.isArray(e.cols)||Array.isArray(e.values)),ae=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e.values;if(A(t))return t;if(A(e))return e},ie=(e,t)=>{if(e.mode!=="result"||Ue(e.value)!==z)return!1;const n=ae(e.value);return n&&t.push({answer_type:z,values:n}),!0},ce=e=>{if(A(e.values))return e;const t=e;if(!A(t))return e;const n={};for(const r of Be)n[r]=t[r];return e.values=n,e},le={id:"recordset",answerType:z,applyChunk:ie,normalizeReport:ce},w="output_file",We=e=>!e||typeof e!="object"?"":String(e.type||e.answer_type||""),_=(e,t)=>{if(!e||typeof e!="object")return;const n=e[t];return typeof n=="string"&&n?n:void 0},P=e=>{if(!e||typeof e!="object")return{};const t=e.values&&typeof e.values=="object"?e.values:void 0,n=_(t,"file_id")??_(e,"file_id"),r=_(t,"file_name")??_(e,"file_name");return{...n?{file_id:n}:{},...r?{file_name:r}:{}}},ue=(e,t)=>{if(e.mode!=="result"||We(e.value)!==w)return!1;const n=P(e.value);return!n.file_id&&!n.file_name||t.push({answer_type:w,values:n}),!0},de=e=>{const t=P(e);if(!t.file_id&&!t.file_name)return e;const n=e.values&&typeof e.values=="object"&&!Array.isArray(e.values)?e.values:{};return(!t.file_id||n.file_id)&&(!t.file_name||n.file_name)||(e.values={...n,...t}),e},fe={id:w,answerType:w,applyChunk:ue,normalizeReport:de},h=e=>({success:!1,message:e,data:null}),qe=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{throw new Error("执行指令不是合法的 JSON")}},me=e=>{const t=qe(e);if(!t||typeof t!="object")throw new Error("执行指令格式无效");const{type:n,executor:r,action:o}=t;if(n!=="action_execute")throw new Error(`不支持的指令类型:${String(n??"")}`);if(r!=="host"&&r!=="agent")throw new Error(`不支持的执行端:${String(r??"")}`);if(!o||typeof o!="object"||typeof o.name!="string"||!o.name.trim())throw new Error("执行指令缺少合法的 action.name");if(!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))throw new Error("执行指令的 action.arguments 必须是对象");return{type:n,executor:r,action:{name:o.name,arguments:o.arguments}}},pe=(e,t="执行端未返回有效的执行结果")=>{if(!e||typeof e!="object")return h(t);const n=e;return typeof n.success!="boolean"?h("执行端返回的 success 必须是布尔值"):{success:n.success,message:typeof n.message=="string"?n.message:n.success?"操作成功":"操作失败",data:Object.prototype.hasOwnProperty.call(n,"data")?n.data??null:null}},Ge=e=>{if(e&&typeof e=="object"){const t=e;if(typeof t.success=="boolean")return e;if(t.json_ok===!0)return{success:!0,message:"操作成功",data:e};if(t.json_ok===!1)return{success:!1,message:typeof t.error=="string"?t.error:"操作失败",data:e}}return h("系统操作返回了无法识别的报文帧")},Xe=e=>({name:e.name,arguments:e.arguments}),Ye=e=>typeof e.reply_id=="string"||typeof e.reply_id=="number"?e.reply_id:void 0,k=e=>{if((e==null?void 0:e.mode)!=="front_reply")return{kind:"ignored"};const t=Ye(e),n=e.values??e.value;let r=n;if(typeof n=="string")try{r=JSON.parse(n)}catch{return{kind:"ignored"}}if(!r||typeof r!="object"||Array.isArray(r)||r.type!=="action_execute")return{kind:"ignored"};try{return{kind:"ok",replyId:t,command:me(r)}}catch(o){return{kind:"invalid",replyId:t,error:o instanceof Error?o:new Error("执行指令解析失败")}}},Ke=["single_select","multi_select","date","text"],y=new Map;let X=0;const b=e=>!!e&&typeof e=="object"&&!Array.isArray(e),g=e=>typeof e=="string"&&e.trim()?e:void 0,Ve=(e,t)=>{if(!Array.isArray(e)||e.length===0)throw new Error(`确认项 ${t} 缺少可选项`);return e.map((n,r)=>{if(!b(n)||typeof n.label!="string"||!n.label.trim())throw new Error(`确认项 ${t} 的第 ${r+1} 个选项格式无效`);if(!Object.prototype.hasOwnProperty.call(n,"value"))throw new Error(`确认项 ${t} 的第 ${r+1} 个选项缺少 value`);return{label:n.label,value:n.value}})},Je=e=>{if(e===void 0)return;if(!b(e))throw new Error("确认项的 binding 必须是对象");const t={};return typeof e.actionIndex=="number"&&(t.actionIndex=e.actionIndex),typeof e.actionName=="string"&&(t.actionName=e.actionName),typeof e.parameterPath=="string"&&(t.parameterPath=e.parameterPath),t},Ze=(e,t)=>{if(!b(e)||!Ke.includes(e.type))throw new Error(`确认项 ${t} 的 input.type 无效`);const n=e.type,r={type:n,placeholder:g(e.placeholder)};if((n==="single_select"||n==="multi_select")&&(r.options=Ve(e.options,t)),n==="date"){if(e.format!==void 0&&e.format!=="YYYY-MM-DD")throw new Error(`确认项 ${t} 暂不支持日期格式 ${String(e.format)}`);r.format="YYYY-MM-DD"}if(e.textInput!==void 0){if(!b(e.textInput))throw new Error(`确认项 ${t} 的 textInput 必须是对象`);r.textInput={placeholder:g(e.textInput.placeholder)}}return r},ye=e=>{if(!Array.isArray(e.items)||e.items.length===0)throw new Error("collect_clarifications 至少需要一个确认项");const t=new Set,n=e.items.map((r,o)=>{if(!b(r))throw new Error(`第 ${o+1} 个确认项格式无效`);const s=typeof r.id=="string"?r.id.trim():"",a=typeof r.question=="string"?r.question.trim():"";if(!s)throw new Error(`第 ${o+1} 个确认项缺少 id`);if(t.has(s))throw new Error(`确认项 id 重复:${s}`);if(!a)throw new Error(`确认项 ${s} 缺少 question`);return t.add(s),{id:s,question:a,description:g(r.description),required:r.required!==!1,default:r.default,binding:Je(r.binding),input:Ze(r.input,s)}});return{title:g(e.title)??"需要你确认几项信息",description:g(e.description)??"请补充以下信息,我会据此继续完成操作。",items:n}},he=e=>e!==void 0?String(e):(X+=1,`clarification-${Date.now()}-${X}`),ge=e=>{y.set(e.reportId,e)},Fe=e=>y.has(e),O=(e,t)=>{const n=e.reports.findIndex(r=>{var o;return((o=r.values)==null?void 0:o.requestId)===e.reportId});n<0||e.reports.splice(n,1,{...e.reports[n],values:{...e.reports[n].values,...t}})},we=(e,t)=>{var n;if(!e.reply)return!1;try{return e.reply({type:"wait_reply",reply_id:e.replyId,values:t})!==!1}catch(r){return(n=e.onError)==null||n.call(e,r),!1}},Qe=(e,t)=>{const n=y.get(e);if(!n)return!1;y.delete(e);const r=we(n,{success:!0,message:"用户已提交补充信息",data:{answers:t}});return O(n,{status:"submitted",resultMessage:r?"补充信息已提交":"补充信息已提交,但结果回传失败(连接已关闭)",answers:t}),!0},et=e=>{const t=y.get(e);if(!t)return!1;y.delete(e);const n=we(t,{success:!1,message:"用户取消了补充信息",data:null});return O(t,{status:"cancelled",resultMessage:n?"已取消补充信息":"已取消补充信息,但结果回传失败(连接已关闭)"}),!0},tt=()=>{y.forEach(e=>{O(e,{status:"expired",resultMessage:"本次补充信息已失效(回答已结束)"})}),y.clear()},be=(e,t,n)=>{var r;if(!(e!=null&&e.reply))return!1;try{const o={type:"wait_reply",reply_id:t,values:n};return e.reply(o)!==!1}catch(o){return(r=e.onError)==null||r.call(e,o),!1}},ve=(e,t,n)=>{be(e,t,h(n))},x="collect_clarifications",_e=(e,t,n,r)=>{var m;const o=k(e);if(o.kind!=="ok")return!1;const{command:s,replyId:a}=o;if(s.executor!=="host"||s.action.name!=="collect_clarifications")return!1;const i=r==null?void 0:r.actionExecute;let c;try{c=ye(s.action.arguments)}catch(d){return(m=i==null?void 0:i.onError)==null||m.call(i,d),ve(i,a,d instanceof Error?d.message:"确认项参数无效"),!0}const u=he(a),l={requestId:u,...c,status:"pending",resultMessage:""};return ge({reportId:u,replyId:a,reports:t,reply:i==null?void 0:i.reply,onError:i==null?void 0:i.onError}),t.push({answer_type:x,values:l}),!0},ze=e=>{const t=e.values;!t||typeof t!="object"||t.status==="pending"&&(t.status="expired",t.resultMessage="本次补充信息已失效(回答已结束)")},Ae={id:"collect_clarifications",answerType:x,applyChunk:_e,normalizeReport:ze},S="agent_action";let Y=0;const nt=e=>e!==void 0?String(e):(Y+=1,`agent-action-${Date.now()}-${Y}`),rt=(e,t,n)=>{const r=e.findIndex(o=>{var s;return o.answer_type===S&&((s=o.values)==null?void 0:s.id)===t});r<0||e.splice(r,1,{...e[r],values:{...e[r].values,...n}})},ot=async(e,t,n,r,o)=>{var a,i;let s;if(!(o!=null&&o.execute))s=h(`宿主未注入执行器,无法执行:${e.name}`);else try{s=pe(await o.execute(e),`宿主未返回 ${e.name} 的执行结果`)}catch(c){(a=o.onError)==null||a.call(o,c),s=h(c instanceof Error?c.message:`${e.name} 执行失败`)}rt(r,t,{status:s.success?"success":"error",message:s.message,data:s.data??void 0}),be(o,n,s)||(i=o==null?void 0:o.onError)==null||i.call(o,new Error(`${e.name} 已执行,但 wait_reply 回传失败(连接已关闭)`))},Ee=(e,t,n,r)=>{var l;const o=k(e);if(o.kind==="ignored")return!1;const s=r==null?void 0:r.actionExecute;if(o.kind==="invalid")return(l=s==null?void 0:s.onError)==null||l.call(s,o.error),ve(s,o.replyId,o.error.message),!0;const{command:a,replyId:i}=o;if(a.executor!=="agent")return!1;const c=nt(i),u={id:c,name:a.action.name,arguments:a.action.arguments,status:"running",message:"执行中…"};return t.push({answer_type:S,values:u}),ot(a.action,c,i,t,s),!0},Se=e=>{const t=e.values;!t||typeof t!="object"||t.status==="running"&&(t.status="unknown",t.message="执行状态未知(回答已结束)")},Ce={id:"agent_action",answerType:S,applyChunk:Ee,normalizeReport:Se},E=[ee,J,se,le,fe,Ae,Ce],st=e=>{const t=(e==null?void 0:e.parsers)??[];return t.length?[...E,...t]:E},at=(e,t,n)=>{var a;const r=(a=e.answer)==null?void 0:a.reports;if(!r)return[];const o=new Set(((n==null?void 0:n.parsers)??[]).filter(i=>i.applyChunk&&i.answerType).map(i=>i.answerType)),s=[];for(const i of st(n))i.applyChunk&&(E.includes(i)&&i.answerType&&o.has(i.answerType)||i.applyChunk(t,r,e,n)&&s.push(i.id));return s},Re=(e,t)=>{var s;const n=e.answer_type;if(!n)return;const o=((t==null?void 0:t.parsers)??[]).find(a=>a.answerType===n&&!!a.normalizeReport)??E.find(a=>a.answerType===n&&!!a.normalizeReport);(s=o==null?void 0:o.normalizeReport)==null||s.call(o,e,t)},M=(e,t="",n="",r)=>{var a;const o=(e==null?void 0:e.values)??e;if((a=o==null?void 0:o.answer)!=null&&a.reports){const i=o;for(const c of i.answer.reports)Re(c,r);return i}const s=K(t,n);return typeof o=="string"&&I({mode:"knowledge_stream",value:o},s.answer.reports,s,r),s},it={User:"user",Assistant:"assistant"};let ct=0;const N=(e="msg")=>`${e}-${++ct}`,Te=e=>{const t=e.trim();if(!t||t==="[DONE]")return null;const n=t.replace(/^data:\s*/,"");try{return JSON.parse(n)}catch{try{return JSON.parse(decodeURIComponent(n))}catch{return null}}},Ie=()=>{let e="";return{push(t){const n=(e+t).split(`
2
+ `);return e=n.pop()||"",n},flush(){const t=e;return e="",t?[t]:[]}}},$e=30,lt=/[A-Za-z]:[\\/][^\s"'`,。;;、,()()【】\[\]<>|?*]*/g,ut=/\\\\[^\s"'`,。;;、,()()【】\[\]<>|?*]+/g,dt=/(^|[\s"'`((【\[::,,、])((?:\/[^\s"'`,。;;、,()()【】\[\]<>|?*\/]+){2,})/g,ft=/^(?:请帮忙|请帮我|帮我看看|帮我把|帮我|帮忙|请把|麻烦你|麻烦|劳驾|请你|请问|帮(?!助))\s*[::,,、\-—]?\s*/,R=e=>{const t=e.split(/[\\/]+/).filter(Boolean);return t.length?t[t.length-1]:""},mt=e=>e.replace(ut,t=>R(t)).replace(lt,t=>R(t)).replace(dt,(t,n,r)=>n+R(r)),pt=e=>{let t=String(e??"").replace(/\r\n|\r|\n/g," ").replace(/\s+/g," ").trim();if(!t)return"";t=mt(t).replace(/\s+/g," ").trim();let n="";for(;n!==t;)n=t,t=t.replace(ft,"").trim(),t=t.replace(/^[::,,、\-—\s]+/,"").trim();return t.slice(0,$e)},yt=async(e,t)=>{const n=e.getReader(),r=new TextDecoder,o=Ie(),s=a=>{const i=Te(a);i&&t(i)};try{for(;;){const{done:a,value:i}=await n.read();if(a)break;o.push(r.decode(i,{stream:!0})).forEach(s)}o.flush().forEach(s)}catch(a){throw await n.cancel().catch(()=>{}),a}finally{n.releaseLock()}},v=new Set(["png","jpg","jpeg","gif","webp","svg","bmp"]),L=e=>!e||isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,ht=e=>{var r;if(e.type&&e.type!=="file")return!1;const t=e.attachContent||{};if(t.groupType==="image")return!0;const n=(t.suffix||((r=e.name)!=null&&r.includes(".")?e.name.split(".").pop():"")||"").toLowerCase();return!!(v.has(n)||t.raw&&typeof t.raw.type=="string"&&t.raw.type.startsWith("image/"))},je=(e,t,n)=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?e:`${(t||"").replace(/\/$/,"")}${n}?file_id=${e}`,Pe=(e,t="",n)=>e?n?n(e):je(e,t,"/file/download_file"):"",gt=(e,t="",n)=>{const r=e.attachContent||{};return r.url?r.url:typeof r.fileContent=="string"&&r.fileContent.startsWith("data:image/")?r.fileContent:r.fileId?Pe(r.fileId,t,n):""},T=e=>{var i;const t=(e==null?void 0:e.name)||"",n=t.includes(".")&&((i=t.split(".").pop())==null?void 0:i.toLowerCase())||"",r=v.has(n)||(e==null?void 0:e.type)&&typeof e.type=="string"&&e.type.startsWith("image/");let o;if(r&&typeof window<"u"&&typeof URL<"u"&&e instanceof Blob)try{o=URL.createObjectURL(e)}catch{o=void 0}const s=L(e==null?void 0:e.size),a=[n.toUpperCase(),s].filter(Boolean).join(" · ");return{type:"file",name:t,description:a,attachContent:{file_name:t,size:e==null?void 0:e.size,suffix:n,raw:e,url:o,groupType:r?"image":"file"}}},H=e=>{var s;const t=(e==null?void 0:e.file_name)??(e==null?void 0:e.name)??(e==null?void 0:e.title)??"",n=t.includes(".")&&((s=t.split(".").pop())==null?void 0:s.toLowerCase())||"",r=v.has(n)||(e==null?void 0:e.groupType)==="image",o=n?n.toUpperCase():"";return{type:"file",name:t,description:o,attachContent:{file_name:(e==null?void 0:e.file_name)??t,fileId:(e==null?void 0:e.file_id)??(e==null?void 0:e.id),fileContent:e==null?void 0:e.file_content,suffix:n,groupType:r?"image":"file"}}},ke=e=>{var r,o,s,a;const t=(e==null?void 0:e.values)??e,n=((r=t==null?void 0:t.attach)==null?void 0:r.files)??((s=(o=t==null?void 0:t.answer)==null?void 0:o.attach)==null?void 0:s.files)??(t==null?void 0:t.attach_files)??((a=t==null?void 0:t.answer)==null?void 0:a.attach_files)??[];return!Array.isArray(n)||n.length===0?[]:n.map(i=>H(i))},wt=e=>{var r,o;if(!e)return{type:"file",name:"",description:"",attachContent:{}};if(typeof Blob<"u"&&e instanceof Blob)return T(e);if(typeof e=="object"&&e.attachContent){const s=e.type||"file",a=e.name||e.attachContent.file_name||e.attachContent.name||"";let i=e.description||"";const c={...e.attachContent};if(s==="file"&&(!c.suffix&&a.includes(".")&&(c.suffix=((r=a.split(".").pop())==null?void 0:r.toLowerCase())||""),(c.groupType==="image"||c.suffix&&v.has(c.suffix.toLowerCase())||c.raw&&typeof c.raw.type=="string"&&c.raw.type.startsWith("image/"))&&(c.groupType="image"),!i)){const l=typeof c.size=="number"?L(c.size):c.size||"";i=[c.suffix?c.suffix.toUpperCase():"",l].filter(Boolean).join(" · ")}return{...e,type:s,name:a,description:i,attachContent:c}}if(e.file_id||e.fileId)return H(e);if(e.raw&&typeof Blob<"u"&&e.raw instanceof Blob){const s=T(e.raw);return{...s,...e,attachContent:{...s.attachContent,...e.attachContent}}}const t=e.name||e.title||"",n=t.includes(".")&&((o=t.split(".").pop())==null?void 0:o.toLowerCase())||"";return{type:e.type||"file",name:t,description:e.description||(n?n.toUpperCase():""),attachContent:{file_name:t,suffix:n,...e}}},D=e=>ke(e),bt=async e=>[...(await e.getHistoryGroups()).groups??[]].sort((r,o)=>String(o.create_time??"").localeCompare(String(r.create_time??""))),vt=async(e,t)=>{const n=await e.createHistoryGroup(t),r=(n==null?void 0:n.group_id)??(n==null?void 0:n.history_group_id)??"";if(!r)throw new Error("创建对话分组失败");return r},_t=(e,t)=>e.deleteHistoryGroup(t),zt=(e,t,n)=>e.setHistoryGroupTitle(t,n),Oe=5,xe=async(e,t,n)=>{const r=new Array(e.length);let o=0;const s=Array.from({length:Math.min(t,e.length)},async()=>{for(;o<e.length;){const a=o++;r[a]=await n(e[a],a)}});return await Promise.all(s),r},At=async(e,t,n=10,r=0,o)=>{if(!t)return[];const a=[...await e.getHistoryDetail(t,r,n)].sort((u,l)=>String(u.create_time||"").localeCompare(String(l.create_time||""))),i=await xe(a,Oe,async u=>{try{return await e.getHistoryAnswer(u.history_id||"")}catch{return null}}),c=[];return a.forEach((u,l)=>{const m=u.history_id||N("h"),d=i[l],f=d!=null?D(d):[];if(c.push({id:m,historyId:u.history_id,role:"user",content:u.question??"",attachments:f.length>0?f:void 0}),d!=null){const p=M(d,m,u.question??"",o);c.push({id:`${m}-answer`,historyId:u.history_id,role:"assistant",answer:p,error:!1,stopped:!1,thinking:{steps:$(p),expanded:!1}})}}),c},Et=async(e,t,n=10,r,o=0,s)=>{if(!t)return r==null||r({type:"users",users:[]}),[];const i=[...await e.getHistoryDetail(t,o,n)].sort((d,f)=>String(d.create_time||"").localeCompare(String(f.create_time||""))),c=i.map(d=>d.history_id||N("h")),u=i.map((d,f)=>({id:c[f],historyId:d.history_id,role:"user",content:d.question??""}));r==null||r({type:"users",users:u});const l=new Array(i.length).fill(null);await xe(i,Oe,async(d,f)=>{let p=null;try{p=await e.getHistoryAnswer(d.history_id||"")}catch{p=null}if(p==null)return;const B=D(p);B.length>0&&(u[f].attachments=B);const U=M(p,c[f],d.question??"",s),W={id:`${c[f]}-answer`,historyId:d.history_id,role:"assistant",answer:U,error:!1,stopped:!1,thinking:{steps:$(U),expanded:!1}};l[f]=W,r==null||r({type:"assistant",index:f,user:u[f],assistant:W})});const m=[];return i.forEach((d,f)=>{m.push(u[f]);const p=l[f];p&&m.push(p)}),m};exports.AGENT_ACTION_ANSWER_TYPE=S;exports.CHAT_TITLE_MAX_LENGTH=$e;exports.COLLECT_CLARIFICATIONS_ANSWER_TYPE=x;exports.IFRAME_RESIZER_CHILD_SCRIPT=Le;exports.IMAGE_EXTENSIONS=v;exports.OUTPUT_FILE_ANSWER_TYPE=w;exports.RECORDSET_ANSWER_TYPE=z;exports.RoleEnum=it;exports.agentActionParser=Ce;exports.applyAgentActionChunk=Ee;exports.applyAnswerChunk=at;exports.applyCollectClarificationsChunk=_e;exports.applyDeepThinkingChunk=F;exports.applyIframePageChunk=re;exports.applyKnowledgeStreamChunk=I;exports.applyOutputFileChunk=ue;exports.applyRecordsetChunk=ie;exports.buildChatTitle=pt;exports.cancelClarification=et;exports.clearPendingClarifications=tt;exports.collectClarificationsParser=Ae;exports.collectDeepThinkingSteps=Q;exports.collectThinkingSteps=$;exports.consumeStream=yt;exports.createEmptyAnswerValues=K;exports.createFailureResult=h;exports.createHistoryGroup=vt;exports.createLineSplitter=Ie;exports.deepThinkingParser=ee;exports.deleteHistoryGroup=_t;exports.extractAttachmentsFromHistory=D;exports.extractHistoryAttachments=ke;exports.formatFileSize=L;exports.getHistoryGroups=bt;exports.hasPendingClarification=Fe;exports.iframePageParser=se;exports.injectIframeResizerScript=j;exports.isImageAttachment=ht;exports.knowledgeStreamParser=J;exports.loadGroupMessages=At;exports.loadGroupMessagesByStep=Et;exports.nextClarificationRequestId=he;exports.nextLocalMessageId=N;exports.normalizeActionDefinition=Xe;exports.normalizeActionResult=pe;exports.normalizeAgentActionReport=Se;exports.normalizeAnswer=M;exports.normalizeAnswerReport=Re;exports.normalizeAttachment=wt;exports.normalizeCollectClarificationsReport=ze;exports.normalizeIframePageReport=oe;exports.normalizeKnowledgeStreamReport=V;exports.normalizeOutputFileReport=de;exports.normalizeRecordsetReport=ce;exports.outputFileParser=fe;exports.parseActionExecuteCommand=me;exports.parseClarificationArguments=ye;exports.parseHistoryAttachment=H;exports.parseRealtimeAttachment=T;exports.parseSseLine=Te;exports.readFrontReplyAction=k;exports.readOutputFilePayload=P;exports.readRecordsetPayload=ae;exports.recordsetParser=le;exports.registerClarification=ge;exports.resolveAttachDownloadUrl=Pe;exports.resolveAttachPreviewUrl=gt;exports.resolveRemoteFileUrl=je;exports.setHistoryGroupTitle=zt;exports.submitClarification=Qe;exports.wrapActionFrame=Ge;
3
3
  //# sourceMappingURL=index.cjs.map
@@ -15,8 +15,8 @@
15
15
  * - `./answerCom/iframePage`:iframe 页面(applyIframePageChunk / 注入 child 脚本 / types)
16
16
  * - `./answerCom/recordset`:记录集表格(applyRecordsetChunk / normalizeRecordsetReport / types)
17
17
  * - `./answerCom/outputFile`:输出文件(applyOutputFileChunk / normalizeOutputFileReport / types)
18
- * - `./answerCom/actionExecute`:front_reply 指令(action_execute:host 执行器 + 确认卡片
19
- * collect_clarifications;parseActionExecute / actionProtocol / clarification / types)
18
+ * - `./answerCom/actionExecute`:front_reply 内的 action_execute 指令——
19
+ * host 端 collect_clarifications(确认卡片)/ agent 端指令执行过程(进度卡片)
20
20
  * - `./deepThinking`:思考(applyDeepThinkingChunk / collectDeepThinkingSteps / types)
21
21
  * - `./history`:历史分组与会话的业务逻辑(依赖 wi-chat-request)
22
22
  *
@@ -43,11 +43,13 @@ export { RECORDSET_ANSWER_TYPE, readRecordsetPayload, applyRecordsetChunk, norma
43
43
  export type { RecordsetColumn, RecordsetValue } from './answerCom/recordset/types';
44
44
  export { OUTPUT_FILE_ANSWER_TYPE, readOutputFilePayload, applyOutputFileChunk, normalizeOutputFileReport, outputFileParser } from './answerCom/outputFile/parseOutputFile';
45
45
  export type { OutputFileValue } from './answerCom/outputFile/types';
46
- export { ACTION_EXECUTE_ANSWER_TYPE, applyActionExecuteChunk, normalizeActionExecuteReport, actionExecuteParser } from './answerCom/actionExecute/parseActionExecute';
47
- export { createFailureResult, normalizeActionResult, parseActionExecuteCommand, wrapActionFrame, normalizeActionDefinition } from './answerCom/actionExecute/actionProtocol';
46
+ export { COLLECT_CLARIFICATIONS_ANSWER_TYPE, applyCollectClarificationsChunk, normalizeCollectClarificationsReport, collectClarificationsParser } from './answerCom/actionExecute/parseCollectClarifications';
47
+ export { AGENT_ACTION_ANSWER_TYPE, applyAgentActionChunk, normalizeAgentActionReport, agentActionParser } from './answerCom/actionExecute/parseAgentAction';
48
+ export { createFailureResult, normalizeActionResult, parseActionExecuteCommand, wrapActionFrame, normalizeActionDefinition, readFrontReplyAction } from './answerCom/actionExecute/actionProtocol';
49
+ export type { FrontReplyActionResult } from './answerCom/actionExecute/actionProtocol';
48
50
  export { parseClarificationArguments, nextClarificationRequestId, registerClarification, hasPendingClarification, submitClarification, cancelClarification, clearPendingClarifications } from './answerCom/actionExecute/clarification';
49
51
  export type { ParsedClarificationArguments } from './answerCom/actionExecute/clarification';
50
- export type { ActionExecutor, ActionDefinition, ActionExecuteCommand, ActionResult, WaitReplyPayload, FrontReplyOptions, ClarificationInputType, ClarificationAnswerMode, ClarificationOption, ClarificationBinding, ClarificationInput, ClarificationItem, ClarificationAnswer, ClarificationStatus, ClarificationViewModel, } from './answerCom/actionExecute/types';
52
+ export type { ActionExecutor, ActionDefinition, ActionExecuteCommand, ActionResult, WaitReplyPayload, ActionExecuteOptions, AgentActionStatus, AgentActionValue, ClarificationInputType, ClarificationAnswerMode, ClarificationOption, ClarificationBinding, ClarificationInput, ClarificationItem, ClarificationAnswer, ClarificationStatus, ClarificationViewModel, } from './answerCom/actionExecute/types';
51
53
  export { applyDeepThinkingChunk, collectDeepThinkingSteps, collectThinkingSteps, deepThinkingParser } from './deepThinking/parseDeepThinking';
52
54
  export type { ExecProcessItem } from './deepThinking/types';
53
55
  export { extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep } from './history';